diff --git a/packages/docs-drawing/src/controllers/doc-drawing.controller.ts b/packages/docs-drawing/src/controllers/doc-drawing.controller.ts index 36c5fb00d47..224a1776abb 100644 --- a/packages/docs-drawing/src/controllers/doc-drawing.controller.ts +++ b/packages/docs-drawing/src/controllers/doc-drawing.controller.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import type { DocumentDataModel, IDocumentData } from '@univerjs/core'; import { Disposable, ICommandService, IResourceManagerService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core'; -import type { IDrawingMapItem, IDrawingMapItemData } from '@univerjs/drawing'; import { IDrawingManagerService } from '@univerjs/drawing'; +import type { DocumentDataModel, IDocumentData } from '@univerjs/core'; +import type { IDrawingMapItem, IDrawingMapItemData } from '@univerjs/drawing'; import { type IDocDrawing, IDocDrawingService } from '../services/doc-drawing.service'; export const DOCS_DRAWING_PLUGIN = 'DOC_DRAWING_PLUGIN'; @@ -51,9 +51,16 @@ export class DocDrawingController extends Disposable { private _initSnapshot() { const toJson = (unitId: string) => { - const map = this._docDrawingService.getDrawingDataForUnit(unitId); - if (map?.[unitId]) { - return JSON.stringify(map?.[unitId]); + const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC); + if (doc) { + const drawings = doc.getSnapshot().drawings; + const drawingOrder = doc.getSnapshot().drawingsOrder; + const data: IDrawingMapItem = { + data: drawings ?? {}, + order: drawingOrder ?? [], + + }; + return JSON.stringify(data); } return ''; };