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(sheets-drawing-ui): use start row and col when upload image to a merged cell (#5199)

SunLiang684e7be47c1b
diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts
index 79b3b2be3b..95db45dfd6 100644
--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts
+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts
@@ -261,6 +261,14 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
if (!selection) {
return false;
}
+
+ // use start row and col when upload image to a merged cell
+ let row = selection.primary.actualRow;
+ let col = selection.primary.actualColumn;
+ if (selection.primary.isMerged) {
+ row = selection.primary.startRow;
+ col = selection.primary.startColumn;
+ }
const docDataModel = createDocumentModelWithStyle('', {});
const imageSize = getDrawingSizeByCell(
@@ -268,8 +276,8 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
{
unitId: this._context.unitId,
subUnitId: this._context.unit.getActiveSheet().getSheetId(),
- row: selection.primary.actualRow,
- col: selection.primary.actualColumn,
+ row,
+ col,
},
width,
height,
@@ -328,8 +336,8 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
return this._commandService.syncExecuteCommand(SetRangeValuesCommand.id, {
value: {
- [location?.row ?? selection.primary.actualRow]: {
- [location?.col ?? selection.primary.actualColumn]: {
+ [location?.row ?? row]: {
+ [location?.col ?? col]: {
p: (docDataModel.getSnapshot()),
t: 1,
},