@univerjs/sheets-drawing-ui 1.3.1 → 1.5.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 (75) hide show
  1. package/README.md +9 -5
  2. package/lib/cjs/facade.js +4 -9
  3. package/lib/cjs/index.js +780 -410
  4. package/lib/cjs/locale/ar-SA.js +1 -2
  5. package/lib/cjs/locale/ca-ES.js +1 -2
  6. package/lib/cjs/locale/de-DE.js +1 -2
  7. package/lib/cjs/locale/en-US.js +1 -2
  8. package/lib/cjs/locale/es-ES.js +1 -2
  9. package/lib/cjs/locale/fa-IR.js +1 -2
  10. package/lib/cjs/locale/fr-FR.js +1 -2
  11. package/lib/cjs/locale/id-ID.js +1 -2
  12. package/lib/cjs/locale/it-IT.js +1 -2
  13. package/lib/cjs/locale/ja-JP.js +1 -2
  14. package/lib/cjs/locale/ko-KR.js +1 -2
  15. package/lib/cjs/locale/pl-PL.js +1 -2
  16. package/lib/cjs/locale/pt-BR.js +1 -2
  17. package/lib/cjs/locale/ru-RU.js +1 -2
  18. package/lib/cjs/locale/sk-SK.js +1 -2
  19. package/lib/cjs/locale/vi-VN.js +1 -2
  20. package/lib/cjs/locale/zh-CN.js +1 -2
  21. package/lib/cjs/locale/zh-HK.js +1 -2
  22. package/lib/cjs/locale/zh-TW.js +1 -2
  23. package/lib/es/facade.js +4 -8
  24. package/lib/es/index.js +786 -416
  25. package/lib/es/locale/ar-SA.js +1 -2
  26. package/lib/es/locale/ca-ES.js +1 -2
  27. package/lib/es/locale/de-DE.js +1 -2
  28. package/lib/es/locale/en-US.js +1 -2
  29. package/lib/es/locale/es-ES.js +1 -2
  30. package/lib/es/locale/fa-IR.js +1 -2
  31. package/lib/es/locale/fr-FR.js +1 -2
  32. package/lib/es/locale/id-ID.js +1 -2
  33. package/lib/es/locale/it-IT.js +1 -2
  34. package/lib/es/locale/ja-JP.js +1 -2
  35. package/lib/es/locale/ko-KR.js +1 -2
  36. package/lib/es/locale/pl-PL.js +1 -2
  37. package/lib/es/locale/pt-BR.js +1 -2
  38. package/lib/es/locale/ru-RU.js +1 -2
  39. package/lib/es/locale/sk-SK.js +1 -2
  40. package/lib/es/locale/vi-VN.js +1 -2
  41. package/lib/es/locale/zh-CN.js +1 -2
  42. package/lib/es/locale/zh-HK.js +1 -2
  43. package/lib/es/locale/zh-TW.js +1 -2
  44. package/lib/facade.js +4 -8
  45. package/lib/index.js +786 -416
  46. package/lib/locale/ar-SA.js +1 -2
  47. package/lib/locale/ca-ES.js +1 -2
  48. package/lib/locale/de-DE.js +1 -2
  49. package/lib/locale/en-US.js +1 -2
  50. package/lib/locale/es-ES.js +1 -2
  51. package/lib/locale/fa-IR.js +1 -2
  52. package/lib/locale/fr-FR.js +1 -2
  53. package/lib/locale/id-ID.js +1 -2
  54. package/lib/locale/it-IT.js +1 -2
  55. package/lib/locale/ja-JP.js +1 -2
  56. package/lib/locale/ko-KR.js +1 -2
  57. package/lib/locale/pl-PL.js +1 -2
  58. package/lib/locale/pt-BR.js +1 -2
  59. package/lib/locale/ru-RU.js +1 -2
  60. package/lib/locale/sk-SK.js +1 -2
  61. package/lib/locale/vi-VN.js +1 -2
  62. package/lib/locale/zh-CN.js +1 -2
  63. package/lib/locale/zh-HK.js +1 -2
  64. package/lib/locale/zh-TW.js +1 -2
  65. package/lib/types/controllers/sheet-drawing-copy-paste.controller.d.ts +7 -3
  66. package/lib/types/controllers/sheet-drawing-permission.controller.d.ts +2 -0
  67. package/lib/types/controllers/sheet-drawing-update.controller.d.ts +7 -4
  68. package/lib/types/facade/f-worksheet.d.ts +5 -1
  69. package/lib/types/menu/drawing-popup-menu.controller.d.ts +5 -2
  70. package/lib/types/services/batch-save-images.service.d.ts +1 -1
  71. package/lib/types/services/canvas-float-dom-manager.service.d.ts +11 -4
  72. package/lib/types/services/drawing-context-menu.service.d.ts +1 -1
  73. package/lib/types/views/background/worksheet-background-image.extension.d.ts +1 -0
  74. package/lib/umd/index.js +2 -2
  75. package/package.json +19 -19
