From 3faf552a4ad5d55bf6a8af35f0a9254f1126752e Mon Sep 17 00:00:00 2001 From: zw Date: Thu, 12 Sep 2024 14:32:13 +0800 Subject: [PATCH] feat: update --- .../src/controllers/doc-drawing.controller.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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 ''; };