@univerjs/sheets-drawing-ui 0.1.16 → 0.2.0

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