package/lib/es/index.js CHANGED
@@ -1,20 +1,20 @@
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, drawingPositionToTransform, getSheetDrawingPlacement, refreshSheetDrawingPlacement, transformToAxisAlignPosition, transformToDrawingPosition } from "@univerjs/sheets-drawing";
1
+ import { BooleanNumber, BuildTextUtils, CommandType, CustomCommandExecutionError, 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, SheetTypes, 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, refreshSheetDrawingPlacement, transformDrawingsToChartSheet, 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
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
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
- 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
- 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";
7
+ import { COMMAND_LISTENER_SKELETON_CHANGE, IAutoFillService, INTERCEPTOR_POINT, InterceptCellContentPriority, RangeProtectionPermissionEditPoint, SetFrozenMutation, SetRangeValuesCommand, SetSelectionsOperation, SetWorksheetActiveOperation, SetWorksheetRowAutoHeightMutation, SheetInterceptorService, SheetPermissionCheckController, SheetSkeletonService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookCopyPermission, WorkbookEditablePermission, WorkbookRenameSheetPermission, WorkbookViewPermission, WorksheetCopyPermission, WorksheetEditPermission, WorksheetViewPermission, attachRangeWithCoord, discreteRangeToRange, getSheetCommandTarget, isCellImage } from "@univerjs/sheets";
8
+ import { COPY_TYPE, EditingRenderController, HoverManagerService, IEditorBridgeService, ISheetClipboardService, ISheetSelectionRenderService, PREDEFINED_HOOK_NAME_PASTE, SHEET_VIEW_KEY, SetCellEditVisibleOperation, SetScrollOperation, SetZoomRatioOperation, SheetCanvasPopManagerService, SheetPasteCommand, SheetPrintInterceptorService, SheetSkeletonManagerService, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, deriveStateFromActiveSheet$, getCurrentRangeDisable$, useHighlightRange, virtualizeDiscreteRanges } from "@univerjs/sheets-ui";
9
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
- import { COMPONENT_IMAGE_POPUP_MENU, COMPONENT_MOBILE_IMAGE_POPUP_MENU, DrawingCommonPanel, DrawingRenderService, ImageCropperObject, ImageResetSizeOperation, OpenImageCropOperation, UniverDrawingMobileUIPlugin, UniverDrawingUIPlugin, disposeDrawingRenderObject, insertGroupObject } from "@univerjs/drawing-ui";
11
- import { BehaviorSubject, EMPTY, Observable, Subject, combineLatest, distinctUntilChanged, filter, map, of, switchMap, take, takeUntil, tap, throttleTime, timer } from "rxjs";
10
+ import { COMPONENT_IMAGE_POPUP_MENU, COMPONENT_MOBILE_IMAGE_POPUP_MENU, DrawingCommonPanel, DrawingRenderService, ImageCropperObject, ImageResetSizeOperation, OleUIService, OpenImageCropOperation, UniverDrawingMobileUIPlugin, UniverDrawingUIPlugin, createOlePreviewViewer, disposeDrawingRenderObject, insertGroupObject, registerOlePreviewRenderer } from "@univerjs/drawing-ui";
11
+ import { BehaviorSubject, EMPTY, Observable, Subject, combineLatest, distinctUntilChanged, filter, map, of, startWith, switchMap, take, takeUntil, tap, throttleTime, timer } from "rxjs";
12
12
  import { DocDrawingController, UniverDocsDrawingPlugin } from "@univerjs/docs-drawing";
13
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
 
17
- //#region src/commands/commands/delete-drawings.command.ts
17
+ // src/commands/commands/delete-drawings.command.ts
18
18
  const DeleteDrawingsCommand = {
19
19
  id: "sheet.command.delete-drawing",
20
20
  type: CommandType.COMMAND,
@@ -39,8 +39,7 @@ const DeleteDrawingsCommand = {
39
39
  }
40
40
  };
41
41
 
42
- //#endregion
43
- //#region src/commands/commands/utils.ts
42
+ // src/commands/commands/utils.ts
44
43
  function ungroupToGroup(ungroupParams) {
45
44
  const newGroupParams = [];
46
45
  ungroupParams.forEach((ungroupParam) => {
@@ -160,8 +159,7 @@ function cloneDrawingParam(param, newDrawingId, parentGroupId) {
160
159
  return JSON.parse(JSON.stringify(newParam));
161
160
  }
162
161
 
163
- //#endregion
164
- //#region src/commands/commands/group-sheet-drawing.command.ts
162
+ // src/commands/commands/group-sheet-drawing.command.ts
165
163
  /**
166
164
  * The command to insert new defined name
167
165
  */
@@ -223,8 +221,7 @@ const GroupSheetDrawingCommand = {
223
221
  }
224
222
  };
225
223
 
226
- //#endregion
227
- //#region src/commands/commands/ungroup-sheet-drawing.command.ts
224
+ // src/commands/commands/ungroup-sheet-drawing.command.ts
228
225
  /**
229
226
  * The command to insert new defined name
230
227
  */
@@ -286,8 +283,7 @@ const UngroupSheetDrawingCommand = {
286
283
  }
287
284
  };
288
285
 
289
- //#endregion
290
- //#region src/utils/worksheet-background-image.ts
286
+ // src/utils/worksheet-background-image.ts
291
287
  /**
292
288
  * Copyright 2023-present DreamNum Co., Ltd.
293
289
  *
@@ -426,8 +422,7 @@ function readUint32Be(bytes, offset) {
426
422
  return ((bytes[offset] ?? 0) << 24 >>> 0 | (bytes[offset + 1] ?? 0) << 16 | (bytes[offset + 2] ?? 0) << 8 | (bytes[offset + 3] ?? 0)) >>> 0;
427
423
  }
428
424
 
429
- //#endregion
430
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
425
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
431
426
  function _typeof(o) {
432
427
  "@babel/helpers - typeof";
433
428
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -437,28 +432,25 @@ function _typeof(o) {
437
432
  }, _typeof(o);
438
433
  }
439
434
 
440
- //#endregion
441
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
442
- function toPrimitive(t, r) {
435
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
436
+ function toPrimitive(t, e) {
443
437
  if ("object" != _typeof(t) || !t) return t;
444
- var e = t[Symbol.toPrimitive];
445
- if (void 0 !== e) {
446
- var i = e.call(t, r || "default");
438
+ var r;
439
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
440
+ var i = r.call(t, e || "default");
447
441
  if ("object" != _typeof(i)) return i;
448
442
  throw new TypeError("@@toPrimitive must return a primitive value.");
449
443
  }
450
- return ("string" === r ? String : Number)(t);
444
+ return ("string" === e ? String : Number)(t);
451
445
  }
452
446
 
453
- //#endregion
454
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
447
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
455
448
  function toPropertyKey(t) {
456
449
  var i = toPrimitive(t, "string");
457
450
  return "symbol" == _typeof(i) ? i : i + "";
458
451
  }
459
452
 
460
- //#endregion
461
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
453
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
462
454
  function _defineProperty(e, r, t) {
463
455
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
464
456
  value: t,
@@ -468,16 +460,14 @@ function _defineProperty(e, r, t) {
468
460
  }) : e[r] = t, e;
469
461
  }
470
462
 
471
- //#endregion
472
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
463
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
473
464
  function __decorateParam(paramIndex, decorator) {
474
465
  return function(target, key) {
475
466
  decorator(target, key, paramIndex);
476
467
  };
477
468
  }
478
469
 
479
- //#endregion
480
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
470
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
481
471
  function __decorate(decorators, target, key, desc) {
482
472
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
483
473
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -485,8 +475,7 @@ function __decorate(decorators, target, key, desc) {
485
475
  return c > 3 && r && Object.defineProperty(target, key, r), r;
486
476
  }
487
477
 
488
- //#endregion
489
- //#region src/controllers/sheet-drawing-update.controller.ts
478
+ // src/controllers/sheet-drawing-update.controller.ts
490
479
  /**
491
480
  * Calculate the bounding box after rotation
492
481
  * @param {number} width Width
@@ -529,12 +518,11 @@ function getDrawingSizeByCell(accessor, location, originImageWidth, originImageH
529
518
  };
530
519
  }
531
520
  let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Disposable {
532
- constructor(_context, _commandService, _sheetInterceptorService, _selectionRenderService, _imageIoService, _fileOpenerService, _sheetDrawingService, _drawingManagerService, _contextService, _messageService, _localeService, selectionManagerService, _sheetSkeletonService, _injector, _urlImageService) {
521
+ constructor(_context, _commandService, _sheetInterceptorService, _imageIoService, _fileOpenerService, _sheetDrawingService, _drawingManagerService, _contextService, _messageService, _localeService, selectionManagerService, _sheetSkeletonService, _injector, _urlImageService) {
533
522
  super();
534
523
  this._context = _context;
535
524
  this._commandService = _commandService;
536
525
  this._sheetInterceptorService = _sheetInterceptorService;
537
- this._selectionRenderService = _selectionRenderService;
538
526
  this._imageIoService = _imageIoService;
539
527
  this._fileOpenerService = _fileOpenerService;
540
528
  this._sheetDrawingService = _sheetDrawingService;
@@ -553,6 +541,8 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
553
541
  this._focusDrawingListener();
554
542
  }
555
543
  async insertFloatImage() {
544
+ const target = this._captureImageTarget();
545
+ if (!target) return false;
556
546
  const files = await this._fileOpenerService.openFile({
557
547
  multiple: true,
558
548
  accept: DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(",")
@@ -565,18 +555,19 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
565
555
  });
566
556
  return false;
567
557
  } else if (fileLength === 0) return false;
568
- files.forEach(async (file) => await this.insertFloatImageByFile(file));
569
- return true;
558
+ return (await Promise.all(files.map((file) => this._insertFloatImage(file, target).catch((error) => {
559
+ this._injector.get(ILogService).error(error);
560
+ return false;
561
+ })))).every(Boolean);
570
562
  }
571
563
  async insertCellImage() {
564
+ const target = this._captureCellImageTarget();
565
+ if (!target) return false;
572
566
  const file = (await this._fileOpenerService.openFile({
573
567
  multiple: false,
574
568
  accept: DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(",")
575
569
  }))[0];
576
- if (file) {
577
- await this._insertCellImage(file);
578
- return true;
579
- }
570
+ if (file) return this._insertCellImage(file, void 0, target);
580
571
  return false;
581
572
  }
582
573
  async setWorksheetBackgroundImage(files) {
@@ -621,6 +612,15 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
621
612
  return this._insertCellImage(file, location);
622
613
  }
623
614
  async insertFloatImageByFile(file) {
615
+ const target = this._captureImageTarget();
616
+ if (!target) return false;
617
+ return this._insertFloatImage(file, target).catch((error) => {
618
+ this._injector.get(ILogService).error(error);
619
+ return false;
620
+ });
621
+ }
622
+ async _insertFloatImage(file, target) {
623
+ if (!this._isImageTargetValid(target)) return false;
624
624
  let imageParam;
625
625
  try {
626
626
  imageParam = await this._imageIoService.saveImage(file);
@@ -639,11 +639,14 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
639
639
  content: this._localeService.t("sheets-drawing-ui.update-status.invalidImage")
640
640
  });
641
641
  }
642
- if (imageParam == null) return;
643
- const { unitId, subUnitId } = this._getUnitInfo();
642
+ if (imageParam == null || !this._isImageTargetValid(target)) return false;
643
+ const { unitId, subUnitId } = target;
644
644
  const { imageId, imageSourceType, source, base64Cache } = imageParam;
645
- const { width, height, image } = await getImageSize(base64Cache || "");
646
- const { width: sceneWidth, height: sceneHeight } = this._context.scene;
645
+ const imageSize = await getImageSize(base64Cache || "").catch(() => null);
646
+ if (!imageSize) return false;
647
+ const { width, height, image } = imageSize;
648
+ if (!this._isImageTargetValid(target) || !Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return false;
649
+ const { sceneWidth, sceneHeight } = target;
647
650
  this._imageIoService.addImageSourceCache(source, imageSourceType, image);
648
651
  let scale = 1;
649
652
  if (width > DRAWING_IMAGE_WIDTH_LIMIT || height > DRAWING_IMAGE_HEIGHT_LIMIT) {
@@ -651,13 +654,51 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
651
654
  const scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
652
655
  scale = Math.min(scaleWidth, scaleHeight);
653
656
  }
657
+ if (target.worksheet.getConfig().type === SheetTypes.CHART) {
658
+ const bounds = this._getChartImageBounds(target.render);
659
+ if (!bounds) return false;
660
+ const marker = {
661
+ row: 0,
662
+ column: 0,
663
+ rowOffset: 0,
664
+ columnOffset: 0
665
+ };
666
+ const placed = transformDrawingsToChartSheet([{
667
+ unitId,
668
+ subUnitId,
669
+ drawingId: imageId,
670
+ drawingType: DrawingTypeEnum.DRAWING_IMAGE,
671
+ imageSourceType,
672
+ source,
673
+ transform: {
674
+ left: 0,
675
+ top: 0,
676
+ width: width * scale,
677
+ height: height * scale
678
+ },
679
+ sheetTransform: {
680
+ from: marker,
681
+ to: marker
682
+ },
683
+ axisAlignSheetTransform: {
684
+ from: marker,
685
+ to: marker
686
+ }
687
+ }], bounds, target.worksheet.getConfig().rightToLeft === BooleanNumber.TRUE);
688
+ if (!(placed === null || placed === void 0 ? void 0 : placed.length)) return false;
689
+ const [drawing] = placed;
690
+ return this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
691
+ unitId,
692
+ drawings: [drawing]
693
+ });
694
+ }
654
695
  const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
655
- if (!sheetSkeletonParam) return;
696
+ if (!sheetSkeletonParam) return false;
656
697
  const { skeleton } = sheetSkeletonParam;
657
- const sheetTransform = this._getImagePosition(width * scale, height * scale, sceneWidth, sceneHeight, skeleton);
658
- if (!sheetTransform) return;
698
+ const sheetTransform = this._getImagePosition(width * scale, height * scale, sceneWidth, sceneHeight, skeleton, target.range);
699
+ if (!sheetTransform) return false;
659
700
  const newTransform = drawingPositionToTransform(sheetTransform, sheetSkeletonParam);
660
- if (!newTransform) return;
701
+ if (!newTransform) return false;
661
702
  const sheetDrawingParam = {
662
703
  unitId,
663
704
  subUnitId,
@@ -674,7 +715,9 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
674
715
  drawings: [sheetDrawingParam]
675
716
  });
676
717
  }
677
- async _insertCellImage(file, location) {
718
+ async _insertCellImage(file, location, capturedTarget) {
719
+ const target = capturedTarget ?? this._captureCellImageTarget(location);
720
+ if (!target || !this._isImageTargetValid(target)) return false;
678
721
  let imageParam;
679
722
  try {
680
723
  imageParam = await this._imageIoService.saveImage(file);
@@ -697,21 +740,11 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
697
740
  const { imageId, imageSourceType, source, base64Cache } = imageParam;
698
741
  const { width, height, image } = await getImageSize(base64Cache || "");
699
742
  this._imageIoService.addImageSourceCache(source, imageSourceType, image);
700
- const selection = this._workbookSelections.getCurrentLastSelection();
701
- if (!selection) return false;
702
- let row = selection.primary.actualRow;
703
- let col = selection.primary.actualColumn;
704
- if (selection.primary.isMerged) {
705
- row = selection.primary.startRow;
706
- col = selection.primary.startColumn;
707
- }
743
+ if (!this._isImageTargetValid(target)) return false;
744
+ const cellLocation = target.location;
745
+ const { row, col } = cellLocation;
708
746
  const docDataModel = createDocumentModelWithStyle("", {});
709
- const imageSize = getDrawingSizeByCell(this._injector, {
710
- unitId: this._context.unitId,
711
- subUnitId: this._context.unit.getActiveSheet().getSheetId(),
712
- row,
713
- col
714
- }, width, height, 0);
747
+ const imageSize = getDrawingSizeByCell(this._injector, cellLocation, width, height, 0);
715
748
  if (!imageSize) return false;
716
749
  const docTransform = buildDocTransform(imageSize.width, imageSize.height);
717
750
  const docDrawingParam = {
@@ -745,17 +778,25 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
745
778
  if (jsonXActions) {
746
779
  docDataModel.apply(jsonXActions);
747
780
  return this._commandService.syncExecuteCommand(SetRangeValuesCommand.id, {
748
- value: { [(location === null || location === void 0 ? void 0 : location.row) ?? row]: { [(location === null || location === void 0 ? void 0 : location.col) ?? col]: {
781
+ value: { [row]: { [col]: {
749
782
  p: docDataModel.getSnapshot(),
750
783
  t: 1
751
784
  } } },
752
- unitId: location === null || location === void 0 ? void 0 : location.unitId,
753
- subUnitId: location === null || location === void 0 ? void 0 : location.subUnitId
785
+ unitId: target.unitId,
786
+ subUnitId: target.subUnitId,
787
+ range: {
788
+ startRow: row,
789
+ endRow: row,
790
+ startColumn: col,
791
+ endColumn: col
792
+ }
754
793
  });
755
794
  }
756
795
  return false;
757
796
  }
758
797
  async insertCellImageByUrl(url, location) {
798
+ const target = this._captureCellImageTarget(location);
799
+ if (!target) return false;
759
800
  let src = url;
760
801
  try {
761
802
  src = await this._urlImageService.getImage(url);
@@ -764,15 +805,10 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
764
805
  }
765
806
  const { width, height, image } = await getImageSize(src || "");
766
807
  this._imageIoService.addImageSourceCache(url, ImageSourceType.URL, image);
767
- const selection = this._workbookSelections.getCurrentLastSelection();
768
- if (!selection) return false;
808
+ if (!this._isImageTargetValid(target)) return false;
809
+ const cellLocation = target.location;
769
810
  const docDataModel = createDocumentModelWithStyle("", {});
770
- const imageSize = getDrawingSizeByCell(this._injector, {
771
- unitId: this._context.unitId,
772
- subUnitId: this._context.unit.getActiveSheet().getSheetId(),
773
- row: selection.primary.actualRow,
774
- col: selection.primary.actualColumn
775
- }, width, height, 0);
811
+ const imageSize = getDrawingSizeByCell(this._injector, cellLocation, width, height, 0);
776
812
  if (!imageSize) return false;
777
813
  const docTransform = buildDocTransform(imageSize.width, imageSize.height);
778
814
  const docDrawingParam = {
@@ -806,16 +842,87 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
806
842
  if (jsonXActions) {
807
843
  docDataModel.apply(jsonXActions);
808
844
  return this._commandService.syncExecuteCommand(SetRangeValuesCommand.id, {
809
- 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]: {
845
+ value: { [cellLocation.row]: { [cellLocation.col]: {
810
846
  p: docDataModel.getSnapshot(),
811
847
  t: 1
812
848
  } } },
813
- unitId: location === null || location === void 0 ? void 0 : location.unitId,
814
- subUnitId: location === null || location === void 0 ? void 0 : location.subUnitId
849
+ unitId: target.unitId,
850
+ subUnitId: target.subUnitId,
851
+ range: {
852
+ startRow: cellLocation.row,
853
+ endRow: cellLocation.row,
854
+ startColumn: cellLocation.col,
855
+ endColumn: cellLocation.col
856
+ }
815
857
  });
816
858
  }
817
859
  return false;
818
860
  }
861
+ _captureImageTarget(location) {
862
+ if (this._disposed) return null;
863
+ const instances = this._injector.get(IUniverInstanceService);
864
+ const host = getSheetCommandTarget(instances, location ?? { unitId: this._context.unitId });
865
+ const render = host && this._injector.get(IRenderManagerService).getRenderUnitById(host.unitId);
866
+ const sheetType = (host === null || host === void 0 ? void 0 : host.worksheet.getConfig().type) ?? SheetTypes.GRID;
867
+ if (!host || !render || sheetType !== SheetTypes.GRID && sheetType !== SheetTypes.CHART) return null;
868
+ const frame = render.components.get(SHEET_VIEW_KEY.CHART_PAGE);
869
+ const pageFrame = frame instanceof Rect ? frame : void 0;
870
+ const selections = this._workbookSelections.getCurrentSelections();
871
+ const range = (selections === null || selections === void 0 ? void 0 : selections.length) ? { ...selections[selections.length - 1].range } : {
872
+ startRow: 0,
873
+ endRow: 0,
874
+ startColumn: 0,
875
+ endColumn: 0
876
+ };
877
+ const target = {
878
+ ...host,
879
+ render,
880
+ location,
881
+ pageFrame,
882
+ range,
883
+ sceneWidth: render.scene.width,
884
+ sceneHeight: render.scene.height
885
+ };
886
+ return this._isImageTargetValid(target) ? target : null;
887
+ }
888
+ _captureCellImageTarget(location) {
889
+ const target = this._captureImageTarget(location);
890
+ if (!target || (target.worksheet.getConfig().type ?? SheetTypes.GRID) !== SheetTypes.GRID) return null;
891
+ if (!location) {
892
+ const selection = this._workbookSelections.getCurrentLastSelection();
893
+ if (!selection) return null;
894
+ const { primary } = selection;
895
+ target.location = {
896
+ unitId: target.unitId,
897
+ subUnitId: target.subUnitId,
898
+ row: primary.isMerged ? primary.startRow : primary.actualRow,
899
+ col: primary.isMerged ? primary.startColumn : primary.actualColumn
900
+ };
901
+ }
902
+ return target;
903
+ }
904
+ _isImageTargetValid(target) {
905
+ if (this._disposed) return false;
906
+ const instances = this._injector.get(IUniverInstanceService);
907
+ const { workbook, worksheet, unitId, subUnitId, render } = target;
908
+ if (instances.getUnit(unitId, UniverInstanceType.UNIVER_SHEET) !== workbook || workbook.getSheetBySheetId(subUnitId) !== worksheet || render.isDisposed() || this._injector.get(IRenderManagerService).getRenderUnitById(unitId) !== render) return false;
909
+ return worksheet.getConfig().type !== SheetTypes.CHART || target.pageFrame === render.components.get(SHEET_VIEW_KEY.CHART_PAGE) && Boolean(this._getChartImageBounds(render));
910
+ }
911
+ _getChartImageBounds(render) {
912
+ const frame = render.components.get(SHEET_VIEW_KEY.CHART_PAGE);
913
+ if (!frame || ![
914
+ frame.left,
915
+ frame.top,
916
+ frame.width,
917
+ frame.height
918
+ ].every(Number.isFinite) || frame.width <= 0 || frame.height <= 0) return null;
919
+ return {
920
+ left: frame.left,
921
+ top: frame.top,
922
+ width: frame.width,
923
+ height: frame.height
924
+ };
925
+ }
819
926
  _getUnitInfo() {
820
927
  const workbook = this._context.unit;
821
928
  const worksheet = workbook.getActiveSheet();
@@ -824,15 +931,7 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
824
931
  subUnitId: worksheet.getSheetId()
825
932
  };
826
933
  }
827
- _getImagePosition(imageWidth, imageHeight, sceneWidth, sceneHeight, skeleton) {
828
- const selections = this._workbookSelections.getCurrentSelections();
829
- let range = {
830
- startRow: 0,
831
- endRow: 0,
832
- startColumn: 0,
833
- endColumn: 0
834
- };
835
- if (selections && selections.length > 0) range = selections[selections.length - 1].range;
934
+ _getImagePosition(imageWidth, imageHeight, sceneWidth, sceneHeight, skeleton, range) {
836
935
  const rangeWithCoord = attachRangeWithCoord(skeleton, range);
837
936
  if (rangeWithCoord == null) return;
838
937
  let { startColumn, startRow, startX, startY } = rangeWithCoord;
@@ -854,7 +953,10 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
854
953
  isChangeStart = true;
855
954
  }
856
955
  if (isChangeStart) {
857
- const newCoord = this._selectionRenderService.getCellWithCoordByOffset(startX, startY);
956
+ const newCoord = skeleton.getCellWithCoordByOffset(startX, startY, 1, 1, {
957
+ x: 0,
958
+ y: 0
959
+ });
858
960
  if (newCoord == null) return;
859
961
  startX = newCoord.startX;
860
962
  startY = newCoord.startY;
@@ -867,7 +969,10 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
867
969
  row: startRow,
868
970
  rowOffset: 0
869
971
  };
870
- const endSelectionCell = this._selectionRenderService.getCellWithCoordByOffset(startX + imageWidth, startY + imageHeight);
972
+ const endSelectionCell = skeleton.getCellWithCoordByOffset(startX + imageWidth, startY + imageHeight, 1, 1, {
973
+ x: 0,
974
+ y: 0
975
+ });
871
976
  if (endSelectionCell == null) return;
872
977
  return {
873
978
  from,
@@ -897,14 +1002,27 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
897
1002
  params.forEach((param) => {
898
1003
  const { unitId, subUnitId, drawingId, transform } = param;
899
1004
  const sheetSkeletonParam = this._sheetSkeletonService.getSkeletonParam(unitId, subUnitId);
900
- if (!transform || !sheetSkeletonParam) return;
901
- const { skeleton } = sheetSkeletonParam;
1005
+ if (!transform) return;
902
1006
  const sheetDrawing = this._sheetDrawingService.getDrawingByParam({
903
1007
  unitId,
904
1008
  subUnitId,
905
1009
  drawingId
906
1010
  });
907
1011
  if (sheetDrawing == null || sheetDrawing.unitId !== this._context.unitId) return;
1012
+ if (sheetDrawing.anchorType === SheetDrawingAnchorType.None) {
1013
+ const next = {
1014
+ ...sheetDrawing,
1015
+ ...param,
1016
+ transform: {
1017
+ ...sheetDrawing.transform,
1018
+ ...transform
1019
+ }
1020
+ };
1021
+ drawings.push(applySheetDrawingPlacement(next, getSheetDrawingPlacement(next)));
1022
+ return;
1023
+ }
1024
+ if (!sheetSkeletonParam) return;
1025
+ const { skeleton } = sheetSkeletonParam;
908
1026
  const sheetTransform = transformToDrawingPosition({
909
1027
  ...sheetDrawing.transform,
910
1028
  ...transform
@@ -1029,22 +1147,20 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends Di
1029
1147
  SheetDrawingUpdateController = __decorate([
1030
1148
  __decorateParam(1, ICommandService),
1031
1149
  __decorateParam(2, Inject(SheetInterceptorService)),
1032
- __decorateParam(3, ISheetSelectionRenderService),
1033
- __decorateParam(4, IImageIoService),
1034
- __decorateParam(5, ILocalFileService),
1035
- __decorateParam(6, ISheetDrawingService),
1036
- __decorateParam(7, IDrawingManagerService),
1037
- __decorateParam(8, IContextService),
1038
- __decorateParam(9, IMessageService),
1039
- __decorateParam(10, Inject(LocaleService)),
1040
- __decorateParam(11, Inject(SheetsSelectionsService)),
1041
- __decorateParam(12, Inject(SheetSkeletonService)),
1042
- __decorateParam(13, Inject(Injector)),
1043
- __decorateParam(14, IURLImageService)
1150
+ __decorateParam(3, IImageIoService),
1151
+ __decorateParam(4, ILocalFileService),
1152
+ __decorateParam(5, ISheetDrawingService),
1153
+ __decorateParam(6, IDrawingManagerService),
1154
+ __decorateParam(7, IContextService),
1155
+ __decorateParam(8, IMessageService),
1156
+ __decorateParam(9, Inject(LocaleService)),
1157
+ __decorateParam(10, Inject(SheetsSelectionsService)),
1158
+ __decorateParam(11, Inject(SheetSkeletonService)),
1159
+ __decorateParam(12, Inject(Injector)),
1160
+ __decorateParam(13, IURLImageService)
1044
1161
  ], SheetDrawingUpdateController);
1045
1162
 
1046
- //#endregion
1047
- //#region src/commands/commands/insert-image.command.ts
1163
+ // src/commands/commands/insert-image.command.ts
1048
1164
  const InsertFloatImageCommand = {
1049
1165
  id: "sheet.command.insert-float-image",
1050
1166
  type: CommandType.COMMAND,
@@ -1072,8 +1188,7 @@ const InsertCellImageCommand = {
1072
1188
  }
1073
1189
  };
1074
1190
 
1075
- //#endregion
1076
- //#region src/commands/commands/move-drawings.command.ts
1191
+ // src/commands/commands/move-drawings.command.ts
1077
1192
  const MoveDrawingsCommand = {
1078
1193
  id: "sheet.command.move-drawing",
1079
1194
  type: CommandType.COMMAND,
@@ -1086,27 +1201,60 @@ const MoveDrawingsCommand = {
1086
1201
  const drawings = drawingManagerService.getFocusDrawings();
1087
1202
  if (drawings.length === 0) return false;
1088
1203
  const unitId = drawings[0].unitId;
1089
- const newDrawings = drawings.map((drawing) => {
1090
- const { transform, unitId, subUnitId } = drawing;
1091
- const skeleton = sheetSkeletonService.getSkeleton(unitId, subUnitId);
1092
- if (!transform || !skeleton) return null;
1093
- const newTransform = { ...transform };
1094
- const { left = 0, top = 0 } = transform;
1095
- if (direction === Direction.UP) newTransform.top = top - 1;
1096
- else if (direction === Direction.DOWN) newTransform.top = top + 1;
1097
- else if (direction === Direction.LEFT) newTransform.left = left - 1;
1098
- else if (direction === Direction.RIGHT) newTransform.left = left + 1;
1099
- return {
1100
- ...drawing,
1101
- transform: newTransform,
1102
- sheetTransform: transformToDrawingPosition(newTransform, skeleton),
1103
- axisAlignSheetTransform: transformToAxisAlignPosition(newTransform, skeleton)
1204
+ const movableDrawings = drawings.flatMap((drawing) => {
1205
+ const sheetDrawing = drawing;
1206
+ const { transform, anchorType = SheetDrawingAnchorType.Position } = sheetDrawing;
1207
+ if (!transform) return [];
1208
+ const skeleton = sheetSkeletonService.getSkeleton(drawing.unitId, drawing.subUnitId);
1209
+ if (anchorType !== SheetDrawingAnchorType.None && !skeleton) return [];
1210
+ return [{
1211
+ drawing: sheetDrawing,
1212
+ skeleton,
1213
+ anchorType
1214
+ }];
1215
+ });
1216
+ if (movableDrawings.length === 0) return false;
1217
+ let moveX = direction === Direction.LEFT ? -1 : direction === Direction.RIGHT ? 1 : 0;
1218
+ let moveY = direction === Direction.UP ? -1 : direction === Direction.DOWN ? 1 : 0;
1219
+ let minX = -Infinity;
1220
+ let minY = -Infinity;
1221
+ let maxX = Infinity;
1222
+ let maxY = Infinity;
1223
+ for (const { drawing, skeleton } of movableDrawings) {
1224
+ if (!skeleton) continue;
1225
+ const { left = 0, top = 0, width = 0, height = 0 } = drawing.transform;
1226
+ const { rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop, columnTotalWidth, rowTotalHeight } = skeleton;
1227
+ minX = Math.max(minX, rowHeaderWidthAndMarginLeft - left);
1228
+ minY = Math.max(minY, columnHeaderHeightAndMarginTop - top);
1229
+ maxX = Math.min(maxX, rowHeaderWidthAndMarginLeft + columnTotalWidth - left - width);
1230
+ maxY = Math.min(maxY, columnHeaderHeightAndMarginTop + rowTotalHeight - top - height);
1231
+ }
1232
+ moveX = Math.max(minX, Math.min(moveX, maxX));
1233
+ moveY = Math.max(minY, Math.min(moveY, maxY));
1234
+ if (moveX === 0 && moveY === 0) return false;
1235
+ const newDrawings = movableDrawings.flatMap(({ drawing, skeleton, anchorType }) => {
1236
+ const { left = 0, top = 0, width = 0, height = 0 } = drawing.transform;
1237
+ const bounds = {
1238
+ left: left + moveX,
1239
+ top: top + moveY,
1240
+ width,
1241
+ height
1104
1242
  };
1105
- }).filter((drawing) => drawing != null);
1243
+ if (anchorType === SheetDrawingAnchorType.None) return [applySheetDrawingPlacement(drawing, {
1244
+ kind: anchorType,
1245
+ bounds
1246
+ })];
1247
+ if (!skeleton) return [];
1248
+ return [applySheetDrawingPlacement(drawing, {
1249
+ kind: anchorType,
1250
+ bounds
1251
+ }, skeleton)];
1252
+ });
1253
+ if (newDrawings.length === 0) return false;
1106
1254
  if (undoRedoGroupService.runTimed(unitId, `sheet-drawing:nudge:${drawings[0].subUnitId}:${drawings.map((drawing) => drawing.drawingId).sort().join(",")}`, () => commandService.syncExecuteCommand(SetSheetDrawingCommand.id, {
1107
1255
  unitId,
1108
1256
  drawings: newDrawings
1109
- }))) {
1257
+ }), "append")) {
1110
1258
  commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id, [unitId]);
1111
1259
  return true;
1112
1260
  }
@@ -1114,8 +1262,7 @@ const MoveDrawingsCommand = {
1114
1262
  }
1115
1263
  };
1116
1264
 
1117
- //#endregion
1118
- //#region src/services/batch-save-images.service.ts
1265
+ // src/services/batch-save-images.service.ts
1119
1266
  /**
1120
1267
  * File name part type for multi-select
1121
1268
  */
@@ -1474,8 +1621,7 @@ BatchSaveImagesService = __decorate([
1474
1621
  __decorateParam(3, IURLImageService)
1475
1622
  ], BatchSaveImagesService);
1476
1623
 
1477
- //#endregion
1478
- //#region src/views/batch-save-images/component-name.ts
1624
+ // src/views/batch-save-images/component-name.ts
1479
1625
  /**
1480
1626
  * Copyright 2023-present DreamNum Co., Ltd.
1481
1627
  *
@@ -1493,8 +1639,7 @@ BatchSaveImagesService = __decorate([
1493
1639
  */
1494
1640
  const BATCH_SAVE_IMAGES_DIALOG_ID = "sheet.dialog.batch-save-images";
1495
1641
 
1496
- //#endregion
1497
- //#region src/commands/commands/save-cell-images.command.ts
1642
+ // src/commands/commands/save-cell-images.command.ts
1498
1643
  const SaveCellImagesCommand = {
1499
1644
  id: "sheet.command.save-cell-images",
1500
1645
  type: CommandType.COMMAND,
@@ -1525,8 +1670,7 @@ const SaveCellImagesCommand = {
1525
1670
  }
1526
1671
  };
1527
1672
 
1528
- //#endregion
1529
- //#region src/commands/commands/worksheet-background-image.command.ts
1673
+ // src/commands/commands/worksheet-background-image.command.ts
1530
1674
  const AddWorksheetBackgroundImageCommand = {
1531
1675
  id: "sheet.command.add-worksheet-background-image",
1532
1676
  type: CommandType.COMMAND,
@@ -1543,8 +1687,7 @@ const DeleteWorksheetBackgroundImageCommand = {
1543
1687
  handler: (accessor) => accessor.get(ICommandService).executeCommand(SetWorksheetBackgroundImageCommand.id, { backgroundImage: null })
1544
1688
  };
1545
1689
 
1546
- //#endregion
1547
- //#region src/views/sheet-image-panel/component-name.ts
1690
+ // src/views/sheet-image-panel/component-name.ts
1548
1691
  /**
1549
1692
  * Copyright 2023-present DreamNum Co., Ltd.
1550
1693
  *
@@ -1562,8 +1705,7 @@ const DeleteWorksheetBackgroundImageCommand = {
1562
1705
  */
1563
1706
  const COMPONENT_SHEET_DRAWING_PANEL = "COMPONENT_SHEET_DRAWING_PANEL";
1564
1707
 
1565
- //#endregion
1566
- //#region src/commands/operations/open-drawing-panel.operation.ts
1708
+ // src/commands/operations/open-drawing-panel.operation.ts
1567
1709
  const SidebarSheetDrawingOperation = {
1568
1710
  id: "sidebar.operation.sheet-image",
1569
1711
  type: CommandType.COMMAND,
@@ -1593,8 +1735,7 @@ const SidebarSheetDrawingOperation = {
1593
1735
  }
1594
1736
  };
1595
1737
 
1596
- //#endregion
1597
- //#region src/commands/operations/edit-sheet-drawing.operation.ts
1738
+ // src/commands/operations/edit-sheet-drawing.operation.ts
1598
1739
  const EditSheetDrawingOperation = {
1599
1740
  id: "sheet.operation.edit-sheet-image",
1600
1741
  type: CommandType.OPERATION,
@@ -1607,8 +1748,7 @@ const EditSheetDrawingOperation = {
1607
1748
  }
1608
1749
  };
1609
1750
 
1610
- //#endregion
1611
- //#region src/controllers/sheet-drawing-group-copy-paste.controller.ts
1751
+ // src/controllers/sheet-drawing-group-copy-paste.controller.ts
1612
1752
  const specialPastes$1 = [
1613
1753
  PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,
1614
1754
  PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,
@@ -1810,8 +1950,7 @@ SheetsDrawingGroupCopyPasteController = __decorate([
1810
1950
  __decorateParam(4, IDrawingManagerService)
1811
1951
  ], SheetsDrawingGroupCopyPasteController);
1812
1952
 
1813
- //#endregion
1814
- //#region src/services/sheet-chart-render-object.config.ts
1953
+ // src/services/sheet-chart-render-object.config.ts
1815
1954
  /** Shared Chart frame config for editor and isolated print Scene objects. */
1816
1955
  const SHEET_CHART_RENDER_OBJECT_CONFIG = Object.freeze({
1817
1956
  borderEnabled: false,
@@ -1821,8 +1960,7 @@ const SHEET_CHART_RENDER_OBJECT_CONFIG = Object.freeze({
1821
1960
  strokeWidth: 1
1822
1961
  });
1823
1962
 
1824
- //#endregion
1825
- //#region src/services/canvas-float-dom-manager.service.ts
1963
+ // src/services/canvas-float-dom-manager.service.ts
1826
1964
  var _SheetCanvasFloatDomManagerService;
1827
1965
  const SHEET_FLOAT_DOM_PREFIX = "univer-sheet-float-dom-";
1828
1966
  function createExternalRuntimeDisposable(owner, id, disposeById) {
@@ -1888,9 +2026,12 @@ function applyFloatDomTransformerConfig(rect, floatDomParam) {
1888
2026
  };
1889
2027
  }
1890
2028
  function applySheetChartTransformerConfig(rect) {
2029
+ var _rect$transformerConf, _rect$transformerConf2;
1891
2030
  rect.transformerConfig = {
1892
2031
  ...rect.transformerConfig,
1893
- ...SHEET_CHART_TRANSFORMER_CONFIG
2032
+ ...SHEET_CHART_TRANSFORMER_CONFIG,
2033
+ moveEnabled: ((_rect$transformerConf = rect.transformerConfig) === null || _rect$transformerConf === void 0 ? void 0 : _rect$transformerConf.moveEnabled) ?? SHEET_CHART_TRANSFORMER_CONFIG.moveEnabled,
2034
+ resizeEnabled: ((_rect$transformerConf2 = rect.transformerConfig) === null || _rect$transformerConf2 === void 0 ? void 0 : _rect$transformerConf2.resizeEnabled) ?? SHEET_CHART_TRANSFORMER_CONFIG.resizeEnabled
1894
2035
  };
1895
2036
  }
1896
2037
  function isStage2RuntimeEmbedFloatDom(floatDomParam) {
@@ -2019,8 +2160,8 @@ function transformBound2DOMBound(posOfFloatObject, scene, skeleton, worksheet, f
2019
2160
  const { boundsOfViewArea: specBoundsOfViewArea, scrollDirectionResponse } = floatDomInfo || {};
2020
2161
  const { rowHeaderWidth, columnHeaderHeight } = skeleton;
2021
2162
  const boundsOfViewArea = {
2022
- top: skipBoundsOfViewArea ? 0 : columnHeaderHeight,
2023
- left: skipBoundsOfViewArea ? 0 : rowHeaderWidth
2163
+ top: skipBoundsOfViewArea ? 0 : columnHeaderHeight * scaleY,
2164
+ left: skipBoundsOfViewArea ? 0 : rowHeaderWidth * scaleX
2024
2165
  };
2025
2166
  if (specBoundsOfViewArea) {
2026
2167
  if (Tools.isDefine(boundsOfViewArea.top)) boundsOfViewArea.top = specBoundsOfViewArea.top;
@@ -2118,6 +2259,10 @@ const calcSheetFloatDomPosition = (floatObject, scene, skeleton, worksheet, floa
2118
2259
  };
2119
2260
  };
2120
2261
  let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = class SheetCanvasFloatDomManagerService extends Disposable {
2262
+ registerMoveTransformConstraint(constraint) {
2263
+ this._moveTransformConstraints.add(constraint);
2264
+ return toDisposable(() => this._moveTransformConstraints.delete(constraint));
2265
+ }
2121
2266
  constructor(_renderManagerService, _univerInstanceService, _commandService, _drawingManagerService, _canvasFloatDomService, _sheetDrawingService, _lifecycleService, _canvasFloatDomPreviewService) {
2122
2267
  super();
2123
2268
  this._renderManagerService = _renderManagerService;
@@ -2135,12 +2280,29 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2135
2280
  _defineProperty(this, "add$", this._add$.asObservable());
2136
2281
  _defineProperty(this, "_remove$", new Subject());
2137
2282
  _defineProperty(this, "remove$", this._remove$.asObservable());
2283
+ _defineProperty(this, "_moveTransformConstraints", /* @__PURE__ */ new Set());
2284
+ _defineProperty(this, "_floatDomMoveDisposables", /* @__PURE__ */ new Map());
2138
2285
  _defineProperty(this, "_renderObjectFactories", /* @__PURE__ */ new Map());
2139
2286
  this._drawingAddListener();
2140
2287
  this._featureUpdateListener();
2141
2288
  this._deleteListener();
2142
2289
  this._bindScrollEvent();
2143
2290
  this._bindEmbedFloatDragHandleEvent();
2291
+ this.disposeWithMe(this._renderManagerService.disposed$.subscribe((unitId) => {
2292
+ for (const info of Array.from(this._domLayerInfoMap.values())) if (info.unitId === unitId) this._removeDom(info.id);
2293
+ }));
2294
+ this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe((unit) => {
2295
+ for (const info of Array.from(this._domLayerInfoMap.values())) if (info.unitId === unit.getUnitId()) this._removeDom(info.id);
2296
+ }));
2297
+ }
2298
+ dispose() {
2299
+ this._moveTransformConstraints.clear();
2300
+ for (const id of Array.from(this._domLayerInfoMap.keys())) this._removeDom(id);
2301
+ this._renderObjectFactories.clear();
2302
+ this._transformChange$.complete();
2303
+ this._add$.complete();
2304
+ this._remove$.complete();
2305
+ super.dispose();
2144
2306
  }
2145
2307
  /**
2146
2308
  * Register a factory that creates the canvas-side render object for a sheet
@@ -2165,14 +2327,26 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2165
2327
  const factory = factories === null || factories === void 0 ? void 0 : factories[factories.length - 1];
2166
2328
  return (factory === null || factory === void 0 ? void 0 : factory(context)) ?? new Rect(context.key, context.config);
2167
2329
  }
2330
+ _forwardWheelToCanvas(canvas, event) {
2331
+ if (!canvas.dispatchEvent(new WheelEvent(event.type, event))) event.preventDefault();
2332
+ }
2168
2333
  _bindScrollEvent() {
2169
- this._lifecycleService.lifecycle$.pipe(filter((s) => s === LifecycleStages.Rendered), take(1)).subscribe(() => {
2334
+ this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(filter((s) => s === LifecycleStages.Rendered), take(1)).subscribe(() => {
2170
2335
  this._scrollUpdateListener();
2171
- });
2336
+ }));
2172
2337
  }
2173
2338
  getFloatDomInfo(id) {
2174
2339
  return this._domLayerInfoMap.get(id);
2175
2340
  }
2341
+ updateFloatDomEventOptions(id, eventOptions) {
2342
+ const info = this._domLayerInfoMap.get(id);
2343
+ if (!(info === null || info === void 0 ? void 0 : info.floatDomConfig)) return;
2344
+ info.floatDomConfig = {
2345
+ ...info.floatDomConfig,
2346
+ eventOptions
2347
+ };
2348
+ this._canvasFloatDomService.updateFloatDom(id, { eventOptions });
2349
+ }
2176
2350
  getFloatDomsBySubUnitId(unitId, subUnitId) {
2177
2351
  return Array.from(this._domLayerInfoMap.values()).filter((info) => info.subUnitId === subUnitId && info.unitId === unitId);
2178
2352
  }
@@ -2189,6 +2363,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2189
2363
  this.disposeWithMe(() => document.removeEventListener(EMBED_FLOAT_DRAG_HANDLE_POINTER_DOWN_EVENT, listener));
2190
2364
  }
2191
2365
  _handleEmbedFloatDragHandlePointerDown(event) {
2366
+ var _this$_floatDomMoveDi, _this$_univerInstance2;
2192
2367
  const detail = event.detail;
2193
2368
  if (!(detail === null || detail === void 0 ? void 0 : detail.hostAnchorId)) return;
2194
2369
  const info = this._domLayerInfoMap.get(detail.hostAnchorId);
@@ -2196,7 +2371,21 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2196
2371
  const dragState = createFloatDomMoveDragState(info, detail);
2197
2372
  const renderObject = this._getSceneAndTransformerByDrawingSearch(info.unitId);
2198
2373
  if (!dragState || !renderObject) return;
2199
- const { scene, transformer } = renderObject;
2374
+ (_this$_floatDomMoveDi = this._floatDomMoveDisposables.get(info.id)) === null || _this$_floatDomMoveDi === void 0 || _this$_floatDomMoveDi.dispose();
2375
+ const { scene, transformer, canvas } = renderObject;
2376
+ const isCurrentHost = () => {
2377
+ var _this$_getSceneAndTra, _this$_univerInstance;
2378
+ return this._domLayerInfoMap.get(info.id) === info && ((_this$_getSceneAndTra = this._getSceneAndTransformerByDrawingSearch(info.unitId)) === null || _this$_getSceneAndTra === void 0 ? void 0 : _this$_getSceneAndTra.scene) === scene && ((_this$_univerInstance = this._univerInstanceService.getUnit(info.unitId, UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getActiveSheet().getSheetId()) === info.subUnitId;
2379
+ };
2380
+ const isChartSheet = ((_this$_univerInstance2 = this._univerInstanceService.getUnit(info.unitId, UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance2 === void 0 || (_this$_univerInstance2 = _this$_univerInstance2.getSheetBySheetId(info.subUnitId)) === null || _this$_univerInstance2 === void 0 ? void 0 : _this$_univerInstance2.getConfig().type) === SheetTypes.CHART;
2381
+ const toScenePoint = (point) => {
2382
+ const bounds = canvas.getBoundingClientRect();
2383
+ return scene.getMainViewport().transformVector2SceneCoord(Vector2.FromArray([point.clientX - bounds.left, point.clientY - bounds.top]));
2384
+ };
2385
+ const startPoint = isChartSheet ? toScenePoint({
2386
+ clientX: dragState.startClientX,
2387
+ clientY: dragState.startClientY
2388
+ }) : void 0;
2200
2389
  if (info.rect.oKey) {
2201
2390
  var _scene$getTransformer;
2202
2391
  transformer.clearControlByIds([info.rect.oKey]);
@@ -2204,15 +2393,35 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2204
2393
  }
2205
2394
  const handlePointerMove = (pointerEvent) => {
2206
2395
  if (dragState.pointerId != null && pointerEvent.pointerId !== dragState.pointerId) return;
2396
+ if (!isCurrentHost()) return;
2207
2397
  pointerEvent.preventDefault();
2208
- const nextTransform = resolveFloatDomMoveDragTransform(dragState, pointerEvent, scene);
2209
- info.rect.transformByState(nextTransform);
2398
+ const point = startPoint && toScenePoint(pointerEvent);
2399
+ const nextTransform = point && startPoint ? {
2400
+ left: dragState.startLeft + point.x - startPoint.x,
2401
+ top: dragState.startTop + point.y - startPoint.y
2402
+ } : resolveFloatDomMoveDragTransform(dragState, pointerEvent, scene);
2403
+ const drawing = this._sheetDrawingService.getDrawingByParam({
2404
+ unitId: info.unitId,
2405
+ subUnitId: info.subUnitId,
2406
+ drawingId: info.id
2407
+ });
2408
+ if ((drawing === null || drawing === void 0 ? void 0 : drawing.anchorType) === SheetDrawingAnchorType.None) {
2409
+ const next = {
2410
+ ...drawing,
2411
+ transform: {
2412
+ ...drawing.transform,
2413
+ ...nextTransform
2414
+ }
2415
+ };
2416
+ let transform = applySheetDrawingPlacement(drawing, getSheetDrawingPlacement(next)).transform;
2417
+ for (const constraint of this._moveTransformConstraints) transform = constraint(drawing, transform);
2418
+ info.rect.transformByState(transform);
2419
+ } else info.rect.transformByState(nextTransform);
2210
2420
  };
2211
2421
  const handlePointerUp = (pointerEvent) => {
2212
2422
  if (dragState.pointerId != null && pointerEvent.pointerId !== dragState.pointerId) return;
2213
- window.removeEventListener("pointermove", handlePointerMove, true);
2214
- window.removeEventListener("pointerup", handlePointerUp, true);
2215
- window.removeEventListener("pointercancel", handlePointerCancel, true);
2423
+ cleanupDrag();
2424
+ if (!isCurrentHost()) return;
2216
2425
  pointerEvent.preventDefault();
2217
2426
  if (info.rect.left !== dragState.startLeft || info.rect.top !== dragState.startTop) this._commitFloatDomMove(info);
2218
2427
  if (info.runtimeStage === "stage1") {
@@ -2222,9 +2431,8 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2222
2431
  };
2223
2432
  const handlePointerCancel = (pointerEvent) => {
2224
2433
  if (dragState.pointerId != null && pointerEvent.pointerId !== dragState.pointerId) return;
2225
- window.removeEventListener("pointermove", handlePointerMove, true);
2226
- window.removeEventListener("pointerup", handlePointerUp, true);
2227
- window.removeEventListener("pointercancel", handlePointerCancel, true);
2434
+ cleanupDrag();
2435
+ if (!isCurrentHost()) return;
2228
2436
  info.rect.transformByState({
2229
2437
  left: dragState.startLeft,
2230
2438
  top: dragState.startTop
@@ -2234,6 +2442,13 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2234
2442
  (_scene$attachTransfor2 = scene.attachTransformerTo) === null || _scene$attachTransfor2 === void 0 || _scene$attachTransfor2.call(scene, info.rect);
2235
2443
  }
2236
2444
  };
2445
+ const cleanupDrag = () => {
2446
+ this._floatDomMoveDisposables.delete(info.id);
2447
+ window.removeEventListener("pointermove", handlePointerMove, true);
2448
+ window.removeEventListener("pointerup", handlePointerUp, true);
2449
+ window.removeEventListener("pointercancel", handlePointerCancel, true);
2450
+ };
2451
+ this._floatDomMoveDisposables.set(info.id, { dispose: cleanupDrag });
2237
2452
  window.addEventListener("pointermove", handlePointerMove, true);
2238
2453
  window.addEventListener("pointerup", handlePointerUp, true);
2239
2454
  window.addEventListener("pointercancel", handlePointerCancel, true);
@@ -2246,7 +2461,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2246
2461
  subUnitId: info.subUnitId,
2247
2462
  drawingId: info.id
2248
2463
  });
2249
- if (!skeletonParam || !(drawing === null || drawing === void 0 ? void 0 : drawing.transform)) return;
2464
+ if (!(drawing === null || drawing === void 0 ? void 0 : drawing.transform) || this._domLayerInfoMap.get(info.id) !== info) return;
2250
2465
  const transform = {
2251
2466
  ...drawing.transform,
2252
2467
  left: info.rect.left,
@@ -2259,6 +2474,18 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2259
2474
  skewX: info.rect.skewX,
2260
2475
  skewY: info.rect.skewY
2261
2476
  };
2477
+ if (drawing.anchorType === SheetDrawingAnchorType.None) {
2478
+ const next = {
2479
+ ...drawing,
2480
+ transform
2481
+ };
2482
+ this._commandService.syncExecuteCommand(SetSheetDrawingCommand.id, {
2483
+ unitId: info.unitId,
2484
+ drawings: [applySheetDrawingPlacement(drawing, getSheetDrawingPlacement(next))]
2485
+ });
2486
+ return;
2487
+ }
2488
+ if (!skeletonParam) return;
2262
2489
  const sheetTransform = transformToDrawingPosition(transform, skeletonParam.skeleton);
2263
2490
  const axisAlignSheetTransform = transformToAxisAlignPosition(transform, skeletonParam.skeleton);
2264
2491
  if (!sheetTransform || !axisAlignSheetTransform) return;
@@ -2439,7 +2666,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2439
2666
  const activeSheetId = workbook.getActiveSheet().getSheetId();
2440
2667
  if (!floatDomParam || !target) return;
2441
2668
  const skeleton = (_this$_renderManagerS2 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS2 === void 0 ? void 0 : _this$_renderManagerS2.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId);
2442
- if (!skeleton) return;
2669
+ if (!skeleton && (target.worksheet.getConfig().type !== SheetTypes.CHART || floatDomParam.anchorType !== SheetDrawingAnchorType.None)) return;
2443
2670
  const { transform, drawingType, data, hidden, groupId } = floatDomParam;
2444
2671
  if (!isCanvasFloatDomDrawingType(drawingType)) return;
2445
2672
  const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
@@ -2487,6 +2714,11 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2487
2714
  top,
2488
2715
  width,
2489
2716
  height,
2717
+ angle,
2718
+ flipX,
2719
+ flipY,
2720
+ skewX,
2721
+ skewY,
2490
2722
  zIndex: this._getDrawingZIndex(unitId, subUnitId, drawingId)
2491
2723
  };
2492
2724
  const isChart = drawingType === DrawingTypeEnum.DRAWING_CHART;
@@ -2528,18 +2760,17 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2528
2760
  });
2529
2761
  previewSubscription && disposableCollection.add(previewSubscription);
2530
2762
  }
2531
- const initPosition = calcSheetFloatDomPosition(rect, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet);
2763
+ const initPosition = this._calculateFloatDomPosition(rect, renderObject.renderUnit.scene, target.worksheet, skeleton === null || skeleton === void 0 ? void 0 : skeleton.skeleton);
2532
2764
  const position$ = new BehaviorSubject(initPosition);
2533
2765
  const domId = `${SHEET_FLOAT_DOM_PREFIX}${generateRandomId(6)}`;
2534
2766
  const shouldAutoMountRuntime = shouldAutoMountFloatDomRuntime(floatDomParam);
2535
2767
  const shouldSyncEmbedRuntimeStage = isEmbedFloatDomData(floatDomParam);
2536
2768
  let info;
2537
2769
  const handleRuntimeStageEnter = (stage) => {
2538
- if (info) {
2539
- info.runtimeStage = stage;
2540
- info.runtimeMounted = shouldAutoMountRuntime || stage === "stage2";
2541
- if (shouldUpdateFloatDomLayerOnRuntimeStageChange(floatDomParam)) this._canvasFloatDomService.updateFloatDom(drawingId, { eventPassThrough: shouldPassThroughFloatDomRuntimeEvents(floatDomParam, stage) });
2542
- }
2770
+ if (!info || this._domLayerInfoMap.get(drawingId) !== info) return;
2771
+ info.runtimeStage = stage;
2772
+ info.runtimeMounted = shouldAutoMountRuntime || stage === "stage2";
2773
+ if (shouldUpdateFloatDomLayerOnRuntimeStageChange(floatDomParam)) this._canvasFloatDomService.updateFloatDom(drawingId, { eventPassThrough: shouldPassThroughFloatDomRuntimeEvents(floatDomParam, stage) });
2543
2774
  syncFloatDomHostSelectionOnStageEnter(stage, this._getSceneAndTransformerByDrawingSearch(unitId), rect);
2544
2775
  };
2545
2776
  const floatDomConfig = {
@@ -2548,6 +2779,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2548
2779
  domId,
2549
2780
  componentKey: floatDomParam.componentKey,
2550
2781
  eventPassThrough: shouldPassThroughFloatDomRuntimeEvents(floatDomParam, "inactive"),
2782
+ preventBrowserZoom: true,
2551
2783
  preserveOnFocusChange: shouldPreserveFloatDomOnFocusChange(floatDomParam),
2552
2784
  onPointerDown: (evt) => {
2553
2785
  if (shouldForwardSheetHostedEmbedFloatDomEvent(floatDomParam, evt)) canvas.dispatchEvent(new PointerEvent(evt.type, evt));
@@ -2559,7 +2791,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2559
2791
  if (shouldForwardSheetHostedEmbedFloatDomEvent(floatDomParam, evt)) canvas.dispatchEvent(new PointerEvent(evt.type, evt));
2560
2792
  },
2561
2793
  onWheel: (evt) => {
2562
- if (shouldForwardSheetHostedEmbedFloatDomEvent(floatDomParam, evt)) canvas.dispatchEvent(new WheelEvent(evt.type, evt));
2794
+ if (shouldForwardSheetHostedEmbedFloatDomEvent(floatDomParam, evt)) this._forwardWheelToCanvas(canvas, evt);
2563
2795
  },
2564
2796
  data,
2565
2797
  props: shouldSyncEmbedRuntimeStage ? { onRuntimeStageEnter: handleRuntimeStageEnter } : void 0,
@@ -2638,7 +2870,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2638
2870
  disposableCollection.add(sceneUpListener);
2639
2871
  }
2640
2872
  const listener = rect.onTransformChange$.subscribeEvent(() => {
2641
- const newPosition = calcSheetFloatDomPosition(rect, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet);
2873
+ const newPosition = this._calculateFloatDomPosition(rect, renderObject.renderUnit.scene, target.worksheet, skeleton === null || skeleton === void 0 ? void 0 : skeleton.skeleton);
2642
2874
  position$.next(newPosition);
2643
2875
  if (previewObjectKey) this._syncPreviewObjectTransform(scene.getObject(previewObjectKey), rect);
2644
2876
  });
@@ -2647,7 +2879,7 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2647
2879
  if (previewObjectKey) scene.removeObject(previewObjectKey);
2648
2880
  });
2649
2881
  listener && disposableCollection.add(listener);
2650
- this._bindFloatDomScroll(disposableCollection, info, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet);
2882
+ this._bindFloatDomScroll(disposableCollection, info, renderObject.renderUnit.scene, skeleton === null || skeleton === void 0 ? void 0 : skeleton.skeleton, target.worksheet);
2651
2883
  this._domLayerInfoMap.set(drawingId, info);
2652
2884
  });
2653
2885
  }));
@@ -2684,11 +2916,11 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2684
2916
  subUnitId
2685
2917
  });
2686
2918
  const skeleton = (_this$_renderManagerS3 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS3 === void 0 ? void 0 : _this$_renderManagerS3.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId);
2687
- if (!renderObject || !target || !skeleton) return;
2919
+ if (!renderObject || !target || !skeleton && target.worksheet.getConfig().type !== SheetTypes.CHART) return;
2688
2920
  ids.forEach((id) => {
2689
2921
  const floatDomInfo = this._domLayerInfoMap.get(id);
2690
2922
  if (floatDomInfo) {
2691
- const position = calcSheetFloatDomPosition(floatDomInfo.rect, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet, floatDomInfo);
2923
+ const position = this._calculateFloatDomPosition(floatDomInfo.rect, renderObject.renderUnit.scene, target.worksheet, skeleton === null || skeleton === void 0 ? void 0 : skeleton.skeleton, floatDomInfo);
2692
2924
  floatDomInfo.position$.next(position);
2693
2925
  }
2694
2926
  });
@@ -2718,9 +2950,35 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2718
2950
  _bindFloatDomScroll(disposableCollection, info, scene, skeleton, worksheet) {
2719
2951
  const viewport = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
2720
2952
  if (!viewport) return;
2721
- disposableCollection.add(fromEventSubject(viewport.onScrollAfter$).subscribe(() => {
2722
- info.position$.next(calcSheetFloatDomPosition(info.rect, scene, skeleton, worksheet, info));
2723
- }));
2953
+ const updatePosition = () => {
2954
+ if (this._domLayerInfoMap.get(info.id) !== info) return;
2955
+ info.position$.next(this._calculateFloatDomPosition(info.rect, scene, worksheet, skeleton, info));
2956
+ };
2957
+ disposableCollection.add(fromEventSubject(viewport.onScrollAfter$).subscribe(updatePosition));
2958
+ if (worksheet.getConfig().type === SheetTypes.CHART) {
2959
+ disposableCollection.add(scene.onTransformChange$.subscribeEvent(updatePosition));
2960
+ disposableCollection.add(viewport.onResized$.subscribe(updatePosition));
2961
+ }
2962
+ }
2963
+ _calculateFloatDomPosition(rect, scene, worksheet, skeleton, info) {
2964
+ if (skeleton) return calcSheetFloatDomPosition(rect, scene, skeleton, worksheet, info);
2965
+ const center = scene.getMainViewport().getAbsoluteVector(Vector2.FromArray([rect.left + rect.width / 2, rect.top + rect.height / 2]));
2966
+ const { scaleX, scaleY, angle } = scene.transform.decompose();
2967
+ const width = rect.width * scaleX;
2968
+ const height = rect.height * scaleY;
2969
+ return {
2970
+ startX: center.x - width / 2,
2971
+ startY: center.y - height / 2,
2972
+ endX: center.x + width / 2,
2973
+ endY: center.y + height / 2,
2974
+ width,
2975
+ height,
2976
+ rotate: rect.angle + angle,
2977
+ absolute: {
2978
+ left: false,
2979
+ top: false
2980
+ }
2981
+ };
2724
2982
  }
2725
2983
  updateFloatDomProps(unitId, subUnitId, id, props) {
2726
2984
  const info = this._domLayerInfoMap.get(id);
@@ -2890,9 +3148,11 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2890
3148
  return this._createFloatDomDisposable(id);
2891
3149
  }
2892
3150
  _removeDom(id, removeDrawing = false) {
3151
+ var _this$_floatDomMoveDi2;
2893
3152
  const info = this._domLayerInfoMap.get(id);
2894
3153
  if (!info) return;
2895
3154
  const { unitId, subUnitId } = info;
3155
+ (_this$_floatDomMoveDi2 = this._floatDomMoveDisposables.get(id)) === null || _this$_floatDomMoveDi2 === void 0 || _this$_floatDomMoveDi2.dispose();
2896
3156
  this._domLayerInfoMap.delete(id);
2897
3157
  info.dispose.dispose();
2898
3158
  const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
@@ -3056,17 +3316,9 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3056
3316
  subUnitId
3057
3317
  }, domRect, scene, this._drawingManagerService);
3058
3318
  const disposableCollection = new DisposableCollection();
3059
- const viewMain = scene.getMainViewport();
3060
- const { rowHeaderWidth, columnHeaderHeight } = skeletonParam.skeleton;
3061
3319
  const floatDomInfo = {
3062
3320
  dispose: disposableCollection,
3063
3321
  rect: domRect,
3064
- boundsOfViewArea: {
3065
- top: columnHeaderHeight,
3066
- left: rowHeaderWidth,
3067
- bottom: viewMain.bottom,
3068
- right: viewMain.right
3069
- },
3070
3322
  domAnchor,
3071
3323
  unitId,
3072
3324
  subUnitId,
@@ -3083,12 +3335,13 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3083
3335
  let floatDomCfg = {
3084
3336
  position$,
3085
3337
  id: drawingId,
3338
+ preventBrowserZoom: true,
3086
3339
  componentKey: floatDomParam.componentKey,
3087
3340
  onPointerDown: () => {},
3088
3341
  onPointerMove: () => {},
3089
3342
  onPointerUp: () => {},
3090
3343
  onWheel: (evt) => {
3091
- canvas.dispatchEvent(new WheelEvent(evt.type, evt));
3344
+ this._forwardWheelToCanvas(canvas, evt);
3092
3345
  },
3093
3346
  data,
3094
3347
  unitId
@@ -3292,12 +3545,13 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3292
3545
  let floatDomCfg = {
3293
3546
  position$,
3294
3547
  id: drawingId,
3548
+ preventBrowserZoom: true,
3295
3549
  componentKey: floatDomParam.componentKey,
3296
3550
  onPointerDown: () => {},
3297
3551
  onPointerMove: () => {},
3298
3552
  onPointerUp: () => {},
3299
3553
  onWheel: (evt) => {
3300
- canvas.dispatchEvent(new WheelEvent(evt.type, evt));
3554
+ this._forwardWheelToCanvas(canvas, evt);
3301
3555
  },
3302
3556
  data,
3303
3557
  unitId
@@ -3510,8 +3764,7 @@ function calculateOffset(value, rangeWidth) {
3510
3764
  return rangeWidth * Number.parseFloat(value) / 100;
3511
3765
  }
3512
3766
 
3513
- //#endregion
3514
- //#region src/embed/floating-host/register-sheets-drawing-floating-host.ts
3767
+ // src/embed/floating-host/register-sheets-drawing-floating-host.ts
3515
3768
  const SHEETS_DRAWING_FLOATING_HOST_DEPENDENCIES = [[SheetCanvasFloatDomManagerService]];
3516
3769
  function registerSheetsDrawingFloatingHostCapability(injector) {
3517
3770
  if (!injector.has(SheetCanvasFloatDomManagerService)) registerDependencies(injector, SHEETS_DRAWING_FLOATING_HOST_DEPENDENCIES);
@@ -3535,9 +3788,27 @@ function touchSheetsDrawingFloatingHostCapabilityWhenReady(injector) {
3535
3788
  });
3536
3789
  }
3537
3790
 
3538
- //#endregion
3539
- //#region src/menu/image.menu.ts
3791
+ // src/menu/image.menu.ts
3540
3792
  const SHEETS_IMAGE_MENU_ID = "sheet.menu.image";
3793
+ /** Chart Sheets have no cells; other sheet types retain the existing range-menu permission rules. */
3794
+ function getImageMenuDisabled$(accessor, floating) {
3795
+ return deriveStateFromActiveSheet$(accessor.get(IUniverInstanceService), true, ({ workbook, worksheet }) => {
3796
+ if (worksheet.getConfig().type === SheetTypes.CHART) {
3797
+ if (!floating) return of(true);
3798
+ const permissions = accessor.get(IPermissionService);
3799
+ const ids = [new WorkbookEditablePermission(workbook.getUnitId()).id, new WorksheetEditPermission(workbook.getUnitId(), worksheet.getSheetId()).id];
3800
+ return permissions.permissionPointUpdate$.pipe(startWith(null), map(() => ids.some((id) => {
3801
+ var _permissions$getPermi;
3802
+ return ((_permissions$getPermi = permissions.getPermissionPoint(id)) === null || _permissions$getPermi === void 0 ? void 0 : _permissions$getPermi.value) !== true;
3803
+ })), distinctUntilChanged());
3804
+ }
3805
+ return getCurrentRangeDisable$(accessor, {
3806
+ workbookTypes: [WorkbookEditablePermission],
3807
+ worksheetTypes: [WorksheetEditPermission],
3808
+ rangeTypes: [RangeProtectionPermissionEditPoint]
3809
+ });
3810
+ });
3811
+ }
3541
3812
  function ImageMenuFactory(accessor) {
3542
3813
  return {
3543
3814
  id: SHEETS_IMAGE_MENU_ID,
@@ -3545,17 +3816,14 @@ function ImageMenuFactory(accessor) {
3545
3816
  icon: "AddImageIcon",
3546
3817
  tooltip: "sheets-drawing-ui.title",
3547
3818
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
3548
- disabled$: getCurrentRangeDisable$(accessor, {
3549
- workbookTypes: [WorkbookEditablePermission],
3550
- worksheetTypes: [WorksheetEditPermission],
3551
- rangeTypes: [RangeProtectionPermissionEditPoint]
3552
- })
3819
+ disabled$: getImageMenuDisabled$(accessor, true)
3553
3820
  };
3554
3821
  }
3555
3822
  function UploadFloatImageMenuFactory(accessor) {
3556
3823
  return {
3557
3824
  id: InsertFloatImageCommand.id,
3558
3825
  title: "sheets-drawing-ui.upload.float",
3826
+ disabled$: getImageMenuDisabled$(accessor, true),
3559
3827
  type: MenuItemType.BUTTON,
3560
3828
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)
3561
3829
  };
@@ -3564,13 +3832,13 @@ function UploadCellImageMenuFactory(accessor) {
3564
3832
  return {
3565
3833
  id: InsertCellImageCommand.id,
3566
3834
  title: "sheets-drawing-ui.upload.cell",
3835
+ disabled$: getImageMenuDisabled$(accessor, false),
3567
3836
  type: MenuItemType.BUTTON,
3568
3837
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)
3569
3838
  };
3570
3839
  }
3571
3840
 
3572
- //#endregion
3573
- //#region src/menu/save-images.menu.ts
3841
+ // src/menu/save-images.menu.ts
3574
3842
  /**
3575
3843
  * Check if selection range has any images
3576
3844
  */
@@ -3613,8 +3881,7 @@ function SaveCellImagesMenuFactory(accessor) {
3613
3881
  };
3614
3882
  }
3615
3883
 
3616
- //#endregion
3617
- //#region src/menu/worksheet-background-image.menu.ts
3884
+ // src/menu/worksheet-background-image.menu.ts
3618
3885
  const WORKSHEET_BACKGROUND_IMAGE_MENU_ID = "sheet.menu.worksheet-background-image";
3619
3886
  function worksheetBackgroundImagePresent$(accessor) {
3620
3887
  const commandService = accessor.get(ICommandService);
@@ -3671,8 +3938,7 @@ function DeleteWorksheetBackgroundImageMenuFactory(accessor) {
3671
3938
  };
3672
3939
  }
3673
3940
 
3674
- //#endregion
3675
- //#region src/menu/schema.ts
3941
+ // src/menu/schema.ts
3676
3942
  const menuSchema = {
3677
3943
  [RibbonInsertGroup.MEDIA]: { [SHEETS_IMAGE_MENU_ID]: {
3678
3944
  order: 0,
@@ -3724,19 +3990,16 @@ const menuSchema = {
3724
3990
  } } }
3725
3991
  };
3726
3992
 
3727
- //#endregion
3728
- //#region package.json
3993
+ // package.json
3729
3994
  var name = "@univerjs/sheets-drawing-ui";
3730
- var version = "1.3.1";
3995
+ var version = "1.5.0";
3731
3996
 
3732
- //#endregion
3733
- //#region src/config/config.ts
3997
+ // src/config/config.ts
3734
3998
  const SHEETS_DRAWING_UI_PLUGIN_CONFIG_KEY = "sheets-drawing-ui.config";
3735
3999
  const configSymbol = Symbol(SHEETS_DRAWING_UI_PLUGIN_CONFIG_KEY);
3736
4000
  const defaultPluginConfig = {};
3737
4001
 
3738
- //#endregion
3739
- //#region src/services/drawing-context-menu.service.ts
4002
+ // src/services/drawing-context-menu.service.ts
3740
4003
  const IDrawingContextMenuService = createIdentifier("sheets-drawing-ui.drawing-context-menu.service");
3741
4004
  var DrawingContextMenuService = class extends Disposable {
3742
4005
  constructor(..._args) {
@@ -3755,8 +4018,7 @@ var DrawingContextMenuService = class extends Disposable {
3755
4018
  }
3756
4019
  };
3757
4020
 
3758
- //#endregion
3759
- //#region src/controllers/drawing-context-menu.controller.ts
4021
+ // src/controllers/drawing-context-menu.controller.ts
3760
4022
  let DrawingContextMenuController = class DrawingContextMenuController extends RxDisposable {
3761
4023
  constructor(_drawingManagerService, _contextMenuService, _renderManagerService, _univerInstanceService, _drawingContextMenuService) {
3762
4024
  super();
@@ -3812,8 +4074,7 @@ DrawingContextMenuController = __decorate([
3812
4074
  __decorateParam(4, IDrawingContextMenuService)
3813
4075
  ], DrawingContextMenuController);
3814
4076
 
3815
- //#endregion
3816
- //#region src/views/batch-save-images/BatchSaveImagesDialog.tsx
4077
+ // src/views/batch-save-images/BatchSaveImagesDialog.tsx
3817
4078
  function BatchSaveImagesDialog({ SelectComponent = Select } = {}) {
3818
4079
  const localeService = useDependency(LocaleService);
3819
4080
  const dialogService = useDependency(IDialogService);
@@ -3937,8 +4198,7 @@ function BatchSaveImagesDialog({ SelectComponent = Select } = {}) {
3937
4198
  });
3938
4199
  }
3939
4200
 
3940
- //#endregion
3941
- //#region src/views/batch-save-images/MobileBatchSaveImagesDialog.tsx
4201
+ // src/views/batch-save-images/MobileBatchSaveImagesDialog.tsx
3942
4202
  /**
3943
4203
  * Copyright 2023-present DreamNum Co., Ltd.
3944
4204
  *
@@ -3958,14 +4218,12 @@ function MobileBatchSaveImagesDialog() {
3958
4218
  return /* @__PURE__ */ jsx(BatchSaveImagesDialog, { SelectComponent: MobileSelect });
3959
4219
  }
3960
4220
 
3961
- //#endregion
3962
- //#region src/views/sheet-image-panel/sheet-drawing-panel.util.ts
4221
+ // src/views/sheet-image-panel/sheet-drawing-panel.util.ts
3963
4222
  function isSheetDrawing(drawing) {
3964
4223
  return Boolean(drawing && "sheetTransform" in drawing && drawing.sheetTransform);
3965
4224
  }
3966
4225
 
3967
- //#endregion
3968
- //#region src/views/sheet-image-panel/SheetDrawingAnchor.tsx
4226
+ // src/views/sheet-image-panel/SheetDrawingAnchor.tsx
3969
4227
  const SheetDrawingAnchor = (props) => {
3970
4228
  function getAnchorKind(value) {
3971
4229
  if (value === SheetDrawingAnchorType.Position || value === SheetDrawingAnchorType.Both || value === SheetDrawingAnchorType.None) return value;
@@ -4087,8 +4345,7 @@ const SheetDrawingAnchor = (props) => {
4087
4345
  });
4088
4346
  };
4089
4347
 
4090
- //#endregion
4091
- //#region src/commands/operations/preview-sheet-image-opacity.operation.ts
4348
+ // src/commands/operations/preview-sheet-image-opacity.operation.ts
4092
4349
  const PreviewSheetImageOpacityOperation = {
4093
4350
  id: "sheet.operation.preview-image-opacity",
4094
4351
  type: CommandType.OPERATION,
@@ -4103,8 +4360,7 @@ const PreviewSheetImageOpacityOperation = {
4103
4360
  }
4104
4361
  };
4105
4362
 
4106
- //#endregion
4107
- //#region src/views/sheet-image-panel/SheetImageTransparencySlider.tsx
4363
+ // src/views/sheet-image-panel/SheetImageTransparencySlider.tsx
4108
4364
  const MIN_TRANSPARENCY = 0;
4109
4365
  const MAX_TRANSPARENCY = 100;
4110
4366
  const TRANSPARENCY_STEP = 1;
@@ -4362,8 +4618,7 @@ function normalizeTransparency$1(value) {
4362
4618
  return Math.min(Math.max(Math.round(value), MIN_TRANSPARENCY), MAX_TRANSPARENCY);
4363
4619
  }
4364
4620
 
4365
- //#endregion
4366
- //#region src/views/sheet-image-panel/SheetImageTransparency.tsx
4621
+ // src/views/sheet-image-panel/SheetImageTransparency.tsx
4367
4622
  const IMAGE_TRANSPARENCY_PRESETS = [
4368
4623
  0,
4369
4624
  15,
@@ -4471,8 +4726,7 @@ function transparencyToOpacity(transparency) {
4471
4726
  return (100 - transparency) / 100;
4472
4727
  }
4473
4728
 
4474
- //#endregion
4475
- //#region src/views/sheet-image-panel/SheetDrawingPanel.tsx
4729
+ // src/views/sheet-image-panel/SheetDrawingPanel.tsx
4476
4730
  /**
4477
4731
  * Copyright 2023-present DreamNum Co., Ltd.
4478
4732
  *
@@ -4501,8 +4755,7 @@ const SheetDrawingPanel = () => {
4501
4755
  });
4502
4756
  };
4503
4757
 
4504
- //#endregion
4505
- //#region src/controllers/mobile/components.controller.ts
4758
+ // src/controllers/mobile/components.controller.ts
4506
4759
  /**
4507
4760
  * Copyright 2023-present DreamNum Co., Ltd.
4508
4761
  *
@@ -4527,8 +4780,7 @@ let MobileComponentsController = class MobileComponentsController extends Dispos
4527
4780
  };
4528
4781
  MobileComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager))], MobileComponentsController);
4529
4782
 
4530
- //#endregion
4531
- //#region src/controllers/render-controllers/sheet-celll-image-hover.render-controller.ts
4783
+ // src/controllers/render-controllers/sheet-celll-image-hover.render-controller.ts
4532
4784
  const CELL_IMAGE_PREVIEW_KEY = "preview-cell-image";
4533
4785
  let SheetCellImageHoverRenderController = class SheetCellImageHoverRenderController extends Disposable {
4534
4786
  constructor(_context, _hoverManagerService, _selectionsService, _drawingRenderService, _sheetSkeletonManagerService) {
@@ -4602,8 +4854,7 @@ SheetCellImageHoverRenderController = __decorate([
4602
4854
  __decorateParam(4, Inject(SheetSkeletonManagerService))
4603
4855
  ], SheetCellImageHoverRenderController);
4604
4856
 
4605
- //#endregion
4606
- //#region src/controllers/render-controllers/sheet-drawing.render-controller.ts
4857
+ // src/controllers/render-controllers/sheet-drawing.render-controller.ts
4607
4858
  let SheetsDrawingRenderController = class SheetsDrawingRenderController extends Disposable {
4608
4859
  constructor(_context, _sheetDrawingService, _drawingManagerService, _sheetSkeletonService, _logService) {
4609
4860
  super();
@@ -4663,13 +4914,13 @@ SheetsDrawingRenderController = __decorate([
4663
4914
  __decorateParam(4, ILogService)
4664
4915
  ], SheetsDrawingRenderController);
4665
4916
 
4666
- //#endregion
4667
- //#region src/views/background/worksheet-background-image.extension.ts
4917
+ // src/views/background/worksheet-background-image.extension.ts
4668
4918
  const WORKSHEET_BACKGROUND_IMAGE_EXTENSION_KEY = "WorksheetBackgroundImageExtension";
4669
- var WorksheetBackgroundImageExtension = class extends SheetExtension {
4919
+ var WorksheetBackgroundImageExtension = class WorksheetBackgroundImageExtension extends SheetExtension {
4670
4920
  constructor(injector, _requestRender) {
4671
4921
  super();
4672
4922
  this._requestRender = _requestRender;
4923
+ _defineProperty(this, "viewportCacheReusable", this.constructor === WorksheetBackgroundImageExtension);
4673
4924
  _defineProperty(this, "uKey", WORKSHEET_BACKGROUND_IMAGE_EXTENSION_KEY);
4674
4925
  _defineProperty(this, "type", SHEET_EXTENSION_TYPE.BACKGROUND);
4675
4926
  _defineProperty(this, "_imageCache", void 0);
@@ -4704,8 +4955,7 @@ var WorksheetBackgroundImageExtension = class extends SheetExtension {
4704
4955
  }
4705
4956
  };
4706
4957
 
4707
- //#endregion
4708
- //#region src/controllers/render-controllers/worksheet-background.render-controller.ts
4958
+ // src/controllers/render-controllers/worksheet-background.render-controller.ts
4709
4959
  let WorksheetBackgroundRenderController = class WorksheetBackgroundRenderController extends Disposable {
4710
4960
  constructor(_context, commandService, injector) {
4711
4961
  super();
@@ -4727,8 +4977,7 @@ let WorksheetBackgroundRenderController = class WorksheetBackgroundRenderControl
4727
4977
  };
4728
4978
  WorksheetBackgroundRenderController = __decorate([__decorateParam(1, ICommandService), __decorateParam(2, Inject(Injector))], WorksheetBackgroundRenderController);
4729
4979
 
4730
- //#endregion
4731
- //#region src/controllers/sheet-cell-image.controller.ts
4980
+ // src/controllers/sheet-cell-image.controller.ts
4732
4981
  function resizeImageByCell(injector, location, cell) {
4733
4982
  var _documentData$drawing, _documentData$drawing2;
4734
4983
  const documentData = cell === null || cell === void 0 ? void 0 : cell.p;
@@ -4807,8 +5056,7 @@ SheetCellImageController = __decorate([
4807
5056
  __decorateParam(4, Inject(IEditorBridgeService))
4808
5057
  ], SheetCellImageController);
4809
5058
 
4810
- //#endregion
4811
- //#region src/controllers/sheet-cell-image-autofill.controller.ts
5059
+ // src/controllers/sheet-cell-image-autofill.controller.ts
4812
5060
  /**
4813
5061
  * Copyright 2023-present DreamNum Co., Ltd.
4814
5062
  *
@@ -4849,8 +5097,7 @@ let SheetCellImageAutofillController = class SheetCellImageAutofillController ex
4849
5097
  };
4850
5098
  SheetCellImageAutofillController = __decorate([__decorateParam(0, Inject(IAutoFillService)), __decorateParam(1, Inject(Injector))], SheetCellImageAutofillController);
4851
5099
 
4852
- //#endregion
4853
- //#region src/controllers/sheet-cell-image-copy-paste.controller.ts
5100
+ // src/controllers/sheet-cell-image-copy-paste.controller.ts
4854
5101
  const DISABLE_UNITS = [DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];
4855
5102
  let SheetCellImageCopyPasteController = class SheetCellImageCopyPasteController extends Disposable {
4856
5103
  constructor(_commandService, _univerInstanceService, _dialogService, _renderManagerService, _localeService) {
@@ -4923,8 +5170,7 @@ SheetCellImageCopyPasteController = __decorate([
4923
5170
  __decorateParam(4, Inject(LocaleService))
4924
5171
  ], SheetCellImageCopyPasteController);
4925
5172
 
4926
- //#endregion
4927
- //#region src/controllers/sheet-drawing-active-render.controller.ts
5173
+ // src/controllers/sheet-drawing-active-render.controller.ts
4928
5174
  let SheetDrawingActiveRenderController = class SheetDrawingActiveRenderController extends Disposable {
4929
5175
  constructor(_context, _commandService, _sheetSkeletonService, _sheetDrawingService, _drawingManagerService, _logService) {
4930
5176
  super();
@@ -5050,8 +5296,7 @@ function prepareSheetDrawings(drawings, skeleton) {
5050
5296
  };
5051
5297
  }
5052
5298
 
5053
- //#endregion
5054
- //#region src/controllers/sheet-drawing-copy-paste.controller.ts
5299
+ // src/controllers/sheet-drawing-copy-paste.controller.ts
5055
5300
  const IMAGE_PNG_MIME_TYPE = "image/png";
5056
5301
  function base64ToBlob(base64) {
5057
5302
  const arr = base64.split(",");
@@ -5093,7 +5338,11 @@ const specialPastes = [
5093
5338
  PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA
5094
5339
  ];
5095
5340
  let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController extends RxDisposable {
5096
- constructor(_sheetClipboardService, _renderManagerService, _sheetSkeletonService, _drawingService, _clipboardInterfaceService, _commandService) {
5341
+ dispose() {
5342
+ this._copyInfo = null;
5343
+ super.dispose();
5344
+ }
5345
+ constructor(_sheetClipboardService, _renderManagerService, _sheetSkeletonService, _drawingService, _clipboardInterfaceService, _commandService, _instanceService, _permissions) {
5097
5346
  super();
5098
5347
  this._sheetClipboardService = _sheetClipboardService;
5099
5348
  this._renderManagerService = _renderManagerService;
@@ -5101,6 +5350,8 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
5101
5350
  this._drawingService = _drawingService;
5102
5351
  this._clipboardInterfaceService = _clipboardInterfaceService;
5103
5352
  this._commandService = _commandService;
5353
+ this._instanceService = _instanceService;
5354
+ this._permissions = _permissions;
5104
5355
  _defineProperty(this, "_copyInfo", void 0);
5105
5356
  this._initCopyPaste();
5106
5357
  }
@@ -5110,12 +5361,15 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
5110
5361
  _initCopyPaste() {
5111
5362
  this.disposeWithMe(this._sheetClipboardService.addClipboardHook({
5112
5363
  id: "SHEET_IMAGE_UI_PLUGIN",
5113
- onBeforeCopyFocusedObject: (unitId, _subUnitId, copyType) => {
5364
+ onBeforeCopyFocusedObject: (unitId, subUnitId, copyType) => {
5114
5365
  this._copyInfo = null;
5115
5366
  const drawings = this._focusedDrawings.filter((drawing) => drawing.drawingType === DrawingTypeEnum.DRAWING_IMAGE);
5116
5367
  if (drawings.length === 0) return false;
5117
5368
  const [drawing] = drawings;
5118
5369
  if (copyType === COPY_TYPE.CUT) {
5370
+ var _this$_instanceServic;
5371
+ const worksheet = (_this$_instanceServic = this._instanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) === null || _this$_instanceServic === void 0 ? void 0 : _this$_instanceServic.getSheetBySheetId(subUnitId);
5372
+ if ((worksheet === null || worksheet === void 0 ? void 0 : worksheet.getConfig().type) === SheetTypes.CHART) return false;
5119
5373
  const params = {
5120
5374
  unitId,
5121
5375
  drawings
@@ -5245,12 +5499,15 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
5245
5499
  };
5246
5500
  }
5247
5501
  _generateSingleDrawingPasteMutations(pasteContext, copyType) {
5502
+ var _this$_instanceServic2;
5248
5503
  const { pasteType, pasteTo } = pasteContext;
5249
5504
  if (specialPastes.includes(pasteType)) return {
5250
5505
  redos: [],
5251
5506
  undos: []
5252
5507
  };
5253
5508
  const { unitId, subUnitId, range } = pasteTo;
5509
+ const worksheet = (_this$_instanceServic2 = this._instanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) === null || _this$_instanceServic2 === void 0 ? void 0 : _this$_instanceServic2.getSheetBySheetId(subUnitId);
5510
+ if ((worksheet === null || worksheet === void 0 ? void 0 : worksheet.getConfig().type) === SheetTypes.CHART) return this._generateChartSheetImagePasteMutations(pasteTo);
5254
5511
  const pasteToSkeleton = this._sheetSkeletonService.getSkeleton(unitId, subUnitId);
5255
5512
  if (!pasteToSkeleton) return {
5256
5513
  redos: [],
@@ -5296,6 +5553,47 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
5296
5553
  }
5297
5554
  });
5298
5555
  }
5556
+ _generateChartSheetImagePasteMutations(pasteTo) {
5557
+ var _this$_renderManagerS;
5558
+ const { unitId, subUnitId } = pasteTo;
5559
+ const worksheet = this._instanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET).getSheetBySheetId(subUnitId);
5560
+ if (!this._permissions.permissionCheckWithoutRange({
5561
+ workbookTypes: [WorkbookEditablePermission],
5562
+ worksheetTypes: [WorksheetEditPermission]
5563
+ }, unitId, subUnitId)) throw new CustomCommandExecutionError(SheetPasteCommand.id);
5564
+ const source = this._copyInfo;
5565
+ if (!this._permissions.permissionCheckWithoutRange({
5566
+ workbookTypes: [WorkbookCopyPermission],
5567
+ worksheetTypes: [WorksheetCopyPermission]
5568
+ }, source.unitId, source.subUnitId) || source.drawings.some((drawing) => !Tools.diffValue(drawing, this._drawingService.getDrawingByParam(drawing)))) throw new CustomCommandExecutionError(SheetPasteCommand.id);
5569
+ const frame = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.components.get(SHEET_VIEW_KEY.CHART_PAGE);
5570
+ const originals = this._copyInfo.drawings;
5571
+ const placed = frame && transformDrawingsToChartSheet(originals, {
5572
+ left: frame.left,
5573
+ top: frame.top,
5574
+ width: frame.width,
5575
+ height: frame.height
5576
+ }, worksheet.getConfig().rightToLeft === BooleanNumber.TRUE);
5577
+ if (!placed) return {
5578
+ redos: [],
5579
+ undos: []
5580
+ };
5581
+ const copies = new Map(placed.map((drawing) => [drawing.drawingId, drawing]));
5582
+ return this._generateMutations(originals, {
5583
+ unitId,
5584
+ subUnitId,
5585
+ isCut: false,
5586
+ getTransform: (_transform, _sheetTransform, drawing) => {
5587
+ const copy = copies.get(drawing.drawingId);
5588
+ return {
5589
+ anchorType: copy.anchorType,
5590
+ transform: copy.transform,
5591
+ sheetTransform: copy.sheetTransform,
5592
+ axisAlignSheetTransform: copy.axisAlignSheetTransform
5593
+ };
5594
+ }
5595
+ });
5596
+ }
5299
5597
  _generateMutations(drawings, payload) {
5300
5598
  const { unitId, subUnitId, getTransform, isCut } = payload;
5301
5599
  const redos = [];
@@ -5304,15 +5602,13 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
5304
5602
  drawings.forEach((drawing) => {
5305
5603
  const { transform, sheetTransform } = drawing;
5306
5604
  if (!transform) return;
5307
- const transformContext = getTransform(transform, sheetTransform);
5605
+ const transformContext = getTransform(transform, sheetTransform, drawing);
5308
5606
  const drawingObject = {
5309
5607
  ...drawing,
5310
- unitId,
5311
- subUnitId,
5608
+ ...transformContext,
5312
5609
  drawingId: isCut ? drawing.drawingId : generateRandomId(),
5313
- transform: transformContext.transform,
5314
- sheetTransform: transformContext.sheetTransform,
5315
- axisAlignSheetTransform: transformContext.axisAlignSheetTransform
5610
+ unitId,
5611
+ subUnitId
5316
5612
  };
5317
5613
  if (isCut) {
5318
5614
  const { undo, redo, objects } = _drawingService.getBatchUpdateOp([drawingObject]);
@@ -5455,11 +5751,136 @@ SheetsDrawingCopyPasteController = __decorate([
5455
5751
  __decorateParam(2, Inject(SheetSkeletonService)),
5456
5752
  __decorateParam(3, IDrawingManagerService),
5457
5753
  __decorateParam(4, IClipboardInterfaceService),
5458
- __decorateParam(5, ICommandService)
5754
+ __decorateParam(5, ICommandService),
5755
+ __decorateParam(6, IUniverInstanceService),
5756
+ __decorateParam(7, Inject(SheetPermissionCheckController))
5459
5757
  ], SheetsDrawingCopyPasteController);
5460
5758
 
5461
- //#endregion
5462
- //#region src/controllers/sheet-drawing-permission.controller.ts
5759
+ // src/commands/commands/flip-drawings.command.ts
5760
+ /**
5761
+ * The command to flip sheet drawing elements
5762
+ */
5763
+ const FlipSheetDrawingCommand = {
5764
+ id: "sheet.command.toggle-flip-drawings",
5765
+ type: CommandType.COMMAND,
5766
+ handler: (accessor, params) => {
5767
+ if (!params) return false;
5768
+ const commandService = accessor.get(ICommandService);
5769
+ const undoRedoService = accessor.get(IUndoRedoService);
5770
+ const sheetDrawingService = accessor.get(ISheetDrawingService);
5771
+ const sheetSkeletonService = accessor.get(SheetSkeletonService);
5772
+ const { drawings } = params;
5773
+ const flipH = params.flipH;
5774
+ const flipV = params.flipV;
5775
+ const unitIds = [];
5776
+ const updateParams = [];
5777
+ for (const param of drawings) {
5778
+ const { unitId, subUnitId, drawingId } = param;
5779
+ unitIds.push(unitId);
5780
+ const drawingData = sheetDrawingService.getDrawingData(unitId, subUnitId);
5781
+ const existing = drawingData === null || drawingData === void 0 ? void 0 : drawingData[drawingId];
5782
+ if (!existing) continue;
5783
+ const skeleton = sheetSkeletonService.getSkeleton(unitId, subUnitId);
5784
+ if (!skeleton) continue;
5785
+ const transform = { ...existing.transform };
5786
+ if (flipH) transform.flipX = !transform.flipX;
5787
+ if (flipV) transform.flipY = !transform.flipY;
5788
+ const sheetTransform = transformToDrawingPosition(transform, skeleton);
5789
+ const axisAlignSheetTransform = transformToAxisAlignPosition(transform, skeleton);
5790
+ const updateParamItem = {
5791
+ unitId,
5792
+ subUnitId,
5793
+ drawingType: existing.drawingType,
5794
+ drawingId,
5795
+ transform,
5796
+ sheetTransform,
5797
+ axisAlignSheetTransform
5798
+ };
5799
+ if (existing.drawingType === DrawingTypeEnum.DRAWING_IMAGE) {
5800
+ const scene = getSceneByDrawingSearch(accessor, unitId);
5801
+ if (scene) {
5802
+ const drawingShapeKey = getDrawingShapeKeyByDrawingSearch({
5803
+ unitId,
5804
+ subUnitId,
5805
+ drawingId
5806
+ });
5807
+ const imageShape = scene.getObject(drawingShapeKey);
5808
+ if (imageShape) {
5809
+ const srcRect = imageShape.srcRect;
5810
+ if (srcRect) {
5811
+ let newSrcRect;
5812
+ const { left = 0, top = 0, right = 0, bottom = 0 } = srcRect;
5813
+ if (flipH) {
5814
+ const centerX = left + (right - left) / 2;
5815
+ newSrcRect = {
5816
+ left: centerX - (right - left) / 2,
5817
+ top,
5818
+ right: centerX + (right - left) / 2,
5819
+ bottom
5820
+ };
5821
+ }
5822
+ if (flipV) {
5823
+ const centerY = top + (bottom - top) / 2;
5824
+ newSrcRect = {
5825
+ left,
5826
+ top: centerY - (bottom - top) / 2,
5827
+ right,
5828
+ bottom: centerY + (bottom - top) / 2
5829
+ };
5830
+ }
5831
+ if (newSrcRect) updateParamItem.srcRect = newSrcRect;
5832
+ }
5833
+ }
5834
+ }
5835
+ }
5836
+ updateParams.push(updateParamItem);
5837
+ }
5838
+ if (updateParams.length === 0) return false;
5839
+ const { unitId: opUnitId, subUnitId: opSubUnitId, undo, redo, objects } = sheetDrawingService.getBatchUpdateOp(updateParams);
5840
+ const updateMutation = {
5841
+ id: SetDrawingApplyMutation.id,
5842
+ params: {
5843
+ unitId: opUnitId,
5844
+ subUnitId: opSubUnitId,
5845
+ op: redo,
5846
+ objects,
5847
+ type: DrawingApplyType.UPDATE
5848
+ }
5849
+ };
5850
+ const undoUpdateMutation = {
5851
+ id: SetDrawingApplyMutation.id,
5852
+ params: {
5853
+ unitId: opUnitId,
5854
+ subUnitId: opSubUnitId,
5855
+ op: undo,
5856
+ objects,
5857
+ type: DrawingApplyType.UPDATE
5858
+ }
5859
+ };
5860
+ if (sequenceExecute([updateMutation], commandService).result) {
5861
+ undoRedoService.pushUndoRedo({
5862
+ unitID: opUnitId,
5863
+ undoMutations: [undoUpdateMutation, {
5864
+ id: ClearSheetDrawingTransformerOperation.id,
5865
+ params: unitIds
5866
+ }],
5867
+ redoMutations: [updateMutation, {
5868
+ id: ClearSheetDrawingTransformerOperation.id,
5869
+ params: unitIds
5870
+ }]
5871
+ });
5872
+ return true;
5873
+ }
5874
+ return false;
5875
+ }
5876
+ };
5877
+ function getSceneByDrawingSearch(accessor, unitId) {
5878
+ const render = accessor.get(IRenderManagerService).getRenderUnitById(unitId);
5879
+ if (!render) return null;
5880
+ return render.scene;
5881
+ }
5882
+
5883
+ // src/controllers/sheet-drawing-permission.controller.ts
5463
5884
  const drawingObjectTypes = [
5464
5885
  ObjectType.IMAGE,
5465
5886
  ObjectType.SHAPE,
@@ -5482,6 +5903,7 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
5482
5903
  this._initViewPermissionChange();
5483
5904
  this._initEditPermissionChange();
5484
5905
  this._initCommandPermissionCheck();
5906
+ this._initChartSheetCommandPermissionCheck();
5485
5907
  }
5486
5908
  _initDrawingVisible() {
5487
5909
  const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
@@ -5657,6 +6079,30 @@ let SheetDrawingPermissionController = class SheetDrawingPermissionController ex
5657
6079
  }
5658
6080
  }));
5659
6081
  }
6082
+ _initChartSheetCommandPermissionCheck() {
6083
+ this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
6084
+ if (command.id === GroupSheetDrawingCommand.id || command.id === UngroupSheetDrawingCommand.id) {
6085
+ for (const group of command.params ?? []) {
6086
+ this._checkChartSheetEditPermission(group.parent.unitId, group.parent.subUnitId);
6087
+ for (const child of group.children) this._checkChartSheetEditPermission(child.unitId, child.subUnitId);
6088
+ }
6089
+ return;
6090
+ }
6091
+ if (command.id === FlipSheetDrawingCommand.id) {
6092
+ const params = command.params;
6093
+ for (const drawing of (params === null || params === void 0 ? void 0 : params.drawings) ?? []) this._checkChartSheetEditPermission(drawing.unitId, drawing.subUnitId);
6094
+ }
6095
+ }));
6096
+ }
6097
+ _checkChartSheetEditPermission(unitId, subUnitId) {
6098
+ var _this$_univerInstance;
6099
+ const worksheet = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
6100
+ if ((worksheet === null || worksheet === void 0 ? void 0 : worksheet.getConfig().type) !== SheetTypes.CHART) return;
6101
+ if (!this._sheetPermissionCheckController.permissionCheckWithoutRange({
6102
+ workbookTypes: [WorkbookEditablePermission],
6103
+ worksheetTypes: [WorksheetEditPermission]
6104
+ }, unitId, subUnitId)) this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-drawing-ui.permission.dialog.editErr"));
6105
+ }
5660
6106
  _initCommandPermissionCheck() {
5661
6107
  this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
5662
6108
  let unitId;
@@ -5701,8 +6147,7 @@ function getPlacementCommandTarget(params) {
5701
6147
  };
5702
6148
  }
5703
6149
 
5704
- //#endregion
5705
- //#region src/views/PrintingFloatDom.tsx
6150
+ // src/views/PrintingFloatDom.tsx
5706
6151
  function createPrintingFloatDom(info, scene, skeleton, worksheet) {
5707
6152
  const { width, height, angle, left, top } = info.transform;
5708
6153
  const offsetBound = transformBound2DOMBound({
@@ -5764,8 +6209,7 @@ function mountPrintingFloatDom(props, root, injector) {
5764
6209
  return () => unmount(root);
5765
6210
  }
5766
6211
 
5767
- //#endregion
5768
- //#region src/controllers/sheet-drawing-printing.controller.ts
6212
+ // src/controllers/sheet-drawing-printing.controller.ts
5769
6213
  let SheetDrawingPrintingController = class SheetDrawingPrintingController extends Disposable {
5770
6214
  constructor(_sheetPrintInterceptorService, _drawingRenderService, _drawingManagerService, _renderManagerService, _componetManager, _injector) {
5771
6215
  super();
@@ -5787,7 +6231,10 @@ let SheetDrawingPrintingController = class SheetDrawingPrintingController extend
5787
6231
  const drawing = subUnitData.data[id];
5788
6232
  if (drawing.hidden) return;
5789
6233
  if (drawing.drawingType !== DrawingTypeEnum.DRAWING_CHART && drawing.drawingType !== DrawingTypeEnum.DRAWING_DOM && drawing.drawingType !== DrawingTypeEnum.DRAWING_BLOCK) {
5790
- const resource = this._drawingRenderService.renderDrawing(drawing, scene, { allowInactiveSheet: true });
6234
+ const resource = this._drawingRenderService.renderDrawing(drawing, scene, {
6235
+ allowInactiveSheet: true,
6236
+ interactive: false
6237
+ });
5791
6238
  if (resource) resourceCollector.add(Promise.resolve(resource));
5792
6239
  }
5793
6240
  });
@@ -5879,133 +6326,7 @@ SheetDrawingPrintingController = __decorate([
5879
6326
  __decorateParam(5, Inject(Injector))
5880
6327
  ], SheetDrawingPrintingController);
5881
6328
 
5882
- //#endregion
5883
- //#region src/commands/commands/flip-drawings.command.ts
5884
- /**
5885
- * The command to flip sheet drawing elements
5886
- */
5887
- const FlipSheetDrawingCommand = {
5888
- id: "sheet.command.toggle-flip-drawings",
5889
- type: CommandType.COMMAND,
5890
- handler: (accessor, params) => {
5891
- if (!params) return false;
5892
- const commandService = accessor.get(ICommandService);
5893
- const undoRedoService = accessor.get(IUndoRedoService);
5894
- const sheetDrawingService = accessor.get(ISheetDrawingService);
5895
- const sheetSkeletonService = accessor.get(SheetSkeletonService);
5896
- const { drawings } = params;
5897
- const flipH = params.flipH;
5898
- const flipV = params.flipV;
5899
- const unitIds = [];
5900
- const updateParams = [];
5901
- for (const param of drawings) {
5902
- const { unitId, subUnitId, drawingId } = param;
5903
- unitIds.push(unitId);
5904
- const drawingData = sheetDrawingService.getDrawingData(unitId, subUnitId);
5905
- const existing = drawingData === null || drawingData === void 0 ? void 0 : drawingData[drawingId];
5906
- if (!existing) continue;
5907
- const skeleton = sheetSkeletonService.getSkeleton(unitId, subUnitId);
5908
- if (!skeleton) continue;
5909
- const transform = { ...existing.transform };
5910
- if (flipH) transform.flipX = !transform.flipX;
5911
- if (flipV) transform.flipY = !transform.flipY;
5912
- const sheetTransform = transformToDrawingPosition(transform, skeleton);
5913
- const axisAlignSheetTransform = transformToAxisAlignPosition(transform, skeleton);
5914
- const updateParamItem = {
5915
- unitId,
5916
- subUnitId,
5917
- drawingType: existing.drawingType,
5918
- drawingId,
5919
- transform,
5920
- sheetTransform,
5921
- axisAlignSheetTransform
5922
- };
5923
- if (existing.drawingType === DrawingTypeEnum.DRAWING_IMAGE) {
5924
- const scene = getSceneByDrawingSearch(accessor, unitId);
5925
- if (scene) {
5926
- const drawingShapeKey = getDrawingShapeKeyByDrawingSearch({
5927
- unitId,
5928
- subUnitId,
5929
- drawingId
5930
- });
5931
- const imageShape = scene.getObject(drawingShapeKey);
5932
- if (imageShape) {
5933
- const srcRect = imageShape.srcRect;
5934
- if (srcRect) {
5935
- let newSrcRect;
5936
- const { left = 0, top = 0, right = 0, bottom = 0 } = srcRect;
5937
- if (flipH) {
5938
- const centerX = left + (right - left) / 2;
5939
- newSrcRect = {
5940
- left: centerX - (right - left) / 2,
5941
- top,
5942
- right: centerX + (right - left) / 2,
5943
- bottom
5944
- };
5945
- }
5946
- if (flipV) {
5947
- const centerY = top + (bottom - top) / 2;
5948
- newSrcRect = {
5949
- left,
5950
- top: centerY - (bottom - top) / 2,
5951
- right,
5952
- bottom: centerY + (bottom - top) / 2
5953
- };
5954
- }
5955
- if (newSrcRect) updateParamItem.srcRect = newSrcRect;
5956
- }
5957
- }
5958
- }
5959
- }
5960
- updateParams.push(updateParamItem);
5961
- }
5962
- if (updateParams.length === 0) return false;
5963
- const { unitId: opUnitId, subUnitId: opSubUnitId, undo, redo, objects } = sheetDrawingService.getBatchUpdateOp(updateParams);
5964
- const updateMutation = {
5965
- id: SetDrawingApplyMutation.id,
5966
- params: {
5967
- unitId: opUnitId,
5968
- subUnitId: opSubUnitId,
5969
- op: redo,
5970
- objects,
5971
- type: DrawingApplyType.UPDATE
5972
- }
5973
- };
5974
- const undoUpdateMutation = {
5975
- id: SetDrawingApplyMutation.id,
5976
- params: {
5977
- unitId: opUnitId,
5978
- subUnitId: opSubUnitId,
5979
- op: undo,
5980
- objects,
5981
- type: DrawingApplyType.UPDATE
5982
- }
5983
- };
5984
- if (sequenceExecute([updateMutation], commandService).result) {
5985
- undoRedoService.pushUndoRedo({
5986
- unitID: opUnitId,
5987
- undoMutations: [undoUpdateMutation, {
5988
- id: ClearSheetDrawingTransformerOperation.id,
5989
- params: unitIds
5990
- }],
5991
- redoMutations: [updateMutation, {
5992
- id: ClearSheetDrawingTransformerOperation.id,
5993
- params: unitIds
5994
- }]
5995
- });
5996
- return true;
5997
- }
5998
- return false;
5999
- }
6000
- };
6001
- function getSceneByDrawingSearch(accessor, unitId) {
6002
- const render = accessor.get(IRenderManagerService).getRenderUnitById(unitId);
6003
- if (!render) return null;
6004
- return render.scene;
6005
- }
6006
-
6007
- //#endregion
6008
- //#region src/controllers/shortcuts/drawing.shortcut.ts
6329
+ // src/controllers/shortcuts/drawing.shortcut.ts
6009
6330
  function whenSheetDrawingFocused(contextService) {
6010
6331
  return contextService.getContextValue(FOCUSING_SHEET) && !contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) && !contextService.getContextValue(FOCUSING_PANEL_EDITOR) && contextService.getContextValue(FOCUSING_COMMON_DRAWINGS) && !contextService.getContextValue(FOCUSING_SHAPE_TEXT_EDITOR);
6011
6332
  }
@@ -6060,8 +6381,7 @@ const DeleteDrawingsShortcutItem = {
6060
6381
  mac: KeyCode.BACKSPACE
6061
6382
  };
6062
6383
 
6063
- //#endregion
6064
- //#region src/controllers/ui.controller.ts
6384
+ // src/controllers/ui.controller.ts
6065
6385
  /**
6066
6386
  * Copyright 2023-present DreamNum Co., Ltd.
6067
6387
  *
@@ -6136,8 +6456,7 @@ SheetDrawingUIController = __decorate([
6136
6456
  __decorateParam(3, Inject(ISidebarService))
6137
6457
  ], SheetDrawingUIController);
6138
6458
 
6139
- //#endregion
6140
- //#region src/menu/mobile-drawing-popup-menu.controller.ts
6459
+ // src/menu/mobile-drawing-popup-menu.controller.ts
6141
6460
  const MOBILE_IMAGE_ACTIONS_DIALOG_ID = "sheet-mobile-image-actions";
6142
6461
  const MOBILE_DRAWING_LONG_PRESS_DURATION = 500;
6143
6462
  let MobileDrawingPopupMenuController = class MobileDrawingPopupMenuController extends RxDisposable {
@@ -6390,11 +6709,13 @@ let MobileDrawingPopupMenuController = class MobileDrawingPopupMenuController ex
6390
6709
  _getFloatingObjectMenuItems() {
6391
6710
  return this._menuManagerService.getFlatMenuByPositionKey(FloatingObjectToolbarPosition.SHEET).flatMap(({ item }, index) => {
6392
6711
  if (!item || item.type !== MenuItemType.BUTTON || !item.title) return [];
6712
+ const { icon, params } = item;
6393
6713
  return [{
6394
6714
  label: item.title,
6715
+ ...typeof icon === "string" ? { icon } : {},
6395
6716
  index: 100 + index,
6396
6717
  commandId: item.commandId ?? item.id,
6397
- commandParams: typeof item.params === "function" ? item.params() : item.params,
6718
+ commandParams: typeof params === "function" ? params.call(item) : params,
6398
6719
  disable: false
6399
6720
  }];
6400
6721
  });
@@ -6415,8 +6736,7 @@ MobileDrawingPopupMenuController = __decorate([
6415
6736
  __decorateParam(11, ILayoutService)
6416
6737
  ], MobileDrawingPopupMenuController);
6417
6738
 
6418
- //#endregion
6419
- //#region src/menu/mobile-schema.ts
6739
+ // src/menu/mobile-schema.ts
6420
6740
  const mobileMenuSchema = {
6421
6741
  [RibbonInsertGroup.MEDIA]: { [SHEETS_IMAGE_MENU_ID]: {
6422
6742
  order: 0,
@@ -6456,8 +6776,7 @@ const mobileMenuSchema = {
6456
6776
  } } }
6457
6777
  };
6458
6778
 
6459
- //#endregion
6460
- //#region src/menu/mobile-sheet-drawing-menu.controller.ts
6779
+ // src/menu/mobile-sheet-drawing-menu.controller.ts
6461
6780
  /**
6462
6781
  * Copyright 2023-present DreamNum Co., Ltd.
6463
6782
  *
@@ -6481,8 +6800,7 @@ let MobileSheetDrawingMenuController = class MobileSheetDrawingMenuController ex
6481
6800
  };
6482
6801
  MobileSheetDrawingMenuController = __decorate([__decorateParam(0, IMenuManagerService)], MobileSheetDrawingMenuController);
6483
6802
 
6484
- //#endregion
6485
- //#region src/services/sheet-drawing-hit-test.service.ts
6803
+ // src/services/sheet-drawing-hit-test.service.ts
6486
6804
  let SheetDrawingHitTestService = class SheetDrawingHitTestService extends Disposable {
6487
6805
  constructor(_drawingManagerService, _univerInstanceService, _renderManagerService) {
6488
6806
  super();
@@ -6592,8 +6910,7 @@ SheetDrawingHitTestService = __decorate([
6592
6910
  __decorateParam(2, IRenderManagerService)
6593
6911
  ], SheetDrawingHitTestService);
6594
6912
 
6595
- //#endregion
6596
- //#region src/mobile-plugin.ts
6913
+ // src/mobile-plugin.ts
6597
6914
  let UniverSheetsDrawingMobileUIPlugin = class UniverSheetsDrawingMobileUIPlugin extends Plugin {
6598
6915
  constructor(_config = defaultPluginConfig, _injector, _renderManagerService, _configService) {
6599
6916
  super();
@@ -6673,8 +6990,7 @@ UniverSheetsDrawingMobileUIPlugin = __decorate([
6673
6990
  __decorateParam(3, IConfigService)
6674
6991
  ], UniverSheetsDrawingMobileUIPlugin);
6675
6992
 
6676
- //#endregion
6677
- //#region src/controllers/components.controller.ts
6993
+ // src/controllers/components.controller.ts
6678
6994
  /**
6679
6995
  * Copyright 2023-present DreamNum Co., Ltd.
6680
6996
  *
@@ -6703,10 +7019,9 @@ let ComponentsController = class ComponentsController extends Disposable {
6703
7019
  };
6704
7020
  ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager))], ComponentsController);
6705
7021
 
6706
- //#endregion
6707
- //#region src/menu/drawing-popup-menu.controller.ts
7022
+ // src/menu/drawing-popup-menu.controller.ts
6708
7023
  let DrawingPopupMenuController = class DrawingPopupMenuController extends RxDisposable {
6709
- constructor(_localeService, _drawingManagerService, _canvasPopManagerService, _renderManagerService, _univerInstanceService, _messageService, _menuManagerService, _contextService, _ioService, _commandService) {
7024
+ constructor(_localeService, _drawingManagerService, _canvasPopManagerService, _renderManagerService, _univerInstanceService, _messageService, _menuManagerService, _contextService, _ioService, _commandService, _oleUI, _permissionService) {
6710
7025
  super();
6711
7026
  this._localeService = _localeService;
6712
7027
  this._drawingManagerService = _drawingManagerService;
@@ -6718,7 +7033,40 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends RxDisp
6718
7033
  this._contextService = _contextService;
6719
7034
  this._ioService = _ioService;
6720
7035
  this._commandService = _commandService;
7036
+ this._oleUI = _oleUI;
7037
+ this._permissionService = _permissionService;
6721
7038
  _defineProperty(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
7039
+ this.disposeWithMe(this._oleUI.registerHost(UniverInstanceType.UNIVER_SHEET, {
7040
+ isEditable: (drawing) => {
7041
+ var _this$_permissionServ;
7042
+ return this._drawingManagerService.getDrawingEditable() && ((_this$_permissionServ = this._permissionService.getPermissionPoint(new WorkbookEditablePermission(drawing.unitId).id)) === null || _this$_permissionServ === void 0 ? void 0 : _this$_permissionServ.value) !== false;
7043
+ },
7044
+ attach: (object, componentKey, extraProps, _drawing, direction = "top-center") => this._canvasPopManagerService.attachPopupToObject(object, {
7045
+ componentKey,
7046
+ extraProps,
7047
+ direction,
7048
+ portal: true,
7049
+ offset: direction === "top-center" ? [0, 8] : [0, 0]
7050
+ }),
7051
+ rename: (drawing, name) => this._commandService.executeCommand(SetSheetDrawingCommand.id, {
7052
+ unitId: drawing.unitId,
7053
+ drawings: [{
7054
+ ...drawing,
7055
+ oleFileName: name
7056
+ }]
7057
+ }),
7058
+ saveOnlineUnit: (drawing, online) => this._commandService.executeCommand(SetSheetDrawingCommand.id, {
7059
+ unitId: drawing.unitId,
7060
+ drawings: [{
7061
+ ...drawing,
7062
+ oleOnlineUnit: online
7063
+ }]
7064
+ }),
7065
+ remove: (drawing) => this._commandService.executeCommand(RemoveSheetDrawingCommand.id, {
7066
+ unitId: drawing.unitId,
7067
+ drawings: [drawing]
7068
+ })
7069
+ }));
6722
7070
  this._init();
6723
7071
  }
6724
7072
  _init() {
@@ -6793,7 +7141,7 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends RxDisp
6793
7141
  const object = selectedObjects.values().next().value;
6794
7142
  if (!object) return;
6795
7143
  const drawingParam = this._drawingManagerService.getDrawingOKey(object.oKey);
6796
- if (!drawingParam || drawingParam.drawingType === DrawingTypeEnum.DRAWING_SHAPE) return;
7144
+ if (!drawingParam || drawingParam.drawingType === DrawingTypeEnum.DRAWING_SHAPE || drawingParam.drawingType === DrawingTypeEnum.DRAWING_OLE) return;
6797
7145
  const { unitId, subUnitId, drawingId, drawingType } = drawingParam;
6798
7146
  const data = drawingParam.data;
6799
7147
  if (data && (data.disablePopup || data.version === 1 && typeof data.embedId === "string")) return;
@@ -6803,7 +7151,10 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends RxDisp
6803
7151
  constrainToCanvas: true,
6804
7152
  direction: this._localeService.getDirection() === "rtl" ? "left" : "horizontal",
6805
7153
  offset: [2, 0],
6806
- extraProps: { menuItems }
7154
+ extraProps: {
7155
+ menuItems,
7156
+ icon: this._canvasPopManagerService.getFeatureMenuIcon(drawingType)
7157
+ }
6807
7158
  }));
6808
7159
  }
6809
7160
  _getImageMenuItems(unitId, subUnitId, drawingId, drawingType) {
@@ -6890,11 +7241,13 @@ let DrawingPopupMenuController = class DrawingPopupMenuController extends RxDisp
6890
7241
  _getFloatingObjectMenuItems() {
6891
7242
  return this._menuManagerService.getFlatMenuByPositionKey(FloatingObjectToolbarPosition.SHEET).flatMap(({ item }, index) => {
6892
7243
  if (!item || item.type !== MenuItemType.BUTTON || !item.title) return [];
7244
+ const { icon, params } = item;
6893
7245
  return [{
6894
7246
  label: item.title,
7247
+ ...typeof icon === "string" ? { icon } : {},
6895
7248
  index: 100 + index,
6896
7249
  commandId: item.commandId ?? item.id,
6897
- commandParams: typeof item.params === "function" ? item.params() : item.params,
7250
+ commandParams: typeof params === "function" ? params.call(item) : params,
6898
7251
  disable: false
6899
7252
  }];
6900
7253
  });
@@ -6910,11 +7263,30 @@ DrawingPopupMenuController = __decorate([
6910
7263
  __decorateParam(6, IMenuManagerService),
6911
7264
  __decorateParam(7, IContextService),
6912
7265
  __decorateParam(8, IImageIoService),
6913
- __decorateParam(9, ICommandService)
7266
+ __decorateParam(9, ICommandService),
7267
+ __decorateParam(10, Inject(OleUIService)),
7268
+ __decorateParam(11, IPermissionService)
6914
7269
  ], DrawingPopupMenuController);
7270
+ function createSheetOlePreview(context) {
7271
+ return createOlePreviewViewer({
7272
+ ...context,
7273
+ setReadonly: (permissions, unitId) => {
7274
+ for (const point of [new WorkbookEditablePermission(unitId), new WorkbookRenameSheetPermission(unitId)]) {
7275
+ if (!permissions.getPermissionPoint(point.id)) permissions.addPermissionPoint(point);
7276
+ permissions.updatePermissionPoint(point.id, false);
7277
+ }
7278
+ },
7279
+ register: (viewer) => {
7280
+ viewer.registerPlugin(UniverSheetsPlugin);
7281
+ viewer.registerPlugin(UniverSheetsUIPlugin, { disableEdit: true });
7282
+ viewer.registerPlugin(UniverSheetsDrawingPlugin);
7283
+ viewer.registerPlugin(UniverSheetsDrawingUIPlugin);
7284
+ }
7285
+ });
7286
+ }
7287
+ registerOlePreviewRenderer(UniverInstanceType.UNIVER_SHEET, createSheetOlePreview);
6915
7288
 
6916
- //#endregion
6917
- //#region src/menu/sheet-drawing-menu.controller.ts
7289
+ // src/menu/sheet-drawing-menu.controller.ts
6918
7290
  /**
6919
7291
  * Copyright 2023-present DreamNum Co., Ltd.
6920
7292
  *
@@ -6938,8 +7310,7 @@ let SheetDrawingMenuController = class SheetDrawingMenuController extends Dispos
6938
7310
  };
6939
7311
  SheetDrawingMenuController = __decorate([__decorateParam(0, IMenuManagerService)], SheetDrawingMenuController);
6940
7312
 
6941
- //#endregion
6942
- //#region src/plugin.ts
7313
+ // src/plugin.ts
6943
7314
  let UniverSheetsDrawingUIPlugin = class UniverSheetsDrawingUIPlugin extends Plugin {
6944
7315
  constructor(_config = defaultPluginConfig, _injector, _renderManagerService, _configService) {
6945
7316
  super();
@@ -7018,5 +7389,4 @@ UniverSheetsDrawingUIPlugin = __decorate([
7018
7389
  __decorateParam(3, IConfigService)
7019
7390
  ], UniverSheetsDrawingUIPlugin);
7020
7391
 
7021
- //#endregion
7022
7392
  export { AddWorksheetBackgroundImageCommand, BatchSaveImagesService, DeleteDrawingsCommand, DeleteWorksheetBackgroundImageCommand, DrawingContextMenuService, EditSheetDrawingOperation, FileNamePart, GroupSheetDrawingCommand, IBatchSaveImagesService, IDrawingContextMenuService, InsertFloatImageCommand, MoveDrawingsCommand, SHEETS_DRAWING_FLOATING_HOST_DEPENDENCIES, SHEETS_IMAGE_MENU_ID, SHEET_CHART_RENDER_OBJECT_CONFIG, SHEET_FLOAT_DOM_PREFIX, SaveCellImagesCommand, SheetCanvasFloatDomManagerService, SheetDrawingAnchor, SheetDrawingHitTestService, SheetDrawingUpdateController, SheetsDrawingGroupCopyPasteController, menuSchema as SheetsDrawingUIMenuSchema, SidebarSheetDrawingOperation, UngroupSheetDrawingCommand, UniverSheetsDrawingMobileUIPlugin, UniverSheetsDrawingUIPlugin, calcSheetFloatDomPosition, registerSheetsDrawingFloatingHostCapability };