@univerjs/sheets-drawing-ui 1.0.0-alpha.7 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -125,28 +125,23 @@ function cloneGroupParams(groupParams) {
125
125
  groupParams.groups.forEach((p) => idMap.set(p.drawingId, (0, _univerjs_core.generateRandomId)(10)));
126
126
  const clonedNestedIdRecord = {};
127
127
  for (const [oldGroupId, entry] of Object.entries(groupParams.nestedIdRecord)) {
128
- var _idMap$get, _entry$children;
129
- const newGroupId = (_idMap$get = idMap.get(oldGroupId)) !== null && _idMap$get !== void 0 ? _idMap$get : oldGroupId;
128
+ var _entry$children;
129
+ const newGroupId = idMap.get(oldGroupId) ?? oldGroupId;
130
130
  clonedNestedIdRecord[newGroupId] = {
131
131
  drawingId: newGroupId,
132
- children: (_entry$children = entry.children) === null || _entry$children === void 0 ? void 0 : _entry$children.map((id) => {
133
- var _idMap$get2;
134
- return (_idMap$get2 = idMap.get(id)) !== null && _idMap$get2 !== void 0 ? _idMap$get2 : id;
135
- })
132
+ children: (_entry$children = entry.children) === null || _entry$children === void 0 ? void 0 : _entry$children.map((id) => idMap.get(id) ?? id)
136
133
  };
137
134
  }
138
135
  const flatChildren = [];
139
136
  const groups = [];
140
137
  for (const group of groupParams.groups) {
141
- var _idMap$get3, _idMap$get4;
142
- const groupDrawingId = (_idMap$get3 = idMap.get(group.drawingId)) !== null && _idMap$get3 !== void 0 ? _idMap$get3 : group.drawingId;
143
- const parentGroupId = group.groupId ? (_idMap$get4 = idMap.get(group.groupId)) !== null && _idMap$get4 !== void 0 ? _idMap$get4 : group.groupId : void 0;
138
+ const groupDrawingId = idMap.get(group.drawingId) ?? group.drawingId;
139
+ const parentGroupId = group.groupId ? idMap.get(group.groupId) ?? group.groupId : void 0;
144
140
  groups.push(cloneDrawingParam(group, groupDrawingId, parentGroupId));
145
141
  }
146
142
  for (const child of groupParams.flatChildren || []) {
147
- var _idMap$get5, _idMap$get6;
148
- const childDrawingId = (_idMap$get5 = idMap.get(child.drawingId)) !== null && _idMap$get5 !== void 0 ? _idMap$get5 : child.drawingId;
149
- const parentGroupId = child.groupId ? (_idMap$get6 = idMap.get(child.groupId)) !== null && _idMap$get6 !== void 0 ? _idMap$get6 : child.groupId : void 0;
143
+ const childDrawingId = idMap.get(child.drawingId) ?? child.drawingId;
144
+ const parentGroupId = child.groupId ? idMap.get(child.groupId) ?? child.groupId : void 0;
150
145
  flatChildren.push(cloneDrawingParam(child, childDrawingId, parentGroupId));
151
146
  }
152
147
  return {
@@ -293,7 +288,7 @@ const UngroupSheetDrawingCommand = {
293
288
  };
294
289
 
295
290
  //#endregion
296
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
291
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
297
292
  function _typeof(o) {
298
293
  "@babel/helpers - typeof";
299
294
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -304,7 +299,7 @@ function _typeof(o) {
304
299
  }
305
300
 
306
301
  //#endregion
307
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
302
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
308
303
  function toPrimitive(t, r) {
309
304
  if ("object" != _typeof(t) || !t) return t;
310
305
  var e = t[Symbol.toPrimitive];
@@ -317,14 +312,14 @@ function toPrimitive(t, r) {
317
312
  }
318
313
 
319
314
  //#endregion
320
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
315
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
321
316
  function toPropertyKey(t) {
322
317
  var i = toPrimitive(t, "string");
323
318
  return "symbol" == _typeof(i) ? i : i + "";
324
319
  }
325
320
 
326
321
  //#endregion
327
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
322
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
328
323
  function _defineProperty(e, r, t) {
329
324
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
330
325
  value: t,
@@ -335,7 +330,7 @@ function _defineProperty(e, r, t) {
335
330
  }
336
331
 
337
332
  //#endregion
338
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
333
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
339
334
  function __decorateParam(paramIndex, decorator) {
340
335
  return function(target, key) {
341
336
  decorator(target, key, paramIndex);
@@ -343,7 +338,7 @@ function __decorateParam(paramIndex, decorator) {
343
338
  }
344
339
 
345
340
  //#endregion
346
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
341
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
347
342
  function __decorate(decorators, target, key, desc) {
348
343
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
349
344
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -379,11 +374,11 @@ function rotatedBoundingBox(width, height, angleDegrees) {
379
374
  function getDrawingSizeByCell(accessor, location, originImageWidth, originImageHeight, angle) {
380
375
  var _skeletonManagerServi;
381
376
  const { rotatedHeight, rotatedWidth } = rotatedBoundingBox(originImageWidth, originImageHeight, angle);
382
- const currentRender = accessor.get(_univerjs_engine_render.IRenderManagerService).getRenderById(location.unitId);
377
+ const currentRender = accessor.get(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(location.unitId);
383
378
  if (!currentRender) return false;
384
379
  const skeleton = (_skeletonManagerServi = currentRender.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(location.subUnitId)) === null || _skeletonManagerServi === void 0 ? void 0 : _skeletonManagerServi.skeleton;
385
380
  if (skeleton == null) return false;
386
- const cellInfo = skeleton.getCellByIndex(location.row, location.col);
381
+ const cellInfo = skeleton.getCellWithCoordByIndex(location.row, location.col);
387
382
  const cellWidth = cellInfo.mergeInfo.endX - cellInfo.mergeInfo.startX - 2;
388
383
  const cellHeight = cellInfo.mergeInfo.endY - cellInfo.mergeInfo.startY - 2;
389
384
  const imageRatio = rotatedWidth / rotatedHeight;
@@ -449,7 +444,6 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
449
444
  return this._insertCellImage(file, location);
450
445
  }
451
446
  async insertFloatImageByFile(file) {
452
- var _transformToAxisAlign;
453
447
  let imageParam;
454
448
  try {
455
449
  imageParam = await this._imageIoService.saveImage(file);
@@ -496,7 +490,7 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
496
490
  source,
497
491
  transform: newTransform,
498
492
  sheetTransform,
499
- axisAlignSheetTransform: (_transformToAxisAlign = (0, _univerjs_sheets_drawing.transformToAxisAlignPosition)(newTransform, skeleton)) !== null && _transformToAxisAlign !== void 0 ? _transformToAxisAlign : sheetTransform
493
+ axisAlignSheetTransform: (0, _univerjs_sheets_drawing.transformToAxisAlignPosition)(newTransform, skeleton) ?? sheetTransform
500
494
  };
501
495
  return this._commandService.executeCommand(_univerjs_sheets_drawing.InsertSheetDrawingCommand.id, {
502
496
  unitId,
@@ -572,10 +566,9 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
572
566
  }
573
567
  });
574
568
  if (jsonXActions) {
575
- var _location$row, _location$col;
576
569
  docDataModel.apply(jsonXActions);
577
570
  return this._commandService.syncExecuteCommand(_univerjs_sheets.SetRangeValuesCommand.id, {
578
- value: { [(_location$row = location === null || location === void 0 ? void 0 : location.row) !== null && _location$row !== void 0 ? _location$row : row]: { [(_location$col = location === null || location === void 0 ? void 0 : location.col) !== null && _location$col !== void 0 ? _location$col : col]: {
571
+ value: { [(location === null || location === void 0 ? void 0 : location.row) ?? row]: { [(location === null || location === void 0 ? void 0 : location.col) ?? col]: {
579
572
  p: docDataModel.getSnapshot(),
580
573
  t: 1
581
574
  } } },
@@ -634,10 +627,9 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
634
627
  }
635
628
  });
636
629
  if (jsonXActions) {
637
- var _location$row2, _location$col2;
638
630
  docDataModel.apply(jsonXActions);
639
631
  return this._commandService.syncExecuteCommand(_univerjs_sheets.SetRangeValuesCommand.id, {
640
- value: { [(_location$row2 = location === null || location === void 0 ? void 0 : location.row) !== null && _location$row2 !== void 0 ? _location$row2 : selection.primary.actualRow]: { [(_location$col2 = location === null || location === void 0 ? void 0 : location.col) !== null && _location$col2 !== void 0 ? _location$col2 : selection.primary.actualColumn]: {
632
+ value: { [(location === null || location === void 0 ? void 0 : location.row) ?? selection.primary.actualRow]: { [(location === null || location === void 0 ? void 0 : location.col) ?? selection.primary.actualColumn]: {
641
633
  p: docDataModel.getSnapshot(),
642
634
  t: 1
643
635
  } } },
@@ -889,20 +881,17 @@ const InsertFloatImageCommand = {
889
881
  if (files) {
890
882
  const awaitFiles = files.map((file) => sheetDrawingUpdateController.insertFloatImageByFile(file));
891
883
  return (await Promise.all(awaitFiles)).every((result) => result);
892
- } else {
893
- var _sheetDrawingUpdateCo;
894
- return (_sheetDrawingUpdateCo = sheetDrawingUpdateController.insertFloatImage()) !== null && _sheetDrawingUpdateCo !== void 0 ? _sheetDrawingUpdateCo : false;
895
- }
884
+ } else return sheetDrawingUpdateController.insertFloatImage() ?? false;
896
885
  }
897
886
  };
898
887
  const InsertCellImageCommand = {
899
888
  id: "sheet.command.insert-cell-image",
900
889
  type: _univerjs_core.CommandType.COMMAND,
901
890
  handler: (accessor) => {
902
- var _getCurrentTypeOfRend2, _getCurrentTypeOfRend3;
891
+ var _getCurrentTypeOfRend2;
903
892
  const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
904
893
  const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
905
- return (_getCurrentTypeOfRend2 = (_getCurrentTypeOfRend3 = (0, _univerjs_engine_render.getCurrentTypeOfRenderer)(_univerjs_core.UniverInstanceType.UNIVER_SHEET, univerInstanceService, renderManagerService)) === null || _getCurrentTypeOfRend3 === void 0 ? void 0 : _getCurrentTypeOfRend3.with(SheetDrawingUpdateController).insertCellImage()) !== null && _getCurrentTypeOfRend2 !== void 0 ? _getCurrentTypeOfRend2 : false;
894
+ return ((_getCurrentTypeOfRend2 = (0, _univerjs_engine_render.getCurrentTypeOfRenderer)(_univerjs_core.UniverInstanceType.UNIVER_SHEET, univerInstanceService, renderManagerService)) === null || _getCurrentTypeOfRend2 === void 0 ? void 0 : _getCurrentTypeOfRend2.with(SheetDrawingUpdateController).insertCellImage()) ?? false;
906
895
  }
907
896
  };
908
897
 
@@ -991,20 +980,14 @@ function rangeToA1Notation(range) {
991
980
  return start === end ? start : `${start}:${end}`;
992
981
  }
993
982
  /**
994
- * Check if a cell has image
995
- */
996
- function cellHasImage$1(cell) {
997
- var _cell$p, _cell$p2;
998
- return !!((cell === null || cell === void 0 || (_cell$p = cell.p) === null || _cell$p === void 0 || (_cell$p = _cell$p.drawingsOrder) === null || _cell$p === void 0 ? void 0 : _cell$p.length) && (cell === null || cell === void 0 || (_cell$p2 = cell.p) === null || _cell$p2 === void 0 || (_cell$p2 = _cell$p2.drawingsOrder) === null || _cell$p2 === void 0 ? void 0 : _cell$p2.length) > 0);
999
- }
1000
- /**
1001
983
  * Get image data from cell
1002
984
  */
1003
985
  function getCellImageData(cell) {
1004
- var _cell$p3, _cell$p4;
1005
- if (!((_cell$p3 = cell.p) === null || _cell$p3 === void 0 || (_cell$p3 = _cell$p3.drawingsOrder) === null || _cell$p3 === void 0 ? void 0 : _cell$p3.length) || !((_cell$p4 = cell.p) === null || _cell$p4 === void 0 ? void 0 : _cell$p4.drawings)) return null;
1006
- const drawingId = cell.p.drawingsOrder[0];
1007
- const drawing = cell.p.drawings[drawingId];
986
+ var _documentData$drawing;
987
+ const documentData = cell.p;
988
+ const drawingId = documentData === null || documentData === void 0 || (_documentData$drawing = documentData.drawingsOrder) === null || _documentData$drawing === void 0 ? void 0 : _documentData$drawing[0];
989
+ if (!(0, _univerjs_sheets.isCellImage)(documentData) || !drawingId || !(documentData === null || documentData === void 0 ? void 0 : documentData.drawings)) return null;
990
+ const drawing = documentData.drawings[drawingId];
1008
991
  if (!drawing || !("source" in drawing) || !("imageSourceType" in drawing)) return null;
1009
992
  return drawing;
1010
993
  }
@@ -1038,12 +1021,6 @@ let BatchSaveImagesService = class BatchSaveImagesService extends _univerjs_core
1038
1021
  this._imageIoService = _imageIoService;
1039
1022
  this._urlImageService = _urlImageService;
1040
1023
  }
1041
- /**
1042
- * @deprecated Use IURLImageService directly
1043
- */
1044
- registerURLImageDownloader(downloader) {
1045
- return this._urlImageService.registerURLImageDownloader(downloader);
1046
- }
1047
1024
  getCellImagesInSelection() {
1048
1025
  const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
1049
1026
  if (!workbook) return [];
@@ -1057,7 +1034,7 @@ let BatchSaveImagesService = class BatchSaveImagesService extends _univerjs_core
1057
1034
  const { startRow, endRow, startColumn, endColumn } = selection.range;
1058
1035
  for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) {
1059
1036
  const cell = cellMatrix.getValue(row, col);
1060
- if (cellHasImage$1(cell)) {
1037
+ if ((0, _univerjs_sheets.isCellImage)(cell === null || cell === void 0 ? void 0 : cell.p)) {
1061
1038
  const imageData = getCellImageData(cell);
1062
1039
  if (imageData) images.push({
1063
1040
  row,
@@ -1083,7 +1060,7 @@ let BatchSaveImagesService = class BatchSaveImagesService extends _univerjs_core
1083
1060
  const { startRow, endRow, startColumn, endColumn } = range;
1084
1061
  for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) {
1085
1062
  const cell = cellMatrix.getValue(row, col);
1086
- if (cellHasImage$1(cell)) {
1063
+ if ((0, _univerjs_sheets.isCellImage)(cell === null || cell === void 0 ? void 0 : cell.p)) {
1087
1064
  const imageData = getCellImageData(cell);
1088
1065
  if (imageData) images.push({
1089
1066
  row,
@@ -1121,8 +1098,8 @@ let BatchSaveImagesService = class BatchSaveImagesService extends _univerjs_core
1121
1098
  for (let row = minRow; row <= maxRow; row++) {
1122
1099
  const cell = cellMatrix.getValue(row, col);
1123
1100
  if (cell) {
1124
- var _cell$v, _cell$p5;
1125
- if (((_cell$v = cell.v) === null || _cell$v === void 0 ? void 0 : _cell$v.toString()) || ((_cell$p5 = cell.p) === null || _cell$p5 === void 0 || (_cell$p5 = _cell$p5.body) === null || _cell$p5 === void 0 || (_cell$p5 = _cell$p5.dataStream) === null || _cell$p5 === void 0 ? void 0 : _cell$p5.trim()) || "") {
1101
+ var _cell$v, _cell$p;
1102
+ if (((_cell$v = cell.v) === null || _cell$v === void 0 ? void 0 : _cell$v.toString()) || ((_cell$p = cell.p) === null || _cell$p === void 0 || (_cell$p = _cell$p.body) === null || _cell$p === void 0 || (_cell$p = _cell$p.dataStream) === null || _cell$p === void 0 ? void 0 : _cell$p.trim()) || "") {
1126
1103
  columnsWithData.add(col);
1127
1104
  break;
1128
1105
  }
@@ -1158,8 +1135,8 @@ let BatchSaveImagesService = class BatchSaveImagesService extends _univerjs_core
1158
1135
  for (let row = minRow; row <= maxRow; row++) {
1159
1136
  const cell = cellMatrix.getValue(row, col);
1160
1137
  if (cell) {
1161
- var _cell$v2, _cell$p6;
1162
- if (((_cell$v2 = cell.v) === null || _cell$v2 === void 0 ? void 0 : _cell$v2.toString()) || ((_cell$p6 = cell.p) === null || _cell$p6 === void 0 || (_cell$p6 = _cell$p6.body) === null || _cell$p6 === void 0 || (_cell$p6 = _cell$p6.dataStream) === null || _cell$p6 === void 0 ? void 0 : _cell$p6.trim()) || "") {
1138
+ var _cell$v2, _cell$p2;
1139
+ if (((_cell$v2 = cell.v) === null || _cell$v2 === void 0 ? void 0 : _cell$v2.toString()) || ((_cell$p2 = cell.p) === null || _cell$p2 === void 0 || (_cell$p2 = _cell$p2.body) === null || _cell$p2 === void 0 || (_cell$p2 = _cell$p2.dataStream) === null || _cell$p2 === void 0 ? void 0 : _cell$p2.trim()) || "") {
1163
1140
  columnsWithData.add(col);
1164
1141
  break;
1165
1142
  }
@@ -1210,8 +1187,8 @@ let BatchSaveImagesService = class BatchSaveImagesService extends _univerjs_core
1210
1187
  if (worksheet) {
1211
1188
  const cell = worksheet.getCellMatrix().getValue(imageInfo.row, config.columnIndex);
1212
1189
  if (cell) {
1213
- var _cell$v3, _cell$p7;
1214
- const value = ((_cell$v3 = cell.v) === null || _cell$v3 === void 0 ? void 0 : _cell$v3.toString()) || ((_cell$p7 = cell.p) === null || _cell$p7 === void 0 || (_cell$p7 = _cell$p7.body) === null || _cell$p7 === void 0 || (_cell$p7 = _cell$p7.dataStream) === null || _cell$p7 === void 0 ? void 0 : _cell$p7.trim()) || "";
1190
+ var _cell$v3, _cell$p3;
1191
+ const value = ((_cell$v3 = cell.v) === null || _cell$v3 === void 0 ? void 0 : _cell$v3.toString()) || ((_cell$p3 = cell.p) === null || _cell$p3 === void 0 || (_cell$p3 = _cell$p3.body) === null || _cell$p3 === void 0 || (_cell$p3 = _cell$p3.dataStream) === null || _cell$p3 === void 0 ? void 0 : _cell$p3.trim()) || "";
1215
1192
  if (value) {
1216
1193
  const sanitized = value.replace(/[<>:"/\\|?*]/g, "_").trim();
1217
1194
  if (sanitized) parts.push(sanitized);
@@ -1232,8 +1209,8 @@ let BatchSaveImagesService = class BatchSaveImagesService extends _univerjs_core
1232
1209
  if (worksheet) {
1233
1210
  const cell = worksheet.getCellMatrix().getValue(imageInfo.row, config.columnIndex);
1234
1211
  if (cell) {
1235
- var _cell$v4, _cell$p8;
1236
- const value = ((_cell$v4 = cell.v) === null || _cell$v4 === void 0 ? void 0 : _cell$v4.toString()) || ((_cell$p8 = cell.p) === null || _cell$p8 === void 0 || (_cell$p8 = _cell$p8.body) === null || _cell$p8 === void 0 || (_cell$p8 = _cell$p8.dataStream) === null || _cell$p8 === void 0 ? void 0 : _cell$p8.trim()) || "";
1212
+ var _cell$v4, _cell$p4;
1213
+ const value = ((_cell$v4 = cell.v) === null || _cell$v4 === void 0 ? void 0 : _cell$v4.toString()) || ((_cell$p4 = cell.p) === null || _cell$p4 === void 0 || (_cell$p4 = _cell$p4.body) === null || _cell$p4 === void 0 || (_cell$p4 = _cell$p4.dataStream) === null || _cell$p4 === void 0 ? void 0 : _cell$p4.trim()) || "";
1237
1214
  if (value) {
1238
1215
  const sanitized = value.replace(/[<>:"/\\|?*]/g, "_").trim();
1239
1216
  if (sanitized) parts.push(sanitized);
@@ -1363,7 +1340,6 @@ const SaveCellImagesCommand = {
1363
1340
  width: 360,
1364
1341
  title: { title: titleText },
1365
1342
  children: { label: BATCH_SAVE_IMAGES_DIALOG_ID },
1366
- destroyOnClose: true,
1367
1343
  preservePositionOnDestroy: true,
1368
1344
  onClose: () => dialogService.close(BATCH_SAVE_IMAGES_DIALOG_ID)
1369
1345
  });
@@ -1516,7 +1492,6 @@ let SheetsDrawingGroupCopyPasteController = class SheetsDrawingGroupCopyPasteCon
1516
1492
  };
1517
1493
  }
1518
1494
  _generateGroupPasteMutations(pasteTo) {
1519
- var _cloned$flatChildren;
1520
1495
  if (!this._copyInfo) return {
1521
1496
  redos: [],
1522
1497
  undos: []
@@ -1547,12 +1522,11 @@ let SheetsDrawingGroupCopyPasteController = class SheetsDrawingGroupCopyPasteCon
1547
1522
  left: pasteRect.startX,
1548
1523
  top: pasteRect.startY
1549
1524
  };
1550
- const allDrawings = [...((_cloned$flatChildren = cloned.flatChildren) !== null && _cloned$flatChildren !== void 0 ? _cloned$flatChildren : []).map((d) => ({
1525
+ const allDrawings = [...(cloned.flatChildren ?? []).map((d) => ({
1551
1526
  ...d,
1552
1527
  unitId,
1553
1528
  subUnitId
1554
1529
  })), ...cloned.groups.map((d) => {
1555
- var _transformToDrawingPo, _transformToAxisAlign;
1556
1530
  if (d.drawingId !== newRootGroupId) return {
1557
1531
  ...d,
1558
1532
  unitId,
@@ -1563,8 +1537,8 @@ let SheetsDrawingGroupCopyPasteController = class SheetsDrawingGroupCopyPasteCon
1563
1537
  unitId,
1564
1538
  subUnitId,
1565
1539
  transform: newTransform,
1566
- sheetTransform: (_transformToDrawingPo = (0, _univerjs_sheets_drawing.transformToDrawingPosition)(newTransform, pasteToSkeleton)) !== null && _transformToDrawingPo !== void 0 ? _transformToDrawingPo : origRootGroup.sheetTransform,
1567
- axisAlignSheetTransform: (_transformToAxisAlign = (0, _univerjs_sheets_drawing.transformToAxisAlignPosition)(newTransform, pasteToSkeleton)) !== null && _transformToAxisAlign !== void 0 ? _transformToAxisAlign : origRootGroup.sheetTransform
1540
+ sheetTransform: (0, _univerjs_sheets_drawing.transformToDrawingPosition)(newTransform, pasteToSkeleton) ?? origRootGroup.sheetTransform,
1541
+ axisAlignSheetTransform: (0, _univerjs_sheets_drawing.transformToAxisAlignPosition)(newTransform, pasteToSkeleton) ?? origRootGroup.sheetTransform
1568
1542
  };
1569
1543
  })];
1570
1544
  const { undo: removeOp, redo: insertOp, objects } = this._sheetDrawingService.getBatchAddOp(allDrawings);
@@ -1688,14 +1662,13 @@ function shouldStartFloatDomMoveFromHandle(info, detail) {
1688
1662
  return detail.hostAnchorId === info.id && (detail.hostUnitId == null || detail.hostUnitId === info.unitId) && (detail.button == null || detail.button === 0) && typeof detail.clientX === "number" && typeof detail.clientY === "number";
1689
1663
  }
1690
1664
  function createFloatDomMoveDragState(info, detail) {
1691
- var _info$rect$left, _info$rect$top;
1692
1665
  if (typeof detail.clientX !== "number" || typeof detail.clientY !== "number") return;
1693
1666
  return {
1694
1667
  pointerId: detail.pointerId,
1695
1668
  startClientX: detail.clientX,
1696
1669
  startClientY: detail.clientY,
1697
- startLeft: Number((_info$rect$left = info.rect.left) !== null && _info$rect$left !== void 0 ? _info$rect$left : 0),
1698
- startTop: Number((_info$rect$top = info.rect.top) !== null && _info$rect$top !== void 0 ? _info$rect$top : 0)
1670
+ startLeft: Number(info.rect.left ?? 0),
1671
+ startTop: Number(info.rect.top ?? 0)
1699
1672
  };
1700
1673
  }
1701
1674
  function resolveFloatDomMoveDragTransform(state, event, scene) {
@@ -1977,8 +1950,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
1977
1950
  * default {@link Rect} fallback.
1978
1951
  */
1979
1952
  registerRenderObjectFactory(drawingType, factory) {
1980
- var _this$_renderObjectFa;
1981
- const factories = (_this$_renderObjectFa = this._renderObjectFactories.get(drawingType)) !== null && _this$_renderObjectFa !== void 0 ? _this$_renderObjectFa : [];
1953
+ const factories = this._renderObjectFactories.get(drawingType) ?? [];
1982
1954
  factories.push(factory);
1983
1955
  this._renderObjectFactories.set(drawingType, factories);
1984
1956
  return { dispose: () => {
@@ -1990,10 +1962,9 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
1990
1962
  } };
1991
1963
  }
1992
1964
  _createRenderObject(context) {
1993
- var _factory;
1994
1965
  const factories = this._renderObjectFactories.get(context.drawingType);
1995
1966
  const factory = factories === null || factories === void 0 ? void 0 : factories[factories.length - 1];
1996
- return (_factory = factory === null || factory === void 0 ? void 0 : factory(context)) !== null && _factory !== void 0 ? _factory : new _univerjs_engine_render.Rect(context.key, context.config);
1967
+ return (factory === null || factory === void 0 ? void 0 : factory(context)) ?? new _univerjs_engine_render.Rect(context.key, context.config);
1997
1968
  }
1998
1969
  _bindScrollEvent() {
1999
1970
  this._lifecycleService.lifecycle$.pipe((0, rxjs.filter)((s) => s === _univerjs_core.LifecycleStages.Rendered), (0, rxjs.take)(1)).subscribe(() => {
@@ -2070,7 +2041,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2070
2041
  }
2071
2042
  _commitFloatDomMove(info) {
2072
2043
  var _this$_renderManagerS;
2073
- const skeletonParam = (_this$_renderManagerS = this._renderManagerService.getRenderById(info.unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(info.subUnitId);
2044
+ const skeletonParam = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(info.unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(info.subUnitId);
2074
2045
  const drawing = this._sheetDrawingService.getDrawingByParam({
2075
2046
  unitId: info.unitId,
2076
2047
  subUnitId: info.subUnitId,
@@ -2239,7 +2210,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2239
2210
  }
2240
2211
  _getSceneAndTransformerByDrawingSearch(unitId) {
2241
2212
  if (unitId == null) return;
2242
- const renderUnit = this._renderManagerService.getRenderById(unitId);
2213
+ const renderUnit = this._renderManagerService.getRenderUnitById(unitId);
2243
2214
  const scene = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.scene;
2244
2215
  if (renderUnit == null || scene == null) return null;
2245
2216
  return {
@@ -2263,7 +2234,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2263
2234
  if (!workbook) return;
2264
2235
  const activeSheetId = workbook.getActiveSheet().getSheetId();
2265
2236
  if (!floatDomParam || !target) return;
2266
- const skeleton = (_this$_renderManagerS2 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId);
2237
+ const skeleton = (_this$_renderManagerS2 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId);
2267
2238
  if (!skeleton) return;
2268
2239
  const { transform, drawingType, data, hidden, groupId } = floatDomParam;
2269
2240
  if (!isCanvasFloatDomDrawingType(drawingType)) return;
@@ -2321,7 +2292,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2321
2292
  if (data && data.border) imageConfig.stroke = data.border;
2322
2293
  Object.assign(imageConfig, SHEET_CHART_RENDER_OBJECT_CONFIG);
2323
2294
  } else imageConfig.rotateEnabled = false;
2324
- const rect = rectShape !== null && rectShape !== void 0 ? rectShape : this._createRenderObject({
2295
+ const rect = rectShape ?? this._createRenderObject({
2325
2296
  key: rectShapeKey,
2326
2297
  config: imageConfig,
2327
2298
  unitId,
@@ -2471,6 +2442,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2471
2442
  if (previewObjectKey) scene.removeObject(previewObjectKey);
2472
2443
  });
2473
2444
  listener && disposableCollection.add(listener);
2445
+ this._bindFloatDomScroll(disposableCollection, info, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet);
2474
2446
  this._domLayerInfoMap.set(drawingId, info);
2475
2447
  });
2476
2448
  }));
@@ -2506,7 +2478,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2506
2478
  unitId,
2507
2479
  subUnitId
2508
2480
  });
2509
- const skeleton = (_this$_renderManagerS3 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS3 === void 0 ? void 0 : _this$_renderManagerS3.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId);
2481
+ const skeleton = (_this$_renderManagerS3 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS3 === void 0 ? void 0 : _this$_renderManagerS3.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId);
2510
2482
  if (!renderObject || !target || !skeleton) return;
2511
2483
  ids.forEach((id) => {
2512
2484
  const floatDomInfo = this._domLayerInfoMap.get(id);
@@ -2523,23 +2495,6 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2523
2495
  this._syncFloatDomVisibilityForActiveSheet(unitId, subUnitId);
2524
2496
  updateSheet(unitId, subUnitId);
2525
2497
  }));
2526
- this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => workbook ? workbook.activeSheet$ : (0, rxjs.of)(null)), (0, rxjs.map)((worksheet) => {
2527
- if (!worksheet) return null;
2528
- const unitId = worksheet.getUnitId();
2529
- const render = this._renderManagerService.getRenderById(unitId);
2530
- return render ? {
2531
- render,
2532
- unitId,
2533
- subUnitId: worksheet.getSheetId()
2534
- } : null;
2535
- }), (0, rxjs.switchMap)((render) => render ? (0, _univerjs_core.fromEventSubject)(render.render.scene.getViewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe((0, rxjs.map)(() => ({
2536
- unitId: render.unitId,
2537
- subUnitId: render.subUnitId
2538
- }))) : (0, rxjs.of)(null))).subscribe((value) => {
2539
- if (!value) return;
2540
- const { unitId, subUnitId } = value;
2541
- updateSheet(unitId, subUnitId);
2542
- }));
2543
2498
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
2544
2499
  if (commandInfo.id === _univerjs_sheets_ui.SetZoomRatioOperation.id) {
2545
2500
  const { unitId } = commandInfo.params;
@@ -2555,6 +2510,13 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2555
2510
  }
2556
2511
  }));
2557
2512
  }
2513
+ _bindFloatDomScroll(disposableCollection, info, scene, skeleton, worksheet) {
2514
+ const viewport = scene.getViewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN);
2515
+ if (!viewport) return;
2516
+ disposableCollection.add((0, _univerjs_core.fromEventSubject)(viewport.onScrollAfter$).subscribe(() => {
2517
+ info.position$.next(calcSheetFloatDomPosition(info.rect, scene, skeleton, worksheet, info));
2518
+ }));
2519
+ }
2558
2520
  updateFloatDomProps(unitId, subUnitId, id, props) {
2559
2521
  const info = this._domLayerInfoMap.get(id);
2560
2522
  const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
@@ -2584,13 +2546,13 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2584
2546
  }
2585
2547
  }
2586
2548
  _getObjectIncludingGroup(scene, key, groupKey) {
2587
- var _ref, _ref2, _this$_getChildObject, _scene$getObjectInclu;
2588
- return (_ref = (_ref2 = (_this$_getChildObject = this._getChildObjectFromGroup(scene, key, groupKey)) !== null && _this$_getChildObject !== void 0 ? _this$_getChildObject : (_scene$getObjectInclu = scene.getObjectIncludeInGroup) === null || _scene$getObjectInclu === void 0 ? void 0 : _scene$getObjectInclu.call(scene, key)) !== null && _ref2 !== void 0 ? _ref2 : scene.getObject(key)) !== null && _ref !== void 0 ? _ref : null;
2549
+ var _scene$getObjectInclu;
2550
+ return this._getChildObjectFromGroup(scene, key, groupKey) ?? ((_scene$getObjectInclu = scene.getObjectIncludeInGroup) === null || _scene$getObjectInclu === void 0 ? void 0 : _scene$getObjectInclu.call(scene, key)) ?? scene.getObject(key) ?? null;
2589
2551
  }
2590
2552
  _getChildObjectFromGroup(scene, key, groupKey) {
2591
- var _scene$getObjectInclu2, _scene$getObjectInclu3;
2553
+ var _scene$getObjectInclu2;
2592
2554
  if (!groupKey) return null;
2593
- const groupObject = (_scene$getObjectInclu2 = (_scene$getObjectInclu3 = scene.getObjectIncludeInGroup) === null || _scene$getObjectInclu3 === void 0 ? void 0 : _scene$getObjectInclu3.call(scene, groupKey)) !== null && _scene$getObjectInclu2 !== void 0 ? _scene$getObjectInclu2 : scene.getObject(groupKey);
2555
+ const groupObject = ((_scene$getObjectInclu2 = scene.getObjectIncludeInGroup) === null || _scene$getObjectInclu2 === void 0 ? void 0 : _scene$getObjectInclu2.call(scene, groupKey)) ?? scene.getObject(groupKey);
2594
2556
  return this._findChildObject(groupObject, key);
2595
2557
  }
2596
2558
  _findChildObject(object, key) {
@@ -2614,16 +2576,15 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2614
2576
  if (info) info.rect = object;
2615
2577
  }
2616
2578
  _getChartDataBackground(data) {
2617
- var _record$backgroundCol;
2618
2579
  if (!data || typeof data !== "object" || Array.isArray(data)) return;
2619
2580
  const record = data;
2620
- const background = (_record$backgroundCol = record.backgroundColor) !== null && _record$backgroundCol !== void 0 ? _record$backgroundCol : record.background;
2581
+ const background = record.backgroundColor ?? record.background;
2621
2582
  return typeof background === "string" ? background : void 0;
2622
2583
  }
2623
2584
  _getPosition(position, unitId) {
2624
2585
  var _this$_renderManagerS4;
2625
2586
  const { startX, endX, startY, endY } = position;
2626
- const selectionRenderService = (_this$_renderManagerS4 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS4 === void 0 ? void 0 : _this$_renderManagerS4.with(_univerjs_sheets_ui.ISheetSelectionRenderService);
2587
+ const selectionRenderService = (_this$_renderManagerS4 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS4 === void 0 ? void 0 : _this$_renderManagerS4.with(_univerjs_sheets_ui.ISheetSelectionRenderService);
2627
2588
  if (selectionRenderService == null) return;
2628
2589
  const start = selectionRenderService.getCellWithCoordByOffset(startX, startY);
2629
2590
  if (start == null) return;
@@ -2690,7 +2651,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2690
2651
  if (!target) throw new Error("cannot find current target!");
2691
2652
  const { unitId, subUnitId } = target;
2692
2653
  const { initPosition, componentKey, data, allowTransform = true } = layer;
2693
- const id = propId !== null && propId !== void 0 ? propId : (0, _univerjs_core.generateRandomId)();
2654
+ const id = propId ?? (0, _univerjs_core.generateRandomId)();
2694
2655
  const sheetTransform = this._getPosition(initPosition, unitId);
2695
2656
  if (sheetTransform == null) return;
2696
2657
  const sheetDrawingParam = {
@@ -2770,12 +2731,12 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2770
2731
  const { unitId, subUnitId } = target;
2771
2732
  const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2772
2733
  if (!renderObject) return;
2773
- const currentRender = this._renderManagerService.getRenderById(unitId);
2734
+ const currentRender = this._renderManagerService.getRenderUnitById(unitId);
2774
2735
  if (!currentRender) return;
2775
- const skeletonParam = (_this$_renderManagerS5 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS5 === void 0 ? void 0 : _this$_renderManagerS5.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId);
2736
+ const skeletonParam = (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS5 === void 0 ? void 0 : _this$_renderManagerS5.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId);
2776
2737
  if (!skeletonParam) return;
2777
2738
  const { componentKey, data, allowTransform = true } = config;
2778
- const id = propId !== null && propId !== void 0 ? propId : (0, _univerjs_core.generateRandomId)();
2739
+ const id = propId ?? (0, _univerjs_core.generateRandomId)();
2779
2740
  const { position: rangePosition, position$: rangePos$ } = this._createRangePositionObserver(range, currentRender, skeletonParam.skeleton);
2780
2741
  const sheetTransform = this._getPosition(rangePosition, unitId);
2781
2742
  if (sheetTransform == null) return;
@@ -2810,7 +2771,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2810
2771
  if (!workbook) return;
2811
2772
  const activeSheetId = workbook.getActiveSheet().getSheetId();
2812
2773
  if (!floatDomParam || !target) return;
2813
- const skMangerService = (_this$_renderManagerS6 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS6 === void 0 ? void 0 : _this$_renderManagerS6.with(_univerjs_sheets_ui.SheetSkeletonManagerService);
2774
+ const skMangerService = (_this$_renderManagerS6 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS6 === void 0 ? void 0 : _this$_renderManagerS6.with(_univerjs_sheets_ui.SheetSkeletonManagerService);
2814
2775
  if (!skMangerService) return;
2815
2776
  const skeletonParam = skMangerService.getSkeletonParam(subUnitId);
2816
2777
  if (!skeletonParam) return;
@@ -2933,34 +2894,34 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2933
2894
  };
2934
2895
  this._canvasFloatDomService.addFloatDom(floatDomCfg);
2935
2896
  this.disposeWithMe(rangePos$.subscribe((newRangePos) => {
2936
- var _domAnchor$width, _domAnchor$height, _domAnchor$width2, _domAnchor$height2;
2937
2897
  const calcOffsetPos = calcDomPositionByAnchor({
2938
2898
  rotate: 0,
2939
2899
  startX: newRangePos.startX,
2940
2900
  startY: newRangePos.startY,
2941
2901
  endX: newRangePos.endX,
2942
2902
  endY: newRangePos.endY,
2943
- width: (_domAnchor$width = domAnchor.width) !== null && _domAnchor$width !== void 0 ? _domAnchor$width : newRangePos.width,
2944
- height: (_domAnchor$height = domAnchor.height) !== null && _domAnchor$height !== void 0 ? _domAnchor$height : newRangePos.height,
2903
+ width: domAnchor.width ?? newRangePos.width,
2904
+ height: domAnchor.height ?? newRangePos.height,
2945
2905
  absolute: {
2946
2906
  left: rangePosition.absolute.left,
2947
2907
  top: rangePosition.absolute.top
2948
2908
  }
2949
2909
  }, domAnchor);
2950
- const newPos = calcSheetFloatDomPosition(new _univerjs_engine_render.Rect((0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
2910
+ const newRect = new _univerjs_engine_render.Rect((0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
2951
2911
  unitId,
2952
2912
  subUnitId,
2953
2913
  drawingId
2954
2914
  }), {
2955
2915
  left: calcOffsetPos.startX,
2956
2916
  top: calcOffsetPos.startY,
2957
- width: (_domAnchor$width2 = domAnchor.width) !== null && _domAnchor$width2 !== void 0 ? _domAnchor$width2 : newRangePos.width,
2958
- height: (_domAnchor$height2 = domAnchor.height) !== null && _domAnchor$height2 !== void 0 ? _domAnchor$height2 : newRangePos.height,
2917
+ width: domAnchor.width ?? newRangePos.width,
2918
+ height: domAnchor.height ?? newRangePos.height,
2959
2919
  zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
2960
- }), renderObject.renderUnit.scene, skeletonParam.skeleton, target.worksheet, floatDomInfo);
2920
+ });
2921
+ const newPos = calcSheetFloatDomPosition(newRect, renderObject.renderUnit.scene, skeletonParam.skeleton, target.worksheet, floatDomInfo);
2961
2922
  position$.next(newPos);
2962
2923
  }));
2963
- const skm = (_this$_renderManagerS7 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS7 === void 0 ? void 0 : _this$_renderManagerS7.with(_univerjs_sheets_ui.SheetSkeletonManagerService);
2924
+ const skm = (_this$_renderManagerS7 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS7 === void 0 ? void 0 : _this$_renderManagerS7.with(_univerjs_sheets_ui.SheetSkeletonManagerService);
2964
2925
  const skeletonSubscription = skm === null || skm === void 0 ? void 0 : skm.currentSkeleton$.subscribe((skeleton) => {
2965
2926
  if (!skeleton) return;
2966
2927
  if (skeletonParam.sheetId !== skeleton.sheetId) this._removeDom(id, true);
@@ -2974,6 +2935,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2974
2935
  this._canvasFloatDomService.removeFloatDom(drawingId);
2975
2936
  });
2976
2937
  listener && disposableCollection.add(listener);
2938
+ this._bindFloatDomScroll(disposableCollection, floatDomInfo, renderObject.renderUnit.scene, skeletonParam.skeleton, target.worksheet);
2977
2939
  this._domLayerInfoMap.set(drawingId, floatDomInfo);
2978
2940
  }
2979
2941
  return this._createFloatDomDisposable(id);
@@ -2987,12 +2949,12 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2987
2949
  if (!target) throw new Error("cannot find current target!");
2988
2950
  const { unitId, subUnitId } = target;
2989
2951
  if (!this._getSceneAndTransformerByDrawingSearch(unitId)) return;
2990
- const currentRender = this._renderManagerService.getRenderById(unitId);
2952
+ const currentRender = this._renderManagerService.getRenderUnitById(unitId);
2991
2953
  if (!currentRender) return;
2992
- const skeletonParam = (_this$_renderManagerS8 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS8 === void 0 ? void 0 : _this$_renderManagerS8.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId);
2954
+ const skeletonParam = (_this$_renderManagerS8 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS8 === void 0 ? void 0 : _this$_renderManagerS8.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId);
2993
2955
  if (!skeletonParam) return;
2994
2956
  const { componentKey, data, allowTransform = true } = config;
2995
- const id = propId !== null && propId !== void 0 ? propId : (0, _univerjs_core.generateRandomId)();
2957
+ const id = propId ?? (0, _univerjs_core.generateRandomId)();
2996
2958
  const { position: rangePosition, position$: rangePos$ } = this._createRangePositionObserver({
2997
2959
  startRow: 0,
2998
2960
  endRow: 0,
@@ -3032,7 +2994,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3032
2994
  if (!workbook) return;
3033
2995
  const activeSheetId = workbook.getActiveSheet().getSheetId();
3034
2996
  if (!floatDomParam || !target) return;
3035
- const skMangerService = (_this$_renderManagerS9 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS9 === void 0 ? void 0 : _this$_renderManagerS9.with(_univerjs_sheets_ui.SheetSkeletonManagerService);
2997
+ const skMangerService = (_this$_renderManagerS9 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS9 === void 0 ? void 0 : _this$_renderManagerS9.with(_univerjs_sheets_ui.SheetSkeletonManagerService);
3036
2998
  if (!skMangerService) return;
3037
2999
  const skeleton = skMangerService.getSkeletonParam(subUnitId);
3038
3000
  if (!skeleton) return;
@@ -3150,7 +3112,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3150
3112
  top: rangePosition.absolute.top
3151
3113
  }
3152
3114
  }, domLayoutParam);
3153
- const newPos = calcSheetFloatDomPosition(new _univerjs_engine_render.Rect((0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
3115
+ const newRect = new _univerjs_engine_render.Rect((0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
3154
3116
  unitId,
3155
3117
  subUnitId,
3156
3118
  drawingId
@@ -3160,10 +3122,11 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3160
3122
  width: domLayoutParam.width,
3161
3123
  height: domLayoutParam.height,
3162
3124
  zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
3163
- }), renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet, floatDomInfo);
3125
+ });
3126
+ const newPos = calcSheetFloatDomPosition(newRect, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet, floatDomInfo);
3164
3127
  position$.next(newPos);
3165
3128
  }));
3166
- const skm = (_this$_renderManagerS10 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS10 === void 0 ? void 0 : _this$_renderManagerS10.with(_univerjs_sheets_ui.SheetSkeletonManagerService);
3129
+ const skm = (_this$_renderManagerS10 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS10 === void 0 ? void 0 : _this$_renderManagerS10.with(_univerjs_sheets_ui.SheetSkeletonManagerService);
3167
3130
  skm === null || skm === void 0 || skm.currentSkeleton$.subscribe((skeleton) => {
3168
3131
  if (!skeleton) return;
3169
3132
  if (skeletonParam.sheetId !== skeleton.sheetId) this._removeDom(id, true);
@@ -3172,6 +3135,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3172
3135
  this._canvasFloatDomService.removeFloatDom(drawingId);
3173
3136
  });
3174
3137
  listener && disposableCollection.add(listener);
3138
+ this._bindFloatDomScroll(disposableCollection, floatDomInfo, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet);
3175
3139
  this._domLayerInfoMap.set(drawingId, floatDomInfo);
3176
3140
  }
3177
3141
  return this._createFloatDomDisposable(id);
@@ -3287,12 +3251,11 @@ function calcCellPositionByCell(row, col, skeleton) {
3287
3251
  };
3288
3252
  }
3289
3253
  function calcDomPositionByAnchor(rangePosition, domAnchor, scale) {
3290
- var _scale, _domAnchor$width3, _domAnchor$height3;
3291
- scale = (_scale = scale) !== null && _scale !== void 0 ? _scale : 1;
3254
+ scale = scale ?? 1;
3292
3255
  const rangeWidth = rangePosition.endX - rangePosition.startX;
3293
3256
  const rangeHeight = rangePosition.endY - rangePosition.startY;
3294
- const domWidth = (_domAnchor$width3 = domAnchor === null || domAnchor === void 0 ? void 0 : domAnchor.width) !== null && _domAnchor$width3 !== void 0 ? _domAnchor$width3 : rangeWidth;
3295
- const domHeight = (_domAnchor$height3 = domAnchor === null || domAnchor === void 0 ? void 0 : domAnchor.height) !== null && _domAnchor$height3 !== void 0 ? _domAnchor$height3 : rangeHeight;
3257
+ const domWidth = (domAnchor === null || domAnchor === void 0 ? void 0 : domAnchor.width) ?? rangeWidth;
3258
+ const domHeight = (domAnchor === null || domAnchor === void 0 ? void 0 : domAnchor.height) ?? rangeHeight;
3296
3259
  let domLeft = 0;
3297
3260
  let domTop = 0;
3298
3261
  if (domAnchor) {
@@ -3387,13 +3350,6 @@ function UploadCellImageMenuFactory(accessor) {
3387
3350
  //#endregion
3388
3351
  //#region src/menu/save-images.menu.ts
3389
3352
  /**
3390
- * Check if a cell has image
3391
- */
3392
- function cellHasImage(cell) {
3393
- var _cell$p, _cell$p2;
3394
- return !!((cell === null || cell === void 0 || (_cell$p = cell.p) === null || _cell$p === void 0 || (_cell$p = _cell$p.drawingsOrder) === null || _cell$p === void 0 ? void 0 : _cell$p.length) && (cell === null || cell === void 0 || (_cell$p2 = cell.p) === null || _cell$p2 === void 0 || (_cell$p2 = _cell$p2.drawingsOrder) === null || _cell$p2 === void 0 ? void 0 : _cell$p2.length) > 0);
3395
- }
3396
- /**
3397
3353
  * Check if selection range has any images
3398
3354
  */
3399
3355
  function selectionHasImages(workbook, selection) {
@@ -3401,7 +3357,10 @@ function selectionHasImages(workbook, selection) {
3401
3357
  if (!worksheet) return false;
3402
3358
  const cellMatrix = worksheet.getCellMatrix();
3403
3359
  const { startRow, endRow, startColumn, endColumn } = selection;
3404
- for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) if (cellHasImage(cellMatrix.getValue(row, col))) return true;
3360
+ for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) {
3361
+ const cell = cellMatrix.getValue(row, col);
3362
+ if ((0, _univerjs_sheets.isCellImage)(cell === null || cell === void 0 ? void 0 : cell.p)) return true;
3363
+ }
3405
3364
  return false;
3406
3365
  }
3407
3366
  /**
@@ -3470,7 +3429,7 @@ const menuSchema = {
3470
3429
  //#endregion
3471
3430
  //#region package.json
3472
3431
  var name = "@univerjs/sheets-drawing-ui";
3473
- var version = "1.0.0-alpha.7";
3432
+ var version = "1.0.0-beta.0";
3474
3433
 
3475
3434
  //#endregion
3476
3435
  //#region src/config/config.ts
@@ -3605,18 +3564,17 @@ function BatchSaveImagesDialog() {
3605
3564
  //#endregion
3606
3565
  //#region src/views/sheet-image-panel/SheetDrawingAnchor.tsx
3607
3566
  const SheetDrawingAnchor = (props) => {
3608
- var _drawingParam$anchorT;
3609
3567
  const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
3610
3568
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
3611
3569
  const drawingManagerService = (0, _univerjs_ui.useDependency)(_univerjs_drawing.IDrawingManagerService);
3612
3570
  const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
3613
3571
  const { drawings } = props;
3614
- const drawingParam = drawings[0];
3615
- const renderObject = drawingParam ? renderManagerService.getRenderById(drawingParam.unitId) : void 0;
3572
+ const drawingParam = isSheetDrawing(drawings[0]) ? drawings[0] : void 0;
3573
+ const renderObject = drawingParam ? renderManagerService.getRenderUnitById(drawingParam.unitId) : void 0;
3616
3574
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
3617
3575
  const transformer = scene === null || scene === void 0 ? void 0 : scene.getTransformerByCreate();
3618
3576
  const [anchorShow, setAnchorShow] = (0, react.useState)(true);
3619
- const [value, setValue] = (0, react.useState)((_drawingParam$anchorT = drawingParam === null || drawingParam === void 0 ? void 0 : drawingParam.anchorType) !== null && _drawingParam$anchorT !== void 0 ? _drawingParam$anchorT : _univerjs_sheets_drawing.SheetDrawingAnchorType.Position);
3577
+ const [value, setValue] = (0, react.useState)(drawingParam ? (0, _univerjs_sheets_drawing.getSheetDrawingPlacement)(drawingParam).kind : _univerjs_sheets_drawing.SheetDrawingAnchorType.Position);
3620
3578
  function getUpdateParams(objects, drawingManagerService) {
3621
3579
  const params = [];
3622
3580
  objects.forEach((object) => {
@@ -3626,6 +3584,10 @@ const SheetDrawingAnchor = (props) => {
3626
3584
  params.push(null);
3627
3585
  return true;
3628
3586
  }
3587
+ if (!isSheetDrawing(searchParam)) {
3588
+ params.push(null);
3589
+ return true;
3590
+ }
3629
3591
  const { unitId, subUnitId, drawingId, drawingType, anchorType, sheetTransform, axisAlignSheetTransform } = searchParam;
3630
3592
  params.push({
3631
3593
  unitId,
@@ -3649,9 +3611,9 @@ const SheetDrawingAnchor = (props) => {
3649
3611
  const params = getUpdateParams(objects, drawingManagerService);
3650
3612
  if (params.length === 0) setAnchorShow(false);
3651
3613
  else if (params.length >= 1) {
3652
- var _params$;
3653
3614
  setAnchorShow(true);
3654
- setValue(((_params$ = params[0]) === null || _params$ === void 0 ? void 0 : _params$.anchorType) || _univerjs_sheets_drawing.SheetDrawingAnchorType.Position);
3615
+ const drawing = params[0];
3616
+ setValue(drawing ? (0, _univerjs_sheets_drawing.getSheetDrawingPlacement)(drawing).kind : _univerjs_sheets_drawing.SheetDrawingAnchorType.Position);
3655
3617
  }
3656
3618
  });
3657
3619
  return () => {
@@ -3661,21 +3623,34 @@ const SheetDrawingAnchor = (props) => {
3661
3623
  }, [drawingManagerService, transformer]);
3662
3624
  if (!drawingParam || !transformer) return null;
3663
3625
  function handleChange(value) {
3664
- setValue(value);
3626
+ const kind = getAnchorKind(value);
3627
+ if (!kind) return;
3665
3628
  const focusDrawings = drawingManagerService.getFocusDrawings();
3666
- if (focusDrawings.length === 0) return;
3667
- const updateParams = focusDrawings.map((drawing) => {
3668
- return {
3669
- unitId: drawing.unitId,
3670
- subUnitId: drawing.subUnitId,
3629
+ if (!focusDrawings.length || !focusDrawings.every(isSheetDrawing)) return;
3630
+ const { unitId, subUnitId } = focusDrawings[0];
3631
+ const placementUpdates = [];
3632
+ for (const drawing of focusDrawings) {
3633
+ const { transform } = drawing;
3634
+ const { left, top, width, height } = transform ?? {};
3635
+ if (typeof left !== "number" || typeof top !== "number" || typeof width !== "number" || typeof height !== "number" || !Number.isFinite(left) || !Number.isFinite(top) || !Number.isFinite(width) || !Number.isFinite(height)) return;
3636
+ placementUpdates.push({
3671
3637
  drawingId: drawing.drawingId,
3672
- anchorType: value
3673
- };
3674
- });
3675
- commandService.executeCommand(_univerjs_sheets_drawing.SetSheetDrawingCommand.id, {
3676
- unitId: focusDrawings[0].unitId,
3677
- drawings: updateParams
3678
- });
3638
+ placement: {
3639
+ kind,
3640
+ bounds: {
3641
+ left,
3642
+ top,
3643
+ width,
3644
+ height
3645
+ }
3646
+ }
3647
+ });
3648
+ }
3649
+ if (commandService.syncExecuteCommand(_univerjs_sheets_drawing.SetSheetDrawingPlacementCommand.id, {
3650
+ unitId,
3651
+ subUnitId,
3652
+ drawings: placementUpdates
3653
+ })) setValue(kind);
3679
3654
  }
3680
3655
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3681
3656
  className: (0, _univerjs_design.clsx)("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", { "univer-hidden": !anchorShow }),
@@ -3703,6 +3678,13 @@ const SheetDrawingAnchor = (props) => {
3703
3678
  }) })]
3704
3679
  });
3705
3680
  };
3681
+ function isSheetDrawing(drawing) {
3682
+ return Boolean(drawing && "sheetTransform" in drawing && "axisAlignSheetTransform" in drawing);
3683
+ }
3684
+ function getAnchorKind(value) {
3685
+ if (value === _univerjs_sheets_drawing.SheetDrawingAnchorType.Position || value === _univerjs_sheets_drawing.SheetDrawingAnchorType.Both || value === _univerjs_sheets_drawing.SheetDrawingAnchorType.None) return value;
3686
+ return null;
3687
+ }
3706
3688
 
3707
3689
  //#endregion
3708
3690
  //#region src/views/sheet-image-panel/SheetDrawingPanel.tsx
@@ -3798,7 +3780,7 @@ let DrawingContextMenuController = class DrawingContextMenuController extends _u
3798
3780
  _contextMenuListener(workbook) {
3799
3781
  var _this$_renderManagerS;
3800
3782
  if (!workbook) return;
3801
- const scene = (_this$_renderManagerS = this._renderManagerService.getRenderById(workbook.getUnitId())) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
3783
+ const scene = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(workbook.getUnitId())) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
3802
3784
  if (!scene) return;
3803
3785
  const transformer = scene.getTransformerByCreate();
3804
3786
  if (!transformer) return;
@@ -3818,16 +3800,15 @@ let DrawingContextMenuController = class DrawingContextMenuController extends _u
3818
3800
  }));
3819
3801
  }
3820
3802
  _getContextMenuPosition(drawings) {
3821
- var _this$_drawingContext;
3822
3803
  if (drawings.length !== 1) return _univerjs_ui.ContextMenuPosition.DRAWING;
3823
3804
  const [drawing] = drawings;
3824
- return (_this$_drawingContext = this._drawingContextMenuService.getContextMenuPosition({
3805
+ return this._drawingContextMenuService.getContextMenuPosition({
3825
3806
  unitId: drawing.unitId,
3826
3807
  subUnitId: drawing.subUnitId,
3827
3808
  drawingId: drawing.drawingId,
3828
3809
  drawingType: drawing.drawingType,
3829
3810
  drawing
3830
- })) !== null && _this$_drawingContext !== void 0 ? _this$_drawingContext : _univerjs_ui.ContextMenuPosition.DRAWING;
3811
+ }) ?? _univerjs_ui.ContextMenuPosition.DRAWING;
3831
3812
  }
3832
3813
  };
3833
3814
  DrawingContextMenuController = __decorate([
@@ -3919,7 +3900,14 @@ let SheetsDrawingRenderController = class SheetsDrawingRenderController extends
3919
3900
  const drawingData = subUnitData.data[drawingId];
3920
3901
  const { unitId, subUnitId } = drawingData;
3921
3902
  const skeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
3922
- if (skeletonParam && drawingData.sheetTransform) drawingData.transform = (0, _univerjs_sheets_drawing.drawingPositionToTransform)(drawingData.sheetTransform, skeletonParam);
3903
+ if (skeletonParam && drawingData.sheetTransform && !drawingData.groupId) {
3904
+ const transform = (0, _univerjs_sheets_drawing.drawingPositionToTransform)(drawingData.sheetTransform, skeletonParam);
3905
+ drawingData.transform = transform && drawingData.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_GROUP ? {
3906
+ ...transform,
3907
+ left: (transform.left ?? 0) - skeletonParam.skeleton.rowHeaderWidthAndMarginLeft,
3908
+ top: (transform.top ?? 0) - skeletonParam.skeleton.columnHeaderHeightAndMarginTop
3909
+ } : transform;
3910
+ }
3923
3911
  }
3924
3912
  }
3925
3913
  this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId));
@@ -3935,9 +3923,11 @@ SheetsDrawingRenderController = __decorate([
3935
3923
  //#endregion
3936
3924
  //#region src/controllers/sheet-cell-image.controller.ts
3937
3925
  function resizeImageByCell(injector, location, cell) {
3938
- var _cell$p, _cell$p2;
3939
- if ((cell === null || cell === void 0 || (_cell$p = cell.p) === null || _cell$p === void 0 || (_cell$p = _cell$p.body) === null || _cell$p === void 0 ? void 0 : _cell$p.dataStream.length) === 3 && ((_cell$p2 = cell.p) === null || _cell$p2 === void 0 || (_cell$p2 = _cell$p2.drawingsOrder) === null || _cell$p2 === void 0 ? void 0 : _cell$p2.length) === 1) {
3940
- const image = cell.p.drawings[cell.p.drawingsOrder[0]];
3926
+ var _documentData$drawing, _documentData$drawing2;
3927
+ const documentData = cell === null || cell === void 0 ? void 0 : cell.p;
3928
+ const drawingId = (0, _univerjs_sheets.isCellImage)(documentData) && (documentData === null || documentData === void 0 || (_documentData$drawing = documentData.drawingsOrder) === null || _documentData$drawing === void 0 ? void 0 : _documentData$drawing.length) === 1 ? documentData.drawingsOrder[0] : void 0;
3929
+ const image = drawingId ? documentData === null || documentData === void 0 || (_documentData$drawing2 = documentData.drawings) === null || _documentData$drawing2 === void 0 ? void 0 : _documentData$drawing2[drawingId] : void 0;
3930
+ if (image && documentData) {
3941
3931
  const imageSize = getDrawingSizeByCell(injector, {
3942
3932
  unitId: location.unitId,
3943
3933
  subUnitId: location.subUnitId,
@@ -3953,8 +3943,8 @@ function resizeImageByCell(injector, location, cell) {
3953
3943
  image.transform.top = 0;
3954
3944
  image.docTransform.positionH.posOffset = 0;
3955
3945
  image.docTransform.positionV.posOffset = 0;
3956
- cell.p.documentStyle.pageSize.width = Infinity;
3957
- cell.p.documentStyle.pageSize.height = Infinity;
3946
+ documentData.documentStyle.pageSize.width = Infinity;
3947
+ documentData.documentStyle.pageSize.height = Infinity;
3958
3948
  return true;
3959
3949
  }
3960
3950
  }
@@ -3986,8 +3976,7 @@ let SheetCellImageController = class SheetCellImageController extends _univerjs_
3986
3976
  effect: _univerjs_core.InterceptorEffectEnum.Style,
3987
3977
  priority: _univerjs_sheets.InterceptCellContentPriority.CELL_IMAGE,
3988
3978
  handler: (cell, pos, next) => {
3989
- var _cell$p$drawingsOrder;
3990
- if ((cell === null || cell === void 0 ? void 0 : cell.p) && ((_cell$p$drawingsOrder = cell.p.drawingsOrder) === null || _cell$p$drawingsOrder === void 0 ? void 0 : _cell$p$drawingsOrder.length)) {
3979
+ if (cell && (0, _univerjs_sheets.isCellImage)(cell.p)) {
3991
3980
  if (cell === pos.rawData) cell = { ...pos.rawData };
3992
3981
  if (!cell.interceptorStyle) cell.interceptorStyle = {};
3993
3982
  cell.interceptorStyle.tr = { a: 0 };
@@ -4087,10 +4076,9 @@ let SheetCellImageCopyPasteController = class SheetCellImageCopyPasteController
4087
4076
  _initDocImageCopyPasteHooks() {
4088
4077
  this.disposeWithMe(this._commandService.beforeCommandExecuted((commandInfo) => {
4089
4078
  if (commandInfo.id === _univerjs_docs_ui.InnerPasteCommand.id) {
4090
- var _doc$drawings;
4091
4079
  const { doc } = commandInfo.params;
4092
4080
  const currentDoc = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
4093
- if (currentDoc == null || !Object.keys((_doc$drawings = doc.drawings) !== null && _doc$drawings !== void 0 ? _doc$drawings : {}).length) return;
4081
+ if (currentDoc == null || !Object.keys(doc.drawings ?? {}).length) return;
4094
4082
  const docUnitId = currentDoc.getUnitId();
4095
4083
  if (DISABLE_UNITS.includes(docUnitId)) {
4096
4084
  var _currentDoc$getBody;
@@ -4106,7 +4094,6 @@ let SheetCellImageCopyPasteController = class SheetCellImageCopyPasteController
4106
4094
  title: { label: this._localeService.t("sheets-drawing-ui.cell-image.pasteTitle") },
4107
4095
  children: { label: this._localeService.t("sheets-drawing-ui.cell-image.pasteContent") },
4108
4096
  width: 320,
4109
- destroyOnClose: true,
4110
4097
  onClose: handleCloseDialog,
4111
4098
  showOk: true,
4112
4099
  showCancel: true,
@@ -4158,12 +4145,11 @@ let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderControlle
4158
4145
  setTimeout(() => {
4159
4146
  const drawingMap = this._drawingManagerService.drawingManagerData;
4160
4147
  const removeDrawings = [];
4161
- Object.keys(drawingMap !== null && drawingMap !== void 0 ? drawingMap : {}).forEach((unitId) => {
4162
- var _drawingMap$unitId;
4163
- const subUnitMap = (_drawingMap$unitId = drawingMap[unitId]) !== null && _drawingMap$unitId !== void 0 ? _drawingMap$unitId : {};
4148
+ Object.keys(drawingMap ?? {}).forEach((unitId) => {
4149
+ const subUnitMap = drawingMap[unitId] ?? {};
4164
4150
  Object.keys(subUnitMap).forEach((subUnitId) => {
4165
- var _subUnitMap$subUnitId, _subUnitMap$subUnitId2;
4166
- const drawingData = (_subUnitMap$subUnitId = (_subUnitMap$subUnitId2 = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId2 === void 0 ? void 0 : _subUnitMap$subUnitId2.data) !== null && _subUnitMap$subUnitId !== void 0 ? _subUnitMap$subUnitId : {};
4151
+ var _subUnitMap$subUnitId;
4152
+ const drawingData = ((_subUnitMap$subUnitId = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId === void 0 ? void 0 : _subUnitMap$subUnitId.data) ?? {};
4167
4153
  Object.keys(drawingData).forEach((drawingId) => {
4168
4154
  if (unitId === selfUnitId) removeDrawings.push(drawingData[drawingId]);
4169
4155
  });
@@ -4179,13 +4165,12 @@ let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderControlle
4179
4165
  const drawingMap = this._drawingManagerService.drawingManagerData;
4180
4166
  const insertDrawings = [];
4181
4167
  const removeDrawings = [];
4182
- Object.keys(drawingMap !== null && drawingMap !== void 0 ? drawingMap : {}).forEach((unitId) => {
4183
- var _drawingMap$unitId2;
4168
+ Object.keys(drawingMap ?? {}).forEach((unitId) => {
4184
4169
  if (unitId !== showUnitId) return;
4185
- const subUnitMap = (_drawingMap$unitId2 = drawingMap[unitId]) !== null && _drawingMap$unitId2 !== void 0 ? _drawingMap$unitId2 : {};
4170
+ const subUnitMap = drawingMap[unitId] ?? {};
4186
4171
  Object.keys(subUnitMap).forEach((subUnitId) => {
4187
- var _subUnitMap$subUnitId3, _subUnitMap$subUnitId4;
4188
- const drawingData = (_subUnitMap$subUnitId3 = (_subUnitMap$subUnitId4 = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId4 === void 0 ? void 0 : _subUnitMap$subUnitId4.data) !== null && _subUnitMap$subUnitId3 !== void 0 ? _subUnitMap$subUnitId3 : {};
4172
+ var _subUnitMap$subUnitId2;
4173
+ const drawingData = ((_subUnitMap$subUnitId2 = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId2 === void 0 ? void 0 : _subUnitMap$subUnitId2.data) ?? {};
4189
4174
  Object.keys(drawingData).forEach((drawingId) => {
4190
4175
  if (unitId === showUnitId && subUnitId === showSubunitId) {
4191
4176
  const drawing = drawingData[drawingId];
@@ -4409,7 +4394,6 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
4409
4394
  subUnitId,
4410
4395
  isCut: copyType === _univerjs_sheets_ui.COPY_TYPE.CUT,
4411
4396
  getTransform: (transform, sheetTransform) => {
4412
- var _transformToDrawingPo, _transformToAxisAlign;
4413
4397
  const pasteRect = (0, _univerjs_sheets.attachRangeWithCoord)(pasteToSkeleton, {
4414
4398
  startRow: pasteRange.startRow,
4415
4399
  endRow: pasteRange.endRow,
@@ -4423,8 +4407,8 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
4423
4407
  };
4424
4408
  return {
4425
4409
  transform: newTransform,
4426
- sheetTransform: (_transformToDrawingPo = (0, _univerjs_sheets_drawing.transformToDrawingPosition)(newTransform, pasteToSkeleton)) !== null && _transformToDrawingPo !== void 0 ? _transformToDrawingPo : sheetTransform,
4427
- axisAlignSheetTransform: (_transformToAxisAlign = (0, _univerjs_sheets_drawing.transformToAxisAlignPosition)(newTransform, pasteToSkeleton)) !== null && _transformToAxisAlign !== void 0 ? _transformToAxisAlign : sheetTransform
4410
+ sheetTransform: (0, _univerjs_sheets_drawing.transformToDrawingPosition)(newTransform, pasteToSkeleton) ?? sheetTransform,
4411
+ axisAlignSheetTransform: (0, _univerjs_sheets_drawing.transformToAxisAlignPosition)(newTransform, pasteToSkeleton) ?? sheetTransform
4428
4412
  };
4429
4413
  }
4430
4414
  });
@@ -4555,11 +4539,10 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
4555
4539
  unitId: toUnitId,
4556
4540
  subUnitId: toSubUnitId,
4557
4541
  getTransform: (transform, sheetTransform) => {
4558
- var _transform$left, _transform$top, _transformToAxisAlign2;
4559
4542
  const newTransform = {
4560
4543
  ...transform,
4561
- left: ((_transform$left = transform === null || transform === void 0 ? void 0 : transform.left) !== null && _transform$left !== void 0 ? _transform$left : 0) + leftOffset,
4562
- top: ((_transform$top = transform === null || transform === void 0 ? void 0 : transform.top) !== null && _transform$top !== void 0 ? _transform$top : 0) + topOffset
4544
+ left: ((transform === null || transform === void 0 ? void 0 : transform.left) ?? 0) + leftOffset,
4545
+ top: ((transform === null || transform === void 0 ? void 0 : transform.top) ?? 0) + topOffset
4563
4546
  };
4564
4547
  return {
4565
4548
  transform: newTransform,
@@ -4576,7 +4559,7 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
4576
4559
  column: sheetTransform.from.column + columnOffset
4577
4560
  }
4578
4561
  },
4579
- axisAlignSheetTransform: (_transformToAxisAlign2 = (0, _univerjs_sheets_drawing.transformToAxisAlignPosition)(newTransform, toSkeleton)) !== null && _transformToAxisAlign2 !== void 0 ? _transformToAxisAlign2 : sheetTransform
4562
+ axisAlignSheetTransform: (0, _univerjs_sheets_drawing.transformToAxisAlignPosition)(newTransform, toSkeleton) ?? sheetTransform
4580
4563
  };
4581
4564
  },
4582
4565
  isCut: copyType === _univerjs_sheets_ui.COPY_TYPE.CUT
@@ -4644,7 +4627,7 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
4644
4627
  const subUnitId = sheet.getSheetId();
4645
4628
  const drawingData = this._sheetDrawingService.getDrawingData(unitId, subUnitId);
4646
4629
  const drawingDataValues = Object.values(drawingData);
4647
- const renderObject = this._renderManagerService.getRenderById(unitId);
4630
+ const renderObject = this._renderManagerService.getRenderUnitById(unitId);
4648
4631
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
4649
4632
  if (!scene) return;
4650
4633
  scene.getAllObjectsByOrder().forEach((object) => {
@@ -4678,7 +4661,7 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
4678
4661
  const subUnitId = sheet.getSheetId();
4679
4662
  const drawingData = this._sheetDrawingService.getDrawingData(unitId, subUnitId);
4680
4663
  const drawingDataValues = Object.values(drawingData);
4681
- const renderObject = this._renderManagerService.getRenderById(unitId);
4664
+ const renderObject = this._renderManagerService.getRenderUnitById(unitId);
4682
4665
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
4683
4666
  if (!scene) return;
4684
4667
  scene.getAllObjectsByOrder().forEach((object) => {
@@ -4694,7 +4677,7 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
4694
4677
  if (!sheet) return rxjs.EMPTY;
4695
4678
  const unitId = workbook.getUnitId();
4696
4679
  const subUnitId = sheet.getSheetId();
4697
- const renderObject = this._renderManagerService.getRenderById(unitId);
4680
+ const renderObject = this._renderManagerService.getRenderUnitById(unitId);
4698
4681
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
4699
4682
  if (!scene) return rxjs.EMPTY;
4700
4683
  const transformer = scene.getTransformerByCreate();
@@ -4742,7 +4725,7 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
4742
4725
  if (!sheet) return rxjs.EMPTY;
4743
4726
  const unitId = workbook.getUnitId();
4744
4727
  const subUnitId = sheet.getSheetId();
4745
- const renderObject = this._renderManagerService.getRenderById(unitId);
4728
+ const renderObject = this._renderManagerService.getRenderUnitById(unitId);
4746
4729
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
4747
4730
  if (!scene) return rxjs.EMPTY;
4748
4731
  const transformer = scene.getTransformerByCreate();
@@ -4779,7 +4762,7 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
4779
4762
  const sheet = workbook.getActiveSheet();
4780
4763
  if (!sheet) return;
4781
4764
  const subUnitId = sheet.getSheetId();
4782
- const renderObject = this._renderManagerService.getRenderById(unitId);
4765
+ const renderObject = this._renderManagerService.getRenderUnitById(unitId);
4783
4766
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
4784
4767
  if (!scene) return;
4785
4768
  const drawingData = this._sheetDrawingService.getDrawingData(unitId, subUnitId);
@@ -4800,6 +4783,10 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
4800
4783
  const { drawings } = command.params;
4801
4784
  unitId = drawings === null || drawings === void 0 || (_drawings$ = drawings[0]) === null || _drawings$ === void 0 ? void 0 : _drawings$.unitId;
4802
4785
  subUnitId = drawings === null || drawings === void 0 || (_drawings$2 = drawings[0]) === null || _drawings$2 === void 0 ? void 0 : _drawings$2.subUnitId;
4786
+ } else if (command.id === _univerjs_sheets_drawing.SetSheetDrawingPlacementCommand.id) {
4787
+ const target = getPlacementCommandTarget(command.params);
4788
+ unitId = target.unitId;
4789
+ subUnitId = target.subUnitId;
4803
4790
  } else if (command.id === _univerjs_sheets_drawing.SetDrawingArrangeCommand.id) {
4804
4791
  const params = command.params;
4805
4792
  unitId = params.unitId;
@@ -4823,16 +4810,23 @@ SheetDrawingPermissionController = __decorate([
4823
4810
  __decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetPermissionCheckController)),
4824
4811
  __decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_sheets_drawing.ISheetDrawingService))
4825
4812
  ], SheetDrawingPermissionController);
4813
+ function getPlacementCommandTarget(params) {
4814
+ if (!params) return {};
4815
+ return {
4816
+ unitId: "unitId" in params && typeof params.unitId === "string" ? params.unitId : void 0,
4817
+ subUnitId: "subUnitId" in params && typeof params.subUnitId === "string" ? params.subUnitId : void 0
4818
+ };
4819
+ }
4826
4820
 
4827
4821
  //#endregion
4828
4822
  //#region src/views/PrintingFloatDom.tsx
4829
4823
  function createPrintingFloatDom(info, scene, skeleton, worksheet) {
4830
4824
  const { width, height, angle, left, top } = info.transform;
4831
4825
  const offsetBound = transformBound2DOMBound({
4832
- left: left !== null && left !== void 0 ? left : 0,
4833
- right: (left !== null && left !== void 0 ? left : 0) + (width !== null && width !== void 0 ? width : 0),
4834
- top: top !== null && top !== void 0 ? top : 0,
4835
- bottom: (top !== null && top !== void 0 ? top : 0) + (height !== null && height !== void 0 ? height : 0)
4826
+ left: left ?? 0,
4827
+ right: (left ?? 0) + (width ?? 0),
4828
+ top: top ?? 0,
4829
+ bottom: (top ?? 0) + (height ?? 0)
4836
4830
  }, scene, skeleton, worksheet, void 0, true);
4837
4831
  const { scaleX, scaleY } = scene.getAncestorScale();
4838
4832
  const domPos = {
@@ -4916,7 +4910,7 @@ let SheetDrawingPrintingController = class SheetDrawingPrintingController extend
4916
4910
  } }));
4917
4911
  this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE, { handler: (range, pos, next) => {
4918
4912
  const { unitId, subUnitId } = pos;
4919
- const renderer = this._renderManagerService.getRenderById(unitId);
4913
+ const renderer = this._renderManagerService.getRenderUnitById(unitId);
4920
4914
  if (!renderer) return next(range);
4921
4915
  const skeleton = renderer.with(_univerjs_sheets_ui.SheetSkeletonManagerService).getSkeletonParam(subUnitId);
4922
4916
  if (!skeleton) return next(range);
@@ -5120,7 +5114,7 @@ const FlipSheetDrawingCommand = {
5120
5114
  }
5121
5115
  };
5122
5116
  function getSceneByDrawingSearch(accessor, unitId) {
5123
- const render = accessor.get(_univerjs_engine_render.IRenderManagerService).getRenderById(unitId);
5117
+ const render = accessor.get(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(unitId);
5124
5118
  if (!render) return null;
5125
5119
  return render.scene;
5126
5120
  }
@@ -5309,7 +5303,7 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends _unive
5309
5303
  }
5310
5304
  _popupMenuListener(unitId) {
5311
5305
  var _this$_renderManagerS;
5312
- const scene = (_this$_renderManagerS = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
5306
+ const scene = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
5313
5307
  if (!scene) return;
5314
5308
  const transformer = scene.getTransformerByCreate();
5315
5309
  if (!transformer) return;
@@ -5334,7 +5328,7 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends _unive
5334
5328
  const menus = this._canvasPopManagerService.getFeatureMenu(unitId, subUnitId, drawingId, drawingType);
5335
5329
  singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
5336
5330
  componentKey: _univerjs_drawing_ui.COMPONENT_IMAGE_POPUP_MENU,
5337
- direction: "horizontal",
5331
+ direction: this._localeService.getDirection() === "rtl" ? "left" : "horizontal",
5338
5332
  offset: [2, 0],
5339
5333
  extraProps: { menuItems: menus || this._getImageMenuItems(unitId, subUnitId, drawingId, drawingType) }
5340
5334
  }));
@@ -5473,7 +5467,7 @@ let SheetDrawingHitTestService = class SheetDrawingHitTestService extends _unive
5473
5467
  }
5474
5468
  hitTest(unitId, subUnitId, offsetX, offsetY) {
5475
5469
  var _this$_renderManagerS;
5476
- const scene = (_this$_renderManagerS = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
5470
+ const scene = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
5477
5471
  if (!scene) return null;
5478
5472
  return this._hitTestScene(scene, unitId, subUnitId, offsetX, offsetY);
5479
5473
  }
@@ -5497,7 +5491,7 @@ let SheetDrawingHitTestService = class SheetDrawingHitTestService extends _unive
5497
5491
  this._disposeDoubleClickListener();
5498
5492
  return;
5499
5493
  }
5500
- const render = this._renderManagerService.getRenderById(context.unitId);
5494
+ const render = this._renderManagerService.getRenderUnitById(context.unitId);
5501
5495
  const scene = render === null || render === void 0 ? void 0 : render.scene;
5502
5496
  if (!render || !scene) {
5503
5497
  this._disposeDoubleClickListener();
@@ -5628,7 +5622,7 @@ _defineProperty(UniverSheetsDrawingUIPlugin, "pluginName", "SHEET_IMAGE_UI_PLUGI
5628
5622
  _defineProperty(UniverSheetsDrawingUIPlugin, "packageName", name);
5629
5623
  _defineProperty(UniverSheetsDrawingUIPlugin, "version", version);
5630
5624
  UniverSheetsDrawingUIPlugin = __decorate([
5631
- (0, _univerjs_core.DependentOn)(_univerjs_drawing.UniverDrawingPlugin, _univerjs_docs_drawing.UniverDocsDrawingPlugin, _univerjs_drawing_ui.UniverDrawingUIPlugin, _univerjs_sheets_drawing.UniverSheetsDrawingPlugin),
5625
+ (0, _univerjs_core.DependentOn)(_univerjs_drawing.UniverDrawingPlugin, _univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_docs_drawing.UniverDocsDrawingPlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_sheets_drawing.UniverSheetsDrawingPlugin, _univerjs_drawing_ui.UniverDrawingUIPlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
5632
5626
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
5633
5627
  __decorateParam(2, _univerjs_engine_render.IRenderManagerService),
5634
5628
  __decorateParam(3, _univerjs_core.IConfigService)