Skip to content

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.

fix(drawing): fix the issue of cut and delete float image (#6215)

wpxp123456cc3be1518066
diff --git a/packages/engine-render/src/scene.transformer.ts b/packages/engine-render/src/scene.transformer.ts
index a06e1e4d27..9eb8341af1 100644
--- a/packages/engine-render/src/scene.transformer.ts
+++ b/packages/engine-render/src/scene.transformer.ts
@@ -258,10 +258,6 @@ export class Transformer extends Disposable implements ITransformerConfig {
}
clearSelectedObjects() {
- if (this._selectedObjectMap.size === 0) {
- return;
- }
-
this._selectedObjectMap.clear();
this._cancelFocusSubscription?.unsubscribe();
this._cancelFocusSubscription = null;
diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-copy-paste.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-copy-paste.controller.ts
index fb3257a598..278fdc3e1a 100644
--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-copy-paste.controller.ts
+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-copy-paste.controller.ts
@@ -120,11 +120,17 @@ export class SheetsDrawingCopyPasteController extends Disposable {
id: 'SHEET_IMAGE_UI_PLUGIN',
onBeforeCopy: (unitId, subUnitId, range, copyType) => {
+ this._copyInfo = null;
+
const focusDrawings = this._focusedDrawings;
if (focusDrawings.length > 0) {
// handle single drawing copy
const [drawing] = focusDrawings;
+ if (drawing.drawingType !== DrawingTypeEnum.DRAWING_IMAGE) {
+ return;
+ }
+
if (copyType === COPY_TYPE.CUT) {
const params: IDeleteDrawingCommandParams = {
unitId,
@@ -228,6 +234,9 @@ export class SheetsDrawingCopyPasteController extends Disposable {
Object.keys(drawings).forEach((drawingId) => {
const drawing = drawings[drawingId];
+ if (drawing.drawingType !== DrawingTypeEnum.DRAWING_IMAGE) {
+ return;
+ }
const { transform } = drawing;
if ((drawing as ISheetDrawing).anchorType !== SheetDrawingAnchorType.Both) {
return;
diff --git a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts b/packages/sheets-ui/src/services/clipboard/clipboard.service.ts
index 93dfc027b0..a78032dd61 100644
--- a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts
+++ b/packages/sheets-ui/src/services/clipboard/clipboard.service.ts
@@ -136,7 +136,7 @@ export interface ISheetClipboardService {
rePasteWithPasteType(type: IPasteHookKeyType): boolean;
disposePasteOptionsCache(): void;
- generateCopyContent(workbookId: string, worksheetId: string, range: IRange): Nullable<ICopyContent>;
+ generateCopyContent(workbookId: string, worksheetId: string, range: IRange, copyType?: COPY_TYPE): Nullable<ICopyContent>;
copyContentCache(): CopyContentCache; // return the cache content for inner copy/cut/paste.
addClipboardHook(hook: ISheetClipboardHook): IDisposable; // add a hook to the clipboard service
getClipboardHooks(): ISheetClipboardHook[]; // get all hooks
@@ -239,7 +239,7 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard
const workbookId = workbook.getUnitId();
const worksheetId = worksheet.getSheetId();
- const copyContent = this.generateCopyContent(workbookId, worksheetId, selection.range);
+ const copyContent = this.generateCopyContent(workbookId, worksheetId, selection.range, copyType);
if (!copyContent) {
return false;