Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docs-drawing): drawing resource #3410

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions packages/docs-drawing/src/controllers/doc-drawing.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<DocumentDataModel>(unitId, UniverInstanceType.UNIVER_DOC);
if (doc) {
const drawings = doc.getSnapshot().drawings;
const drawingOrder = doc.getSnapshot().drawingsOrder;
const data: IDrawingMapItem<IDocDrawing> = {
data: drawings ?? {},
order: drawingOrder ?? [],

};
return JSON.stringify(data);
}
return '';
};
Expand Down
Loading