@univerjs/sheets-drawing-ui 1.0.3 → 1.1.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.
Files changed (94) hide show
  1. package/lib/cjs/facade.js +18 -43
  2. package/lib/cjs/index.js +510 -67
  3. package/lib/cjs/locale/ar-SA.js +1 -0
  4. package/lib/cjs/locale/ca-ES.js +1 -0
  5. package/lib/cjs/locale/de-DE.js +1 -0
  6. package/lib/cjs/locale/en-US.js +1 -0
  7. package/lib/cjs/locale/es-ES.js +1 -0
  8. package/lib/cjs/locale/fa-IR.js +1 -0
  9. package/lib/cjs/locale/fr-FR.js +1 -0
  10. package/lib/cjs/locale/id-ID.js +1 -0
  11. package/lib/cjs/locale/it-IT.js +1 -0
  12. package/lib/cjs/locale/ja-JP.js +1 -0
  13. package/lib/cjs/locale/ko-KR.js +1 -0
  14. package/lib/cjs/locale/pl-PL.js +1 -0
  15. package/lib/cjs/locale/pt-BR.js +1 -0
  16. package/lib/cjs/locale/ru-RU.js +1 -0
  17. package/lib/cjs/locale/sk-SK.js +1 -0
  18. package/lib/cjs/locale/vi-VN.js +1 -0
  19. package/lib/cjs/locale/zh-CN.js +1 -0
  20. package/lib/cjs/locale/zh-HK.js +1 -0
  21. package/lib/cjs/locale/zh-TW.js +1 -0
  22. package/lib/es/facade.js +18 -43
  23. package/lib/es/index.js +509 -66
  24. package/lib/es/locale/ar-SA.js +1 -0
  25. package/lib/es/locale/ca-ES.js +1 -0
  26. package/lib/es/locale/de-DE.js +1 -0
  27. package/lib/es/locale/en-US.js +1 -0
  28. package/lib/es/locale/es-ES.js +1 -0
  29. package/lib/es/locale/fa-IR.js +1 -0
  30. package/lib/es/locale/fr-FR.js +1 -0
  31. package/lib/es/locale/id-ID.js +1 -0
  32. package/lib/es/locale/it-IT.js +1 -0
  33. package/lib/es/locale/ja-JP.js +1 -0
  34. package/lib/es/locale/ko-KR.js +1 -0
  35. package/lib/es/locale/pl-PL.js +1 -0
  36. package/lib/es/locale/pt-BR.js +1 -0
  37. package/lib/es/locale/ru-RU.js +1 -0
  38. package/lib/es/locale/sk-SK.js +1 -0
  39. package/lib/es/locale/vi-VN.js +1 -0
  40. package/lib/es/locale/zh-CN.js +1 -0
  41. package/lib/es/locale/zh-HK.js +1 -0
  42. package/lib/es/locale/zh-TW.js +1 -0
  43. package/lib/facade.js +18 -43
  44. package/lib/index.css +290 -0
  45. package/lib/index.js +509 -66
  46. package/lib/locale/ar-SA.js +1 -0
  47. package/lib/locale/ca-ES.js +1 -0
  48. package/lib/locale/de-DE.js +1 -0
  49. package/lib/locale/en-US.js +1 -0
  50. package/lib/locale/es-ES.js +1 -0
  51. package/lib/locale/fa-IR.js +1 -0
  52. package/lib/locale/fr-FR.js +1 -0
  53. package/lib/locale/id-ID.js +1 -0
  54. package/lib/locale/it-IT.js +1 -0
  55. package/lib/locale/ja-JP.js +1 -0
  56. package/lib/locale/ko-KR.js +1 -0
  57. package/lib/locale/pl-PL.js +1 -0
  58. package/lib/locale/pt-BR.js +1 -0
  59. package/lib/locale/ru-RU.js +1 -0
  60. package/lib/locale/sk-SK.js +1 -0
  61. package/lib/locale/vi-VN.js +1 -0
  62. package/lib/locale/zh-CN.js +1 -0
  63. package/lib/locale/zh-HK.js +1 -0
  64. package/lib/locale/zh-TW.js +1 -0
  65. package/lib/types/commands/operations/preview-sheet-image-opacity.operation.d.ts +20 -0
  66. package/lib/types/controllers/sheet-drawing-active-render.controller.d.ts +7 -2
  67. package/lib/types/facade/f-worksheet.d.ts +1 -0
  68. package/lib/types/locale/en-US.d.ts +3 -0
  69. package/lib/types/services/canvas-float-dom-manager.service.d.ts +2 -0
  70. package/lib/types/views/sheet-image-panel/SheetImageTransparency.d.ts +20 -0
  71. package/lib/types/views/sheet-image-panel/SheetImageTransparencySlider.d.ts +24 -0
  72. package/lib/types/views/sheet-image-panel/sheet-drawing-panel.util.d.ts +18 -0
  73. package/lib/umd/facade.js +1 -1
  74. package/lib/umd/index.js +2 -2
  75. package/lib/umd/locale/ar-SA.js +1 -1
  76. package/lib/umd/locale/ca-ES.js +1 -1
  77. package/lib/umd/locale/de-DE.js +1 -1
  78. package/lib/umd/locale/en-US.js +1 -1
  79. package/lib/umd/locale/es-ES.js +1 -1
  80. package/lib/umd/locale/fa-IR.js +1 -1
  81. package/lib/umd/locale/fr-FR.js +1 -1
  82. package/lib/umd/locale/id-ID.js +1 -1
  83. package/lib/umd/locale/it-IT.js +1 -1
  84. package/lib/umd/locale/ja-JP.js +1 -1
  85. package/lib/umd/locale/ko-KR.js +1 -1
  86. package/lib/umd/locale/pl-PL.js +1 -1
  87. package/lib/umd/locale/pt-BR.js +1 -1
  88. package/lib/umd/locale/ru-RU.js +1 -1
  89. package/lib/umd/locale/sk-SK.js +1 -1
  90. package/lib/umd/locale/vi-VN.js +1 -1
  91. package/lib/umd/locale/zh-CN.js +1 -1
  92. package/lib/umd/locale/zh-HK.js +1 -1
  93. package/lib/umd/locale/zh-TW.js +1 -1
  94. package/package.json +16 -16
