@univerjs/sheets-drawing-ui 0.2.11 → 0.2.12

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/es/index.js CHANGED
@@ -2,15 +2,15 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { CommandType, ICommandService, IUndoRedoService, LocaleService, IUniverInstanceService, useDependency, RxDisposable, UniverInstanceType, connectInjector, toDisposable, FOCUSING_COMMON_DRAWINGS, OnLifecycle, LifecycleStages, Inject, Injector, IContextService, Disposable, Direction, FOCUSING_FX_BAR_EDITOR, EDITOR_ACTIVATED, Rectangle, DrawingTypeEnum as DrawingTypeEnum$1, DisposableCollection, generateRandomId, Tools, UserManagerService, IPermissionService, LifecycleService, Plugin, DependentOn } from "@univerjs/core";
5
+ import { CommandType, ICommandService, IUndoRedoService, LocaleService, IUniverInstanceService, useDependency, RxDisposable, UniverInstanceType, connectInjector, toDisposable, FOCUSING_COMMON_DRAWINGS, OnLifecycle, LifecycleStages, Inject, Injector, IContextService, Disposable, Direction, FOCUSING_FX_BAR_EDITOR, EDITOR_ACTIVATED, Rectangle, DrawingTypeEnum as DrawingTypeEnum$1, DisposableCollection, generateRandomId, Tools, UserManagerService, IPermissionService, LifecycleService, Plugin, DependentOn, IConfigService } from "@univerjs/core";
6
6
  import { ImageCropperObject, COMPONENT_IMAGE_POPUP_MENU, OpenImageCropOperation, ImageResetSizeOperation, DrawingCommonPanel, DrawingRenderService, UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
7
7
  import { ISheetDrawingService, SetDrawingApplyMutation, DrawingApplyType, SheetDrawingAnchorType, UniverSheetsDrawingPlugin } from "@univerjs/sheets-drawing";
8
- import { IDrawingManagerService, IImageIoService, ArrangeTypeEnum, DrawingTypeEnum, DRAWING_IMAGE_COUNT_LIMIT, ImageUploadStatusType, DRAWING_IMAGE_ALLOW_SIZE, getImageSize, DRAWING_IMAGE_WIDTH_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_ALLOW_IMAGE_LIST, getDrawingShapeKeyByDrawingSearch, UniverDrawingPlugin } from "@univerjs/drawing";
8
+ import { IDrawingManagerService, IImageIoService, DrawingTypeEnum, ArrangeTypeEnum, DRAWING_IMAGE_COUNT_LIMIT, ImageUploadStatusType, DRAWING_IMAGE_ALLOW_SIZE, getImageSize, DRAWING_IMAGE_WIDTH_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_ALLOW_IMAGE_LIST, getDrawingShapeKeyByDrawingSearch, UniverDrawingPlugin } from "@univerjs/drawing";
9
9
  import { IRenderManagerService, getGroupState, transformObjectOutOfGroup, precisionTo, Rect, DRAWING_OBJECT_LAYER_INDEX, SHEET_VIEWPORT_KEY, RENDER_CLASS_TYPE } from "@univerjs/engine-render";
10
10
  import { SheetCanvasPopManagerService, attachRangeWithCoord, SheetSkeletonManagerService, ISheetSelectionRenderService, getCurrentRangeDisable$, SetScrollOperation, SetZoomRatioOperation, SheetPrintInterceptorService, COPY_TYPE, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges, ISheetClipboardService } from "@univerjs/sheets-ui";
11
- import { takeUntil, Subject, BehaviorSubject, combineLatest, map, filter, distinctUntilChanged, first } from "rxjs";
12
- import { ISidebarService, BuiltInUIPart, IUIPartsService, IMessageService, MenuItemType, MenuPosition, MenuGroup, getMenuHiddenObservable, KeyCode, ComponentManager, IMenuService, IShortcutService, CanvasFloatDomService } from "@univerjs/ui";
13
- import { getSheetCommandTarget, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, InsertRowCommand, InsertColCommand, RemoveRowCommand, RemoveColCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, DeltaRowHeightCommand, SetRowHeightCommand, DeltaColumnWidthCommand, SetColWidthCommand, SetRowHiddenCommand, SetSpecificRowsVisibleCommand, SetSpecificColsVisibleCommand, SetColHiddenCommand, SetRowVisibleMutation, SetRowHiddenMutation, SetColVisibleMutation, SetColHiddenMutation, SetWorksheetRowHeightMutation, SetWorksheetColWidthMutation, SetWorksheetActiveOperation, SheetInterceptorService, SetFrozenMutation, WorkbookViewPermission, WorksheetViewPermission } from "@univerjs/sheets";
11
+ import { takeUntil, Subject, BehaviorSubject, combineLatest, map, filter, distinctUntilChanged } from "rxjs";
12
+ import { ISidebarService, BuiltInUIPart, IUIPartsService, IMessageService, MenuItemType, getMenuHiddenObservable, KeyCode, RibbonStartGroup, ComponentManager, IMenuManagerService, IShortcutService, CanvasFloatDomService } from "@univerjs/ui";
13
+ import { getSheetCommandTarget, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, InsertRowCommand, InsertColCommand, RemoveRowCommand, RemoveColCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, DeltaRowHeightCommand, SetRowHeightCommand, DeltaColumnWidthCommand, SetColWidthCommand, SetRowHiddenCommand, SetSpecificRowsVisibleCommand, SetSpecificColsVisibleCommand, SetColHiddenCommand, MoveColsCommand, MoveRowsCommand, MoveRangeCommand, SetRowVisibleMutation, SetRowHiddenMutation, SetColVisibleMutation, SetColHiddenMutation, SetWorksheetRowHeightMutation, SetWorksheetColWidthMutation, SetWorksheetActiveOperation, SheetInterceptorService, SetFrozenMutation, WorkbookViewPermission, WorksheetViewPermission } from "@univerjs/sheets";
14
14
  import React, { useEffect, forwardRef, useRef, createElement, useState } from "react";
15
15
  import { MessageType, RadioGroup, Radio } from "@univerjs/design";
16
16
  import clsx from "clsx";
@@ -152,8 +152,8 @@ let DrawingPopupMenuController = (_a = class extends RxDisposable {
152
152
  const oKey = object.oKey, drawingParam = this._drawingManagerService.getDrawingOKey(oKey);
153
153
  if (!drawingParam)
154
154
  return;
155
- const { unitId: unitId2, subUnitId, drawingId } = drawingParam;
156
- singletonPopupDisposer == null || singletonPopupDisposer.dispose(), singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
155
+ const { unitId: unitId2, subUnitId, drawingId, drawingType } = drawingParam;
156
+ drawingType !== DrawingTypeEnum.DRAWING_DOM && (singletonPopupDisposer == null || singletonPopupDisposer.dispose(), singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
157
157
  componentKey: COMPONENT_IMAGE_POPUP_MENU,
158
158
  direction: "horizontal",
159
159
  offset: [2, 0],
@@ -164,7 +164,7 @@ let DrawingPopupMenuController = (_a = class extends RxDisposable {
164
164
  unitId: unitId2,
165
165
  subUnitId,
166
166
  drawingId
167
- }]);
167
+ }]));
168
168
  })
