@univerjs/sheets-drawing-ui 0.2.5 → 0.2.7

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