package/lib/es/index.js CHANGED
@@ -1,16 +1,16 @@
1
- import { BooleanNumber, BuildTextUtils, CommandType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Direction, Disposable, DisposableCollection, DrawingTypeEnum, FOCUSING_COMMON_DRAWINGS, FOCUSING_FX_BAR_EDITOR, FOCUSING_PANEL_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET, ICommandService, IConfigService, IContextService, IImageIoService, IPermissionService, IURLImageService, IUndoRedoService, IUniverInstanceService, ImageCacheMap, ImageSourceType, ImageUploadStatusType, Inject, Injector, InterceptorEffectEnum, LifecycleService, LifecycleStages, LocaleService, ObjectMatrix, Optional, Plugin, PositionedObjectLayoutType, RxDisposable, Tools, UniverInstanceType, UserManagerService, WrapTextType, createDocumentModelWithStyle, createIdentifier, fromEventSubject, generateRandomId, merge, mergeOverrideWithDependencies, registerDependencies, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
2
- import { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SetWorksheetBackgroundImageCommand, SetWorksheetBackgroundImageMutation, SheetDrawingAnchorType, UniverSheetsDrawingPlugin, drawingPositionToTransform, getSheetDrawingPlacement, transformToAxisAlignPosition, transformToDrawingPosition } from "@univerjs/sheets-drawing";
1
+ import { BooleanNumber, BuildTextUtils, CommandType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Direction, Disposable, DisposableCollection, DrawingTypeEnum, FOCUSING_COMMON_DRAWINGS, FOCUSING_FX_BAR_EDITOR, FOCUSING_PANEL_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET, ICommandService, IConfigService, IContextService, IImageIoService, ILogService, IPermissionService, IURLImageService, IUndoRedoService, IUniverInstanceService, ImageCacheMap, ImageSourceType, ImageUploadStatusType, Inject, Injector, InterceptorEffectEnum, LifecycleService, LifecycleStages, LocaleService, ObjectMatrix, Optional, Plugin, PositionedObjectLayoutType, RxDisposable, Tools, UniverInstanceType, UserManagerService, WrapTextType, createDocumentModelWithStyle, createIdentifier, fromEventSubject, generateRandomId, merge, mergeOverrideWithDependencies, registerDependencies, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
2
+ import { ClearSheetDrawingTransformerOperation, DrawingApplyType, ISheetDrawingService, InsertSheetDrawingCommand, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetDrawingArrangeCommand, SetSheetDrawingCommand, SetSheetDrawingPlacementCommand, SetWorksheetBackgroundImageCommand, SetWorksheetBackgroundImageMutation, SheetDrawingAnchorType, UniverSheetsDrawingPlugin, applySheetDrawingPlacement, drawingPositionToTransform, getSheetDrawingPlacement, transformToAxisAlignPosition, transformToDrawingPosition } from "@univerjs/sheets-drawing";
3
3
  import { CURSOR_TYPE, DEFAULT_TRANSFORMER_CONFIG, DRAWING_OBJECT_LAYER_INDEX, IRenderManagerService, Image, ObjectType, Rect, SHEET_EXTENSION_TYPE, SHEET_VIEWPORT_KEY, SheetExtension, UniverRenderEnginePlugin, Vector2, getCurrentTypeOfRenderer, getGroupState, transformObjectOutOfGroup } from "@univerjs/engine-render";
4
- import { Button, Checkbox, CheckboxGroup, FormLayout, MessageType, MobileSelect, Radio, RadioGroup, Select, clsx, render, unmount } from "@univerjs/design";
4
+ import { Button, Checkbox, CheckboxGroup, DropdownMenu, FormLayout, Input, MessageType, MobileSelect, Radio, RadioGroup, Select, borderClassName, clsx, render, unmount } from "@univerjs/design";
5
5
  import { buildDocTransform, docDrawingPositionToTransform } from "@univerjs/docs";
6
- import { DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, IDrawingManagerService, SetDrawingSelectedOperation, UniverDrawingPlugin, getDrawingImageAllowSize, getDrawingShapeKeyByDrawingSearch, getImageSize } from "@univerjs/drawing";
6
+ import { DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, IDrawingManagerService, SetDrawingSelectedOperation, UniverDrawingPlugin, getDrawingImageAllowSize, getDrawingShapeKeyByDrawingSearch, getImageSize, normalizeImageOpacity } from "@univerjs/drawing";
7
7
  import { COMMAND_LISTENER_SKELETON_CHANGE, IAutoFillService, INTERCEPTOR_POINT, InterceptCellContentPriority, RangeProtectionPermissionEditPoint, SetFrozenMutation, SetRangeValuesCommand, SetSelectionsOperation, SetWorksheetActiveOperation, SetWorksheetRowAutoHeightMutation, SheetInterceptorService, SheetPermissionCheckController, SheetSkeletonService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, WorkbookViewPermission, WorksheetEditPermission, WorksheetViewPermission, attachRangeWithCoord, discreteRangeToRange, getSheetCommandTarget, isCellImage } from "@univerjs/sheets";
8
8
  import { COPY_TYPE, EditingRenderController, HoverManagerService, IEditorBridgeService, ISheetClipboardService, ISheetSelectionRenderService, PREDEFINED_HOOK_NAME_PASTE, SetCellEditVisibleOperation, SetScrollOperation, SetZoomRatioOperation, SheetCanvasPopManagerService, SheetPrintInterceptorService, SheetSkeletonManagerService, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, getCurrentRangeDisable$, useHighlightRange, virtualizeDiscreteRanges } from "@univerjs/sheets-ui";
9
- import { CanvasFloatDomPreviewService, CanvasFloatDomService, ComponentManager, ContextMenuGroup, ContextMenuPosition, FloatingObjectToolbarPosition, IClipboardInterfaceService, IContextMenuService, IDialogService, ILayoutService, ILocalFileService, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, KeyCode, MenuItemType, PrintFloatDomSingle, RibbonDataGroup, RibbonInsertGroup, RibbonPosition, RibbonViewGroup, UndoRedoGroupService, UniverMobileUIPlugin, connectInjector, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
9
+ import { CanvasFloatDomPreviewService, CanvasFloatDomService, ComponentManager, ContextMenuGroup, ContextMenuPosition, FloatingObjectToolbarPosition, IClipboardInterfaceService, IContextMenuService, IDialogService, ILayoutService, ILocalFileService, IMenuManagerService, IMessageService, IShortcutService, ISidebarService, IconManager, KeyCode, MenuItemType, PrintFloatDomSingle, RibbonDataGroup, RibbonInsertGroup, RibbonPosition, RibbonViewGroup, UndoRedoGroupService, UniverMobileUIPlugin, connectInjector, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
10
10
  import { COMPONENT_IMAGE_POPUP_MENU, COMPONENT_MOBILE_IMAGE_POPUP_MENU, DrawingCommonPanel, DrawingRenderService, ImageCropperObject, ImageResetSizeOperation, OpenImageCropOperation, UniverDrawingMobileUIPlugin, UniverDrawingUIPlugin, disposeDrawingRenderObject, insertGroupObject } from "@univerjs/drawing-ui";
11
11
  import { BehaviorSubject, EMPTY, Observable, Subject, combineLatest, distinctUntilChanged, filter, map, of, switchMap, take, takeUntil, tap, throttleTime, timer } from "rxjs";
12
12
  import { DocDrawingController, UniverDocsDrawingPlugin } from "@univerjs/docs-drawing";
13
- import { useCallback, useEffect, useMemo, useState } from "react";
13
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
14
14
  import { jsx, jsxs } from "react/jsx-runtime";
15
15
  import { InnerPasteCommand } from "@univerjs/docs-ui";
16
16
 
@@ -427,7 +427,7 @@ function readUint32Be(bytes, offset) {
427
427
  }
428
428
 
429
429
  //#endregion
430
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
430
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
431
431
  function _typeof(o) {
432
432
  "@babel/helpers - typeof";
433
433
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -438,7 +438,7 @@ function _typeof(o) {
438
438
  }
439
439
 
440
440
  //#endregion
441
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
441
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
442
442
  function toPrimitive(t, r) {
443
443
  if ("object" != _typeof(t) || !t) return t;
444
444
  var e = t[Symbol.toPrimitive];
@@ -451,14 +451,14 @@ function toPrimitive(t, r) {
451
451
  }
452
452
 
453
453
  //#endregion
454
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
454
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
455
455
  function toPropertyKey(t) {
456
456
  var i = toPrimitive(t, "string");
457
457
  return "symbol" == _typeof(i) ? i : i + "";
458
458
  }
459
459
 
460
460
  //#endregion
461
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
461
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
462
462
  function _defineProperty(e, r, t) {
463
463
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
464
464
  value: t,
@@ -469,7 +469,7 @@ function _defineProperty(e, r, t) {
469
469
  }
470
470
 
471
471
  //#endregion
472
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
472
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
473
473
  function __decorateParam(paramIndex, decorator) {
474
474
  return function(target, key) {
475
475
  decorator(target, key, paramIndex);
@@ -477,7 +477,7 @@ function __decorateParam(paramIndex, decorator) {
477
477
  }
478
478
 
479
479
  //#endregion
480
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
480
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
481
481
  function __decorate(decorators, target, key, desc) {
482
482
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
483
483
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3070,7 +3070,12 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3070
3070
  domAnchor,
3071
3071
  unitId,
3072
3072
  subUnitId,
3073
- id: drawingId
3073
+ id: drawingId,
3074
+ runtimeMetadata: {
3075
+ componentKey,
3076
+ data,
3077
+ allowTransform
3078
+ }
3074
3079
  };
3075
3080
  const initedPosition = calcSheetFloatDomPosition(domRect, renderObject.renderUnit.scene, skeletonParam.skeleton, target.worksheet, floatDomInfo);
3076
3081
  const position$ = new BehaviorSubject(initedPosition);
@@ -3274,7 +3279,12 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3274
3279
  right: viewMain.right
3275
3280
  },
3276
3281
  domAnchor: domLayoutParam,
3277
- scrollDirectionResponse: "HORIZONTAL"
3282
+ scrollDirectionResponse: "HORIZONTAL",
3283
+ runtimeMetadata: {
3284
+ componentKey,
3285
+ data,
3286
+ allowTransform
3287
+ }
3278
3288
  };
3279
3289
  const initedPosition = calcSheetFloatDomPosition(domRect, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet, floatDomInfo);
3280
3290
  const position$ = new BehaviorSubject(initedPosition);
@@ -3717,7 +3727,7 @@ const menuSchema = {
3717
3727
  //#endregion
3718
3728
  //#region package.json
3719
3729
  var name = "@univerjs/sheets-drawing-ui";
3720
- var version = "1.0.3";
3730
+ var version = "1.1.0";
3721
3731
 
3722
3732
  //#endregion
3723
3733
  //#region src/config/config.ts
@@ -3948,9 +3958,19 @@ function MobileBatchSaveImagesDialog() {
3948
3958
  return /* @__PURE__ */ jsx(BatchSaveImagesDialog, { SelectComponent: MobileSelect });
3949
3959
  }
3950
3960
 
3961
+ //#endregion
3962
+ //#region src/views/sheet-image-panel/sheet-drawing-panel.util.ts
3963
+ function isSheetDrawing(drawing) {
3964
+ return Boolean(drawing && "sheetTransform" in drawing && drawing.sheetTransform);
3965
+ }
3966
+
3951
3967
  //#endregion
3952
3968
  //#region src/views/sheet-image-panel/SheetDrawingAnchor.tsx
3953
3969
  const SheetDrawingAnchor = (props) => {
3970
+ function getAnchorKind(value) {
3971
+ if (value === SheetDrawingAnchorType.Position || value === SheetDrawingAnchorType.Both || value === SheetDrawingAnchorType.None) return value;
3972
+ return null;
3973
+ }
3954
3974
  const commandService = useDependency(ICommandService);
3955
3975
  const localeService = useDependency(LocaleService);
3956
3976
  const drawingManagerService = useDependency(IDrawingManagerService);
@@ -4066,12 +4086,389 @@ const SheetDrawingAnchor = (props) => {
4066
4086
  }) })]
4067
4087
  });
4068
4088
  };
4069
- function isSheetDrawing(drawing) {
4070
- return Boolean(drawing && "sheetTransform" in drawing && "axisAlignSheetTransform" in drawing);
4089
+
4090
+ //#endregion
4091
+ //#region src/commands/operations/preview-sheet-image-opacity.operation.ts
4092
+ const PreviewSheetImageOpacityOperation = {
4093
+ id: "sheet.operation.preview-image-opacity",
4094
+ type: CommandType.OPERATION,
4095
+ handler: (accessor, params) => {
4096
+ var _renderManagerService;
4097
+ if (!params || !Number.isFinite(params.opacity)) return false;
4098
+ const scene = (_renderManagerService = accessor.get(IRenderManagerService).getRenderUnitById(params.unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.scene;
4099
+ const image = scene === null || scene === void 0 ? void 0 : scene.getObject(getDrawingShapeKeyByDrawingSearch(params));
4100
+ if (!(image instanceof Image)) return false;
4101
+ image.setOpacity(Math.min(Math.max(params.opacity, 0), 1));
4102
+ return true;
4103
+ }
4104
+ };
4105
+
4106
+ //#endregion
4107
+ //#region src/views/sheet-image-panel/SheetImageTransparencySlider.tsx
4108
+ const MIN_TRANSPARENCY = 0;
4109
+ const MAX_TRANSPARENCY = 100;
4110
+ const TRANSPARENCY_STEP = 1;
4111
+ const TRANSPARENCY_PAGE_STEP = 10;
4112
+ const DRAG_PREVIEW_INTERVAL = 50;
4113
+ function SheetImageTransparencySlider(props) {
4114
+ const { value, shortcuts, ariaLabel, disabled = false, onChange, onChangeComplete } = props;
4115
+ const localeService = useDependency(LocaleService);
4116
+ const isRtl = useObservable(localeService.direction$, localeService.getDirection()) === "rtl";
4117
+ const sliderRailRef = useRef(null);
4118
+ const dragValueRef = useRef(value);
4119
+ const pendingDragValueRef = useRef(null);
4120
+ const lastPreviewedDragValueRef = useRef(value);
4121
+ const dragPreviewTimerRef = useRef(null);
4122
+ const dragCleanupRef = useRef(null);
4123
+ const [isDragging, setIsDragging] = useState(false);
4124
+ const [dragValue, setDragValue] = useState(value);
4125
+ useEffect(() => () => {
4126
+ var _dragCleanupRef$curre;
4127
+ (_dragCleanupRef$curre = dragCleanupRef.current) === null || _dragCleanupRef$curre === void 0 || _dragCleanupRef$curre.call(dragCleanupRef);
4128
+ clearDragPreviewTimer();
4129
+ }, []);
4130
+ function getValueByClientX(clientX) {
4131
+ const rail = sliderRailRef.current;
4132
+ if (!rail) return value;
4133
+ const railRect = rail.getBoundingClientRect();
4134
+ if (railRect.width <= 0) return value;
4135
+ let ratio = (clientX - railRect.left) / railRect.width;
4136
+ ratio = Math.min(Math.max(ratio, 0), 1);
4137
+ if (isRtl) ratio = 1 - ratio;
4138
+ return normalizeTransparency$1(MIN_TRANSPARENCY + ratio * 100);
4139
+ }
4140
+ function clearDragPreviewTimer() {
4141
+ if (dragPreviewTimerRef.current != null) {
4142
+ window.clearTimeout(dragPreviewTimerRef.current);
4143
+ dragPreviewTimerRef.current = null;
4144
+ }
4145
+ }
4146
+ function previewDragValue(nextValue) {
4147
+ if (nextValue === lastPreviewedDragValueRef.current) return;
4148
+ lastPreviewedDragValueRef.current = nextValue;
4149
+ onChange === null || onChange === void 0 || onChange(nextValue);
4150
+ }
4151
+ function flushDragPreview() {
4152
+ clearDragPreviewTimer();
4153
+ const nextValue = pendingDragValueRef.current;
4154
+ pendingDragValueRef.current = null;
4155
+ if (nextValue != null) previewDragValue(nextValue);
4156
+ }
4157
+ function scheduleDragPreview(nextValue) {
4158
+ pendingDragValueRef.current = nextValue;
4159
+ if (dragPreviewTimerRef.current != null) return;
4160
+ dragPreviewTimerRef.current = window.setTimeout(() => {
4161
+ dragPreviewTimerRef.current = null;
4162
+ const pendingValue = pendingDragValueRef.current;
4163
+ pendingDragValueRef.current = null;
4164
+ if (pendingValue != null) previewDragValue(pendingValue);
4165
+ }, DRAG_PREVIEW_INTERVAL);
4166
+ }
4167
+ function updateDragValue(clientX) {
4168
+ const nextValue = getValueByClientX(clientX);
4169
+ dragValueRef.current = nextValue;
4170
+ setDragValue(nextValue);
4171
+ return nextValue;
4172
+ }
4173
+ function handlePointerDown(e) {
4174
+ var _dragCleanupRef$curre2;
4175
+ if (disabled) return;
4176
+ e.preventDefault();
4177
+ e.stopPropagation();
4178
+ (_dragCleanupRef$curre2 = dragCleanupRef.current) === null || _dragCleanupRef$curre2 === void 0 || _dragCleanupRef$curre2.call(dragCleanupRef);
4179
+ clearDragPreviewTimer();
4180
+ pendingDragValueRef.current = null;
4181
+ lastPreviewedDragValueRef.current = value;
4182
+ setIsDragging(true);
4183
+ scheduleDragPreview(updateDragValue(e.clientX));
4184
+ function cleanup() {
4185
+ window.removeEventListener("pointermove", handlePointerMove);
4186
+ window.removeEventListener("pointerup", handlePointerUp);
4187
+ window.removeEventListener("pointercancel", handlePointerUp);
4188
+ dragCleanupRef.current = null;
4189
+ }
4190
+ function handlePointerMove(event) {
4191
+ scheduleDragPreview(updateDragValue(event.clientX));
4192
+ }
4193
+ function handlePointerUp() {
4194
+ cleanup();
4195
+ flushDragPreview();
4196
+ setIsDragging(false);
4197
+ onChangeComplete === null || onChangeComplete === void 0 || onChangeComplete(dragValueRef.current);
4198
+ }
4199
+ dragCleanupRef.current = cleanup;
4200
+ window.addEventListener("pointermove", handlePointerMove);
4201
+ window.addEventListener("pointerup", handlePointerUp);
4202
+ window.addEventListener("pointercancel", handlePointerUp);
4203
+ }
4204
+ function handleSliderKeyDown(e) {
4205
+ let nextValue = null;
4206
+ if (e.key === "ArrowLeft" || e.key === "ArrowDown") nextValue = value - TRANSPARENCY_STEP;
4207
+ else if (e.key === "ArrowRight" || e.key === "ArrowUp") nextValue = value + TRANSPARENCY_STEP;
4208
+ else if (e.key === "PageDown") nextValue = value - TRANSPARENCY_PAGE_STEP;
4209
+ else if (e.key === "PageUp") nextValue = value + TRANSPARENCY_PAGE_STEP;
4210
+ else if (e.key === "Home") nextValue = MIN_TRANSPARENCY;
4211
+ else if (e.key === "End") nextValue = MAX_TRANSPARENCY;
4212
+ if (nextValue == null || disabled) return;
4213
+ e.preventDefault();
4214
+ e.stopPropagation();
4215
+ const normalizedValue = normalizeTransparency$1(nextValue);
4216
+ onChange === null || onChange === void 0 || onChange(normalizedValue);
4217
+ onChangeComplete === null || onChangeComplete === void 0 || onChangeComplete(normalizedValue);
4218
+ }
4219
+ const visualValue = isDragging ? dragValue : value;
4220
+ const sliderOffset = normalizeTransparency$1(visualValue);
4221
+ const handleOffset = isRtl ? MAX_TRANSPARENCY - sliderOffset : sliderOffset;
4222
+ return /* @__PURE__ */ jsxs("div", {
4223
+ className: clsx("univer-flex univer-select-none univer-items-center univer-gap-1.5", { "univer-cursor-not-allowed": disabled }),
4224
+ children: [/* @__PURE__ */ jsx("div", {
4225
+ className: "univer-flex univer-h-6 univer-min-w-0 univer-flex-1 univer-items-center",
4226
+ children: /* @__PURE__ */ jsx("div", {
4227
+ className: clsx("univer-relative univer-h-1.5 univer-w-full univer-rounded-full univer-bg-gray-200 univer-px-1.5 univer-transition-colors dark:!univer-bg-gray-600", { "univer-opacity-60": disabled }),
4228
+ children: /* @__PURE__ */ jsxs("div", {
4229
+ ref: sliderRailRef,
4230
+ "data-u-comp": "sheet-image-transparency-slider-track",
4231
+ className: "univer-relative univer-h-1.5 univer-bg-gray-200 dark:!univer-bg-gray-600",
4232
+ onPointerDown: handlePointerDown,
4233
+ children: [/* @__PURE__ */ jsx("div", {
4234
+ className: clsx("univer-bg-primary-500/60 univer-absolute univer-top-0 univer-h-full univer-rounded-full", isRtl ? "univer-right-0" : "univer-left-0"),
4235
+ style: { width: `${sliderOffset}%` }
4236
+ }), /* @__PURE__ */ jsx("button", {
4237
+ className: clsx("univer-absolute univer-top-1/2 univer-size-3.5 -univer-translate-x-1/2 -univer-translate-y-1/2 univer-rounded-full univer-bg-gray-0 univer-shadow-sm focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-primary-100 dark:!univer-bg-gray-800", borderClassName, {
4238
+ "univer-cursor-pointer hover:univer-border-primary-600 hover:univer-shadow-md": !disabled,
4239
+ "univer-cursor-not-allowed": disabled,
4240
+ "univer-scale-105 univer-border-primary-600 univer-shadow-md": isDragging,
4241
+ "univer-transition-all": !isDragging,
4242
+ "univer-transition-none": isDragging
4243
+ }),
4244
+ role: "slider",
4245
+ "aria-label": ariaLabel,
4246
+ "aria-valuemin": MIN_TRANSPARENCY,
4247
+ "aria-valuemax": MAX_TRANSPARENCY,
4248
+ "aria-valuenow": visualValue,
4249
+ "aria-valuetext": `${visualValue}%`,
4250
+ disabled,
4251
+ type: "button",
4252
+ style: { left: `${handleOffset}%` },
4253
+ onKeyDown: handleSliderKeyDown
4254
+ })]
4255
+ })
4256
+ })
4257
+ }), /* @__PURE__ */ jsx(SheetImageTransparencyInput, {
4258
+ value,
4259
+ shortcuts,
4260
+ ariaLabel,
4261
+ disabled,
4262
+ onChange,
4263
+ onChangeComplete
4264
+ })]
4265
+ });
4266
+ }
4267
+ function SheetImageTransparencyInput(props) {
4268
+ const { value, shortcuts, ariaLabel, disabled = false, onChange, onChangeComplete } = props;
4269
+ const iconManager = useDependency(IconManager);
4270
+ const isEditingRef = useRef(false);
4271
+ const [listVisible, setListVisible] = useState(false);
4272
+ const [inputValue, setInputValue] = useState(() => `${value}%`);
4273
+ useEffect(() => {
4274
+ if (!isEditingRef.current) setInputValue(`${value}%`);
4275
+ }, [value]);
4276
+ function emitValue(nextValue) {
4277
+ const normalizedValue = normalizeTransparency$1(nextValue);
4278
+ onChange === null || onChange === void 0 || onChange(normalizedValue);
4279
+ onChangeComplete === null || onChangeComplete === void 0 || onChangeComplete(normalizedValue);
4280
+ }
4281
+ function handleSelect(nextValue) {
4282
+ if (disabled) return;
4283
+ setListVisible(false);
4284
+ emitValue(nextValue);
4285
+ }
4286
+ function handleFocus() {
4287
+ if (disabled) return;
4288
+ isEditingRef.current = true;
4289
+ setInputValue(String(value));
4290
+ }
4291
+ function commitInput() {
4292
+ if (disabled || !isEditingRef.current) return;
4293
+ const parsedValue = parseTransparency(inputValue);
4294
+ isEditingRef.current = false;
4295
+ if (parsedValue == null) {
4296
+ setInputValue(`${value}%`);
4297
+ return;
4298
+ }
4299
+ if (parsedValue === value) {
4300
+ setInputValue(`${parsedValue}%`);
4301
+ return;
4302
+ }
4303
+ emitValue(parsedValue);
4304
+ }
4305
+ function handleKeyDown(e) {
4306
+ e.stopPropagation();
4307
+ if (e.key === "Enter") {
4308
+ e.preventDefault();
4309
+ commitInput();
4310
+ e.currentTarget.blur();
4311
+ }
4312
+ }
4313
+ const items = [{
4314
+ type: "radio",
4315
+ value: value.toString(),
4316
+ options: shortcuts.map((shortcut) => ({
4317
+ value: shortcut.toString(),
4318
+ label: `${shortcut}%`
4319
+ })),
4320
+ onSelect: (selectedValue) => handleSelect(Number(selectedValue))
4321
+ }];
4322
+ const MoreDownIcon = iconManager.get("MoreDownIcon");
4323
+ return /* @__PURE__ */ jsxs("div", {
4324
+ className: clsx("univer-flex univer-h-6 univer-w-[68px] univer-flex-shrink-0 univer-items-center univer-overflow-hidden univer-rounded-md univer-border univer-border-gray-200 univer-bg-gray-0 dark:!univer-border-gray-600 dark:!univer-bg-gray-800", { "univer-opacity-60": disabled }),
4325
+ onClick: (e) => e.stopPropagation(),
4326
+ children: [/* @__PURE__ */ jsx(Input, {
4327
+ className: "univer-box-border univer-h-6 univer-min-w-0 univer-flex-1 univer-border-none univer-bg-transparent [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-full [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-px-1 [&_input]:univer-text-center [&_input]:univer-text-xs [&_input]:univer-tabular-nums",
4328
+ inputClass: "univer-w-full",
4329
+ size: "mini",
4330
+ "aria-label": ariaLabel,
4331
+ value: inputValue,
4332
+ disabled,
4333
+ type: "text",
4334
+ onChange: setInputValue,
4335
+ onFocus: handleFocus,
4336
+ onBlur: commitInput,
4337
+ onKeyDown: handleKeyDown
4338
+ }), /* @__PURE__ */ jsx(DropdownMenu, {
4339
+ align: "end",
4340
+ items,
4341
+ open: listVisible,
4342
+ disabled,
4343
+ onOpenChange: setListVisible,
4344
+ children: /* @__PURE__ */ jsx(Button, {
4345
+ className: "univer-h-6 univer-w-4 univer-rounded-none univer-p-0",
4346
+ size: "small",
4347
+ variant: "text",
4348
+ "aria-label": ariaLabel,
4349
+ disabled,
4350
+ children: /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-size-3 univer-text-gray-500 dark:!univer-text-gray-300" })
4351
+ })
4352
+ })]
4353
+ });
4071
4354
  }
4072
- function getAnchorKind(value) {
4073
- if (value === SheetDrawingAnchorType.Position || value === SheetDrawingAnchorType.Both || value === SheetDrawingAnchorType.None) return value;
4074
- return null;
4355
+ function parseTransparency(rawValue) {
4356
+ const normalizedValue = rawValue.trim().replace(/%$/, "").trim();
4357
+ if (normalizedValue === "") return null;
4358
+ const parsedValue = Number(normalizedValue);
4359
+ return Number.isFinite(parsedValue) ? normalizeTransparency$1(parsedValue) : null;
4360
+ }
4361
+ function normalizeTransparency$1(value) {
4362
+ return Math.min(Math.max(Math.round(value), MIN_TRANSPARENCY), MAX_TRANSPARENCY);
4363
+ }
4364
+
4365
+ //#endregion
4366
+ //#region src/views/sheet-image-panel/SheetImageTransparency.tsx
4367
+ const IMAGE_TRANSPARENCY_PRESETS = [
4368
+ 0,
4369
+ 15,
4370
+ 30,
4371
+ 50,
4372
+ 65,
4373
+ 80
4374
+ ];
4375
+ const SheetImageTransparency = ({ drawings }) => {
4376
+ const commandService = useDependency(ICommandService);
4377
+ const localeService = useDependency(LocaleService);
4378
+ const sheetDrawingService = useDependency(ISheetDrawingService);
4379
+ const drawingParam = isSheetDrawing(drawings[0]) ? drawings[0] : void 0;
4380
+ const currentDrawing = drawingParam ? sheetDrawingService.getDrawingByParam(drawingParam) ?? drawingParam : void 0;
4381
+ const image = (currentDrawing === null || currentDrawing === void 0 ? void 0 : currentDrawing.drawingType) === DrawingTypeEnum.DRAWING_IMAGE ? currentDrawing : void 0;
4382
+ const modelOpacity = normalizeImageOpacity(image === null || image === void 0 ? void 0 : image.opacity);
4383
+ const modelTransparency = Math.round((1 - modelOpacity) * 100);
4384
+ const [previewState, setPreviewState] = useState(null);
4385
+ const previewPendingRef = useRef(false);
4386
+ const [, setModelRevision] = useState(0);
4387
+ const transparency = image && (previewState === null || previewState === void 0 ? void 0 : previewState.unitId) === image.unitId && previewState.subUnitId === image.subUnitId && previewState.drawingId === image.drawingId ? previewState.transparency : modelTransparency;
4388
+ useEffect(() => {
4389
+ if (!drawingParam) return;
4390
+ const subscription = sheetDrawingService.update$.subscribe((updatedDrawings) => {
4391
+ if (updatedDrawings.some((updatedDrawing) => updatedDrawing.unitId === drawingParam.unitId && updatedDrawing.subUnitId === drawingParam.subUnitId && updatedDrawing.drawingId === drawingParam.drawingId)) setModelRevision((revision) => revision + 1);
4392
+ });
4393
+ return () => subscription.unsubscribe();
4394
+ }, [drawingParam, sheetDrawingService]);
4395
+ useEffect(() => {
4396
+ previewPendingRef.current = false;
4397
+ return () => {
4398
+ if (!previewPendingRef.current || !image) return;
4399
+ commandService.syncExecuteCommand(PreviewSheetImageOpacityOperation.id, {
4400
+ unitId: image.unitId,
4401
+ subUnitId: image.subUnitId,
4402
+ drawingId: image.drawingId,
4403
+ opacity: modelOpacity
4404
+ });
4405
+ };
4406
+ }, [
4407
+ commandService,
4408
+ image,
4409
+ modelOpacity,
4410
+ modelTransparency
4411
+ ]);
4412
+ if (!image) return null;
4413
+ const title = localeService.t("sheets-drawing-ui.image-transparency.title");
4414
+ const { unitId, subUnitId, drawingId } = image;
4415
+ function previewTransparency(nextTransparency) {
4416
+ const normalizedTransparency = normalizeTransparency(nextTransparency);
4417
+ const opacity = transparencyToOpacity(normalizedTransparency);
4418
+ previewPendingRef.current = true;
4419
+ setPreviewState({
4420
+ unitId,
4421
+ subUnitId,
4422
+ drawingId,
4423
+ transparency: normalizedTransparency
4424
+ });
4425
+ commandService.syncExecuteCommand(PreviewSheetImageOpacityOperation.id, {
4426
+ unitId,
4427
+ subUnitId,
4428
+ drawingId,
4429
+ opacity
4430
+ });
4431
+ }
4432
+ function commitTransparency(nextTransparency) {
4433
+ const opacity = transparencyToOpacity(normalizeTransparency(nextTransparency));
4434
+ previewPendingRef.current = false;
4435
+ setPreviewState(null);
4436
+ if (opacity === modelOpacity) return;
4437
+ if (!commandService.syncExecuteCommand(SetSheetDrawingCommand.id, {
4438
+ unitId,
4439
+ drawings: [{
4440
+ unitId,
4441
+ subUnitId,
4442
+ drawingId,
4443
+ opacity
4444
+ }]
4445
+ })) commandService.syncExecuteCommand(PreviewSheetImageOpacityOperation.id, {
4446
+ unitId,
4447
+ subUnitId,
4448
+ drawingId,
4449
+ opacity: modelOpacity
4450
+ });
4451
+ }
4452
+ return /* @__PURE__ */ jsxs("section", {
4453
+ className: "univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",
4454
+ children: [/* @__PURE__ */ jsx("header", {
4455
+ className: "univer-text-gray-600 dark:!univer-text-gray-200",
4456
+ children: title
4457
+ }), /* @__PURE__ */ jsx(SheetImageTransparencySlider, {
4458
+ value: transparency,
4459
+ shortcuts: IMAGE_TRANSPARENCY_PRESETS,
4460
+ ariaLabel: title,
4461
+ onChange: previewTransparency,
4462
+ onChangeComplete: commitTransparency
4463
+ })]
4464
+ });
4465
+ };
4466
+ function normalizeTransparency(transparency) {
4467
+ if (!Number.isFinite(transparency)) return 0;
4468
+ return Math.min(Math.max(Math.round(transparency), 0), 100);
4469
+ }
4470
+ function transparencyToOpacity(transparency) {
4471
+ return (100 - transparency) / 100;
4075
4472
  }
4076
4473
 
4077
4474
  //#endregion
@@ -4096,7 +4493,11 @@ const SheetDrawingPanel = () => {
4096
4493
  const drawings = useObservable(() => drawingManagerService.focus$, drawingManagerService.getFocusDrawings(), false, [drawingManagerService]);
4097
4494
  return !!(drawings === null || drawings === void 0 ? void 0 : drawings.length) && /* @__PURE__ */ jsxs("div", {
4098
4495
  className: "univer-text-sm",
4099
- children: [/* @__PURE__ */ jsx(DrawingCommonPanel, { drawings }), /* @__PURE__ */ jsx(SheetDrawingAnchor, { drawings })]
4496
+ children: [
4497
+ /* @__PURE__ */ jsx(DrawingCommonPanel, { drawings }),
4498
+ /* @__PURE__ */ jsx(SheetImageTransparency, { drawings }),
4499
+ /* @__PURE__ */ jsx(SheetDrawingAnchor, { drawings })
4500
+ ]
4100
4501
  });
4101
4502
  };
4102
4503
 
@@ -4507,80 +4908,121 @@ SheetCellImageCopyPasteController = __decorate([
4507
4908
  //#endregion
4508
4909
  //#region src/controllers/sheet-drawing-active-render.controller.ts
4509
4910
  let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderController extends Disposable {
4510
- constructor(_context, _commandService, _sheetSkeletonService, _sheetDrawingService, _drawingManagerService) {
4911
+ constructor(_context, _commandService, _sheetSkeletonService, _sheetDrawingService, _drawingManagerService, _logService) {
4511
4912
  super();
4512
4913
  this._context = _context;
4513
4914
  this._commandService = _commandService;
4514
4915
  this._sheetSkeletonService = _sheetSkeletonService;
4515
4916
  this._sheetDrawingService = _sheetDrawingService;
4516
4917
  this._drawingManagerService = _drawingManagerService;
4918
+ this._logService = _logService;
4919
+ _defineProperty(this, "_renderTimeout", void 0);
4517
4920
  this._commandListener();
4518
4921
  }
4922
+ dispose() {
4923
+ this._cancelPendingRender();
4924
+ super.dispose();
4925
+ }
4926
+ _cancelPendingRender() {
4927
+ if (this._renderTimeout !== void 0) {
4928
+ clearTimeout(this._renderTimeout);
4929
+ this._renderTimeout = void 0;
4930
+ }
4931
+ }
4932
+ _scheduleRender(callback) {
4933
+ this._cancelPendingRender();
4934
+ this._renderTimeout = setTimeout(() => {
4935
+ this._renderTimeout = void 0;
4936
+ callback();
4937
+ }, 0);
4938
+ }
4519
4939
  _commandListener() {
4940
+ this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
4941
+ if (command.id !== SetWorksheetActiveOperation.id) return;
4942
+ const { unitId, subUnitId } = command.params;
4943
+ const { unit, unitId: contextUnitId } = this._context;
4944
+ if (unitId !== contextUnitId || !unit.getSheetBySheetId(subUnitId) || unit.getActiveSheet().getSheetId() === subUnitId) return;
4945
+ this._clearDrawings(unitId, subUnitId);
4946
+ }));
4520
4947
  this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
4521
4948
  if (command.id === SetWorksheetActiveOperation.id) {
4522
4949
  const { unitId, subUnitId } = command.params;
4523
- this._updateDrawings(unitId, subUnitId);
4950
+ if (unitId === this._context.unitId && subUnitId === this._context.unit.getActiveSheet().getSheetId()) this._updateDrawings(unitId, subUnitId);
4524
4951
  }
4525
4952
  }));
4526
4953
  this.disposeWithMe(this._context.activated$.subscribe((activated) => {
4527
4954
  const { unit, unitId } = this._context;
4528
- if (activated) this._updateDrawings(unitId, unit.getActiveSheet().getSheetId());
4529
- else this._clearDrawings(unitId);
4955
+ if (activated) {
4956
+ const subUnitId = unit.getActiveSheet().getSheetId();
4957
+ this._clearDrawings(unitId, subUnitId);
4958
+ this._updateDrawings(unitId, subUnitId);
4959
+ } else this._clearDrawings(unitId);
4530
4960
  }));
4531
4961
  }
4532
- _clearDrawings(selfUnitId) {
4533
- setTimeout(() => {
4534
- const drawingMap = this._drawingManagerService.drawingManagerData;
4535
- const removeDrawings = [];
4536
- Object.keys(drawingMap ?? {}).forEach((unitId) => {
4537
- const subUnitMap = drawingMap[unitId] ?? {};
4538
- Object.keys(subUnitMap).forEach((subUnitId) => {
4539
- var _subUnitMap$subUnitId;
4540
- const drawingData = ((_subUnitMap$subUnitId = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId === void 0 ? void 0 : _subUnitMap$subUnitId.data) ?? {};
4541
- Object.keys(drawingData).forEach((drawingId) => {
4542
- if (unitId === selfUnitId) removeDrawings.push(drawingData[drawingId]);
4543
- });
4544
- });
4545
- });
4546
- this._sheetDrawingService.removeNotification(removeDrawings);
4547
- this._drawingManagerService.removeNotification(removeDrawings);
4548
- });
4962
+ _clearDrawings(unitId, keepSubUnitId) {
4963
+ this._cancelPendingRender();
4964
+ const subUnitMap = this._drawingManagerService.drawingManagerData[unitId] ?? {};
4965
+ const removeDrawings = [];
4966
+ for (const subUnitId of Object.keys(subUnitMap)) {
4967
+ var _subUnitMap$subUnitId;
4968
+ if (subUnitId === keepSubUnitId) continue;
4969
+ for (const drawing of Object.values(((_subUnitMap$subUnitId = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId === void 0 ? void 0 : _subUnitMap$subUnitId.data) ?? {})) removeDrawings.push(drawing);
4970
+ }
4971
+ this._sheetDrawingService.removeNotification(removeDrawings);
4972
+ this._drawingManagerService.removeNotification(removeDrawings);
4549
4973
  }
4550
4974
  _updateDrawings(showUnitId, showSubunitId) {
4551
- setTimeout(() => {
4975
+ this._scheduleRender(() => {
4976
+ var _subUnitMap$showSubun;
4552
4977
  const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(showUnitId, showSubunitId);
4553
- const drawingMap = this._drawingManagerService.drawingManagerData;
4554
- const insertDrawings = [];
4555
- const removeDrawings = [];
4556
- Object.keys(drawingMap ?? {}).forEach((unitId) => {
4557
- if (unitId !== showUnitId) return;
4558
- const subUnitMap = drawingMap[unitId] ?? {};
4559
- Object.keys(subUnitMap).forEach((subUnitId) => {
4560
- var _subUnitMap$subUnitId2;
4561
- const drawingData = ((_subUnitMap$subUnitId2 = subUnitMap[subUnitId]) === null || _subUnitMap$subUnitId2 === void 0 ? void 0 : _subUnitMap$subUnitId2.data) ?? {};
4562
- Object.keys(drawingData).forEach((drawingId) => {
4563
- if (unitId === showUnitId && subUnitId === showSubunitId) {
4564
- const drawing = drawingData[drawingId];
4565
- if (drawing.sheetTransform && drawing.anchorType !== SheetDrawingAnchorType.None) drawing.transform = drawingPositionToTransform(drawing.sheetTransform, sheetSkeletonParam);
4566
- insertDrawings.push(drawingData[drawingId]);
4567
- } else removeDrawings.push(drawingData[drawingId]);
4568
- });
4569
- });
4570
- });
4978
+ const drawingData = ((_subUnitMap$showSubun = (this._drawingManagerService.drawingManagerData[showUnitId] ?? {})[showSubunitId]) === null || _subUnitMap$showSubun === void 0 ? void 0 : _subUnitMap$showSubun.data) ?? {};
4979
+ const { successDrawings, refreshedDrawings, failures } = prepareSheetDrawings(Object.values(drawingData), sheetSkeletonParam === null || sheetSkeletonParam === void 0 ? void 0 : sheetSkeletonParam.skeleton);
4980
+ const removeDrawings = failures.map(({ drawingId }) => drawingData[drawingId]);
4981
+ this._sheetDrawingService.refreshTransform(refreshedDrawings);
4982
+ this._drawingManagerService.refreshTransform(refreshedDrawings);
4571
4983
  this._sheetDrawingService.removeNotification(removeDrawings);
4572
- this._sheetDrawingService.addNotification(insertDrawings);
4984
+ this._sheetDrawingService.addNotification(successDrawings);
4573
4985
  this._drawingManagerService.removeNotification(removeDrawings);
4574
- this._drawingManagerService.addNotification(insertDrawings);
4575
- }, 0);
4986
+ this._drawingManagerService.addNotification(successDrawings);
4987
+ if (failures.length) this._logService.error("[SheetDrawingActiveRenderController]", {
4988
+ unitId: showUnitId,
4989
+ subUnitId: showSubunitId,
4990
+ failures
4991
+ });
4992
+ });
4576
4993
  }
4577
4994
  };
4578
4995
  SheetDrawingActiveRenderController = __decorate([
4579
4996
  __decorateParam(1, ICommandService),
4580
4997
  __decorateParam(2, Inject(SheetSkeletonService)),
4581
4998
  __decorateParam(3, ISheetDrawingService),
4582
- __decorateParam(4, IDrawingManagerService)
4999
+ __decorateParam(4, IDrawingManagerService),
5000
+ __decorateParam(5, ILogService)
4583
5001
  ], SheetDrawingActiveRenderController);
5002
+ function prepareSheetDrawings(drawings, skeleton) {
5003
+ const successDrawings = [];
5004
+ const refreshedDrawings = [];
5005
+ const failures = [];
5006
+ for (const drawing of drawings) {
5007
+ if (skeleton && drawing.sheetTransform && drawing.anchorType !== SheetDrawingAnchorType.None) try {
5008
+ refreshedDrawings.push(applySheetDrawingPlacement(drawing, getSheetDrawingPlacement(drawing), skeleton));
5009
+ } catch (error) {
5010
+ failures.push({
5011
+ drawingId: drawing.drawingId,
5012
+ drawingType: drawing.drawingType,
5013
+ anchorType: drawing.anchorType ?? SheetDrawingAnchorType.Position,
5014
+ error
5015
+ });
5016
+ continue;
5017
+ }
5018
+ successDrawings.push(drawing);
5019
+ }
5020
+ return {
5021
+ successDrawings,
5022
+ refreshedDrawings,
5023
+ failures
5024
+ };
5025
+ }
4584
5026
 
4585
5027
  //#endregion
4586
5028
  //#region src/controllers/sheet-drawing-copy-paste.controller.ts
@@ -5632,7 +6074,8 @@ let SheetDrawingUIController = class SheetDrawingUIController extends Disposable
5632
6074
  MoveDrawingsCommand,
5633
6075
  DeleteDrawingsCommand,
5634
6076
  SaveCellImagesCommand,
5635
- FlipSheetDrawingCommand
6077
+ FlipSheetDrawingCommand,
6078
+ PreviewSheetImageOpacityOperation
5636
6079
  ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
5637
6080
  }
5638
6081
  _initShortcuts() {