169
169
  )
170
170
  ), this.disposeWithMe(
@@ -748,8 +748,6 @@ function ImageMenuFactory(accessor) {
748
748
  return {
749
749
  id: IMAGE_MENU_ID,
750
750
  type: MenuItemType.SUBITEMS,
751
- positions: [MenuPosition.TOOLBAR_START],
752
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
753
751
  icon: IMAGE_UPLOAD_ICON,
754
752
  tooltip: "sheetImage.title",
755
753
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
@@ -768,7 +766,6 @@ function UploadFloatImageMenuFactory(_accessor) {
768
766
  type: UploadFileType.floatImage
769
767
  }
770
768
  },
771
- positions: [IMAGE_MENU_ID],
772
769
  hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SHEET)
773
770
  };
774
771
  }
@@ -959,31 +956,33 @@ const MoveDrawingDownShortcutItem = {
959
956
  preconditions: whenSheetDrawingFocused,
960
957
  binding: KeyCode.DELETE,
961
958
  mac: KeyCode.BACKSPACE
959
+ }, menuSchema = {
960
+ [RibbonStartGroup.FORMULAS_INSERT]: {
961
+ [IMAGE_MENU_ID]: {
962
+ order: 3,
963
+ menuItemFactory: ImageMenuFactory,
964
+ [InsertFloatImageOperation.id]: {
965
+ order: 0,
966
+ menuItemFactory: UploadFloatImageMenuFactory
967
+ }
968
+ }
969
+ }
962
970
  };
963
971
  var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
964
972
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
965
973
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
966
974
  return kind && result && __defProp$7(target, key, result), result;
