Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(sheets-drawing-ui): sheet-drawing-import (#3277)
zhangw183b3e0526c6
diff --git a/packages/drawing-ui/src/controllers/image-update.controller.ts b/packages/drawing-ui/src/controllers/image-update.controller.tsindex acf404a10f..8bb26b02f8 100644--- a/packages/drawing-ui/src/controllers/image-update.controller.ts+++ b/packages/drawing-ui/src/controllers/image-update.controller.ts@@ -23,7 +23,6 @@ import {LifecycleStages,OnLifecycle,toDisposable,- UniverInstanceType,} from '@univerjs/core';import type { Image, Scene } from '@univerjs/engine-render';import { CURSOR_TYPE, IRenderManagerService } from '@univerjs/engine-render';@@ -58,8 +57,6 @@ export class ImageUpdateController extends Disposable {}private _initialize() {- this._recoveryImages();-this._drawingAddListener();this._commandExecutedListener();@@ -67,35 +64,6 @@ export class ImageUpdateController extends Disposable {this._imageUpdateListener();}- private _recoveryImages() {- const drawingList = this._drawingManagerService.drawingManagerData;- const info = getCurrentUnitInfo(this._currentUniverService);- if (info == null) {- return;- }-- const { unitId: currentUnitId, subUnitId: currentSubUnitId, current } = info;-- if (current.type === UniverInstanceType.UNIVER_DOC) {- return;- }-- Object.keys(drawingList).forEach((unitId) => {- Object.keys(drawingList[unitId]).forEach((subUnitId) => {- const drawingMap = drawingList[unitId][subUnitId].data;- if (drawingMap == null || unitId !== currentUnitId || subUnitId !== currentSubUnitId) {- return;- }- Object.keys(drawingMap).forEach((drawingId) => {- const drawing = drawingMap[drawingId];- if (drawing) {- this._insertImages([{ unitId, subUnitId, drawingId }]);- }- });- });- });- }-private _commandExecutedListener() {this.disposeWithMe(this._commandService.onCommandExecuted((command: ICommandInfo) => {diff --git a/packages/sheets-drawing-ui/src/controllers/render-controllers/sheet-drawing.render-controller.ts b/packages/sheets-drawing-ui/src/controllers/render-controllers/sheet-drawing.render-controller.tsindex cb6bf4745e..ef59325535 100644--- a/packages/sheets-drawing-ui/src/controllers/render-controllers/sheet-drawing.render-controller.ts+++ b/packages/sheets-drawing-ui/src/controllers/render-controllers/sheet-drawing.render-controller.ts@@ -14,18 +14,21 @@* limitations under the License.*/-import { Disposable, Inject, LifecycleService, LifecycleStages, UniverInstanceType } from '@univerjs/core';+import { Disposable, Inject, LifecycleService, UniverInstanceType } from '@univerjs/core';import { IDrawingManagerService } from '@univerjs/drawing';import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';import { ISheetDrawingService } from '@univerjs/sheets-drawing';-import { filter, first } from 'rxjs';+import { ISheetSelectionRenderService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';+import { drawingPositionToTransform } from '../../basics/transform-position';export class SheetsDrawingRenderController extends Disposable implements IRenderModule {constructor(private _context: IRenderContext,@ISheetDrawingService private readonly _sheetDrawingService: ISheetDrawingService,@IDrawingManagerService private readonly _drawingManagerService: IDrawingManagerService,- @Inject(LifecycleService) private _lifecycleService: LifecycleService+ @Inject(LifecycleService) private _lifecycleService: LifecycleService,+ @Inject(ISheetSelectionRenderService) private _sheetSelectionRenderService: ISheetSelectionRenderService,+ @Inject(SheetSkeletonManagerService) private _sheetSkeletonManagerService: SheetSkeletonManagerService) {super();@@ -37,11 +40,20 @@ export class SheetsDrawingRenderController extends Disposable implements IRender}private _drawingInitializeListener() {- this._lifecycleService.lifecycle$.pipe(filter((e) => e === LifecycleStages.Steady), first()).subscribe(() => {- if (this._context.type === UniverInstanceType.UNIVER_SHEET) {- this._sheetDrawingService.initializeNotification(this._context.unitId);- this._drawingManagerService.initializeNotification(this._context.unitId);+ // initialize drawing data and add to sheet canvas+ if (this._context.type === UniverInstanceType.UNIVER_SHEET) {+ this._sheetDrawingService.initializeNotification(this._context.unitId);+ const data = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);+ for (const subUnit in data) {+ const subUnitData = data[subUnit];+ for (const drawingId in subUnitData.data) {+ const drawingData = subUnitData.data[drawingId];+ drawingData.transform = drawingPositionToTransform(drawingData.sheetTransform, this._sheetSelectionRenderService, this._sheetSkeletonManagerService);+ }}- });++ this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId));+ this._drawingManagerService.initializeNotification(this._context.unitId);+ }}}