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