Skip to content

Commit

Permalink
fix: save data error (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
weird94 authored Aug 30, 2024
1 parent f58a7f2 commit c0dc254
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
24 changes: 12 additions & 12 deletions src/univer/sheets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ export function sheetInit(option: IUniverUIConfig, settings: UniverPluginSetting

async getMentions() {
return [
{
id: mockUser.userID,
label: mockUser.name,
type: 'user',
icon: mockUser.avatar,
},
{
id: '2',
label: 'User2',
type: 'user',
icon: mockUser.avatar,
},
// {
// id: mockUser.userID,
// label: mockUser.name,
// type: 'user',
// icon: mockUser.avatar,
// },
// {
// id: '2',
// label: 'User2',
// type: 'user',
// icon: mockUser.avatar,
// },
]
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/views/udoc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DocumentDataModel, IDocumentData, Univer } from '@univerjs/core'
import { Tools, UniverInstanceType } from '@univerjs/core'
import { IResourceLoaderService, Tools, UniverInstanceType } from '@univerjs/core'
import { FUniver } from '@univerjs/facade'
import type { WorkspaceLeaf } from 'obsidian'
import { TextFileView } from 'obsidian'
Expand All @@ -21,7 +21,9 @@ export class UDocView extends TextFileView {
}

getViewData(): string {
return JSON.stringify(Tools.deepClone(this.documentModal.getSnapshot()))
const resourceLoaderService = this.univer.__getInjector().get(IResourceLoaderService)
const snapshot = resourceLoaderService.saveDoc(this.documentModal)
return JSON.stringify(Tools.deepClone(snapshot))
}

setViewData(data: string): void {
Expand Down Expand Up @@ -56,7 +58,7 @@ export class UDocView extends TextFileView {
return Type
}

clear(): void {}
clear(): void { }

async onOpen() {
this.rootContainer = this.contentEl as HTMLDivElement
Expand Down
5 changes: 4 additions & 1 deletion src/views/xlsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export class XlsxTypeView extends TextFileView {
async saveToExcel(file: TFile, workbook: Workbook) {
if (!file || !workbook)
return
const saveWorkbookData = workbook.save()
const saveWorkbookData = this.FUniver.getUniverSheet(workbook.getUnitId())?.getSnapshot()
if (!saveWorkbookData) {
return
}
const snapshotJSON = await transformWorkbookDataToSnapshotJson(saveWorkbookData)
const snapshot = JSON.stringify(snapshotJSON)
// @ts-expect-error
Expand Down

0 comments on commit c0dc254

Please sign in to comment.