967
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7");
968
- const DefaultSheetsDrawingConfig = {};
969
- var _a3;
975
+ }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a3;
970
976
  let SheetDrawingUIController = (_a3 = class extends Disposable {
971
- constructor(_config, _injector, _componentManager, _menuService, _commandService, _shortcutService) {
972
- super(), this._config = _config, this._injector = _injector, this._componentManager = _componentManager, this._menuService = _menuService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._init();
977
+ constructor(_injector, _componentManager, _menuManagerService, _commandService, _shortcutService) {
978
+ super(), this._injector = _injector, this._componentManager = _componentManager, this._menuManagerService = _menuManagerService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._init();
973
979
  }
974
980
  _initCustomComponents() {
975
981
  const componentManager = this._componentManager;
976
982
  this.disposeWithMe(componentManager.register(IMAGE_UPLOAD_ICON, AddImageSingle)), this.disposeWithMe(componentManager.register(COMPONENT_UPLOAD_FILE_MENU, UploadFileMenu)), this.disposeWithMe(componentManager.register(COMPONENT_SHEET_DRAWING_PANEL, SheetDrawingPanel));
977
983
  }
978
984
  _initMenus() {
979
- const { menu = {} } = this._config;
980
- [
981
- ImageMenuFactory,
982
- UploadFloatImageMenuFactory
983
- // UploadCellImageMenuFactory,
984
- ].forEach((menuFactory) => {
985
- this._menuService.addMenuItem(menuFactory(this._injector), menu);
986
- });
985
+ this._menuManagerService.mergeMenu(menuSchema);
987
986
  }
988
987
  _initCommands() {
989
988
  [
@@ -1020,11 +1019,11 @@ let SheetDrawingUIController = (_a3 = class extends Disposable {
1020
1019
  }, __name(_a3, "SheetDrawingUIController"), _a3);
1021
1020
  SheetDrawingUIController = __decorateClass$7([
1022
1021
  OnLifecycle(LifecycleStages.Rendered, SheetDrawingUIController),
1023
- __decorateParam$7(1, Inject(Injector)),
1024
- __decorateParam$7(2, Inject(ComponentManager)),
1025
- __decorateParam$7(3, IMenuService),
1026
- __decorateParam$7(4, ICommandService),
1027
- __decorateParam$7(5, IShortcutService)
1022
+ __decorateParam$7(0, Inject(Injector)),
1023
+ __decorateParam$7(1, Inject(ComponentManager)),
1024
+ __decorateParam$7(2, IMenuManagerService),
1025
+ __decorateParam$7(3, ICommandService),
1026
+ __decorateParam$7(4, IShortcutService)
1028
1027
  ], SheetDrawingUIController);
1029
1028
  var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1030
1029
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
@@ -1047,7 +1046,10 @@ const UPDATE_COMMANDS = [
1047
1046
  SetRowHiddenCommand.id,
1048
1047
  SetSpecificRowsVisibleCommand.id,
1049
1048
  SetSpecificColsVisibleCommand.id,
1050
- SetColHiddenCommand.id
1049
+ SetColHiddenCommand.id,
1050
+ MoveColsCommand.id,
1051
+ MoveRowsCommand.id,
1052
+ MoveRangeCommand.id
1051
1053
  ], REFRESH_MUTATIONS = [
1052
1054
  SetRowVisibleMutation.id,
1053
1055
  SetRowHiddenMutation.id,
@@ -1058,8 +1060,8 @@ const UPDATE_COMMANDS = [
1058
1060
  ];
1059
1061
  var _a4;
1060
1062
  let SheetDrawingTransformAffectedController = (_a4 = class extends Disposable {
1061
- constructor(_context, _commandService, _selectionRenderService, _skeletonManagerService, _sheetInterceptorService, _sheetDrawingService, _drawingManagerService, _univerInstanceService) {
1062
- super(), this._context = _context, this._commandService = _commandService, this._selectionRenderService = _selectionRenderService, this._skeletonManagerService = _skeletonManagerService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._univerInstanceService = _univerInstanceService, this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener();
1063
+ constructor(_context, _renderManagerService, _commandService, _selectionRenderService, _skeletonManagerService, _sheetInterceptorService, _sheetDrawingService, _drawingManagerService, _univerInstanceService) {
1064
+ super(), this._context = _context, this._renderManagerService = _renderManagerService, this._commandService = _commandService, this._selectionRenderService = _selectionRenderService, this._skeletonManagerService = _skeletonManagerService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._univerInstanceService = _univerInstanceService, this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener();
1063
1065
  }
1064
1066
  _sheetInterceptorListener() {
1065
1067
  this.disposeWithMe(
@@ -1072,6 +1074,8 @@ let SheetDrawingTransformAffectedController = (_a4 = class extends Disposable {
1072
1074
  const cId = commandInfo.id;
1073
1075
  if (cId === InsertRowCommand.id)
1074
1076
  return this._moveRowInterceptor(commandInfo.params, "insert");
1077
+ if ([MoveColsCommand.id, MoveRowsCommand.id, MoveRangeCommand.id].includes(cId))
1078
+ return this._moveRangeInterceptor(commandInfo.params);
1075
1079
  if (cId === InsertColCommand.id)
1076
1080
  return this._moveColInterceptor(commandInfo.params, "insert");
1077
1081
  if (cId === RemoveRowCommand.id)
@@ -1406,6 +1410,52 @@ let SheetDrawingTransformAffectedController = (_a4 = class extends Disposable {
1406
1410
  }
1407
1411
  return { unitId, subUnitId };
1408
1412
  }
1413
+ _moveRangeInterceptor(params) {
1414
+ var _a11, _b;
1415
+ const { toRange, fromRange } = params, target = getSheetCommandTarget(this._univerInstanceService);
1416
+ if (!target)
1417
+ return { redos: [], undos: [] };
1418
+ const { unitId, subUnitId } = target, skeleton = (_b = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService)) == null ? void 0 : _b.getCurrentSkeleton();
1419
+ if (!skeleton)
1420
+ return { redos: [], undos: [] };
1421
+ const selectionRect = attachRangeWithCoord(skeleton, fromRange);
1422
+ if (!selectionRect)
1423
+ return { redos: [], undos: [] };
1424
+ const { startX, endX, startY, endY } = selectionRect, drawings = this._sheetDrawingService.getDrawingData(unitId, subUnitId), containedDrawings = [];
1425
+ Object.keys(drawings).forEach((drawingId) => {
1426
+ const drawing = drawings[drawingId];
1427
+ if (drawing.anchorType !== SheetDrawingAnchorType.Both)
1428
+ return;
1429
+ const { transform } = drawing;
1430
+ if (!transform)
1431
+ return;
1432
+ const { left = 0, top = 0, width = 0, height = 0 } = transform, { drawingStartX, drawingEndX, drawingStartY, drawingEndY } = {
1433
+ drawingStartX: left,
1434
+ drawingEndX: left + width,
1435
+ drawingStartY: top,
1436
+ drawingEndY: top + height
1437
+ };
1438
+ startX <= drawingStartX && drawingEndX <= endX && startY <= drawingStartY && drawingEndY <= endY && containedDrawings.push(drawing);
1439
+ });
1440
+ const redos = [], undos = [], rowOffset = toRange.startRow - fromRange.startRow, colOffset = toRange.startColumn - fromRange.startColumn, updateDrawings = containedDrawings.map((drawing) => {
1441
+ const oldSheetTransform = drawing.sheetTransform, sheetTransform = {
1442
+ to: { ...oldSheetTransform.to, row: oldSheetTransform.to.row + rowOffset, column: oldSheetTransform.to.column + colOffset },
1443
+ from: { ...oldSheetTransform.from, row: oldSheetTransform.from.row + rowOffset, column: oldSheetTransform.from.column + colOffset }
1444
+ }, transform = drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService);
1445
+ return {
1446
+ unitId,
1447
+ subUnitId,
1448
+ drawingId: drawing.drawingId,
1449
+ transform,
1450
+ sheetTransform
1451
+ };
1452
+ });
1453
+ if (updateDrawings.length) {
1454
+ const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
1455
+ redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
1456
+ }
1457
+ return { redos, undos };
1458
+ }
1409
1459
  _moveRowInterceptor(params, type) {
1410
1460
  const ids = this._getUnitIdAndSubUnitId(params, type);
1411
1461
  if (ids == null)
@@ -1421,7 +1471,7 @@ let SheetDrawingTransformAffectedController = (_a4 = class extends Disposable {
1421
1471
  newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1422
1472
  } else {
1423
1473
  const { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
1424
- if (fromRow >= rowStartIndex && toRow <= rowEndIndex)
1474
+ if (anchorType === SheetDrawingAnchorType.Both && fromRow >= rowStartIndex && toRow <= rowEndIndex)
1425
1475
  deleteDrawings.push({ unitId, subUnitId, drawingId });
1426
1476
  else {
1427
1477
  const param = this._shrinkRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType);
@@ -1462,7 +1512,7 @@ let SheetDrawingTransformAffectedController = (_a4 = class extends Disposable {
1462
1512
  newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1463
1513
  } else {
1464
1514
  const { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
1465
- if (fromColumn >= colStartIndex && toColumn <= colEndIndex)
1515
+ if (anchorType === SheetDrawingAnchorType.Both && fromColumn >= colStartIndex && toColumn <= colEndIndex)
1466
1516
  deleteDrawings.push({ unitId, subUnitId, drawingId });
1467
1517
  else {
1468
1518
  const param = this._shrinkCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType);
@@ -1662,7 +1712,7 @@ let SheetDrawingTransformAffectedController = (_a4 = class extends Disposable {
1662
1712
  const params = command.params, { unitId: showUnitId, subUnitId: showSubunitId } = params, drawingMap = this._drawingManagerService.drawingManagerData, insertDrawings = [], removeDrawings = [];
1663
1713
  Object.keys(drawingMap).forEach((unitId) => {
1664
1714
  const subUnitMap = drawingMap[unitId];
1665
- Object.keys(subUnitMap).forEach((subUnitId) => {
1715
+ subUnitMap != null && Object.keys(subUnitMap).forEach((subUnitId) => {
1666
1716
  const drawingData = subUnitMap[subUnitId].data;
1667
1717
  drawingData != null && Object.keys(drawingData).forEach((drawingId) => {
1668
1718
  if (unitId === showUnitId && subUnitId === showSubunitId) {
@@ -1690,7 +1740,7 @@ let SheetDrawingTransformAffectedController = (_a4 = class extends Disposable {
1690
1740
  _refreshDrawingTransform(unitId, subUnitId, ranges) {
1691
1741
  const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [];
1692
1742
  Object.keys(drawingData).forEach((drawingId) => {
1693
- const drawing = drawingData[drawingId], { sheetTransform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1743
+ const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1694
1744
  if (anchorType === SheetDrawingAnchorType.None)
1695
1745
  return !0;
1696
1746
  const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
@@ -1710,9 +1760,14 @@ let SheetDrawingTransformAffectedController = (_a4 = class extends Disposable {
1710
1760
  endColumn: toColumn
1711
1761
  }
1712
1762
  ) || fromRow > endRow || fromColumn > endColumn) {
1763
+ const isPositionAnchor = anchorType === SheetDrawingAnchorType.Position, newTransform = drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService);
1713
1764
  updateDrawings.push({
1714
1765
  ...drawing,
1715
- transform: drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService)
1766
+ transform: {
1767
+ ...newTransform,
1768
+ width: isPositionAnchor ? transform == null ? void 0 : transform.width : newTransform == null ? void 0 : newTransform.width,
1769
+ height: isPositionAnchor ? transform == null ? void 0 : transform.height : newTransform == null ? void 0 : newTransform.height
1770
+ }
1716
1771
  });
1717
1772
  break;
1718
1773
  }
@@ -1721,13 +1776,14 @@ let SheetDrawingTransformAffectedController = (_a4 = class extends Disposable {
1721
1776
  }
1722
1777
  }, __name(_a4, "SheetDrawingTransformAffectedController"), _a4);
1723
1778
  SheetDrawingTransformAffectedController = __decorateClass$6([
1724
- __decorateParam$6(1, ICommandService),
1725
- __decorateParam$6(2, ISheetSelectionRenderService),
1726
- __decorateParam$6(3, Inject(SheetSkeletonManagerService)),
1727
- __decorateParam$6(4, Inject(SheetInterceptorService)),
1728
- __decorateParam$6(5, ISheetDrawingService),
1729
- __decorateParam$6(6, IDrawingManagerService),
1730
- __decorateParam$6(7, IUniverInstanceService)
1779
+ __decorateParam$6(1, IRenderManagerService),
1780
+ __decorateParam$6(2, ICommandService),
1781
+ __decorateParam$6(3, ISheetSelectionRenderService),
1782
+ __decorateParam$6(4, Inject(SheetSkeletonManagerService)),
1783
+ __decorateParam$6(5, Inject(SheetInterceptorService)),
1784
+ __decorateParam$6(6, ISheetDrawingService),
1785
+ __decorateParam$6(7, IDrawingManagerService),
1786
+ __decorateParam$6(8, IUniverInstanceService)
1731
1787
  ], SheetDrawingTransformAffectedController);
1732
1788
  var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1733
1789
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
@@ -1828,8 +1884,11 @@ let SheetCanvasFloatDomManagerService = (_a5 = class extends Disposable {
1828
1884
  this._drawingManagerService.add$.subscribe((params) => {
1829
1885
  params.forEach((param) => {
1830
1886
  var _a11, _b, _c;
1831
- const { unitId, subUnitId, drawingId } = param, target = getSheetCommandTarget(this._univerInstanceService, { unitId, subUnitId }), floatDomParam = this._drawingManagerService.getDrawingByParam(param), skeleton = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
1832
- if (floatDomParam == null || target == null || skeleton == null)
1887
+ const { unitId, subUnitId, drawingId } = param, target = getSheetCommandTarget(this._univerInstanceService, { unitId, subUnitId }), floatDomParam = this._drawingManagerService.getDrawingByParam(param);
1888
+ if (!floatDomParam || !target)
1889
+ return;
1890
+ const skeleton = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
1891
+ if (!skeleton)
1833
1892
  return;
1834
1893
  const { transform, drawingType, data } = floatDomParam;
1835
1894
  if (drawingType !== DrawingTypeEnum$1.DRAWING_DOM)
@@ -1852,7 +1911,7 @@ let SheetCanvasFloatDomManagerService = (_a5 = class extends Disposable {
1852
1911
  height,
1853
1912
  zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
1854
1913
  }, rect = new Rect(rectShapeKey, imageConfig);
1855
- scene.addObject(rect, DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(rect);
1914
+ scene.addObject(rect, DRAWING_OBJECT_LAYER_INDEX), floatDomParam.allowTransform !== !1 && scene.attachTransformerTo(rect);
1856
1915
  const map2 = this._ensureMap(unitId, subUnitId), disposableCollection = new DisposableCollection(), initPosition = calcPosition(rect, renderObject.renderObject, skeleton.skeleton, target.worksheet), position$ = new BehaviorSubject(initPosition), info = {
1857
1916
  dispose: disposableCollection,
1858
1917
  rect,
@@ -1981,7 +2040,7 @@ let SheetCanvasFloatDomManagerService = (_a5 = class extends Disposable {
1981
2040
  });
1982
2041
  if (!target)
1983
2042
  throw new Error("cannot find current target!");
1984
- const { unitId, subUnitId } = target, { initPosition, componentKey, data } = layer, id = propId != null ? propId : generateRandomId(), sheetTransform = this._getPosition(initPosition, unitId);
2043
+ const { unitId, subUnitId } = target, { initPosition, componentKey, data, allowTransform = !0 } = layer, id = propId != null ? propId : generateRandomId(), sheetTransform = this._getPosition(initPosition, unitId);
1985
2044
  if (sheetTransform == null)
1986
2045
  return;
1987
2046
  this._ensureMap(unitId, subUnitId).set(id, layer);
@@ -1998,7 +2057,8 @@ let SheetCanvasFloatDomManagerService = (_a5 = class extends Disposable {
1998
2057
  width: initPosition.endX - initPosition.startX,
1999
2058
  height: initPosition.endY - initPosition.startY
2000
2059
  },
2001
- data
2060
+ data,
2061
+ allowTransform
2002
2062
  };
2003
2063
  return this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
2004
2064
  unitId,
@@ -2284,9 +2344,9 @@ let SheetsDrawingCopyPasteController = (_a8 = class extends Disposable {
2284
2344
  }
2285
2345
  _collect(unitId, subUnitId, range) {
2286
2346
  var _a11;
2287
- const skeletonManagetService = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService);
2288
- if (!skeletonManagetService) return;
2289
- const selectionRect = skeletonManagetService.attachRangeWithCoord(range);
2347
+ const skeletonManagerService = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService);
2348
+ if (!skeletonManagerService) return;
2349
+ const selectionRect = skeletonManagerService.attachRangeWithCoord(range);
2290
2350
  if (!selectionRect)
2291
2351
  return;
2292
2352
  const { startX, endX, startY, endY } = selectionRect, drawings = this._sheetDrawingService.getDrawingData(unitId, subUnitId), containedDrawings = [];
@@ -2324,15 +2384,15 @@ let SheetsDrawingCopyPasteController = (_a8 = class extends Disposable {
2324
2384
  const { copyRange } = copyInfo;
2325
2385
  if (!copyRange)
2326
2386
  return { redos: [], undos: [] };
2327
- const { drawings, unitId, subUnitId } = this._copyInfo, { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyRange, pastedRange]), { row: copyRow, col: copyCol } = mapFunc(vCopyRange.startRow, vCopyRange.startColumn), { row: pasteRow, col: pasteCol } = mapFunc(vPastedRange.startRow, vPastedRange.startColumn), skeletonManagetService = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService);
2328
- if (!skeletonManagetService)
2387
+ const { drawings, unitId, subUnitId } = this._copyInfo, { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyRange, pastedRange]), { row: copyRow, col: copyCol } = mapFunc(vCopyRange.startRow, vCopyRange.startColumn), { row: pasteRow, col: pasteCol } = mapFunc(vPastedRange.startRow, vPastedRange.startColumn), skeletonManagerService = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService);
2388
+ if (!skeletonManagerService)
2329
2389
  return { redos: [], undos: [] };
2330
- const copyRect = skeletonManagetService.attachRangeWithCoord({
2390
+ const copyRect = skeletonManagerService.attachRangeWithCoord({
2331
2391
  startRow: copyRow,
2332
2392
  endRow: copyRow,
2333
2393
  startColumn: copyCol,
2334
2394
  endColumn: copyCol
2335
- }), pasteRect = skeletonManagetService.attachRangeWithCoord({
2395
+ }), pasteRect = skeletonManagerService.attachRangeWithCoord({
2336
2396
  startRow: pasteRow,
2337
2397
  endRow: pasteRow,
2338
2398
  startColumn: pasteCol,
@@ -2403,23 +2463,35 @@ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPrope
2403
2463
  return kind && result && __defProp$1(target, key, result), result;
2404
2464
  }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a9;
2405
2465
  let SheetsDrawingRenderController = (_a9 = class extends Disposable {
2406
- constructor(_context, _sheetDrawingService, _drawingManagerService, _lifecycleService) {
2407
- super(), this._context = _context, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._lifecycleService = _lifecycleService, this._init();
2466
+ constructor(_context, _sheetDrawingService, _drawingManagerService, _lifecycleService, _sheetSelectionRenderService, _sheetSkeletonManagerService) {
2467
+ super(), this._context = _context, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._lifecycleService = _lifecycleService, this._sheetSelectionRenderService = _sheetSelectionRenderService, this._sheetSkeletonManagerService = _sheetSkeletonManagerService, this._init();
2408
2468
  }
2409
2469
  _init() {
2410
2470
  this._drawingInitializeListener();
2411
2471
  }
2412
2472
  _drawingInitializeListener() {
2413
- this._lifecycleService.lifecycle$.pipe(filter((e) => e === LifecycleStages.Steady), first()).subscribe(() => {
2414
- this._context.type === UniverInstanceType.UNIVER_SHEET && (this._sheetDrawingService.initializeNotification(this._context.unitId), this._drawingManagerService.initializeNotification(this._context.unitId));
2415
- });
2473
+ if (this._context.type === UniverInstanceType.UNIVER_SHEET) {
2474
+ this._sheetDrawingService.initializeNotification(this._context.unitId);
2475
+ const data = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);
2476
+ for (const subUnit in data) {
2477
+ const subUnitData = data[subUnit];
2478
+ for (const drawingId in subUnitData.data) {
2479
+ const drawingData = subUnitData.data[drawingId];
2480
+ drawingData.transform = drawingPositionToTransform(drawingData.sheetTransform, this._sheetSelectionRenderService, this._sheetSkeletonManagerService);
2481
+ }
2482
+ }
2483
+ this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)), this._drawingManagerService.initializeNotification(this._context.unitId);
2484
+ }
2416
2485
  }
2417
2486
  }, __name(_a9, "SheetsDrawingRenderController"), _a9);
2418
2487
  SheetsDrawingRenderController = __decorateClass$1([
2419
2488
  __decorateParam$1(1, ISheetDrawingService),
2420
2489
  __decorateParam$1(2, IDrawingManagerService),
2421
- __decorateParam$1(3, Inject(LifecycleService))
2490
+ __decorateParam$1(3, Inject(LifecycleService)),
2491
+ __decorateParam$1(4, Inject(ISheetSelectionRenderService)),
2492
+ __decorateParam$1(5, Inject(SheetSkeletonManagerService))
2422
2493
  ], SheetsDrawingRenderController);
2494
+ const PLUGIN_CONFIG_KEY = "sheets-drawing-ui.config", defaultPluginConfig = {};
2423
2495
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2424
2496
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2425
2497
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -2428,10 +2500,10 @@ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnProperty
2428
2500
  const PLUGIN_NAME = "SHEET_IMAGE_UI_PLUGIN";
2429
2501
  var _a10;
2430
2502
  let UniverSheetsDrawingUIPlugin = (_a10 = class extends Plugin {
2431
- constructor(config = {}, _injector, _localeService, _renderManagerService) {
2432
- super();
2433
- __publicField(this, "_pluginConfig");
2434
- this._injector = _injector, this._localeService = _localeService, this._renderManagerService = _renderManagerService, this._pluginConfig = Tools.deepMerge({}, DefaultSheetsDrawingConfig, config);
2503
+ constructor(_config = defaultPluginConfig, _injector, _renderManagerService, _configService) {
2504
+ super(), this._config = _config, this._injector = _injector, this._renderManagerService = _renderManagerService, this._configService = _configService;
2505
+ const { menu, ...rest } = this._config;
2506
+ menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
2435
2507
  }
2436
2508
  onStarting() {
2437
2509
  this._initDependencies();
@@ -2442,9 +2514,7 @@ let UniverSheetsDrawingUIPlugin = (_a10 = class extends Plugin {
2442
2514
  _initDependencies() {
2443
2515
  [
2444
2516
  [SheetCanvasFloatDomManagerService],
2445
- [SheetDrawingUIController, {
2446
- useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SheetDrawingUIController, this._pluginConfig), "useFactory")
2447
- }],
2517
+ [SheetDrawingUIController],
2448
2518
  [DrawingPopupMenuController],
2449
2519
  [SheetDrawingPrintingController],
2450
2520
  [SheetDrawingPermissionController],
@@ -2466,8 +2536,8 @@ __publicField2(UniverSheetsDrawingUIPlugin, "pluginName", PLUGIN_NAME);
2466
2536
  UniverSheetsDrawingUIPlugin = __decorateClass([
2467
2537
  DependentOn(UniverDrawingPlugin, UniverDrawingUIPlugin, UniverSheetsDrawingPlugin),
2468
2538
  __decorateParam(1, Inject(Injector)),
2469
- __decorateParam(2, Inject(LocaleService)),
2470
- __decorateParam(3, IRenderManagerService)
2539
+ __decorateParam(2, IRenderManagerService),
2540
+ __decorateParam(3, IConfigService)
2471
2541
  ], UniverSheetsDrawingUIPlugin);
2472
2542
  export {
2473
2543
  ClearSheetDrawingTransformerOperation,
@@ -0,0 +1,9 @@
1
+ import { MenuConfig } from '@univerjs/ui';
2
+ import { DependencyOverride } from '@univerjs/core';
3
+ export declare const PLUGIN_CONFIG_KEY = "sheets-drawing-ui.config";
4
+ export declare const configSymbol: unique symbol;
5
+ export interface IUniverSheetsDrawingUIConfig {
6
+ menu?: MenuConfig;
7
+ overrides?: DependencyOverride;
8
+ }
9
+ export declare const defaultPluginConfig: IUniverSheetsDrawingUIConfig;
@@ -0,0 +1,2 @@
1
+ import { MenuSchemaType } from '@univerjs/ui';
2
+ export declare const menuSchema: MenuSchemaType;
@@ -2,12 +2,15 @@ import { Disposable, LifecycleService } from '@univerjs/core';
2
2
  import { IDrawingManagerService } from '@univerjs/drawing';
3
3
  import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
4
4
  import { ISheetDrawingService } from '@univerjs/sheets-drawing';
5
+ import { ISheetSelectionRenderService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';
5
6
  export declare class SheetsDrawingRenderController extends Disposable implements IRenderModule {
6
7
  private _context;
7
8
  private readonly _sheetDrawingService;
8
9
  private readonly _drawingManagerService;
9
10
  private _lifecycleService;
10
- constructor(_context: IRenderContext, _sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _lifecycleService: LifecycleService);
11
+ private _sheetSelectionRenderService;
12
+ private _sheetSkeletonManagerService;
13
+ constructor(_context: IRenderContext, _sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _lifecycleService: LifecycleService, _sheetSelectionRenderService: ISheetSelectionRenderService, _sheetSkeletonManagerService: SheetSkeletonManagerService);
11
14
  private _init;
12
15
  private _drawingInitializeListener;
13
16
  }
@@ -3,9 +3,10 @@ import { ISheetSelectionRenderService, SheetSkeletonManagerService } from '@univ
3
3
  import { IDrawingManagerService } from '@univerjs/drawing';
4
4
  import { SheetInterceptorService } from '@univerjs/sheets';
5
5
  import { ISheetDrawingService } from '@univerjs/sheets-drawing';
6
- import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
6
+ import { IRenderContext, IRenderManagerService, IRenderModule } from '@univerjs/engine-render';
7
7
  export declare class SheetDrawingTransformAffectedController extends Disposable implements IRenderModule {
8
8
  private readonly _context;
9
+ private readonly _renderManagerService;
9
10
  private readonly _commandService;
10
11
  private readonly _selectionRenderService;
11
12
  private readonly _skeletonManagerService;
@@ -13,7 +14,7 @@ export declare class SheetDrawingTransformAffectedController extends Disposable
13
14
  private readonly _sheetDrawingService;
14
15
  private readonly _drawingManagerService;
15
16
  private readonly _univerInstanceService;
16
- constructor(_context: IRenderContext<Workbook>, _commandService: ICommandService, _selectionRenderService: ISheetSelectionRenderService, _skeletonManagerService: SheetSkeletonManagerService, _sheetInterceptorService: SheetInterceptorService, _sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _univerInstanceService: IUniverInstanceService);
17
+ constructor(_context: IRenderContext<Workbook>, _renderManagerService: IRenderManagerService, _commandService: ICommandService, _selectionRenderService: ISheetSelectionRenderService, _skeletonManagerService: SheetSkeletonManagerService, _sheetInterceptorService: SheetInterceptorService, _sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _univerInstanceService: IUniverInstanceService);
17
18
  private _sheetInterceptorListener;
18
19
  private _getRangeMoveUndo;
19
20
  private _getUpdateOrDeleteDrawings;
@@ -23,6 +24,7 @@ export declare class SheetDrawingTransformAffectedController extends Disposable
23
24
  private _getDrawingUndoForRowVisible;
24
25
  private _getDrawingUndoForRowAndColSize;
25
26
  private _getUnitIdAndSubUnitId;
27
+ private _moveRangeInterceptor;
26
28
  private _moveRowInterceptor;
27
29
  private _moveColInterceptor;
28
30
  private _expandCol;
@@ -1,18 +1,12 @@
1
- import { DependencyOverride, Disposable, ICommandService, Injector } from '@univerjs/core';
2
- import { MenuConfig, ComponentManager, IMenuService, IShortcutService } from '@univerjs/ui';
3
- export interface IUniverSheetsDrawingConfig {
4
- menu?: MenuConfig;
5
- overrides?: DependencyOverride;
6
- }
7
- export declare const DefaultSheetsDrawingConfig: IUniverSheetsDrawingConfig;
1
+ import { Disposable, ICommandService, Injector } from '@univerjs/core';
2
+ import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';
8
3
  export declare class SheetDrawingUIController extends Disposable {
9
- private readonly _config;
10
4
  private readonly _injector;
11
5
  private readonly _componentManager;
12
- private readonly _menuService;
6
+ private readonly _menuManagerService;
13
7
  private readonly _commandService;
14
8
  private readonly _shortcutService;
15
- constructor(_config: Partial<IUniverSheetsDrawingConfig>, _injector: Injector, _componentManager: ComponentManager, _menuService: IMenuService, _commandService: ICommandService, _shortcutService: IShortcutService);
9
+ constructor(_injector: Injector, _componentManager: ComponentManager, _menuManagerService: IMenuManagerService, _commandService: ICommandService, _shortcutService: IShortcutService);
16
10
  private _initCustomComponents;
17
11
  private _initMenus;
18
12
  private _initCommands;
@@ -1,14 +1,14 @@
1
- import { Injector, LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
1
+ import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
2
  import { IRenderManagerService } from '@univerjs/engine-render';
3
- import { IUniverSheetsDrawingConfig } from './controllers/sheet-drawing.controller';
3
+ import { IUniverSheetsDrawingUIConfig } from './controllers/config.schema';
4
4
  export declare class UniverSheetsDrawingUIPlugin extends Plugin {
5
+ private readonly _config;
5
6
  protected _injector: Injector;
6
- private readonly _localeService;
7
7
  private readonly _renderManagerService;
8
+ private readonly _configService;
8
9
  static type: UniverInstanceType;
9
10
  static pluginName: string;
10
- private _pluginConfig;
11
- constructor(config: Partial<IUniverSheetsDrawingConfig> | undefined, _injector: Injector, _localeService: LocaleService, _renderManagerService: IRenderManagerService);
11
+ constructor(_config: Partial<IUniverSheetsDrawingUIConfig>, _injector: Injector, _renderManagerService: IRenderManagerService, _configService: IConfigService);
12
12
  onStarting(): void;
13
13
  onRendered(): void;
14
14
  private _initDependencies;
@@ -7,7 +7,7 @@ export interface ICanvasFloatDom {
7
7
  /**
8
8
  * whether allow transform float-dom
9
9
  */
10
- allowTransform: boolean;
10
+ allowTransform?: boolean;
11
11
  /**
12
12
  * initial position of float-dom
13
13
  */