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
refactor: drawing commands support interceptors (#3924)
YuHong68cd2380e768
diff --git a/packages/sheets-drawing-ui/src/commands/commands/insert-sheet-drawing.command.ts b/packages/sheets-drawing-ui/src/commands/commands/insert-sheet-drawing.command.tsindex 0532defa11..a11b2eeda0 100644--- a/packages/sheets-drawing-ui/src/commands/commands/insert-sheet-drawing.command.ts+++ b/packages/sheets-drawing-ui/src/commands/commands/insert-sheet-drawing.command.ts@@ -59,17 +59,19 @@ export const InsertSheetDrawingCommand: ICommand = {const insertMutation = { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT } };const undoInsertMutation = { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.REMOVE } };- const result = sequenceExecute([insertMutation, ...intercepted.redos], commandService);+ const result = sequenceExecute([...(intercepted.preRedos ?? []), insertMutation, ...intercepted.redos], commandService);if (result) {undoRedoService.pushUndoRedo({unitID: unitId,undoMutations: [- ...intercepted.undos,+ ...(intercepted.preUndos ?? []),undoInsertMutation,+ ...(intercepted.undos),{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds },],redoMutations: [+ ...(intercepted.preRedos ?? []),insertMutation,...intercepted.redos,{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds },diff --git a/packages/sheets-drawing-ui/src/commands/commands/remove-sheet-drawing.command.ts b/packages/sheets-drawing-ui/src/commands/commands/remove-sheet-drawing.command.tsindex 75bd3a7845..51a30a8634 100644--- a/packages/sheets-drawing-ui/src/commands/commands/remove-sheet-drawing.command.ts+++ b/packages/sheets-drawing-ui/src/commands/commands/remove-sheet-drawing.command.ts@@ -61,17 +61,19 @@ export const RemoveSheetDrawingCommand: ICommand = {const removeMutation = { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.REMOVE } };const undoRemoveMutation = { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.INSERT } };- const result = sequenceExecute([removeMutation, ...intercepted.redos], commandService);+ const result = sequenceExecute([...(intercepted.preRedos ?? []), removeMutation, ...intercepted.redos], commandService);if (result) {undoRedoService.pushUndoRedo({unitID: unitId,undoMutations: [- ...intercepted.undos,+ ...(intercepted.preUndos ?? []),undoRemoveMutation,+ ...intercepted.undos,{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds },],redoMutations: [+ ...(intercepted.preRedos ?? []),removeMutation,...intercepted.redos,{ id: ClearSheetDrawingTransformerOperation.id, params: unitIds },diff --git a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.tsindex 3a211d73a6..458eb540f5 100644--- a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts+++ b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts@@ -551,7 +551,7 @@ export class SheetCanvasFloatDomManagerService extends Disposable {}}- addFloatDomToPosition(layer: ICanvasFloatDom, propId?: string, executeCommand = true) {+ addFloatDomToPosition(layer: ICanvasFloatDom, propId?: string) {const target = getSheetCommandTarget(this._univerInstanceService, {unitId: layer.unitId,subUnitId: layer.subUnitId,@@ -587,12 +587,11 @@ export class SheetCanvasFloatDomManagerService extends Disposable {data,allowTransform,};- if (executeCommand) {- this._commandService.executeCommand(InsertSheetDrawingCommand.id, {- unitId,- drawings: [sheetDrawingParam],- } as IInsertDrawingCommandParams);- }++ this._commandService.executeCommand(InsertSheetDrawingCommand.id, {+ unitId,+ drawings: [sheetDrawingParam],+ } as IInsertDrawingCommandParams);this._add$.next({ unitId, subUnitId, id });@@ -601,7 +600,6 @@ export class SheetCanvasFloatDomManagerService extends Disposable {dispose: () => {this._removeDom(id, true);},- sheetDrawingParam,};}