@univerjs/sheets-drawing-ui 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,2172 +1,2154 @@
1
- var en = Object.defineProperty;
2
- var tn = (i, e, n) => e in i ? en(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n;
3
- var H = (i, e, n) => tn(i, typeof e != "symbol" ? e + "" : e, n);
4
- import { CommandType as F, ICommandService as V, IUndoRedoService as ge, LocaleService as _e, IUniverInstanceService as he, RxDisposable as nn, UniverInstanceType as B, toDisposable as rn, FOCUSING_COMMON_DRAWINGS as we, OnLifecycle as ie, LifecycleStages as se, IContextService as _t, Disposable as oe, Direction as q, FOCUSING_FORMULA_EDITOR as sn, EDITOR_ACTIVATED as on, Rectangle as an, DrawingTypeEnum as Ye, DisposableCollection as cn, Tools as ne, UserManagerService as dn, IPermissionService as ln, Plugin as un, DependentOn as gn } from "@univerjs/core";
5
- import { Inject as W, Injector as nt } from "@wendellhu/redi";
6
- import { ImageCropperObject as hn, COMPONENT_IMAGE_POPUP_MENU as mn, OpenImageCropOperation as fn, ImageResetSizeOperation as pn, DrawingCommonPanel as wn, DrawingRenderService as _n, UniverDrawingUIPlugin as vn } from "@univerjs/drawing-ui";
7
- import { ISheetDrawingService as k, SetDrawingApplyMutation as E, DrawingApplyType as y, SheetDrawingAnchorType as O, UniverSheetsDrawingPlugin as Sn } from "@univerjs/sheets-drawing";
8
- import { IDrawingManagerService as z, IImageIoService as vt, ArrangeTypeEnum as Ce, DrawingTypeEnum as Ve, DRAWING_IMAGE_COUNT_LIMIT as dt, ImageUploadStatusType as ke, DRAWING_IMAGE_ALLOW_SIZE as Cn, getImageSize as In, DRAWING_IMAGE_WIDTH_LIMIT as lt, DRAWING_IMAGE_HEIGHT_LIMIT as ut, DRAWING_IMAGE_ALLOW_IMAGE_LIST as Rn, getDrawingShapeKeyByDrawingSearch as Mn, UniverDrawingPlugin as Dn } from "@univerjs/drawing";
9
- import { IRenderManagerService as K, getGroupState as bn, transformObjectOutOfGroup as En, precisionTo as Q, Rect as yn, DRAWING_OBJECT_LAYER_INDEX as On, SHEET_VIEWPORT_KEY as Pn, RENDER_CLASS_TYPE as ae } from "@univerjs/engine-render";
10
- import { SheetCanvasPopManagerService as Tn, ISheetSelectionRenderService as Ge, SheetSkeletonManagerService as re, attachRangeWithCoord as Un, getCurrentRangeDisable$ as An, SetScrollOperation as Nn, SetZoomRatioOperation as jn, SheetPrintInterceptorService as Ln, COPY_TYPE as gt, PREDEFINED_HOOK_NAME as Ie, virtualizeDiscreteRanges as Bn, ISheetClipboardService as Wn } from "@univerjs/sheets-ui";
11
- import { takeUntil as ht, Subject as mt, BehaviorSubject as $n, combineLatest as Re, map as ft, filter as Me, distinctUntilChanged as De } from "rxjs";
12
- import { ISidebarService as Vn, BuiltInUIPart as Gn, IUIPartsService as xn, IMessageService as Fn, MenuItemType as St, MenuPosition as Yn, MenuGroup as kn, getMenuHiddenObservable as Ct, KeyCode as ue, ComponentManager as Hn, IMenuService as Xn, IShortcutService as zn, CanvasFloatDomService as Kn } from "@univerjs/ui";
13
- import { useDependency as ee, connectInjector as Jn } from "@wendellhu/redi/react-bindings";
14
- import { getSheetCommandTarget as le, SheetsSelectionsService as Zn, WorkbookEditablePermission as Ze, WorksheetEditPermission as Pe, RangeProtectionPermissionEditPoint as qn, InsertRowCommand as It, InsertColCommand as Rt, RemoveRowCommand as Mt, RemoveColCommand as Dt, DeleteRangeMoveLeftCommand as bt, DeleteRangeMoveUpCommand as Et, InsertRangeMoveDownCommand as yt, InsertRangeMoveRightCommand as Ot, DeltaRowHeightCommand as qe, SetRowHeightCommand as Qe, DeltaColumnWidthCommand as Pt, SetColWidthCommand as Tt, SetRowHiddenCommand as Ut, SetSpecificRowsVisibleCommand as At, SetSpecificColsVisibleCommand as Nt, SetColHiddenCommand as jt, SetRowVisibleMutation as Qn, SetRowHiddenMutation as er, SetColVisibleMutation as tr, SetColHiddenMutation as nr, SetWorksheetRowHeightMutation as rr, SetWorksheetColWidthMutation as ir, SetWorksheetActiveOperation as sr, SheetInterceptorService as or, SetFrozenMutation as ar, WorkbookViewPermission as pt, WorksheetViewPermission as He } from "@univerjs/sheets";
15
- import L, { useEffect as rt, forwardRef as Lt, useRef as Bt, createElement as Wt, useState as et } from "react";
16
- import { MessageType as be, RadioGroup as cr, Radio as Xe } from "@univerjs/design";
17
- import Ee from "clsx";
18
- const j = {
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
+ import { CommandType, ICommandService, IUndoRedoService, LocaleService, IUniverInstanceService, useDependency, RxDisposable, UniverInstanceType, connectInjector, toDisposable, FOCUSING_COMMON_DRAWINGS, OnLifecycle, LifecycleStages, Inject, Injector, IContextService, Disposable, Direction, FOCUSING_FORMULA_EDITOR, EDITOR_ACTIVATED, Rectangle, DrawingTypeEnum as DrawingTypeEnum$1, DisposableCollection, Tools, UserManagerService, IPermissionService, Plugin, DependentOn } from "@univerjs/core";
6
+ import { ImageCropperObject, COMPONENT_IMAGE_POPUP_MENU, OpenImageCropOperation, ImageResetSizeOperation, DrawingCommonPanel, DrawingRenderService, UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
7
+ import { ISheetDrawingService, SetDrawingApplyMutation, DrawingApplyType, SheetDrawingAnchorType, UniverSheetsDrawingPlugin } from "@univerjs/sheets-drawing";
8
+ import { IDrawingManagerService, IImageIoService, ArrangeTypeEnum, DrawingTypeEnum, DRAWING_IMAGE_COUNT_LIMIT, ImageUploadStatusType, DRAWING_IMAGE_ALLOW_SIZE, getImageSize, DRAWING_IMAGE_WIDTH_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_ALLOW_IMAGE_LIST, getDrawingShapeKeyByDrawingSearch, UniverDrawingPlugin } from "@univerjs/drawing";
9
+ import { IRenderManagerService, getGroupState, transformObjectOutOfGroup, precisionTo, Rect, DRAWING_OBJECT_LAYER_INDEX, SHEET_VIEWPORT_KEY, RENDER_CLASS_TYPE } from "@univerjs/engine-render";
10
+ import { SheetCanvasPopManagerService, attachRangeWithCoord, SheetSkeletonManagerService, ISheetSelectionRenderService, getCurrentRangeDisable$, SetScrollOperation, SetZoomRatioOperation, SheetPrintInterceptorService, COPY_TYPE, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges, ISheetClipboardService } from "@univerjs/sheets-ui";
11
+ import { takeUntil, Subject, BehaviorSubject, combineLatest, map, filter, distinctUntilChanged } from "rxjs";
12
+ import { ISidebarService, BuiltInUIPart, IUIPartsService, IMessageService, MenuItemType, MenuPosition, MenuGroup, getMenuHiddenObservable, KeyCode, ComponentManager, IMenuService, IShortcutService, CanvasFloatDomService } from "@univerjs/ui";
13
+ import { getSheetCommandTarget, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, InsertRowCommand, InsertColCommand, RemoveRowCommand, RemoveColCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, DeltaRowHeightCommand, SetRowHeightCommand, DeltaColumnWidthCommand, SetColWidthCommand, SetRowHiddenCommand, SetSpecificRowsVisibleCommand, SetSpecificColsVisibleCommand, SetColHiddenCommand, SetRowVisibleMutation, SetRowHiddenMutation, SetColVisibleMutation, SetColHiddenMutation, SetWorksheetRowHeightMutation, SetWorksheetColWidthMutation, SetWorksheetActiveOperation, SheetInterceptorService, SetFrozenMutation, WorkbookViewPermission, WorksheetViewPermission } from "@univerjs/sheets";
14
+ import React, { useEffect, forwardRef, useRef, createElement, useState } from "react";
15
+ import { MessageType, RadioGroup, Radio } from "@univerjs/design";
16
+ import clsx from "clsx";
17
+ const ClearSheetDrawingTransformerOperation = {
19
18
  id: "sheet.operation.clear-drawing-transformer",
20
- type: F.MUTATION,
21
- handler: (i, e) => {
22
- const n = i.get(K);
23
- return e.forEach((t) => {
24
- var r, s;
25
- (s = (r = n.getRenderById(t)) == null ? void 0 : r.scene.getTransformer()) == null || s.debounceRefreshControls();
19
+ type: CommandType.MUTATION,
20
+ handler: /* @__PURE__ */ __name((accessor, params) => {
21
+ const renderManagerService = accessor.get(IRenderManagerService);
22
+ return params.forEach((unitId) => {
23
+ var _a10, _b;
24
+ (_b = (_a10 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.scene.getTransformer()) == null || _b.debounceRefreshControls();
26
25
  }), !0;
27
- }
28
- }, it = {
26
+ }, "handler")
27
+ }, RemoveSheetDrawingCommand = {
29
28
  id: "sheet.command.remove-sheet-image",
30
- type: F.COMMAND,
31
- handler: (i, e) => {
32
- const n = i.get(V), t = i.get(ge), r = i.get(k);
33
- if (!e) return !1;
34
- const { drawings: s } = e, o = [];
35
- s.forEach((f) => {
36
- const { unitId: m } = f;
37
- o.push(m);
29
+ type: CommandType.COMMAND,
30
+ handler: /* @__PURE__ */ __name((accessor, params) => {
31
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
32
+ if (!params) return !1;
33
+ const { drawings } = params, unitIds = [];
34
+ drawings.forEach((param) => {
35
+ const { unitId: unitId2 } = param;
36
+ unitIds.push(unitId2);
38
37
  });
39
- const a = r.getBatchRemoveOp(s), { unitId: d, subUnitId: h, undo: l, redo: c, objects: u } = a;
40
- return n.syncExecuteCommand(E.id, { unitId: d, subUnitId: h, op: c, objects: u, type: y.REMOVE }) ? (t.pushUndoRedo({
41
- unitID: d,
38
+ const jsonOp = sheetDrawingService.getBatchRemoveOp(drawings), { unitId, subUnitId, undo, redo, objects } = jsonOp;
39
+ return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.REMOVE }) ? (undoRedoService.pushUndoRedo({
40
+ unitID: unitId,
42
41
  undoMutations: [
43
- { id: E.id, params: { unitId: d, subUnitId: h, op: l, objects: u, type: y.INSERT } },
44
- { id: j.id, params: o }
42
+ { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.INSERT } },
43
+ { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
45
44
  ],
46
45
  redoMutations: [
47
- { id: E.id, params: { unitId: d, subUnitId: h, op: c, objects: u, type: y.REMOVE } },
48
- { id: j.id, params: o }
46
+ { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.REMOVE } },
47
+ { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
49
48
  ]
50
49
  }), !0) : !1;
51
- }
52
- }, $t = "COMPONENT_SHEET_DRAWING_PANEL", Vt = {
50
+ }, "handler")
51
+ }, COMPONENT_SHEET_DRAWING_PANEL = "COMPONENT_SHEET_DRAWING_PANEL", SidebarSheetDrawingOperation = {
53
52
  id: "sidebar.operation.sheet-image",
54
- type: F.COMMAND,
55
- handler: async (i, e) => {
56
- const n = i.get(Vn), t = i.get(_e), r = i.get(he), s = i.get(z);
57
- if (!le(r)) return !1;
58
- switch (e.value) {
53
+ type: CommandType.COMMAND,
54
+ handler: /* @__PURE__ */ __name(async (accessor, params) => {
55
+ const sidebarService = accessor.get(ISidebarService), localeService = accessor.get(LocaleService), univerInstanceService = accessor.get(IUniverInstanceService), drawingManagerService = accessor.get(IDrawingManagerService);
56
+ if (!getSheetCommandTarget(univerInstanceService)) return !1;
57
+ switch (params.value) {
59
58
  case "open":
60
- n.open({
61
- header: { title: t.t("sheetImage.panel.title") },
62
- children: { label: $t },
63
- onClose: () => {
64
- s.focusDrawing(null);
65
- },
59
+ sidebarService.open({
60
+ header: { title: localeService.t("sheetImage.panel.title") },
61
+ children: { label: COMPONENT_SHEET_DRAWING_PANEL },
62
+ onClose: /* @__PURE__ */ __name(() => {
63
+ drawingManagerService.focusDrawing(null);
64
+ }, "onClose"),
66
65
  width: 360
67
66
  });
68
67
  break;
69
68
  case "close":
70
69
  default:
71
- n.close();
70
+ sidebarService.close();
72
71
  break;
73
72
  }
74
73
  return !0;
75
- }
76
- }, Gt = {
74
+ }, "handler")
75
+ }, EditSheetDrawingOperation = {
77
76
  id: "sheet.operation.edit-sheet-image",
78
- type: F.OPERATION,
79
- handler: (i, e) => {
80
- const n = i.get(z), t = i.get(V);
81
- return e == null ? !1 : (n.focusDrawing([e]), t.executeCommand(Vt.id, { value: "open" }), !0);
82
- }
83
- }, dr = "univer-upload-loading", lr = "univer-upload-loading-body", ur = "univer-upload-loading-body-animation", gr = "univer-UniverCircleAnimation", hr = "univer-upload-loading-body-text", ye = {
84
- uploadLoading: dr,
85
- uploadLoadingBody: lr,
86
- uploadLoadingBodyAnimation: ur,
87
- univerCircleAnimation: gr,
88
- uploadLoadingBodyText: hr
89
- }, mr = () => {
90
- const i = ee(vt), e = ee(_e), [n, t] = L.useState(0);
91
- return rt(() => {
92
- const r = i.change$.subscribe((s) => {
93
- t(s);
77
+ type: CommandType.OPERATION,
78
+ handler: /* @__PURE__ */ __name((accessor, params) => {
79
+ const drawingManagerService = accessor.get(IDrawingManagerService), commandService = accessor.get(ICommandService);
80
+ return params == null ? !1 : (drawingManagerService.focusDrawing([params]), commandService.executeCommand(SidebarSheetDrawingOperation.id, { value: "open" }), !0);
81
+ }, "handler")
82
+ }, uploadLoading = "univer-upload-loading", uploadLoadingBody = "univer-upload-loading-body", uploadLoadingBodyAnimation = "univer-upload-loading-body-animation", univerCircleAnimation = "univer-UniverCircleAnimation", uploadLoadingBodyText = "univer-upload-loading-body-text", styles$2 = {
83
+ uploadLoading,
84
+ uploadLoadingBody,
85
+ uploadLoadingBodyAnimation,
86
+ univerCircleAnimation,
87
+ uploadLoadingBodyText
88
+ }, UploadLoading = /* @__PURE__ */ __name(() => {
89
+ const imageIoService = useDependency(IImageIoService), localeService = useDependency(LocaleService), [remain, setRemain] = React.useState(0);
90
+ return useEffect(() => {
91
+ const sub = imageIoService.change$.subscribe((count) => {
92
+ setRemain(count);
94
93
  });
95
94
  return () => {
96
- r.unsubscribe();
95
+ sub.unsubscribe();
97
96
  };
98
- }, [i]), /* @__PURE__ */ L.createElement("div", { style: { display: n > 0 ? "block" : "none" }, className: ye.uploadLoading }, /* @__PURE__ */ L.createElement("div", { className: ye.uploadLoadingBody }, /* @__PURE__ */ L.createElement("div", { className: ye.uploadLoadingBodyAnimation }), /* @__PURE__ */ L.createElement("div", { className: ye.uploadLoadingBodyText }, `${e.t("uploadLoading.loading")}: ${n}`)));
99
- };
100
- var fr = Object.defineProperty, pr = Object.getOwnPropertyDescriptor, wr = (i, e, n, t) => {
101
- for (var r = t > 1 ? void 0 : t ? pr(e, n) : e, s = i.length - 1, o; s >= 0; s--)
102
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
103
- return t && r && fr(e, n, r), r;
104
- }, te = (i, e) => (n, t) => e(n, t, i);
105
- let Te = class extends nn {
106
- constructor(e, n, t, r, s, o, a) {
97
+ }, [imageIoService]), /* @__PURE__ */ React.createElement("div", { style: { display: remain > 0 ? "block" : "none" }, className: styles$2.uploadLoading }, /* @__PURE__ */ React.createElement("div", { className: styles$2.uploadLoadingBody }, /* @__PURE__ */ React.createElement("div", { className: styles$2.uploadLoadingBodyAnimation }), /* @__PURE__ */ React.createElement("div", { className: styles$2.uploadLoadingBodyText }, `${localeService.t("uploadLoading.loading")}: ${remain}`)));
98
+ }, "UploadLoading");
99
+ var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
100
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
101
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
102
+ return kind && result && __defProp$8(target, key, result), result;
103
+ }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a;
104
+ let DrawingPopupMenuController = (_a = class extends RxDisposable {
105
+ constructor(_injector, _drawingManagerService, _canvasPopManagerService, _renderManagerService, _univerInstanceService, _contextService, _uiPartsService) {
107
106
  super();
108
- H(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
109
- this._injector = e, this._drawingManagerService = n, this._canvasPopManagerService = t, this._renderManagerService = r, this._univerInstanceService = s, this._contextService = o, this._uiPartsService = a, this._init();
107
+ __publicField(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
108
+ this._injector = _injector, this._drawingManagerService = _drawingManagerService, this._canvasPopManagerService = _canvasPopManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._contextService = _contextService, this._uiPartsService = _uiPartsService, this._init();
110
109
  }
111
110
  _init() {
112
- this._univerInstanceService.getCurrentTypeOfUnit$(B.UNIVER_SHEET).pipe(ht(this.dispose$)).subscribe((e) => this._create(e)), this._univerInstanceService.getTypeOfUnitDisposed$(B.UNIVER_SHEET).pipe(ht(this.dispose$)).subscribe((e) => this._dispose(e)), this._univerInstanceService.getAllUnitsForType(B.UNIVER_SHEET).forEach((e) => this._create(e)), this._uiPartsService.registerComponent(Gn.CONTENT, () => Jn(mr, this._injector));
111
+ this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._create(workbook)), this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._dispose(workbook)), this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => this._create(workbook)), this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(UploadLoading, this._injector));
113
112
  }
114
- _dispose(e) {
115
- const n = e.getUnitId();
116
- this._renderManagerService.removeRender(n);
113
+ _dispose(workbook) {
114
+ const unitId = workbook.getUnitId();
115
+ this._renderManagerService.removeRender(unitId);
117
116
  }
118
- _create(e) {
119
- if (!e)
117
+ _create(workbook) {
118
+ if (!workbook)
120
119
  return;
121
- const n = e.getUnitId();
122
- this._renderManagerService.has(n) && !this._initImagePopupMenu.has(n) && (this._popupMenuListener(n), this._initImagePopupMenu.add(n));
120
+ const unitId = workbook.getUnitId();
121
+ this._renderManagerService.has(unitId) && !this._initImagePopupMenu.has(unitId) && (this._popupMenuListener(unitId), this._initImagePopupMenu.add(unitId));
123
122
  }
124
- _hasCropObject(e) {
125
- const n = e.getAllObjects();
126
- for (const t of n)
127
- if (t instanceof hn)
123
+ _hasCropObject(scene) {
124
+ const objects = scene.getAllObjects();
125
+ for (const object of objects)
126
+ if (object instanceof ImageCropperObject)
128
127
  return !0;
129
128
  return !1;
130
129
  }
131
- _popupMenuListener(e) {
132
- var s;
133
- const n = (s = this._renderManagerService.getRenderById(e)) == null ? void 0 : s.scene;
134
- if (!n)
130
+ _popupMenuListener(unitId) {
131
+ var _a10;
132
+ const scene = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.scene;
133
+ if (!scene)
135
134
  return;
136
- const t = n.getTransformerByCreate();
137
- if (!t)
135
+ const transformer = scene.getTransformerByCreate();
136
+ if (!transformer)
138
137
  return;
139
- let r;
138
+ let singletonPopupDisposer;
140
139
  this.disposeWithMe(
141
- rn(
142
- t.createControl$.subscribe(() => {
143
- if (this._contextService.setContextValue(we, !0), this._hasCropObject(n))
140
+ toDisposable(
141
+ transformer.createControl$.subscribe(() => {
142
+ if (this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !0), this._hasCropObject(scene))
144
143
  return;
145
- const o = t.getSelectedObjectMap();
146
- if (o.size > 1) {
147
- r == null || r.dispose();
144
+ const selectedObjects = transformer.getSelectedObjectMap();
145
+ if (selectedObjects.size > 1) {
146
+ singletonPopupDisposer == null || singletonPopupDisposer.dispose();
148
147
  return;
149
148
  }
150
- const a = o.values().next().value;
151
- if (!a)
149
+ const object = selectedObjects.values().next().value;
150
+ if (!object)
152
151
  return;
153
- const d = a.oKey, h = this._drawingManagerService.getDrawingOKey(d);
154
- if (!h)
152
+ const oKey = object.oKey, drawingParam = this._drawingManagerService.getDrawingOKey(oKey);
153
+ if (!drawingParam)
155
154
  return;
156
- const { unitId: l, subUnitId: c, drawingId: u } = h;
157
- r == null || r.dispose(), r = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(a, {
158
- componentKey: mn,
155
+ const { unitId: unitId2, subUnitId, drawingId } = drawingParam;
156
+ singletonPopupDisposer == null || singletonPopupDisposer.dispose(), singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
157
+ componentKey: COMPONENT_IMAGE_POPUP_MENU,
159
158
  direction: "horizontal",
160
159
  offset: [2, 0],
161
160
  extraProps: {
162
- menuItems: this._getImageMenuItems(l, c, u)
161
+ menuItems: this._getImageMenuItems(unitId2, subUnitId, drawingId)
163
162
  }
164
163
  })), this._drawingManagerService.focusDrawing([{
165
- unitId: l,
166
- subUnitId: c,
167
- drawingId: u
164
+ unitId: unitId2,
165
+ subUnitId,
166
+ drawingId
168
167
  }]);
169
168
  })
170
169
  )
171
170
  ), this.disposeWithMe(
172
- t.clearControl$.subscribe(() => {
173
- r == null || r.dispose(), this._contextService.setContextValue(we, !1), this._drawingManagerService.focusDrawing(null);
171
+ transformer.clearControl$.subscribe(() => {
172
+ singletonPopupDisposer == null || singletonPopupDisposer.dispose(), this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1), this._drawingManagerService.focusDrawing(null);
174
173
  })
175
174
  ), this.disposeWithMe(
176
- t.changing$.subscribe(() => {
177
- r == null || r.dispose();
175
+ transformer.changing$.subscribe(() => {
176
+ singletonPopupDisposer == null || singletonPopupDisposer.dispose();
178
177
  })
179
178
  );
180
179
  }
181
- _getImageMenuItems(e, n, t) {
180
+ _getImageMenuItems(unitId, subUnitId, drawingId) {
182
181
  return [
183
182
  {
184
183
  label: "image-popup.edit",
185
184
  index: 0,
186
- commandId: Gt.id,
187
- commandParams: { unitId: e, subUnitId: n, drawingId: t },
185
+ commandId: EditSheetDrawingOperation.id,
186
+ commandParams: { unitId, subUnitId, drawingId },
188
187
  disable: !1
189
188
  },
190
189
  {
191
190
  label: "image-popup.delete",
192
191
  index: 1,
193
- commandId: it.id,
194
- commandParams: { unitId: e, drawings: [{ unitId: e, subUnitId: n, drawingId: t }] },
192
+ commandId: RemoveSheetDrawingCommand.id,
193
+ commandParams: { unitId, drawings: [{ unitId, subUnitId, drawingId }] },
195
194
  disable: !1
196
195
  },
197
196
  {
198
197
  label: "image-popup.crop",
199
198
  index: 2,
200
- commandId: fn.id,
201
- commandParams: { unitId: e, subUnitId: n, drawingId: t },
199
+ commandId: OpenImageCropOperation.id,
200
+ commandParams: { unitId, subUnitId, drawingId },
202
201
  disable: !1
203
202
  },
204
203
  {
205
204
  label: "image-popup.reset",
206
205
  index: 3,
207
- commandId: pn.id,
208
- commandParams: [{ unitId: e, subUnitId: n, drawingId: t }],
206
+ commandId: ImageResetSizeOperation.id,
207
+ commandParams: [{ unitId, subUnitId, drawingId }],
209
208
  disable: !1
210
209
  }
211
210
  ];
212
211
  }
213
- };
214
- Te = wr([
215
- ie(se.Steady, Te),
216
- te(0, W(nt)),
217
- te(1, z),
218
- te(2, W(Tn)),
219
- te(3, K),
220
- te(4, he),
221
- te(5, _t),
222
- te(6, W(xn))
223
- ], Te);
224
- const xe = {
212
+ }, __name(_a, "DrawingPopupMenuController"), _a);
213
+ DrawingPopupMenuController = __decorateClass$8([
214
+ OnLifecycle(LifecycleStages.Steady, DrawingPopupMenuController),
215
+ __decorateParam$8(0, Inject(Injector)),
216
+ __decorateParam$8(1, IDrawingManagerService),
217
+ __decorateParam$8(2, Inject(SheetCanvasPopManagerService)),
218
+ __decorateParam$8(3, IRenderManagerService),
219
+ __decorateParam$8(4, IUniverInstanceService),
220
+ __decorateParam$8(5, IContextService),
221
+ __decorateParam$8(6, Inject(IUIPartsService))
222
+ ], DrawingPopupMenuController);
223
+ const InsertFloatImageOperation = {
225
224
  id: "sheet.operation.insert-float-image",
226
- type: F.OPERATION,
227
- handler: (i, e) => !0
228
- }, Be = {
225
+ type: CommandType.OPERATION,
226
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
227
+ }, InsertCellImageOperation = {
229
228
  id: "sheet.operation.insert-cell-image",
230
- type: F.OPERATION,
231
- handler: (i, e) => !0
232
- }, st = {
229
+ type: CommandType.OPERATION,
230
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
231
+ }, InsertSheetDrawingCommand = {
233
232
  id: "sheet.command.insert-sheet-image",
234
- type: F.COMMAND,
235
- handler: (i, e) => {
236
- const n = i.get(V), t = i.get(ge), r = i.get(k);
237
- if (!e) return !1;
238
- const s = e.drawings, o = s.map((f) => f.unitId), a = r.getBatchAddOp(s), { unitId: d, subUnitId: h, undo: l, redo: c, objects: u } = a;
239
- return n.syncExecuteCommand(E.id, { op: c, unitId: d, subUnitId: h, objects: u, type: y.INSERT }) ? (t.pushUndoRedo({
240
- unitID: d,
233
+ type: CommandType.COMMAND,
234
+ handler: /* @__PURE__ */ __name((accessor, params) => {
235
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
236
+ if (!params) return !1;
237
+ const drawings = params.drawings, unitIds = drawings.map((param) => param.unitId), jsonOp = sheetDrawingService.getBatchAddOp(drawings), { unitId, subUnitId, undo, redo, objects } = jsonOp;
238
+ return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT }) ? (undoRedoService.pushUndoRedo({
239
+ unitID: unitId,
241
240
  undoMutations: [
242
- { id: E.id, params: { op: l, unitId: d, subUnitId: h, objects: u, type: y.REMOVE } },
243
- { id: j.id, params: o }
241
+ { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.REMOVE } },
242
+ { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
244
243
  ],
245
244
  redoMutations: [
246
- { id: E.id, params: { op: c, unitId: d, subUnitId: h, objects: u, type: y.INSERT } },
247
- { id: j.id, params: o }
245
+ { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT } },
246
+ { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
248
247
  ]
249
248
  }), !0) : !1;
250
- }
251
- }, Fe = {
249
+ }, "handler")
250
+ }, SetSheetDrawingCommand = {
252
251
  id: "sheet.command.set-sheet-image",
253
- type: F.COMMAND,
254
- handler: (i, e) => {
255
- const n = i.get(V), t = i.get(ge), r = i.get(k);
256
- if (!e) return !1;
257
- const { drawings: s } = e, o = r.getBatchUpdateOp(s), { unitId: a, subUnitId: d, undo: h, redo: l, objects: c } = o;
258
- return n.syncExecuteCommand(E.id, { unitId: a, subUnitId: d, op: l, objects: c, type: y.UPDATE }) ? (t.pushUndoRedo({
259
- unitID: a,
252
+ type: CommandType.COMMAND,
253
+ handler: /* @__PURE__ */ __name((accessor, params) => {
254
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
255
+ if (!params) return !1;
256
+ const { drawings } = params, jsonOp = sheetDrawingService.getBatchUpdateOp(drawings), { unitId, subUnitId, undo, redo, objects } = jsonOp;
257
+ return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE }) ? (undoRedoService.pushUndoRedo({
258
+ unitID: unitId,
260
259
  undoMutations: [
261
- { id: E.id, params: { unitId: a, subUnitId: d, op: h, objects: c, type: y.UPDATE } },
262
- { id: j.id, params: [a] }
260
+ { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } },
261
+ { id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
263
262
  ],
264
263
  redoMutations: [
265
- { id: E.id, params: { unitId: a, subUnitId: d, op: l, objects: c, type: y.UPDATE } },
266
- { id: j.id, params: [a] }
264
+ { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } },
265
+ { id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
267
266
  ]
268
267
  }), !0) : !1;
269
- }
270
- }, xt = {
268
+ }, "handler")
269
+ }, SetDrawingArrangeCommand = {
271
270
  id: "sheet.command.set-drawing-arrange",
272
- type: F.COMMAND,
273
- handler: (i, e) => {
274
- const n = i.get(V), t = i.get(ge);
275
- if (!e) return !1;
276
- const r = i.get(k), { unitId: s, subUnitId: o, drawingIds: a, arrangeType: d } = e, h = { unitId: s, subUnitId: o, drawingIds: a };
277
- let l;
278
- if (d === Ce.forward ? l = r.getForwardDrawingsOp(h) : d === Ce.backward ? l = r.getBackwardDrawingOp(h) : d === Ce.front ? l = r.getFrontDrawingsOp(h) : d === Ce.back && (l = r.getBackDrawingsOp(h)), l == null)
271
+ type: CommandType.COMMAND,
272
+ handler: /* @__PURE__ */ __name((accessor, params) => {
273
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService);
274
+ if (!params) return !1;
275
+ const sheetDrawingService = accessor.get(ISheetDrawingService), { unitId, subUnitId, drawingIds, arrangeType } = params, drawingOrderMapParam = { unitId, subUnitId, drawingIds };
276
+ let jsonOp;
277
+ if (arrangeType === ArrangeTypeEnum.forward ? jsonOp = sheetDrawingService.getForwardDrawingsOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.backward ? jsonOp = sheetDrawingService.getBackwardDrawingOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.front ? jsonOp = sheetDrawingService.getFrontDrawingsOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.back && (jsonOp = sheetDrawingService.getBackDrawingsOp(drawingOrderMapParam)), jsonOp == null)
279
278
  return !1;
280
- const { objects: c, redo: u, undo: g } = l;
281
- return n.syncExecuteCommand(E.id, { op: u, unitId: s, subUnitId: o, objects: c, type: y.ARRANGE }) ? (t.pushUndoRedo({
282
- unitID: s,
279
+ const { objects, redo, undo } = jsonOp;
280
+ return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.ARRANGE }) ? (undoRedoService.pushUndoRedo({
281
+ unitID: unitId,
283
282
  undoMutations: [
284
- { id: E.id, params: { op: g, unitId: s, subUnitId: o, objects: c, type: y.ARRANGE } }
283
+ { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.ARRANGE } }
285
284
  ],
286
285
  redoMutations: [
287
- { id: E.id, params: { op: u, unitId: s, subUnitId: o, objects: c, type: y.ARRANGE } }
286
+ { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.ARRANGE } }
288
287
  ]
289
288
  }), !0) : !1;
290
- }
289
+ }, "handler")
291
290
  };
292
- function _r(i) {
293
- const e = [];
294
- return i.forEach((n) => {
295
- const { parent: t, children: r } = n, { unitId: s, subUnitId: o, drawingId: a } = t, d = bn(0, 0, r.map((c) => c.transform || {})), h = r.map((c) => {
296
- const u = c.transform || { left: 0, top: 0 }, { unitId: g, subUnitId: f, drawingId: m } = c;
291
+ function ungroupToGroup(ungroupParams) {
292
+ const newGroupParams = [];
293
+ return ungroupParams.forEach((ungroupParam) => {
294
+ const { parent, children } = ungroupParam, { unitId, subUnitId, drawingId: groupId } = parent, groupTransform = getGroupState(0, 0, children.map((o) => o.transform || {})), newChildren = children.map((drawing) => {
295
+ const transform = drawing.transform || { left: 0, top: 0 }, { unitId: unitId2, subUnitId: subUnitId2, drawingId } = drawing;
297
296
  return {
298
- unitId: g,
299
- subUnitId: f,
300
- drawingId: m,
297
+ unitId: unitId2,
298
+ subUnitId: subUnitId2,
299
+ drawingId,
301
300
  transform: {
302
- ...u,
303
- left: u.left - d.left,
304
- top: u.top - d.top
301
+ ...transform,
302
+ left: transform.left - groupTransform.left,
303
+ top: transform.top - groupTransform.top
305
304
  },
306
- groupId: a
305
+ groupId
307
306
  };
308
- }), l = {
309
- unitId: s,
310
- subUnitId: o,
311
- drawingId: a,
312
- drawingType: Ve.DRAWING_GROUP,
313
- transform: d
307
+ }), groupParam = {
308
+ unitId,
309
+ subUnitId,
310
+ drawingId: groupId,
311
+ drawingType: DrawingTypeEnum.DRAWING_GROUP,
312
+ transform: groupTransform
314
313
  };
315
- e.push({
316
- parent: l,
317
- children: h
314
+ newGroupParams.push({
315
+ parent: groupParam,
316
+ children: newChildren
318
317
  });
319
- }), e;
318
+ }), newGroupParams;
320
319
  }
321
- function vr(i) {
322
- const e = [];
323
- return i.forEach((n) => {
324
- const { parent: t, children: r } = n, { unitId: s, subUnitId: o, drawingId: a, transform: d = { width: 0, height: 0 } } = t;
325
- if (d == null)
320
+ __name(ungroupToGroup, "ungroupToGroup");
321
+ function groupToUngroup(groupParams) {
322
+ const newGroupParams = [];
323
+ return groupParams.forEach((groupParam) => {
324
+ const { parent, children } = groupParam, { unitId, subUnitId, drawingId: groupId, transform: groupTransform = { width: 0, height: 0 } } = parent;
325
+ if (groupTransform == null)
326
326
  return;
327
- const h = r.map((c) => {
328
- const { transform: u } = c, { unitId: g, subUnitId: f, drawingId: m } = c, p = En(u || {}, d, d.width || 0, d.height || 0);
327
+ const newChildren = children.map((object) => {
328
+ const { transform } = object, { unitId: unitId2, subUnitId: subUnitId2, drawingId } = object, newTransform = transformObjectOutOfGroup(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0);
329
329
  return {
330
- unitId: g,
331
- subUnitId: f,
332
- drawingId: m,
333
- transform: p,
330
+ unitId: unitId2,
331
+ subUnitId: subUnitId2,
332
+ drawingId,
333
+ transform: newTransform,
334
334
  groupId: void 0
335
335
  };
336
- }), l = {
337
- unitId: s,
338
- subUnitId: o,
339
- drawingId: a,
340
- drawingType: Ve.DRAWING_GROUP,
336
+ }), ungroupParam = {
337
+ unitId,
338
+ subUnitId,
339
+ drawingId: groupId,
340
+ drawingType: DrawingTypeEnum.DRAWING_GROUP,
341
341
  transform: {
342
342
  left: 0,
343
343
  top: 0
344
344
  }
345
345
  };
346
- e.push({
347
- parent: l,
348
- children: h
346
+ newGroupParams.push({
347
+ parent: ungroupParam,
348
+ children: newChildren
349
349
  });
350
- }), e;
350
+ }), newGroupParams;
351
351
  }
352
- const Ft = {
352
+ __name(groupToUngroup, "groupToUngroup");
353
+ const GroupSheetDrawingCommand = {
353
354
  id: "sheet.command.group-sheet-image",
354
- type: F.COMMAND,
355
- handler: (i, e) => {
356
- const n = i.get(V), t = i.get(ge), r = i.get(k);
357
- if (!e) return !1;
358
- const s = [];
359
- e.forEach(({ parent: g, children: f }) => {
360
- s.push(g.unitId), f.forEach((m) => {
361
- s.push(m.unitId);
355
+ type: CommandType.COMMAND,
356
+ handler: /* @__PURE__ */ __name((accessor, params) => {
357
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
358
+ if (!params) return !1;
359
+ const unitIds = [];
360
+ params.forEach(({ parent, children }) => {
361
+ unitIds.push(parent.unitId), children.forEach((child) => {
362
+ unitIds.push(child.unitId);
362
363
  });
363
364
  });
364
- const o = r.getGroupDrawingOp(e), { unitId: a, subUnitId: d, undo: h, redo: l, objects: c } = o;
365
- return n.syncExecuteCommand(E.id, { op: l, unitId: a, subUnitId: d, objects: c, type: y.GROUP }) ? (t.pushUndoRedo({
366
- unitID: a,
365
+ const jsonOp = sheetDrawingService.getGroupDrawingOp(params), { unitId, subUnitId, undo, redo, objects } = jsonOp;
366
+ return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.GROUP }) ? (undoRedoService.pushUndoRedo({
367
+ unitID: unitId,
367
368
  undoMutations: [
368
- { id: E.id, params: { op: h, unitId: a, subUnitId: d, objects: vr(c), type: y.UNGROUP } },
369
- { id: j.id, params: s }
369
+ { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects: groupToUngroup(objects), type: DrawingApplyType.UNGROUP } },
370
+ { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
370
371
  ],
371
372
  redoMutations: [
372
- { id: E.id, params: { op: l, unitId: a, subUnitId: d, objects: c, type: y.GROUP } },
373
- { id: j.id, params: s }
373
+ { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.GROUP } },
374
+ { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
374
375
  ]
375
376
  }), !0) : !1;
376
- }
377
- }, Yt = {
377
+ }, "handler")
378
+ }, UngroupSheetDrawingCommand = {
378
379
  id: "sheet.command.ungroup-sheet-image",
379
- type: F.COMMAND,
380
- handler: (i, e) => {
381
- const n = i.get(V), t = i.get(ge), r = i.get(k);
382
- if (!e) return !1;
383
- const s = [];
384
- e.forEach(({ parent: g, children: f }) => {
385
- s.push(g.unitId), f.forEach((m) => {
386
- s.push(m.unitId);
380
+ type: CommandType.COMMAND,
381
+ handler: /* @__PURE__ */ __name((accessor, params) => {
382
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
383
+ if (!params) return !1;
384
+ const unitIds = [];
385
+ params.forEach(({ parent, children }) => {
386
+ unitIds.push(parent.unitId), children.forEach((child) => {
387
+ unitIds.push(child.unitId);
387
388
  });
388
389
  });
389
- const o = r.getUngroupDrawingOp(e), { unitId: a, subUnitId: d, undo: h, redo: l, objects: c } = o;
390
- return n.syncExecuteCommand(E.id, { op: l, unitId: a, subUnitId: d, objects: c, type: y.UNGROUP }) ? (t.pushUndoRedo({
391
- unitID: a,
390
+ const jsonOp = sheetDrawingService.getUngroupDrawingOp(params), { unitId, subUnitId, undo, redo, objects } = jsonOp;
391
+ return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.UNGROUP }) ? (undoRedoService.pushUndoRedo({
392
+ unitID: unitId,
392
393
  undoMutations: [
393
- { id: E.id, params: { op: h, unitId: a, subUnitId: d, objects: _r(c), type: y.GROUP } },
394
- { id: j.id, params: s }
394
+ { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects: ungroupToGroup(objects), type: DrawingApplyType.GROUP } },
395
+ { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
395
396
  ],
396
397
  redoMutations: [
397
- { id: E.id, params: { op: l, unitId: a, subUnitId: d, objects: c, type: y.UNGROUP } },
398
- { id: j.id, params: s }
398
+ { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.UNGROUP } },
399
+ { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
399
400
  ]
400
401
  }), !0) : !1;
401
- }
402
+ }, "handler")
402
403
  };
403
- function $(i, e, n) {
404
- const { from: t, to: r, flipY: s = !1, flipX: o = !1, angle: a = 0, skewX: d = 0, skewY: h = 0 } = i, { column: l, columnOffset: c, row: u, rowOffset: g } = t, { column: f, columnOffset: m, row: p, rowOffset: S } = r, C = n.attachRangeWithCoord({
405
- startColumn: l,
406
- endColumn: l,
407
- startRow: u,
408
- endRow: u
404
+ function drawingPositionToTransform(position, selectionRenderService, sheetSkeletonManagerService) {
405
+ const { from, to, flipY = !1, flipX = !1, angle = 0, skewX = 0, skewY = 0 } = position, { column: fromColumn, columnOffset: fromColumnOffset, row: fromRow, rowOffset: fromRowOffset } = from, { column: toColumn, columnOffset: toColumnOffset, row: toRow, rowOffset: toRowOffset } = to, startSelectionCell = sheetSkeletonManagerService.attachRangeWithCoord({
406
+ startColumn: fromColumn,
407
+ endColumn: fromColumn,
408
+ startRow: fromRow,
409
+ endRow: fromRow
409
410
  });
410
- if (C == null)
411
+ if (startSelectionCell == null)
411
412
  return;
412
- const v = n.attachRangeWithCoord({
413
- startColumn: f,
414
- endColumn: f,
415
- startRow: p,
416
- endRow: p
413
+ const endSelectionCell = sheetSkeletonManagerService.attachRangeWithCoord({
414
+ startColumn: toColumn,
415
+ endColumn: toColumn,
416
+ startRow: toRow,
417
+ endRow: toRow
417
418
  });
418
- if (v == null)
419
+ if (endSelectionCell == null)
419
420
  return;
420
- const { startX: R, startY: _ } = C, { startX: b, startY: w } = v;
421
- let P = Q(R + c, 1), D = Q(_ + g, 1), T = Q(b + m - P, 1), U = Q(w + S - D, 1);
422
- C.startX === v.endX && (T = 0), C.startY === v.endY && (U = 0);
423
- const M = n.getCurrentSkeleton(), I = M.rowHeaderWidth + M.columnTotalWidth, A = M.columnHeaderHeight + M.rowTotalHeight;
424
- return P + T > I && (P = I - T), D + U > A && (D = A - U), {
425
- flipY: s,
426
- flipX: o,
427
- angle: a,
428
- skewX: d,
429
- skewY: h,
430
- left: P,
431
- top: D,
432
- width: T,
433
- height: U
421
+ const { startX: startSelectionX, startY: startSelectionY } = startSelectionCell, { startX: endSelectionX, startY: endSelectionY } = endSelectionCell;
422
+ let left = precisionTo(startSelectionX + fromColumnOffset, 1), top = precisionTo(startSelectionY + fromRowOffset, 1), width = precisionTo(endSelectionX + toColumnOffset - left, 1), height = precisionTo(endSelectionY + toRowOffset - top, 1);
423
+ startSelectionCell.startX === endSelectionCell.endX && (width = 0), startSelectionCell.startY === endSelectionCell.endY && (height = 0);
424
+ const skeleton = sheetSkeletonManagerService.getCurrentSkeleton(), sheetWidth = skeleton.rowHeaderWidth + skeleton.columnTotalWidth, sheetHeight = skeleton.columnHeaderHeight + skeleton.rowTotalHeight;
425
+ return left + width > sheetWidth && (left = sheetWidth - width), top + height > sheetHeight && (top = sheetHeight - height), {
426
+ flipY,
427
+ flipX,
428
+ angle,
429
+ skewX,
430
+ skewY,
431
+ left,
432
+ top,
433
+ width,
434
+ height
434
435
  };
435
436
  }
436
- function N(i, e) {
437
- const { left: n = 0, top: t = 0, width: r = 0, height: s = 0, flipY: o = !1, flipX: a = !1, angle: d = 0, skewX: h = 0, skewY: l = 0 } = i, c = e.getSelectionCellByPosition(n, t);
438
- if (c == null)
437
+ __name(drawingPositionToTransform, "drawingPositionToTransform");
438
+ function transformToDrawingPosition(transform, selectionRenderService) {
439
+ const { left = 0, top = 0, width = 0, height = 0, flipY = !1, flipX = !1, angle = 0, skewX = 0, skewY = 0 } = transform, startSelectionCell = selectionRenderService.getSelectionCellByPosition(left, top);
440
+ if (startSelectionCell == null)
439
441
  return;
440
- const u = {
441
- column: c.actualColumn,
442
- columnOffset: Q(n - c.startX, 1),
443
- row: c.actualRow,
444
- rowOffset: Q(t - c.startY, 1)
445
- }, g = e.getSelectionCellByPosition(n + r, t + s);
446
- if (g == null)
442
+ const from = {
443
+ column: startSelectionCell.actualColumn,
444
+ columnOffset: precisionTo(left - startSelectionCell.startX, 1),
445
+ row: startSelectionCell.actualRow,
446
+ rowOffset: precisionTo(top - startSelectionCell.startY, 1)
447
+ }, endSelectionCell = selectionRenderService.getSelectionCellByPosition(left + width, top + height);
448
+ if (endSelectionCell == null)
447
449
  return;
448
- const f = {
449
- column: g.actualColumn,
450
- columnOffset: Q(n + r - g.startX, 1),
451
- row: g.actualRow,
452
- rowOffset: Q(t + s - g.startY, 1)
450
+ const to = {
451
+ column: endSelectionCell.actualColumn,
452
+ columnOffset: precisionTo(left + width - endSelectionCell.startX, 1),
453
+ row: endSelectionCell.actualRow,
454
+ rowOffset: precisionTo(top + height - endSelectionCell.startY, 1)
453
455
  };
454
456
  return {
455
- flipY: o,
456
- flipX: a,
457
- angle: d,
458
- skewX: h,
459
- skewY: l,
460
- from: u,
461
- to: f
457
+ flipY,
458
+ flipX,
459
+ angle,
460
+ skewX,
461
+ skewY,
462
+ from,
463
+ to
462
464
  };
463
465
  }
464
- var Sr = Object.defineProperty, Cr = Object.getOwnPropertyDescriptor, Ir = (i, e, n, t) => {
465
- for (var r = t > 1 ? void 0 : t ? Cr(e, n) : e, s = i.length - 1, o; s >= 0; s--)
466
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
467
- return t && r && Sr(e, n, r), r;
468
- }, X = (i, e) => (n, t) => e(n, t, i);
469
- let Ue = class extends oe {
470
- constructor(i, e, n, t, r, s, o, a, d, h) {
471
- super(), this._commandService = i, this._univerInstanceService = e, this._selectionManagerService = n, this._imageIoService = t, this._sheetDrawingService = r, this._drawingManagerService = s, this._contextService = o, this._messageService = a, this._localeService = d, this._renderManagerService = h, this._init();
472
- }
473
- // TODO@wzhudev: selection render service would be a render unit, we we cannot
474
- // easily access it here.
475
- get _selectionRenderService() {
476
- return this._renderManagerService.getRenderById(
477
- this._univerInstanceService.getCurrentUnitForType(B.UNIVER_SHEET).getUnitId()
478
- ).with(Ge);
479
- }
480
- get _skeletonManagerService() {
481
- return this._renderManagerService.getRenderById(
482
- this._univerInstanceService.getCurrentUnitForType(B.UNIVER_SHEET).getUnitId()
483
- ).with(re);
484
- }
485
- _init() {
486
- this._initCommandListeners(), this._updateImageListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener(), this._drawingAddListener();
466
+ __name(transformToDrawingPosition, "transformToDrawingPosition");
467
+ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
468
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
469
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
470
+ return kind && result && __defProp$7(target, key, result), result;
471
+ }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a2;
472
+ let SheetDrawingUpdateController = (_a2 = class extends Disposable {
473
+ constructor(_context, _skeletonManagerService, _commandService, _selectionRenderService, _imageIoService, _sheetDrawingService, _drawingManagerService, _contextService, _messageService, _localeService, selectionManagerService) {
474
+ super();
475
+ __publicField(this, "_workbookSelections");
476
+ this._context = _context, this._skeletonManagerService = _skeletonManagerService, this._commandService = _commandService, this._selectionRenderService = _selectionRenderService, this._imageIoService = _imageIoService, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._contextService = _contextService, this._messageService = _messageService, this._localeService = _localeService, this._workbookSelections = selectionManagerService.getWorkbookSelections(this._context.unitId), this._initCommandListeners(), this._updateImageListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener(), this._drawingAddListener();
487
477
  }
488
478
  /**
489
479
  * Upload image to cell or float image
490
480
  */
491
481
  _initCommandListeners() {
492
482
  this.disposeWithMe(
493
- this._commandService.onCommandExecuted(async (i) => {
494
- if (i.id === Be.id || i.id === xe.id) {
495
- const e = i.params;
496
- if (e.files == null)
483
+ this._commandService.onCommandExecuted(async (command) => {
484
+ if (command.id === InsertCellImageOperation.id || command.id === InsertFloatImageOperation.id) {
485
+ const params = command.params;
486
+ if (params.files == null)
497
487
  return;
498
- const n = e.files.length;
499
- if (n > dt) {
488
+ const fileLength = params.files.length;
489
+ if (fileLength > DRAWING_IMAGE_COUNT_LIMIT) {
500
490
  this._messageService.show({
501
- type: be.Error,
502
- content: this._localeService.t("update-status.exceedMaxCount", String(dt))
491
+ type: MessageType.Error,
492
+ content: this._localeService.t("update-status.exceedMaxCount", String(DRAWING_IMAGE_COUNT_LIMIT))
503
493
  });
504
494
  return;
505
495
  }
506
- this._imageIoService.setWaitCount(n), i.id === Be.id ? e.files.forEach(async (t) => {
507
- await this._insertCellImage(t);
508
- }) : e.files.forEach(async (t) => {
509
- await this._insertFloatImage(t);
496
+ this._imageIoService.setWaitCount(fileLength), command.id === InsertCellImageOperation.id ? params.files.forEach(async (file) => {
497
+ await this._insertCellImage(file);
498
+ }) : params.files.forEach(async (file) => {
499
+ await this._insertFloatImage(file);
510
500
  });
511
501
  }
512
502
  })
513
503
  );
514
504
  }
515
- async _insertCellImage(i) {
505
+ async _insertCellImage(file) {
516
506
  }
517
- async _insertFloatImage(i) {
518
- let e;
507
+ async _insertFloatImage(file) {
508
+ let imageParam;
519
509
  try {
520
- e = await this._imageIoService.saveImage(i);
521
- } catch (C) {
522
- const v = C.message;
523
- v === ke.ERROR_EXCEED_SIZE ? this._messageService.show({
524
- type: be.Error,
525
- content: this._localeService.t("update-status.exceedMaxSize", String(Cn / (1024 * 1024)))
526
- }) : v === ke.ERROR_IMAGE_TYPE ? this._messageService.show({
527
- type: be.Error,
510
+ imageParam = await this._imageIoService.saveImage(file);
511
+ } catch (error) {
512
+ const type = error.message;
513
+ type === ImageUploadStatusType.ERROR_EXCEED_SIZE ? this._messageService.show({
514
+ type: MessageType.Error,
515
+ content: this._localeService.t("update-status.exceedMaxSize", String(DRAWING_IMAGE_ALLOW_SIZE / (1024 * 1024)))
516
+ }) : type === ImageUploadStatusType.ERROR_IMAGE_TYPE ? this._messageService.show({
517
+ type: MessageType.Error,
528
518
  content: this._localeService.t("update-status.invalidImageType")
529
- }) : v === ke.ERROR_IMAGE && this._messageService.show({
530
- type: be.Error,
519
+ }) : type === ImageUploadStatusType.ERROR_IMAGE && this._messageService.show({
520
+ type: MessageType.Error,
531
521
  content: this._localeService.t("update-status.invalidImage")
532
522
  });
533
523
  }
534
- if (e == null)
535
- return;
536
- const n = this._getUnitInfo();
537
- if (n == null)
524
+ if (imageParam == null)
538
525
  return;
539
- const { unitId: t, subUnitId: r } = n, { imageId: s, imageSourceType: o, source: a, base64Cache: d } = e, { width: h, height: l, image: c } = await In(d || ""), u = this._renderManagerService.getRenderById(t);
540
- if (u == null)
526
+ const info = this._getUnitInfo();
527
+ if (info == null)
541
528
  return;
542
- const { width: g, height: f } = u.scene;
543
- this._imageIoService.addImageSourceCache(a, o, c);
544
- let m = 1;
545
- if (h > lt || l > ut) {
546
- const C = lt / h, v = ut / l;
547
- m = Math.max(C, v);
529
+ const { unitId, subUnitId } = info, { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || ""), { width: sceneWidth, height: sceneHeight } = this._context.scene;
530
+ this._imageIoService.addImageSourceCache(source, imageSourceType, image);
531
+ let scale = 1;
532
+ if (width > DRAWING_IMAGE_WIDTH_LIMIT || height > DRAWING_IMAGE_HEIGHT_LIMIT) {
533
+ const scaleWidth = DRAWING_IMAGE_WIDTH_LIMIT / width, scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
534
+ scale = Math.max(scaleWidth, scaleHeight);
548
535
  }
549
- const p = this._getImagePosition(h * m, l * m, g, f);
550
- if (p == null)
536
+ const sheetTransform = this._getImagePosition(width * scale, height * scale, sceneWidth, sceneHeight);
537
+ if (sheetTransform == null)
551
538
  return;
552
- const S = {
553
- unitId: t,
554
- subUnitId: r,
555
- drawingId: s,
556
- drawingType: Ve.DRAWING_IMAGE,
557
- imageSourceType: o,
558
- source: a,
559
- transform: $(p, this._selectionRenderService, this._skeletonManagerService),
560
- sheetTransform: p
539
+ const sheetDrawingParam = {
540
+ unitId,
541
+ subUnitId,
542
+ drawingId: imageId,
543
+ drawingType: DrawingTypeEnum.DRAWING_IMAGE,
544
+ imageSourceType,
545
+ source,
546
+ transform: drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService),
547
+ sheetTransform
561
548
  };
562
- this._commandService.executeCommand(st.id, {
563
- unitId: t,
564
- drawings: [S]
549
+ this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
550
+ unitId,
551
+ drawings: [sheetDrawingParam]
565
552
  });
566
553
  }
567
554
  _getUnitInfo() {
568
- const i = this._univerInstanceService.getCurrentUnitForType(B.UNIVER_SHEET);
569
- if (i == null)
570
- return;
571
- const e = i.getActiveSheet();
572
- if (e == null)
573
- return;
574
- const n = i.getUnitId(), t = e.getSheetId();
555
+ const workbook = this._context.unit, worksheet = workbook.getActiveSheet(), unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId();
575
556
  return {
576
- unitId: n,
577
- subUnitId: t
557
+ unitId,
558
+ subUnitId
578
559
  };
579
560
  }
580
- _getImagePosition(i, e, n, t) {
581
- const r = this._selectionManagerService.getCurrentSelections();
582
- let s = {
561
+ _getImagePosition(imageWidth, imageHeight, sceneWidth, sceneHeight) {
562
+ const selections = this._workbookSelections.getCurrentSelections();
563
+ let range = {
583
564
  startRow: 0,
584
565
  endRow: 0,
585
566
  startColumn: 0,
586
567
  endColumn: 0
587
568
  };
588
- r && r.length > 0 && (s = r[r.length - 1].range);
589
- const o = Un(this._skeletonManagerService.getCurrent().skeleton, s);
590
- if (o == null)
569
+ selections && selections.length > 0 && (range = selections[selections.length - 1].range);
570
+ const rangeWithCoord = attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton, range);
571
+ if (rangeWithCoord == null)
591
572
  return;
592
- let { startColumn: a, startRow: d, startX: h, startY: l } = o, c = !1;
593
- if (h + i > n && (h = n - i, h < 0 && (h = 0, i = n), c = !0), l + e > t && (l = t - e, l < 0 && (l = 0, e = t), c = !0), c) {
594
- const m = this._selectionRenderService.getSelectionCellByPosition(h, l);
595
- if (m == null)
573
+ let { startColumn, startRow, startX, startY } = rangeWithCoord, isChangeStart = !1;
574
+ if (startX + imageWidth > sceneWidth && (startX = sceneWidth - imageWidth, startX < 0 && (startX = 0, imageWidth = sceneWidth), isChangeStart = !0), startY + imageHeight > sceneHeight && (startY = sceneHeight - imageHeight, startY < 0 && (startY = 0, imageHeight = sceneHeight), isChangeStart = !0), isChangeStart) {
575
+ const newCoord = this._selectionRenderService.getSelectionCellByPosition(startX, startY);
576
+ if (newCoord == null)
596
577
  return;
597
- h = m.startX, l = m.startY, a = m.actualColumn, d = m.actualRow;
578
+ startX = newCoord.startX, startY = newCoord.startY, startColumn = newCoord.actualColumn, startRow = newCoord.actualRow;
598
579
  }
599
- const u = {
600
- column: a,
580
+ const from = {
581
+ column: startColumn,
601
582
  columnOffset: 0,
602
- row: d,
583
+ row: startRow,
603
584
  rowOffset: 0
604
- }, g = this._selectionRenderService.getSelectionCellByPosition(h + i, l + e);
605
- if (g == null)
585
+ }, endSelectionCell = this._selectionRenderService.getSelectionCellByPosition(startX + imageWidth, startY + imageHeight);
586
+ if (endSelectionCell == null)
606
587
  return;
607
- const f = {
608
- column: g.actualColumn,
609
- columnOffset: h + i - g.startX,
610
- row: g.actualRow,
611
- rowOffset: l + e - g.startY
588
+ const to = {
589
+ column: endSelectionCell.actualColumn,
590
+ columnOffset: startX + imageWidth - endSelectionCell.startX,
591
+ row: endSelectionCell.actualRow,
592
+ rowOffset: startY + imageHeight - endSelectionCell.startY
612
593
  };
613
594
  return {
614
- from: u,
615
- to: f
595
+ from,
596
+ to
616
597
  };
617
598
  }
618
599
  _updateOrderListener() {
619
- this._drawingManagerService.featurePluginOrderUpdate$.subscribe((i) => {
620
- const { unitId: e, subUnitId: n, drawingIds: t, arrangeType: r } = i;
621
- this._commandService.executeCommand(xt.id, {
622
- unitId: e,
623
- subUnitId: n,
624
- drawingIds: t,
625
- arrangeType: r
600
+ this._drawingManagerService.featurePluginOrderUpdate$.subscribe((params) => {
601
+ const { unitId, subUnitId, drawingIds, arrangeType } = params;
602
+ this._commandService.executeCommand(SetDrawingArrangeCommand.id, {
603
+ unitId,
604
+ subUnitId,
605
+ drawingIds,
606
+ arrangeType
626
607
  });
627
608
  });
628
609
  }
629
610
  _updateImageListener() {
630
- this._drawingManagerService.featurePluginUpdate$.subscribe((i) => {
631
- const e = [];
632
- i.length !== 0 && (i.forEach((n) => {
633
- const { unitId: t, subUnitId: r, drawingId: s, drawingType: o, transform: a } = n;
634
- if (a == null)
611
+ this._drawingManagerService.featurePluginUpdate$.subscribe((params) => {
612
+ const drawings = [];
613
+ params.length !== 0 && (params.forEach((param) => {
614
+ const { unitId, subUnitId, drawingId, drawingType, transform } = param;
615
+ if (transform == null)
635
616
  return;
636
- const d = this._sheetDrawingService.getDrawingByParam({ unitId: t, subUnitId: r, drawingId: s });
637
- if (d == null)
617
+ const sheetDrawing = this._sheetDrawingService.getDrawingByParam({ unitId, subUnitId, drawingId });
618
+ if (sheetDrawing == null)
638
619
  return;
639
- const h = N({ ...d.transform, ...a }, this._selectionRenderService);
640
- if (h == null)
620
+ const sheetTransform = transformToDrawingPosition({ ...sheetDrawing.transform, ...transform }, this._selectionRenderService);
621
+ if (sheetTransform == null)
641
622
  return;
642
- const l = {
643
- ...n,
644
- transform: { ...d.transform, ...a, ...$(h, this._selectionRenderService, this._skeletonManagerService) },
645
- sheetTransform: { ...h }
623
+ const newDrawing = {
624
+ ...param,
625
+ transform: { ...sheetDrawing.transform, ...transform, ...drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService) },
626
+ sheetTransform: { ...sheetTransform }
646
627
  };
647
- e.push(l);
648
- }), e.length > 0 && this._commandService.executeCommand(Fe.id, {
649
- unitId: i[0].unitId,
650
- drawings: e
628
+ drawings.push(newDrawing);
629
+ }), drawings.length > 0 && this._commandService.executeCommand(SetSheetDrawingCommand.id, {
630
+ unitId: params[0].unitId,
631
+ drawings
651
632
  }));
652
633
  });
653
634
  }
654
635
  _groupDrawingListener() {
655
- this._drawingManagerService.featurePluginGroupUpdate$.subscribe((i) => {
656
- this._commandService.executeCommand(Ft.id, i);
657
- const { unitId: e, subUnitId: n, drawingId: t } = i[0].parent;
658
- this._drawingManagerService.focusDrawing([{ unitId: e, subUnitId: n, drawingId: t }]);
659
- }), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((i) => {
660
- this._commandService.executeCommand(Yt.id, i);
636
+ this._drawingManagerService.featurePluginGroupUpdate$.subscribe((params) => {
637
+ this._commandService.executeCommand(GroupSheetDrawingCommand.id, params);
638
+ const { unitId, subUnitId, drawingId } = params[0].parent;
639
+ this._drawingManagerService.focusDrawing([{ unitId, subUnitId, drawingId }]);
640
+ }), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((params) => {
641
+ this._commandService.executeCommand(UngroupSheetDrawingCommand.id, params);
661
642
  });
662
643
  }
663
644
  _focusDrawingListener() {
664
645
  this.disposeWithMe(
665
- this._drawingManagerService.focus$.subscribe((i) => {
666
- i == null || i.length === 0 ? (this._contextService.setContextValue(we, !1), this._sheetDrawingService.focusDrawing([])) : (this._contextService.setContextValue(we, !0), this._sheetDrawingService.focusDrawing(i));
646
+ this._drawingManagerService.focus$.subscribe((params) => {
647
+ params == null || params.length === 0 ? (this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1), this._sheetDrawingService.focusDrawing([])) : (this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !0), this._sheetDrawingService.focusDrawing(params));
667
648
  })
668
649
  );
669
650
  }
670
651
  _drawingAddListener() {
671
652
  this.disposeWithMe(
672
- this._sheetDrawingService.add$.subscribe((i) => {
673
- this._registerDrawing(i);
653
+ this._sheetDrawingService.add$.subscribe((params) => {
654
+ this._registerDrawing(params);
674
655
  })
675
656
  );
676
657
  }
677
- _registerDrawing(i) {
678
- i.forEach((n) => {
679
- const t = this._sheetDrawingService.getDrawingByParam(n);
680
- if (t == null)
658
+ _registerDrawing(params) {
659
+ params.forEach((param) => {
660
+ const drawingParam = this._sheetDrawingService.getDrawingByParam(param);
661
+ if (drawingParam == null)
681
662
  return;
682
- const { sheetTransform: r } = t;
683
- t.transform = $(r, this._selectionRenderService, this._skeletonManagerService);
663
+ const { sheetTransform } = drawingParam;
664
+ drawingParam.transform = drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService);
684
665
  });
685
- const e = i[0].unitId;
686
- this._drawingManagerService.registerDrawingData(e, this._sheetDrawingService.getDrawingDataForUnit(e)), this._drawingManagerService.initializeNotification(e);
687
- }
688
- };
689
- Ue = Ir([
690
- ie(se.Rendered, Ue),
691
- X(0, V),
692
- X(1, he),
693
- X(2, W(Zn)),
694
- X(3, vt),
695
- X(4, k),
696
- X(5, z),
697
- X(6, _t),
698
- X(7, Fn),
699
- X(8, W(_e)),
700
- X(9, K)
701
- ], Ue);
702
- var Y = function() {
703
- return Y = Object.assign || function(i) {
704
- for (var e, n = 1, t = arguments.length; n < t; n++) {
705
- e = arguments[n];
706
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (i[r] = e[r]);
666
+ const unitId = params[0].unitId;
667
+ this._drawingManagerService.registerDrawingData(unitId, this._sheetDrawingService.getDrawingDataForUnit(unitId)), this._drawingManagerService.initializeNotification(unitId);
668
+ }
669
+ }, __name(_a2, "SheetDrawingUpdateController"), _a2);
670
+ SheetDrawingUpdateController = __decorateClass$7([
671
+ __decorateParam$7(1, Inject(SheetSkeletonManagerService)),
672
+ __decorateParam$7(2, ICommandService),
673
+ __decorateParam$7(3, ISheetSelectionRenderService),
674
+ __decorateParam$7(4, IImageIoService),
675
+ __decorateParam$7(5, ISheetDrawingService),
676
+ __decorateParam$7(6, IDrawingManagerService),
677
+ __decorateParam$7(7, IContextService),
678
+ __decorateParam$7(8, IMessageService),
679
+ __decorateParam$7(9, Inject(LocaleService)),
680
+ __decorateParam$7(10, Inject(SheetsSelectionsService))
681
+ ], SheetDrawingUpdateController);
682
+ var __assign = function() {
683
+ return __assign = Object.assign || function(t) {
684
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
685
+ s = arguments[i];
686
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
707
687
  }
708
- return i;
709
- }, Y.apply(this, arguments);
710
- }, Rr = function(i, e) {
711
- var n = {};
712
- for (var t in i) Object.prototype.hasOwnProperty.call(i, t) && e.indexOf(t) < 0 && (n[t] = i[t]);
713
- if (i != null && typeof Object.getOwnPropertySymbols == "function")
714
- for (var r = 0, t = Object.getOwnPropertySymbols(i); r < t.length; r++)
715
- e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(i, t[r]) && (n[t[r]] = i[t[r]]);
716
- return n;
717
- }, kt = Lt(function(i, e) {
718
- var n = i.icon, t = i.id, r = i.className, s = i.extend, o = Rr(i, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), d = Bt("_".concat(br()));
719
- return Ht(n, "".concat(t), { defIds: n.defIds, idSuffix: d.current }, Y({ ref: e, className: a }, o), s);
688
+ return t;
689
+ }, __assign.apply(this, arguments);
690
+ }, __rest = function(s, e) {
691
+ var t = {};
692
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
693
+ if (s != null && typeof Object.getOwnPropertySymbols == "function")
694
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
695
+ e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
696
+ return t;
697
+ }, IconBase = forwardRef(function(props, ref) {
698
+ var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
699
+ return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
720
700
  });
721
- function Ht(i, e, n, t, r) {
722
- return Wt(i.tag, Y(Y({ key: e }, Mr(i, n, r)), t), (Dr(i, n).children || []).map(function(s, o) {
723
- return Ht(s, "".concat(e, "-").concat(i.tag, "-").concat(o), n, void 0, r);
701
+ function render(node, id, runtimeProps, rootProps, extend) {
702
+ return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
703
+ return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
724
704
  }));
725
705
  }
726
- function Mr(i, e, n) {
727
- var t = Y({}, i.attrs);
728
- n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
729
- var r = e.defIds;
730
- return !r || r.length === 0 || (i.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(s) {
731
- var o = s[0], a = s[1];
732
- typeof a == "string" && (t[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
733
- })), t;
706
+ __name(render, "render");
707
+ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
708
+ var attrs = __assign({}, node.attrs);
709
+ extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
710
+ var defIds = runtimeProps.defIds;
711
+ return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a10) {
712
+ var key = _a10[0], value = _a10[1];
713
+ typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
714
+ })), attrs;
734
715
  }
735
- function Dr(i, e) {
736
- var n, t = e.defIds;
737
- return !t || t.length === 0 ? i : i.tag === "defs" && (!((n = i.children) === null || n === void 0) && n.length) ? Y(Y({}, i), { children: i.children.map(function(r) {
738
- return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? Y(Y({}, r), { attrs: Y(Y({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
739
- }) }) : i;
716
+ __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
717
+ function replaceRuntimeIdsInDefs(node, runtimeProps) {
718
+ var _a10, defIds = runtimeProps.defIds;
719
+ return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a10 = node.children) === null || _a10 === void 0) && _a10.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
720
+ return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
721
+ }) }) : node;
740
722
  }
741
- function br() {
723
+ __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
724
+ function generateShortUuid() {
742
725
  return Math.random().toString(36).substring(2, 8);
743
726
  }
744
- kt.displayName = "UniverIcon";
745
- var Er = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, Xt = Lt(function(i, e) {
746
- return Wt(kt, Object.assign({}, i, {
727
+ __name(generateShortUuid, "generateShortUuid");
728
+ IconBase.displayName = "UniverIcon";
729
+ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, AddImageSingle = forwardRef(function(props, ref) {
730
+ return createElement(IconBase, Object.assign({}, props, {
747
731
  id: "add-image-single",
748
- ref: e,
749
- icon: Er
732
+ ref,
733
+ icon: element
750
734
  }));
751
735
  });
752
- Xt.displayName = "AddImageSingle";
753
- const yr = "univer-upload-file-menu", Or = "univer-upload-file-menu-input", wt = {
754
- uploadFileMenu: yr,
755
- uploadFileMenuInput: Or
756
- }, zt = "COMPONENT_UPLOAD_FILE_MENU";
757
- var We = /* @__PURE__ */ ((i) => (i[i.cellImage = 0] = "cellImage", i[i.floatImage = 1] = "floatImage", i))(We || {});
758
- const Pr = (i) => {
759
- const { type: e } = i, n = ee(V), t = Bt(null), r = () => {
760
- var a;
761
- (a = t.current) == null || a.click();
762
- }, s = Rn.map((a) => `.${a.replace("image/", "")}`).join(","), o = (a) => {
763
- const d = a.target.files;
764
- if (d == null)
736
+ AddImageSingle.displayName = "AddImageSingle";
737
+ const uploadFileMenu = "univer-upload-file-menu", uploadFileMenuInput = "univer-upload-file-menu-input", styles$1 = {
738
+ uploadFileMenu,
739
+ uploadFileMenuInput
740
+ }, COMPONENT_UPLOAD_FILE_MENU = "COMPONENT_UPLOAD_FILE_MENU";
741
+ var UploadFileType = /* @__PURE__ */ ((UploadFileType2) => (UploadFileType2[UploadFileType2.cellImage = 0] = "cellImage", UploadFileType2[UploadFileType2.floatImage = 1] = "floatImage", UploadFileType2))(UploadFileType || {});
742
+ const UploadFileMenu = /* @__PURE__ */ __name((props) => {
743
+ const { type } = props, commandService = useDependency(ICommandService), fileInputRef = useRef(null), handleButtonClick = /* @__PURE__ */ __name(() => {
744
+ var _a10;
745
+ (_a10 = fileInputRef.current) == null || _a10.click();
746
+ }, "handleButtonClick"), imageAccept = DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(","), handleFileChange = /* @__PURE__ */ __name((event) => {
747
+ const fileList = event.target.files;
748
+ if (fileList == null)
765
749
  return;
766
- const h = Array.from(d);
767
- e === We.floatImage ? n.executeCommand(xe.id, { files: h }) : e === We.cellImage && n.executeCommand(Be.id, { files: h }), t.current && (t.current.value = "");
768
- };
769
- return /* @__PURE__ */ L.createElement("div", { onClick: r, className: wt.uploadFileMenu }, /* @__PURE__ */ L.createElement(
750
+ const files = Array.from(fileList);
751
+ type === UploadFileType.floatImage ? commandService.executeCommand(InsertFloatImageOperation.id, { files }) : type === UploadFileType.cellImage && commandService.executeCommand(InsertCellImageOperation.id, { files }), fileInputRef.current && (fileInputRef.current.value = "");
752
+ }, "handleFileChange");
753
+ return /* @__PURE__ */ React.createElement("div", { onClick: handleButtonClick, className: styles$1.uploadFileMenu }, /* @__PURE__ */ React.createElement(
770
754
  "input",
771
755
  {
772
756
  type: "file",
773
- className: wt.uploadFileMenuInput,
774
- ref: t,
775
- onChange: o,
776
- accept: s,
757
+ className: styles$1.uploadFileMenuInput,
758
+ ref: fileInputRef,
759
+ onChange: handleFileChange,
760
+ accept: imageAccept,
777
761
  multiple: !0
778
762
  }
779
763
  ));
780
- }, Kt = "addition-and-subtraction-single", Jt = "sheet.menu.image";
781
- function Tr(i) {
764
+ }, "UploadFileMenu"), IMAGE_UPLOAD_ICON = "addition-and-subtraction-single", IMAGE_MENU_ID = "sheet.menu.image";
765
+ function ImageMenuFactory(accessor) {
782
766
  return {
783
- id: Jt,
784
- type: St.SUBITEMS,
785
- positions: [Yn.TOOLBAR_START],
786
- group: kn.TOOLBAR_FORMULAS_INSERT,
787
- icon: Kt,
767
+ id: IMAGE_MENU_ID,
768
+ type: MenuItemType.SUBITEMS,
769
+ positions: [MenuPosition.TOOLBAR_START],
770
+ group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
771
+ icon: IMAGE_UPLOAD_ICON,
788
772
  tooltip: "sheetImage.title",
789
- hidden$: Ct(i, B.UNIVER_SHEET),
790
- disabled$: An(i, { workbookTypes: [Ze], worksheetTypes: [Pe], rangeTypes: [qn] })
773
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
774
+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
791
775
  };
792
776
  }
793
- function Ur(i) {
777
+ __name(ImageMenuFactory, "ImageMenuFactory");
778
+ function UploadFloatImageMenuFactory(_accessor) {
794
779
  return {
795
- id: xe.id,
780
+ id: InsertFloatImageOperation.id,
796
781
  title: "sheetImage.upload.float",
797
- type: St.SELECTOR,
782
+ type: MenuItemType.SELECTOR,
798
783
  label: {
799
- name: zt,
784
+ name: COMPONENT_UPLOAD_FILE_MENU,
800
785
  props: {
801
- type: We.floatImage
786
+ type: UploadFileType.floatImage
802
787
  }
803
788
  },
804
- positions: [Jt],
805
- hidden$: Ct(i, B.UNIVER_SHEET)
789
+ positions: [IMAGE_MENU_ID],
790
+ hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SHEET)
806
791
  };
807
792
  }
808
- const Ar = "univer-image-common-panel", Nr = "univer-image-common-panel-grid", jr = "univer-image-common-panel-border", Lr = "univer-image-common-panel-title", Br = "univer-image-common-panel-subtitle", Wr = "univer-image-common-panel-row", $r = "univer-image-common-panel-row-vertical", Vr = "univer-image-common-panel-column", Gr = "univer-image-common-panel-column-center", xr = "univer-image-common-panel-inline", Fr = "univer-image-common-panel-span2", Yr = "univer-image-common-panel-span3", kr = "univer-image-common-panel-input", Hr = "univer-sheet-image-menu", Xr = "univer-sheet-image-menu-input", Z = {
809
- imageCommonPanel: Ar,
810
- imageCommonPanelGrid: Nr,
811
- imageCommonPanelBorder: jr,
812
- imageCommonPanelTitle: Lr,
813
- imageCommonPanelSubtitle: Br,
814
- imageCommonPanelRow: Wr,
815
- imageCommonPanelRowVertical: $r,
816
- imageCommonPanelColumn: Vr,
817
- imageCommonPanelColumnCenter: Gr,
818
- imageCommonPanelInline: xr,
819
- imageCommonPanelSpan2: Fr,
820
- imageCommonPanelSpan3: Yr,
821
- imageCommonPanelInput: kr,
822
- sheetImageMenu: Hr,
823
- sheetImageMenuInput: Xr
824
- }, zr = (i) => {
825
- var v;
826
- const e = ee(V), n = ee(_e), t = ee(z), r = ee(K), { drawings: s } = i, o = s[0];
827
- if (o == null)
793
+ __name(UploadFloatImageMenuFactory, "UploadFloatImageMenuFactory");
794
+ const imageCommonPanel = "univer-image-common-panel", imageCommonPanelGrid = "univer-image-common-panel-grid", imageCommonPanelBorder = "univer-image-common-panel-border", imageCommonPanelTitle = "univer-image-common-panel-title", imageCommonPanelSubtitle = "univer-image-common-panel-subtitle", imageCommonPanelRow = "univer-image-common-panel-row", imageCommonPanelRowVertical = "univer-image-common-panel-row-vertical", imageCommonPanelColumn = "univer-image-common-panel-column", imageCommonPanelColumnCenter = "univer-image-common-panel-column-center", imageCommonPanelInline = "univer-image-common-panel-inline", imageCommonPanelSpan2 = "univer-image-common-panel-span2", imageCommonPanelSpan3 = "univer-image-common-panel-span3", imageCommonPanelInput = "univer-image-common-panel-input", sheetImageMenu = "univer-sheet-image-menu", sheetImageMenuInput = "univer-sheet-image-menu-input", styles = {
795
+ imageCommonPanel,
796
+ imageCommonPanelGrid,
797
+ imageCommonPanelBorder,
798
+ imageCommonPanelTitle,
799
+ imageCommonPanelSubtitle,
800
+ imageCommonPanelRow,
801
+ imageCommonPanelRowVertical,
802
+ imageCommonPanelColumn,
803
+ imageCommonPanelColumnCenter,
804
+ imageCommonPanelInline,
805
+ imageCommonPanelSpan2,
806
+ imageCommonPanelSpan3,
807
+ imageCommonPanelInput,
808
+ sheetImageMenu,
809
+ sheetImageMenuInput
810
+ }, SheetDrawingAnchor = /* @__PURE__ */ __name((props) => {
811
+ var _a10;
812
+ const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), { drawings } = props, drawingParam = drawings[0];
813
+ if (drawingParam == null)
828
814
  return;
829
- const { unitId: a } = o, d = r.getRenderById(a), h = d == null ? void 0 : d.scene;
830
- if (h == null)
815
+ const { unitId } = drawingParam, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
816
+ if (scene == null)
831
817
  return;
832
- const l = h.getTransformerByCreate(), [c, u] = et(!0), g = (v = o.anchorType) != null ? v : O.Position, [f, m] = et(g);
833
- function p(R, _) {
834
- const b = [];
835
- return R.forEach((w) => {
836
- const { oKey: P } = w, D = _.getDrawingOKey(P);
837
- if (D == null)
838
- return b.push(null), !0;
839
- const { unitId: T, subUnitId: U, drawingId: M, drawingType: I, anchorType: A, sheetTransform: G } = D;
840
- b.push({
841
- unitId: T,
842
- subUnitId: U,
843
- drawingId: M,
844
- anchorType: A,
845
- sheetTransform: G,
846
- drawingType: I
818
+ const transformer = scene.getTransformerByCreate(), [anchorShow, setAnchorShow] = useState(!0), type = (_a10 = drawingParam.anchorType) != null ? _a10 : SheetDrawingAnchorType.Position, [value, setValue] = useState(type);
819
+ function getUpdateParams(objects, drawingManagerService2) {
820
+ const params = [];
821
+ return objects.forEach((object) => {
822
+ const { oKey } = object, searchParam = drawingManagerService2.getDrawingOKey(oKey);
823
+ if (searchParam == null)
824
+ return params.push(null), !0;
825
+ const { unitId: unitId2, subUnitId, drawingId, drawingType, anchorType, sheetTransform } = searchParam;
826
+ params.push({
827
+ unitId: unitId2,
828
+ subUnitId,
829
+ drawingId,
830
+ anchorType,
831
+ sheetTransform,
832
+ drawingType
847
833
  });
848
- }), b;
849
- }
850
- rt(() => {
851
- const R = l.clearControl$.subscribe((b) => {
852
- b === !0 && u(!1);
853
- }), _ = l.changeStart$.subscribe((b) => {
854
- var D;
855
- const { objects: w } = b, P = p(w, t);
856
- if (P.length === 0)
857
- u(!1);
858
- else if (P.length >= 1) {
859
- u(!0);
860
- const T = ((D = P[0]) == null ? void 0 : D.anchorType) || O.Position;
861
- m(T);
834
+ }), params;
835
+ }
836
+ __name(getUpdateParams, "getUpdateParams"), useEffect(() => {
837
+ const onClearControlObserver = transformer.clearControl$.subscribe((changeSelf) => {
838
+ changeSelf === !0 && setAnchorShow(!1);
839
+ }), onChangeStartObserver = transformer.changeStart$.subscribe((state) => {
840
+ var _a11;
841
+ const { objects } = state, params = getUpdateParams(objects, drawingManagerService);
842
+ if (params.length === 0)
843
+ setAnchorShow(!1);
844
+ else if (params.length >= 1) {
845
+ setAnchorShow(!0);
846
+ const anchorType = ((_a11 = params[0]) == null ? void 0 : _a11.anchorType) || SheetDrawingAnchorType.Position;
847
+ setValue(anchorType);
862
848
  }
863
849
  });
864
850
  return () => {
865
- _.unsubscribe(), R.unsubscribe();
851
+ onChangeStartObserver.unsubscribe(), onClearControlObserver.unsubscribe();
866
852
  };
867
853
  }, []);
868
- function S(R) {
869
- m(R);
870
- const _ = t.getFocusDrawings();
871
- if (_.length === 0)
854
+ function handleChange(value2) {
855
+ setValue(value2);
856
+ const focusDrawings = drawingManagerService.getFocusDrawings();
857
+ if (focusDrawings.length === 0)
872
858
  return;
873
- const b = _.map((w) => ({
874
- unitId: w.unitId,
875
- subUnitId: w.subUnitId,
876
- drawingId: w.drawingId,
877
- anchorType: R
859
+ const updateParams = focusDrawings.map((drawing) => ({
860
+ unitId: drawing.unitId,
861
+ subUnitId: drawing.subUnitId,
862
+ drawingId: drawing.drawingId,
863
+ anchorType: value2
878
864
  }));
879
- e.executeCommand(Fe.id, {
880
- unitId: _[0].unitId,
881
- drawings: b
865
+ commandService.executeCommand(SetSheetDrawingCommand.id, {
866
+ unitId: focusDrawings[0].unitId,
867
+ drawings: updateParams
882
868
  });
883
869
  }
884
- const C = (R) => R ? "block" : "none";
885
- return /* @__PURE__ */ L.createElement("div", { className: Ee(Z.imageCommonPanelGrid, Z.imageCommonPanelBorder), style: { display: C(c) } }, /* @__PURE__ */ L.createElement("div", { className: Z.imageCommonPanelRow }, /* @__PURE__ */ L.createElement("div", { className: Ee(Z.imageCommonPanelColumn, Z.imageCommonPanelTitle) }, /* @__PURE__ */ L.createElement("div", null, n.t("drawing-anchor.title")))), /* @__PURE__ */ L.createElement("div", { className: Ee(Z.imageCommonPanelRow) }, /* @__PURE__ */ L.createElement("div", { className: Ee(Z.imageCommonPanelColumn) }, /* @__PURE__ */ L.createElement(cr, { value: f, onChange: S, direction: "vertical" }, /* @__PURE__ */ L.createElement(Xe, { value: O.Both }, n.t("drawing-anchor.both")), /* @__PURE__ */ L.createElement(Xe, { value: O.Position }, n.t("drawing-anchor.position")), /* @__PURE__ */ L.createElement(Xe, { value: O.None }, n.t("drawing-anchor.none"))))));
886
- }, Kr = () => {
887
- const i = ee(z), e = i.getFocusDrawings(), [n, t] = et(e);
888
- return rt(() => {
889
- const r = i.focus$.subscribe((s) => {
890
- t(s);
870
+ __name(handleChange, "handleChange");
871
+ const gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay");
872
+ return /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelGrid, styles.imageCommonPanelBorder), style: { display: gridDisplay(anchorShow) } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("drawing-anchor.title")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelRow) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(RadioGroup, { value, onChange: handleChange, direction: "vertical" }, /* @__PURE__ */ React.createElement(Radio, { value: SheetDrawingAnchorType.Both }, localeService.t("drawing-anchor.both")), /* @__PURE__ */ React.createElement(Radio, { value: SheetDrawingAnchorType.Position }, localeService.t("drawing-anchor.position")), /* @__PURE__ */ React.createElement(Radio, { value: SheetDrawingAnchorType.None }, localeService.t("drawing-anchor.none"))))));
873
+ }, "SheetDrawingAnchor"), SheetDrawingPanel = /* @__PURE__ */ __name(() => {
874
+ const drawingManagerService = useDependency(IDrawingManagerService), focusDrawings = drawingManagerService.getFocusDrawings(), [drawings, setDrawings] = useState(focusDrawings);
875
+ return useEffect(() => {
876
+ const focusDispose = drawingManagerService.focus$.subscribe((drawings2) => {
877
+ setDrawings(drawings2);
891
878
  });
892
879
  return () => {
893
- r.unsubscribe();
880
+ focusDispose.unsubscribe();
894
881
  };
895
- }, []), !!(n != null && n.length) && /* @__PURE__ */ L.createElement("div", { className: Z.imageCommonPanel }, /* @__PURE__ */ L.createElement(wn, { drawings: n }), /* @__PURE__ */ L.createElement(zr, { drawings: n }));
896
- }, ve = {
882
+ }, []), !!(drawings != null && drawings.length) && /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanel }, /* @__PURE__ */ React.createElement(DrawingCommonPanel, { drawings }), /* @__PURE__ */ React.createElement(SheetDrawingAnchor, { drawings }));
883
+ }, "SheetDrawingPanel"), MoveDrawingsCommand = {
897
884
  id: "sheet.command.move-drawing",
898
- type: F.COMMAND,
899
- handler: (i, e) => {
900
- const n = i.get(V), t = i.get(k), r = i.get(Ge), { direction: s } = e, o = t.getFocusDrawings();
901
- if (o.length === 0)
885
+ type: CommandType.COMMAND,
886
+ handler: /* @__PURE__ */ __name((accessor, params) => {
887
+ const commandService = accessor.get(ICommandService), drawingManagerService = accessor.get(ISheetDrawingService), selectionRenderService = accessor.get(ISheetSelectionRenderService), { direction } = params, drawings = drawingManagerService.getFocusDrawings();
888
+ if (drawings.length === 0)
902
889
  return !1;
903
- const a = o[0].unitId, d = o.map((l) => {
904
- const { transform: c } = l;
905
- if (c == null)
890
+ const unitId = drawings[0].unitId, newDrawings = drawings.map((drawing) => {
891
+ const { transform } = drawing;
892
+ if (transform == null)
906
893
  return null;
907
- const u = { ...c }, { left: g = 0, top: f = 0 } = c;
908
- return s === q.UP ? u.top = f - 1 : s === q.DOWN ? u.top = f + 1 : s === q.LEFT ? u.left = g - 1 : s === q.RIGHT && (u.left = g + 1), {
909
- ...l,
910
- transform: u,
911
- sheetTransform: N(u, r)
894
+ const newTransform = { ...transform }, { left = 0, top = 0 } = transform;
895
+ return direction === Direction.UP ? newTransform.top = top - 1 : direction === Direction.DOWN ? newTransform.top = top + 1 : direction === Direction.LEFT ? newTransform.left = left - 1 : direction === Direction.RIGHT && (newTransform.left = left + 1), {
896
+ ...drawing,
897
+ transform: newTransform,
898
+ sheetTransform: transformToDrawingPosition(newTransform, selectionRenderService)
912
899
  };
913
- }).filter((l) => l != null);
914
- return n.syncExecuteCommand(Fe.id, {
915
- unitId: a,
916
- drawings: d
917
- }) ? (n.syncExecuteCommand(j.id, [a]), !0) : !1;
918
- }
919
- }, Zt = {
900
+ }).filter((drawing) => drawing != null);
901
+ return commandService.syncExecuteCommand(SetSheetDrawingCommand.id, {
902
+ unitId,
903
+ drawings: newDrawings
904
+ }) ? (commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id, [unitId]), !0) : !1;
905
+ }, "handler")
906
+ }, DeleteDrawingsCommand = {
920
907
  id: "sheet.command.delete-drawing",
921
- type: F.COMMAND,
922
- handler: (i) => {
923
- const e = i.get(V), t = i.get(k).getFocusDrawings();
924
- if (t.length === 0)
908
+ type: CommandType.COMMAND,
909
+ handler: /* @__PURE__ */ __name((accessor) => {
910
+ const commandService = accessor.get(ICommandService), drawings = accessor.get(ISheetDrawingService).getFocusDrawings();
911
+ if (drawings.length === 0)
925
912
  return !1;
926
- const r = t[0].unitId, s = t.map((o) => {
927
- const { unitId: a, subUnitId: d, drawingId: h, drawingType: l } = o;
913
+ const unitId = drawings[0].unitId, newDrawings = drawings.map((drawing) => {
914
+ const { unitId: unitId2, subUnitId, drawingId, drawingType } = drawing;
928
915
  return {
929
- unitId: a,
930
- subUnitId: d,
931
- drawingId: h,
932
- drawingType: l
916
+ unitId: unitId2,
917
+ subUnitId,
918
+ drawingId,
919
+ drawingType
933
920
  };
934
921
  });
935
- return e.executeCommand(it.id, {
936
- unitId: r,
937
- drawings: s
922
+ return commandService.executeCommand(RemoveSheetDrawingCommand.id, {
923
+ unitId,
924
+ drawings: newDrawings
938
925
  });
939
- }
926
+ }, "handler")
940
927
  };
941
- function Se(i) {
942
- return !i.getContextValue(sn) && !i.getContextValue(on) && i.getContextValue(we);
928
+ function whenSheetDrawingFocused(contextService) {
929
+ return !contextService.getContextValue(FOCUSING_FORMULA_EDITOR) && !contextService.getContextValue(EDITOR_ACTIVATED) && contextService.getContextValue(FOCUSING_COMMON_DRAWINGS);
943
930
  }
944
- const Jr = {
945
- id: ve.id,
931
+ __name(whenSheetDrawingFocused, "whenSheetDrawingFocused");
932
+ const MoveDrawingDownShortcutItem = {
933
+ id: MoveDrawingsCommand.id,
946
934
  description: "shortcut.sheet.drawing-move-down",
947
935
  group: "4_sheet-drawing-view",
948
- binding: ue.ARROW_DOWN,
936
+ binding: KeyCode.ARROW_DOWN,
949
937
  priority: 100,
950
- preconditions: Se,
938
+ preconditions: whenSheetDrawingFocused,
951
939
  staticParameters: {
952
- direction: q.DOWN
940
+ direction: Direction.DOWN
953
941
  }
954
- }, Zr = {
955
- id: ve.id,
942
+ }, MoveDrawingUpShortcutItem = {
943
+ id: MoveDrawingsCommand.id,
956
944
  description: "shortcut.sheet.drawing-move-up",
957
945
  group: "4_sheet-drawing-view",
958
- binding: ue.ARROW_UP,
946
+ binding: KeyCode.ARROW_UP,
959
947
  priority: 100,
960
- preconditions: Se,
948
+ preconditions: whenSheetDrawingFocused,
961
949
  staticParameters: {
962
- direction: q.UP
950
+ direction: Direction.UP
963
951
  }
964
- }, qr = {
965
- id: ve.id,
952
+ }, MoveDrawingLeftShortcutItem = {
953
+ id: MoveDrawingsCommand.id,
966
954
  description: "shortcut.sheet.drawing-move-left",
967
955
  group: "4_sheet-drawing-view",
968
- binding: ue.ARROW_LEFT,
956
+ binding: KeyCode.ARROW_LEFT,
969
957
  priority: 100,
970
- preconditions: Se,
958
+ preconditions: whenSheetDrawingFocused,
971
959
  staticParameters: {
972
- direction: q.LEFT
960
+ direction: Direction.LEFT
973
961
  }
974
- }, Qr = {
975
- id: ve.id,
962
+ }, MoveDrawingRightShortcutItem = {
963
+ id: MoveDrawingsCommand.id,
976
964
  description: "shortcut.sheet.drawing-move-right",
977
965
  group: "4_sheet-drawing-view",
978
- binding: ue.ARROW_RIGHT,
966
+ binding: KeyCode.ARROW_RIGHT,
979
967
  priority: 100,
980
- preconditions: Se,
968
+ preconditions: whenSheetDrawingFocused,
981
969
  staticParameters: {
982
- direction: q.RIGHT
970
+ direction: Direction.RIGHT
983
971
  }
984
- }, ei = {
985
- id: Zt.id,
972
+ }, DeleteDrawingsShortcutItem = {
973
+ id: DeleteDrawingsCommand.id,
986
974
  description: "shortcut.sheet.drawing-delete",
987
975
  group: "4_sheet-drawing-view",
988
976
  // when focusing on any other input tag do not trigger this shortcut
989
- preconditions: Se,
990
- binding: ue.DELETE,
991
- mac: ue.BACKSPACE
977
+ preconditions: whenSheetDrawingFocused,
978
+ binding: KeyCode.DELETE,
979
+ mac: KeyCode.BACKSPACE
992
980
  };
993
- var ti = Object.defineProperty, ni = Object.getOwnPropertyDescriptor, ri = (i, e, n, t) => {
994
- for (var r = t > 1 ? void 0 : t ? ni(e, n) : e, s = i.length - 1, o; s >= 0; s--)
995
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
996
- return t && r && ti(e, n, r), r;
997
- }, me = (i, e) => (n, t) => e(n, t, i);
998
- const ii = {};
999
- let pe = class extends oe {
1000
- constructor(i, e, n, t, r, s) {
1001
- super(), this._config = i, this._injector = e, this._componentManager = n, this._menuService = t, this._commandService = r, this._shortcutService = s, this._init();
981
+ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
982
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
983
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
984
+ return kind && result && __defProp$6(target, key, result), result;
985
+ }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6");
986
+ const DefaultSheetsDrawingConfig = {};
987
+ var _a3;
988
+ let SheetDrawingUIController = (_a3 = class extends Disposable {
989
+ constructor(_config, _injector, _componentManager, _menuService, _commandService, _shortcutService) {
990
+ super(), this._config = _config, this._injector = _injector, this._componentManager = _componentManager, this._menuService = _menuService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._init();
1002
991
  }
1003
992
  _initCustomComponents() {
1004
- const i = this._componentManager;
1005
- this.disposeWithMe(i.register(Kt, Xt)), this.disposeWithMe(i.register(zt, Pr)), this.disposeWithMe(i.register($t, Kr));
993
+ const componentManager = this._componentManager;
994
+ this.disposeWithMe(componentManager.register(IMAGE_UPLOAD_ICON, AddImageSingle)), this.disposeWithMe(componentManager.register(COMPONENT_UPLOAD_FILE_MENU, UploadFileMenu)), this.disposeWithMe(componentManager.register(COMPONENT_SHEET_DRAWING_PANEL, SheetDrawingPanel));
1006
995
  }
1007
996
  _initMenus() {
1008
- const { menu: i = {} } = this._config;
997
+ const { menu = {} } = this._config;
1009
998
  [
1010
- Tr,
1011
- Ur
999
+ ImageMenuFactory,
1000
+ UploadFloatImageMenuFactory
1012
1001
  // UploadCellImageMenuFactory,
1013
- ].forEach((e) => {
1014
- this._menuService.addMenuItem(e(this._injector), i);
1002
+ ].forEach((menuFactory) => {
1003
+ this._menuService.addMenuItem(menuFactory(this._injector), menu);
1015
1004
  });
1016
1005
  }
1017
1006
  _initCommands() {
1018
1007
  [
1019
- xe,
1020
- Be,
1021
- st,
1022
- it,
1023
- Fe,
1024
- Vt,
1025
- j,
1026
- Gt,
1027
- Ft,
1028
- Yt,
1029
- ve,
1030
- Zt,
1031
- xt
1032
- ].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i)));
1008
+ InsertFloatImageOperation,
1009
+ InsertCellImageOperation,
1010
+ InsertSheetDrawingCommand,
1011
+ RemoveSheetDrawingCommand,
1012
+ SetSheetDrawingCommand,
1013
+ SidebarSheetDrawingOperation,
1014
+ ClearSheetDrawingTransformerOperation,
1015
+ EditSheetDrawingOperation,
1016
+ GroupSheetDrawingCommand,
1017
+ UngroupSheetDrawingCommand,
1018
+ MoveDrawingsCommand,
1019
+ DeleteDrawingsCommand,
1020
+ SetDrawingArrangeCommand
1021
+ ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
1033
1022
  }
1034
1023
  _initShortcuts() {
1035
1024
  [
1036
1025
  // sheet drawing shortcuts
1037
- Jr,
1038
- Zr,
1039
- qr,
1040
- Qr,
1041
- ei
1042
- ].forEach((i) => {
1043
- this.disposeWithMe(this._shortcutService.registerShortcut(i));
1026
+ MoveDrawingDownShortcutItem,
1027
+ MoveDrawingUpShortcutItem,
1028
+ MoveDrawingLeftShortcutItem,
1029
+ MoveDrawingRightShortcutItem,
1030
+ DeleteDrawingsShortcutItem
1031
+ ].forEach((item) => {
1032
+ this.disposeWithMe(this._shortcutService.registerShortcut(item));
1044
1033
  });
1045
1034
  }
1046
1035
  _init() {
1047
1036
  this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
1048
1037
  }
1049
- };
1050
- pe = ri([
1051
- ie(se.Rendered, pe),
1052
- me(1, W(nt)),
1053
- me(2, W(Hn)),
1054
- me(3, Xn),
1055
- me(4, V),
1056
- me(5, zn)
1057
- ], pe);
1058
- var si = Object.defineProperty, oi = Object.getOwnPropertyDescriptor, ai = (i, e, n, t) => {
1059
- for (var r = t > 1 ? void 0 : t ? oi(e, n) : e, s = i.length - 1, o; s >= 0; s--)
1060
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
1061
- return t && r && si(e, n, r), r;
1062
- }, ce = (i, e) => (n, t) => e(n, t, i);
1063
- const ci = [
1064
- It.id,
1065
- Rt.id,
1066
- Mt.id,
1067
- Dt.id,
1068
- bt.id,
1069
- Et.id,
1070
- yt.id,
1071
- Ot.id,
1072
- qe.id,
1073
- Qe.id,
1074
- Pt.id,
1075
- Tt.id,
1076
- Ut.id,
1077
- At.id,
1078
- Nt.id,
1079
- jt.id
1080
- ], di = [
1081
- Qn.id,
1082
- er.id,
1083
- tr.id,
1084
- nr.id,
1085
- rr.id,
1086
- ir.id
1038
+ }, __name(_a3, "SheetDrawingUIController"), _a3);
1039
+ SheetDrawingUIController = __decorateClass$6([
1040
+ OnLifecycle(LifecycleStages.Rendered, SheetDrawingUIController),
1041
+ __decorateParam$6(1, Inject(Injector)),
1042
+ __decorateParam$6(2, Inject(ComponentManager)),
1043
+ __decorateParam$6(3, IMenuService),
1044
+ __decorateParam$6(4, ICommandService),
1045
+ __decorateParam$6(5, IShortcutService)
1046
+ ], SheetDrawingUIController);
1047
+ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1048
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1049
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1050
+ return kind && result && __defProp$5(target, key, result), result;
1051
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5");
1052
+ const UPDATE_COMMANDS = [
1053
+ InsertRowCommand.id,
1054
+ InsertColCommand.id,
1055
+ RemoveRowCommand.id,
1056
+ RemoveColCommand.id,
1057
+ DeleteRangeMoveLeftCommand.id,
1058
+ DeleteRangeMoveUpCommand.id,
1059
+ InsertRangeMoveDownCommand.id,
1060
+ InsertRangeMoveRightCommand.id,
1061
+ DeltaRowHeightCommand.id,
1062
+ SetRowHeightCommand.id,
1063
+ DeltaColumnWidthCommand.id,
1064
+ SetColWidthCommand.id,
1065
+ SetRowHiddenCommand.id,
1066
+ SetSpecificRowsVisibleCommand.id,
1067
+ SetSpecificColsVisibleCommand.id,
1068
+ SetColHiddenCommand.id
1069
+ ], REFRESH_MUTATIONS = [
1070
+ SetRowVisibleMutation.id,
1071
+ SetRowHiddenMutation.id,
1072
+ SetColVisibleMutation.id,
1073
+ SetColHiddenMutation.id,
1074
+ SetWorksheetRowHeightMutation.id,
1075
+ SetWorksheetColWidthMutation.id
1087
1076
  ];
1088
- let Ae = class extends oe {
1089
- constructor(i, e, n, t, r, s) {
1090
- super(), this._commandService = i, this._sheetInterceptorService = e, this._renderManagerService = n, this._sheetDrawingService = t, this._drawingManagerService = r, this._univerInstanceService = s, this._init();
1091
- }
1092
- // TODO@wzhudev: selection render service would be a render unit, we we cannot
1093
- // easily access it here.
1094
- get _selectionRenderService() {
1095
- return this._renderManagerService.getRenderById(
1096
- this._univerInstanceService.getCurrentUnitForType(B.UNIVER_SHEET).getUnitId()
1097
- ).with(Ge);
1098
- }
1099
- get _skeletonManagerService() {
1100
- return this._renderManagerService.getRenderById(
1101
- this._univerInstanceService.getCurrentUnitForType(B.UNIVER_SHEET).getUnitId()
1102
- ).with(re);
1103
- }
1104
- _init() {
1105
- this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener();
1077
+ var _a4;
1078
+ let SheetDrawingTransformAffectedController = (_a4 = class extends Disposable {
1079
+ constructor(_context, _commandService, _selectionRenderService, _skeletonManagerService, _sheetInterceptorService, _sheetDrawingService, _drawingManagerService, _univerInstanceService) {
1080
+ super(), this._context = _context, this._commandService = _commandService, this._selectionRenderService = _selectionRenderService, this._skeletonManagerService = _skeletonManagerService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._univerInstanceService = _univerInstanceService, this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener();
1106
1081
  }
1107
1082
  _sheetInterceptorListener() {
1108
1083
  this.disposeWithMe(
1109
1084
  this._sheetInterceptorService.interceptCommand({
1110
- getMutations: (i) => {
1111
- if (!ci.includes(i.id))
1085
+ getMutations: /* @__PURE__ */ __name((commandInfo) => {
1086
+ if (!UPDATE_COMMANDS.includes(commandInfo.id))
1112
1087
  return { redos: [], undos: [] };
1113
- if (i.params == null)
1088
+ if (commandInfo.params == null)
1114
1089
  return { redos: [], undos: [] };
1115
- const e = i.id;
1116
- if (e === It.id)
1117
- return this._moveRowInterceptor(i.params, "insert");
1118
- if (e === Rt.id)
1119
- return this._moveColInterceptor(i.params, "insert");
1120
- if (e === Mt.id)
1121
- return this._moveRowInterceptor(i.params, "remove");
1122
- if (e === Dt.id)
1123
- return this._moveColInterceptor(i.params, "remove");
1124
- if (e === bt.id) {
1125
- const { range: n } = i.params;
1090
+ const cId = commandInfo.id;
1091
+ if (cId === InsertRowCommand.id)
1092
+ return this._moveRowInterceptor(commandInfo.params, "insert");
1093
+ if (cId === InsertColCommand.id)
1094
+ return this._moveColInterceptor(commandInfo.params, "insert");
1095
+ if (cId === RemoveRowCommand.id)
1096
+ return this._moveRowInterceptor(commandInfo.params, "remove");
1097
+ if (cId === RemoveColCommand.id)
1098
+ return this._moveColInterceptor(commandInfo.params, "remove");
1099
+ if (cId === DeleteRangeMoveLeftCommand.id) {
1100
+ const { range } = commandInfo.params;
1126
1101
  return this._getRangeMoveUndo(
1127
- n,
1102
+ range,
1128
1103
  0
1129
1104
  /* deleteLeft */
1130
1105
  );
1131
- } else if (e === Et.id) {
1132
- const { range: n } = i.params;
1106
+ } else if (cId === DeleteRangeMoveUpCommand.id) {
1107
+ const { range } = commandInfo.params;
1133
1108
  return this._getRangeMoveUndo(
1134
- n,
1109
+ range,
1135
1110
  1
1136
1111
  /* deleteUp */
1137
1112
  );
1138
- } else if (e === yt.id) {
1139
- const { range: n } = i.params;
1113
+ } else if (cId === InsertRangeMoveDownCommand.id) {
1114
+ const { range } = commandInfo.params;
1140
1115
  return this._getRangeMoveUndo(
1141
- n,
1116
+ range,
1142
1117
  2
1143
1118
  /* insertDown */
1144
1119
  );
1145
- } else if (e === Ot.id) {
1146
- const { range: n } = i.params;
1120
+ } else if (cId === InsertRangeMoveRightCommand.id) {
1121
+ const { range } = commandInfo.params;
1147
1122
  return this._getRangeMoveUndo(
1148
- n,
1123
+ range,
1149
1124
  3
1150
1125
  /* insertRight */
1151
1126
  );
1152
- } else if (e === Ut.id || e === At.id) {
1153
- const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n;
1154
- return this._getDrawingUndoForRowVisible(t, r, s);
1155
- } else if (e === Nt.id || e === jt.id) {
1156
- const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n;
1157
- return this._getDrawingUndoForColVisible(t, r, s);
1158
- } else if (e === qe.id || e === Qe.id || e === Pt.id || e === Tt.id) {
1159
- const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n, o = e === qe.id || e === Qe.id;
1160
- return this._getDrawingUndoForRowAndColSize(t, r, s, o);
1127
+ } else if (cId === SetRowHiddenCommand.id || cId === SetSpecificRowsVisibleCommand.id) {
1128
+ const params = commandInfo.params, { unitId, subUnitId, ranges } = params;
1129
+ return this._getDrawingUndoForRowVisible(unitId, subUnitId, ranges);
1130
+ } else if (cId === SetSpecificColsVisibleCommand.id || cId === SetColHiddenCommand.id) {
1131
+ const params = commandInfo.params, { unitId, subUnitId, ranges } = params;
1132
+ return this._getDrawingUndoForColVisible(unitId, subUnitId, ranges);
1133
+ } else if (cId === DeltaRowHeightCommand.id || cId === SetRowHeightCommand.id || cId === DeltaColumnWidthCommand.id || cId === SetColWidthCommand.id) {
1134
+ const params = commandInfo.params, { unitId, subUnitId, ranges } = params, isRow = cId === DeltaRowHeightCommand.id || cId === SetRowHeightCommand.id;
1135
+ return this._getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges, isRow);
1161
1136
  }
1162
1137
  return { redos: [], undos: [] };
1163
- }
1138
+ }, "getMutations")
1164
1139
  })
1165
1140
  );
1166
1141
  }
1167
- _getRangeMoveUndo(i, e) {
1168
- const n = le(this._univerInstanceService);
1169
- if (n == null)
1142
+ _getRangeMoveUndo(range, type) {
1143
+ const newParams = getSheetCommandTarget(this._univerInstanceService);
1144
+ if (newParams == null)
1170
1145
  return { redos: [], undos: [] };
1171
- const t = n.unitId, r = n.subUnitId, s = [], o = [], a = this._sheetDrawingService.getDrawingData(t, r), d = [], h = [];
1172
- if (Object.keys(a).forEach((l) => {
1173
- const c = a[l], { updateDrawings: u, deleteDrawings: g } = this._getUpdateOrDeleteDrawings(i, e, c);
1174
- d.push(...u), h.push(...g);
1175
- }), d.length === 0 && h.length === 0)
1146
+ const unitId = newParams.unitId, subUnitId = newParams.subUnitId, redos = [], undos = [], drawingData = this._sheetDrawingService.getDrawingData(unitId, subUnitId), updateDrawings = [], deleteDrawings = [];
1147
+ if (Object.keys(drawingData).forEach((drawingId) => {
1148
+ const drawing = drawingData[drawingId], { updateDrawings: updateDrawingsPart, deleteDrawings: deleteDrawingsPart } = this._getUpdateOrDeleteDrawings(range, type, drawing);
1149
+ updateDrawings.push(...updateDrawingsPart), deleteDrawings.push(...deleteDrawingsPart);
1150
+ }), updateDrawings.length === 0 && deleteDrawings.length === 0)
1176
1151
  return { redos: [], undos: [] };
1177
- if (d.length > 0) {
1178
- const l = this._sheetDrawingService.getBatchUpdateOp(d), { undo: c, redo: u, objects: g } = l;
1179
- s.push({ id: E.id, params: { unitId: t, subUnitId: r, op: u, objects: g, type: y.UPDATE } }), o.push({ id: E.id, params: { unitId: t, subUnitId: r, op: c, objects: g, type: y.UPDATE } });
1152
+ if (updateDrawings.length > 0) {
1153
+ const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
1154
+ redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
1180
1155
  }
1181
- if (h.length > 0) {
1182
- const l = this._sheetDrawingService.getBatchRemoveOp(h), c = l.undo, u = l.redo, g = l.objects;
1183
- s.push({ id: E.id, params: { unitId: t, subUnitId: r, op: u, objects: g, type: y.REMOVE } }), o.push({ id: E.id, params: { unitId: t, subUnitId: r, op: c, objects: g, type: y.INSERT } });
1156
+ if (deleteDrawings.length > 0) {
1157
+ const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings), deleteUndo = deleteJsonOp.undo, deleteRedo = deleteJsonOp.redo, deleteObjects = deleteJsonOp.objects;
1158
+ redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteRedo, objects: deleteObjects, type: DrawingApplyType.REMOVE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteUndo, objects: deleteObjects, type: DrawingApplyType.INSERT } });
1184
1159
  }
1185
- return s.push({ id: j.id, params: [t] }), o.push({ id: j.id, params: [t] }), {
1186
- redos: s,
1187
- undos: o
1160
+ return redos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), undos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), {
1161
+ redos,
1162
+ undos
1188
1163
  };
1189
1164
  }
1190
- _getUpdateOrDeleteDrawings(i, e, n) {
1191
- const t = [], r = [], { sheetTransform: s, anchorType: o = O.Position, transform: a, unitId: d, subUnitId: h, drawingId: l } = n, { from: c, to: u } = s, { row: g, column: f } = c, { row: m, column: p } = u;
1192
- if (s == null || a == null)
1165
+ _getUpdateOrDeleteDrawings(range, type, drawing) {
1166
+ const updateDrawings = [], deleteDrawings = [], { sheetTransform, anchorType = SheetDrawingAnchorType.Position, transform, unitId, subUnitId, drawingId } = drawing, { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1167
+ if (sheetTransform == null || transform == null)
1193
1168
  return {
1194
- updateDrawings: t,
1195
- deleteDrawings: r
1169
+ updateDrawings,
1170
+ deleteDrawings
1196
1171
  };
1197
- const { startRow: S, endRow: C, startColumn: v, endColumn: R } = i;
1198
- let _ = null, b = null;
1199
- if (e === 0 && g >= S && m <= C)
1200
- if (f >= v && p <= R)
1201
- r.push({ unitId: d, subUnitId: h, drawingId: l });
1172
+ const { startRow, endRow, startColumn, endColumn } = range;
1173
+ let newSheetTransform = null, newTransform = null;
1174
+ if (type === 0 && fromRow >= startRow && toRow <= endRow)
1175
+ if (fromColumn >= startColumn && toColumn <= endColumn)
1176
+ deleteDrawings.push({ unitId, subUnitId, drawingId });
1202
1177
  else {
1203
- const w = this._shrinkCol(s, a, v, R, o);
1204
- _ = w == null ? void 0 : w.newSheetTransform, b = w == null ? void 0 : w.newTransform;
1178
+ const param = this._shrinkCol(sheetTransform, transform, startColumn, endColumn, anchorType);
1179
+ newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1205
1180
  }
1206
- else if (e === 1 && f >= v && p <= R)
1207
- if (g >= S && m <= C)
1208
- r.push({ unitId: d, subUnitId: h, drawingId: l });
1181
+ else if (type === 1 && fromColumn >= startColumn && toColumn <= endColumn)
1182
+ if (fromRow >= startRow && toRow <= endRow)
1183
+ deleteDrawings.push({ unitId, subUnitId, drawingId });
1209
1184
  else {
1210
- const w = this._shrinkRow(s, a, S, C, o);
1211
- _ = w == null ? void 0 : w.newSheetTransform, b = w == null ? void 0 : w.newTransform;
1185
+ const param = this._shrinkRow(sheetTransform, transform, startRow, endRow, anchorType);
1186
+ newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1212
1187
  }
1213
- else if (e === 2) {
1214
- const w = this._expandRow(s, a, S, C, o);
1215
- _ = w == null ? void 0 : w.newSheetTransform, b = w == null ? void 0 : w.newTransform;
1216
- } else if (e === 3) {
1217
- const w = this._expandCol(s, a, v, R, o);
1218
- _ = w == null ? void 0 : w.newSheetTransform, b = w == null ? void 0 : w.newTransform;
1188
+ else if (type === 2) {
1189
+ const param = this._expandRow(sheetTransform, transform, startRow, endRow, anchorType);
1190
+ newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1191
+ } else if (type === 3) {
1192
+ const param = this._expandCol(sheetTransform, transform, startColumn, endColumn, anchorType);
1193
+ newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1219
1194
  }
1220
- if (_ != null && b != null) {
1221
- const w = $(_, this._selectionRenderService, this._skeletonManagerService);
1222
- t.push({ ...n, sheetTransform: _, transform: w });
1195
+ if (newSheetTransform != null && newTransform != null) {
1196
+ const newTransform2 = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1197
+ updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform2 });
1223
1198
  }
1224
- return { updateDrawings: t, deleteDrawings: r };
1199
+ return { updateDrawings, deleteDrawings };
1225
1200
  }
1226
- _remainDrawingSize(i, e, n) {
1227
- const t = N({ ...i }, this._selectionRenderService);
1228
- t != null && e.push({
1229
- ...n,
1230
- sheetTransform: t
1201
+ _remainDrawingSize(transform, updateDrawings, drawing) {
1202
+ const newSheetTransform = transformToDrawingPosition({ ...transform }, this._selectionRenderService);
1203
+ newSheetTransform != null && updateDrawings.push({
1204
+ ...drawing,
1205
+ sheetTransform: newSheetTransform
1231
1206
  });
1232
1207
  }
1233
1208
  // eslint-disable-next-line max-lines-per-function
1234
- _getDrawingUndoForColVisible(i, e, n) {
1235
- const t = this._drawingManagerService.getDrawingData(i, e), r = [], s = [];
1236
- if (Object.keys(t).forEach((l) => {
1237
- const c = t[l], { sheetTransform: u, transform: g, anchorType: f = O.Position } = c;
1238
- if (f === O.None)
1239
- this._remainDrawingSize(g, r, c);
1209
+ _getDrawingUndoForColVisible(unitId, subUnitId, ranges) {
1210
+ const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [], preUpdateDrawings = [];
1211
+ if (Object.keys(drawingData).forEach((drawingId) => {
1212
+ const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1213
+ if (anchorType === SheetDrawingAnchorType.None)
1214
+ this._remainDrawingSize(transform, updateDrawings, drawing);
1240
1215
  else {
1241
- const { from: m, to: p } = u, { row: S, column: C } = m, { row: v, column: R } = p;
1242
- for (let _ = 0; _ < n.length; _++) {
1243
- const b = n[_], { startRow: w, endRow: P, startColumn: D, endColumn: T } = b;
1244
- if (R < D)
1216
+ const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1217
+ for (let i = 0; i < ranges.length; i++) {
1218
+ const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
1219
+ if (toColumn < startColumn)
1245
1220
  continue;
1246
- if (f === O.Position) {
1247
- let I = null, A = null;
1248
- if (C >= D && C <= T) {
1249
- const G = this._skeletonManagerService.attachRangeWithCoord({ startColumn: C, endColumn: T, startRow: m.row, endRow: p.row });
1250
- if (G == null)
1221
+ if (anchorType === SheetDrawingAnchorType.Position) {
1222
+ let newSheetTransform2 = null, newTransform2 = null;
1223
+ if (fromColumn >= startColumn && fromColumn <= endColumn) {
1224
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: fromColumn, endColumn, startRow: from.row, endRow: to.row });
1225
+ if (selectionCell == null)
1251
1226
  return;
1252
- A = { ...g, left: G.startX };
1227
+ newTransform2 = { ...transform, left: selectionCell.startX };
1253
1228
  }
1254
- if (A != null && (I = N(A, this._selectionRenderService), I != null && A != null)) {
1255
- r.push({ ...c, sheetTransform: I, transform: A });
1229
+ if (newTransform2 != null && (newSheetTransform2 = transformToDrawingPosition(newTransform2, this._selectionRenderService), newSheetTransform2 != null && newTransform2 != null)) {
1230
+ updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform2, transform: newTransform2 });
1256
1231
  break;
1257
1232
  }
1258
- this._remainDrawingSize(g, r, c);
1233
+ this._remainDrawingSize(transform, updateDrawings, drawing);
1259
1234
  continue;
1260
1235
  }
1261
- if (C >= D && R <= T)
1236
+ if (fromColumn >= startColumn && toColumn <= endColumn)
1262
1237
  continue;
1263
- let U = null, M = null;
1264
- if (C >= D && C <= T) {
1265
- const I = this._skeletonManagerService.attachRangeWithCoord({ startColumn: C, endColumn: T, startRow: m.row, endRow: p.row });
1266
- if (I == null)
1238
+ let newSheetTransform = null, newTransform = null;
1239
+ if (fromColumn >= startColumn && fromColumn <= endColumn) {
1240
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: fromColumn, endColumn, startRow: from.row, endRow: to.row });
1241
+ if (selectionCell == null)
1267
1242
  return;
1268
- M = {
1269
- ...g,
1270
- left: (I == null ? void 0 : I.startX) || 0,
1271
- width: ((g == null ? void 0 : g.width) || 0) - I.endX + I.startX
1243
+ newTransform = {
1244
+ ...transform,
1245
+ left: (selectionCell == null ? void 0 : selectionCell.startX) || 0,
1246
+ width: ((transform == null ? void 0 : transform.width) || 0) - selectionCell.endX + selectionCell.startX
1272
1247
  };
1273
- } else if (R >= D && R <= T) {
1274
- const I = this._skeletonManagerService.attachRangeWithCoord({ startColumn: D, endColumn: R, startRow: m.row, endRow: p.row });
1275
- if (I == null)
1248
+ } else if (toColumn >= startColumn && toColumn <= endColumn) {
1249
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn, endColumn: toColumn, startRow: from.row, endRow: to.row });
1250
+ if (selectionCell == null)
1276
1251
  return;
1277
- M = {
1278
- ...g,
1279
- left: I.startX - ((g == null ? void 0 : g.width) || 0)
1252
+ newTransform = {
1253
+ ...transform,
1254
+ left: selectionCell.startX - ((transform == null ? void 0 : transform.width) || 0)
1280
1255
  };
1281
1256
  } else {
1282
- const I = this._skeletonManagerService.attachRangeWithCoord({ startColumn: D, endColumn: T, startRow: m.row, endRow: p.row });
1283
- if (I == null)
1257
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn, endColumn, startRow: from.row, endRow: to.row });
1258
+ if (selectionCell == null)
1284
1259
  return;
1285
- if (M = {
1286
- ...g,
1287
- width: ((g == null ? void 0 : g.width) || 0) - I.endX + I.startX
1288
- }, U = N(M, this._selectionRenderService), U != null && M != null) {
1289
- s.push({ ...c, sheetTransform: U, transform: M });
1260
+ if (newTransform = {
1261
+ ...transform,
1262
+ width: ((transform == null ? void 0 : transform.width) || 0) - selectionCell.endX + selectionCell.startX
1263
+ }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService), newSheetTransform != null && newTransform != null) {
1264
+ preUpdateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
1290
1265
  break;
1291
1266
  }
1292
1267
  }
1293
- if (M != null && (U = N(M, this._selectionRenderService)), M != null && U != null) {
1294
- r.push({ ...c, sheetTransform: U, transform: M });
1268
+ if (newTransform != null && (newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService)), newTransform != null && newSheetTransform != null) {
1269
+ updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
1295
1270
  break;
1296
1271
  } else
1297
- this._remainDrawingSize(g, r, c);
1272
+ this._remainDrawingSize(transform, updateDrawings, drawing);
1298
1273
  }
1299
1274
  }
1300
- }), r.length === 0 && s.length === 0)
1275
+ }), updateDrawings.length === 0 && preUpdateDrawings.length === 0)
1301
1276
  return { redos: [], undos: [] };
1302
- const { redos: o, undos: a } = this._createUndoAndRedoMutation(i, e, r), d = [], h = [];
1303
- if (s.length > 0) {
1304
- const { redos: l, undos: c } = this._createUndoAndRedoMutation(i, e, s);
1305
- d.push(...l), h.push(...c);
1277
+ const { redos, undos } = this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings), preRedos = [], preUndos = [];
1278
+ if (preUpdateDrawings.length > 0) {
1279
+ const { redos: redos2, undos: undos2 } = this._createUndoAndRedoMutation(unitId, subUnitId, preUpdateDrawings);
1280
+ preRedos.push(...redos2), preUndos.push(...undos2);
1306
1281
  }
1307
1282
  return {
1308
- redos: o,
1309
- undos: a,
1310
- preRedos: d,
1311
- preUndos: h
1283
+ redos,
1284
+ undos,
1285
+ preRedos,
1286
+ preUndos
1312
1287
  };
1313
1288
  }
1314
- _createUndoAndRedoMutation(i, e, n) {
1315
- const t = this._sheetDrawingService.getBatchUpdateOp(n), { undo: r, redo: s, objects: o } = t, a = [
1316
- { id: E.id, params: { unitId: i, subUnitId: e, op: s, objects: o, type: y.UPDATE } },
1317
- { id: j.id, params: [i] }
1318
- ], d = [
1319
- { id: E.id, params: { unitId: i, subUnitId: e, op: r, objects: o, type: y.UPDATE } },
1320
- { id: j.id, params: [i] }
1289
+ _createUndoAndRedoMutation(unitId, subUnitId, updateDrawings) {
1290
+ const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp, redos = [
1291
+ { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } },
1292
+ { id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
1293
+ ], undos = [
1294
+ { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } },
1295
+ { id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
1321
1296
  ];
1322
1297
  return {
1323
- redos: a,
1324
- undos: d
1298
+ redos,
1299
+ undos
1325
1300
  };
1326
1301
  }
1327
1302
  // eslint-disable-next-line max-lines-per-function
1328
- _getDrawingUndoForRowVisible(i, e, n) {
1329
- const t = this._drawingManagerService.getDrawingData(i, e), r = [], s = [];
1330
- if (Object.keys(t).forEach((l) => {
1331
- const c = t[l], { sheetTransform: u, transform: g, anchorType: f = O.Position } = c;
1332
- if (f === O.None)
1333
- this._remainDrawingSize(g, r, c);
1303
+ _getDrawingUndoForRowVisible(unitId, subUnitId, ranges) {
1304
+ const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [], preUpdateDrawings = [];
1305
+ if (Object.keys(drawingData).forEach((drawingId) => {
1306
+ const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1307
+ if (anchorType === SheetDrawingAnchorType.None)
1308
+ this._remainDrawingSize(transform, updateDrawings, drawing);
1334
1309
  else {
1335
- const { from: m, to: p } = u, { row: S, column: C } = m, { row: v, column: R } = p;
1336
- for (let _ = 0; _ < n.length; _++) {
1337
- const b = n[_], { startRow: w, endRow: P, startColumn: D, endColumn: T } = b;
1338
- if (v < w)
1310
+ const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1311
+ for (let i = 0; i < ranges.length; i++) {
1312
+ const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
1313
+ if (toRow < startRow)
1339
1314
  continue;
1340
- if (f === O.Position) {
1341
- let I = null, A = null;
1342
- if (S >= w && S <= P) {
1343
- const G = this._skeletonManagerService.attachRangeWithCoord({ startColumn: m.column, endColumn: p.column, startRow: S, endRow: P });
1344
- if (G == null)
1315
+ if (anchorType === SheetDrawingAnchorType.Position) {
1316
+ let newSheetTransform2 = null, newTransform2 = null;
1317
+ if (fromRow >= startRow && fromRow <= endRow) {
1318
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow: fromRow, endRow });
1319
+ if (selectionCell == null)
1345
1320
  return;
1346
- A = { ...g, top: G.startY };
1321
+ newTransform2 = { ...transform, top: selectionCell.startY };
1347
1322
  }
1348
- if (A != null && (I = N(A, this._selectionRenderService), I != null && A != null)) {
1349
- r.push({ ...c, sheetTransform: I, transform: A });
1323
+ if (newTransform2 != null && (newSheetTransform2 = transformToDrawingPosition(newTransform2, this._selectionRenderService), newSheetTransform2 != null && newTransform2 != null)) {
1324
+ updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform2, transform: newTransform2 });
1350
1325
  break;
1351
1326
  }
1352
- this._remainDrawingSize(g, r, c);
1327
+ this._remainDrawingSize(transform, updateDrawings, drawing);
1353
1328
  continue;
1354
1329
  }
1355
- if (S >= w && v <= P)
1330
+ if (fromRow >= startRow && toRow <= endRow)
1356
1331
  continue;
1357
- let U = null, M = null;
1358
- if (S >= w && S <= P) {
1359
- const I = this._skeletonManagerService.attachRangeWithCoord({ startColumn: m.column, endColumn: p.column, startRow: S, endRow: P });
1360
- if (I == null)
1332
+ let newSheetTransform = null, newTransform = null;
1333
+ if (fromRow >= startRow && fromRow <= endRow) {
1334
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow: fromRow, endRow });
1335
+ if (selectionCell == null)
1361
1336
  return;
1362
- M = {
1363
- ...g,
1364
- top: (I == null ? void 0 : I.startY) || 0,
1365
- height: ((g == null ? void 0 : g.height) || 0) - I.endY + I.startY
1337
+ newTransform = {
1338
+ ...transform,
1339
+ top: (selectionCell == null ? void 0 : selectionCell.startY) || 0,
1340
+ height: ((transform == null ? void 0 : transform.height) || 0) - selectionCell.endY + selectionCell.startY
1366
1341
  };
1367
- } else if (v >= w && v <= P) {
1368
- const I = this._skeletonManagerService.attachRangeWithCoord({ startColumn: m.column, endColumn: p.column, startRow: w, endRow: v });
1369
- if (I == null)
1342
+ } else if (toRow >= startRow && toRow <= endRow) {
1343
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow, endRow: toRow });
1344
+ if (selectionCell == null)
1370
1345
  return;
1371
- M = {
1372
- ...g,
1373
- top: I.startY - ((g == null ? void 0 : g.height) || 0)
1346
+ newTransform = {
1347
+ ...transform,
1348
+ top: selectionCell.startY - ((transform == null ? void 0 : transform.height) || 0)
1374
1349
  };
1375
1350
  } else {
1376
- const I = this._skeletonManagerService.attachRangeWithCoord({ startColumn: m.column, endColumn: p.column, startRow: w, endRow: P });
1377
- if (I == null)
1351
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow, endRow });
1352
+ if (selectionCell == null)
1378
1353
  return;
1379
- if (M = {
1380
- ...g,
1381
- height: ((g == null ? void 0 : g.height) || 0) - I.endY + I.startY
1382
- }, U = N(M, this._selectionRenderService), U != null && M != null) {
1383
- s.push({ ...c, sheetTransform: U, transform: M });
1354
+ if (newTransform = {
1355
+ ...transform,
1356
+ height: ((transform == null ? void 0 : transform.height) || 0) - selectionCell.endY + selectionCell.startY
1357
+ }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService), newSheetTransform != null && newTransform != null) {
1358
+ preUpdateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
1384
1359
  break;
1385
1360
  }
1386
1361
  }
1387
- if (M != null && (U = N(M, this._selectionRenderService)), M != null && U != null) {
1388
- r.push({ ...c, sheetTransform: U, transform: M });
1362
+ if (newTransform != null && (newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService)), newTransform != null && newSheetTransform != null) {
1363
+ updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
1389
1364
  break;
1390
1365
  } else
1391
- this._remainDrawingSize(g, r, c);
1366
+ this._remainDrawingSize(transform, updateDrawings, drawing);
1392
1367
  }
1393
1368
  }
1394
- }), r.length === 0 && s.length === 0)
1369
+ }), updateDrawings.length === 0 && preUpdateDrawings.length === 0)
1395
1370
  return { redos: [], undos: [] };
1396
- const { redos: o, undos: a } = this._createUndoAndRedoMutation(i, e, r), d = [], h = [];
1397
- if (s.length > 0) {
1398
- const { redos: l, undos: c } = this._createUndoAndRedoMutation(i, e, s);
1399
- d.push(...l), h.push(...c);
1371
+ const { redos, undos } = this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings), preRedos = [], preUndos = [];
1372
+ if (preUpdateDrawings.length > 0) {
1373
+ const { redos: redos2, undos: undos2 } = this._createUndoAndRedoMutation(unitId, subUnitId, preUpdateDrawings);
1374
+ preRedos.push(...redos2), preUndos.push(...undos2);
1400
1375
  }
1401
1376
  return {
1402
- redos: o,
1403
- undos: a,
1404
- preRedos: d,
1405
- preUndos: h
1377
+ redos,
1378
+ undos,
1379
+ preRedos,
1380
+ preUndos
1406
1381
  };
1407
1382
  }
1408
- _getDrawingUndoForRowAndColSize(i, e, n, t) {
1409
- const r = this._drawingManagerService.getDrawingData(i, e), s = [];
1410
- return Object.keys(r).forEach((o) => {
1411
- const a = r[o], { sheetTransform: d, transform: h, anchorType: l = O.Position } = a;
1412
- if (l === O.None)
1413
- this._remainDrawingSize(h, s, a);
1383
+ _getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges, isRow) {
1384
+ const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [];
1385
+ return Object.keys(drawingData).forEach((drawingId) => {
1386
+ const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1387
+ if (anchorType === SheetDrawingAnchorType.None)
1388
+ this._remainDrawingSize(transform, updateDrawings, drawing);
1414
1389
  else {
1415
- const { from: c, to: u } = d, { row: g, column: f } = c, { row: m, column: p } = u;
1416
- for (let S = 0; S < n.length; S++) {
1417
- const C = n[S], { startRow: v, endRow: R, startColumn: _, endColumn: b } = C;
1418
- if (m < v || p < _)
1390
+ const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1391
+ for (let i = 0; i < ranges.length; i++) {
1392
+ const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
1393
+ if (toRow < startRow || toColumn < startColumn)
1419
1394
  continue;
1420
- if (l === O.Position && (g <= v && m >= R || f <= _ && p >= b)) {
1421
- this._remainDrawingSize(h, s, a);
1395
+ if (anchorType === SheetDrawingAnchorType.Position && (fromRow <= startRow && toRow >= endRow || fromColumn <= startColumn && toColumn >= endColumn)) {
1396
+ this._remainDrawingSize(transform, updateDrawings, drawing);
1422
1397
  continue;
1423
1398
  }
1424
- const w = $(
1425
- { ...d },
1399
+ const newTransform = drawingPositionToTransform(
1400
+ { ...sheetTransform },
1426
1401
  this._selectionRenderService,
1427
1402
  this._skeletonManagerService
1428
1403
  );
1429
- if (w != null) {
1430
- s.push({
1431
- ...a,
1432
- transform: w
1404
+ if (newTransform != null) {
1405
+ updateDrawings.push({
1406
+ ...drawing,
1407
+ transform: newTransform
1433
1408
  });
1434
1409
  break;
1435
1410
  }
1436
1411
  }
1437
1412
  }
1438
- }), s.length === 0 ? { redos: [], undos: [] } : this._createUndoAndRedoMutation(i, e, s);
1413
+ }), updateDrawings.length === 0 ? { redos: [], undos: [] } : this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings);
1439
1414
  }
1440
- _getUnitIdAndSubUnitId(i, e) {
1441
- let n, t;
1442
- if (e === "insert")
1443
- n = i.unitId, t = i.subUnitId;
1415
+ _getUnitIdAndSubUnitId(params, type) {
1416
+ let unitId, subUnitId;
1417
+ if (type === "insert")
1418
+ unitId = params.unitId, subUnitId = params.subUnitId;
1444
1419
  else {
1445
- const r = le(this._univerInstanceService);
1446
- if (r == null)
1420
+ const newParams = getSheetCommandTarget(this._univerInstanceService);
1421
+ if (newParams == null)
1447
1422
  return;
1448
- n = r.unitId, t = r.subUnitId;
1423
+ unitId = newParams.unitId, subUnitId = newParams.subUnitId;
1449
1424
  }
1450
- return { unitId: n, subUnitId: t };
1425
+ return { unitId, subUnitId };
1451
1426
  }
1452
- _moveRowInterceptor(i, e) {
1453
- const n = this._getUnitIdAndSubUnitId(i, e);
1454
- if (n == null)
1427
+ _moveRowInterceptor(params, type) {
1428
+ const ids = this._getUnitIdAndSubUnitId(params, type);
1429
+ if (ids == null)
1455
1430
  return { redos: [], undos: [] };
1456
- const { unitId: t, subUnitId: r } = n, { range: s } = i, o = s.startRow, a = s.endRow, d = [], h = [], l = this._sheetDrawingService.getDrawingData(t, r), c = [], u = [];
1457
- if (Object.keys(l).forEach((g) => {
1458
- const f = l[g], { sheetTransform: m, transform: p, anchorType: S = O.Position } = f;
1459
- if (m == null || p == null)
1431
+ const { unitId, subUnitId } = ids, { range } = params, rowStartIndex = range.startRow, rowEndIndex = range.endRow, redos = [], undos = [], data = this._sheetDrawingService.getDrawingData(unitId, subUnitId), updateDrawings = [], deleteDrawings = [];
1432
+ if (Object.keys(data).forEach((drawingId) => {
1433
+ const drawing = data[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1434
+ if (sheetTransform == null || transform == null)
1460
1435
  return;
1461
- let C, v;
1462
- if (e === "insert") {
1463
- const _ = this._expandRow(m, p, o, a, S);
1464
- C = _ == null ? void 0 : _.newSheetTransform, v = _ == null ? void 0 : _.newTransform;
1436
+ let newSheetTransform, newTransform;
1437
+ if (type === "insert") {
1438
+ const param = this._expandRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType);
1439
+ newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1465
1440
  } else {
1466
- const { from: _, to: b } = m, { row: w } = _, { row: P } = b;
1467
- if (w >= o && P <= a)
1468
- u.push({ unitId: t, subUnitId: r, drawingId: g });
1441
+ const { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
1442
+ if (fromRow >= rowStartIndex && toRow <= rowEndIndex)
1443
+ deleteDrawings.push({ unitId, subUnitId, drawingId });
1469
1444
  else {
1470
- const D = this._shrinkRow(m, p, o, a, S);
1471
- C = D == null ? void 0 : D.newSheetTransform, v = D == null ? void 0 : D.newTransform;
1445
+ const param = this._shrinkRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType);
1446
+ newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1472
1447
  }
1473
1448
  }
1474
- if (!C || !v)
1449
+ if (!newSheetTransform || !newTransform)
1475
1450
  return;
1476
- const R = { unitId: t, subUnitId: r, drawingId: g, transform: v, sheetTransform: C };
1477
- c.push(R);
1478
- }), c.length === 0 && u.length === 0)
1451
+ const params2 = { unitId, subUnitId, drawingId, transform: newTransform, sheetTransform: newSheetTransform };
1452
+ updateDrawings.push(params2);
1453
+ }), updateDrawings.length === 0 && deleteDrawings.length === 0)
1479
1454
  return { redos: [], undos: [] };
1480
- if (c.length > 0) {
1481
- const g = this._sheetDrawingService.getBatchUpdateOp(c), { undo: f, redo: m, objects: p } = g;
1482
- d.push({ id: E.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: y.UPDATE } }), h.push({ id: E.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: y.UPDATE } });
1455
+ if (updateDrawings.length > 0) {
1456
+ const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
1457
+ redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
1483
1458
  }
1484
- if (u.length > 0) {
1485
- const g = this._sheetDrawingService.getBatchRemoveOp(u), f = g.undo, m = g.redo, p = g.objects;
1486
- d.push({ id: E.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: y.REMOVE } }), h.push({ id: E.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: y.INSERT } });
1459
+ if (deleteDrawings.length > 0) {
1460
+ const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings), deleteUndo = deleteJsonOp.undo, deleteRedo = deleteJsonOp.redo, deleteObjects = deleteJsonOp.objects;
1461
+ redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteRedo, objects: deleteObjects, type: DrawingApplyType.REMOVE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteUndo, objects: deleteObjects, type: DrawingApplyType.INSERT } });
1487
1462
  }
1488
- return d.push({ id: j.id, params: [t] }), h.push({ id: j.id, params: [t] }), {
1489
- redos: d,
1490
- undos: h
1463
+ return redos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), undos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), {
1464
+ redos,
1465
+ undos
1491
1466
  };
1492
1467
  }
1493
- _moveColInterceptor(i, e) {
1494
- const n = this._getUnitIdAndSubUnitId(i, e);
1495
- if (n == null)
1468
+ _moveColInterceptor(params, type) {
1469
+ const ids = this._getUnitIdAndSubUnitId(params, type);
1470
+ if (ids == null)
1496
1471
  return { redos: [], undos: [] };
1497
- const { unitId: t, subUnitId: r } = n, { range: s } = i, o = s.startColumn, a = s.endColumn, d = [], h = [], l = this._sheetDrawingService.getDrawingData(t, r), c = [], u = [];
1498
- if (Object.keys(l).forEach((g) => {
1499
- const f = l[g], { sheetTransform: m, transform: p, anchorType: S = O.Position } = f;
1500
- if (m == null || p == null)
1472
+ const { unitId, subUnitId } = ids, { range } = params, colStartIndex = range.startColumn, colEndIndex = range.endColumn, redos = [], undos = [], data = this._sheetDrawingService.getDrawingData(unitId, subUnitId), updateDrawings = [], deleteDrawings = [];
1473
+ if (Object.keys(data).forEach((drawingId) => {
1474
+ const drawing = data[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1475
+ if (sheetTransform == null || transform == null)
1501
1476
  return;
1502
- let C, v;
1503
- if (e === "insert") {
1504
- const _ = this._expandCol(m, p, o, a, S);
1505
- C = _ == null ? void 0 : _.newSheetTransform, v = _ == null ? void 0 : _.newTransform;
1477
+ let newSheetTransform, newTransform;
1478
+ if (type === "insert") {
1479
+ const param = this._expandCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType);
1480
+ newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1506
1481
  } else {
1507
- const { from: _, to: b } = m, { column: w } = _, { column: P } = b;
1508
- if (w >= o && P <= a)
1509
- u.push({ unitId: t, subUnitId: r, drawingId: g });
1482
+ const { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
1483
+ if (fromColumn >= colStartIndex && toColumn <= colEndIndex)
1484
+ deleteDrawings.push({ unitId, subUnitId, drawingId });
1510
1485
  else {
1511
- const D = this._shrinkCol(m, p, o, a, S);
1512
- C = D == null ? void 0 : D.newSheetTransform, v = D == null ? void 0 : D.newTransform;
1486
+ const param = this._shrinkCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType);
1487
+ newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1513
1488
  }
1514
1489
  }
1515
- if (!C || !v)
1490
+ if (!newSheetTransform || !newTransform)
1516
1491
  return;
1517
- const R = { unitId: t, subUnitId: r, drawingId: g, transform: v, sheetTransform: C };
1518
- c.push(R);
1519
- }), c.length === 0 && u.length === 0)
1492
+ const params2 = { unitId, subUnitId, drawingId, transform: newTransform, sheetTransform: newSheetTransform };
1493
+ updateDrawings.push(params2);
1494
+ }), updateDrawings.length === 0 && deleteDrawings.length === 0)
1520
1495
  return { redos: [], undos: [] };
1521
- if (c.length > 0) {
1522
- const g = this._sheetDrawingService.getBatchUpdateOp(c), { undo: f, redo: m, objects: p } = g;
1523
- d.push({ id: E.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: y.UPDATE } }), h.push({ id: E.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: y.UPDATE } });
1496
+ if (updateDrawings.length > 0) {
1497
+ const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
1498
+ redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
1524
1499
  }
1525
- if (u.length > 0) {
1526
- const g = this._sheetDrawingService.getBatchRemoveOp(u), f = g.undo, m = g.redo, p = g.objects;
1527
- d.push({ id: E.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: y.REMOVE } }), h.push({ id: E.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: y.INSERT } });
1500
+ if (deleteDrawings.length > 0) {
1501
+ const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings), deleteUndo = deleteJsonOp.undo, deleteRedo = deleteJsonOp.redo, deleteObjects = deleteJsonOp.objects;
1502
+ redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteRedo, objects: deleteObjects, type: DrawingApplyType.REMOVE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteUndo, objects: deleteObjects, type: DrawingApplyType.INSERT } });
1528
1503
  }
1529
- return d.push({ id: j.id, params: [t] }), h.push({ id: j.id, params: [t] }), { redos: d, undos: h };
1504
+ return redos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), undos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), { redos, undos };
1530
1505
  }
1531
- _expandCol(i, e, n, t, r = O.Position) {
1532
- const s = t - n + 1, { from: o, to: a } = i, { column: d } = o, { column: h } = a;
1533
- if (r === O.None)
1506
+ _expandCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType = SheetDrawingAnchorType.Position) {
1507
+ const colCount = colEndIndex - colStartIndex + 1, { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
1508
+ if (anchorType === SheetDrawingAnchorType.None)
1534
1509
  return {
1535
- newSheetTransform: N({ ...e }, this._selectionRenderService),
1536
- newTransform: e
1510
+ newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1511
+ newTransform: transform
1537
1512
  };
1538
- let l = null, c = null;
1539
- if (d >= n) {
1540
- const u = this._skeletonManagerService.attachRangeWithCoord({ startColumn: n, endColumn: t, startRow: o.row, endRow: a.row });
1541
- if (u == null)
1513
+ let newSheetTransform = null, newTransform = null;
1514
+ if (fromColumn >= colStartIndex) {
1515
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: colStartIndex, endColumn: colEndIndex, startRow: from.row, endRow: to.row });
1516
+ if (selectionCell == null)
1542
1517
  return;
1543
- c = { ...e, left: (e.left || 0) + u.endX - u.startX }, l = N(c, this._selectionRenderService);
1544
- } else if (h >= t)
1545
- if (r === O.Both)
1546
- l = {
1547
- from: { ...o },
1548
- to: { ...a, column: h + s }
1549
- }, c = $(l, this._selectionRenderService, this._skeletonManagerService);
1518
+ newTransform = { ...transform, left: (transform.left || 0) + selectionCell.endX - selectionCell.startX }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
1519
+ } else if (toColumn >= colEndIndex)
1520
+ if (anchorType === SheetDrawingAnchorType.Both)
1521
+ newSheetTransform = {
1522
+ from: { ...from },
1523
+ to: { ...to, column: toColumn + colCount }
1524
+ }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1550
1525
  else
1551
1526
  return {
1552
- newSheetTransform: N({ ...e }, this._selectionRenderService),
1553
- newTransform: e
1527
+ newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1528
+ newTransform: transform
1554
1529
  };
1555
- return l != null && c != null ? {
1556
- newSheetTransform: l,
1557
- newTransform: c
1530
+ return newSheetTransform != null && newTransform != null ? {
1531
+ newSheetTransform,
1532
+ newTransform
1558
1533
  } : null;
1559
1534
  }
1560
- _shrinkCol(i, e, n, t, r = O.Position) {
1561
- const s = t - n + 1, { from: o, to: a } = i, { column: d } = o, { column: h } = a;
1562
- if (r === O.None)
1535
+ _shrinkCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType = SheetDrawingAnchorType.Position) {
1536
+ const colCount = colEndIndex - colStartIndex + 1, { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
1537
+ if (anchorType === SheetDrawingAnchorType.None)
1563
1538
  return {
1564
- newSheetTransform: N({ ...e }, this._selectionRenderService),
1565
- newTransform: e
1539
+ newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1540
+ newTransform: transform
1566
1541
  };
1567
- let l = null, c = null;
1568
- if (d > t)
1569
- l = {
1570
- from: { ...o, column: d - s },
1571
- to: { ...a, column: h - s }
1572
- }, c = $(l, this._selectionRenderService, this._skeletonManagerService);
1542
+ let newSheetTransform = null, newTransform = null;
1543
+ if (fromColumn > colEndIndex)
1544
+ newSheetTransform = {
1545
+ from: { ...from, column: fromColumn - colCount },
1546
+ to: { ...to, column: toColumn - colCount }
1547
+ }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1573
1548
  else {
1574
- if (d >= n && h <= t)
1549
+ if (fromColumn >= colStartIndex && toColumn <= colEndIndex)
1575
1550
  return null;
1576
- if (d < n && h > t)
1577
- if (r === O.Both)
1578
- l = {
1579
- from: { ...o },
1580
- to: { ...a, column: h - s }
1581
- }, c = $(l, this._selectionRenderService, this._skeletonManagerService);
1551
+ if (fromColumn < colStartIndex && toColumn > colEndIndex)
1552
+ if (anchorType === SheetDrawingAnchorType.Both)
1553
+ newSheetTransform = {
1554
+ from: { ...from },
1555
+ to: { ...to, column: toColumn - colCount }
1556
+ }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1582
1557
  else
1583
1558
  return {
1584
- newSheetTransform: N({ ...e }, this._selectionRenderService),
1585
- newTransform: e
1559
+ newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1560
+ newTransform: transform
1586
1561
  };
1587
- else if (d >= n && d <= t) {
1588
- if (d === n)
1589
- c = { ...e, left: (e.left || 0) - i.from.columnOffset };
1562
+ else if (fromColumn >= colStartIndex && fromColumn <= colEndIndex) {
1563
+ if (fromColumn === colStartIndex)
1564
+ newTransform = { ...transform, left: (transform.left || 0) - sheetTransform.from.columnOffset };
1590
1565
  else {
1591
- const u = this._skeletonManagerService.attachRangeWithCoord({ startColumn: n, endColumn: d - 1, startRow: o.row, endRow: a.row });
1592
- if (u == null)
1566
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: colStartIndex, endColumn: fromColumn - 1, startRow: from.row, endRow: to.row });
1567
+ if (selectionCell == null)
1593
1568
  return;
1594
- c = { ...e, left: (e.left || 0) - u.endX + u.startX - i.from.columnOffset };
1569
+ newTransform = { ...transform, left: (transform.left || 0) - selectionCell.endX + selectionCell.startX - sheetTransform.from.columnOffset };
1595
1570
  }
1596
- l = N(c, this._selectionRenderService);
1597
- } else if (h >= n && h <= t && r === O.Both) {
1598
- const u = this._skeletonManagerService.attachRangeWithCoord({
1599
- startColumn: n - 1,
1600
- endColumn: n - 1,
1601
- startRow: o.row,
1602
- endRow: a.row
1571
+ newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
1572
+ } else if (toColumn >= colStartIndex && toColumn <= colEndIndex && anchorType === SheetDrawingAnchorType.Both) {
1573
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({
1574
+ startColumn: colStartIndex - 1,
1575
+ endColumn: colStartIndex - 1,
1576
+ startRow: from.row,
1577
+ endRow: to.row
1603
1578
  });
1604
- if (u == null)
1579
+ if (selectionCell == null)
1605
1580
  return;
1606
- l = {
1607
- from: { ...o },
1608
- to: { ...a, column: n - 1, columnOffset: u.endX - u.startX }
1609
- }, c = $(l, this._selectionRenderService, this._skeletonManagerService);
1581
+ newSheetTransform = {
1582
+ from: { ...from },
1583
+ to: { ...to, column: colStartIndex - 1, columnOffset: selectionCell.endX - selectionCell.startX }
1584
+ }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1610
1585
  }
1611
1586
  }
1612
- return l != null && c != null ? {
1613
- newSheetTransform: l,
1614
- newTransform: c
1587
+ return newSheetTransform != null && newTransform != null ? {
1588
+ newSheetTransform,
1589
+ newTransform
1615
1590
  } : null;
1616
1591
  }
1617
- _expandRow(i, e, n, t, r = O.Position) {
1618
- const s = t - n + 1, { from: o, to: a } = i, { row: d } = o, { row: h } = a;
1619
- if (r === O.None)
1592
+ _expandRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType = SheetDrawingAnchorType.Position) {
1593
+ const rowCount = rowEndIndex - rowStartIndex + 1, { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
1594
+ if (anchorType === SheetDrawingAnchorType.None)
1620
1595
  return {
1621
- newSheetTransform: N({ ...e }, this._selectionRenderService),
1622
- newTransform: e
1596
+ newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1597
+ newTransform: transform
1623
1598
  };
1624
- let l = null, c = null;
1625
- if (d >= n) {
1626
- const u = this._skeletonManagerService.attachRangeWithCoord({ startRow: n, endRow: t, startColumn: o.column, endColumn: a.column });
1627
- if (u == null)
1599
+ let newSheetTransform = null, newTransform = null;
1600
+ if (fromRow >= rowStartIndex) {
1601
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startRow: rowStartIndex, endRow: rowEndIndex, startColumn: from.column, endColumn: to.column });
1602
+ if (selectionCell == null)
1628
1603
  return;
1629
- c = { ...e, top: (e.top || 0) + u.endY - u.startY }, l = N(c, this._selectionRenderService);
1630
- } else if (h >= t)
1631
- if (r === O.Both)
1632
- l = {
1633
- from: { ...o },
1604
+ newTransform = { ...transform, top: (transform.top || 0) + selectionCell.endY - selectionCell.startY }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
1605
+ } else if (toRow >= rowEndIndex)
1606
+ if (anchorType === SheetDrawingAnchorType.Both)
1607
+ newSheetTransform = {
1608
+ from: { ...from },
1634
1609
  to: {
1635
- ...a,
1636
- row: h + s
1610
+ ...to,
1611
+ row: toRow + rowCount
1637
1612
  }
1638
- }, c = $(l, this._selectionRenderService, this._skeletonManagerService);
1613
+ }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1639
1614
  else
1640
1615
  return {
1641
- newSheetTransform: N({ ...e }, this._selectionRenderService),
1642
- newTransform: e
1616
+ newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1617
+ newTransform: transform
1643
1618
  };
1644
- return l != null && c != null ? {
1645
- newSheetTransform: l,
1646
- newTransform: c
1619
+ return newSheetTransform != null && newTransform != null ? {
1620
+ newSheetTransform,
1621
+ newTransform
1647
1622
  } : null;
1648
1623
  }
1649
- _shrinkRow(i, e, n, t, r = O.Position) {
1650
- const s = t - n + 1, { from: o, to: a } = i, { row: d } = o, { row: h } = a;
1651
- if (r === O.None)
1624
+ _shrinkRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType = SheetDrawingAnchorType.Position) {
1625
+ const rowCount = rowEndIndex - rowStartIndex + 1, { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
1626
+ if (anchorType === SheetDrawingAnchorType.None)
1652
1627
  return {
1653
- newSheetTransform: N({ ...e }, this._selectionRenderService),
1654
- newTransform: e
1628
+ newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1629
+ newTransform: transform
1655
1630
  };
1656
- let l = null, c = null;
1657
- if (d > t)
1658
- l = {
1659
- from: { ...o, row: d - s },
1660
- to: { ...a, row: h - s }
1661
- }, c = $(l, this._selectionRenderService, this._skeletonManagerService);
1631
+ let newSheetTransform = null, newTransform = null;
1632
+ if (fromRow > rowEndIndex)
1633
+ newSheetTransform = {
1634
+ from: { ...from, row: fromRow - rowCount },
1635
+ to: { ...to, row: toRow - rowCount }
1636
+ }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1662
1637
  else {
1663
- if (d >= n && h <= t)
1638
+ if (fromRow >= rowStartIndex && toRow <= rowEndIndex)
1664
1639
  return null;
1665
- if (d < n && h > t)
1666
- if (r === O.Both)
1667
- l = {
1668
- from: { ...o },
1669
- to: { ...a, row: h - s }
1670
- }, c = $(l, this._selectionRenderService, this._skeletonManagerService);
1640
+ if (fromRow < rowStartIndex && toRow > rowEndIndex)
1641
+ if (anchorType === SheetDrawingAnchorType.Both)
1642
+ newSheetTransform = {
1643
+ from: { ...from },
1644
+ to: { ...to, row: toRow - rowCount }
1645
+ }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1671
1646
  else
1672
1647
  return {
1673
- newSheetTransform: N({ ...e }, this._selectionRenderService),
1674
- newTransform: e
1648
+ newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1649
+ newTransform: transform
1675
1650
  };
1676
- else if (d >= n && d <= t) {
1677
- if (d === n)
1678
- c = { ...e, top: (e.top || 0) - i.from.rowOffset };
1651
+ else if (fromRow >= rowStartIndex && fromRow <= rowEndIndex) {
1652
+ if (fromRow === rowStartIndex)
1653
+ newTransform = { ...transform, top: (transform.top || 0) - sheetTransform.from.rowOffset };
1679
1654
  else {
1680
- const u = this._skeletonManagerService.attachRangeWithCoord({ startRow: n, endRow: d - 1, startColumn: o.column, endColumn: a.column });
1681
- if (u == null)
1655
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startRow: rowStartIndex, endRow: fromRow - 1, startColumn: from.column, endColumn: to.column });
1656
+ if (selectionCell == null)
1682
1657
  return;
1683
- c = { ...e, top: (e.top || 0) - u.endY + u.startY - i.from.rowOffset };
1658
+ newTransform = { ...transform, top: (transform.top || 0) - selectionCell.endY + selectionCell.startY - sheetTransform.from.rowOffset };
1684
1659
  }
1685
- l = N(c, this._selectionRenderService);
1686
- } else if (h >= n && h <= t && r === O.Both) {
1687
- const u = this._skeletonManagerService.attachRangeWithCoord({ startColumn: o.column, endColumn: o.column, startRow: n - 1, endRow: n - 1 });
1688
- if (u == null)
1660
+ newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
1661
+ } else if (toRow >= rowStartIndex && toRow <= rowEndIndex && anchorType === SheetDrawingAnchorType.Both) {
1662
+ const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: from.column, startRow: rowStartIndex - 1, endRow: rowStartIndex - 1 });
1663
+ if (selectionCell == null)
1689
1664
  return;
1690
- l = {
1691
- from: { ...o },
1692
- to: { ...a, row: n - 1, rowOffset: u.endY - u.startY }
1693
- }, c = $(l, this._selectionRenderService, this._skeletonManagerService);
1665
+ newSheetTransform = {
1666
+ from: { ...from },
1667
+ to: { ...to, row: rowStartIndex - 1, rowOffset: selectionCell.endY - selectionCell.startY }
1668
+ }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1694
1669
  }
1695
1670
  }
1696
- return l != null && c != null ? {
1697
- newSheetTransform: l,
1698
- newTransform: c
1671
+ return newSheetTransform != null && newTransform != null ? {
1672
+ newSheetTransform,
1673
+ newTransform
1699
1674
  } : null;
1700
1675
  }
1701
1676
  _commandListener() {
1702
1677
  this.disposeWithMe(
1703
- this._commandService.onCommandExecuted((i) => {
1704
- i.id === sr.id && setTimeout(() => {
1705
- const e = i.params, { unitId: n, subUnitId: t } = e, r = this._drawingManagerService.drawingManagerData, s = [], o = [];
1706
- Object.keys(r).forEach((a) => {
1707
- const d = r[a];
1708
- Object.keys(d).forEach((h) => {
1709
- const l = d[h].data;
1710
- l != null && Object.keys(l).forEach((c) => {
1711
- if (a === n && h === t) {
1712
- const u = l[c];
1713
- u.transform = $(u.sheetTransform, this._selectionRenderService, this._skeletonManagerService), s.push(l[c]);
1678
+ this._commandService.onCommandExecuted((command) => {
1679
+ command.id === SetWorksheetActiveOperation.id && setTimeout(() => {
1680
+ const params = command.params, { unitId: showUnitId, subUnitId: showSubunitId } = params, drawingMap = this._drawingManagerService.drawingManagerData, insertDrawings = [], removeDrawings = [];
1681
+ Object.keys(drawingMap).forEach((unitId) => {
1682
+ const subUnitMap = drawingMap[unitId];
1683
+ Object.keys(subUnitMap).forEach((subUnitId) => {
1684
+ const drawingData = subUnitMap[subUnitId].data;
1685
+ drawingData != null && Object.keys(drawingData).forEach((drawingId) => {
1686
+ if (unitId === showUnitId && subUnitId === showSubunitId) {
1687
+ const drawing = drawingData[drawingId];
1688
+ drawing.transform = drawingPositionToTransform(drawing.sheetTransform, this._selectionRenderService, this._skeletonManagerService), insertDrawings.push(drawingData[drawingId]);
1714
1689
  } else
1715
- o.push(l[c]);
1690
+ removeDrawings.push(drawingData[drawingId]);
1716
1691
  });
1717
1692
  });
1718
- }), this._drawingManagerService.removeNotification(o), this._drawingManagerService.addNotification(s);
1693
+ }), this._drawingManagerService.removeNotification(removeDrawings), this._drawingManagerService.addNotification(insertDrawings);
1719
1694
  }, 0);
1720
1695
  })
1721
1696
  );
1722
1697
  }
1723
1698
  _sheetRefreshListener() {
1724
1699
  this.disposeWithMe(
1725
- this._commandService.onCommandExecuted((i) => {
1726
- di.includes(i.id) && requestIdleCallback(() => {
1727
- const e = i.params, { unitId: n, subUnitId: t, ranges: r } = e;
1728
- this._refreshDrawingTransform(n, t, r);
1700
+ this._commandService.onCommandExecuted((command) => {
1701
+ REFRESH_MUTATIONS.includes(command.id) && requestIdleCallback(() => {
1702
+ const params = command.params, { unitId, subUnitId, ranges } = params;
1703
+ this._refreshDrawingTransform(unitId, subUnitId, ranges);
1729
1704
  });
1730
1705
  })
1731
1706
  );
1732
1707
  }
1733
- _refreshDrawingTransform(i, e, n) {
1734
- const t = this._drawingManagerService.getDrawingData(i, e), r = [];
1735
- Object.keys(t).forEach((s) => {
1736
- const o = t[s], { sheetTransform: a, anchorType: d = O.Position } = o;
1737
- if (d === O.None)
1708
+ _refreshDrawingTransform(unitId, subUnitId, ranges) {
1709
+ const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [];
1710
+ Object.keys(drawingData).forEach((drawingId) => {
1711
+ const drawing = drawingData[drawingId], { sheetTransform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1712
+ if (anchorType === SheetDrawingAnchorType.None)
1738
1713
  return !0;
1739
- const { from: h, to: l } = a, { row: c, column: u } = h, { row: g, column: f } = l;
1740
- for (let m = 0; m < n.length; m++) {
1741
- const p = n[m], { startRow: S, endRow: C, startColumn: v, endColumn: R } = p;
1742
- if (an.intersects(
1714
+ const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1715
+ for (let i = 0; i < ranges.length; i++) {
1716
+ const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
1717
+ if (Rectangle.intersects(
1743
1718
  {
1744
- startRow: S,
1745
- endRow: C,
1746
- startColumn: v,
1747
- endColumn: R
1719
+ startRow,
1720
+ endRow,
1721
+ startColumn,
1722
+ endColumn
1748
1723
  },
1749
1724
  {
1750
- startRow: c,
1751
- endRow: g,
1752
- startColumn: u,
1753
- endColumn: f
1725
+ startRow: fromRow,
1726
+ endRow: toRow,
1727
+ startColumn: fromColumn,
1728
+ endColumn: toColumn
1754
1729
  }
1755
- ) || c > C || u > R) {
1756
- r.push({
1757
- ...o,
1758
- transform: $(a, this._selectionRenderService, this._skeletonManagerService)
1730
+ ) || fromRow > endRow || fromColumn > endColumn) {
1731
+ updateDrawings.push({
1732
+ ...drawing,
1733
+ transform: drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService)
1759
1734
  });
1760
1735
  break;
1761
1736
  }
1762
1737
  }
1763
- }), r.length !== 0 && (this._drawingManagerService.refreshTransform(r), this._commandService.syncExecuteCommand(j.id, [i]));
1764
- }
1765
- };
1766
- Ae = ai([
1767
- ie(se.Rendered, Ae),
1768
- ce(0, V),
1769
- ce(1, W(or)),
1770
- ce(2, K),
1771
- ce(3, k),
1772
- ce(4, z),
1773
- ce(5, he)
1774
- ], Ae);
1775
- var li = Object.defineProperty, ui = Object.getOwnPropertyDescriptor, gi = (i, e, n, t) => {
1776
- for (var r = t > 1 ? void 0 : t ? ui(e, n) : e, s = i.length - 1, o; s >= 0; s--)
1777
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
1778
- return t && r && li(e, n, r), r;
1779
- }, de = (i, e) => (n, t) => e(n, t, i);
1780
- function hi(i, e, n, t) {
1781
- const { scaleX: r, scaleY: s } = e.getAncestorScale(), o = e.getViewport(Pn.VIEW_MAIN), a = {
1738
+ }), updateDrawings.length !== 0 && (this._drawingManagerService.refreshTransform(updateDrawings), this._commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id, [unitId]));
1739
+ }
1740
+ }, __name(_a4, "SheetDrawingTransformAffectedController"), _a4);
1741
+ SheetDrawingTransformAffectedController = __decorateClass$5([
1742
+ __decorateParam$5(1, ICommandService),
1743
+ __decorateParam$5(2, ISheetSelectionRenderService),
1744
+ __decorateParam$5(3, Inject(SheetSkeletonManagerService)),
1745
+ __decorateParam$5(4, Inject(SheetInterceptorService)),
1746
+ __decorateParam$5(5, ISheetDrawingService),
1747
+ __decorateParam$5(6, IDrawingManagerService),
1748
+ __decorateParam$5(7, IUniverInstanceService)
1749
+ ], SheetDrawingTransformAffectedController);
1750
+ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1751
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1752
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1753
+ return kind && result && __defProp$4(target, key, result), result;
1754
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4");
1755
+ function transformBound2DOMBound(originBound, scene, skeleton, worksheet) {
1756
+ const { scaleX, scaleY } = scene.getAncestorScale(), viewMain = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN), absolute = {
1782
1757
  left: !0,
1783
1758
  top: !0
1784
1759
  };
1785
- if (!o)
1760
+ if (!viewMain)
1786
1761
  return {
1787
- ...i,
1788
- absolute: a
1762
+ ...originBound,
1763
+ absolute
1789
1764
  };
1790
- const { left: d, right: h, top: l, bottom: c } = i, u = t.getFreeze(), { startColumn: g, startRow: f, xSplit: m, ySplit: p } = u, S = n.getNoMergeCellPositionByIndexWithNoHeader(f - p, g - m), C = n.getNoMergeCellPositionByIndexWithNoHeader(f, g), { rowHeaderWidth: v, columnHeaderHeight: R } = n, _ = C.startX - S.startX, b = C.startY - S.startY, { top: w, left: P, viewportScrollX: D, viewportScrollY: T } = o;
1791
- let U, M;
1792
- d < P ? (a.left = !0, U = (_ + v + (d - P)) * r, M = Math.max(
1765
+ const { left, right, top, bottom } = originBound, freeze = worksheet.getFreeze(), { startColumn, startRow, xSplit, ySplit } = freeze, startSheetView = skeleton.getNoMergeCellPositionByIndexWithNoHeader(startRow - ySplit, startColumn - xSplit), endSheetView = skeleton.getNoMergeCellPositionByIndexWithNoHeader(startRow, startColumn), { rowHeaderWidth, columnHeaderHeight } = skeleton, freezeWidth = endSheetView.startX - startSheetView.startX, freezeHeight = endSheetView.startY - startSheetView.startY, { top: freezeTop, left: freezeLeft, viewportScrollX: actualScrollX, viewportScrollY: actualScrollY } = viewMain;
1766
+ let offsetLeft, offsetRight;
1767
+ left < freezeLeft ? (absolute.left = !0, offsetLeft = (freezeWidth + rowHeaderWidth + (left - freezeLeft)) * scaleX, offsetRight = Math.max(
1793
1768
  Math.min(
1794
- (_ + v + (h - P)) * r,
1795
- (_ + v) * r
1769
+ (freezeWidth + rowHeaderWidth + (right - freezeLeft)) * scaleX,
1770
+ (freezeWidth + rowHeaderWidth) * scaleX
1796
1771
  ),
1797
- (h - D) * r
1798
- )) : (a.left = !1, U = Math.max((d - D) * r, (_ + v) * r), M = Math.max((h - D) * r, (_ + v) * r));
1799
- let I, A;
1800
- return l < w ? (a.top = !0, I = (b + R + (l - w)) * s, A = Math.max(
1772
+ (right - actualScrollX) * scaleX
1773
+ )) : (absolute.left = !1, offsetLeft = Math.max((left - actualScrollX) * scaleX, (freezeWidth + rowHeaderWidth) * scaleX), offsetRight = Math.max((right - actualScrollX) * scaleX, (freezeWidth + rowHeaderWidth) * scaleX));
1774
+ let offsetTop, offsetBottom;
1775
+ return top < freezeTop ? (absolute.top = !0, offsetTop = (freezeHeight + columnHeaderHeight + (top - freezeTop)) * scaleY, offsetBottom = Math.max(
1801
1776
  Math.min(
1802
- (b + R + (h - w)) * s,
1803
- (b + R) * s
1777
+ (freezeHeight + columnHeaderHeight + (right - freezeTop)) * scaleY,
1778
+ (freezeHeight + columnHeaderHeight) * scaleY
1804
1779
  ),
1805
- (c - T) * s
1806
- )) : (a.top = !1, I = Math.max((l - T) * s, (b + R) * s), A = Math.max((c - T) * s, (b + R) * s)), {
1807
- left: U,
1808
- right: M,
1809
- top: I,
1810
- bottom: A,
1811
- absolute: a
1780
+ (bottom - actualScrollY) * scaleY
1781
+ )) : (absolute.top = !1, offsetTop = Math.max((top - actualScrollY) * scaleY, (freezeHeight + columnHeaderHeight) * scaleY), offsetBottom = Math.max((bottom - actualScrollY) * scaleY, (freezeHeight + columnHeaderHeight) * scaleY)), {
1782
+ left: offsetLeft,
1783
+ right: offsetRight,
1784
+ top: offsetTop,
1785
+ bottom: offsetBottom,
1786
+ absolute
1812
1787
  };
1813
1788
  }
1814
- const ze = (i, e, n, t) => {
1815
- const { scene: r } = e, { left: s, top: o, width: a, height: d, angle: h } = i, l = {
1816
- left: s,
1817
- right: s + a,
1818
- top: o,
1819
- bottom: o + d
1820
- }, c = hi(l, r, n, t);
1789
+ __name(transformBound2DOMBound, "transformBound2DOMBound");
1790
+ const calcPosition = /* @__PURE__ */ __name((targetObject, currentRender, skeleton, worksheet) => {
1791
+ const { scene } = currentRender, { left, top, width, height, angle } = targetObject, bound = {
1792
+ left,
1793
+ right: left + width,
1794
+ top,
1795
+ bottom: top + height
1796
+ }, offsetBound = transformBound2DOMBound(bound, scene, skeleton, worksheet);
1821
1797
  return {
1822
- startX: c.left,
1823
- endX: c.right,
1824
- startY: c.top,
1825
- endY: c.bottom,
1826
- rotate: h,
1827
- width: a,
1828
- height: d,
1829
- absolute: c.absolute
1798
+ startX: offsetBound.left,
1799
+ endX: offsetBound.right,
1800
+ startY: offsetBound.top,
1801
+ endY: offsetBound.bottom,
1802
+ rotate: angle,
1803
+ width,
1804
+ height,
1805
+ absolute: offsetBound.absolute
1830
1806
  };
1831
- };
1832
- let tt = class extends oe {
1833
- constructor(e, n, t, r, s, o) {
1807
+ }, "calcPosition");
1808
+ var _a5;
1809
+ let SheetCanvasFloatDomManagerService = (_a5 = class extends Disposable {
1810
+ constructor(_renderManagerService, _univerInstanceService, _commandService, _drawingManagerService, _canvasFloatDomService, _sheetDrawingService) {
1834
1811
  super();
1835
- H(this, "_domLayerMap", /* @__PURE__ */ new Map());
1836
- H(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
1837
- H(this, "_transformChange$", new mt());
1838
- H(this, "transformChange$", this._transformChange$.asObservable());
1839
- H(this, "_remove$", new mt());
1840
- H(this, "remove$", this._remove$.asObservable());
1841
- H(this, "_hooks", []);
1842
- this._renderManagerService = e, this._univerInstanceService = n, this._commandService = t, this._drawingManagerService = r, this._canvasFloatDomService = s, this._sheetDrawingService = o, this._drawingAddListener(), this._scrollUpdateListener(), this._featureUpdateListener(), this._deleteListener();
1843
- }
1844
- _ensureMap(e, n) {
1845
- let t = this._domLayerMap.get(e);
1846
- t || (t = /* @__PURE__ */ new Map(), this._domLayerMap.set(e, t));
1847
- let r = t.get(n);
1848
- return r || (r = /* @__PURE__ */ new Map(), t.set(n, r)), r;
1849
- }
1850
- _getSceneAndTransformerByDrawingSearch(e) {
1851
- if (e == null)
1812
+ __publicField(this, "_domLayerMap", /* @__PURE__ */ new Map());
1813
+ __publicField(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
1814
+ __publicField(this, "_transformChange$", new Subject());
1815
+ __publicField(this, "transformChange$", this._transformChange$.asObservable());
1816
+ __publicField(this, "_remove$", new Subject());
1817
+ __publicField(this, "remove$", this._remove$.asObservable());
1818
+ __publicField(this, "_hooks", []);
1819
+ this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._drawingManagerService = _drawingManagerService, this._canvasFloatDomService = _canvasFloatDomService, this._sheetDrawingService = _sheetDrawingService, this._drawingAddListener(), this._scrollUpdateListener(), this._featureUpdateListener(), this._deleteListener();
1820
+ }
1821
+ _ensureMap(unitId, subUnitId) {
1822
+ let unitMap = this._domLayerMap.get(unitId);
1823
+ unitMap || (unitMap = /* @__PURE__ */ new Map(), this._domLayerMap.set(unitId, unitMap));
1824
+ let subUnitMap = unitMap.get(subUnitId);
1825
+ return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), unitMap.set(subUnitId, subUnitMap)), subUnitMap;
1826
+ }
1827
+ _getSceneAndTransformerByDrawingSearch(unitId) {
1828
+ if (unitId == null)
1852
1829
  return;
1853
- const n = this._renderManagerService.getRenderById(e), t = n == null ? void 0 : n.scene;
1854
- if (n == null || t == null)
1830
+ const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1831
+ if (renderObject == null || scene == null)
1855
1832
  return null;
1856
- const r = t.getTransformerByCreate(), s = n.engine.getCanvasElement();
1857
- return { scene: t, transformer: r, renderObject: n, canvas: s };
1833
+ const transformer = scene.getTransformerByCreate(), canvas = renderObject.engine.getCanvasElement();
1834
+ return { scene, transformer, renderObject, canvas };
1858
1835
  }
1859
- _getFloatDomProps(e) {
1860
- let n;
1861
- return this._hooks.forEach((t) => {
1862
- n = t.onGetFloatDomProps(e);
1863
- }), n;
1836
+ _getFloatDomProps(id) {
1837
+ let props;
1838
+ return this._hooks.forEach((hook) => {
1839
+ props = hook.onGetFloatDomProps(id);
1840
+ }), props;
1864
1841
  }
1865
1842
  // eslint-disable-next-line max-lines-per-function
1866
1843
  _drawingAddListener() {
1867
1844
  this.disposeWithMe(
1868
1845
  // eslint-disable-next-line max-lines-per-function
1869
- this._drawingManagerService.add$.subscribe((e) => {
1870
- e.forEach((n) => {
1871
- var ot, at, ct;
1872
- const { unitId: t, subUnitId: r, drawingId: s } = n, o = le(this._univerInstanceService, { unitId: t, subUnitId: r }), a = this._drawingManagerService.getDrawingByParam(n), d = (ot = this._renderManagerService.getRenderById(t)) == null ? void 0 : ot.with(re).getWorksheetSkeleton(r);
1873
- if (a == null || o == null || d == null)
1846
+ this._drawingManagerService.add$.subscribe((params) => {
1847
+ params.forEach((param) => {
1848
+ var _a10, _b, _c;
1849
+ const { unitId, subUnitId, drawingId } = param, target = getSheetCommandTarget(this._univerInstanceService, { unitId, subUnitId }), floatDomParam = this._drawingManagerService.getDrawingByParam(param), skeleton = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
1850
+ if (floatDomParam == null || target == null || skeleton == null)
1874
1851
  return;
1875
- const { transform: h, drawingType: l } = a;
1876
- if (l !== Ye.DRAWING_DOM)
1852
+ const { transform, drawingType, data } = floatDomParam;
1853
+ if (drawingType !== DrawingTypeEnum$1.DRAWING_DOM)
1877
1854
  return;
1878
- const c = this._getSceneAndTransformerByDrawingSearch(t);
1879
- if (c == null)
1855
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1856
+ if (renderObject == null)
1880
1857
  return;
1881
- const { scene: u, canvas: g } = c;
1882
- if (h == null)
1858
+ const { scene, canvas } = renderObject;
1859
+ if (transform == null)
1883
1860
  return !0;
1884
- const { left: f, top: m, width: p, height: S, angle: C, flipX: v, flipY: R, skewX: _, skewY: b } = h, w = Mn({ unitId: t, subUnitId: r, drawingId: s }), P = u.getObject(w);
1885
- if (P != null) {
1886
- P.transformByState({ left: f, top: m, width: p, height: S, angle: C, flipX: v, flipY: R, skewX: _, skewY: b });
1861
+ const { left, top, width, height, angle, flipX, flipY, skewX, skewY } = transform, rectShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), rectShape = scene.getObject(rectShapeKey);
1862
+ if (rectShape != null) {
1863
+ rectShape.transformByState({ left, top, width, height, angle, flipX, flipY, skewX, skewY });
1887
1864
  return;
1888
1865
  }
1889
- const D = {
1890
- left: f,
1891
- top: m,
1892
- width: p,
1893
- height: S,
1894
- zIndex: this._drawingManagerService.getDrawingOrder(t, r).length - 1
1895
- }, T = new yn(w, D);
1896
- u.addObject(T, On).attachTransformerTo(T);
1897
- const U = this._ensureMap(t, r), M = new cn(), I = ze(T, c.renderObject, d.skeleton, o.worksheet), A = new $n(I), G = {
1898
- dispose: M,
1899
- rect: T,
1900
- position$: A,
1901
- unitId: t,
1902
- subUnitId: r
1866
+ const imageConfig = {
1867
+ left,
1868
+ top,
1869
+ width,
1870
+ height,
1871
+ zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
1872
+ }, rect = new Rect(rectShapeKey, imageConfig);
1873
+ scene.addObject(rect, DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(rect);
1874
+ const map2 = this._ensureMap(unitId, subUnitId), disposableCollection = new DisposableCollection(), initPosition = calcPosition(rect, renderObject.renderObject, skeleton.skeleton, target.worksheet), position$ = new BehaviorSubject(initPosition), info = {
1875
+ dispose: disposableCollection,
1876
+ rect,
1877
+ position$,
1878
+ unitId,
1879
+ subUnitId
1903
1880
  };
1904
1881
  this._canvasFloatDomService.addFloatDom({
1905
- position$: A,
1906
- id: s,
1907
- componentKey: a.componentKey,
1908
- onPointerDown: (x) => {
1909
- g.dispatchEvent(new PointerEvent(x.type, x));
1910
- },
1911
- onPointerMove: (x) => {
1912
- g.dispatchEvent(new PointerEvent(x.type, x));
1913
- },
1914
- onPointerUp: (x) => {
1915
- g.dispatchEvent(new PointerEvent(x.type, x));
1916
- },
1917
- onWheel: (x) => {
1918
- g.dispatchEvent(new WheelEvent(x.type, x));
1919
- },
1920
- props: (ct = (at = U.get(s)) == null ? void 0 : at.props) != null ? ct : this._getFloatDomProps(s)
1882
+ position$,
1883
+ id: drawingId,
1884
+ componentKey: floatDomParam.componentKey,
1885
+ onPointerDown: /* @__PURE__ */ __name((evt) => {
1886
+ canvas.dispatchEvent(new PointerEvent(evt.type, evt));
1887
+ }, "onPointerDown"),
1888
+ onPointerMove: /* @__PURE__ */ __name((evt) => {
1889
+ canvas.dispatchEvent(new PointerEvent(evt.type, evt));
1890
+ }, "onPointerMove"),
1891
+ onPointerUp: /* @__PURE__ */ __name((evt) => {
1892
+ canvas.dispatchEvent(new PointerEvent(evt.type, evt));
1893
+ }, "onPointerUp"),
1894
+ onWheel: /* @__PURE__ */ __name((evt) => {
1895
+ canvas.dispatchEvent(new WheelEvent(evt.type, evt));
1896
+ }, "onWheel"),
1897
+ props: (_c = (_b = map2.get(drawingId)) == null ? void 0 : _b.props) != null ? _c : this._getFloatDomProps(drawingId),
1898
+ data
1921
1899
  });
1922
- const J = T.onTransformChange$.subscribeEvent(() => {
1923
- const x = ze(T, c.renderObject, d.skeleton, o.worksheet);
1924
- A.next(
1925
- x
1900
+ const listener = rect.onTransformChange$.subscribeEvent(() => {
1901
+ const newPosition = calcPosition(rect, renderObject.renderObject, skeleton.skeleton, target.worksheet);
1902
+ position$.next(
1903
+ newPosition
1926
1904
  );
1927
1905
  });
1928
- M.add(() => {
1929
- this._canvasFloatDomService.removeFloatDom(s);
1930
- }), J && M.add(J), this._domLayerInfoMap.set(s, G);
1906
+ disposableCollection.add(() => {
1907
+ this._canvasFloatDomService.removeFloatDom(drawingId);
1908
+ }), listener && disposableCollection.add(listener), this._domLayerInfoMap.set(drawingId, info), map2.set(drawingId, {
1909
+ ...map2.get(drawingId)
1910
+ });
1931
1911
  });
1932
1912
  })
1933
1913
  );
1934
1914
  }
1935
1915
  _scrollUpdateListener() {
1936
- this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
1937
- var t, r;
1938
- const n = (s, o) => {
1939
- var u;
1940
- const a = this._getSceneAndTransformerByDrawingSearch(s), d = this._ensureMap(s, o), h = Array.from(d.keys()), l = le(this._univerInstanceService, { unitId: s, subUnitId: o }), c = (u = this._renderManagerService.getRenderById(s)) == null ? void 0 : u.with(re).getWorksheetSkeleton(o);
1941
- !a || !l || !c || h.forEach((g) => {
1942
- const f = this._domLayerInfoMap.get(g);
1943
- if (f) {
1944
- const m = ze(f.rect, a.renderObject, c.skeleton, l.worksheet);
1945
- f.position$.next(m);
1916
+ this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
1917
+ var _a10, _b;
1918
+ const updateSheet = /* @__PURE__ */ __name((unitId, subUnitId) => {
1919
+ var _a11;
1920
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId), map2 = this._ensureMap(unitId, subUnitId), ids = Array.from(map2.keys()), target = getSheetCommandTarget(this._univerInstanceService, { unitId, subUnitId }), skeleton = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
1921
+ !renderObject || !target || !skeleton || ids.forEach((id) => {
1922
+ const info = this._domLayerInfoMap.get(id);
1923
+ if (info) {
1924
+ const position = calcPosition(info.rect, renderObject.renderObject, skeleton.skeleton, target.worksheet);
1925
+ info.position$.next(position);
1946
1926
  }
1947
1927
  });
1948
- };
1949
- if (e.id === Nn.id) {
1950
- const s = e.params, { unitId: o, sheetId: a } = s;
1951
- n(o, a);
1952
- } else if (e.id === jn.id) {
1953
- const s = e.params, { unitId: o } = s;
1954
- Array.from((r = (t = this._domLayerMap.get(o)) == null ? void 0 : t.keys()) != null ? r : []).forEach((d) => {
1955
- n(o, d);
1928
+ }, "updateSheet");
1929
+ if (commandInfo.id === SetScrollOperation.id) {
1930
+ const params = commandInfo.params, { unitId, sheetId } = params;
1931
+ updateSheet(unitId, sheetId);
1932
+ } else if (commandInfo.id === SetZoomRatioOperation.id) {
1933
+ const params = commandInfo.params, { unitId } = params;
1934
+ Array.from((_b = (_a10 = this._domLayerMap.get(unitId)) == null ? void 0 : _a10.keys()) != null ? _b : []).forEach((subUnitId) => {
1935
+ updateSheet(unitId, subUnitId);
1956
1936
  });
1957
- } else if (e.id === ar.id) {
1958
- const { unitId: s, subUnitId: o } = e.params;
1959
- n(s, o);
1937
+ } else if (commandInfo.id === SetFrozenMutation.id) {
1938
+ const { unitId, subUnitId } = commandInfo.params;
1939
+ updateSheet(unitId, subUnitId);
1960
1940
  }
1961
1941
  }));
1962
1942
  }
1963
- _getPosition(e, n) {
1964
- var u;
1965
- const { startX: t, endX: r, startY: s, endY: o } = e, a = (u = this._renderManagerService.getRenderById(n)) == null ? void 0 : u.with(Ge);
1966
- if (a == null)
1943
+ _getPosition(position, unitId) {
1944
+ var _a10;
1945
+ const { startX, endX, startY, endY } = position, selectionRenderService = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.with(ISheetSelectionRenderService);
1946
+ if (selectionRenderService == null)
1967
1947
  return;
1968
- const d = a.getSelectionCellByPosition(t, s);
1969
- if (d == null)
1948
+ const start = selectionRenderService.getSelectionCellByPosition(startX, startY);
1949
+ if (start == null)
1970
1950
  return;
1971
- const h = {
1972
- column: d.actualColumn,
1973
- columnOffset: t - d.startX,
1974
- row: d.actualRow,
1975
- rowOffset: s - d.startY
1976
- }, l = a.getSelectionCellByPosition(r, o);
1977
- if (l == null)
1951
+ const from = {
1952
+ column: start.actualColumn,
1953
+ columnOffset: startX - start.startX,
1954
+ row: start.actualRow,
1955
+ rowOffset: startY - start.startY
1956
+ }, end = selectionRenderService.getSelectionCellByPosition(endX, endY);
1957
+ if (end == null)
1978
1958
  return;
1979
- const c = {
1980
- column: l.actualColumn,
1981
- columnOffset: r - l.startX,
1982
- row: l.actualRow,
1983
- rowOffset: o - l.startY
1959
+ const to = {
1960
+ column: end.actualColumn,
1961
+ columnOffset: endX - end.startX,
1962
+ row: end.actualRow,
1963
+ rowOffset: endY - end.startY
1984
1964
  };
1985
1965
  return {
1986
- from: h,
1987
- to: c
1966
+ from,
1967
+ to
1988
1968
  };
1989
1969
  }
1990
1970
  _featureUpdateListener() {
1991
1971
  this.disposeWithMe(
1992
- this._drawingManagerService.update$.subscribe((e) => {
1993
- e.forEach((n) => {
1994
- const t = this._drawingManagerService.getDrawingByParam(n);
1995
- if (!t || t.drawingType !== Ye.DRAWING_DOM)
1972
+ this._drawingManagerService.update$.subscribe((params) => {
1973
+ params.forEach((data) => {
1974
+ const sheetDrawing = this._drawingManagerService.getDrawingByParam(data);
1975
+ if (!sheetDrawing || sheetDrawing.drawingType !== DrawingTypeEnum$1.DRAWING_DOM)
1996
1976
  return;
1997
- const r = {
1998
- ...t.transform
1977
+ const newValue = {
1978
+ ...sheetDrawing.transform
1999
1979
  };
2000
- this._transformChange$.next({ id: n.drawingId, value: r });
1980
+ this._transformChange$.next({ id: data.drawingId, value: newValue });
2001
1981
  });
2002
1982
  })
2003
1983
  );
2004
1984
  }
2005
1985
  _deleteListener() {
2006
1986
  this.disposeWithMe(
2007
- this._drawingManagerService.remove$.subscribe((e) => {
2008
- e.forEach((n) => {
2009
- this._removeDom(n.drawingId);
1987
+ this._drawingManagerService.remove$.subscribe((params) => {
1988
+ params.forEach((param) => {
1989
+ this._removeDom(param.drawingId);
2010
1990
  });
2011
1991
  })
2012
1992
  );
2013
1993
  }
2014
- addFloatDomToPosition(e) {
2015
- const n = le(this._univerInstanceService, {
2016
- unitId: e.unitId,
2017
- subUnitId: e.subUnitId
1994
+ addFloatDomToPosition(layer) {
1995
+ const target = getSheetCommandTarget(this._univerInstanceService, {
1996
+ unitId: layer.unitId,
1997
+ subUnitId: layer.subUnitId
2018
1998
  });
2019
- if (!n)
1999
+ if (!target)
2020
2000
  throw new Error("cannot find current target!");
2021
- const { unitId: t, subUnitId: r } = n, { initPosition: s, componentKey: o } = e, a = ne.generateRandomId(), d = this._getPosition(s, t);
2022
- if (d == null)
2001
+ const { unitId, subUnitId } = target, { initPosition, componentKey, data } = layer, id = Tools.generateRandomId(), sheetTransform = this._getPosition(initPosition, unitId);
2002
+ if (sheetTransform == null)
2023
2003
  return;
2024
- this._ensureMap(t, r).set(a, e);
2025
- const l = {
2026
- unitId: t,
2027
- subUnitId: r,
2028
- drawingId: a,
2029
- drawingType: Ye.DRAWING_DOM,
2030
- componentKey: o,
2031
- sheetTransform: d,
2004
+ this._ensureMap(unitId, subUnitId).set(id, layer);
2005
+ const sheetDrawingParam = {
2006
+ unitId,
2007
+ subUnitId,
2008
+ drawingId: id,
2009
+ drawingType: DrawingTypeEnum$1.DRAWING_DOM,
2010
+ componentKey,
2011
+ sheetTransform,
2032
2012
  transform: {
2033
- left: s.startX,
2034
- top: s.startY,
2035
- width: s.endX - s.startX,
2036
- height: s.endY - s.startY
2037
- }
2013
+ left: initPosition.startX,
2014
+ top: initPosition.startY,
2015
+ width: initPosition.endX - initPosition.startX,
2016
+ height: initPosition.endY - initPosition.startY
2017
+ },
2018
+ data
2038
2019
  };
2039
- return this._commandService.executeCommand(st.id, {
2040
- unitId: t,
2041
- drawings: [l]
2020
+ return this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
2021
+ unitId,
2022
+ drawings: [sheetDrawingParam]
2042
2023
  }), {
2043
- id: a,
2044
- dispose: () => {
2045
- this._removeDom(a, !0);
2046
- }
2024
+ id,
2025
+ dispose: /* @__PURE__ */ __name(() => {
2026
+ this._removeDom(id, !0);
2027
+ }, "dispose")
2047
2028
  };
2048
2029
  }
2049
- _removeDom(e, n = !1) {
2050
- const t = this._domLayerInfoMap.get(e);
2051
- if (!t)
2030
+ _removeDom(id, removeDrawing = !1) {
2031
+ const info = this._domLayerInfoMap.get(id);
2032
+ if (!info)
2052
2033
  return;
2053
- const { unitId: r, subUnitId: s } = t;
2054
- this._domLayerInfoMap.delete(e), t.dispose.dispose();
2055
- const o = this._getSceneAndTransformerByDrawingSearch(r);
2056
- if (o && o.scene.removeObject(t.rect), n) {
2057
- this._ensureMap(r, s).delete(e);
2058
- const d = this._drawingManagerService.getDrawingByParam({ unitId: r, subUnitId: s, drawingId: e });
2059
- if (!d)
2034
+ const { unitId, subUnitId } = info;
2035
+ this._domLayerInfoMap.delete(id), info.dispose.dispose();
2036
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2037
+ if (renderObject && renderObject.scene.removeObject(info.rect), removeDrawing) {
2038
+ this._ensureMap(unitId, subUnitId).delete(id);
2039
+ const param = this._drawingManagerService.getDrawingByParam({ unitId, subUnitId, drawingId: id });
2040
+ if (!param)
2060
2041
  return;
2061
- const h = this._sheetDrawingService.getBatchRemoveOp([d]), { redo: l, objects: c } = h;
2062
- this._commandService.syncExecuteCommand(E.id, { unitId: r, subUnitId: s, op: l, objects: c, type: y.REMOVE });
2042
+ const jsonOp = this._sheetDrawingService.getBatchRemoveOp([param]), { redo, objects } = jsonOp;
2043
+ this._commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.REMOVE });
2063
2044
  }
2064
2045
  }
2065
- addHook(e) {
2066
- return this._hooks.push(e), {
2067
- dispose: () => {
2068
- const n = this._hooks.findIndex((t) => t === e);
2069
- this._hooks.splice(n, 1);
2070
- }
2046
+ addHook(hook) {
2047
+ return this._hooks.push(hook), {
2048
+ dispose: /* @__PURE__ */ __name(() => {
2049
+ const index = this._hooks.findIndex((h) => h === hook);
2050
+ this._hooks.splice(index, 1);
2051
+ }, "dispose")
2071
2052
  };
2072
2053
  }
2073
- };
2074
- tt = gi([
2075
- de(0, W(K)),
2076
- de(1, he),
2077
- de(2, W(V)),
2078
- de(3, z),
2079
- de(4, W(Kn)),
2080
- de(5, k)
2081
- ], tt);
2082
- var mi = Object.defineProperty, fi = Object.getOwnPropertyDescriptor, pi = (i, e, n, t) => {
2083
- for (var r = t > 1 ? void 0 : t ? fi(e, n) : e, s = i.length - 1, o; s >= 0; s--)
2084
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
2085
- return t && r && mi(e, n, r), r;
2086
- }, Oe = (i, e) => (n, t) => e(n, t, i);
2087
- let Ne = class extends oe {
2088
- constructor(i, e, n, t) {
2089
- super(), this._sheetPrintInterceptorService = i, this._drawingRenderService = e, this._drawingManagerService = n, this._renderManagerService = t, this._initPrinting();
2054
+ }, __name(_a5, "SheetCanvasFloatDomManagerService"), _a5);
2055
+ SheetCanvasFloatDomManagerService = __decorateClass$4([
2056
+ OnLifecycle(LifecycleStages.Starting, SheetCanvasFloatDomManagerService),
2057
+ __decorateParam$4(0, Inject(IRenderManagerService)),
2058
+ __decorateParam$4(1, IUniverInstanceService),
2059
+ __decorateParam$4(2, Inject(ICommandService)),
2060
+ __decorateParam$4(3, IDrawingManagerService),
2061
+ __decorateParam$4(4, Inject(CanvasFloatDomService)),
2062
+ __decorateParam$4(5, ISheetDrawingService)
2063
+ ], SheetCanvasFloatDomManagerService);
2064
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2065
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2066
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2067
+ return kind && result && __defProp$3(target, key, result), result;
2068
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a6;
2069
+ let SheetDrawingPrintingController = (_a6 = class extends Disposable {
2070
+ constructor(_sheetPrintInterceptorService, _drawingRenderService, _drawingManagerService, _renderManagerService) {
2071
+ super(), this._sheetPrintInterceptorService = _sheetPrintInterceptorService, this._drawingRenderService = _drawingRenderService, this._drawingManagerService = _drawingManagerService, this._renderManagerService = _renderManagerService, this._initPrinting();
2090
2072
  }
2091
2073
  _initPrinting() {
2092
2074
  this.disposeWithMe(
2093
2075
  this._sheetPrintInterceptorService.interceptor.intercept(
2094
2076
  this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,
2095
2077
  {
2096
- handler: (i, e, n) => {
2097
- const { unitId: t, scene: r, subUnitId: s } = e, o = this._drawingManagerService.getDrawingDataForUnit(t), a = o == null ? void 0 : o[s];
2098
- return a && a.order.forEach((d) => {
2099
- this._drawingRenderService.renderDrawing(a.data[d], r);
2100
- }), n();
2101
- }
2078
+ handler: /* @__PURE__ */ __name((_param, pos, next) => {
2079
+ const { unitId, scene, subUnitId } = pos, unitData = this._drawingManagerService.getDrawingDataForUnit(unitId), subUnitData = unitData == null ? void 0 : unitData[subUnitId];
2080
+ return subUnitData && subUnitData.order.forEach((id) => {
2081
+ this._drawingRenderService.renderDrawing(subUnitData.data[id], scene);
2082
+ }), next();
2083
+ }, "handler")
2102
2084
  }
2103
2085
  )
2104
2086
  ), this.disposeWithMe(
2105
2087
  this._sheetPrintInterceptorService.interceptor.intercept(
2106
2088
  this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,
2107
2089
  {
2108
- handler: (i, e, n) => {
2109
- const { unitId: t, subUnitId: r } = e, s = this._renderManagerService.getRenderById(t);
2110
- if (!s)
2111
- return n(i);
2112
- const o = s.with(re).getWorksheetSkeleton(r);
2113
- if (!o)
2114
- return n(i);
2115
- const a = this._drawingManagerService.getDrawingDataForUnit(t), d = a == null ? void 0 : a[e.subUnitId];
2116
- if (!d)
2117
- return n(i);
2118
- const { scaleX: h, scaleY: l } = s.scene, c = i ? { ...i } : { startColumn: 0, endColumn: 0, endRow: 0, startRow: 0 }, u = d.order.map((g) => d.data[g]).filter((g) => g.drawingType !== Ve.DRAWING_DOM);
2119
- return u.length ? (u.forEach((g) => {
2120
- if (!g.groupId && g.transform && ne.isDefine(g.transform.left) && ne.isDefine(g.transform.top) && ne.isDefine(g.transform.width) && ne.isDefine(g.transform.height)) {
2121
- const f = o.skeleton.getCellPositionByOffset(g.transform.left, g.transform.top, h, l, { x: 0, y: 0 }), m = o.skeleton.getCellPositionByOffset(g.transform.left + g.transform.width, g.transform.top + g.transform.height, h, l, { x: 0, y: 0 });
2122
- f.column < c.startColumn && (c.startColumn = f.column), f.row < c.startRow && (c.startRow = f.row), c.endRow < m.row && (c.endRow = m.row), c.endColumn < m.column && (c.endColumn = m.column);
2090
+ handler: /* @__PURE__ */ __name((range, pos, next) => {
2091
+ const { unitId, subUnitId } = pos, renderer = this._renderManagerService.getRenderById(unitId);
2092
+ if (!renderer)
2093
+ return next(range);
2094
+ const skeleton = renderer.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
2095
+ if (!skeleton)
2096
+ return next(range);
2097
+ const unitData = this._drawingManagerService.getDrawingDataForUnit(unitId), subUnitData = unitData == null ? void 0 : unitData[pos.subUnitId];
2098
+ if (!subUnitData)
2099
+ return next(range);
2100
+ const { scaleX, scaleY } = renderer.scene, newRange = range ? { ...range } : { startColumn: 0, endColumn: 0, endRow: 0, startRow: 0 }, data = subUnitData.order.map((key) => subUnitData.data[key]).filter((item) => item.drawingType !== DrawingTypeEnum.DRAWING_DOM);
2101
+ return data.length ? (data.forEach((param) => {
2102
+ if (!param.groupId && param.transform && Tools.isDefine(param.transform.left) && Tools.isDefine(param.transform.top) && Tools.isDefine(param.transform.width) && Tools.isDefine(param.transform.height)) {
2103
+ const start = skeleton.skeleton.getCellPositionByOffset(param.transform.left, param.transform.top, scaleX, scaleY, { x: 0, y: 0 }), end = skeleton.skeleton.getCellPositionByOffset(param.transform.left + param.transform.width, param.transform.top + param.transform.height, scaleX, scaleY, { x: 0, y: 0 });
2104
+ start.column < newRange.startColumn && (newRange.startColumn = start.column), start.row < newRange.startRow && (newRange.startRow = start.row), newRange.endRow < end.row && (newRange.endRow = end.row), newRange.endColumn < end.column && (newRange.endColumn = end.column);
2123
2105
  }
2124
- }), n(c)) : n(i);
2125
- }
2106
+ }), next(newRange)) : next(range);
2107
+ }, "handler")
2126
2108
  }
2127
2109
  )
2128
2110
  );
2129
2111
  }
2130
- };
2131
- Ne = pi([
2132
- ie(se.Rendered, Ne),
2133
- Oe(0, W(Ln)),
2134
- Oe(1, W(_n)),
2135
- Oe(2, z),
2136
- Oe(3, K)
2137
- ], Ne);
2138
- var wi = Object.defineProperty, _i = Object.getOwnPropertyDescriptor, vi = (i, e, n, t) => {
2139
- for (var r = t > 1 ? void 0 : t ? _i(e, n) : e, s = i.length - 1, o; s >= 0; s--)
2140
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
2141
- return t && r && wi(e, n, r), r;
2142
- }, fe = (i, e) => (n, t) => e(n, t, i);
2143
- let je = class extends oe {
2144
- constructor(i, e, n, t, r) {
2145
- super(), this._drawingManagerService = i, this._renderManagerService = e, this._permissionService = n, this._univerInstanceService = t, this._userManagerService = r, this._initDrawingVisible(), this._initDrawingEditable(), this._initViewPermissionChange(), this._initEditPermissionChange();
2112
+ }, __name(_a6, "SheetDrawingPrintingController"), _a6);
2113
+ SheetDrawingPrintingController = __decorateClass$3([
2114
+ OnLifecycle(LifecycleStages.Rendered, SheetDrawingPrintingController),
2115
+ __decorateParam$3(0, Inject(SheetPrintInterceptorService)),
2116
+ __decorateParam$3(1, Inject(DrawingRenderService)),
2117
+ __decorateParam$3(2, IDrawingManagerService),
2118
+ __decorateParam$3(3, IRenderManagerService)
2119
+ ], SheetDrawingPrintingController);
2120
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2121
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2122
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2123
+ return kind && result && __defProp$2(target, key, result), result;
2124
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a7;
2125
+ let SheetDrawingPermissionController = (_a7 = class extends Disposable {
2126
+ constructor(_drawingManagerService, _renderManagerService, _permissionService, _univerInstanceService, _userManagerService) {
2127
+ super(), this._drawingManagerService = _drawingManagerService, this._renderManagerService = _renderManagerService, this._permissionService = _permissionService, this._univerInstanceService = _univerInstanceService, this._userManagerService = _userManagerService, this._initDrawingVisible(), this._initDrawingEditable(), this._initViewPermissionChange(), this._initEditPermissionChange();
2146
2128
  }
2147
2129
  _initDrawingVisible() {
2148
- const i = this._univerInstanceService.getCurrentTypeOfUnit$(B.UNIVER_SHEET);
2130
+ const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
2149
2131
  this.disposeWithMe(
2150
- Re([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
2151
- if (!e) {
2132
+ combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
2133
+ if (!workbook) {
2152
2134
  this._drawingManagerService.setDrawingVisible(!1);
2153
2135
  return;
2154
2136
  }
2155
- e.activeSheet$.subscribe((t) => {
2156
- if (!t) {
2137
+ workbook.activeSheet$.subscribe((sheet) => {
2138
+ if (!sheet) {
2157
2139
  this._drawingManagerService.setDrawingVisible(!1);
2158
2140
  return;
2159
2141
  }
2160
- const r = e.getUnitId(), s = t.getSheetId();
2161
- if (this._permissionService.composePermission([new pt(r).id, new He(r, s).id]).every((a) => a.value))
2142
+ const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
2143
+ if (this._permissionService.composePermission([new WorkbookViewPermission(unitId).id, new WorksheetViewPermission(unitId, subUnitId).id]).every((permission) => permission.value))
2162
2144
  this._drawingManagerService.setDrawingVisible(!0);
2163
2145
  else {
2164
2146
  this._drawingManagerService.setDrawingVisible(!1);
2165
- const a = e.getUnitId(), d = t.getSheetId(), h = this._drawingManagerService.getDrawingData(a, d), l = Object.values(h), c = this._renderManagerService.getRenderById(a), u = c == null ? void 0 : c.scene;
2166
- if (u == null)
2147
+ const unitId2 = workbook.getUnitId(), subUnitId2 = sheet.getSheetId(), drawingData = this._drawingManagerService.getDrawingData(unitId2, subUnitId2), drawingDataValues = Object.values(drawingData), renderObject = this._renderManagerService.getRenderById(unitId2), scene = renderObject == null ? void 0 : renderObject.scene;
2148
+ if (scene == null)
2167
2149
  return;
2168
- u.getAllObjects().forEach((f) => {
2169
- f.classType === ae.IMAGE && l.some((m) => f.oKey.includes(m.drawingId)) && u.removeObject(f);
2150
+ scene.getAllObjects().forEach((object) => {
2151
+ object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.removeObject(object);
2170
2152
  });
2171
2153
  }
2172
2154
  });
@@ -2174,28 +2156,28 @@ let je = class extends oe {
2174
2156
  );
2175
2157
  }
2176
2158
  _initDrawingEditable() {
2177
- const i = this._univerInstanceService.getCurrentTypeOfUnit$(B.UNIVER_SHEET);
2159
+ const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
2178
2160
  this.disposeWithMe(
2179
- Re([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
2180
- if (!e) {
2161
+ combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
2162
+ if (!workbook) {
2181
2163
  this._drawingManagerService.setDrawingEditable(!1);
2182
2164
  return;
2183
2165
  }
2184
- e.activeSheet$.subscribe((t) => {
2185
- if (!t) {
2166
+ workbook.activeSheet$.subscribe((sheet) => {
2167
+ if (!sheet) {
2186
2168
  this._drawingManagerService.setDrawingEditable(!1);
2187
2169
  return;
2188
2170
  }
2189
- const r = e.getUnitId(), s = t.getSheetId();
2190
- if (this._permissionService.composePermission([new Ze(r).id, new Pe(r, s).id]).every((a) => a.value))
2171
+ const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
2172
+ if (this._permissionService.composePermission([new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id]).every((permission) => permission.value))
2191
2173
  this._drawingManagerService.setDrawingEditable(!0);
2192
2174
  else {
2193
2175
  this._drawingManagerService.setDrawingEditable(!1);
2194
- const a = e.getUnitId(), d = t.getSheetId(), h = this._drawingManagerService.getDrawingData(a, d), l = Object.values(h), c = this._renderManagerService.getRenderById(a), u = c == null ? void 0 : c.scene;
2195
- if (u == null)
2176
+ const unitId2 = workbook.getUnitId(), subUnitId2 = sheet.getSheetId(), drawingData = this._drawingManagerService.getDrawingData(unitId2, subUnitId2), drawingDataValues = Object.values(drawingData), renderObject = this._renderManagerService.getRenderById(unitId2), scene = renderObject == null ? void 0 : renderObject.scene;
2177
+ if (scene == null)
2196
2178
  return;
2197
- u.getAllObjects().forEach((f) => {
2198
- f.classType === ae.IMAGE && l.some((m) => f.oKey.includes(m.drawingId)) && u.detachTransformerFrom(f);
2179
+ scene.getAllObjects().forEach((object) => {
2180
+ object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.detachTransformerFrom(object);
2199
2181
  });
2200
2182
  }
2201
2183
  });
@@ -2203,303 +2185,297 @@ let je = class extends oe {
2203
2185
  );
2204
2186
  }
2205
2187
  _initViewPermissionChange() {
2206
- const i = this._univerInstanceService.getCurrentTypeOfUnit$(B.UNIVER_SHEET);
2188
+ const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
2207
2189
  this.disposeWithMe(
2208
- Re([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
2209
- e && e.activeSheet$.subscribe((t) => {
2210
- var c;
2211
- if (!t)
2190
+ combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
2191
+ workbook && workbook.activeSheet$.subscribe((sheet) => {
2192
+ var _a10;
2193
+ if (!sheet)
2212
2194
  return;
2213
- const r = e.getUnitId(), s = t.getSheetId();
2214
- let o = !0;
2215
- const a = this._renderManagerService.getRenderById(r), d = a == null ? void 0 : a.scene;
2216
- if (d == null)
2195
+ const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
2196
+ let initialViewPermission = !0;
2197
+ const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
2198
+ if (scene == null)
2217
2199
  return;
2218
- const h = d.getTransformerByCreate(), l = this._permissionService.composePermission$([new pt(r).id, new He(r, s).id]).pipe(ft((u) => u.every((g) => g.value)));
2219
- l == null || l.pipe(
2220
- Me((u) => u !== o),
2221
- De()
2200
+ const transformer = scene.getTransformerByCreate(), worksheetViewPermission$ = this._permissionService.composePermission$([new WorkbookViewPermission(unitId).id, new WorksheetViewPermission(unitId, subUnitId).id]).pipe(map((permissions) => permissions.every((item) => item.value)));
2201
+ worksheetViewPermission$ == null || worksheetViewPermission$.pipe(
2202
+ filter((permission) => permission !== initialViewPermission),
2203
+ distinctUntilChanged()
2222
2204
  ).subscribe({
2223
- next: (u) => {
2224
- o = u, this._drawingManagerService.setDrawingVisible(u);
2225
- const g = d.getAllObjects(), f = this._drawingManagerService.getDrawingData(r, s), m = Object.values(f);
2226
- u ? this._drawingManagerService.addNotification(m) : (g.forEach((p) => {
2227
- p.classType === ae.IMAGE && m.some((S) => p.oKey.includes(S.drawingId)) && d.removeObject(p);
2228
- }), h.clearSelectedObjects());
2229
- }
2230
- }), (c = this._permissionService.getPermissionPoint$(new He(r, s).id)) == null || c.pipe(
2231
- Me((u) => u.value !== o),
2232
- De()
2205
+ next: /* @__PURE__ */ __name((permission) => {
2206
+ initialViewPermission = permission, this._drawingManagerService.setDrawingVisible(permission);
2207
+ const objects = scene.getAllObjects(), drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), drawingDataValues = Object.values(drawingData);
2208
+ permission ? this._drawingManagerService.addNotification(drawingDataValues) : (objects.forEach((object) => {
2209
+ object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.removeObject(object);
2210
+ }), transformer.clearSelectedObjects());
2211
+ }, "next")
2212
+ }), (_a10 = this._permissionService.getPermissionPoint$(new WorksheetViewPermission(unitId, subUnitId).id)) == null || _a10.pipe(
2213
+ filter((permission) => permission.value !== initialViewPermission),
2214
+ distinctUntilChanged()
2233
2215
  ).subscribe({
2234
- complete: () => {
2235
- o = !0, this._drawingManagerService.setDrawingVisible(!0);
2236
- const u = this._drawingManagerService.getDrawingData(r, s), g = Object.values(u);
2237
- this._drawingManagerService.addNotification(g);
2238
- }
2216
+ complete: /* @__PURE__ */ __name(() => {
2217
+ initialViewPermission = !0, this._drawingManagerService.setDrawingVisible(!0);
2218
+ const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), drawingDataValues = Object.values(drawingData);
2219
+ this._drawingManagerService.addNotification(drawingDataValues);
2220
+ }, "complete")
2239
2221
  });
2240
2222
  });
2241
2223
  })
2242
2224
  );
2243
2225
  }
2244
2226
  _initEditPermissionChange() {
2245
- const i = this._univerInstanceService.getCurrentTypeOfUnit$(B.UNIVER_SHEET);
2227
+ const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
2246
2228
  this.disposeWithMe(
2247
- Re([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
2248
- e && e.activeSheet$.subscribe((t) => {
2249
- var c;
2250
- if (!t)
2229
+ combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
2230
+ workbook && workbook.activeSheet$.subscribe((sheet) => {
2231
+ var _a10;
2232
+ if (!sheet)
2251
2233
  return;
2252
- const r = e.getUnitId(), s = t.getSheetId();
2253
- let o = !0;
2254
- const a = this._renderManagerService.getRenderById(r), d = a == null ? void 0 : a.scene;
2255
- if (d == null)
2234
+ const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
2235
+ let initialEditPermission = !0;
2236
+ const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
2237
+ if (scene == null)
2256
2238
  return;
2257
- const h = d.getTransformerByCreate(), l = this._permissionService.composePermission$([new Ze(r).id, new Pe(r, s).id]).pipe(ft((u) => u.every((g) => g.value)));
2258
- l == null || l.pipe(
2259
- Me((u) => u !== o),
2260
- De()
2239
+ const transformer = scene.getTransformerByCreate(), composeWorksheetEditPermission = this._permissionService.composePermission$([new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id]).pipe(map((permissions) => permissions.every((item) => item.value)));
2240
+ composeWorksheetEditPermission == null || composeWorksheetEditPermission.pipe(
2241
+ filter((permission) => permission !== initialEditPermission),
2242
+ distinctUntilChanged()
2261
2243
  ).subscribe({
2262
- next: (u) => {
2263
- o = u, this._drawingManagerService.setDrawingEditable(u);
2264
- const g = d.getAllObjects(), f = this._drawingManagerService.getDrawingData(r, s), m = Object.values(f);
2265
- u ? (g.forEach((p) => {
2266
- p.classType === ae.IMAGE && m.some((S) => p.oKey.includes(S.drawingId)) && d.attachTransformerTo(p);
2267
- }), this._drawingManagerService.addNotification(m)) : (g.forEach((p) => {
2268
- p.classType === ae.IMAGE && m.some((S) => p.oKey.includes(S.drawingId)) && d.detachTransformerFrom(p);
2269
- }), h.clearSelectedObjects());
2270
- }
2271
- }), (c = this._permissionService.getPermissionPoint$(new Pe(r, s).id)) == null || c.pipe(
2272
- Me((u) => u.value !== o),
2273
- De()
2244
+ next: /* @__PURE__ */ __name((permission) => {
2245
+ initialEditPermission = permission, this._drawingManagerService.setDrawingEditable(permission);
2246
+ const objects = scene.getAllObjects(), drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), drawingDataValues = Object.values(drawingData);
2247
+ permission ? (objects.forEach((object) => {
2248
+ object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.attachTransformerTo(object);
2249
+ }), this._drawingManagerService.addNotification(drawingDataValues)) : (objects.forEach((object) => {
2250
+ object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.detachTransformerFrom(object);
2251
+ }), transformer.clearSelectedObjects());
2252
+ }, "next")
2253
+ }), (_a10 = this._permissionService.getPermissionPoint$(new WorksheetEditPermission(unitId, subUnitId).id)) == null || _a10.pipe(
2254
+ filter((permission) => permission.value !== initialEditPermission),
2255
+ distinctUntilChanged()
2274
2256
  ).subscribe({
2275
- complete: () => {
2276
- o = !0;
2277
- const u = e.getUnitId(), g = t.getSheetId(), f = this._drawingManagerService.getDrawingData(u, g), m = Object.values(f), p = this._renderManagerService.getRenderById(u), S = p == null ? void 0 : p.scene;
2278
- if (S == null)
2257
+ complete: /* @__PURE__ */ __name(() => {
2258
+ initialEditPermission = !0;
2259
+ const unitId2 = workbook.getUnitId(), subUnitId2 = sheet.getSheetId(), drawingData = this._drawingManagerService.getDrawingData(unitId2, subUnitId2), drawingDataValues = Object.values(drawingData), renderObject2 = this._renderManagerService.getRenderById(unitId2), scene2 = renderObject2 == null ? void 0 : renderObject2.scene;
2260
+ if (scene2 == null)
2279
2261
  return;
2280
- this._drawingManagerService.setDrawingEditable(!0), S.getAllObjects().forEach((v) => {
2281
- v.classType === ae.IMAGE && m.some((R) => v.oKey.includes(R.drawingId)) && S.detachTransformerFrom(v);
2262
+ this._drawingManagerService.setDrawingEditable(!0), scene2.getAllObjects().forEach((object) => {
2263
+ object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene2.detachTransformerFrom(object);
2282
2264
  });
2283
- }
2265
+ }, "complete")
2284
2266
  });
2285
2267
  });
2286
2268
  })
2287
2269
  );
2288
2270
  }
2289
- };
2290
- je = vi([
2291
- ie(se.Rendered, je),
2292
- fe(0, z),
2293
- fe(1, K),
2294
- fe(2, ln),
2295
- fe(3, he),
2296
- fe(4, W(dn))
2297
- ], je);
2298
- var Si = Object.defineProperty, Ci = Object.getOwnPropertyDescriptor, Ii = (i, e, n, t) => {
2299
- for (var r = t > 1 ? void 0 : t ? Ci(e, n) : e, s = i.length - 1, o; s >= 0; s--)
2300
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
2301
- return t && r && Si(e, n, r), r;
2302
- }, Ke = (i, e) => (n, t) => e(n, t, i);
2303
- let Le = class extends oe {
2304
- constructor(e, n, t) {
2271
+ }, __name(_a7, "SheetDrawingPermissionController"), _a7);
2272
+ SheetDrawingPermissionController = __decorateClass$2([
2273
+ OnLifecycle(LifecycleStages.Rendered, SheetDrawingPermissionController),
2274
+ __decorateParam$2(0, IDrawingManagerService),
2275
+ __decorateParam$2(1, IRenderManagerService),
2276
+ __decorateParam$2(2, IPermissionService),
2277
+ __decorateParam$2(3, IUniverInstanceService),
2278
+ __decorateParam$2(4, Inject(UserManagerService))
2279
+ ], SheetDrawingPermissionController);
2280
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2281
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2282
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2283
+ return kind && result && __defProp$1(target, key, result), result;
2284
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a8;
2285
+ let SheetsDrawingCopyPasteController = (_a8 = class extends Disposable {
2286
+ constructor(_sheetClipboardService, _renderManagerService, _sheetDrawingService) {
2305
2287
  super();
2306
- H(this, "_copyInfo");
2307
- this._sheetClipboardService = e, this._renderManagerService = n, this._sheetDrawingService = t, this._initCopyPaste();
2288
+ __publicField(this, "_copyInfo");
2289
+ this._sheetClipboardService = _sheetClipboardService, this._renderManagerService = _renderManagerService, this._sheetDrawingService = _sheetDrawingService, this._initCopyPaste();
2308
2290
  }
2309
2291
  _initCopyPaste() {
2310
2292
  this._sheetClipboardService.addClipboardHook({
2311
2293
  id: "SHEET_IMAGE_UI_PLUGIN",
2312
- onBeforeCopy: (e, n, t) => this._collect(e, n, t),
2313
- onPasteCells: (e, n, t, r) => {
2314
- const { copyType: s = gt.COPY, pasteType: o } = r, { range: a } = e || {}, { range: d, unitId: h, subUnitId: l } = n;
2315
- return this._generateMutations(d, { copyType: s, pasteType: o, copyRange: a, unitId: h, subUnitId: l });
2316
- },
2317
- onPastePlainText: (e, n) => ({ undos: [], redos: [] })
2294
+ onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => this._collect(unitId, subUnitId, range), "onBeforeCopy"),
2295
+ onPasteCells: /* @__PURE__ */ __name((pasteFrom, pasteTo, data, payload) => {
2296
+ const { copyType = COPY_TYPE.COPY, pasteType } = payload, { range: copyRange } = pasteFrom || {}, { range: pastedRange, unitId, subUnitId } = pasteTo;
2297
+ return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });
2298
+ }, "onPasteCells"),
2299
+ onPastePlainText: /* @__PURE__ */ __name((pasteTo, clipText) => ({ undos: [], redos: [] }), "onPastePlainText")
2318
2300
  });
2319
2301
  }
2320
- _collect(e, n, t) {
2321
- var u;
2322
- const r = (u = this._renderManagerService.getRenderById(e)) == null ? void 0 : u.with(re);
2323
- if (!r) return;
2324
- const s = r.attachRangeWithCoord(t);
2325
- if (!s)
2302
+ _collect(unitId, subUnitId, range) {
2303
+ var _a10;
2304
+ const skeletonManagetService = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.with(SheetSkeletonManagerService);
2305
+ if (!skeletonManagetService) return;
2306
+ const selectionRect = skeletonManagetService.attachRangeWithCoord(range);
2307
+ if (!selectionRect)
2326
2308
  return;
2327
- const { startX: o, endX: a, startY: d, endY: h } = s, l = this._sheetDrawingService.getDrawingData(e, n), c = [];
2328
- Object.keys(l).forEach((g) => {
2329
- const f = l[g], { transform: m } = f;
2330
- if (f.anchorType !== O.Both || !m)
2309
+ const { startX, endX, startY, endY } = selectionRect, drawings = this._sheetDrawingService.getDrawingData(unitId, subUnitId), containedDrawings = [];
2310
+ Object.keys(drawings).forEach((drawingId) => {
2311
+ const drawing = drawings[drawingId], { transform } = drawing;
2312
+ if (drawing.anchorType !== SheetDrawingAnchorType.Both || !transform)
2331
2313
  return;
2332
- const { left: p = 0, top: S = 0, width: C = 0, height: v = 0 } = m, { drawingStartX: R, drawingEndX: _, drawingStartY: b, drawingEndY: w } = {
2333
- drawingStartX: p,
2334
- drawingEndX: p + C,
2335
- drawingStartY: S,
2336
- drawingEndY: S + v
2314
+ const { left = 0, top = 0, width = 0, height = 0 } = transform, { drawingStartX, drawingEndX, drawingStartY, drawingEndY } = {
2315
+ drawingStartX: left,
2316
+ drawingEndX: left + width,
2317
+ drawingStartY: top,
2318
+ drawingEndY: top + height
2337
2319
  };
2338
- o <= R && _ <= a && d <= b && w <= h && c.push(f);
2339
- }), c.length && (this._copyInfo = {
2340
- drawings: c,
2341
- unitId: e,
2342
- subUnitId: n
2320
+ startX <= drawingStartX && drawingEndX <= endX && startY <= drawingStartY && drawingEndY <= endY && containedDrawings.push(drawing);
2321
+ }), containedDrawings.length && (this._copyInfo = {
2322
+ drawings: containedDrawings,
2323
+ unitId,
2324
+ subUnitId
2343
2325
  });
2344
2326
  }
2345
2327
  // eslint-disable-next-line max-lines-per-function
2346
- _generateMutations(e, n) {
2347
- var D;
2328
+ _generateMutations(pastedRange, copyInfo) {
2329
+ var _a10;
2348
2330
  if (!this._copyInfo)
2349
2331
  return { redos: [], undos: [] };
2350
2332
  if ([
2351
- Ie.SPECIAL_PASTE_COL_WIDTH,
2352
- Ie.SPECIAL_PASTE_VALUE,
2353
- Ie.SPECIAL_PASTE_FORMAT,
2354
- Ie.SPECIAL_PASTE_FORMULA
2333
+ PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,
2334
+ PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,
2335
+ PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,
2336
+ PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA
2355
2337
  ].includes(
2356
- n.pasteType
2338
+ copyInfo.pasteType
2357
2339
  ))
2358
2340
  return { redos: [], undos: [] };
2359
- const { copyRange: t } = n;
2360
- if (!t)
2341
+ const { copyRange } = copyInfo;
2342
+ if (!copyRange)
2361
2343
  return { redos: [], undos: [] };
2362
- const { drawings: r, unitId: s, subUnitId: o } = this._copyInfo, { ranges: [a, d], mapFunc: h } = Bn([t, e]), { row: l, col: c } = h(a.startRow, a.startColumn), { row: u, col: g } = h(d.startRow, d.startColumn), f = (D = this._renderManagerService.getRenderById(s)) == null ? void 0 : D.with(re);
2363
- if (!f)
2344
+ const { drawings, unitId, subUnitId } = this._copyInfo, { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyRange, pastedRange]), { row: copyRow, col: copyCol } = mapFunc(vCopyRange.startRow, vCopyRange.startColumn), { row: pasteRow, col: pasteCol } = mapFunc(vPastedRange.startRow, vPastedRange.startColumn), skeletonManagetService = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.with(SheetSkeletonManagerService);
2345
+ if (!skeletonManagetService)
2364
2346
  return { redos: [], undos: [] };
2365
- const m = f.attachRangeWithCoord({
2366
- startRow: l,
2367
- endRow: l,
2368
- startColumn: c,
2369
- endColumn: c
2370
- }), p = f.attachRangeWithCoord({
2371
- startRow: u,
2372
- endRow: u,
2373
- startColumn: g,
2374
- endColumn: g
2347
+ const copyRect = skeletonManagetService.attachRangeWithCoord({
2348
+ startRow: copyRow,
2349
+ endRow: copyRow,
2350
+ startColumn: copyCol,
2351
+ endColumn: copyCol
2352
+ }), pasteRect = skeletonManagetService.attachRangeWithCoord({
2353
+ startRow: pasteRow,
2354
+ endRow: pasteRow,
2355
+ startColumn: pasteCol,
2356
+ endColumn: pasteCol
2375
2357
  });
2376
- if (!m || !p)
2358
+ if (!copyRect || !pasteRect)
2377
2359
  return { redos: [], undos: [] };
2378
- const S = [], C = [], v = p.startX - m.startX, R = p.startY - m.startY, _ = u - l, b = g - c, w = n.copyType === gt.CUT, { _sheetDrawingService: P } = this;
2379
- return r.forEach((T) => {
2380
- const { transform: U, sheetTransform: M } = T;
2381
- if (!U)
2360
+ const redos = [], undos = [], leftOffset = pasteRect.startX - copyRect.startX, topOffset = pasteRect.startY - copyRect.startY, rowOffset = pasteRow - copyRow, columnOffset = pasteCol - copyCol, isCut = copyInfo.copyType === COPY_TYPE.CUT, { _sheetDrawingService } = this;
2361
+ return drawings.forEach((drawing) => {
2362
+ const { transform, sheetTransform } = drawing;
2363
+ if (!transform)
2382
2364
  return;
2383
- const I = {
2384
- ...T,
2385
- unitId: s,
2386
- subUnitId: o,
2387
- drawingId: w ? T.drawingId : ne.generateRandomId(),
2365
+ const drawingObject = {
2366
+ ...drawing,
2367
+ unitId,
2368
+ subUnitId,
2369
+ drawingId: isCut ? drawing.drawingId : Tools.generateRandomId(),
2388
2370
  transform: {
2389
- ...U,
2390
- left: U.left + v,
2391
- top: U.top + R
2371
+ ...transform,
2372
+ left: transform.left + leftOffset,
2373
+ top: transform.top + topOffset
2392
2374
  },
2393
2375
  sheetTransform: {
2394
- to: { ...M.to, row: M.to.row + _, column: M.to.column + b },
2395
- from: { ...M.from, row: M.from.row + _, column: M.from.column + b }
2376
+ to: { ...sheetTransform.to, row: sheetTransform.to.row + rowOffset, column: sheetTransform.to.column + columnOffset },
2377
+ from: { ...sheetTransform.from, row: sheetTransform.from.row + rowOffset, column: sheetTransform.from.column + columnOffset }
2396
2378
  }
2397
2379
  };
2398
- if (w) {
2399
- const { undo: A, redo: G, objects: J } = P.getBatchUpdateOp([I]);
2400
- S.push({
2401
- id: E.id,
2380
+ if (isCut) {
2381
+ const { undo, redo, objects } = _sheetDrawingService.getBatchUpdateOp([drawingObject]);
2382
+ redos.push({
2383
+ id: SetDrawingApplyMutation.id,
2402
2384
  params: {
2403
- unitId: s,
2404
- subUnitId: o,
2405
- type: y.UPDATE,
2406
- op: G,
2407
- objects: J
2385
+ unitId,
2386
+ subUnitId,
2387
+ type: DrawingApplyType.UPDATE,
2388
+ op: redo,
2389
+ objects
2408
2390
  }
2409
- }), C.push({
2410
- id: E.id,
2391
+ }), undos.push({
2392
+ id: SetDrawingApplyMutation.id,
2411
2393
  params: {
2412
- unitId: s,
2413
- subUnitId: o,
2414
- type: y.UPDATE,
2415
- op: A,
2416
- objects: J
2394
+ unitId,
2395
+ subUnitId,
2396
+ type: DrawingApplyType.UPDATE,
2397
+ op: undo,
2398
+ objects
2417
2399
  }
2418
2400
  });
2419
2401
  } else {
2420
- const { undo: A, redo: G, objects: J } = P.getBatchAddOp([I]);
2421
- S.push({ id: E.id, params: { op: G, unitId: s, subUnitId: o, objects: J, type: y.INSERT } }), C.push({ id: E.id, params: { op: A, unitId: s, subUnitId: o, objects: J, type: y.REMOVE } });
2402
+ const { undo, redo, objects } = _sheetDrawingService.getBatchAddOp([drawingObject]);
2403
+ redos.push({ id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT } }), undos.push({ id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.REMOVE } });
2422
2404
  }
2423
2405
  }), {
2424
- redos: S,
2425
- undos: C
2406
+ redos,
2407
+ undos
2426
2408
  };
2427
2409
  }
2428
- };
2429
- Le = Ii([
2430
- ie(se.Ready, Le),
2431
- Ke(0, Wn),
2432
- Ke(1, K),
2433
- Ke(2, k)
2434
- ], Le);
2435
- var qt = Object.defineProperty, Ri = Object.getOwnPropertyDescriptor, Mi = (i, e, n) => e in i ? qt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, Di = (i, e, n, t) => {
2436
- for (var r = t > 1 ? void 0 : t ? Ri(e, n) : e, s = i.length - 1, o; s >= 0; s--)
2437
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
2438
- return t && r && qt(e, n, r), r;
2439
- }, Je = (i, e) => (n, t) => e(n, t, i), Qt = (i, e, n) => Mi(i, typeof e != "symbol" ? e + "" : e, n);
2440
- const bi = "SHEET_IMAGE_UI_PLUGIN";
2441
- let $e = class extends un {
2442
- constructor(e = {}, n, t, r) {
2410
+ }, __name(_a8, "SheetsDrawingCopyPasteController"), _a8);
2411
+ SheetsDrawingCopyPasteController = __decorateClass$1([
2412
+ OnLifecycle(LifecycleStages.Ready, SheetsDrawingCopyPasteController),
2413
+ __decorateParam$1(0, ISheetClipboardService),
2414
+ __decorateParam$1(1, IRenderManagerService),
2415
+ __decorateParam$1(2, ISheetDrawingService)
2416
+ ], SheetsDrawingCopyPasteController);
2417
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2418
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2419
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2420
+ return kind && result && __defProp2(target, key, result), result;
2421
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField");
2422
+ const PLUGIN_NAME = "SHEET_IMAGE_UI_PLUGIN";
2423
+ var _a9;
2424
+ let UniverSheetsDrawingUIPlugin = (_a9 = class extends Plugin {
2425
+ constructor(config = {}, _injector, _localeService, _renderManagerService) {
2443
2426
  super();
2444
- H(this, "_pluginConfig");
2445
- this._injector = n, this._localeService = t, this._renderManagerService = r, this._pluginConfig = ne.deepMerge({}, ii, e);
2427
+ __publicField(this, "_pluginConfig");
2428
+ this._injector = _injector, this._localeService = _localeService, this._renderManagerService = _renderManagerService, this._pluginConfig = Tools.deepMerge({}, DefaultSheetsDrawingConfig, config);
2446
2429
  }
2447
- onStarting(e) {
2448
- super.onStarting(e), this._initDependencies(e);
2430
+ onStarting() {
2431
+ this._initDependencies();
2449
2432
  }
2450
2433
  onRendered() {
2451
2434
  this._registerRenderModules();
2452
2435
  }
2453
- _initDependencies(e) {
2454
- const n = [
2455
- // services
2456
- [tt],
2457
- // controllers
2458
- [
2459
- pe,
2460
- {
2461
- useFactory: () => this._injector.createInstance(pe, this._pluginConfig)
2462
- }
2463
- ],
2464
- [Te],
2465
- [Ne],
2466
- [je]
2467
- ], t = [
2468
- Ue,
2469
- Ae
2470
- ];
2471
- n.forEach((r) => e.add(r)), t.forEach((r) => this._renderManagerService.registerRenderModule(B.UNIVER_SHEET, r));
2436
+ _initDependencies() {
2437
+ [
2438
+ [SheetCanvasFloatDomManagerService],
2439
+ [SheetDrawingUIController, {
2440
+ useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SheetDrawingUIController, this._pluginConfig), "useFactory")
2441
+ }],
2442
+ [DrawingPopupMenuController],
2443
+ [SheetDrawingPrintingController],
2444
+ [SheetDrawingPermissionController]
2445
+ ].forEach((dependency) => this._injector.add(dependency));
2472
2446
  }
2473
2447
  _registerRenderModules() {
2474
2448
  [
2475
- [Le]
2476
- ].forEach((e) => {
2477
- this.disposeWithMe(this._renderManagerService.registerRenderModule(B.UNIVER_SHEET, e));
2449
+ [SheetDrawingUpdateController],
2450
+ [SheetDrawingTransformAffectedController],
2451
+ [SheetsDrawingCopyPasteController]
2452
+ ].forEach((m) => {
2453
+ this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, m));
2478
2454
  });
2479
2455
  }
2480
- };
2481
- Qt($e, "type", B.UNIVER_SHEET);
2482
- Qt($e, "pluginName", bi);
2483
- $e = Di([
2484
- gn(Dn, vn, Sn),
2485
- Je(1, W(nt)),
2486
- Je(2, W(_e)),
2487
- Je(3, K)
2488
- ], $e);
2456
+ }, __name(_a9, "UniverSheetsDrawingUIPlugin"), _a9);
2457
+ __publicField2(UniverSheetsDrawingUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
2458
+ __publicField2(UniverSheetsDrawingUIPlugin, "pluginName", PLUGIN_NAME);
2459
+ UniverSheetsDrawingUIPlugin = __decorateClass([
2460
+ DependentOn(UniverDrawingPlugin, UniverDrawingUIPlugin, UniverSheetsDrawingPlugin),
2461
+ __decorateParam(1, Inject(Injector)),
2462
+ __decorateParam(2, Inject(LocaleService)),
2463
+ __decorateParam(3, IRenderManagerService)
2464
+ ], UniverSheetsDrawingUIPlugin);
2489
2465
  export {
2490
- j as ClearSheetDrawingTransformerOperation,
2491
- Zt as DeleteDrawingsCommand,
2492
- Gt as EditSheetDrawingOperation,
2493
- Ft as GroupSheetDrawingCommand,
2494
- Be as InsertCellImageOperation,
2495
- xe as InsertFloatImageOperation,
2496
- st as InsertSheetDrawingCommand,
2497
- ve as MoveDrawingsCommand,
2498
- it as RemoveSheetDrawingCommand,
2499
- xt as SetDrawingArrangeCommand,
2500
- Fe as SetSheetDrawingCommand,
2501
- tt as SheetCanvasFloatDomManagerService,
2502
- Vt as SidebarSheetDrawingOperation,
2503
- Yt as UngroupSheetDrawingCommand,
2504
- $e as UniverSheetsDrawingUIPlugin
2466
+ ClearSheetDrawingTransformerOperation,
2467
+ DeleteDrawingsCommand,
2468
+ EditSheetDrawingOperation,
2469
+ GroupSheetDrawingCommand,
2470
+ InsertCellImageOperation,
2471
+ InsertFloatImageOperation,
2472
+ InsertSheetDrawingCommand,
2473
+ MoveDrawingsCommand,
2474
+ RemoveSheetDrawingCommand,
2475
+ SetDrawingArrangeCommand,
2476
+ SetSheetDrawingCommand,
2477
+ SheetCanvasFloatDomManagerService,
2478
+ SidebarSheetDrawingOperation,
2479
+ UngroupSheetDrawingCommand,
2480
+ UniverSheetsDrawingUIPlugin
2505
2481
  };