@univerjs/sheets-drawing-ui 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +7 -2
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +1 -1389
- package/lib/es/index.js +7 -4388
- package/lib/es/locale/ca-ES.js +1 -54
- package/lib/es/locale/en-US.js +1 -54
- package/lib/es/locale/es-ES.js +1 -54
- package/lib/es/locale/fa-IR.js +1 -54
- package/lib/es/locale/fr-FR.js +1 -54
- package/lib/es/locale/ja-JP.js +1 -54
- package/lib/es/locale/ko-KR.js +1 -54
- package/lib/es/locale/ru-RU.js +1 -54
- package/lib/es/locale/sk-SK.js +1 -54
- package/lib/es/locale/vi-VN.js +1 -54
- package/lib/es/locale/zh-CN.js +1 -54
- package/lib/es/locale/zh-TW.js +1 -54
- package/lib/facade.js +1 -1389
- package/lib/index.css +66 -1
- package/lib/index.js +7 -4388
- package/lib/locale/ca-ES.js +1 -54
- package/lib/locale/en-US.js +1 -54
- package/lib/locale/es-ES.js +1 -54
- package/lib/locale/fa-IR.js +1 -54
- package/lib/locale/fr-FR.js +1 -54
- package/lib/locale/ja-JP.js +1 -54
- package/lib/locale/ko-KR.js +1 -54
- package/lib/locale/ru-RU.js +1 -54
- package/lib/locale/sk-SK.js +1 -54
- package/lib/locale/vi-VN.js +1 -54
- package/lib/locale/zh-CN.js +1 -54
- package/lib/locale/zh-TW.js +1 -54
- package/lib/types/basics/transform-position.d.ts +18 -3
- package/lib/types/commands/commands/delete-drawings.command.d.ts +16 -1
- package/lib/types/commands/commands/flip-drawings.command.d.ts +16 -1
- package/lib/types/commands/commands/group-sheet-drawing.command.d.ts +16 -1
- package/lib/types/commands/commands/insert-image.command.d.ts +16 -1
- package/lib/types/commands/commands/insert-sheet-drawing.command.d.ts +16 -1
- package/lib/types/commands/commands/interfaces.d.ts +17 -2
- package/lib/types/commands/commands/move-drawings.command.d.ts +17 -1
- package/lib/types/commands/commands/remove-sheet-drawing.command.d.ts +16 -1
- package/lib/types/commands/commands/save-cell-images.command.d.ts +16 -1
- package/lib/types/commands/commands/set-drawing-arrange.command.d.ts +18 -2
- package/lib/types/commands/commands/set-sheet-drawing.command.d.ts +16 -1
- package/lib/types/commands/commands/ungroup-sheet-drawing.command.d.ts +16 -1
- package/lib/types/commands/commands/utils.d.ts +23 -1
- package/lib/types/commands/operations/clear-drawing-transformer.operation.d.ts +16 -1
- package/lib/types/commands/operations/edit-sheet-drawing.operation.d.ts +16 -1
- package/lib/types/commands/operations/open-drawing-panel.operation.d.ts +16 -1
- package/lib/types/config/config.d.ts +17 -2
- package/lib/types/controllers/drawing-context-menu.controller.d.ts +28 -0
- package/lib/types/controllers/render-controllers/sheet-celll-image-hover.render-controller.d.ts +16 -1
- package/lib/types/controllers/render-controllers/sheet-drawing.render-controller.d.ts +16 -1
- package/lib/types/controllers/sheet-cell-image-autofill.controller.d.ts +15 -0
- package/lib/types/controllers/sheet-cell-image-copy-paste.controller.d.ts +15 -0
- package/lib/types/controllers/sheet-cell-image.controller.d.ts +19 -2
- package/lib/types/controllers/sheet-drawing-copy-paste.controller.d.ts +15 -0
- package/lib/types/controllers/sheet-drawing-group-copy-paste.controller.d.ts +54 -0
- package/lib/types/controllers/sheet-drawing-permission.controller.d.ts +15 -0
- package/lib/types/controllers/sheet-drawing-printing.controller.d.ts +15 -0
- package/lib/types/controllers/sheet-drawing-transform-affected.controller.d.ts +19 -2
- package/lib/types/controllers/sheet-drawing-update.controller.d.ts +20 -3
- package/lib/types/controllers/sheet-drawing.controller.d.ts +15 -0
- package/lib/types/controllers/shortcuts/drawing.shortcut.d.ts +18 -3
- package/lib/types/facade/f-enum.d.ts +15 -0
- package/lib/types/facade/f-event.d.ts +21 -5
- package/lib/types/facade/f-over-grid-image.d.ts +19 -3
- package/lib/types/facade/f-range.d.ts +15 -0
- package/lib/types/facade/f-univer.d.ts +16 -1
- package/lib/types/facade/f-worksheet.d.ts +23 -7
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/ca-ES.d.ts +16 -1
- package/lib/types/locale/es-ES.d.ts +16 -1
- package/lib/types/locale/fa-IR.d.ts +16 -1
- package/lib/types/locale/fr-FR.d.ts +16 -1
- package/lib/types/locale/ja-JP.d.ts +16 -1
- package/lib/types/locale/ko-KR.d.ts +16 -1
- package/lib/types/locale/ru-RU.d.ts +16 -1
- package/lib/types/locale/sk-SK.d.ts +16 -1
- package/lib/types/locale/vi-VN.d.ts +16 -1
- package/lib/types/locale/zh-CN.d.ts +16 -1
- package/lib/types/locale/zh-TW.d.ts +16 -1
- package/lib/types/menu/drawing-popup-menu.controller.d.ts +17 -1
- package/lib/types/menu/image.menu.d.ts +17 -2
- package/lib/types/menu/save-images.menu.d.ts +17 -2
- package/lib/types/menu/schema.d.ts +16 -1
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/services/batch-save-images.service.d.ts +18 -2
- package/lib/types/services/canvas-float-dom-manager.service.d.ts +24 -6
- package/lib/types/views/printing-float-dom/index.d.ts +18 -3
- package/lib/types/views/sheet-image-panel/SheetDrawingAnchor.d.ts +16 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +7 -2
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +17 -16
package/lib/es/index.js
CHANGED
|
@@ -1,4388 +1,7 @@
|
|
|
1
|
-
var Qr = Object.defineProperty;
|
|
2
|
-
var ei = (i, t, e) => t in i ? Qr(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { SheetInterceptorService as St, SheetsSelectionsService as _t, SetRangeValuesCommand as Gn, getSheetCommandTarget as ce, RangeProtectionPermissionEditPoint as Bi, WorksheetEditPermission as pn, WorkbookEditablePermission as wn, INTERCEPTOR_POINT as $i, InterceptCellContentPriority as Wi, IAutoFillService as ji, discreteRangeToRange as Yn, WorkbookViewPermission as Xn, WorksheetViewPermission as zn, SetFrozenMutation as Fi, SetSelectionsOperation as Li, SetWorksheetRowAutoHeightMutation as pr, COMMAND_LISTENER_SKELETON_CHANGE as Hi, InsertRowCommand as wr, InsertColCommand as Sr, RemoveRowCommand as _r, RemoveColCommand as vr, DeleteRangeMoveLeftCommand as Ir, DeleteRangeMoveUpCommand as Cr, InsertRangeMoveDownCommand as Rr, InsertRangeMoveRightCommand as Dr, DeltaRowHeightCommand as Sn, SetRowHeightCommand as _n, DeltaColumnWidthCommand as br, SetColWidthCommand as Mr, SetRowHiddenCommand as yr, SetSpecificRowsVisibleCommand as Tr, SetSpecificColsVisibleCommand as Er, SetColHiddenCommand as Or, MoveColsCommand as Ur, MoveRowsCommand as Pr, MoveRangeCommand as Ar, SetRowVisibleMutation as Vi, SetRowHiddenMutation as Gi, SetColVisibleMutation as Yi, SetColHiddenMutation as Xi, SetWorksheetRowHeightMutation as zi, SetWorksheetRowIsAutoHeightMutation as Ki, SetWorksheetColWidthMutation as Ji, SetWorksheetActiveOperation as Zi } from "@univerjs/sheets";
|
|
9
|
-
import { MessageType as Me, render as qi, unmount as Qi, FormLayout as sn, CheckboxGroup as es, Checkbox as Kn, Select as ts, Button as Jn, clsx as ns, RadioGroup as rs, Radio as on } from "@univerjs/design";
|
|
10
|
-
import { docDrawingPositionToTransform as Zn, ReplaceSnapshotCommand as is, InnerPasteCommand as ss } from "@univerjs/docs-ui";
|
|
11
|
-
import { IImageIoService as os, IDrawingManagerService as de, DRAWING_IMAGE_ALLOW_IMAGE_LIST as qn, DRAWING_IMAGE_COUNT_LIMIT as Qn, ImageUploadStatusType as Ge, DRAWING_IMAGE_ALLOW_SIZE as er, getImageSize as an, SetDrawingSelectedOperation as Kt, DRAWING_IMAGE_WIDTH_LIMIT as tr, DRAWING_IMAGE_HEIGHT_LIMIT as nr, ImageSourceType as as, getDrawingShapeKeyByDrawingSearch as ye, UniverDrawingPlugin as cs } from "@univerjs/drawing";
|
|
12
|
-
import { ILocalFileService as ds, IMessageService as Nr, IDialogService as En, ISidebarService as ls, getMenuHiddenObservable as Jt, MenuItemType as Zt, IClipboardInterfaceService as us, CanvasFloatDomService as hs, PrintFloatDomSingle as gs, ComponentManager as xr, connectInjector as fs, ContextMenuPosition as cn, ContextMenuGroup as dn, RibbonInsertGroup as ms, useDependency as Ee, KeyCode as rt, IMenuManagerService as ps, IShortcutService as ws } from "@univerjs/ui";
|
|
13
|
-
import { DocDrawingController as Ss, UniverDocsDrawingPlugin as _s } from "@univerjs/docs-drawing";
|
|
14
|
-
import { DrawingRenderService as kr, DrawingCommonPanel as vs, ImageCropperObject as Is, COMPONENT_IMAGE_POPUP_MENU as Cs, OpenImageCropOperation as Rs, ImageResetSizeOperation as Ds, UniverDrawingUIPlugin as bs } from "@univerjs/drawing-ui";
|
|
15
|
-
import { throttleTime as Ms, combineLatest as ft, switchMap as ve, EMPTY as De, tap as rr, map as Ie, distinctUntilChanged as ir, Subject as ln, filter as ys, take as Ts, BehaviorSubject as ze, of as vn } from "rxjs";
|
|
16
|
-
import { jsx as X, jsxs as tt } from "react/jsx-runtime";
|
|
17
|
-
import { useMemo as Ke, useState as ke, useCallback as At, useEffect as Br } from "react";
|
|
18
|
-
function Q(i, t, e) {
|
|
19
|
-
const { from: n, to: r, flipY: s = !1, flipX: o = !1, angle: a = 0, skewX: c = 0, skewY: u = 0 } = i, d = e.getCurrent();
|
|
20
|
-
if (d == null)
|
|
21
|
-
return;
|
|
22
|
-
const l = ii(
|
|
23
|
-
d.unitId,
|
|
24
|
-
d.sheetId,
|
|
25
|
-
{ from: n, to: r },
|
|
26
|
-
e
|
|
27
|
-
);
|
|
28
|
-
let { left: g, top: h, width: f, height: m } = l;
|
|
29
|
-
const p = e.getCurrentSkeleton(), S = p.rowHeaderWidth + p.columnTotalWidth, _ = p.columnHeaderHeight + p.rowTotalHeight;
|
|
30
|
-
return g + f > S && (g = S - f), h + m > _ && (h = _ - m), {
|
|
31
|
-
flipY: s,
|
|
32
|
-
flipX: o,
|
|
33
|
-
angle: a,
|
|
34
|
-
skewX: c,
|
|
35
|
-
skewY: u,
|
|
36
|
-
left: g,
|
|
37
|
-
top: h,
|
|
38
|
-
width: f,
|
|
39
|
-
height: m
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function j(i, t) {
|
|
43
|
-
const { left: e = 0, top: n = 0, width: r = 0, height: s = 0, flipY: o = !1, flipX: a = !1, angle: c = 0, skewX: u = 0, skewY: d = 0 } = i, l = t.getCellWithCoordByOffset(e, n);
|
|
44
|
-
if (l == null)
|
|
45
|
-
return;
|
|
46
|
-
const g = {
|
|
47
|
-
column: l.actualColumn,
|
|
48
|
-
columnOffset: Ot(e - l.startX, 1),
|
|
49
|
-
row: l.actualRow,
|
|
50
|
-
rowOffset: Ot(n - l.startY, 1)
|
|
51
|
-
}, h = t.getCellWithCoordByOffset(e + r, n + s);
|
|
52
|
-
if (h == null)
|
|
53
|
-
return;
|
|
54
|
-
const f = {
|
|
55
|
-
column: h.actualColumn,
|
|
56
|
-
columnOffset: Ot(e + r - h.startX, 1),
|
|
57
|
-
row: h.actualRow,
|
|
58
|
-
rowOffset: Ot(n + s - h.startY, 1)
|
|
59
|
-
};
|
|
60
|
-
return {
|
|
61
|
-
flipY: o,
|
|
62
|
-
flipX: a,
|
|
63
|
-
angle: c,
|
|
64
|
-
skewX: u,
|
|
65
|
-
skewY: d,
|
|
66
|
-
from: g,
|
|
67
|
-
to: f
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function F(i, t) {
|
|
71
|
-
const { left: e = 0, top: n = 0, width: r = 0, height: s = 0, angle: o = 0 } = i, a = (o % 360 + 360) % 360;
|
|
72
|
-
if (!(a >= 45 && a < 135 || a >= 225 && a < 315))
|
|
73
|
-
return j(i, t);
|
|
74
|
-
const u = {
|
|
75
|
-
...i,
|
|
76
|
-
left: e + r / 2 - s / 2,
|
|
77
|
-
top: n + s / 2 - r / 2,
|
|
78
|
-
width: s,
|
|
79
|
-
height: r
|
|
80
|
-
};
|
|
81
|
-
return j(u, t);
|
|
82
|
-
}
|
|
83
|
-
const L = {
|
|
84
|
-
id: "sheet.operation.clear-drawing-transformer",
|
|
85
|
-
type: te.MUTATION,
|
|
86
|
-
handler: (i, t) => {
|
|
87
|
-
const e = i.get(ee);
|
|
88
|
-
return t.forEach((n) => {
|
|
89
|
-
var r, s;
|
|
90
|
-
(s = (r = e.getRenderById(n)) == null ? void 0 : r.scene.getTransformer()) == null || s.debounceRefreshControls();
|
|
91
|
-
}), !0;
|
|
92
|
-
}
|
|
93
|
-
}, vt = {
|
|
94
|
-
id: "sheet.command.remove-sheet-image",
|
|
95
|
-
type: te.COMMAND,
|
|
96
|
-
handler: (i, t) => {
|
|
97
|
-
var _, R, M;
|
|
98
|
-
const e = i.get(K), n = i.get(Be), r = i.get(St), s = i.get(ie);
|
|
99
|
-
if (!t) return !1;
|
|
100
|
-
const { drawings: o } = t, a = [];
|
|
101
|
-
o.forEach((I) => {
|
|
102
|
-
const { unitId: v } = I;
|
|
103
|
-
a.push(v);
|
|
104
|
-
});
|
|
105
|
-
const c = s.getBatchRemoveOp(o), { unitId: u, subUnitId: d, undo: l, redo: g, objects: h } = c, f = r.onCommandExecute({ id: vt.id, params: t }), m = { id: A.id, params: { unitId: u, subUnitId: d, op: g, objects: h, type: P.REMOVE } }, p = { id: A.id, params: { unitId: u, subUnitId: d, op: l, objects: h, type: P.INSERT } };
|
|
106
|
-
return zt([...(_ = f.preRedos) != null ? _ : [], m, ...f.redos], e) ? (n.pushUndoRedo({
|
|
107
|
-
unitID: u,
|
|
108
|
-
undoMutations: [
|
|
109
|
-
...(R = f.preUndos) != null ? R : [],
|
|
110
|
-
p,
|
|
111
|
-
...f.undos,
|
|
112
|
-
{ id: L.id, params: a }
|
|
113
|
-
],
|
|
114
|
-
redoMutations: [
|
|
115
|
-
...(M = f.preRedos) != null ? M : [],
|
|
116
|
-
m,
|
|
117
|
-
...f.redos,
|
|
118
|
-
{ id: L.id, params: a }
|
|
119
|
-
]
|
|
120
|
-
}), !0) : !1;
|
|
121
|
-
}
|
|
122
|
-
}, $r = {
|
|
123
|
-
id: "sheet.command.delete-drawing",
|
|
124
|
-
type: te.COMMAND,
|
|
125
|
-
handler: (i) => {
|
|
126
|
-
const t = i.get(K), n = i.get(ie).getFocusDrawings();
|
|
127
|
-
if (n.length === 0)
|
|
128
|
-
return !1;
|
|
129
|
-
const r = n[0].unitId, s = n.map((o) => {
|
|
130
|
-
const { unitId: a, subUnitId: c, drawingId: u, drawingType: d } = o;
|
|
131
|
-
return {
|
|
132
|
-
unitId: a,
|
|
133
|
-
subUnitId: c,
|
|
134
|
-
drawingId: u,
|
|
135
|
-
drawingType: d
|
|
136
|
-
};
|
|
137
|
-
});
|
|
138
|
-
return t.executeCommand(vt.id, {
|
|
139
|
-
unitId: r,
|
|
140
|
-
drawings: s
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
function Es(i) {
|
|
145
|
-
const t = [];
|
|
146
|
-
return i.forEach((e) => {
|
|
147
|
-
const { parent: n, children: r } = e, { unitId: s, subUnitId: o, drawingId: a } = n, c = ni(0, 0, r.map((l) => l.transform || {})), u = r.map((l) => {
|
|
148
|
-
const g = l.transform || { left: 0, top: 0 }, { unitId: h, subUnitId: f, drawingId: m } = l;
|
|
149
|
-
return {
|
|
150
|
-
unitId: h,
|
|
151
|
-
subUnitId: f,
|
|
152
|
-
drawingId: m,
|
|
153
|
-
transform: {
|
|
154
|
-
...g,
|
|
155
|
-
left: g.left,
|
|
156
|
-
top: g.top
|
|
157
|
-
},
|
|
158
|
-
groupId: a
|
|
159
|
-
};
|
|
160
|
-
}), d = {
|
|
161
|
-
unitId: s,
|
|
162
|
-
subUnitId: o,
|
|
163
|
-
drawingId: a,
|
|
164
|
-
drawingType: B.DRAWING_GROUP,
|
|
165
|
-
groupBaseBound: { ...n.groupBaseBound },
|
|
166
|
-
transform: c
|
|
167
|
-
};
|
|
168
|
-
t.push({
|
|
169
|
-
parent: d,
|
|
170
|
-
children: u
|
|
171
|
-
});
|
|
172
|
-
}), t;
|
|
173
|
-
}
|
|
174
|
-
function Os(i) {
|
|
175
|
-
const t = [];
|
|
176
|
-
return i.forEach((e) => {
|
|
177
|
-
const { parent: n, children: r } = e, { unitId: s, subUnitId: o, drawingId: a, transform: c = { width: 0, height: 0 } } = n;
|
|
178
|
-
if (c == null)
|
|
179
|
-
return;
|
|
180
|
-
const u = r.map((l) => {
|
|
181
|
-
const { transform: g } = l, { unitId: h, subUnitId: f, drawingId: m } = l, p = ti(g || {}, c, c.width || 0, c.height || 0, n.groupBaseBound);
|
|
182
|
-
return {
|
|
183
|
-
unitId: h,
|
|
184
|
-
subUnitId: f,
|
|
185
|
-
drawingId: m,
|
|
186
|
-
transform: p,
|
|
187
|
-
groupId: void 0
|
|
188
|
-
};
|
|
189
|
-
}), d = {
|
|
190
|
-
unitId: s,
|
|
191
|
-
subUnitId: o,
|
|
192
|
-
drawingId: a,
|
|
193
|
-
drawingType: B.DRAWING_GROUP,
|
|
194
|
-
transform: {
|
|
195
|
-
left: 0,
|
|
196
|
-
top: 0
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
t.push({
|
|
200
|
-
parent: d,
|
|
201
|
-
children: u
|
|
202
|
-
});
|
|
203
|
-
}), t;
|
|
204
|
-
}
|
|
205
|
-
const Wr = {
|
|
206
|
-
id: "sheet.command.group-sheet-image",
|
|
207
|
-
type: te.COMMAND,
|
|
208
|
-
handler: (i, t) => {
|
|
209
|
-
const e = i.get(K), n = i.get(Be), r = i.get(ie);
|
|
210
|
-
if (!t) return !1;
|
|
211
|
-
const s = [];
|
|
212
|
-
t.forEach(({ parent: h, children: f }) => {
|
|
213
|
-
s.push(h.unitId), f.forEach((m) => {
|
|
214
|
-
s.push(m.unitId);
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
const o = r.getGroupDrawingOp(t), { unitId: a, subUnitId: c, undo: u, redo: d, objects: l } = o;
|
|
218
|
-
return e.syncExecuteCommand(A.id, { op: d, unitId: a, subUnitId: c, objects: l, type: P.GROUP }) ? (n.pushUndoRedo({
|
|
219
|
-
unitID: a,
|
|
220
|
-
undoMutations: [
|
|
221
|
-
{ id: A.id, params: { op: u, unitId: a, subUnitId: c, objects: Os(l), type: P.UNGROUP } },
|
|
222
|
-
{ id: L.id, params: s }
|
|
223
|
-
],
|
|
224
|
-
redoMutations: [
|
|
225
|
-
{ id: A.id, params: { op: d, unitId: a, subUnitId: c, objects: l, type: P.GROUP } },
|
|
226
|
-
{ id: L.id, params: s }
|
|
227
|
-
]
|
|
228
|
-
}), !0) : !1;
|
|
229
|
-
}
|
|
230
|
-
}, qt = {
|
|
231
|
-
id: "sheet.command.insert-sheet-image",
|
|
232
|
-
type: te.COMMAND,
|
|
233
|
-
handler: (i, t) => {
|
|
234
|
-
var _, R, M;
|
|
235
|
-
const e = i.get(K), n = i.get(Be), r = i.get(ie), s = i.get(St);
|
|
236
|
-
if (!t) return !1;
|
|
237
|
-
const o = t.drawings, a = o.map((I) => I.unitId), c = r.getBatchAddOp(o), { unitId: u, subUnitId: d, undo: l, redo: g, objects: h } = c, f = s.onCommandExecute({ id: qt.id, params: t }), m = { id: A.id, params: { op: g, unitId: u, subUnitId: d, objects: h, type: P.INSERT } }, p = { id: A.id, params: { op: l, unitId: u, subUnitId: d, objects: h, type: P.REMOVE } };
|
|
238
|
-
return zt([...(_ = f.preRedos) != null ? _ : [], m, ...f.redos], e) ? (n.pushUndoRedo({
|
|
239
|
-
unitID: u,
|
|
240
|
-
undoMutations: [
|
|
241
|
-
...(R = f.preUndos) != null ? R : [],
|
|
242
|
-
p,
|
|
243
|
-
...f.undos,
|
|
244
|
-
{ id: L.id, params: a }
|
|
245
|
-
],
|
|
246
|
-
redoMutations: [
|
|
247
|
-
...(M = f.preRedos) != null ? M : [],
|
|
248
|
-
m,
|
|
249
|
-
...f.redos,
|
|
250
|
-
{ id: L.id, params: a }
|
|
251
|
-
]
|
|
252
|
-
}), !0) : !1;
|
|
253
|
-
}
|
|
254
|
-
}, jr = {
|
|
255
|
-
id: "sheet.command.set-drawing-arrange",
|
|
256
|
-
type: te.COMMAND,
|
|
257
|
-
handler: (i, t) => {
|
|
258
|
-
const e = i.get(K), n = i.get(Be);
|
|
259
|
-
if (!t) return !1;
|
|
260
|
-
const r = i.get(ie), { unitId: s, subUnitId: o, drawingIds: a, arrangeType: c } = t, u = { unitId: s, subUnitId: o, drawingIds: a };
|
|
261
|
-
let d;
|
|
262
|
-
if (c === Ut.forward ? d = r.getForwardDrawingsOp(u) : c === Ut.backward ? d = r.getBackwardDrawingOp(u) : c === Ut.front ? d = r.getFrontDrawingsOp(u) : c === Ut.back && (d = r.getBackDrawingsOp(u)), d == null)
|
|
263
|
-
return !1;
|
|
264
|
-
const { objects: l, redo: g, undo: h } = d;
|
|
265
|
-
return e.syncExecuteCommand(A.id, { op: g, unitId: s, subUnitId: o, objects: l, type: P.ARRANGE }) ? (n.pushUndoRedo({
|
|
266
|
-
unitID: s,
|
|
267
|
-
undoMutations: [
|
|
268
|
-
{ id: A.id, params: { op: h, unitId: s, subUnitId: o, objects: l, type: P.ARRANGE } }
|
|
269
|
-
],
|
|
270
|
-
redoMutations: [
|
|
271
|
-
{ id: A.id, params: { op: g, unitId: s, subUnitId: o, objects: l, type: P.ARRANGE } }
|
|
272
|
-
]
|
|
273
|
-
}), !0) : !1;
|
|
274
|
-
}
|
|
275
|
-
}, It = {
|
|
276
|
-
id: "sheet.command.set-sheet-image",
|
|
277
|
-
type: te.COMMAND,
|
|
278
|
-
handler: (i, t) => {
|
|
279
|
-
var S, _;
|
|
280
|
-
const e = i.get(K), n = i.get(Be), r = i.get(ie), s = i.get(St);
|
|
281
|
-
if (!t) return !1;
|
|
282
|
-
const { drawings: o } = t, a = r.getBatchUpdateOp(o), { unitId: c, subUnitId: u, undo: d, redo: l, objects: g } = a, h = s.onCommandExecute({ id: It.id, params: t }), f = [
|
|
283
|
-
...(S = h.preRedos) != null ? S : [],
|
|
284
|
-
{ id: A.id, params: { unitId: c, subUnitId: u, op: l, objects: g, type: P.UPDATE } },
|
|
285
|
-
...h.redos,
|
|
286
|
-
{ id: L.id, params: [c] }
|
|
287
|
-
], m = [
|
|
288
|
-
...(_ = h.preUndos) != null ? _ : [],
|
|
289
|
-
{ id: A.id, params: { unitId: c, subUnitId: u, op: d, objects: g, type: P.UPDATE } },
|
|
290
|
-
...h.undos,
|
|
291
|
-
{ id: L.id, params: [c] }
|
|
292
|
-
];
|
|
293
|
-
return zt(f, e) ? (n.pushUndoRedo({
|
|
294
|
-
unitID: c,
|
|
295
|
-
undoMutations: m,
|
|
296
|
-
redoMutations: f
|
|
297
|
-
}), !0) : !1;
|
|
298
|
-
}
|
|
299
|
-
}, Fr = {
|
|
300
|
-
id: "sheet.command.ungroup-sheet-image",
|
|
301
|
-
type: te.COMMAND,
|
|
302
|
-
handler: (i, t) => {
|
|
303
|
-
const e = i.get(K), n = i.get(Be), r = i.get(ie);
|
|
304
|
-
if (!t) return !1;
|
|
305
|
-
const s = [];
|
|
306
|
-
t.forEach(({ parent: h, children: f }) => {
|
|
307
|
-
s.push(h.unitId), f.forEach((m) => {
|
|
308
|
-
s.push(m.unitId);
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
const o = r.getUngroupDrawingOp(t), { unitId: a, subUnitId: c, undo: u, redo: d, objects: l } = o;
|
|
312
|
-
return e.syncExecuteCommand(A.id, { op: d, unitId: a, subUnitId: c, objects: l, type: P.UNGROUP }) ? (n.pushUndoRedo({
|
|
313
|
-
unitID: a,
|
|
314
|
-
undoMutations: [
|
|
315
|
-
{ id: A.id, params: { op: u, unitId: a, subUnitId: c, objects: Es(l), type: P.GROUP } },
|
|
316
|
-
{ id: L.id, params: s }
|
|
317
|
-
],
|
|
318
|
-
redoMutations: [
|
|
319
|
-
{ id: A.id, params: { op: d, unitId: a, subUnitId: c, objects: l, type: P.UNGROUP } },
|
|
320
|
-
{ id: L.id, params: s }
|
|
321
|
-
]
|
|
322
|
-
}), !0) : !1;
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
var Us = Object.getOwnPropertyDescriptor, Ps = (i, t, e, n) => {
|
|
326
|
-
for (var r = n > 1 ? void 0 : n ? Us(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
327
|
-
(o = i[s]) && (r = o(r) || r);
|
|
328
|
-
return r;
|
|
329
|
-
}, ne = (i, t) => (e, n) => t(e, n, i);
|
|
330
|
-
function As(i, t, e) {
|
|
331
|
-
const n = e * Math.PI / 180, r = Math.abs(i * Math.cos(n)) + Math.abs(t * Math.sin(n)), s = Math.abs(i * Math.sin(n)) + Math.abs(t * Math.cos(n));
|
|
332
|
-
return { rotatedWidth: r, rotatedHeight: s };
|
|
333
|
-
}
|
|
334
|
-
function In(i, t, e, n, r) {
|
|
335
|
-
var _;
|
|
336
|
-
const { rotatedHeight: s, rotatedWidth: o } = As(e, n, r), c = i.get(ee).getRenderById(t.unitId);
|
|
337
|
-
if (!c)
|
|
338
|
-
return !1;
|
|
339
|
-
const d = (_ = c.with(Z).getSkeletonParam(t.subUnitId)) == null ? void 0 : _.skeleton;
|
|
340
|
-
if (d == null)
|
|
341
|
-
return !1;
|
|
342
|
-
const l = d.getCellByIndex(t.row, t.col), g = l.mergeInfo.endX - l.mergeInfo.startX - 2, h = l.mergeInfo.endY - l.mergeInfo.startY - 2, f = o / s, p = Math.ceil(Math.min(g, h * f)) / o, S = !p || Number.isNaN(p) ? 1e-3 : p;
|
|
343
|
-
return {
|
|
344
|
-
width: e * S,
|
|
345
|
-
height: n * S
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
let pt = class extends re {
|
|
349
|
-
constructor(t, e, n, r, s, o, a, c, u, d, l, g, h, f) {
|
|
350
|
-
super();
|
|
351
|
-
ae(this, "_workbookSelections");
|
|
352
|
-
this._context = t, this._skeletonManagerService = e, this._commandService = n, this._selectionRenderService = r, this._imageIoService = s, this._fileOpenerService = o, this._sheetDrawingService = a, this._drawingManagerService = c, this._contextService = u, this._messageService = d, this._localeService = l, this._injector = h, this._urlImageService = f, this._workbookSelections = g.getWorkbookSelections(this._context.unitId), this._updateDrawingListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener();
|
|
353
|
-
}
|
|
354
|
-
async insertFloatImage() {
|
|
355
|
-
const t = await this._fileOpenerService.openFile({
|
|
356
|
-
multiple: !0,
|
|
357
|
-
accept: qn.map((n) => `.${n.replace("image/", "")}`).join(",")
|
|
358
|
-
}), e = t.length;
|
|
359
|
-
return e > Qn ? (this._messageService.show({
|
|
360
|
-
type: Me.Error,
|
|
361
|
-
content: this._localeService.t("update-status.exceedMaxCount", String(Qn))
|
|
362
|
-
}), !1) : e === 0 ? !1 : (t.forEach(async (n) => await this.insertFloatImageByFile(n)), !0);
|
|
363
|
-
}
|
|
364
|
-
async insertCellImage() {
|
|
365
|
-
const e = (await this._fileOpenerService.openFile({
|
|
366
|
-
multiple: !1,
|
|
367
|
-
accept: qn.map((n) => `.${n.replace("image/", "")}`).join(",")
|
|
368
|
-
}))[0];
|
|
369
|
-
return e ? (await this._insertCellImage(e), !0) : !1;
|
|
370
|
-
}
|
|
371
|
-
insertCellImageByFile(t, e) {
|
|
372
|
-
return this._insertCellImage(t, e);
|
|
373
|
-
}
|
|
374
|
-
async insertFloatImageByFile(t) {
|
|
375
|
-
var R;
|
|
376
|
-
let e;
|
|
377
|
-
try {
|
|
378
|
-
e = await this._imageIoService.saveImage(t);
|
|
379
|
-
} catch (M) {
|
|
380
|
-
const I = M.message;
|
|
381
|
-
I === Ge.ERROR_EXCEED_SIZE ? this._messageService.show({
|
|
382
|
-
type: Me.Error,
|
|
383
|
-
content: this._localeService.t("update-status.exceedMaxSize", String(er / (1024 * 1024)))
|
|
384
|
-
}) : I === Ge.ERROR_IMAGE_TYPE ? this._messageService.show({
|
|
385
|
-
type: Me.Error,
|
|
386
|
-
content: this._localeService.t("update-status.invalidImageType")
|
|
387
|
-
}) : I === Ge.ERROR_IMAGE && this._messageService.show({
|
|
388
|
-
type: Me.Error,
|
|
389
|
-
content: this._localeService.t("update-status.invalidImage")
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
if (e == null)
|
|
393
|
-
return;
|
|
394
|
-
const n = this._getUnitInfo(), { unitId: r, subUnitId: s } = n, { imageId: o, imageSourceType: a, source: c, base64Cache: u } = e, { width: d, height: l, image: g } = await an(u || ""), { width: h, height: f } = this._context.scene;
|
|
395
|
-
this._imageIoService.addImageSourceCache(c, a, g);
|
|
396
|
-
let m = 1;
|
|
397
|
-
if (d > tr || l > nr) {
|
|
398
|
-
const M = tr / d, I = nr / l;
|
|
399
|
-
m = Math.max(M, I);
|
|
400
|
-
}
|
|
401
|
-
const p = this._getImagePosition(d * m, l * m, h, f);
|
|
402
|
-
if (p == null)
|
|
403
|
-
return;
|
|
404
|
-
const S = Q(p, this._selectionRenderService, this._skeletonManagerService), _ = {
|
|
405
|
-
unitId: r,
|
|
406
|
-
subUnitId: s,
|
|
407
|
-
drawingId: o,
|
|
408
|
-
drawingType: B.DRAWING_IMAGE,
|
|
409
|
-
imageSourceType: a,
|
|
410
|
-
source: c,
|
|
411
|
-
transform: S,
|
|
412
|
-
sheetTransform: p,
|
|
413
|
-
axisAlignSheetTransform: (R = F(S, this._selectionRenderService)) != null ? R : p
|
|
414
|
-
};
|
|
415
|
-
return this._commandService.executeCommand(qt.id, {
|
|
416
|
-
unitId: r,
|
|
417
|
-
drawings: [_]
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
// eslint-disable-next-line max-lines-per-function
|
|
421
|
-
async _insertCellImage(t, e) {
|
|
422
|
-
var R, M;
|
|
423
|
-
let n;
|
|
424
|
-
try {
|
|
425
|
-
n = await this._imageIoService.saveImage(t);
|
|
426
|
-
} catch (I) {
|
|
427
|
-
const v = I.message;
|
|
428
|
-
v === Ge.ERROR_EXCEED_SIZE ? this._messageService.show({
|
|
429
|
-
type: Me.Error,
|
|
430
|
-
content: this._localeService.t("update-status.exceedMaxSize", String(er / (1024 * 1024)))
|
|
431
|
-
}) : v === Ge.ERROR_IMAGE_TYPE ? this._messageService.show({
|
|
432
|
-
type: Me.Error,
|
|
433
|
-
content: this._localeService.t("update-status.invalidImageType")
|
|
434
|
-
}) : v === Ge.ERROR_IMAGE && this._messageService.show({
|
|
435
|
-
type: Me.Error,
|
|
436
|
-
content: this._localeService.t("update-status.invalidImage")
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
if (n == null)
|
|
440
|
-
return !1;
|
|
441
|
-
const { imageId: r, imageSourceType: s, source: o, base64Cache: a } = n, { width: c, height: u, image: d } = await an(a || "");
|
|
442
|
-
this._imageIoService.addImageSourceCache(o, s, d);
|
|
443
|
-
const l = this._workbookSelections.getCurrentLastSelection();
|
|
444
|
-
if (!l)
|
|
445
|
-
return !1;
|
|
446
|
-
let g = l.primary.actualRow, h = l.primary.actualColumn;
|
|
447
|
-
l.primary.isMerged && (g = l.primary.startRow, h = l.primary.startColumn);
|
|
448
|
-
const f = fn("", {}), m = In(
|
|
449
|
-
this._injector,
|
|
450
|
-
{
|
|
451
|
-
unitId: this._context.unitId,
|
|
452
|
-
subUnitId: this._context.unit.getActiveSheet().getSheetId(),
|
|
453
|
-
row: g,
|
|
454
|
-
col: h
|
|
455
|
-
},
|
|
456
|
-
c,
|
|
457
|
-
u,
|
|
458
|
-
0
|
|
459
|
-
);
|
|
460
|
-
if (!m)
|
|
461
|
-
return !1;
|
|
462
|
-
const p = {
|
|
463
|
-
size: {
|
|
464
|
-
width: m.width,
|
|
465
|
-
height: m.height
|
|
466
|
-
},
|
|
467
|
-
positionH: {
|
|
468
|
-
relativeFrom: Fn.PAGE,
|
|
469
|
-
posOffset: 0
|
|
470
|
-
},
|
|
471
|
-
positionV: {
|
|
472
|
-
relativeFrom: jn.PARAGRAPH,
|
|
473
|
-
posOffset: 0
|
|
474
|
-
},
|
|
475
|
-
angle: 0
|
|
476
|
-
}, S = {
|
|
477
|
-
unitId: f.getUnitId(),
|
|
478
|
-
subUnitId: f.getUnitId(),
|
|
479
|
-
drawingId: r,
|
|
480
|
-
drawingType: B.DRAWING_IMAGE,
|
|
481
|
-
imageSourceType: s,
|
|
482
|
-
source: o,
|
|
483
|
-
transform: Zn(p),
|
|
484
|
-
docTransform: p,
|
|
485
|
-
behindDoc: Vn.FALSE,
|
|
486
|
-
title: "",
|
|
487
|
-
description: "",
|
|
488
|
-
layoutType: Hn.INLINE,
|
|
489
|
-
// Insert inline drawing by default.
|
|
490
|
-
wrapText: Ln.BOTH_SIDES,
|
|
491
|
-
distB: 0,
|
|
492
|
-
distL: 0,
|
|
493
|
-
distR: 0,
|
|
494
|
-
distT: 0
|
|
495
|
-
}, _ = mn.drawing.add({
|
|
496
|
-
documentDataModel: f,
|
|
497
|
-
drawings: [S],
|
|
498
|
-
selection: {
|
|
499
|
-
collapsed: !0,
|
|
500
|
-
startOffset: 0,
|
|
501
|
-
endOffset: 0
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
return _ ? (f.apply(_), this._commandService.syncExecuteCommand(Gn.id, {
|
|
505
|
-
value: {
|
|
506
|
-
[(R = e == null ? void 0 : e.row) != null ? R : g]: {
|
|
507
|
-
[(M = e == null ? void 0 : e.col) != null ? M : h]: {
|
|
508
|
-
p: f.getSnapshot(),
|
|
509
|
-
t: 1
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
},
|
|
513
|
-
unitId: e == null ? void 0 : e.unitId,
|
|
514
|
-
subUnitId: e == null ? void 0 : e.subUnitId
|
|
515
|
-
})) : !1;
|
|
516
|
-
}
|
|
517
|
-
// eslint-disable-next-line max-lines-per-function
|
|
518
|
-
async insertCellImageByUrl(t, e) {
|
|
519
|
-
var h, f;
|
|
520
|
-
let n = t;
|
|
521
|
-
try {
|
|
522
|
-
n = await this._urlImageService.getImage(t);
|
|
523
|
-
} catch (m) {
|
|
524
|
-
console.error(`Failed to get image from URLImageService: ${t}`, m);
|
|
525
|
-
}
|
|
526
|
-
const { width: r, height: s, image: o } = await an(n || "");
|
|
527
|
-
this._imageIoService.addImageSourceCache(t, Ce.URL, o);
|
|
528
|
-
const a = this._workbookSelections.getCurrentLastSelection();
|
|
529
|
-
if (!a)
|
|
530
|
-
return !1;
|
|
531
|
-
const c = fn("", {}), u = In(
|
|
532
|
-
this._injector,
|
|
533
|
-
{
|
|
534
|
-
unitId: this._context.unitId,
|
|
535
|
-
subUnitId: this._context.unit.getActiveSheet().getSheetId(),
|
|
536
|
-
row: a.primary.actualRow,
|
|
537
|
-
col: a.primary.actualColumn
|
|
538
|
-
},
|
|
539
|
-
r,
|
|
540
|
-
s,
|
|
541
|
-
0
|
|
542
|
-
);
|
|
543
|
-
if (!u)
|
|
544
|
-
return !1;
|
|
545
|
-
const d = {
|
|
546
|
-
size: {
|
|
547
|
-
width: u.width,
|
|
548
|
-
height: u.height
|
|
549
|
-
},
|
|
550
|
-
positionH: {
|
|
551
|
-
relativeFrom: Fn.PAGE,
|
|
552
|
-
posOffset: 0
|
|
553
|
-
},
|
|
554
|
-
positionV: {
|
|
555
|
-
relativeFrom: jn.PARAGRAPH,
|
|
556
|
-
posOffset: 0
|
|
557
|
-
},
|
|
558
|
-
angle: 0
|
|
559
|
-
}, l = {
|
|
560
|
-
unitId: c.getUnitId(),
|
|
561
|
-
subUnitId: c.getUnitId(),
|
|
562
|
-
drawingId: Ze(),
|
|
563
|
-
drawingType: B.DRAWING_IMAGE,
|
|
564
|
-
imageSourceType: Ce.URL,
|
|
565
|
-
source: t,
|
|
566
|
-
transform: Zn(d),
|
|
567
|
-
docTransform: d,
|
|
568
|
-
behindDoc: Vn.FALSE,
|
|
569
|
-
title: "",
|
|
570
|
-
description: "",
|
|
571
|
-
layoutType: Hn.INLINE,
|
|
572
|
-
// Insert inline drawing by default.
|
|
573
|
-
wrapText: Ln.BOTH_SIDES,
|
|
574
|
-
distB: 0,
|
|
575
|
-
distL: 0,
|
|
576
|
-
distR: 0,
|
|
577
|
-
distT: 0
|
|
578
|
-
}, g = mn.drawing.add({
|
|
579
|
-
documentDataModel: c,
|
|
580
|
-
drawings: [l],
|
|
581
|
-
selection: {
|
|
582
|
-
collapsed: !0,
|
|
583
|
-
startOffset: 0,
|
|
584
|
-
endOffset: 0
|
|
585
|
-
}
|
|
586
|
-
});
|
|
587
|
-
return g ? (c.apply(g), this._commandService.syncExecuteCommand(Gn.id, {
|
|
588
|
-
value: {
|
|
589
|
-
[(h = e == null ? void 0 : e.row) != null ? h : a.primary.actualRow]: {
|
|
590
|
-
[(f = e == null ? void 0 : e.col) != null ? f : a.primary.actualColumn]: {
|
|
591
|
-
p: c.getSnapshot(),
|
|
592
|
-
t: 1
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
},
|
|
596
|
-
unitId: e == null ? void 0 : e.unitId,
|
|
597
|
-
subUnitId: e == null ? void 0 : e.subUnitId
|
|
598
|
-
})) : !1;
|
|
599
|
-
}
|
|
600
|
-
_getUnitInfo() {
|
|
601
|
-
const t = this._context.unit, e = t.getActiveSheet(), n = t.getUnitId(), r = e.getSheetId();
|
|
602
|
-
return {
|
|
603
|
-
unitId: n,
|
|
604
|
-
subUnitId: r
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
_getImagePosition(t, e, n, r) {
|
|
608
|
-
const s = this._workbookSelections.getCurrentSelections();
|
|
609
|
-
let o = {
|
|
610
|
-
startRow: 0,
|
|
611
|
-
endRow: 0,
|
|
612
|
-
startColumn: 0,
|
|
613
|
-
endColumn: 0
|
|
614
|
-
};
|
|
615
|
-
s && s.length > 0 && (o = s[s.length - 1].range);
|
|
616
|
-
const a = hr(this._skeletonManagerService.getCurrent().skeleton, o);
|
|
617
|
-
if (a == null)
|
|
618
|
-
return;
|
|
619
|
-
let { startColumn: c, startRow: u, startX: d, startY: l } = a, g = !1;
|
|
620
|
-
if (d + t > n && (d = n - t, d < 0 && (d = 0, t = n), g = !0), l + e > r && (l = r - e, l < 0 && (l = 0, e = r), g = !0), g) {
|
|
621
|
-
const p = this._selectionRenderService.getCellWithCoordByOffset(d, l);
|
|
622
|
-
if (p == null)
|
|
623
|
-
return;
|
|
624
|
-
d = p.startX, l = p.startY, c = p.actualColumn, u = p.actualRow;
|
|
625
|
-
}
|
|
626
|
-
const h = {
|
|
627
|
-
column: c,
|
|
628
|
-
columnOffset: 0,
|
|
629
|
-
row: u,
|
|
630
|
-
rowOffset: 0
|
|
631
|
-
}, f = this._selectionRenderService.getCellWithCoordByOffset(d + t, l + e);
|
|
632
|
-
if (f == null)
|
|
633
|
-
return;
|
|
634
|
-
const m = {
|
|
635
|
-
column: f.actualColumn,
|
|
636
|
-
columnOffset: d + t - f.startX,
|
|
637
|
-
row: f.actualRow,
|
|
638
|
-
rowOffset: l + e - f.startY
|
|
639
|
-
};
|
|
640
|
-
return {
|
|
641
|
-
from: h,
|
|
642
|
-
to: m
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
_updateOrderListener() {
|
|
646
|
-
this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe((t) => {
|
|
647
|
-
const { unitId: e, subUnitId: n, drawingIds: r, arrangeType: s } = t;
|
|
648
|
-
this._commandService.executeCommand(jr.id, {
|
|
649
|
-
unitId: e,
|
|
650
|
-
subUnitId: n,
|
|
651
|
-
drawingIds: r,
|
|
652
|
-
arrangeType: s
|
|
653
|
-
});
|
|
654
|
-
}));
|
|
655
|
-
}
|
|
656
|
-
_updateDrawingListener() {
|
|
657
|
-
this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe((t) => {
|
|
658
|
-
const e = [];
|
|
659
|
-
t.length !== 0 && (t.forEach((n) => {
|
|
660
|
-
const { unitId: r, subUnitId: s, drawingId: o, drawingType: a, transform: c } = n;
|
|
661
|
-
if (c == null)
|
|
662
|
-
return;
|
|
663
|
-
const u = this._sheetDrawingService.getDrawingByParam({ unitId: r, subUnitId: s, drawingId: o });
|
|
664
|
-
if (u == null || u.unitId !== this._context.unitId)
|
|
665
|
-
return;
|
|
666
|
-
const d = j({ ...u.transform, ...c }, this._selectionRenderService), l = F({ ...u.transform, ...c }, this._selectionRenderService);
|
|
667
|
-
if (d == null || l == null)
|
|
668
|
-
return;
|
|
669
|
-
const g = {
|
|
670
|
-
...n,
|
|
671
|
-
transform: { ...u.transform, ...c, ...Q(d, this._selectionRenderService, this._skeletonManagerService) },
|
|
672
|
-
sheetTransform: { ...d },
|
|
673
|
-
axisAlignSheetTransform: { ...l }
|
|
674
|
-
};
|
|
675
|
-
e.push(g);
|
|
676
|
-
}), e.length > 0 && this._commandService.executeCommand(It.id, {
|
|
677
|
-
unitId: t[0].unitId,
|
|
678
|
-
drawings: e
|
|
679
|
-
}));
|
|
680
|
-
}));
|
|
681
|
-
}
|
|
682
|
-
_getSheetTransformByParam(t, e) {
|
|
683
|
-
const { unitId: n, subUnitId: r, drawingId: s, transform: o } = t;
|
|
684
|
-
if (o == null)
|
|
685
|
-
return null;
|
|
686
|
-
const a = this._sheetDrawingService.getDrawingByParam({ unitId: n, subUnitId: r, drawingId: s });
|
|
687
|
-
let c = a == null ? void 0 : a.transform;
|
|
688
|
-
if (e && (c = {}), !e && (a == null || a.unitId !== this._context.unitId))
|
|
689
|
-
return null;
|
|
690
|
-
const u = j({ ...c, ...o }, this._selectionRenderService), d = F({ ...c, ...o }, this._selectionRenderService);
|
|
691
|
-
return u == null || d == null ? null : { sheetTransform: u, axisAlignSheetTransform: d };
|
|
692
|
-
}
|
|
693
|
-
_groupDrawingListener() {
|
|
694
|
-
this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe((t) => {
|
|
695
|
-
const e = [];
|
|
696
|
-
for (const n of t) {
|
|
697
|
-
const r = this._getSheetTransformByParam(n.parent, !0), s = [];
|
|
698
|
-
for (const a of n.children) {
|
|
699
|
-
const c = this._getSheetTransformByParam(a, !1);
|
|
700
|
-
c != null && s.push({
|
|
701
|
-
...a,
|
|
702
|
-
sheetTransform: c.sheetTransform,
|
|
703
|
-
axisAlignSheetTransform: c.axisAlignSheetTransform
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
const o = {
|
|
707
|
-
parent: { ...n.parent, sheetTransform: r == null ? void 0 : r.sheetTransform, axisAlignSheetTransform: r == null ? void 0 : r.axisAlignSheetTransform },
|
|
708
|
-
children: s
|
|
709
|
-
};
|
|
710
|
-
e.push(o);
|
|
711
|
-
}
|
|
712
|
-
if (e.length > 0) {
|
|
713
|
-
this._commandService.executeCommand(Wr.id, e);
|
|
714
|
-
const { unitId: n, subUnitId: r, drawingId: s } = t[0].parent;
|
|
715
|
-
this._commandService.syncExecuteCommand(Kt.id, [{ unitId: n, subUnitId: r, drawingId: s }]);
|
|
716
|
-
}
|
|
717
|
-
})), this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((t) => {
|
|
718
|
-
const e = [];
|
|
719
|
-
for (const n of t) {
|
|
720
|
-
const { children: r } = n, s = [];
|
|
721
|
-
for (const o of r) {
|
|
722
|
-
const a = this._getSheetTransformByParam(o, !1);
|
|
723
|
-
a != null && s.push({
|
|
724
|
-
...o,
|
|
725
|
-
sheetTransform: a.sheetTransform,
|
|
726
|
-
axisAlignSheetTransform: a.axisAlignSheetTransform
|
|
727
|
-
});
|
|
728
|
-
}
|
|
729
|
-
e.push({
|
|
730
|
-
...n,
|
|
731
|
-
children: s
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
this._commandService.executeCommand(Fr.id, e);
|
|
735
|
-
}));
|
|
736
|
-
}
|
|
737
|
-
_focusDrawingListener() {
|
|
738
|
-
this.disposeWithMe(
|
|
739
|
-
this._drawingManagerService.focus$.subscribe((t) => {
|
|
740
|
-
t == null || t.length === 0 ? (this._contextService.setContextValue(et, !1), this._sheetDrawingService.focusDrawing([])) : (this._contextService.setContextValue(et, !0), this._sheetDrawingService.focusDrawing(t));
|
|
741
|
-
})
|
|
742
|
-
);
|
|
743
|
-
}
|
|
744
|
-
};
|
|
745
|
-
pt = Ps([
|
|
746
|
-
ne(1, N(Z)),
|
|
747
|
-
ne(2, K),
|
|
748
|
-
ne(3, Oe),
|
|
749
|
-
ne(4, os),
|
|
750
|
-
ne(5, ds),
|
|
751
|
-
ne(6, ie),
|
|
752
|
-
ne(7, de),
|
|
753
|
-
ne(8, gr),
|
|
754
|
-
ne(9, Nr),
|
|
755
|
-
ne(10, N($e)),
|
|
756
|
-
ne(11, N(_t)),
|
|
757
|
-
ne(12, N(st)),
|
|
758
|
-
ne(13, fr)
|
|
759
|
-
], pt);
|
|
760
|
-
const Qt = {
|
|
761
|
-
id: "sheet.command.insert-float-image",
|
|
762
|
-
type: te.COMMAND,
|
|
763
|
-
handler: async (i, t) => {
|
|
764
|
-
var o, a;
|
|
765
|
-
const e = i.get(he), n = i.get(ee), r = (o = Tn(
|
|
766
|
-
$.UNIVER_SHEET,
|
|
767
|
-
e,
|
|
768
|
-
n
|
|
769
|
-
)) == null ? void 0 : o.with(pt);
|
|
770
|
-
if (!r)
|
|
771
|
-
return !1;
|
|
772
|
-
const s = t == null ? void 0 : t.files;
|
|
773
|
-
if (s) {
|
|
774
|
-
const c = s.map((u) => r.insertFloatImageByFile(u));
|
|
775
|
-
return (await Promise.all(c)).every((u) => u);
|
|
776
|
-
} else
|
|
777
|
-
return (a = r.insertFloatImage()) != null ? a : !1;
|
|
778
|
-
}
|
|
779
|
-
}, On = {
|
|
780
|
-
id: "sheet.command.insert-cell-image",
|
|
781
|
-
type: te.COMMAND,
|
|
782
|
-
handler: (i) => {
|
|
783
|
-
var n, r;
|
|
784
|
-
const t = i.get(he), e = i.get(ee);
|
|
785
|
-
return (r = (n = Tn(
|
|
786
|
-
$.UNIVER_SHEET,
|
|
787
|
-
t,
|
|
788
|
-
e
|
|
789
|
-
)) == null ? void 0 : n.with(pt).insertCellImage()) != null ? r : !1;
|
|
790
|
-
}
|
|
791
|
-
}, Ct = {
|
|
792
|
-
id: "sheet.command.move-drawing",
|
|
793
|
-
type: te.COMMAND,
|
|
794
|
-
handler: (i, t) => {
|
|
795
|
-
const e = i.get(K), n = i.get(ie), r = i.get(Oe), { direction: s } = t, o = n.getFocusDrawings();
|
|
796
|
-
if (o.length === 0)
|
|
797
|
-
return !1;
|
|
798
|
-
const a = o[0].unitId, c = o.map((d) => {
|
|
799
|
-
const { transform: l } = d;
|
|
800
|
-
if (l == null)
|
|
801
|
-
return null;
|
|
802
|
-
const g = { ...l }, { left: h = 0, top: f = 0 } = l;
|
|
803
|
-
return s === Te.UP ? g.top = f - 1 : s === Te.DOWN ? g.top = f + 1 : s === Te.LEFT ? g.left = h - 1 : s === Te.RIGHT && (g.left = h + 1), {
|
|
804
|
-
...d,
|
|
805
|
-
transform: g,
|
|
806
|
-
sheetTransform: j(g, r),
|
|
807
|
-
axisAlignSheetTransform: F(g, r)
|
|
808
|
-
};
|
|
809
|
-
}).filter((d) => d != null);
|
|
810
|
-
return e.syncExecuteCommand(It.id, {
|
|
811
|
-
unitId: a,
|
|
812
|
-
drawings: c
|
|
813
|
-
}) ? (e.syncExecuteCommand(L.id, [a]), !0) : !1;
|
|
814
|
-
}
|
|
815
|
-
};
|
|
816
|
-
var Ns = Object.getOwnPropertyDescriptor, xs = (i, t, e, n) => {
|
|
817
|
-
for (var r = n > 1 ? void 0 : n ? Ns(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
818
|
-
(o = i[s]) && (r = o(r) || r);
|
|
819
|
-
return r;
|
|
820
|
-
}, Nt = (i, t) => (e, n) => t(e, n, i), xe = /* @__PURE__ */ ((i) => (i.CELL_ADDRESS = "cellAddress", i.COLUMN_VALUE = "columnValue", i))(xe || {});
|
|
821
|
-
const Un = mi("sheets-drawing-ui.batch-save-images.service");
|
|
822
|
-
function Cn(i) {
|
|
823
|
-
let t = "", e = i;
|
|
824
|
-
for (; e >= 0; )
|
|
825
|
-
t = String.fromCharCode(e % 26 + 65) + t, e = Math.floor(e / 26) - 1;
|
|
826
|
-
return t;
|
|
827
|
-
}
|
|
828
|
-
function Wt(i, t) {
|
|
829
|
-
return `${Cn(t)}${i + 1}`;
|
|
830
|
-
}
|
|
831
|
-
function ks(i) {
|
|
832
|
-
const t = Wt(i.startRow, i.startColumn), e = Wt(i.endRow, i.endColumn);
|
|
833
|
-
return t === e ? t : `${t}:${e}`;
|
|
834
|
-
}
|
|
835
|
-
function sr(i) {
|
|
836
|
-
var t, e, n, r;
|
|
837
|
-
return !!((e = (t = i == null ? void 0 : i.p) == null ? void 0 : t.drawingsOrder) != null && e.length && ((r = (n = i == null ? void 0 : i.p) == null ? void 0 : n.drawingsOrder) == null ? void 0 : r.length) > 0);
|
|
838
|
-
}
|
|
839
|
-
function or(i) {
|
|
840
|
-
var n, r, s;
|
|
841
|
-
if (!((r = (n = i.p) == null ? void 0 : n.drawingsOrder) != null && r.length) || !((s = i.p) != null && s.drawings))
|
|
842
|
-
return null;
|
|
843
|
-
const t = i.p.drawingsOrder[0], e = i.p.drawings[t];
|
|
844
|
-
return !e || !("source" in e) || !("imageSourceType" in e) ? null : e;
|
|
845
|
-
}
|
|
846
|
-
function un(i, t) {
|
|
847
|
-
if (t === Ce.BASE64) {
|
|
848
|
-
const e = i.match(/^data:image\/(\w+);/);
|
|
849
|
-
if (e)
|
|
850
|
-
return e[1] === "jpeg" ? "jpg" : e[1];
|
|
851
|
-
}
|
|
852
|
-
if (t === Ce.URL) {
|
|
853
|
-
const e = i.match(/\.(\w+)(?:\?|$)/);
|
|
854
|
-
if (e)
|
|
855
|
-
return e[1].toLowerCase();
|
|
856
|
-
}
|
|
857
|
-
return "png";
|
|
858
|
-
}
|
|
859
|
-
async function ar(i, t) {
|
|
860
|
-
if (t === Ce.BASE64)
|
|
861
|
-
return (await fetch(i)).blob();
|
|
862
|
-
if (t === Ce.URL)
|
|
863
|
-
return (await fetch(i)).blob();
|
|
864
|
-
throw new Error("UUID image type requires additional handling");
|
|
865
|
-
}
|
|
866
|
-
let Rn = class extends re {
|
|
867
|
-
constructor(i, t, e, n) {
|
|
868
|
-
super(), this._univerInstanceService = i, this._selectionService = t, this._imageIoService = e, this._urlImageService = n;
|
|
869
|
-
}
|
|
870
|
-
/**
|
|
871
|
-
* @deprecated Use IURLImageService directly
|
|
872
|
-
*/
|
|
873
|
-
registerURLImageDownloader(i) {
|
|
874
|
-
return this._urlImageService.registerURLImageDownloader(i);
|
|
875
|
-
}
|
|
876
|
-
getCellImagesInSelection() {
|
|
877
|
-
const i = this._univerInstanceService.getCurrentUnitForType($.UNIVER_SHEET);
|
|
878
|
-
if (!i) return [];
|
|
879
|
-
const t = i.getActiveSheet();
|
|
880
|
-
if (!t) return [];
|
|
881
|
-
const e = this._selectionService.getCurrentSelections();
|
|
882
|
-
if (!e || e.length === 0) return [];
|
|
883
|
-
const n = t.getCellMatrix(), r = [];
|
|
884
|
-
for (const s of e) {
|
|
885
|
-
const { startRow: o, endRow: a, startColumn: c, endColumn: u } = s.range;
|
|
886
|
-
for (let d = o; d <= a; d++)
|
|
887
|
-
for (let l = c; l <= u; l++) {
|
|
888
|
-
const g = n.getValue(d, l);
|
|
889
|
-
if (sr(g)) {
|
|
890
|
-
const h = or(g);
|
|
891
|
-
h && r.push({
|
|
892
|
-
row: d,
|
|
893
|
-
col: l,
|
|
894
|
-
cellAddress: Wt(d, l),
|
|
895
|
-
source: h.source,
|
|
896
|
-
imageSourceType: h.imageSourceType,
|
|
897
|
-
imageId: h.drawingId
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
return r;
|
|
903
|
-
}
|
|
904
|
-
getCellImagesFromRanges(i, t, e) {
|
|
905
|
-
const n = this._univerInstanceService.getUnit(i, $.UNIVER_SHEET);
|
|
906
|
-
if (!n) return [];
|
|
907
|
-
const r = n.getSheetBySheetId(t);
|
|
908
|
-
if (!r) return [];
|
|
909
|
-
const s = r.getCellMatrix(), o = [];
|
|
910
|
-
for (const a of e) {
|
|
911
|
-
const { startRow: c, endRow: u, startColumn: d, endColumn: l } = a;
|
|
912
|
-
for (let g = c; g <= u; g++)
|
|
913
|
-
for (let h = d; h <= l; h++) {
|
|
914
|
-
const f = s.getValue(g, h);
|
|
915
|
-
if (sr(f)) {
|
|
916
|
-
const m = or(f);
|
|
917
|
-
m && o.push({
|
|
918
|
-
row: g,
|
|
919
|
-
col: h,
|
|
920
|
-
cellAddress: Wt(g, h),
|
|
921
|
-
source: m.source,
|
|
922
|
-
imageSourceType: m.imageSourceType,
|
|
923
|
-
imageId: m.drawingId
|
|
924
|
-
});
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
return o;
|
|
929
|
-
}
|
|
930
|
-
getDataColumns() {
|
|
931
|
-
var l, g, h, f;
|
|
932
|
-
const i = this._univerInstanceService.getCurrentUnitForType($.UNIVER_SHEET);
|
|
933
|
-
if (!i) return [];
|
|
934
|
-
const t = i.getActiveSheet();
|
|
935
|
-
if (!t) return [];
|
|
936
|
-
const e = this._selectionService.getCurrentSelections();
|
|
937
|
-
if (!e || e.length === 0) return [];
|
|
938
|
-
const n = t.getCellMatrix(), r = n.getDataRange();
|
|
939
|
-
let s = 1 / 0, o = -1 / 0;
|
|
940
|
-
const a = /* @__PURE__ */ new Set();
|
|
941
|
-
for (const m of e) {
|
|
942
|
-
s = Math.min(s, m.range.startRow), o = Math.max(o, m.range.endRow);
|
|
943
|
-
for (let p = m.range.startColumn; p <= m.range.endColumn; p++)
|
|
944
|
-
a.add(p);
|
|
945
|
-
}
|
|
946
|
-
const c = /* @__PURE__ */ new Set();
|
|
947
|
-
for (let m = r.startColumn; m <= r.endColumn; m++)
|
|
948
|
-
if (!a.has(m))
|
|
949
|
-
for (let p = s; p <= o; p++) {
|
|
950
|
-
const S = n.getValue(p, m);
|
|
951
|
-
if (S && (((l = S.v) == null ? void 0 : l.toString()) || ((f = (h = (g = S.p) == null ? void 0 : g.body) == null ? void 0 : h.dataStream) == null ? void 0 : f.trim()) || "")) {
|
|
952
|
-
c.add(m);
|
|
953
|
-
break;
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
const u = [], d = Array.from(c).sort((m, p) => m - p);
|
|
957
|
-
for (const m of d)
|
|
958
|
-
u.push({
|
|
959
|
-
index: m,
|
|
960
|
-
label: Cn(m)
|
|
961
|
-
});
|
|
962
|
-
return u;
|
|
963
|
-
}
|
|
964
|
-
getDataColumnsForRanges(i, t, e) {
|
|
965
|
-
var h, f, m, p;
|
|
966
|
-
const n = this._univerInstanceService.getUnit(i, $.UNIVER_SHEET);
|
|
967
|
-
if (!n) return [];
|
|
968
|
-
const r = n.getSheetBySheetId(t);
|
|
969
|
-
if (!r) return [];
|
|
970
|
-
const s = r.getCellMatrix(), o = s.getDataRange();
|
|
971
|
-
let a = 1 / 0, c = -1 / 0;
|
|
972
|
-
const u = /* @__PURE__ */ new Set();
|
|
973
|
-
for (const S of e) {
|
|
974
|
-
a = Math.min(a, S.startRow), c = Math.max(c, S.endRow);
|
|
975
|
-
for (let _ = S.startColumn; _ <= S.endColumn; _++)
|
|
976
|
-
u.add(_);
|
|
977
|
-
}
|
|
978
|
-
const d = /* @__PURE__ */ new Set();
|
|
979
|
-
for (let S = o.startColumn; S <= o.endColumn; S++)
|
|
980
|
-
if (!u.has(S))
|
|
981
|
-
for (let _ = a; _ <= c; _++) {
|
|
982
|
-
const R = s.getValue(_, S);
|
|
983
|
-
if (R && (((h = R.v) == null ? void 0 : h.toString()) || ((p = (m = (f = R.p) == null ? void 0 : f.body) == null ? void 0 : m.dataStream) == null ? void 0 : p.trim()) || "")) {
|
|
984
|
-
d.add(S);
|
|
985
|
-
break;
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
const l = [], g = Array.from(d).sort((S, _) => S - _);
|
|
989
|
-
for (const S of g)
|
|
990
|
-
l.push({
|
|
991
|
-
index: S,
|
|
992
|
-
label: Cn(S)
|
|
993
|
-
});
|
|
994
|
-
return l;
|
|
995
|
-
}
|
|
996
|
-
getSelectionRangeNotation() {
|
|
997
|
-
const i = this._selectionService.getCurrentSelections();
|
|
998
|
-
return !i || i.length === 0 ? "" : i.map((t) => ks(t.range)).join(", ");
|
|
999
|
-
}
|
|
1000
|
-
getSelectionRowRange() {
|
|
1001
|
-
const i = this._selectionService.getCurrentSelections();
|
|
1002
|
-
if (!i || i.length === 0) return null;
|
|
1003
|
-
let t = 1 / 0, e = -1 / 0;
|
|
1004
|
-
for (const n of i)
|
|
1005
|
-
t = Math.min(t, n.range.startRow), e = Math.max(e, n.range.endRow);
|
|
1006
|
-
return { startRow: t, endRow: e };
|
|
1007
|
-
}
|
|
1008
|
-
getSelectionColumnIndices() {
|
|
1009
|
-
const i = this._selectionService.getCurrentSelections();
|
|
1010
|
-
if (!i || i.length === 0) return /* @__PURE__ */ new Set();
|
|
1011
|
-
const t = /* @__PURE__ */ new Set();
|
|
1012
|
-
for (const e of i)
|
|
1013
|
-
for (let n = e.range.startColumn; n <= e.range.endColumn; n++)
|
|
1014
|
-
t.add(n);
|
|
1015
|
-
return t;
|
|
1016
|
-
}
|
|
1017
|
-
generateFileName(i, t) {
|
|
1018
|
-
var s, o, a, c;
|
|
1019
|
-
const e = this._univerInstanceService.getCurrentUnitForType($.UNIVER_SHEET), n = un(i.source, i.imageSourceType), r = [];
|
|
1020
|
-
for (const u of t.fileNameParts)
|
|
1021
|
-
if (u === "cellAddress")
|
|
1022
|
-
r.push(i.cellAddress);
|
|
1023
|
-
else if (u === "columnValue" && t.columnIndex !== void 0) {
|
|
1024
|
-
const d = e == null ? void 0 : e.getActiveSheet();
|
|
1025
|
-
if (d) {
|
|
1026
|
-
const g = d.getCellMatrix().getValue(i.row, t.columnIndex);
|
|
1027
|
-
if (g) {
|
|
1028
|
-
const h = ((s = g.v) == null ? void 0 : s.toString()) || ((c = (a = (o = g.p) == null ? void 0 : o.body) == null ? void 0 : a.dataStream) == null ? void 0 : c.trim()) || "";
|
|
1029
|
-
if (h) {
|
|
1030
|
-
const f = h.replace(/[<>:"/\\|?*]/g, "_").trim();
|
|
1031
|
-
f && r.push(f);
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
return r.length === 0 ? `${i.cellAddress}.${n}` : `${r.join("_")}.${n}`;
|
|
1037
|
-
}
|
|
1038
|
-
generateFileNameWithContext(i, t, e, n) {
|
|
1039
|
-
var a, c, u, d;
|
|
1040
|
-
const r = this._univerInstanceService.getUnit(e, $.UNIVER_SHEET), s = un(i.source, i.imageSourceType), o = [];
|
|
1041
|
-
for (const l of t.fileNameParts)
|
|
1042
|
-
if (l === "cellAddress")
|
|
1043
|
-
o.push(i.cellAddress);
|
|
1044
|
-
else if (l === "columnValue" && t.columnIndex !== void 0) {
|
|
1045
|
-
const g = r == null ? void 0 : r.getSheetBySheetId(n);
|
|
1046
|
-
if (g) {
|
|
1047
|
-
const f = g.getCellMatrix().getValue(i.row, t.columnIndex);
|
|
1048
|
-
if (f) {
|
|
1049
|
-
const m = ((a = f.v) == null ? void 0 : a.toString()) || ((d = (u = (c = f.p) == null ? void 0 : c.body) == null ? void 0 : u.dataStream) == null ? void 0 : d.trim()) || "";
|
|
1050
|
-
if (m) {
|
|
1051
|
-
const p = m.replace(/[<>:"/\\|?*]/g, "_").trim();
|
|
1052
|
-
p && o.push(p);
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
return o.length === 0 ? `${i.cellAddress}.${s}` : `${o.join("_")}.${s}`;
|
|
1058
|
-
}
|
|
1059
|
-
async saveImages(i, t) {
|
|
1060
|
-
var r;
|
|
1061
|
-
const e = await window.showDirectoryPicker({ mode: "readwrite" }), n = /* @__PURE__ */ new Map();
|
|
1062
|
-
for (const s of i) {
|
|
1063
|
-
let o = this.generateFileName(s, t);
|
|
1064
|
-
const a = o.replace(/\.\w+$/, ""), c = ((r = o.match(/\.\w+$/)) == null ? void 0 : r[0]) || ".png", u = n.get(a) || 0;
|
|
1065
|
-
u > 0 && (o = `${a}_${u}${c}`), n.set(a, u + 1);
|
|
1066
|
-
try {
|
|
1067
|
-
const d = await this._getImageBlob(s), g = await (await e.getFileHandle(o, { create: !0 })).createWritable();
|
|
1068
|
-
await g.write(d), await g.close();
|
|
1069
|
-
} catch (d) {
|
|
1070
|
-
throw console.error(`Failed to save image ${o}:`, d), d;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
async saveImagesWithContext(i, t, e, n) {
|
|
1075
|
-
var o;
|
|
1076
|
-
const r = await window.showDirectoryPicker({ mode: "readwrite" }), s = /* @__PURE__ */ new Map();
|
|
1077
|
-
for (const a of i) {
|
|
1078
|
-
let c = this.generateFileNameWithContext(a, t, e, n);
|
|
1079
|
-
const u = c.replace(/\.\w+$/, ""), d = ((o = c.match(/\.\w+$/)) == null ? void 0 : o[0]) || ".png", l = s.get(u) || 0;
|
|
1080
|
-
l > 0 && (c = `${u}_${l}${d}`), s.set(u, l + 1);
|
|
1081
|
-
try {
|
|
1082
|
-
const g = await this._getImageBlob(a), f = await (await r.getFileHandle(c, { create: !0 })).createWritable();
|
|
1083
|
-
await f.write(g), await f.close();
|
|
1084
|
-
} catch (g) {
|
|
1085
|
-
throw console.error(`Failed to save image ${c}:`, g), g;
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
async downloadSingleImage(i) {
|
|
1090
|
-
const t = un(i.source, i.imageSourceType), e = `${i.cellAddress}.${t}`;
|
|
1091
|
-
try {
|
|
1092
|
-
const n = await this._getImageBlob(i), r = URL.createObjectURL(n), s = document.createElement("a");
|
|
1093
|
-
s.href = r, s.download = e, document.body.appendChild(s), s.click(), document.body.removeChild(s), URL.revokeObjectURL(r);
|
|
1094
|
-
} catch (n) {
|
|
1095
|
-
throw console.error(`Failed to download image ${e}:`, n), n;
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
async _getImageBlob(i) {
|
|
1099
|
-
if (i.imageSourceType === Ce.UUID) {
|
|
1100
|
-
const t = await this._imageIoService.getImage(i.source);
|
|
1101
|
-
return ar(t, Ce.URL);
|
|
1102
|
-
}
|
|
1103
|
-
return i.imageSourceType === Ce.URL ? this._urlImageService.downloadImage(i.source) : ar(i.source, i.imageSourceType);
|
|
1104
|
-
}
|
|
1105
|
-
};
|
|
1106
|
-
Rn = xs([
|
|
1107
|
-
Nt(0, he),
|
|
1108
|
-
Nt(1, N(_t)),
|
|
1109
|
-
Nt(2, mr),
|
|
1110
|
-
Nt(3, fr)
|
|
1111
|
-
], Rn);
|
|
1112
|
-
const nt = "sheet.dialog.batch-save-images", mt = {
|
|
1113
|
-
id: "sheet.command.save-cell-images",
|
|
1114
|
-
type: te.COMMAND,
|
|
1115
|
-
handler: async (i) => {
|
|
1116
|
-
const t = i.get(En), e = i.get(Un), n = e.getCellImagesInSelection();
|
|
1117
|
-
if (n.length === 1)
|
|
1118
|
-
try {
|
|
1119
|
-
return await e.downloadSingleImage(n[0]), !0;
|
|
1120
|
-
} catch (a) {
|
|
1121
|
-
return console.error("Failed to download image:", a), !1;
|
|
1122
|
-
}
|
|
1123
|
-
const r = i.get($e), s = e.getSelectionRangeNotation(), o = `${r.t("sheetImage.save.title")} (${s})`;
|
|
1124
|
-
return t.open({
|
|
1125
|
-
id: nt,
|
|
1126
|
-
draggable: !0,
|
|
1127
|
-
width: 360,
|
|
1128
|
-
title: { title: o },
|
|
1129
|
-
children: {
|
|
1130
|
-
label: nt
|
|
1131
|
-
},
|
|
1132
|
-
destroyOnClose: !0,
|
|
1133
|
-
preservePositionOnDestroy: !0,
|
|
1134
|
-
onClose: () => t.close(nt)
|
|
1135
|
-
}), !0;
|
|
1136
|
-
}
|
|
1137
|
-
}, Lr = "COMPONENT_SHEET_DRAWING_PANEL", Hr = {
|
|
1138
|
-
id: "sidebar.operation.sheet-image",
|
|
1139
|
-
type: te.COMMAND,
|
|
1140
|
-
handler: async (i, t) => {
|
|
1141
|
-
const e = i.get(ls), n = i.get($e), r = i.get(he), s = i.get(K);
|
|
1142
|
-
return ce(r) ? (t.value === "open" ? e.open({
|
|
1143
|
-
header: { title: n.t("sheetImage.panel.title") },
|
|
1144
|
-
children: { label: Lr },
|
|
1145
|
-
onClose: () => {
|
|
1146
|
-
s.syncExecuteCommand(Kt.id, []);
|
|
1147
|
-
},
|
|
1148
|
-
width: 360
|
|
1149
|
-
}) : e.close(), !0) : !1;
|
|
1150
|
-
}
|
|
1151
|
-
}, Vr = {
|
|
1152
|
-
id: "sheet.operation.edit-sheet-image",
|
|
1153
|
-
type: te.OPERATION,
|
|
1154
|
-
handler: (i, t) => {
|
|
1155
|
-
const e = i.get(K);
|
|
1156
|
-
return t == null ? !1 : (e.syncExecuteCommand(Kt.id, [t]), e.executeCommand(Hr.id, { value: "open" }), !0);
|
|
1157
|
-
}
|
|
1158
|
-
}, Gr = "sheet.menu.image";
|
|
1159
|
-
function Bs(i) {
|
|
1160
|
-
return {
|
|
1161
|
-
id: Gr,
|
|
1162
|
-
type: Zt.SUBITEMS,
|
|
1163
|
-
icon: "AddImageIcon",
|
|
1164
|
-
tooltip: "sheetImage.title",
|
|
1165
|
-
hidden$: Jt(i, $.UNIVER_SHEET),
|
|
1166
|
-
disabled$: si(i, { workbookTypes: [wn], worksheetTypes: [pn], rangeTypes: [Bi] })
|
|
1167
|
-
};
|
|
1168
|
-
}
|
|
1169
|
-
function $s(i) {
|
|
1170
|
-
return {
|
|
1171
|
-
id: Qt.id,
|
|
1172
|
-
title: "sheetImage.upload.float",
|
|
1173
|
-
type: Zt.BUTTON,
|
|
1174
|
-
hidden$: Jt(i, $.UNIVER_SHEET)
|
|
1175
|
-
};
|
|
1176
|
-
}
|
|
1177
|
-
function Ws(i) {
|
|
1178
|
-
return {
|
|
1179
|
-
id: On.id,
|
|
1180
|
-
title: "sheetImage.upload.cell",
|
|
1181
|
-
type: Zt.BUTTON,
|
|
1182
|
-
hidden$: Jt(i, $.UNIVER_SHEET)
|
|
1183
|
-
};
|
|
1184
|
-
}
|
|
1185
|
-
const js = "@univerjs/sheets-drawing-ui", Fs = "0.17.0", Yr = {
|
|
1186
|
-
name: js,
|
|
1187
|
-
version: Fs
|
|
1188
|
-
}, Ls = "sheets-drawing-ui.config", cr = {};
|
|
1189
|
-
var Hs = Object.getOwnPropertyDescriptor, Vs = (i, t, e, n) => {
|
|
1190
|
-
for (var r = n > 1 ? void 0 : n ? Hs(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1191
|
-
(o = i[s]) && (r = o(r) || r);
|
|
1192
|
-
return r;
|
|
1193
|
-
}, xt = (i, t) => (e, n) => t(e, n, i);
|
|
1194
|
-
let Dn = class extends re {
|
|
1195
|
-
constructor(t, e, n, r, s) {
|
|
1196
|
-
super();
|
|
1197
|
-
ae(this, "_isSetCursor", !1);
|
|
1198
|
-
this._context = t, this._hoverManagerService = e, this._selectionsService = n, this._drawingRenderService = r, this._sheetSkeletonManagerService = s, this._initHover(), this._initImageClick();
|
|
1199
|
-
}
|
|
1200
|
-
_initHover() {
|
|
1201
|
-
this.disposeWithMe(this._hoverManagerService.currentRichTextNoDistinct$.pipe(Ms(33)).subscribe((t) => {
|
|
1202
|
-
var n, r;
|
|
1203
|
-
let e = [];
|
|
1204
|
-
t !== null && (e = this._selectionsService.getWorkbookSelections(this._context.unitId).getCurrentSelections()), e.length > 0 && (t == null ? void 0 : t.unitId) === this._context.unitId && (t != null && t.drawing) && e.length === 1 && ((n = e[0].primary) == null ? void 0 : n.actualRow) === t.row && ((r = e[0].primary) == null ? void 0 : r.actualColumn) === t.col ? (this._isSetCursor = !0, this._context.scene.setCursor(ri.ZOOM_IN)) : this._isSetCursor && (this._isSetCursor = !1, this._context.scene.resetCursor());
|
|
1205
|
-
}));
|
|
1206
|
-
}
|
|
1207
|
-
_initImageClick() {
|
|
1208
|
-
this.disposeWithMe(this._hoverManagerService.currentClickedCell$.subscribe((t) => {
|
|
1209
|
-
var e;
|
|
1210
|
-
if (t != null && t.drawing && this._isSetCursor) {
|
|
1211
|
-
const n = t.drawing.drawing.drawingOrigin, r = (e = this._sheetSkeletonManagerService.getCurrentSkeleton()) == null ? void 0 : e.imageCacheMap.getImage(n.imageSourceType, n.source);
|
|
1212
|
-
if (!r) return;
|
|
1213
|
-
this._drawingRenderService.previewImage("preview-cell-image", r.src, r.width, r.height), this._context.scene.resetCursor(), this._isSetCursor = !1;
|
|
1214
|
-
}
|
|
1215
|
-
}));
|
|
1216
|
-
}
|
|
1217
|
-
};
|
|
1218
|
-
Dn = Vs([
|
|
1219
|
-
xt(1, N(oi)),
|
|
1220
|
-
xt(2, N(_t)),
|
|
1221
|
-
xt(3, N(kr)),
|
|
1222
|
-
xt(4, N(Z))
|
|
1223
|
-
], Dn);
|
|
1224
|
-
var Gs = Object.getOwnPropertyDescriptor, Ys = (i, t, e, n) => {
|
|
1225
|
-
for (var r = n > 1 ? void 0 : n ? Gs(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1226
|
-
(o = i[s]) && (r = o(r) || r);
|
|
1227
|
-
return r;
|
|
1228
|
-
}, kt = (i, t) => (e, n) => t(e, n, i);
|
|
1229
|
-
let bn = class extends re {
|
|
1230
|
-
constructor(i, t, e, n, r) {
|
|
1231
|
-
super(), this._context = i, this._sheetDrawingService = t, this._drawingManagerService = e, this._sheetSelectionRenderService = n, this._sheetSkeletonManagerService = r, this._init();
|
|
1232
|
-
}
|
|
1233
|
-
_init() {
|
|
1234
|
-
this._drawingInitializeListener();
|
|
1235
|
-
}
|
|
1236
|
-
_drawingInitializeListener() {
|
|
1237
|
-
this._sheetDrawingService.initializeNotification(this._context.unitId);
|
|
1238
|
-
const i = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);
|
|
1239
|
-
for (const t in i) {
|
|
1240
|
-
const e = i[t];
|
|
1241
|
-
for (const n in e.data) {
|
|
1242
|
-
const r = e.data[n];
|
|
1243
|
-
r.sheetTransform && (r.transform = Q(r.sheetTransform, this._sheetSelectionRenderService, this._sheetSkeletonManagerService));
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)), this._drawingManagerService.initializeNotification(this._context.unitId);
|
|
1247
|
-
}
|
|
1248
|
-
};
|
|
1249
|
-
bn = Ys([
|
|
1250
|
-
kt(1, ie),
|
|
1251
|
-
kt(2, de),
|
|
1252
|
-
kt(3, N(Oe)),
|
|
1253
|
-
kt(4, N(Z))
|
|
1254
|
-
], bn);
|
|
1255
|
-
var Xs = Object.getOwnPropertyDescriptor, zs = (i, t, e, n) => {
|
|
1256
|
-
for (var r = n > 1 ? void 0 : n ? Xs(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1257
|
-
(o = i[s]) && (r = o(r) || r);
|
|
1258
|
-
return r;
|
|
1259
|
-
}, Ye = (i, t) => (e, n) => t(e, n, i);
|
|
1260
|
-
function Xr(i, t, e) {
|
|
1261
|
-
var n, r, s, o;
|
|
1262
|
-
if (((r = (n = e == null ? void 0 : e.p) == null ? void 0 : n.body) == null ? void 0 : r.dataStream.length) === 3 && ((o = (s = e.p) == null ? void 0 : s.drawingsOrder) == null ? void 0 : o.length) === 1) {
|
|
1263
|
-
const a = e.p.drawings[e.p.drawingsOrder[0]], c = In(
|
|
1264
|
-
i,
|
|
1265
|
-
{
|
|
1266
|
-
unitId: t.unitId,
|
|
1267
|
-
subUnitId: t.subUnitId,
|
|
1268
|
-
row: t.row,
|
|
1269
|
-
col: t.col
|
|
1270
|
-
},
|
|
1271
|
-
a.docTransform.size.width,
|
|
1272
|
-
a.docTransform.size.height,
|
|
1273
|
-
a.docTransform.angle
|
|
1274
|
-
);
|
|
1275
|
-
if (c)
|
|
1276
|
-
return a.transform.width = c.width, a.transform.height = c.height, a.docTransform.size.width = c.width, a.docTransform.size.height = c.height, a.transform.left = 0, a.transform.top = 0, a.docTransform.positionH.posOffset = 0, a.docTransform.positionV.posOffset = 0, e.p.documentStyle.pageSize.width = 1 / 0, e.p.documentStyle.pageSize.height = 1 / 0, !0;
|
|
1277
|
-
}
|
|
1278
|
-
return !1;
|
|
1279
|
-
}
|
|
1280
|
-
let jt = class extends re {
|
|
1281
|
-
constructor(i, t, e, n, r, s) {
|
|
1282
|
-
super(), this._commandService = i, this._sheetInterceptorService = t, this._injector = e, this._drawingManagerService = n, this._docDrawingController = r, this._editorBridgeService = s, this._handleInitEditor(), this._initCellContentInterceptor();
|
|
1283
|
-
}
|
|
1284
|
-
_handleInitEditor() {
|
|
1285
|
-
this.disposeWithMe(this._editorBridgeService.visible$.subscribe((i) => {
|
|
1286
|
-
i.visible ? i.visible && (this._drawingManagerService.removeDrawingDataForUnit(gt), this._docDrawingController.loadDrawingDataForUnit(gt), this._drawingManagerService.initializeNotification(gt)) : this._drawingManagerService.removeDrawingDataForUnit(gt);
|
|
1287
|
-
})), this.disposeWithMe(this._commandService.onCommandExecuted((i) => {
|
|
1288
|
-
i.id === is.id && i.params.unitId === qe && (this._drawingManagerService.removeDrawingDataForUnit(qe), this._docDrawingController.loadDrawingDataForUnit(qe), this._drawingManagerService.initializeNotification(qe));
|
|
1289
|
-
}));
|
|
1290
|
-
}
|
|
1291
|
-
_initCellContentInterceptor() {
|
|
1292
|
-
this.disposeWithMe(
|
|
1293
|
-
this._sheetInterceptorService.intercept(
|
|
1294
|
-
$i.CELL_CONTENT,
|
|
1295
|
-
{
|
|
1296
|
-
effect: pi.Style,
|
|
1297
|
-
priority: Wi.CELL_IMAGE,
|
|
1298
|
-
handler: (i, t, e) => {
|
|
1299
|
-
var n;
|
|
1300
|
-
return i != null && i.p && ((n = i.p.drawingsOrder) != null && n.length) && (i === t.rawData && (i = { ...t.rawData }), i.interceptorStyle || (i.interceptorStyle = {}), i.interceptorStyle.tr = { a: 0 }, Xr(this._injector, { unitId: t.unitId, subUnitId: t.subUnitId, row: t.row, col: t.col }, i)), e(i);
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
)
|
|
1304
|
-
);
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
jt = zs([
|
|
1308
|
-
Ye(0, K),
|
|
1309
|
-
Ye(1, N(St)),
|
|
1310
|
-
Ye(2, N(st)),
|
|
1311
|
-
Ye(3, de),
|
|
1312
|
-
Ye(4, N(Ss)),
|
|
1313
|
-
Ye(5, N(ai))
|
|
1314
|
-
], jt);
|
|
1315
|
-
var Ks = Object.getOwnPropertyDescriptor, Js = (i, t, e, n) => {
|
|
1316
|
-
for (var r = n > 1 ? void 0 : n ? Ks(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1317
|
-
(o = i[s]) && (r = o(r) || r);
|
|
1318
|
-
return r;
|
|
1319
|
-
}, dr = (i, t) => (e, n) => t(e, n, i);
|
|
1320
|
-
let Ft = class extends re {
|
|
1321
|
-
constructor(i, t) {
|
|
1322
|
-
super(), this._autoFillService = i, this._injector = t, this._initAutoFillHooks();
|
|
1323
|
-
}
|
|
1324
|
-
_initAutoFillHooks() {
|
|
1325
|
-
this.disposeWithMe(
|
|
1326
|
-
this._autoFillService.addHook({
|
|
1327
|
-
id: "sheet-cell-image-autofill",
|
|
1328
|
-
onBeforeSubmit: (i, t, e, n) => {
|
|
1329
|
-
new wi(n).forValue((r, s, o) => {
|
|
1330
|
-
Xr(this._injector, { unitId: i.unitId, subUnitId: i.subUnitId, row: r, col: s }, o);
|
|
1331
|
-
});
|
|
1332
|
-
}
|
|
1333
|
-
})
|
|
1334
|
-
);
|
|
1335
|
-
}
|
|
1336
|
-
};
|
|
1337
|
-
Ft = Js([
|
|
1338
|
-
dr(0, N(ji)),
|
|
1339
|
-
dr(1, N(st))
|
|
1340
|
-
], Ft);
|
|
1341
|
-
var Zs = Object.getOwnPropertyDescriptor, qs = (i, t, e, n) => {
|
|
1342
|
-
for (var r = n > 1 ? void 0 : n ? Zs(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1343
|
-
(o = i[s]) && (r = o(r) || r);
|
|
1344
|
-
return r;
|
|
1345
|
-
}, dt = (i, t) => (e, n) => t(e, n, i);
|
|
1346
|
-
const Qs = [
|
|
1347
|
-
gt,
|
|
1348
|
-
Si,
|
|
1349
|
-
qe
|
|
1350
|
-
];
|
|
1351
|
-
let Lt = class extends re {
|
|
1352
|
-
constructor(i, t, e, n, r) {
|
|
1353
|
-
super(), this._commandService = i, this._univerInstanceService = t, this._dialogService = e, this._renderManagerService = n, this._localeService = r, this._initDocImageCopyPasteHooks();
|
|
1354
|
-
}
|
|
1355
|
-
_setCellImage(i) {
|
|
1356
|
-
var r;
|
|
1357
|
-
const t = fn("", {}), e = (r = Tn($.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : r.with(ci), n = mn.drawing.add({
|
|
1358
|
-
documentDataModel: t,
|
|
1359
|
-
drawings: [i],
|
|
1360
|
-
selection: {
|
|
1361
|
-
collapsed: !0,
|
|
1362
|
-
startOffset: 0,
|
|
1363
|
-
endOffset: 0
|
|
1364
|
-
}
|
|
1365
|
-
});
|
|
1366
|
-
n && (t.apply(n), e && e.submitCellData(t));
|
|
1367
|
-
}
|
|
1368
|
-
_initDocImageCopyPasteHooks() {
|
|
1369
|
-
this.disposeWithMe(
|
|
1370
|
-
this._commandService.beforeCommandExecuted((i) => {
|
|
1371
|
-
var t, e;
|
|
1372
|
-
if (i.id === ss.id) {
|
|
1373
|
-
const n = i.params, { doc: r } = n, s = this._univerInstanceService.getCurrentUnitOfType($.UNIVER_DOC);
|
|
1374
|
-
if (s == null || !Object.keys((t = r.drawings) != null ? t : {}).length)
|
|
1375
|
-
return;
|
|
1376
|
-
const o = s.getUnitId();
|
|
1377
|
-
if (Qs.includes(o)) {
|
|
1378
|
-
if (o !== qe) {
|
|
1379
|
-
const a = () => {
|
|
1380
|
-
this._dialogService.close("sheet-cell-image-copy-paste"), this._commandService.syncExecuteCommand($n.id, {
|
|
1381
|
-
visible: !1
|
|
1382
|
-
});
|
|
1383
|
-
};
|
|
1384
|
-
((e = s.getBody()) == null ? void 0 : e.dataStream) === `\r
|
|
1385
|
-
` ? (this._commandService.syncExecuteCommand($n.id, {
|
|
1386
|
-
visible: !1
|
|
1387
|
-
}), this._setCellImage(Object.values(r.drawings)[0])) : this._dialogService.open({
|
|
1388
|
-
id: "sheet-cell-image-copy-paste",
|
|
1389
|
-
title: {
|
|
1390
|
-
label: this._localeService.t("cell-image.pasteTitle")
|
|
1391
|
-
},
|
|
1392
|
-
children: {
|
|
1393
|
-
label: this._localeService.t("cell-image.pasteContent")
|
|
1394
|
-
},
|
|
1395
|
-
width: 320,
|
|
1396
|
-
destroyOnClose: !0,
|
|
1397
|
-
onClose: a,
|
|
1398
|
-
showOk: !0,
|
|
1399
|
-
showCancel: !0,
|
|
1400
|
-
onOk: () => {
|
|
1401
|
-
a(), this._setCellImage(Object.values(r.drawings)[0]);
|
|
1402
|
-
},
|
|
1403
|
-
onCancel: a
|
|
1404
|
-
});
|
|
1405
|
-
}
|
|
1406
|
-
throw new Error("Sheet cell image copy paste is not supported in this unit");
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
})
|
|
1410
|
-
);
|
|
1411
|
-
}
|
|
1412
|
-
};
|
|
1413
|
-
Lt = qs([
|
|
1414
|
-
dt(0, K),
|
|
1415
|
-
dt(1, he),
|
|
1416
|
-
dt(2, En),
|
|
1417
|
-
dt(3, ee),
|
|
1418
|
-
dt(4, N($e))
|
|
1419
|
-
], Lt);
|
|
1420
|
-
var eo = Object.getOwnPropertyDescriptor, to = (i, t, e, n) => {
|
|
1421
|
-
for (var r = n > 1 ? void 0 : n ? eo(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1422
|
-
(o = i[s]) && (r = o(r) || r);
|
|
1423
|
-
return r;
|
|
1424
|
-
}, lt = (i, t) => (e, n) => t(e, n, i);
|
|
1425
|
-
const zr = "image/png";
|
|
1426
|
-
function no(i) {
|
|
1427
|
-
const t = i.split(","), e = atob(t[1]), n = e.length, r = new Uint8Array(n);
|
|
1428
|
-
for (let s = 0; s < n; s++)
|
|
1429
|
-
r[s] = e.charCodeAt(s);
|
|
1430
|
-
return new Blob([r], { type: zr });
|
|
1431
|
-
}
|
|
1432
|
-
function ro(i) {
|
|
1433
|
-
const t = new ClipboardItem({ [zr]: no(i) });
|
|
1434
|
-
navigator.clipboard.write([t]).catch((e) => {
|
|
1435
|
-
console.error("Could not copy image using clipboard API: ", e);
|
|
1436
|
-
});
|
|
1437
|
-
}
|
|
1438
|
-
function io() {
|
|
1439
|
-
function i() {
|
|
1440
|
-
const n = document.createElement("input");
|
|
1441
|
-
return n.style.position = "absolute", n.style.height = "1px", n.style.width = "1px", n.style.opacity = "0", n;
|
|
1442
|
-
}
|
|
1443
|
-
const t = document.activeElement, e = i();
|
|
1444
|
-
return document.body.appendChild(e), e.focus(), () => {
|
|
1445
|
-
e.blur(), document.body.removeChild(e), t instanceof HTMLElement && t.focus();
|
|
1446
|
-
};
|
|
1447
|
-
}
|
|
1448
|
-
const lr = [
|
|
1449
|
-
Je.SPECIAL_PASTE_COL_WIDTH,
|
|
1450
|
-
Je.SPECIAL_PASTE_VALUE,
|
|
1451
|
-
Je.SPECIAL_PASTE_FORMAT,
|
|
1452
|
-
Je.SPECIAL_PASTE_FORMULA
|
|
1453
|
-
];
|
|
1454
|
-
let Ht = class extends re {
|
|
1455
|
-
constructor(t, e, n, r, s) {
|
|
1456
|
-
super();
|
|
1457
|
-
ae(this, "_copyInfo");
|
|
1458
|
-
this._sheetClipboardService = t, this._renderManagerService = e, this._drawingService = n, this._clipboardInterfaceService = r, this._commandService = s, this._initCopyPaste();
|
|
1459
|
-
}
|
|
1460
|
-
get _focusedDrawings() {
|
|
1461
|
-
return this._drawingService.getFocusDrawings();
|
|
1462
|
-
}
|
|
1463
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1464
|
-
_initCopyPaste() {
|
|
1465
|
-
this._sheetClipboardService.addClipboardHook({
|
|
1466
|
-
id: "SHEET_IMAGE_UI_PLUGIN",
|
|
1467
|
-
onBeforeCopy: (t, e, n, r) => {
|
|
1468
|
-
this._copyInfo = null;
|
|
1469
|
-
const s = this._focusedDrawings;
|
|
1470
|
-
if (s.length > 0) {
|
|
1471
|
-
const [o] = s;
|
|
1472
|
-
if (o.drawingType !== B.DRAWING_IMAGE)
|
|
1473
|
-
return;
|
|
1474
|
-
if (r === Pe.CUT) {
|
|
1475
|
-
const c = {
|
|
1476
|
-
unitId: t,
|
|
1477
|
-
drawings: [o]
|
|
1478
|
-
};
|
|
1479
|
-
this._commandService.executeCommand(vt.id, c);
|
|
1480
|
-
}
|
|
1481
|
-
setTimeout(() => {
|
|
1482
|
-
const c = io();
|
|
1483
|
-
o.drawingType === B.DRAWING_IMAGE && o.imageSourceType === as.BASE64 ? ro(o.source) : this._clipboardInterfaceService.writeText(""), c();
|
|
1484
|
-
}, 200);
|
|
1485
|
-
const a = {
|
|
1486
|
-
unitId: o.unitId,
|
|
1487
|
-
subUnitId: o.subUnitId,
|
|
1488
|
-
drawings: [o]
|
|
1489
|
-
};
|
|
1490
|
-
this._copyInfo = a;
|
|
1491
|
-
} else {
|
|
1492
|
-
const o = this._createDrawingsCopyInfoByRange(t, e, n);
|
|
1493
|
-
this._copyInfo = o;
|
|
1494
|
-
}
|
|
1495
|
-
},
|
|
1496
|
-
onPasteCells: (t, e, n, r) => {
|
|
1497
|
-
if (!this._copyInfo)
|
|
1498
|
-
return { redos: [], undos: [] };
|
|
1499
|
-
const { copyType: s = Pe.COPY, pasteType: o } = r, { range: a } = t || {}, { range: c, unitId: u, subUnitId: d } = e;
|
|
1500
|
-
return this._copyInfo.copyRange ? this._generateRangeDrawingsPasteMutations({ pasteType: o, unitId: u, subUnitId: d, pasteRange: c }, { copyRange: a, copyType: s }) : this._generateSingleDrawingPasteMutations({ pasteTo: e, pasteType: o }, Pe.COPY);
|
|
1501
|
-
},
|
|
1502
|
-
onPastePlainText: (t, e) => ({ undos: [], redos: [] }),
|
|
1503
|
-
onPasteUnrecognized: (t) => this._copyInfo ? this._generateSingleDrawingPasteMutations({ pasteTo: t, pasteType: Je.DEFAULT_PASTE }, Pe.COPY) : { undos: [], redos: [] },
|
|
1504
|
-
onPasteFiles: (t, e) => {
|
|
1505
|
-
if (this._copyInfo)
|
|
1506
|
-
return this._generateSingleDrawingPasteMutations({ pasteTo: t, pasteType: Je.DEFAULT_PASTE }, Pe.COPY);
|
|
1507
|
-
{
|
|
1508
|
-
const n = e.filter((r) => r.type.includes("image"));
|
|
1509
|
-
if (n.length)
|
|
1510
|
-
return {
|
|
1511
|
-
undos: [],
|
|
1512
|
-
redos: [
|
|
1513
|
-
{
|
|
1514
|
-
id: Qt.id,
|
|
1515
|
-
params: { files: n }
|
|
1516
|
-
}
|
|
1517
|
-
]
|
|
1518
|
-
};
|
|
1519
|
-
}
|
|
1520
|
-
return { undos: [], redos: [] };
|
|
1521
|
-
}
|
|
1522
|
-
});
|
|
1523
|
-
}
|
|
1524
|
-
_createDrawingsCopyInfoByRange(t, e, n) {
|
|
1525
|
-
var g;
|
|
1526
|
-
const r = (g = this._renderManagerService.getRenderById(t)) == null ? void 0 : g.with(Z);
|
|
1527
|
-
if (!r) return;
|
|
1528
|
-
const s = r.attachRangeWithCoord(n);
|
|
1529
|
-
if (!s)
|
|
1530
|
-
return;
|
|
1531
|
-
const { startX: o, endX: a, startY: c, endY: u } = s, d = this._drawingService.getDrawingData(t, e), l = this._focusedDrawings.slice();
|
|
1532
|
-
if (Object.keys(d).forEach((h) => {
|
|
1533
|
-
const f = d[h];
|
|
1534
|
-
if (f.drawingType !== B.DRAWING_IMAGE)
|
|
1535
|
-
return;
|
|
1536
|
-
const { transform: m } = f;
|
|
1537
|
-
if (f.anchorType !== U.Both || !m)
|
|
1538
|
-
return;
|
|
1539
|
-
const { left: p = 0, top: S = 0, width: _ = 0, height: R = 0 } = m, { drawingStartX: M, drawingEndX: I, drawingStartY: v, drawingEndY: C } = {
|
|
1540
|
-
drawingStartX: p,
|
|
1541
|
-
drawingEndX: p + _,
|
|
1542
|
-
drawingStartY: S,
|
|
1543
|
-
drawingEndY: S + R
|
|
1544
|
-
};
|
|
1545
|
-
o <= M && I <= a && c <= v && C <= u && l.push(f);
|
|
1546
|
-
}), l.length)
|
|
1547
|
-
return {
|
|
1548
|
-
copyRange: n,
|
|
1549
|
-
drawings: l,
|
|
1550
|
-
unitId: t,
|
|
1551
|
-
subUnitId: e
|
|
1552
|
-
};
|
|
1553
|
-
}
|
|
1554
|
-
_generateSingleDrawingPasteMutations(t, e) {
|
|
1555
|
-
const { pasteType: n, pasteTo: r } = t;
|
|
1556
|
-
if (lr.includes(n))
|
|
1557
|
-
return { redos: [], undos: [] };
|
|
1558
|
-
const { unitId: s, subUnitId: o, range: a } = r, c = this._renderManagerService.getRenderById(s), u = c == null ? void 0 : c.with(Z), d = c == null ? void 0 : c.with(Oe), l = this._copyInfo;
|
|
1559
|
-
if (!u || !d)
|
|
1560
|
-
return { redos: [], undos: [] };
|
|
1561
|
-
const { drawings: g } = l, h = Yn(a);
|
|
1562
|
-
return this._generateMutations(g, {
|
|
1563
|
-
unitId: s,
|
|
1564
|
-
subUnitId: o,
|
|
1565
|
-
isCut: e === Pe.CUT,
|
|
1566
|
-
getTransform: (f, m) => {
|
|
1567
|
-
var _, R;
|
|
1568
|
-
const p = u.attachRangeWithCoord({
|
|
1569
|
-
startRow: h.startRow,
|
|
1570
|
-
endRow: h.endRow,
|
|
1571
|
-
startColumn: h.startColumn,
|
|
1572
|
-
endColumn: h.endColumn
|
|
1573
|
-
}), S = {
|
|
1574
|
-
...f,
|
|
1575
|
-
left: p == null ? void 0 : p.startX,
|
|
1576
|
-
top: p == null ? void 0 : p.startY
|
|
1577
|
-
};
|
|
1578
|
-
return {
|
|
1579
|
-
transform: S,
|
|
1580
|
-
sheetTransform: (_ = j(S, d)) != null ? _ : m,
|
|
1581
|
-
axisAlignSheetTransform: (R = F(S, d)) != null ? R : m
|
|
1582
|
-
};
|
|
1583
|
-
}
|
|
1584
|
-
});
|
|
1585
|
-
}
|
|
1586
|
-
_generateMutations(t, e) {
|
|
1587
|
-
const {
|
|
1588
|
-
unitId: n,
|
|
1589
|
-
subUnitId: r,
|
|
1590
|
-
getTransform: s,
|
|
1591
|
-
isCut: o
|
|
1592
|
-
} = e, a = [], c = [], { _drawingService: u } = this;
|
|
1593
|
-
return t.forEach((d) => {
|
|
1594
|
-
const { transform: l, sheetTransform: g } = d;
|
|
1595
|
-
if (!l)
|
|
1596
|
-
return;
|
|
1597
|
-
const h = s(l, g), f = {
|
|
1598
|
-
...d,
|
|
1599
|
-
unitId: n,
|
|
1600
|
-
subUnitId: r,
|
|
1601
|
-
drawingId: o ? d.drawingId : Ze(),
|
|
1602
|
-
transform: h.transform,
|
|
1603
|
-
sheetTransform: h.sheetTransform,
|
|
1604
|
-
axisAlignSheetTransform: h.axisAlignSheetTransform
|
|
1605
|
-
};
|
|
1606
|
-
if (o) {
|
|
1607
|
-
const { undo: m, redo: p, objects: S } = u.getBatchUpdateOp([f]);
|
|
1608
|
-
a.push({
|
|
1609
|
-
id: A.id,
|
|
1610
|
-
params: {
|
|
1611
|
-
unitId: n,
|
|
1612
|
-
subUnitId: r,
|
|
1613
|
-
type: P.UPDATE,
|
|
1614
|
-
op: p,
|
|
1615
|
-
objects: S
|
|
1616
|
-
}
|
|
1617
|
-
}), c.push({
|
|
1618
|
-
id: A.id,
|
|
1619
|
-
params: {
|
|
1620
|
-
unitId: n,
|
|
1621
|
-
subUnitId: r,
|
|
1622
|
-
type: P.UPDATE,
|
|
1623
|
-
op: m,
|
|
1624
|
-
objects: S
|
|
1625
|
-
}
|
|
1626
|
-
});
|
|
1627
|
-
} else {
|
|
1628
|
-
const { undo: m, redo: p, objects: S } = u.getBatchAddOp([f]);
|
|
1629
|
-
a.push({ id: A.id, params: { op: p, unitId: n, subUnitId: r, objects: S, type: P.INSERT } }), c.push({ id: A.id, params: { op: m, unitId: n, subUnitId: r, objects: S, type: P.REMOVE } });
|
|
1630
|
-
}
|
|
1631
|
-
}), { redos: a, undos: c };
|
|
1632
|
-
}
|
|
1633
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1634
|
-
_generateRangeDrawingsPasteMutations(t, e) {
|
|
1635
|
-
var D;
|
|
1636
|
-
const {
|
|
1637
|
-
unitId: n,
|
|
1638
|
-
subUnitId: r,
|
|
1639
|
-
pasteType: s,
|
|
1640
|
-
pasteRange: o
|
|
1641
|
-
} = t, {
|
|
1642
|
-
copyRange: a,
|
|
1643
|
-
copyType: c
|
|
1644
|
-
} = e;
|
|
1645
|
-
if (lr.includes(s))
|
|
1646
|
-
return { redos: [], undos: [] };
|
|
1647
|
-
const u = (D = this._renderManagerService.getRenderById(n)) == null ? void 0 : D.with(Z);
|
|
1648
|
-
if (!u || !this._copyInfo)
|
|
1649
|
-
return { redos: [], undos: [] };
|
|
1650
|
-
const { drawings: d } = this._copyInfo;
|
|
1651
|
-
if (!a)
|
|
1652
|
-
return this._generateSingleDrawingPasteMutations({
|
|
1653
|
-
pasteTo: { unitId: n, subUnitId: r, range: Yn(o) },
|
|
1654
|
-
pasteType: s
|
|
1655
|
-
}, c);
|
|
1656
|
-
const { ranges: [l, g], mapFunc: h } = di([a, o]), { row: f, col: m } = h(l.startRow, l.startColumn), { row: p, col: S } = h(g.startRow, g.startColumn), _ = u.attachRangeWithCoord({
|
|
1657
|
-
startRow: f,
|
|
1658
|
-
endRow: f,
|
|
1659
|
-
startColumn: m,
|
|
1660
|
-
endColumn: m
|
|
1661
|
-
}), R = u.attachRangeWithCoord({
|
|
1662
|
-
startRow: p,
|
|
1663
|
-
endRow: p,
|
|
1664
|
-
startColumn: S,
|
|
1665
|
-
endColumn: S
|
|
1666
|
-
});
|
|
1667
|
-
if (!_ || !R || !this._copyInfo)
|
|
1668
|
-
return { redos: [], undos: [] };
|
|
1669
|
-
const M = R.startX - _.startX, I = R.startY - _.startY, v = p - f, C = S - m;
|
|
1670
|
-
return this._generateMutations(d, {
|
|
1671
|
-
unitId: n,
|
|
1672
|
-
subUnitId: r,
|
|
1673
|
-
getTransform: (T, b) => {
|
|
1674
|
-
var O, x, q;
|
|
1675
|
-
const E = {
|
|
1676
|
-
...T,
|
|
1677
|
-
left: ((O = T == null ? void 0 : T.left) != null ? O : 0) + M,
|
|
1678
|
-
top: ((x = T == null ? void 0 : T.top) != null ? x : 0) + I
|
|
1679
|
-
}, w = this._renderManagerService.getRenderById(n), y = w == null ? void 0 : w.with(Oe);
|
|
1680
|
-
return y ? {
|
|
1681
|
-
transform: E,
|
|
1682
|
-
sheetTransform: {
|
|
1683
|
-
...b,
|
|
1684
|
-
to: {
|
|
1685
|
-
...b.to,
|
|
1686
|
-
row: b.to.row + v,
|
|
1687
|
-
column: b.to.column + C
|
|
1688
|
-
},
|
|
1689
|
-
from: {
|
|
1690
|
-
...b.from,
|
|
1691
|
-
row: b.from.row + v,
|
|
1692
|
-
column: b.from.column + C
|
|
1693
|
-
}
|
|
1694
|
-
},
|
|
1695
|
-
axisAlignSheetTransform: (q = F(E, y)) != null ? q : b
|
|
1696
|
-
} : {
|
|
1697
|
-
transform: E,
|
|
1698
|
-
sheetTransform: {
|
|
1699
|
-
...b,
|
|
1700
|
-
to: {
|
|
1701
|
-
...b.to,
|
|
1702
|
-
row: b.to.row + v,
|
|
1703
|
-
column: b.to.column + C
|
|
1704
|
-
},
|
|
1705
|
-
from: {
|
|
1706
|
-
...b.from,
|
|
1707
|
-
row: b.from.row + v,
|
|
1708
|
-
column: b.from.column + C
|
|
1709
|
-
}
|
|
1710
|
-
},
|
|
1711
|
-
axisAlignSheetTransform: {
|
|
1712
|
-
...b,
|
|
1713
|
-
to: {
|
|
1714
|
-
...b.to,
|
|
1715
|
-
row: b.to.row + v,
|
|
1716
|
-
column: b.to.column + C
|
|
1717
|
-
},
|
|
1718
|
-
from: {
|
|
1719
|
-
...b.from,
|
|
1720
|
-
row: b.from.row + v,
|
|
1721
|
-
column: b.from.column + C
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
};
|
|
1725
|
-
},
|
|
1726
|
-
isCut: c === Pe.CUT
|
|
1727
|
-
});
|
|
1728
|
-
}
|
|
1729
|
-
};
|
|
1730
|
-
Ht = to([
|
|
1731
|
-
lt(0, li),
|
|
1732
|
-
lt(1, ee),
|
|
1733
|
-
lt(2, de),
|
|
1734
|
-
lt(3, us),
|
|
1735
|
-
lt(4, K)
|
|
1736
|
-
], Ht);
|
|
1737
|
-
var so = Object.getOwnPropertyDescriptor, oo = (i, t, e, n) => {
|
|
1738
|
-
for (var r = n > 1 ? void 0 : n ? so(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1739
|
-
(o = i[s]) && (r = o(r) || r);
|
|
1740
|
-
return r;
|
|
1741
|
-
}, ut = (i, t) => (e, n) => t(e, n, i);
|
|
1742
|
-
let Vt = class extends re {
|
|
1743
|
-
constructor(i, t, e, n, r) {
|
|
1744
|
-
super(), this._drawingManagerService = i, this._renderManagerService = t, this._permissionService = e, this._univerInstanceService = n, this._userManagerService = r, this._initDrawingVisible(), this._initDrawingEditable(), this._initViewPermissionChange(), this._initEditPermissionChange();
|
|
1745
|
-
}
|
|
1746
|
-
_initDrawingVisible() {
|
|
1747
|
-
const i = this._univerInstanceService.getCurrentTypeOfUnit$($.UNIVER_SHEET), t = this._userManagerService.currentUser$, e = ft([i, t]);
|
|
1748
|
-
this.disposeWithMe(
|
|
1749
|
-
e.pipe(
|
|
1750
|
-
ve(([n, r]) => n ? n.activeSheet$.pipe(
|
|
1751
|
-
rr((s) => {
|
|
1752
|
-
if (!s) {
|
|
1753
|
-
this._drawingManagerService.setDrawingVisible(!1);
|
|
1754
|
-
return;
|
|
1755
|
-
}
|
|
1756
|
-
const o = n.getUnitId(), a = s.getSheetId();
|
|
1757
|
-
this._permissionService.composePermission([
|
|
1758
|
-
new Xn(o).id,
|
|
1759
|
-
new zn(o, a).id
|
|
1760
|
-
]).every((u) => u.value) ? this._drawingManagerService.setDrawingVisible(!0) : this._handleDrawingVisibilityFalse(n, s);
|
|
1761
|
-
})
|
|
1762
|
-
) : (this._drawingManagerService.setDrawingVisible(!1), De))
|
|
1763
|
-
).subscribe()
|
|
1764
|
-
);
|
|
1765
|
-
}
|
|
1766
|
-
_handleDrawingVisibilityFalse(i, t) {
|
|
1767
|
-
this._drawingManagerService.setDrawingVisible(!1);
|
|
1768
|
-
const e = i.getUnitId(), n = t.getSheetId(), r = this._drawingManagerService.getDrawingData(e, n), s = Object.values(r), o = this._renderManagerService.getRenderById(e), a = o == null ? void 0 : o.scene;
|
|
1769
|
-
if (!a)
|
|
1770
|
-
return;
|
|
1771
|
-
a.getAllObjectsByOrder().forEach((u) => {
|
|
1772
|
-
u.classType === He.IMAGE && s.some((d) => u.oKey.includes(d.drawingId)) && a.removeObject(u);
|
|
1773
|
-
});
|
|
1774
|
-
}
|
|
1775
|
-
_initDrawingEditable() {
|
|
1776
|
-
const i = this._univerInstanceService.getCurrentTypeOfUnit$($.UNIVER_SHEET), t = this._userManagerService.currentUser$, e = ft([i, t]);
|
|
1777
|
-
this.disposeWithMe(
|
|
1778
|
-
e.pipe(
|
|
1779
|
-
ve(([n, r]) => n ? n.activeSheet$.pipe(
|
|
1780
|
-
rr((s) => {
|
|
1781
|
-
if (!s) {
|
|
1782
|
-
this._drawingManagerService.setDrawingEditable(!1);
|
|
1783
|
-
return;
|
|
1784
|
-
}
|
|
1785
|
-
const o = n.getUnitId(), a = s.getSheetId();
|
|
1786
|
-
this._permissionService.composePermission([
|
|
1787
|
-
new wn(o).id,
|
|
1788
|
-
new pn(o, a).id
|
|
1789
|
-
]).every((u) => u.value) ? this._drawingManagerService.setDrawingEditable(!0) : this._handleDrawingEditableFalse(n, s);
|
|
1790
|
-
})
|
|
1791
|
-
) : (this._drawingManagerService.setDrawingEditable(!1), De))
|
|
1792
|
-
).subscribe()
|
|
1793
|
-
);
|
|
1794
|
-
}
|
|
1795
|
-
_handleDrawingEditableFalse(i, t) {
|
|
1796
|
-
this._drawingManagerService.setDrawingEditable(!1);
|
|
1797
|
-
const e = i.getUnitId(), n = t.getSheetId(), r = this._drawingManagerService.getDrawingData(e, n), s = Object.values(r), o = this._renderManagerService.getRenderById(e), a = o == null ? void 0 : o.scene;
|
|
1798
|
-
if (!a)
|
|
1799
|
-
return;
|
|
1800
|
-
a.getAllObjectsByOrder().forEach((u) => {
|
|
1801
|
-
u.classType === He.IMAGE && s.some((d) => u.oKey.includes(d.drawingId)) && a.detachTransformerFrom(u);
|
|
1802
|
-
});
|
|
1803
|
-
}
|
|
1804
|
-
_initViewPermissionChange() {
|
|
1805
|
-
const i = this._univerInstanceService.getCurrentTypeOfUnit$($.UNIVER_SHEET), t = this._userManagerService.currentUser$;
|
|
1806
|
-
this.disposeWithMe(
|
|
1807
|
-
ft([i, t]).pipe(
|
|
1808
|
-
ve(([e, n]) => e ? e.activeSheet$.pipe(
|
|
1809
|
-
ve((r) => {
|
|
1810
|
-
if (!r)
|
|
1811
|
-
return De;
|
|
1812
|
-
const s = e.getUnitId(), o = r.getSheetId(), a = this._renderManagerService.getRenderById(s), c = a == null ? void 0 : a.scene;
|
|
1813
|
-
if (!c)
|
|
1814
|
-
return De;
|
|
1815
|
-
const u = c.getTransformerByCreate();
|
|
1816
|
-
return this._permissionService.composePermission$([
|
|
1817
|
-
new Xn(s).id,
|
|
1818
|
-
new zn(s, o).id
|
|
1819
|
-
]).pipe(
|
|
1820
|
-
Ie((l) => l.every((g) => g.value)),
|
|
1821
|
-
ir()
|
|
1822
|
-
).pipe(
|
|
1823
|
-
Ie((l) => ({
|
|
1824
|
-
permission: l,
|
|
1825
|
-
scene: c,
|
|
1826
|
-
transformer: u,
|
|
1827
|
-
unitId: s,
|
|
1828
|
-
subUnitId: o
|
|
1829
|
-
}))
|
|
1830
|
-
);
|
|
1831
|
-
})
|
|
1832
|
-
) : De)
|
|
1833
|
-
).subscribe({
|
|
1834
|
-
next: ({ permission: e, scene: n, transformer: r, unitId: s, subUnitId: o }) => {
|
|
1835
|
-
this._drawingManagerService.setDrawingVisible(e);
|
|
1836
|
-
const a = n.getAllObjectsByOrder(), c = this._drawingManagerService.getDrawingData(s, o), u = Object.values(c);
|
|
1837
|
-
e ? this._drawingManagerService.addNotification(u) : (a.forEach((d) => {
|
|
1838
|
-
d.classType === He.IMAGE && u.some((l) => d.oKey.includes(l.drawingId)) && n.removeObject(d);
|
|
1839
|
-
}), r.clearSelectedObjects());
|
|
1840
|
-
},
|
|
1841
|
-
complete: () => {
|
|
1842
|
-
this._drawingManagerService.setDrawingVisible(!0);
|
|
1843
|
-
const e = this._univerInstanceService.getCurrentUnitForType($.UNIVER_SHEET), n = e == null ? void 0 : e.getActiveSheet(), r = e == null ? void 0 : e.getUnitId(), s = n == null ? void 0 : n.getSheetId();
|
|
1844
|
-
if (!r || !s)
|
|
1845
|
-
return;
|
|
1846
|
-
const o = this._drawingManagerService.getDrawingData(r, s), a = Object.values(o);
|
|
1847
|
-
this._drawingManagerService.addNotification(a);
|
|
1848
|
-
}
|
|
1849
|
-
})
|
|
1850
|
-
);
|
|
1851
|
-
}
|
|
1852
|
-
_initEditPermissionChange() {
|
|
1853
|
-
const i = this._univerInstanceService.getCurrentTypeOfUnit$($.UNIVER_SHEET), t = this._userManagerService.currentUser$;
|
|
1854
|
-
this.disposeWithMe(
|
|
1855
|
-
ft([i, t]).pipe(
|
|
1856
|
-
ve(([e, n]) => e ? e.activeSheet$.pipe(
|
|
1857
|
-
ve((r) => {
|
|
1858
|
-
if (!r)
|
|
1859
|
-
return De;
|
|
1860
|
-
const s = e.getUnitId(), o = r.getSheetId(), a = this._renderManagerService.getRenderById(s), c = a == null ? void 0 : a.scene;
|
|
1861
|
-
if (!c)
|
|
1862
|
-
return De;
|
|
1863
|
-
const u = c.getTransformerByCreate();
|
|
1864
|
-
return this._permissionService.composePermission$([
|
|
1865
|
-
new wn(s).id,
|
|
1866
|
-
new pn(s, o).id
|
|
1867
|
-
]).pipe(
|
|
1868
|
-
Ie((l) => l.every((g) => g.value)),
|
|
1869
|
-
ir()
|
|
1870
|
-
).pipe(
|
|
1871
|
-
Ie((l) => ({
|
|
1872
|
-
permission: l,
|
|
1873
|
-
scene: c,
|
|
1874
|
-
transformer: u,
|
|
1875
|
-
unitId: s,
|
|
1876
|
-
subUnitId: o
|
|
1877
|
-
}))
|
|
1878
|
-
);
|
|
1879
|
-
})
|
|
1880
|
-
) : De)
|
|
1881
|
-
).subscribe({
|
|
1882
|
-
next: ({ permission: e, scene: n, transformer: r, unitId: s, subUnitId: o }) => {
|
|
1883
|
-
this._drawingManagerService.setDrawingEditable(e);
|
|
1884
|
-
const a = n.getAllObjectsByOrder(), c = this._drawingManagerService.getDrawingData(s, o), u = Object.values(c);
|
|
1885
|
-
e ? (a.forEach((d) => {
|
|
1886
|
-
d.classType === He.IMAGE && u.some((l) => d.oKey.includes(l.drawingId)) && n.attachTransformerTo(d);
|
|
1887
|
-
}), this._drawingManagerService.addNotification(u)) : (a.forEach((d) => {
|
|
1888
|
-
d.classType === He.IMAGE && u.some((l) => d.oKey.includes(l.drawingId)) && n.detachTransformerFrom(d);
|
|
1889
|
-
}), r.clearSelectedObjects());
|
|
1890
|
-
},
|
|
1891
|
-
complete: () => {
|
|
1892
|
-
const e = this._univerInstanceService.getCurrentUnitForType($.UNIVER_SHEET);
|
|
1893
|
-
if (!e)
|
|
1894
|
-
return;
|
|
1895
|
-
const n = e.getUnitId(), r = e.getActiveSheet();
|
|
1896
|
-
if (!r)
|
|
1897
|
-
return;
|
|
1898
|
-
const s = r.getSheetId(), o = this._renderManagerService.getRenderById(n), a = o == null ? void 0 : o.scene;
|
|
1899
|
-
if (!a)
|
|
1900
|
-
return;
|
|
1901
|
-
const c = this._drawingManagerService.getDrawingData(n, s), u = Object.values(c);
|
|
1902
|
-
this._drawingManagerService.setDrawingEditable(!0), a.getAllObjectsByOrder().forEach((l) => {
|
|
1903
|
-
l.classType === He.IMAGE && u.some((g) => l.oKey.includes(g.drawingId)) && a.detachTransformerFrom(l);
|
|
1904
|
-
});
|
|
1905
|
-
}
|
|
1906
|
-
})
|
|
1907
|
-
);
|
|
1908
|
-
}
|
|
1909
|
-
};
|
|
1910
|
-
Vt = oo([
|
|
1911
|
-
ut(0, de),
|
|
1912
|
-
ut(1, ee),
|
|
1913
|
-
ut(2, _i),
|
|
1914
|
-
ut(3, he),
|
|
1915
|
-
ut(4, N(vi))
|
|
1916
|
-
], Vt);
|
|
1917
|
-
var ao = Object.getOwnPropertyDescriptor, co = (i, t, e, n) => {
|
|
1918
|
-
for (var r = n > 1 ? void 0 : n ? ao(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1919
|
-
(o = i[s]) && (r = o(r) || r);
|
|
1920
|
-
return r;
|
|
1921
|
-
}, Ae = (i, t) => (e, n) => t(e, n, i);
|
|
1922
|
-
const lo = "univer-sheet-float-dom-";
|
|
1923
|
-
function Kr(i, t, e, n, r, s = !1) {
|
|
1924
|
-
const { scaleX: o, scaleY: a } = t.getAncestorScale(), c = t.getViewport(ur.VIEW_MAIN), u = n.getFreeze(), { startColumn: d, startRow: l, xSplit: g, ySplit: h } = u, f = {
|
|
1925
|
-
left: !0,
|
|
1926
|
-
// left means the left of pic is in a viewMainLeft
|
|
1927
|
-
top: !0
|
|
1928
|
-
};
|
|
1929
|
-
if (!c)
|
|
1930
|
-
return {
|
|
1931
|
-
...i,
|
|
1932
|
-
absolute: f
|
|
1933
|
-
};
|
|
1934
|
-
const { left: m, right: p, top: S, bottom: _ } = i;
|
|
1935
|
-
let { top: R, left: M, viewportScrollX: I, viewportScrollY: v } = c;
|
|
1936
|
-
const { boundsOfViewArea: C, scrollDirectionResponse: D } = r || {}, { rowHeaderWidth: T, columnHeaderHeight: b } = e, E = {
|
|
1937
|
-
top: s ? 0 : b,
|
|
1938
|
-
left: s ? 0 : T
|
|
1939
|
-
};
|
|
1940
|
-
C && (Qe.isDefine(E.top) && (E.top = C.top), Qe.isDefine(E.left) && (E.left = C.left)), D === "HORIZONTAL" && (v = 0), D === "VERTICAL" && (I = 0);
|
|
1941
|
-
let w = 0, y = 0;
|
|
1942
|
-
const O = e.rowStartY(l - h) + b, x = e.colStartX(d - g) + T, q = e.rowStartY(l) + b, z = e.colStartX(d) + T;
|
|
1943
|
-
if (g === 0)
|
|
1944
|
-
f.left = !1, w = (m - I) * o, y = (p - I) * o;
|
|
1945
|
-
else {
|
|
1946
|
-
const Y = m - (x - T), k = p - (x - T);
|
|
1947
|
-
p < z ? (w = Y * o, y = k * o) : m <= z && p >= z ? (w = Y * o, y = Math.max(M, (p - I) * o)) : m > z && (f.left = !1, w = Math.max((m - I) * o, M), y = Math.max((p - I) * o, M));
|
|
1948
|
-
}
|
|
1949
|
-
let V = 0, G = 0;
|
|
1950
|
-
if (h === 0)
|
|
1951
|
-
f.top = !1, V = (S - v) * a, G = (_ - v) * a;
|
|
1952
|
-
else {
|
|
1953
|
-
const Y = S - (O - b), k = _ - (O - b);
|
|
1954
|
-
_ < q ? (V = Y * a, G = k * a) : S <= q && _ >= q ? (V = Y * a, G = Math.max(R, (_ - v) * a)) : S > q && (f.top = !1, V = Math.max((S - v) * a, R), G = Math.max((_ - v) * a, R));
|
|
1955
|
-
}
|
|
1956
|
-
return w = Math.max(w, E.left), V = Math.max(V, E.top), y = Math.max(y, E.left), G = Math.max(G, E.top), {
|
|
1957
|
-
left: w,
|
|
1958
|
-
right: y,
|
|
1959
|
-
top: V,
|
|
1960
|
-
bottom: G,
|
|
1961
|
-
absolute: f
|
|
1962
|
-
};
|
|
1963
|
-
}
|
|
1964
|
-
const _e = (i, t, e, n, r) => {
|
|
1965
|
-
const { left: s, top: o, width: a, height: c, angle: u } = i, d = {
|
|
1966
|
-
left: s,
|
|
1967
|
-
right: s + a,
|
|
1968
|
-
top: o,
|
|
1969
|
-
bottom: o + c
|
|
1970
|
-
}, l = Kr(d, t, e, n, r), { scaleX: g, scaleY: h } = t.getAncestorScale();
|
|
1971
|
-
return {
|
|
1972
|
-
startX: l.left,
|
|
1973
|
-
endX: l.right,
|
|
1974
|
-
startY: l.top,
|
|
1975
|
-
endY: l.bottom,
|
|
1976
|
-
rotate: u,
|
|
1977
|
-
width: a * g,
|
|
1978
|
-
height: c * h,
|
|
1979
|
-
absolute: l.absolute
|
|
1980
|
-
};
|
|
1981
|
-
};
|
|
1982
|
-
let wt = class extends re {
|
|
1983
|
-
constructor(t, e, n, r, s, o, a) {
|
|
1984
|
-
super();
|
|
1985
|
-
/**
|
|
1986
|
-
* for update dom container position when scrolling and zoom
|
|
1987
|
-
*/
|
|
1988
|
-
ae(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
|
|
1989
|
-
ae(this, "_transformChange$", new ln());
|
|
1990
|
-
ae(this, "transformChange$", this._transformChange$.asObservable());
|
|
1991
|
-
ae(this, "_add$", new ln());
|
|
1992
|
-
ae(this, "add$", this._add$.asObservable());
|
|
1993
|
-
ae(this, "_remove$", new ln());
|
|
1994
|
-
ae(this, "remove$", this._remove$.asObservable());
|
|
1995
|
-
this._renderManagerService = t, this._univerInstanceService = e, this._commandService = n, this._drawingManagerService = r, this._canvasFloatDomService = s, this._sheetDrawingService = o, this._lifecycleService = a, this._drawingAddListener(), this._featureUpdateListener(), this._deleteListener(), this._bindScrollEvent();
|
|
1996
|
-
}
|
|
1997
|
-
_bindScrollEvent() {
|
|
1998
|
-
this._lifecycleService.lifecycle$.pipe(ys((t) => t === Ci.Rendered), Ts(1)).subscribe(() => {
|
|
1999
|
-
this._scrollUpdateListener();
|
|
2000
|
-
});
|
|
2001
|
-
}
|
|
2002
|
-
getFloatDomInfo(t) {
|
|
2003
|
-
return this._domLayerInfoMap.get(t);
|
|
2004
|
-
}
|
|
2005
|
-
getFloatDomsBySubUnitId(t, e) {
|
|
2006
|
-
return Array.from(this._domLayerInfoMap.values()).filter((n) => n.subUnitId === e && n.unitId === t);
|
|
2007
|
-
}
|
|
2008
|
-
_getSceneAndTransformerByDrawingSearch(t) {
|
|
2009
|
-
if (t == null)
|
|
2010
|
-
return;
|
|
2011
|
-
const e = this._renderManagerService.getRenderById(t), n = e == null ? void 0 : e.scene;
|
|
2012
|
-
if (e == null || n == null)
|
|
2013
|
-
return null;
|
|
2014
|
-
const r = n.getTransformerByCreate(), s = e.engine.getCanvasElement();
|
|
2015
|
-
return { scene: n, transformer: r, renderUnit: e, canvas: s };
|
|
2016
|
-
}
|
|
2017
|
-
// eslint-disable-next-line max-lines-per-function
|
|
2018
|
-
_drawingAddListener() {
|
|
2019
|
-
this.disposeWithMe(
|
|
2020
|
-
// eslint-disable-next-line max-lines-per-function
|
|
2021
|
-
this._drawingManagerService.add$.subscribe((t) => {
|
|
2022
|
-
t.forEach((e) => {
|
|
2023
|
-
var Y;
|
|
2024
|
-
const { unitId: n, subUnitId: r, drawingId: s } = e, o = ce(this._univerInstanceService, { unitId: n, subUnitId: r }), a = this._drawingManagerService.getDrawingByParam(e), c = this._univerInstanceService.getUnit(n, $.UNIVER_SHEET);
|
|
2025
|
-
if (!c)
|
|
2026
|
-
return;
|
|
2027
|
-
const u = c.getActiveSheet().getSheetId();
|
|
2028
|
-
if (!a || !o)
|
|
2029
|
-
return;
|
|
2030
|
-
const d = (Y = this._renderManagerService.getRenderById(n)) == null ? void 0 : Y.with(Z).getSkeletonParam(r);
|
|
2031
|
-
if (!d)
|
|
2032
|
-
return;
|
|
2033
|
-
const { transform: l, drawingType: g, data: h } = a;
|
|
2034
|
-
if (g !== B.DRAWING_DOM && g !== B.DRAWING_CHART)
|
|
2035
|
-
return;
|
|
2036
|
-
const f = this._getSceneAndTransformerByDrawingSearch(n);
|
|
2037
|
-
if (f == null)
|
|
2038
|
-
return;
|
|
2039
|
-
const { scene: m, canvas: p } = f;
|
|
2040
|
-
if (l == null)
|
|
2041
|
-
return !0;
|
|
2042
|
-
if (u !== r)
|
|
2043
|
-
return;
|
|
2044
|
-
const { left: S, top: _, width: R, height: M, angle: I, flipX: v, flipY: C, skewX: D, skewY: T } = l, b = ye({ unitId: n, subUnitId: r, drawingId: s }), E = m.getObject(b);
|
|
2045
|
-
if (E != null) {
|
|
2046
|
-
E.transformByState({ left: S, top: _, width: R, height: M, angle: I, flipX: v, flipY: C, skewX: D, skewY: T });
|
|
2047
|
-
return;
|
|
2048
|
-
}
|
|
2049
|
-
const w = {
|
|
2050
|
-
left: S,
|
|
2051
|
-
top: _,
|
|
2052
|
-
width: R,
|
|
2053
|
-
height: M,
|
|
2054
|
-
zIndex: this._drawingManagerService.getDrawingOrder(n, r).length - 1
|
|
2055
|
-
}, y = g === B.DRAWING_CHART;
|
|
2056
|
-
if (w.rotateEnabled = !1, y) {
|
|
2057
|
-
const k = h ? h.backgroundColor : "white";
|
|
2058
|
-
w.fill = k, h && h.border && (w.stroke = h.border), w.paintFirst = "stroke", w.strokeWidth = 1, w.borderEnabled = !1, w.radius = 8;
|
|
2059
|
-
}
|
|
2060
|
-
const O = new Ve(b, w);
|
|
2061
|
-
y && O.setObjectType(Bn.CHART), m.addObject(O, nn), a.allowTransform !== !1 && m.attachTransformerTo(O);
|
|
2062
|
-
const x = new Pt(), q = _e(O, f.renderUnit.scene, d.skeleton, o.worksheet), z = new ze(q), V = `${lo}${Ze(6)}`, G = {
|
|
2063
|
-
dispose: x,
|
|
2064
|
-
rect: O,
|
|
2065
|
-
position$: z,
|
|
2066
|
-
unitId: n,
|
|
2067
|
-
subUnitId: r,
|
|
2068
|
-
id: s,
|
|
2069
|
-
domId: V
|
|
2070
|
-
};
|
|
2071
|
-
this._canvasFloatDomService.addFloatDom({
|
|
2072
|
-
position$: z,
|
|
2073
|
-
id: s,
|
|
2074
|
-
domId: V,
|
|
2075
|
-
componentKey: a.componentKey,
|
|
2076
|
-
onPointerDown: (k) => {
|
|
2077
|
-
p.dispatchEvent(new PointerEvent(k.type, k));
|
|
2078
|
-
},
|
|
2079
|
-
onPointerMove: (k) => {
|
|
2080
|
-
p.dispatchEvent(new PointerEvent(k.type, k));
|
|
2081
|
-
},
|
|
2082
|
-
onPointerUp: (k) => {
|
|
2083
|
-
p.dispatchEvent(new PointerEvent(k.type, k));
|
|
2084
|
-
},
|
|
2085
|
-
onWheel: (k) => {
|
|
2086
|
-
p.dispatchEvent(new WheelEvent(k.type, k));
|
|
2087
|
-
},
|
|
2088
|
-
data: h,
|
|
2089
|
-
unitId: n
|
|
2090
|
-
});
|
|
2091
|
-
const J = O.onTransformChange$.subscribeEvent(() => {
|
|
2092
|
-
const k = _e(O, f.renderUnit.scene, d.skeleton, o.worksheet);
|
|
2093
|
-
z.next(
|
|
2094
|
-
k
|
|
2095
|
-
);
|
|
2096
|
-
});
|
|
2097
|
-
x.add(() => {
|
|
2098
|
-
this._canvasFloatDomService.removeFloatDom(s);
|
|
2099
|
-
}), J && x.add(J), this._domLayerInfoMap.set(s, G);
|
|
2100
|
-
});
|
|
2101
|
-
})
|
|
2102
|
-
), this.disposeWithMe(
|
|
2103
|
-
this._drawingManagerService.remove$.subscribe((t) => {
|
|
2104
|
-
t.forEach((e) => {
|
|
2105
|
-
var l;
|
|
2106
|
-
const { unitId: n, subUnitId: r, drawingId: s } = e, o = ye({ unitId: n, subUnitId: r, drawingId: s }), a = this._getSceneAndTransformerByDrawingSearch(n);
|
|
2107
|
-
if (a == null)
|
|
2108
|
-
return;
|
|
2109
|
-
const { transformer: c, scene: u } = a, d = u.getObject(o);
|
|
2110
|
-
d != null && d.oKey && (c.clearControlByIds([d == null ? void 0 : d.oKey]), (l = u.getTransformer()) == null || l.clearSelectedObjects());
|
|
2111
|
-
});
|
|
2112
|
-
})
|
|
2113
|
-
);
|
|
2114
|
-
}
|
|
2115
|
-
_scrollUpdateListener() {
|
|
2116
|
-
const t = (e, n) => {
|
|
2117
|
-
var c;
|
|
2118
|
-
const r = this._getSceneAndTransformerByDrawingSearch(e), s = Array.from(this._domLayerInfoMap.keys()).map((u) => ({ id: u, ...this._domLayerInfoMap.get(u) })).filter((u) => u.subUnitId === n && u.unitId === e).map((u) => u.id), o = ce(this._univerInstanceService, { unitId: e, subUnitId: n }), a = (c = this._renderManagerService.getRenderById(e)) == null ? void 0 : c.with(Z).getSkeletonParam(n);
|
|
2119
|
-
!r || !o || !a || s.forEach((u) => {
|
|
2120
|
-
const d = this._domLayerInfoMap.get(u);
|
|
2121
|
-
if (d) {
|
|
2122
|
-
const l = _e(d.rect, r.renderUnit.scene, a.skeleton, o.worksheet, d);
|
|
2123
|
-
d.position$.next(l);
|
|
2124
|
-
}
|
|
2125
|
-
});
|
|
2126
|
-
};
|
|
2127
|
-
this.disposeWithMe(
|
|
2128
|
-
this._univerInstanceService.getCurrentTypeOfUnit$($.UNIVER_SHEET).pipe(
|
|
2129
|
-
ve((e) => e ? e.activeSheet$ : vn(null)),
|
|
2130
|
-
Ie((e) => {
|
|
2131
|
-
if (!e) return null;
|
|
2132
|
-
const n = e.getUnitId(), r = this._renderManagerService.getRenderById(n);
|
|
2133
|
-
return r ? { render: r, unitId: n, subUnitId: e.getSheetId() } : null;
|
|
2134
|
-
}),
|
|
2135
|
-
ve(
|
|
2136
|
-
(e) => e ? Ri(e.render.scene.getViewport(ur.VIEW_MAIN).onScrollAfter$).pipe(Ie(() => ({ unitId: e.unitId, subUnitId: e.subUnitId }))) : vn(null)
|
|
2137
|
-
)
|
|
2138
|
-
).subscribe((e) => {
|
|
2139
|
-
if (!e) return;
|
|
2140
|
-
const { unitId: n, subUnitId: r } = e;
|
|
2141
|
-
t(n, r);
|
|
2142
|
-
})
|
|
2143
|
-
), this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
|
|
2144
|
-
if (e.id === Wn.id) {
|
|
2145
|
-
const n = e.params, { unitId: r } = n;
|
|
2146
|
-
Array.from(this._domLayerInfoMap.values()).filter((o) => o.unitId === r).map((o) => o.subUnitId).forEach((o) => {
|
|
2147
|
-
t(r, o);
|
|
2148
|
-
});
|
|
2149
|
-
} else if (e.id === Fi.id) {
|
|
2150
|
-
const { unitId: n, subUnitId: r } = e.params;
|
|
2151
|
-
t(n, r);
|
|
2152
|
-
} else if (e.id === Li.id) {
|
|
2153
|
-
const { unitId: n, subUnitId: r } = e.params;
|
|
2154
|
-
t(n, r);
|
|
2155
|
-
}
|
|
2156
|
-
}));
|
|
2157
|
-
}
|
|
2158
|
-
updateFloatDomProps(t, e, n, r) {
|
|
2159
|
-
const s = this._domLayerInfoMap.get(n), o = this._getSceneAndTransformerByDrawingSearch(t);
|
|
2160
|
-
if (s && o) {
|
|
2161
|
-
const { scene: a } = o, c = ye({ unitId: t, subUnitId: e, drawingId: n }), u = a.getObject(c);
|
|
2162
|
-
u && u instanceof Ve && u.setProps(r);
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
_getPosition(t, e) {
|
|
2166
|
-
var g;
|
|
2167
|
-
const { startX: n, endX: r, startY: s, endY: o } = t, a = (g = this._renderManagerService.getRenderById(e)) == null ? void 0 : g.with(Oe);
|
|
2168
|
-
if (a == null)
|
|
2169
|
-
return;
|
|
2170
|
-
const c = a.getCellWithCoordByOffset(n, s);
|
|
2171
|
-
if (c == null)
|
|
2172
|
-
return;
|
|
2173
|
-
const u = {
|
|
2174
|
-
column: c.actualColumn,
|
|
2175
|
-
columnOffset: n - c.startX,
|
|
2176
|
-
row: c.actualRow,
|
|
2177
|
-
rowOffset: s - c.startY
|
|
2178
|
-
}, d = a.getCellWithCoordByOffset(r, o);
|
|
2179
|
-
if (d == null)
|
|
2180
|
-
return;
|
|
2181
|
-
const l = {
|
|
2182
|
-
column: d.actualColumn,
|
|
2183
|
-
columnOffset: r - d.startX,
|
|
2184
|
-
row: d.actualRow,
|
|
2185
|
-
rowOffset: o - d.startY
|
|
2186
|
-
};
|
|
2187
|
-
return {
|
|
2188
|
-
from: u,
|
|
2189
|
-
to: l
|
|
2190
|
-
};
|
|
2191
|
-
}
|
|
2192
|
-
_featureUpdateListener() {
|
|
2193
|
-
this.disposeWithMe(
|
|
2194
|
-
this._drawingManagerService.update$.subscribe((t) => {
|
|
2195
|
-
t.forEach((e) => {
|
|
2196
|
-
const n = this._drawingManagerService.getDrawingByParam(e);
|
|
2197
|
-
if (!n || n.drawingType !== B.DRAWING_DOM && n.drawingType !== B.DRAWING_CHART)
|
|
2198
|
-
return;
|
|
2199
|
-
const r = {
|
|
2200
|
-
...n.transform
|
|
2201
|
-
};
|
|
2202
|
-
this._transformChange$.next({ id: e.drawingId, value: r }), this._canvasFloatDomService.updateFloatDom(e.drawingId, {
|
|
2203
|
-
...n
|
|
2204
|
-
});
|
|
2205
|
-
const s = this._getSceneAndTransformerByDrawingSearch(e.unitId);
|
|
2206
|
-
if (s && n.drawingType !== B.DRAWING_CHART) {
|
|
2207
|
-
const { scene: o } = s, a = this._domLayerInfoMap.get(e.drawingId);
|
|
2208
|
-
a != null && a.rect && (n.allowTransform === !1 ? o.detachTransformerFrom(a.rect) : o.attachTransformerTo(a.rect));
|
|
2209
|
-
}
|
|
2210
|
-
});
|
|
2211
|
-
})
|
|
2212
|
-
);
|
|
2213
|
-
}
|
|
2214
|
-
_deleteListener() {
|
|
2215
|
-
this.disposeWithMe(
|
|
2216
|
-
this._drawingManagerService.remove$.subscribe((t) => {
|
|
2217
|
-
t.forEach((e) => {
|
|
2218
|
-
this._removeDom(e.drawingId);
|
|
2219
|
-
});
|
|
2220
|
-
})
|
|
2221
|
-
);
|
|
2222
|
-
}
|
|
2223
|
-
// CreateFloatDomCommand --> floatDomService.addFloatDomToPosition
|
|
2224
|
-
addFloatDomToPosition(t, e) {
|
|
2225
|
-
const n = ce(this._univerInstanceService, {
|
|
2226
|
-
unitId: t.unitId,
|
|
2227
|
-
subUnitId: t.subUnitId
|
|
2228
|
-
});
|
|
2229
|
-
if (!n)
|
|
2230
|
-
throw new Error("cannot find current target!");
|
|
2231
|
-
const { unitId: r, subUnitId: s } = n, { initPosition: o, componentKey: a, data: c, allowTransform: u = !0 } = t, d = e != null ? e : Ze(), l = this._getPosition(o, r);
|
|
2232
|
-
if (l == null)
|
|
2233
|
-
return;
|
|
2234
|
-
const g = {
|
|
2235
|
-
unitId: r,
|
|
2236
|
-
subUnitId: s,
|
|
2237
|
-
drawingId: d,
|
|
2238
|
-
drawingType: t.type || B.DRAWING_DOM,
|
|
2239
|
-
componentKey: a,
|
|
2240
|
-
sheetTransform: l,
|
|
2241
|
-
transform: {
|
|
2242
|
-
left: o.startX,
|
|
2243
|
-
top: o.startY,
|
|
2244
|
-
width: o.endX - o.startX,
|
|
2245
|
-
height: o.endY - o.startY
|
|
2246
|
-
},
|
|
2247
|
-
axisAlignSheetTransform: l,
|
|
2248
|
-
data: c,
|
|
2249
|
-
allowTransform: u
|
|
2250
|
-
};
|
|
2251
|
-
return this._commandService.executeCommand(qt.id, {
|
|
2252
|
-
unitId: r,
|
|
2253
|
-
drawings: [g]
|
|
2254
|
-
}), this._add$.next({ unitId: r, subUnitId: s, id: d }), {
|
|
2255
|
-
id: d,
|
|
2256
|
-
dispose: () => {
|
|
2257
|
-
this._removeDom(d, !0);
|
|
2258
|
-
}
|
|
2259
|
-
};
|
|
2260
|
-
}
|
|
2261
|
-
_removeDom(t, e = !1) {
|
|
2262
|
-
const n = this._domLayerInfoMap.get(t);
|
|
2263
|
-
if (!n)
|
|
2264
|
-
return;
|
|
2265
|
-
const { unitId: r, subUnitId: s } = n;
|
|
2266
|
-
this._domLayerInfoMap.delete(t), n.dispose.dispose();
|
|
2267
|
-
const o = this._getSceneAndTransformerByDrawingSearch(r);
|
|
2268
|
-
if (o && o.scene.removeObject(n.rect), e) {
|
|
2269
|
-
const a = this._drawingManagerService.getDrawingByParam({ unitId: r, subUnitId: s, drawingId: t });
|
|
2270
|
-
if (!a)
|
|
2271
|
-
return;
|
|
2272
|
-
const c = this._sheetDrawingService.getBatchRemoveOp([a]), { redo: u, objects: d } = c;
|
|
2273
|
-
this._commandService.syncExecuteCommand(A.id, { unitId: r, subUnitId: s, op: u, objects: d, type: P.REMOVE });
|
|
2274
|
-
}
|
|
2275
|
-
}
|
|
2276
|
-
// eslint-disable-next-line max-lines-per-function, complexity
|
|
2277
|
-
addFloatDomToRange(t, e, n, r) {
|
|
2278
|
-
var v, C, D;
|
|
2279
|
-
const s = ce(this._univerInstanceService, {
|
|
2280
|
-
unitId: e.unitId,
|
|
2281
|
-
subUnitId: e.subUnitId
|
|
2282
|
-
});
|
|
2283
|
-
if (!s)
|
|
2284
|
-
throw new Error("cannot find current target!");
|
|
2285
|
-
const { unitId: o, subUnitId: a } = s, c = this._getSceneAndTransformerByDrawingSearch(o);
|
|
2286
|
-
if (!c) return;
|
|
2287
|
-
const u = this._renderManagerService.getRenderById(o);
|
|
2288
|
-
if (!u) return;
|
|
2289
|
-
const d = (v = this._renderManagerService.getRenderById(o)) == null ? void 0 : v.with(Z).getWorksheetSkeleton(a);
|
|
2290
|
-
if (!d) return;
|
|
2291
|
-
const { componentKey: l, data: g, allowTransform: h = !0 } = e, f = r != null ? r : Ze(), { position: m, position$: p } = this._createRangePositionObserver(t, u, d.skeleton);
|
|
2292
|
-
if (this._getPosition(m, o) == null)
|
|
2293
|
-
return;
|
|
2294
|
-
const _ = c.scene, { scaleX: R } = _.getAncestorScale(), M = Bt(m, n, R), I = {
|
|
2295
|
-
unitId: o,
|
|
2296
|
-
subUnitId: a,
|
|
2297
|
-
drawingId: f,
|
|
2298
|
-
drawingType: e.type || B.DRAWING_DOM,
|
|
2299
|
-
componentKey: l,
|
|
2300
|
-
transform: {
|
|
2301
|
-
left: M.startX,
|
|
2302
|
-
top: M.startY,
|
|
2303
|
-
width: M.width,
|
|
2304
|
-
height: M.height
|
|
2305
|
-
},
|
|
2306
|
-
data: g,
|
|
2307
|
-
allowTransform: h
|
|
2308
|
-
};
|
|
2309
|
-
{
|
|
2310
|
-
const { unitId: T, subUnitId: b, drawingId: E } = I, w = ce(this._univerInstanceService, { unitId: T, subUnitId: b }), y = I, O = this._univerInstanceService.getUnit(T, $.UNIVER_SHEET);
|
|
2311
|
-
if (!O)
|
|
2312
|
-
return;
|
|
2313
|
-
const x = O.getActiveSheet().getSheetId();
|
|
2314
|
-
if (!y || !w)
|
|
2315
|
-
return;
|
|
2316
|
-
const q = (C = this._renderManagerService.getRenderById(T)) == null ? void 0 : C.with(Z);
|
|
2317
|
-
if (!q)
|
|
2318
|
-
return;
|
|
2319
|
-
const z = q.getWorksheetSkeleton(b);
|
|
2320
|
-
if (!z)
|
|
2321
|
-
return;
|
|
2322
|
-
const { transform: V, drawingType: G, data: J } = y;
|
|
2323
|
-
if (G !== B.DRAWING_DOM && G !== B.DRAWING_CHART)
|
|
2324
|
-
return;
|
|
2325
|
-
const Y = this._getSceneAndTransformerByDrawingSearch(T);
|
|
2326
|
-
if (Y == null)
|
|
2327
|
-
return;
|
|
2328
|
-
const { scene: k, canvas: se } = Y;
|
|
2329
|
-
if (V == null || x !== b)
|
|
2330
|
-
return;
|
|
2331
|
-
const { left: ge, top: fe, width: le, height: Re, angle: Ue, flipX: tn, flipY: Dt, skewX: bt, skewY: We } = V, Mt = ye({ unitId: T, subUnitId: b, drawingId: E }), me = k.getObject(Mt);
|
|
2332
|
-
if (me != null) {
|
|
2333
|
-
me.transformByState({ left: ge, top: fe, width: le, height: Re, angle: Ue, flipX: tn, flipY: Dt, skewX: bt, skewY: We });
|
|
2334
|
-
return;
|
|
2335
|
-
}
|
|
2336
|
-
const oe = {
|
|
2337
|
-
left: ge,
|
|
2338
|
-
// from floatDomParam.transform
|
|
2339
|
-
top: fe,
|
|
2340
|
-
width: le,
|
|
2341
|
-
height: Re,
|
|
2342
|
-
zIndex: this._drawingManagerService.getDrawingOrder(T, b).length - 1
|
|
2343
|
-
}, je = G === B.DRAWING_CHART;
|
|
2344
|
-
if (je) {
|
|
2345
|
-
const W = J ? J.backgroundColor : "white";
|
|
2346
|
-
oe.fill = W, oe.rotateEnabled = !1, J && J.border && (oe.stroke = J.border), oe.paintFirst = "stroke", oe.strokeWidth = 1, oe.borderEnabled = !1, oe.radius = 8;
|
|
2347
|
-
}
|
|
2348
|
-
const pe = new Ve(Mt, oe);
|
|
2349
|
-
je && pe.setObjectType(Bn.CHART), k.addObject(pe, nn), y.allowTransform !== !1 && k.attachTransformerTo(pe);
|
|
2350
|
-
const we = new Pt(), yt = k.getMainViewport(), { rowHeaderWidth: Fe, columnHeaderHeight: ot } = z.skeleton, Tt = {
|
|
2351
|
-
top: ot,
|
|
2352
|
-
left: Fe,
|
|
2353
|
-
bottom: yt.bottom,
|
|
2354
|
-
right: yt.right
|
|
2355
|
-
}, Se = {
|
|
2356
|
-
dispose: we,
|
|
2357
|
-
rect: pe,
|
|
2358
|
-
boundsOfViewArea: Tt,
|
|
2359
|
-
domAnchor: n,
|
|
2360
|
-
unitId: T,
|
|
2361
|
-
subUnitId: b
|
|
2362
|
-
}, H = _e(pe, Y.renderUnit.scene, z.skeleton, w.worksheet, Se), Le = new ze(H);
|
|
2363
|
-
Se.position$ = Le;
|
|
2364
|
-
let at = {
|
|
2365
|
-
position$: Le,
|
|
2366
|
-
id: E,
|
|
2367
|
-
componentKey: y.componentKey,
|
|
2368
|
-
onPointerDown: () => {
|
|
2369
|
-
},
|
|
2370
|
-
onPointerMove: () => {
|
|
2371
|
-
},
|
|
2372
|
-
onPointerUp: () => {
|
|
2373
|
-
},
|
|
2374
|
-
onWheel: (W) => {
|
|
2375
|
-
se.dispatchEvent(new WheelEvent(W.type, W));
|
|
2376
|
-
},
|
|
2377
|
-
data: J,
|
|
2378
|
-
unitId: T
|
|
2379
|
-
};
|
|
2380
|
-
e.eventPassThrough && (at = {
|
|
2381
|
-
...at,
|
|
2382
|
-
onPointerDown: (W) => {
|
|
2383
|
-
se.dispatchEvent(new PointerEvent(W.type, W));
|
|
2384
|
-
},
|
|
2385
|
-
onPointerMove: (W) => {
|
|
2386
|
-
se.dispatchEvent(new PointerEvent(W.type, W));
|
|
2387
|
-
},
|
|
2388
|
-
onPointerUp: (W) => {
|
|
2389
|
-
se.dispatchEvent(new PointerEvent(W.type, W));
|
|
2390
|
-
}
|
|
2391
|
-
}), this._canvasFloatDomService.addFloatDom(at), this.disposeWithMe(p.subscribe((W) => {
|
|
2392
|
-
var An, Nn, xn, kn;
|
|
2393
|
-
const Pn = Bt({
|
|
2394
|
-
startX: W.startX,
|
|
2395
|
-
startY: W.startY,
|
|
2396
|
-
endX: W.endX,
|
|
2397
|
-
endY: W.endY,
|
|
2398
|
-
width: (An = n.width) != null ? An : W.width,
|
|
2399
|
-
height: (Nn = n.height) != null ? Nn : W.height,
|
|
2400
|
-
absolute: {
|
|
2401
|
-
left: m.absolute.left,
|
|
2402
|
-
top: m.absolute.top
|
|
2403
|
-
}
|
|
2404
|
-
}, n), Jr = ye({ unitId: T, subUnitId: b, drawingId: E }), Zr = new Ve(Jr, {
|
|
2405
|
-
left: Pn.startX,
|
|
2406
|
-
top: Pn.startY,
|
|
2407
|
-
width: (xn = n.width) != null ? xn : W.width,
|
|
2408
|
-
height: (kn = n.height) != null ? kn : W.height,
|
|
2409
|
-
zIndex: this._drawingManagerService.getDrawingOrder(T, b).length - 1
|
|
2410
|
-
}), qr = _e(Zr, Y.renderUnit.scene, z.skeleton, w.worksheet, Se);
|
|
2411
|
-
Le.next(qr);
|
|
2412
|
-
}));
|
|
2413
|
-
const ct = (D = this._renderManagerService.getRenderById(T)) == null ? void 0 : D.with(Z);
|
|
2414
|
-
ct == null || ct.currentSkeleton$.subscribe((W) => {
|
|
2415
|
-
W && z.sheetId !== W.sheetId && this._removeDom(f, !0);
|
|
2416
|
-
});
|
|
2417
|
-
const Et = pe.onTransformChange$.subscribeEvent(() => {
|
|
2418
|
-
const W = _e(pe, Y.renderUnit.scene, z.skeleton, w.worksheet, Se);
|
|
2419
|
-
Le.next(
|
|
2420
|
-
W
|
|
2421
|
-
);
|
|
2422
|
-
});
|
|
2423
|
-
we.add(() => {
|
|
2424
|
-
this._canvasFloatDomService.removeFloatDom(E);
|
|
2425
|
-
}), Et && we.add(Et), this._domLayerInfoMap.set(E, Se);
|
|
2426
|
-
}
|
|
2427
|
-
return {
|
|
2428
|
-
id: f,
|
|
2429
|
-
dispose: () => {
|
|
2430
|
-
this._removeDom(f, !0);
|
|
2431
|
-
}
|
|
2432
|
-
};
|
|
2433
|
-
}
|
|
2434
|
-
// eslint-disable-next-line max-lines-per-function, complexity
|
|
2435
|
-
addFloatDomToColumnHeader(t, e, n, r) {
|
|
2436
|
-
var M, I, v;
|
|
2437
|
-
const s = ce(this._univerInstanceService, {
|
|
2438
|
-
unitId: e.unitId,
|
|
2439
|
-
subUnitId: e.subUnitId
|
|
2440
|
-
});
|
|
2441
|
-
if (!s)
|
|
2442
|
-
throw new Error("cannot find current target!");
|
|
2443
|
-
const { unitId: o, subUnitId: a } = s;
|
|
2444
|
-
if (!this._getSceneAndTransformerByDrawingSearch(o)) return;
|
|
2445
|
-
const u = this._renderManagerService.getRenderById(o);
|
|
2446
|
-
if (!u) return;
|
|
2447
|
-
const d = (M = this._renderManagerService.getRenderById(o)) == null ? void 0 : M.with(Z).getWorksheetSkeleton(a);
|
|
2448
|
-
if (!d) return;
|
|
2449
|
-
const { componentKey: l, data: g, allowTransform: h = !0 } = e, f = r != null ? r : Ze(), { position: m, position$: p } = this._createRangePositionObserver({
|
|
2450
|
-
startRow: 0,
|
|
2451
|
-
endRow: 0,
|
|
2452
|
-
startColumn: t,
|
|
2453
|
-
endColumn: t
|
|
2454
|
-
}, u, d.skeleton), S = m;
|
|
2455
|
-
if (S.startY = 0, this._getPosition(m, o) == null)
|
|
2456
|
-
return;
|
|
2457
|
-
const R = {
|
|
2458
|
-
unitId: o,
|
|
2459
|
-
subUnitId: a,
|
|
2460
|
-
drawingId: f,
|
|
2461
|
-
drawingType: e.type || B.DRAWING_DOM,
|
|
2462
|
-
componentKey: l,
|
|
2463
|
-
transform: {
|
|
2464
|
-
left: S.startX,
|
|
2465
|
-
top: S.startY,
|
|
2466
|
-
width: S.width,
|
|
2467
|
-
height: S.height
|
|
2468
|
-
},
|
|
2469
|
-
data: g,
|
|
2470
|
-
allowTransform: h
|
|
2471
|
-
};
|
|
2472
|
-
{
|
|
2473
|
-
const { unitId: C, subUnitId: D, drawingId: T } = R, b = ce(this._univerInstanceService, { unitId: C, subUnitId: D }), E = R, w = this._univerInstanceService.getUnit(C, $.UNIVER_SHEET);
|
|
2474
|
-
if (!w)
|
|
2475
|
-
return;
|
|
2476
|
-
const y = w.getActiveSheet().getSheetId();
|
|
2477
|
-
if (!E || !b)
|
|
2478
|
-
return;
|
|
2479
|
-
const O = (I = this._renderManagerService.getRenderById(C)) == null ? void 0 : I.with(Z);
|
|
2480
|
-
if (!O)
|
|
2481
|
-
return;
|
|
2482
|
-
const x = O.getWorksheetSkeleton(D);
|
|
2483
|
-
if (!x)
|
|
2484
|
-
return;
|
|
2485
|
-
const { transform: q, data: z } = E, V = this._getSceneAndTransformerByDrawingSearch(C);
|
|
2486
|
-
if (V == null)
|
|
2487
|
-
return;
|
|
2488
|
-
const { scene: G, canvas: J } = V;
|
|
2489
|
-
if (q == null || y !== D)
|
|
2490
|
-
return;
|
|
2491
|
-
const { left: Y, top: k, width: se, height: ge, angle: fe, flipX: le, flipY: Re, skewX: Ue, skewY: tn } = q, Dt = ye({ unitId: C, subUnitId: D, drawingId: T }), bt = G.getObject(Dt);
|
|
2492
|
-
if (bt != null) {
|
|
2493
|
-
bt.transformByState({ left: Y, top: k, width: se, height: ge, angle: fe, flipX: le, flipY: Re, skewX: Ue, skewY: tn });
|
|
2494
|
-
return;
|
|
2495
|
-
}
|
|
2496
|
-
const We = Bt({
|
|
2497
|
-
startX: S.startX,
|
|
2498
|
-
startY: 0,
|
|
2499
|
-
endX: m.endX,
|
|
2500
|
-
endY: m.endY,
|
|
2501
|
-
width: n.width,
|
|
2502
|
-
height: n.height,
|
|
2503
|
-
absolute: {
|
|
2504
|
-
left: m.absolute.left,
|
|
2505
|
-
top: m.absolute.top
|
|
2506
|
-
}
|
|
2507
|
-
}, n), Mt = {
|
|
2508
|
-
left: We.startX,
|
|
2509
|
-
top: We.startY,
|
|
2510
|
-
width: We.width,
|
|
2511
|
-
height: We.height,
|
|
2512
|
-
zIndex: this._drawingManagerService.getDrawingOrder(C, D).length - 1
|
|
2513
|
-
}, me = new Ve(Dt, Mt);
|
|
2514
|
-
G.addObject(me, nn), E.allowTransform !== !1 && G.attachTransformerTo(me);
|
|
2515
|
-
const oe = new Pt(), je = G.getMainViewport(), pe = {
|
|
2516
|
-
top: 0,
|
|
2517
|
-
//viewMain.top,
|
|
2518
|
-
left: je.left,
|
|
2519
|
-
bottom: je.bottom,
|
|
2520
|
-
right: je.right
|
|
2521
|
-
}, we = {
|
|
2522
|
-
dispose: oe,
|
|
2523
|
-
rect: me,
|
|
2524
|
-
// position$,
|
|
2525
|
-
unitId: C,
|
|
2526
|
-
subUnitId: D,
|
|
2527
|
-
boundsOfViewArea: pe,
|
|
2528
|
-
domAnchor: n,
|
|
2529
|
-
scrollDirectionResponse: "HORIZONTAL"
|
|
2530
|
-
/* HORIZONTAL */
|
|
2531
|
-
}, yt = _e(me, V.renderUnit.scene, x.skeleton, b.worksheet, we), Fe = new ze(yt);
|
|
2532
|
-
we.position$ = Fe;
|
|
2533
|
-
let ot = {
|
|
2534
|
-
position$: Fe,
|
|
2535
|
-
id: T,
|
|
2536
|
-
componentKey: E.componentKey,
|
|
2537
|
-
onPointerDown: () => {
|
|
2538
|
-
},
|
|
2539
|
-
onPointerMove: () => {
|
|
2540
|
-
},
|
|
2541
|
-
onPointerUp: () => {
|
|
2542
|
-
},
|
|
2543
|
-
onWheel: (H) => {
|
|
2544
|
-
J.dispatchEvent(new WheelEvent(H.type, H));
|
|
2545
|
-
},
|
|
2546
|
-
data: z,
|
|
2547
|
-
unitId: C
|
|
2548
|
-
};
|
|
2549
|
-
e.eventPassThrough && (ot = {
|
|
2550
|
-
...ot,
|
|
2551
|
-
onPointerDown: (H) => {
|
|
2552
|
-
J.dispatchEvent(new PointerEvent(H.type, H));
|
|
2553
|
-
},
|
|
2554
|
-
onPointerMove: (H) => {
|
|
2555
|
-
J.dispatchEvent(new PointerEvent(H.type, H));
|
|
2556
|
-
},
|
|
2557
|
-
onPointerUp: (H) => {
|
|
2558
|
-
J.dispatchEvent(new PointerEvent(H.type, H));
|
|
2559
|
-
}
|
|
2560
|
-
}), this._canvasFloatDomService.addFloatDom(ot);
|
|
2561
|
-
const Tt = me.onTransformChange$.subscribeEvent(() => {
|
|
2562
|
-
const H = _e(me, V.renderUnit.scene, x.skeleton, b.worksheet, we);
|
|
2563
|
-
Fe.next(
|
|
2564
|
-
H
|
|
2565
|
-
);
|
|
2566
|
-
});
|
|
2567
|
-
this.disposeWithMe(p.subscribe((H) => {
|
|
2568
|
-
const Le = Bt({
|
|
2569
|
-
startX: H.startX,
|
|
2570
|
-
startY: 0,
|
|
2571
|
-
endX: H.endX,
|
|
2572
|
-
endY: H.endY,
|
|
2573
|
-
width: n.width,
|
|
2574
|
-
height: n.height,
|
|
2575
|
-
absolute: {
|
|
2576
|
-
left: m.absolute.left,
|
|
2577
|
-
top: m.absolute.top
|
|
2578
|
-
}
|
|
2579
|
-
}, n), at = ye({ unitId: C, subUnitId: D, drawingId: T }), ct = new Ve(at, {
|
|
2580
|
-
left: Le.startX,
|
|
2581
|
-
top: 0,
|
|
2582
|
-
width: n.width,
|
|
2583
|
-
height: n.height,
|
|
2584
|
-
zIndex: this._drawingManagerService.getDrawingOrder(C, D).length - 1
|
|
2585
|
-
}), Et = _e(ct, V.renderUnit.scene, x.skeleton, b.worksheet, we);
|
|
2586
|
-
Fe.next(Et);
|
|
2587
|
-
}));
|
|
2588
|
-
const Se = (v = this._renderManagerService.getRenderById(C)) == null ? void 0 : v.with(Z);
|
|
2589
|
-
Se == null || Se.currentSkeleton$.subscribe((H) => {
|
|
2590
|
-
H && d.sheetId !== H.sheetId && this._removeDom(f, !0);
|
|
2591
|
-
}), oe.add(() => {
|
|
2592
|
-
this._canvasFloatDomService.removeFloatDom(T);
|
|
2593
|
-
}), Tt && oe.add(Tt), this._domLayerInfoMap.set(T, we);
|
|
2594
|
-
}
|
|
2595
|
-
return {
|
|
2596
|
-
id: f,
|
|
2597
|
-
dispose: () => {
|
|
2598
|
-
this._removeDom(f, !0);
|
|
2599
|
-
}
|
|
2600
|
-
};
|
|
2601
|
-
}
|
|
2602
|
-
/**
|
|
2603
|
-
* Unlike _createCellPositionObserver, this accept a range not a single cell.
|
|
2604
|
-
*
|
|
2605
|
-
* @param initialRow
|
|
2606
|
-
* @param initialCol
|
|
2607
|
-
* @param currentRender
|
|
2608
|
-
* @param skeleton
|
|
2609
|
-
* @param activeViewport
|
|
2610
|
-
* @returns position of cell to canvas.
|
|
2611
|
-
*/
|
|
2612
|
-
// eslint-disable-next-line max-lines-per-function
|
|
2613
|
-
_createRangePositionObserver(t, e, n) {
|
|
2614
|
-
let { startRow: r, startColumn: s } = t;
|
|
2615
|
-
const o = ht(r, s, n), a = new ze(o), c = ht(t.endRow, t.endColumn, n), u = new ze(c), d = () => {
|
|
2616
|
-
const p = ht(r, s, n), S = ht(t.endRow, t.endColumn, n);
|
|
2617
|
-
a.next(p), u.next(S);
|
|
2618
|
-
}, l = new Pt();
|
|
2619
|
-
l.add(e.engine.clientRect$.subscribe(() => d())), l.add(this._commandService.onCommandExecuted((p) => {
|
|
2620
|
-
if (p.id === pr.id && p.params.rowsAutoHeightInfo.findIndex((_) => _.row === r) > -1) {
|
|
2621
|
-
d();
|
|
2622
|
-
return;
|
|
2623
|
-
}
|
|
2624
|
-
(Hi.indexOf(p.id) > -1 || p.id === ui.id || p.id === Wn.id) && d();
|
|
2625
|
-
}));
|
|
2626
|
-
const g = (p, S) => {
|
|
2627
|
-
r = p, s = S, d();
|
|
2628
|
-
}, h = () => ({
|
|
2629
|
-
rotate: 0,
|
|
2630
|
-
width: c.right - o.left,
|
|
2631
|
-
height: c.bottom - o.top,
|
|
2632
|
-
absolute: {
|
|
2633
|
-
left: !0,
|
|
2634
|
-
top: !0
|
|
2635
|
-
},
|
|
2636
|
-
startX: o.left,
|
|
2637
|
-
startY: o.top,
|
|
2638
|
-
endX: c.right,
|
|
2639
|
-
endY: c.bottom
|
|
2640
|
-
}), f = a.pipe(
|
|
2641
|
-
Ie((p) => {
|
|
2642
|
-
const S = ht(t.endRow, t.endColumn, n);
|
|
2643
|
-
return {
|
|
2644
|
-
rotate: 0,
|
|
2645
|
-
width: S.right - p.left,
|
|
2646
|
-
height: S.bottom - p.top,
|
|
2647
|
-
absolute: {
|
|
2648
|
-
left: !0,
|
|
2649
|
-
top: !0
|
|
2650
|
-
},
|
|
2651
|
-
startX: p.left,
|
|
2652
|
-
startY: p.top,
|
|
2653
|
-
endX: S.right,
|
|
2654
|
-
endY: S.bottom
|
|
2655
|
-
};
|
|
2656
|
-
})
|
|
2657
|
-
), m = h();
|
|
2658
|
-
return {
|
|
2659
|
-
position$: f,
|
|
2660
|
-
position: m,
|
|
2661
|
-
updateRowCol: g,
|
|
2662
|
-
topLeftPos$: a,
|
|
2663
|
-
rightBottomPos$: u,
|
|
2664
|
-
disposable: l
|
|
2665
|
-
};
|
|
2666
|
-
}
|
|
2667
|
-
};
|
|
2668
|
-
wt = co([
|
|
2669
|
-
Ae(0, N(ee)),
|
|
2670
|
-
Ae(1, he),
|
|
2671
|
-
Ae(2, N(K)),
|
|
2672
|
-
Ae(3, de),
|
|
2673
|
-
Ae(4, N(hs)),
|
|
2674
|
-
Ae(5, ie),
|
|
2675
|
-
Ae(6, N(Ii))
|
|
2676
|
-
], wt);
|
|
2677
|
-
function ht(i, t, e) {
|
|
2678
|
-
const n = e.getCellWithCoordByIndex(i, t), r = n.isMergedMainCell ? n.mergeInfo : n;
|
|
2679
|
-
return {
|
|
2680
|
-
left: r.startX,
|
|
2681
|
-
right: r.endX,
|
|
2682
|
-
top: r.startY,
|
|
2683
|
-
bottom: r.endY
|
|
2684
|
-
};
|
|
2685
|
-
}
|
|
2686
|
-
function Bt(i, t, e) {
|
|
2687
|
-
var u, d;
|
|
2688
|
-
e = e != null ? e : 1;
|
|
2689
|
-
const n = i.endX - i.startX, r = i.endY - i.startY, s = (u = t == null ? void 0 : t.width) != null ? u : n, o = (d = t == null ? void 0 : t.height) != null ? d : r;
|
|
2690
|
-
let a = 0, c = 0;
|
|
2691
|
-
if (t) {
|
|
2692
|
-
if (t.horizonOffsetAlign === "right") {
|
|
2693
|
-
const l = $t(t.marginX, n * e);
|
|
2694
|
-
a = i.endX - l - s;
|
|
2695
|
-
} else
|
|
2696
|
-
a = i.startX + $t(t.marginX, n);
|
|
2697
|
-
if (t.verticalOffsetAlign === "bottom") {
|
|
2698
|
-
const l = $t(t.marginY, r * e);
|
|
2699
|
-
c = i.endY - l - o;
|
|
2700
|
-
} else
|
|
2701
|
-
c = i.startY + $t(t.marginY, r);
|
|
2702
|
-
}
|
|
2703
|
-
return {
|
|
2704
|
-
rotate: 0,
|
|
2705
|
-
startX: a,
|
|
2706
|
-
startY: c,
|
|
2707
|
-
endX: i.endX,
|
|
2708
|
-
endY: i.endY,
|
|
2709
|
-
width: s,
|
|
2710
|
-
height: o,
|
|
2711
|
-
absolute: {
|
|
2712
|
-
left: i.absolute.left,
|
|
2713
|
-
top: i.absolute.top
|
|
2714
|
-
}
|
|
2715
|
-
};
|
|
2716
|
-
}
|
|
2717
|
-
function $t(i, t) {
|
|
2718
|
-
if (i === void 0) return 0;
|
|
2719
|
-
if (typeof i == "number") return i;
|
|
2720
|
-
const e = Number.parseFloat(i);
|
|
2721
|
-
return t * e / 100;
|
|
2722
|
-
}
|
|
2723
|
-
const uo = (i) => {
|
|
2724
|
-
const { floatDomInfos: t, scene: e, skeleton: n, worksheet: r } = i, s = Ke(() => t.map((o) => {
|
|
2725
|
-
const { width: a, height: c, angle: u, left: d, top: l } = o.transform, g = Kr(
|
|
2726
|
-
{
|
|
2727
|
-
left: d != null ? d : 0,
|
|
2728
|
-
right: (d != null ? d : 0) + (a != null ? a : 0),
|
|
2729
|
-
top: l != null ? l : 0,
|
|
2730
|
-
bottom: (l != null ? l : 0) + (c != null ? c : 0)
|
|
2731
|
-
},
|
|
2732
|
-
e,
|
|
2733
|
-
n,
|
|
2734
|
-
r,
|
|
2735
|
-
void 0,
|
|
2736
|
-
!0
|
|
2737
|
-
), { scaleX: h, scaleY: f } = e.getAncestorScale(), m = {
|
|
2738
|
-
startX: g.left,
|
|
2739
|
-
endX: g.right,
|
|
2740
|
-
startY: g.top,
|
|
2741
|
-
endY: g.bottom,
|
|
2742
|
-
rotate: u,
|
|
2743
|
-
width: a * h,
|
|
2744
|
-
height: c * f,
|
|
2745
|
-
absolute: g.absolute
|
|
2746
|
-
}, p = {
|
|
2747
|
-
position$: new ze(m),
|
|
2748
|
-
position: m,
|
|
2749
|
-
id: o.drawingId,
|
|
2750
|
-
componentKey: o.componentKey,
|
|
2751
|
-
onPointerMove: () => {
|
|
2752
|
-
},
|
|
2753
|
-
onPointerDown: () => {
|
|
2754
|
-
},
|
|
2755
|
-
onPointerUp: () => {
|
|
2756
|
-
},
|
|
2757
|
-
onWheel: () => {
|
|
2758
|
-
},
|
|
2759
|
-
unitId: o.unitId,
|
|
2760
|
-
data: o.data
|
|
2761
|
-
};
|
|
2762
|
-
return [o.drawingId, p];
|
|
2763
|
-
}), [t, e, n, r]);
|
|
2764
|
-
return /* @__PURE__ */ X("div", { style: { position: "absolute", top: 0, left: 0 }, children: s.map(([o, a]) => /* @__PURE__ */ X(gs, { layer: a, id: o, position: a.position }, o)) });
|
|
2765
|
-
};
|
|
2766
|
-
var ho = Object.getOwnPropertyDescriptor, go = (i, t, e, n) => {
|
|
2767
|
-
for (var r = n > 1 ? void 0 : n ? ho(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
2768
|
-
(o = i[s]) && (r = o(r) || r);
|
|
2769
|
-
return r;
|
|
2770
|
-
}, Ne = (i, t) => (e, n) => t(e, n, i);
|
|
2771
|
-
let Gt = class extends re {
|
|
2772
|
-
constructor(i, t, e, n, r, s, o) {
|
|
2773
|
-
super(), this._sheetPrintInterceptorService = i, this._drawingRenderService = t, this._drawingManagerService = e, this._renderManagerService = n, this._canvasFloatDomManagerService = r, this._componetManager = s, this._injector = o, this._initPrinting(), this._initPrintingDom();
|
|
2774
|
-
}
|
|
2775
|
-
_initPrinting() {
|
|
2776
|
-
this.disposeWithMe(
|
|
2777
|
-
this._sheetPrintInterceptorService.interceptor.intercept(
|
|
2778
|
-
this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,
|
|
2779
|
-
{
|
|
2780
|
-
handler: (i, t, e) => {
|
|
2781
|
-
const { unitId: n, scene: r, subUnitId: s } = t, o = this._drawingManagerService.getDrawingDataForUnit(n), a = o == null ? void 0 : o[s];
|
|
2782
|
-
return a && a.order.forEach((c) => {
|
|
2783
|
-
const u = a.data[c];
|
|
2784
|
-
u.drawingType !== B.DRAWING_CHART && u.drawingType !== B.DRAWING_DOM && this._drawingRenderService.renderDrawing(u, r);
|
|
2785
|
-
}), e();
|
|
2786
|
-
}
|
|
2787
|
-
}
|
|
2788
|
-
)
|
|
2789
|
-
), this.disposeWithMe(
|
|
2790
|
-
this._sheetPrintInterceptorService.interceptor.intercept(
|
|
2791
|
-
this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,
|
|
2792
|
-
{
|
|
2793
|
-
handler: (i, t, e) => {
|
|
2794
|
-
const { unitId: n, subUnitId: r } = t, s = this._renderManagerService.getRenderById(n);
|
|
2795
|
-
if (!s)
|
|
2796
|
-
return e(i);
|
|
2797
|
-
const o = s.with(Z).getSkeletonParam(r);
|
|
2798
|
-
if (!o)
|
|
2799
|
-
return e(i);
|
|
2800
|
-
const a = this._drawingManagerService.getDrawingDataForUnit(n), c = a == null ? void 0 : a[t.subUnitId];
|
|
2801
|
-
if (!c)
|
|
2802
|
-
return e(i);
|
|
2803
|
-
const { scaleX: u, scaleY: d } = s.scene, l = i ? { ...i } : { startColumn: 0, endColumn: 0, endRow: 0, startRow: 0 }, g = c.order.map((h) => c.data[h]);
|
|
2804
|
-
return g.length ? (g.forEach((h) => {
|
|
2805
|
-
if (!h.groupId && h.transform && Qe.isDefine(h.transform.left) && Qe.isDefine(h.transform.top) && Qe.isDefine(h.transform.width) && Qe.isDefine(h.transform.height)) {
|
|
2806
|
-
const f = o.skeleton.getCellIndexByOffset(h.transform.left, h.transform.top, u, d, { x: 0, y: 0 }), m = o.skeleton.getCellIndexByOffset(h.transform.left + h.transform.width, h.transform.top + h.transform.height, u, d, { x: 0, y: 0 });
|
|
2807
|
-
f.column < l.startColumn && (l.startColumn = f.column), f.row < l.startRow && (l.startRow = f.row), l.endRow < m.row && (l.endRow = m.row), l.endColumn < m.column && (l.endColumn = m.column);
|
|
2808
|
-
}
|
|
2809
|
-
}), e(l)) : e(i);
|
|
2810
|
-
}
|
|
2811
|
-
}
|
|
2812
|
-
)
|
|
2813
|
-
);
|
|
2814
|
-
}
|
|
2815
|
-
_initPrintingDom() {
|
|
2816
|
-
this.disposeWithMe(
|
|
2817
|
-
this._sheetPrintInterceptorService.interceptor.intercept(
|
|
2818
|
-
this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_DOM_COLLECT,
|
|
2819
|
-
{
|
|
2820
|
-
handler: (i, t, e) => {
|
|
2821
|
-
const { unitId: n, subUnitId: r } = t, s = this._drawingManagerService.getDrawingDataForUnit(n), o = s == null ? void 0 : s[r];
|
|
2822
|
-
if (o) {
|
|
2823
|
-
const a = o.order.map((u) => {
|
|
2824
|
-
const d = o.data[u];
|
|
2825
|
-
if (d.drawingType === B.DRAWING_CHART)
|
|
2826
|
-
return {
|
|
2827
|
-
...d,
|
|
2828
|
-
componentKey: this._componetManager.get(Di)
|
|
2829
|
-
};
|
|
2830
|
-
if (d.drawingType === B.DRAWING_DOM) {
|
|
2831
|
-
const l = this._sheetPrintInterceptorService.getPrintComponent(d.componentKey);
|
|
2832
|
-
return {
|
|
2833
|
-
...d,
|
|
2834
|
-
componentKey: this._componetManager.get(l || d.componentKey)
|
|
2835
|
-
};
|
|
2836
|
-
}
|
|
2837
|
-
return null;
|
|
2838
|
-
}).filter(Boolean), c = fs(uo, this._injector);
|
|
2839
|
-
return qi(
|
|
2840
|
-
/* @__PURE__ */ X(c, { floatDomInfos: a, scene: t.scene, skeleton: t.skeleton, worksheet: t.worksheet }),
|
|
2841
|
-
t.root
|
|
2842
|
-
), i == null || i.add(() => {
|
|
2843
|
-
Qi(t.root);
|
|
2844
|
-
}), e(i);
|
|
2845
|
-
}
|
|
2846
|
-
}
|
|
2847
|
-
}
|
|
2848
|
-
)
|
|
2849
|
-
);
|
|
2850
|
-
}
|
|
2851
|
-
};
|
|
2852
|
-
Gt = go([
|
|
2853
|
-
Ne(0, N(hi)),
|
|
2854
|
-
Ne(1, N(kr)),
|
|
2855
|
-
Ne(2, de),
|
|
2856
|
-
Ne(3, ee),
|
|
2857
|
-
Ne(4, N(wt)),
|
|
2858
|
-
Ne(5, N(xr)),
|
|
2859
|
-
Ne(6, N(st))
|
|
2860
|
-
], Gt);
|
|
2861
|
-
var fo = Object.getOwnPropertyDescriptor, mo = (i, t, e, n) => {
|
|
2862
|
-
for (var r = n > 1 ? void 0 : n ? fo(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
2863
|
-
(o = i[s]) && (r = o(r) || r);
|
|
2864
|
-
return r;
|
|
2865
|
-
}, be = (i, t) => (e, n) => t(e, n, i);
|
|
2866
|
-
const po = [
|
|
2867
|
-
wr.id,
|
|
2868
|
-
Sr.id,
|
|
2869
|
-
_r.id,
|
|
2870
|
-
vr.id,
|
|
2871
|
-
Ir.id,
|
|
2872
|
-
Cr.id,
|
|
2873
|
-
Rr.id,
|
|
2874
|
-
Dr.id,
|
|
2875
|
-
Sn.id,
|
|
2876
|
-
_n.id,
|
|
2877
|
-
br.id,
|
|
2878
|
-
Mr.id,
|
|
2879
|
-
yr.id,
|
|
2880
|
-
Tr.id,
|
|
2881
|
-
Er.id,
|
|
2882
|
-
Or.id,
|
|
2883
|
-
Ur.id,
|
|
2884
|
-
Pr.id,
|
|
2885
|
-
Ar.id
|
|
2886
|
-
], wo = [
|
|
2887
|
-
Vi.id,
|
|
2888
|
-
Gi.id,
|
|
2889
|
-
Yi.id,
|
|
2890
|
-
Xi.id,
|
|
2891
|
-
zi.id,
|
|
2892
|
-
pr.id,
|
|
2893
|
-
Ki.id,
|
|
2894
|
-
Ji.id
|
|
2895
|
-
];
|
|
2896
|
-
let Mn = class extends re {
|
|
2897
|
-
constructor(i, t, e, n, r, s, o, a, c) {
|
|
2898
|
-
super(), this._context = i, this._renderManagerService = t, this._commandService = e, this._selectionRenderService = n, this._skeletonManagerService = r, this._sheetInterceptorService = s, this._sheetDrawingService = o, this._drawingManagerService = a, this._univerInstanceService = c, this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener();
|
|
2899
|
-
}
|
|
2900
|
-
_sheetInterceptorListener() {
|
|
2901
|
-
this.disposeWithMe(
|
|
2902
|
-
this._sheetInterceptorService.interceptAfterCommand({
|
|
2903
|
-
/* eslint-disable-next-line complexity */
|
|
2904
|
-
getMutations: (i) => {
|
|
2905
|
-
if (!po.includes(i.id))
|
|
2906
|
-
return { redos: [], undos: [] };
|
|
2907
|
-
if (i.params == null)
|
|
2908
|
-
return { redos: [], undos: [] };
|
|
2909
|
-
const t = i.id;
|
|
2910
|
-
if (t === wr.id)
|
|
2911
|
-
return this._moveRowInterceptor(i.params, "insert");
|
|
2912
|
-
if ([Ur.id, Pr.id, Ar.id].includes(t))
|
|
2913
|
-
return this._moveRangeInterceptor(i.params);
|
|
2914
|
-
if (t === Sr.id)
|
|
2915
|
-
return this._moveColInterceptor(i.params, "insert");
|
|
2916
|
-
if (t === _r.id)
|
|
2917
|
-
return this._moveRowInterceptor(i.params, "remove");
|
|
2918
|
-
if (t === vr.id)
|
|
2919
|
-
return this._moveColInterceptor(i.params, "remove");
|
|
2920
|
-
if (t === Ir.id) {
|
|
2921
|
-
const { range: e } = i.params;
|
|
2922
|
-
return this._getRangeMoveUndo(
|
|
2923
|
-
e,
|
|
2924
|
-
0
|
|
2925
|
-
/* deleteLeft */
|
|
2926
|
-
);
|
|
2927
|
-
} else if (t === Cr.id) {
|
|
2928
|
-
const { range: e } = i.params;
|
|
2929
|
-
return this._getRangeMoveUndo(
|
|
2930
|
-
e,
|
|
2931
|
-
1
|
|
2932
|
-
/* deleteUp */
|
|
2933
|
-
);
|
|
2934
|
-
} else if (t === Rr.id) {
|
|
2935
|
-
const { range: e } = i.params;
|
|
2936
|
-
return this._getRangeMoveUndo(
|
|
2937
|
-
e,
|
|
2938
|
-
2
|
|
2939
|
-
/* insertDown */
|
|
2940
|
-
);
|
|
2941
|
-
} else if (t === Dr.id) {
|
|
2942
|
-
const { range: e } = i.params;
|
|
2943
|
-
return this._getRangeMoveUndo(
|
|
2944
|
-
e,
|
|
2945
|
-
3
|
|
2946
|
-
/* insertRight */
|
|
2947
|
-
);
|
|
2948
|
-
} else if (t === yr.id || t === Tr.id) {
|
|
2949
|
-
const e = i.params, { unitId: n, subUnitId: r, ranges: s } = e;
|
|
2950
|
-
return this._getDrawingUndoForRowVisible(n, r, s);
|
|
2951
|
-
} else if (t === Er.id || t === Or.id) {
|
|
2952
|
-
const e = i.params, { unitId: n, subUnitId: r, ranges: s } = e;
|
|
2953
|
-
return this._getDrawingUndoForColVisible(n, r, s);
|
|
2954
|
-
} else if (t === Sn.id || t === _n.id || t === br.id || t === Mr.id) {
|
|
2955
|
-
const e = i.params, { unitId: n, subUnitId: r, ranges: s } = e, o = t === Sn.id || t === _n.id;
|
|
2956
|
-
return this._getDrawingUndoForRowAndColSize(n, r, s, o);
|
|
2957
|
-
}
|
|
2958
|
-
return { redos: [], undos: [] };
|
|
2959
|
-
}
|
|
2960
|
-
})
|
|
2961
|
-
);
|
|
2962
|
-
}
|
|
2963
|
-
_getRangeMoveUndo(i, t) {
|
|
2964
|
-
const e = ce(this._univerInstanceService);
|
|
2965
|
-
if (e == null)
|
|
2966
|
-
return { redos: [], undos: [] };
|
|
2967
|
-
const n = e.unitId, r = e.subUnitId, s = [], o = [], a = this._sheetDrawingService.getDrawingData(n, r), c = [], u = [];
|
|
2968
|
-
if (Object.keys(a).forEach((d) => {
|
|
2969
|
-
const l = a[d], { updateDrawings: g, deleteDrawings: h } = this._getUpdateOrDeleteDrawings(i, t, l);
|
|
2970
|
-
c.push(...g), u.push(...h);
|
|
2971
|
-
}), c.length === 0 && u.length === 0)
|
|
2972
|
-
return { redos: [], undos: [] };
|
|
2973
|
-
if (c.length > 0) {
|
|
2974
|
-
const d = this._sheetDrawingService.getBatchUpdateOp(c), { undo: l, redo: g, objects: h } = d;
|
|
2975
|
-
s.push({ id: A.id, params: { unitId: n, subUnitId: r, op: g, objects: h, type: P.UPDATE } }), o.push({ id: A.id, params: { unitId: n, subUnitId: r, op: l, objects: h, type: P.UPDATE } });
|
|
2976
|
-
}
|
|
2977
|
-
if (u.length > 0) {
|
|
2978
|
-
const d = this._sheetDrawingService.getBatchRemoveOp(u), l = d.undo, g = d.redo, h = d.objects;
|
|
2979
|
-
s.push({ id: A.id, params: { unitId: n, subUnitId: r, op: g, objects: h, type: P.REMOVE } }), o.push({ id: A.id, params: { unitId: n, subUnitId: r, op: l, objects: h, type: P.INSERT } });
|
|
2980
|
-
}
|
|
2981
|
-
return s.push({ id: L.id, params: [n] }), o.push({ id: L.id, params: [n] }), {
|
|
2982
|
-
redos: s,
|
|
2983
|
-
undos: o
|
|
2984
|
-
};
|
|
2985
|
-
}
|
|
2986
|
-
_getUpdateOrDeleteDrawings(i, t, e) {
|
|
2987
|
-
var D, T, b, E;
|
|
2988
|
-
const n = [], r = [], { sheetTransform: s, anchorType: o = U.Position, transform: a, unitId: c, subUnitId: u, drawingId: d } = e, { from: l, to: g } = s, { row: h, column: f } = l, { row: m, column: p } = g;
|
|
2989
|
-
if (s == null || a == null)
|
|
2990
|
-
return {
|
|
2991
|
-
updateDrawings: n,
|
|
2992
|
-
deleteDrawings: r
|
|
2993
|
-
};
|
|
2994
|
-
const { startRow: S, endRow: _, startColumn: R, endColumn: M } = i;
|
|
2995
|
-
let I = null, v = null, C;
|
|
2996
|
-
if (t === 0 && h >= S && m <= _)
|
|
2997
|
-
if (f >= R && p <= M)
|
|
2998
|
-
r.push({ unitId: c, subUnitId: u, drawingId: d });
|
|
2999
|
-
else {
|
|
3000
|
-
const w = this._shrinkCol(s, a, R, M, o);
|
|
3001
|
-
I = w == null ? void 0 : w.newSheetTransform, v = w == null ? void 0 : w.newTransform, C = (D = w == null ? void 0 : w.axisAlignSheetTransform) != null ? D : void 0;
|
|
3002
|
-
}
|
|
3003
|
-
else if (t === 1 && f >= R && p <= M)
|
|
3004
|
-
if (h >= S && m <= _)
|
|
3005
|
-
r.push({ unitId: c, subUnitId: u, drawingId: d });
|
|
3006
|
-
else {
|
|
3007
|
-
const w = this._shrinkRow(s, a, S, _, o);
|
|
3008
|
-
I = w == null ? void 0 : w.newSheetTransform, v = w == null ? void 0 : w.newTransform, C = (T = w == null ? void 0 : w.axisAlignSheetTransform) != null ? T : void 0;
|
|
3009
|
-
}
|
|
3010
|
-
else if (t === 2) {
|
|
3011
|
-
const w = this._expandRow(s, a, S, _, o);
|
|
3012
|
-
I = w == null ? void 0 : w.newSheetTransform, v = w == null ? void 0 : w.newTransform, C = (b = w == null ? void 0 : w.axisAlignSheetTransform) != null ? b : void 0;
|
|
3013
|
-
} else if (t === 3) {
|
|
3014
|
-
const w = this._expandCol(s, a, R, M, o);
|
|
3015
|
-
I = w == null ? void 0 : w.newSheetTransform, v = w == null ? void 0 : w.newTransform, C = (E = w == null ? void 0 : w.axisAlignSheetTransform) != null ? E : void 0;
|
|
3016
|
-
}
|
|
3017
|
-
if (I != null && v != null) {
|
|
3018
|
-
const w = Q(I, this._selectionRenderService, this._skeletonManagerService);
|
|
3019
|
-
n.push({ ...e, sheetTransform: I, transform: w, axisAlignSheetTransform: C });
|
|
3020
|
-
}
|
|
3021
|
-
return { updateDrawings: n, deleteDrawings: r };
|
|
3022
|
-
}
|
|
3023
|
-
_remainDrawingSize(i, t, e) {
|
|
3024
|
-
const n = j({ ...i }, this._selectionRenderService);
|
|
3025
|
-
if (n != null) {
|
|
3026
|
-
const r = F({ ...i }, this._selectionRenderService);
|
|
3027
|
-
t.push({
|
|
3028
|
-
...e,
|
|
3029
|
-
sheetTransform: n,
|
|
3030
|
-
axisAlignSheetTransform: r
|
|
3031
|
-
});
|
|
3032
|
-
}
|
|
3033
|
-
}
|
|
3034
|
-
// eslint-disable-next-line max-lines-per-function
|
|
3035
|
-
_getDrawingUndoForColVisible(i, t, e) {
|
|
3036
|
-
const n = this._drawingManagerService.getDrawingData(i, t), r = [], s = [];
|
|
3037
|
-
if (Object.keys(n).forEach((d) => {
|
|
3038
|
-
const l = n[d], { sheetTransform: g, transform: h, anchorType: f = U.Position } = l;
|
|
3039
|
-
if (f === U.None)
|
|
3040
|
-
this._remainDrawingSize(h, r, l);
|
|
3041
|
-
else {
|
|
3042
|
-
const { from: m, to: p } = g, { row: S, column: _ } = m, { row: R, column: M } = p;
|
|
3043
|
-
for (let I = 0; I < e.length; I++) {
|
|
3044
|
-
const v = e[I], { startRow: C, endRow: D, startColumn: T, endColumn: b } = v;
|
|
3045
|
-
if (M < T)
|
|
3046
|
-
continue;
|
|
3047
|
-
if (f === U.Position) {
|
|
3048
|
-
let y = null, O = null;
|
|
3049
|
-
if (_ >= T && _ <= b) {
|
|
3050
|
-
const x = this._skeletonManagerService.attachRangeWithCoord({ startColumn: _, endColumn: b, startRow: m.row, endRow: p.row });
|
|
3051
|
-
if (x == null)
|
|
3052
|
-
return;
|
|
3053
|
-
O = { ...h, left: x.startX };
|
|
3054
|
-
}
|
|
3055
|
-
if (O != null) {
|
|
3056
|
-
y = j(O, this._selectionRenderService);
|
|
3057
|
-
const x = F(O, this._selectionRenderService);
|
|
3058
|
-
if (y != null && O != null) {
|
|
3059
|
-
r.push({ ...l, sheetTransform: y, transform: O, axisAlignSheetTransform: x });
|
|
3060
|
-
break;
|
|
3061
|
-
}
|
|
3062
|
-
}
|
|
3063
|
-
this._remainDrawingSize(h, r, l);
|
|
3064
|
-
continue;
|
|
3065
|
-
}
|
|
3066
|
-
if (_ >= T && M <= b)
|
|
3067
|
-
continue;
|
|
3068
|
-
let E = null, w = null;
|
|
3069
|
-
if (_ >= T && _ <= b) {
|
|
3070
|
-
const y = this._skeletonManagerService.attachRangeWithCoord({ startColumn: _, endColumn: b, startRow: m.row, endRow: p.row });
|
|
3071
|
-
if (y == null)
|
|
3072
|
-
return;
|
|
3073
|
-
w = {
|
|
3074
|
-
...h,
|
|
3075
|
-
left: (y == null ? void 0 : y.startX) || 0,
|
|
3076
|
-
width: ((h == null ? void 0 : h.width) || 0) - y.endX + y.startX
|
|
3077
|
-
};
|
|
3078
|
-
} else if (M >= T && M <= b) {
|
|
3079
|
-
const y = this._skeletonManagerService.attachRangeWithCoord({ startColumn: T, endColumn: M, startRow: m.row, endRow: p.row });
|
|
3080
|
-
if (y == null)
|
|
3081
|
-
return;
|
|
3082
|
-
w = {
|
|
3083
|
-
...h,
|
|
3084
|
-
left: y.startX - ((h == null ? void 0 : h.width) || 0)
|
|
3085
|
-
};
|
|
3086
|
-
} else {
|
|
3087
|
-
const y = this._skeletonManagerService.attachRangeWithCoord({ startColumn: T, endColumn: b, startRow: m.row, endRow: p.row });
|
|
3088
|
-
if (y == null)
|
|
3089
|
-
return;
|
|
3090
|
-
if (w = {
|
|
3091
|
-
...h,
|
|
3092
|
-
width: ((h == null ? void 0 : h.width) || 0) - y.endX + y.startX
|
|
3093
|
-
}, E = j(w, this._selectionRenderService), E != null && w != null) {
|
|
3094
|
-
const O = F(w, this._selectionRenderService);
|
|
3095
|
-
s.push({ ...l, sheetTransform: E, transform: w, axisAlignSheetTransform: O });
|
|
3096
|
-
break;
|
|
3097
|
-
}
|
|
3098
|
-
}
|
|
3099
|
-
if (w != null && (E = j(w, this._selectionRenderService)), w != null && E != null) {
|
|
3100
|
-
const y = F(w, this._selectionRenderService);
|
|
3101
|
-
r.push({ ...l, sheetTransform: E, transform: w, axisAlignSheetTransform: y });
|
|
3102
|
-
break;
|
|
3103
|
-
} else
|
|
3104
|
-
this._remainDrawingSize(h, r, l);
|
|
3105
|
-
}
|
|
3106
|
-
}
|
|
3107
|
-
}), r.length === 0 && s.length === 0)
|
|
3108
|
-
return { redos: [], undos: [] };
|
|
3109
|
-
const { redos: o, undos: a } = this._createUndoAndRedoMutation(i, t, r), c = [], u = [];
|
|
3110
|
-
if (s.length > 0) {
|
|
3111
|
-
const { redos: d, undos: l } = this._createUndoAndRedoMutation(i, t, s);
|
|
3112
|
-
c.push(...d), u.push(...l);
|
|
3113
|
-
}
|
|
3114
|
-
return {
|
|
3115
|
-
redos: o,
|
|
3116
|
-
undos: a,
|
|
3117
|
-
preRedos: c,
|
|
3118
|
-
preUndos: u
|
|
3119
|
-
};
|
|
3120
|
-
}
|
|
3121
|
-
_createUndoAndRedoMutation(i, t, e) {
|
|
3122
|
-
const n = this._sheetDrawingService.getBatchUpdateOp(e), { undo: r, redo: s, objects: o } = n, a = [
|
|
3123
|
-
{ id: A.id, params: { unitId: i, subUnitId: t, op: s, objects: o, type: P.UPDATE } },
|
|
3124
|
-
{ id: L.id, params: [i] }
|
|
3125
|
-
], c = [
|
|
3126
|
-
{ id: A.id, params: { unitId: i, subUnitId: t, op: r, objects: o, type: P.UPDATE } },
|
|
3127
|
-
{ id: L.id, params: [i] }
|
|
3128
|
-
];
|
|
3129
|
-
return {
|
|
3130
|
-
redos: a,
|
|
3131
|
-
undos: c
|
|
3132
|
-
};
|
|
3133
|
-
}
|
|
3134
|
-
// eslint-disable-next-line max-lines-per-function
|
|
3135
|
-
_getDrawingUndoForRowVisible(i, t, e) {
|
|
3136
|
-
const n = this._drawingManagerService.getDrawingData(i, t), r = [], s = [];
|
|
3137
|
-
if (Object.keys(n).forEach((d) => {
|
|
3138
|
-
const l = n[d], { sheetTransform: g, transform: h, anchorType: f = U.Position } = l;
|
|
3139
|
-
if (f === U.None)
|
|
3140
|
-
this._remainDrawingSize(h, r, l);
|
|
3141
|
-
else {
|
|
3142
|
-
const { from: m, to: p } = g, { row: S, column: _ } = m, { row: R, column: M } = p;
|
|
3143
|
-
for (let I = 0; I < e.length; I++) {
|
|
3144
|
-
const v = e[I], { startRow: C, endRow: D, startColumn: T, endColumn: b } = v;
|
|
3145
|
-
if (R < C)
|
|
3146
|
-
continue;
|
|
3147
|
-
if (f === U.Position) {
|
|
3148
|
-
let y = null, O = null;
|
|
3149
|
-
if (S >= C && S <= D) {
|
|
3150
|
-
const x = this._skeletonManagerService.attachRangeWithCoord({ startColumn: m.column, endColumn: p.column, startRow: S, endRow: D });
|
|
3151
|
-
if (x == null)
|
|
3152
|
-
return;
|
|
3153
|
-
O = { ...h, top: x.startY };
|
|
3154
|
-
}
|
|
3155
|
-
if (O != null) {
|
|
3156
|
-
y = j(O, this._selectionRenderService);
|
|
3157
|
-
const x = F(O, this._selectionRenderService);
|
|
3158
|
-
if (y != null && O != null) {
|
|
3159
|
-
r.push({ ...l, sheetTransform: y, transform: O, axisAlignSheetTransform: x });
|
|
3160
|
-
break;
|
|
3161
|
-
}
|
|
3162
|
-
}
|
|
3163
|
-
this._remainDrawingSize(h, r, l);
|
|
3164
|
-
continue;
|
|
3165
|
-
}
|
|
3166
|
-
if (S >= C && R <= D)
|
|
3167
|
-
continue;
|
|
3168
|
-
let E = null, w = null;
|
|
3169
|
-
if (S >= C && S <= D) {
|
|
3170
|
-
const y = this._skeletonManagerService.attachRangeWithCoord({ startColumn: m.column, endColumn: p.column, startRow: S, endRow: D });
|
|
3171
|
-
if (y == null)
|
|
3172
|
-
return;
|
|
3173
|
-
w = {
|
|
3174
|
-
...h,
|
|
3175
|
-
top: (y == null ? void 0 : y.startY) || 0,
|
|
3176
|
-
height: ((h == null ? void 0 : h.height) || 0) - y.endY + y.startY
|
|
3177
|
-
};
|
|
3178
|
-
} else if (R >= C && R <= D) {
|
|
3179
|
-
const y = this._skeletonManagerService.attachRangeWithCoord({ startColumn: m.column, endColumn: p.column, startRow: C, endRow: R });
|
|
3180
|
-
if (y == null)
|
|
3181
|
-
return;
|
|
3182
|
-
w = {
|
|
3183
|
-
...h,
|
|
3184
|
-
top: y.startY - ((h == null ? void 0 : h.height) || 0)
|
|
3185
|
-
};
|
|
3186
|
-
} else {
|
|
3187
|
-
const y = this._skeletonManagerService.attachRangeWithCoord({ startColumn: m.column, endColumn: p.column, startRow: C, endRow: D });
|
|
3188
|
-
if (y == null)
|
|
3189
|
-
return;
|
|
3190
|
-
if (w = {
|
|
3191
|
-
...h,
|
|
3192
|
-
height: ((h == null ? void 0 : h.height) || 0) - y.endY + y.startY
|
|
3193
|
-
}, E = j(w, this._selectionRenderService), E != null && w != null) {
|
|
3194
|
-
const O = F(w, this._selectionRenderService);
|
|
3195
|
-
s.push({ ...l, sheetTransform: E, transform: w, axisAlignSheetTransform: O });
|
|
3196
|
-
break;
|
|
3197
|
-
}
|
|
3198
|
-
}
|
|
3199
|
-
if (w != null && (E = j(w, this._selectionRenderService)), w != null && E != null) {
|
|
3200
|
-
const y = F(w, this._selectionRenderService);
|
|
3201
|
-
r.push({ ...l, sheetTransform: E, transform: w, axisAlignSheetTransform: y });
|
|
3202
|
-
break;
|
|
3203
|
-
} else
|
|
3204
|
-
this._remainDrawingSize(h, r, l);
|
|
3205
|
-
}
|
|
3206
|
-
}
|
|
3207
|
-
}), r.length === 0 && s.length === 0)
|
|
3208
|
-
return { redos: [], undos: [] };
|
|
3209
|
-
const { redos: o, undos: a } = this._createUndoAndRedoMutation(i, t, r), c = [], u = [];
|
|
3210
|
-
if (s.length > 0) {
|
|
3211
|
-
const { redos: d, undos: l } = this._createUndoAndRedoMutation(i, t, s);
|
|
3212
|
-
c.push(...d), u.push(...l);
|
|
3213
|
-
}
|
|
3214
|
-
return {
|
|
3215
|
-
redos: o,
|
|
3216
|
-
undos: a,
|
|
3217
|
-
preRedos: c,
|
|
3218
|
-
preUndos: u
|
|
3219
|
-
};
|
|
3220
|
-
}
|
|
3221
|
-
_getDrawingUndoForRowAndColSize(i, t, e, n) {
|
|
3222
|
-
const r = this._drawingManagerService.getDrawingData(i, t), s = [];
|
|
3223
|
-
return Object.keys(r).forEach((o) => {
|
|
3224
|
-
const a = r[o], { sheetTransform: c, transform: u, anchorType: d = U.Position } = a;
|
|
3225
|
-
if (d === U.None)
|
|
3226
|
-
this._remainDrawingSize(u, s, a);
|
|
3227
|
-
else {
|
|
3228
|
-
const { from: l, to: g } = c, { row: h, column: f } = l, { row: m, column: p } = g;
|
|
3229
|
-
for (let S = 0; S < e.length; S++) {
|
|
3230
|
-
const _ = e[S], { startRow: R, endRow: M, startColumn: I, endColumn: v } = _;
|
|
3231
|
-
if (m < R || p < I)
|
|
3232
|
-
continue;
|
|
3233
|
-
if (d === U.Position && (h <= R && m >= M || f <= I && p >= v)) {
|
|
3234
|
-
this._remainDrawingSize(u, s, a);
|
|
3235
|
-
continue;
|
|
3236
|
-
}
|
|
3237
|
-
const C = Q({ ...c }, this._selectionRenderService, this._skeletonManagerService);
|
|
3238
|
-
if (C != null) {
|
|
3239
|
-
s.push({
|
|
3240
|
-
...a,
|
|
3241
|
-
transform: C
|
|
3242
|
-
});
|
|
3243
|
-
break;
|
|
3244
|
-
}
|
|
3245
|
-
}
|
|
3246
|
-
}
|
|
3247
|
-
}), s.length === 0 ? { redos: [], undos: [] } : this._createUndoAndRedoMutation(i, t, s);
|
|
3248
|
-
}
|
|
3249
|
-
_getUnitIdAndSubUnitId(i, t) {
|
|
3250
|
-
let e, n;
|
|
3251
|
-
if (t === "insert")
|
|
3252
|
-
e = i.unitId, n = i.subUnitId;
|
|
3253
|
-
else {
|
|
3254
|
-
const r = ce(this._univerInstanceService);
|
|
3255
|
-
if (r == null)
|
|
3256
|
-
return;
|
|
3257
|
-
e = r.unitId, n = r.subUnitId;
|
|
3258
|
-
}
|
|
3259
|
-
return { unitId: e, subUnitId: n };
|
|
3260
|
-
}
|
|
3261
|
-
_moveRangeInterceptor(i) {
|
|
3262
|
-
var R, M;
|
|
3263
|
-
const { toRange: t, fromRange: e } = i, n = ce(this._univerInstanceService);
|
|
3264
|
-
if (!n)
|
|
3265
|
-
return { redos: [], undos: [] };
|
|
3266
|
-
const { unitId: r, subUnitId: s } = n, o = (M = (R = this._renderManagerService.getRenderById(r)) == null ? void 0 : R.with(Z)) == null ? void 0 : M.getCurrentSkeleton();
|
|
3267
|
-
if (!o)
|
|
3268
|
-
return { redos: [], undos: [] };
|
|
3269
|
-
const a = hr(o, e);
|
|
3270
|
-
if (!a)
|
|
3271
|
-
return { redos: [], undos: [] };
|
|
3272
|
-
const { startX: c, endX: u, startY: d, endY: l } = a, g = this._sheetDrawingService.getDrawingData(r, s), h = [];
|
|
3273
|
-
Object.keys(g).forEach((I) => {
|
|
3274
|
-
const v = g[I];
|
|
3275
|
-
if (v.anchorType !== U.Both)
|
|
3276
|
-
return;
|
|
3277
|
-
const { transform: C } = v;
|
|
3278
|
-
if (!C)
|
|
3279
|
-
return;
|
|
3280
|
-
const { left: D = 0, top: T = 0, width: b = 0, height: E = 0 } = C, { drawingStartX: w, drawingEndX: y, drawingStartY: O, drawingEndY: x } = {
|
|
3281
|
-
drawingStartX: D,
|
|
3282
|
-
drawingEndX: D + b,
|
|
3283
|
-
drawingStartY: T,
|
|
3284
|
-
drawingEndY: T + E
|
|
3285
|
-
};
|
|
3286
|
-
c <= w && y <= u && d <= O && x <= l && h.push(v);
|
|
3287
|
-
});
|
|
3288
|
-
const f = [], m = [], p = t.startRow - e.startRow, S = t.startColumn - e.startColumn, _ = h.map((I) => {
|
|
3289
|
-
const v = I.sheetTransform, C = {
|
|
3290
|
-
to: { ...v.to, row: v.to.row + p, column: v.to.column + S },
|
|
3291
|
-
from: { ...v.from, row: v.from.row + p, column: v.from.column + S }
|
|
3292
|
-
}, D = Q(C, this._selectionRenderService, this._skeletonManagerService);
|
|
3293
|
-
return {
|
|
3294
|
-
unitId: r,
|
|
3295
|
-
subUnitId: s,
|
|
3296
|
-
drawingId: I.drawingId,
|
|
3297
|
-
transform: D,
|
|
3298
|
-
sheetTransform: C
|
|
3299
|
-
};
|
|
3300
|
-
});
|
|
3301
|
-
if (_.length) {
|
|
3302
|
-
const I = this._sheetDrawingService.getBatchUpdateOp(_), { undo: v, redo: C, objects: D } = I;
|
|
3303
|
-
f.push({ id: A.id, params: { unitId: r, subUnitId: s, op: C, objects: D, type: P.UPDATE } }), m.push({ id: A.id, params: { unitId: r, subUnitId: s, op: v, objects: D, type: P.UPDATE } });
|
|
3304
|
-
}
|
|
3305
|
-
return { redos: f, undos: m };
|
|
3306
|
-
}
|
|
3307
|
-
_moveRowInterceptor(i, t) {
|
|
3308
|
-
const e = this._getUnitIdAndSubUnitId(i, t);
|
|
3309
|
-
if (e == null)
|
|
3310
|
-
return { redos: [], undos: [] };
|
|
3311
|
-
const { unitId: n, subUnitId: r } = e, { range: s } = i, o = s.startRow, a = s.endRow, c = [], u = [], d = this._sheetDrawingService.getDrawingData(n, r), l = [], g = [];
|
|
3312
|
-
if (Object.keys(d).forEach((h) => {
|
|
3313
|
-
var v, C;
|
|
3314
|
-
const f = d[h], { sheetTransform: m, transform: p, anchorType: S = U.Position } = f;
|
|
3315
|
-
if (m == null || p == null)
|
|
3316
|
-
return;
|
|
3317
|
-
let _, R, M;
|
|
3318
|
-
if (t === "insert") {
|
|
3319
|
-
const D = this._expandRow(m, p, o, a, S);
|
|
3320
|
-
_ = D == null ? void 0 : D.newSheetTransform, R = D == null ? void 0 : D.newTransform, M = (v = D == null ? void 0 : D.axisAlignSheetTransform) != null ? v : void 0;
|
|
3321
|
-
} else {
|
|
3322
|
-
const { from: D, to: T } = m, { row: b } = D, { row: E } = T;
|
|
3323
|
-
if (S === U.Both && b >= o && E <= a)
|
|
3324
|
-
g.push({ unitId: n, subUnitId: r, drawingId: h });
|
|
3325
|
-
else {
|
|
3326
|
-
const w = this._shrinkRow(m, p, o, a, S);
|
|
3327
|
-
_ = w == null ? void 0 : w.newSheetTransform, R = w == null ? void 0 : w.newTransform, M = (C = w == null ? void 0 : w.axisAlignSheetTransform) != null ? C : void 0;
|
|
3328
|
-
}
|
|
3329
|
-
}
|
|
3330
|
-
if (!_ || !R)
|
|
3331
|
-
return;
|
|
3332
|
-
const I = { unitId: n, subUnitId: r, drawingId: h, transform: R, sheetTransform: _, axisAlignSheetTransform: M };
|
|
3333
|
-
l.push(I);
|
|
3334
|
-
}), l.length === 0 && g.length === 0)
|
|
3335
|
-
return { redos: [], undos: [] };
|
|
3336
|
-
if (l.length > 0) {
|
|
3337
|
-
const h = this._sheetDrawingService.getBatchUpdateOp(l), { undo: f, redo: m, objects: p } = h;
|
|
3338
|
-
c.push({ id: A.id, params: { unitId: n, subUnitId: r, op: m, objects: p, type: P.UPDATE } }), u.push({ id: A.id, params: { unitId: n, subUnitId: r, op: f, objects: p, type: P.UPDATE } });
|
|
3339
|
-
}
|
|
3340
|
-
if (g.length > 0) {
|
|
3341
|
-
const h = this._sheetDrawingService.getBatchRemoveOp(g), f = h.undo, m = h.redo, p = h.objects;
|
|
3342
|
-
c.push({ id: A.id, params: { unitId: n, subUnitId: r, op: m, objects: p, type: P.REMOVE } }), u.push({ id: A.id, params: { unitId: n, subUnitId: r, op: f, objects: p, type: P.INSERT } });
|
|
3343
|
-
}
|
|
3344
|
-
return c.push({ id: L.id, params: [n] }), u.push({ id: L.id, params: [n] }), {
|
|
3345
|
-
redos: c,
|
|
3346
|
-
undos: u
|
|
3347
|
-
};
|
|
3348
|
-
}
|
|
3349
|
-
_moveColInterceptor(i, t) {
|
|
3350
|
-
const e = this._getUnitIdAndSubUnitId(i, t);
|
|
3351
|
-
if (e == null)
|
|
3352
|
-
return { redos: [], undos: [] };
|
|
3353
|
-
const { unitId: n, subUnitId: r } = e, { range: s } = i, o = s.startColumn, a = s.endColumn, c = [], u = [], d = this._sheetDrawingService.getDrawingData(n, r), l = [], g = [];
|
|
3354
|
-
if (Object.keys(d).forEach((h) => {
|
|
3355
|
-
var v, C;
|
|
3356
|
-
const f = d[h], { sheetTransform: m, transform: p, anchorType: S = U.Position } = f;
|
|
3357
|
-
if (m == null || p == null)
|
|
3358
|
-
return;
|
|
3359
|
-
let _, R, M;
|
|
3360
|
-
if (t === "insert") {
|
|
3361
|
-
const D = this._expandCol(m, p, o, a, S);
|
|
3362
|
-
_ = D == null ? void 0 : D.newSheetTransform, R = D == null ? void 0 : D.newTransform, M = (v = D == null ? void 0 : D.axisAlignSheetTransform) != null ? v : void 0;
|
|
3363
|
-
} else {
|
|
3364
|
-
const { from: D, to: T } = m, { column: b } = D, { column: E } = T;
|
|
3365
|
-
if (S === U.Both && b >= o && E <= a)
|
|
3366
|
-
g.push({ unitId: n, subUnitId: r, drawingId: h });
|
|
3367
|
-
else {
|
|
3368
|
-
const w = this._shrinkCol(m, p, o, a, S);
|
|
3369
|
-
_ = w == null ? void 0 : w.newSheetTransform, R = w == null ? void 0 : w.newTransform, M = (C = w == null ? void 0 : w.axisAlignSheetTransform) != null ? C : void 0;
|
|
3370
|
-
}
|
|
3371
|
-
}
|
|
3372
|
-
if (!_ || !R)
|
|
3373
|
-
return;
|
|
3374
|
-
const I = { unitId: n, subUnitId: r, drawingId: h, transform: R, sheetTransform: _, axisAlignSheetTransform: M };
|
|
3375
|
-
l.push(I);
|
|
3376
|
-
}), l.length === 0 && g.length === 0)
|
|
3377
|
-
return { redos: [], undos: [] };
|
|
3378
|
-
if (l.length > 0) {
|
|
3379
|
-
const h = this._sheetDrawingService.getBatchUpdateOp(l), { undo: f, redo: m, objects: p } = h;
|
|
3380
|
-
c.push({ id: A.id, params: { unitId: n, subUnitId: r, op: m, objects: p, type: P.UPDATE } }), u.push({ id: A.id, params: { unitId: n, subUnitId: r, op: f, objects: p, type: P.UPDATE } });
|
|
3381
|
-
}
|
|
3382
|
-
if (g.length > 0) {
|
|
3383
|
-
const h = this._sheetDrawingService.getBatchRemoveOp(g), f = h.undo, m = h.redo, p = h.objects;
|
|
3384
|
-
c.push({ id: A.id, params: { unitId: n, subUnitId: r, op: m, objects: p, type: P.REMOVE } }), u.push({ id: A.id, params: { unitId: n, subUnitId: r, op: f, objects: p, type: P.INSERT } });
|
|
3385
|
-
}
|
|
3386
|
-
return c.push({ id: L.id, params: [n] }), u.push({ id: L.id, params: [n] }), { redos: c, undos: u };
|
|
3387
|
-
}
|
|
3388
|
-
_expandCol(i, t, e, n, r = U.Position) {
|
|
3389
|
-
const s = n - e + 1, { from: o, to: a } = i, { column: c } = o, { column: u } = a;
|
|
3390
|
-
if (r === U.None)
|
|
3391
|
-
return {
|
|
3392
|
-
newSheetTransform: j({ ...t }, this._selectionRenderService),
|
|
3393
|
-
newTransform: t,
|
|
3394
|
-
axisAlignSheetTransform: F({ ...t }, this._selectionRenderService)
|
|
3395
|
-
};
|
|
3396
|
-
let d = null, l = null, g = null;
|
|
3397
|
-
if (c >= e) {
|
|
3398
|
-
const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: e, endColumn: n, startRow: o.row, endRow: a.row });
|
|
3399
|
-
if (h == null)
|
|
3400
|
-
return;
|
|
3401
|
-
l = { ...t, left: (t.left || 0) + h.endX - h.startX }, d = j(l, this._selectionRenderService), g = F(l, this._selectionRenderService);
|
|
3402
|
-
} else if (u >= n)
|
|
3403
|
-
if (r === U.Both)
|
|
3404
|
-
d = {
|
|
3405
|
-
from: { ...o },
|
|
3406
|
-
to: { ...a, column: u + s }
|
|
3407
|
-
}, l = Q(d, this._selectionRenderService, this._skeletonManagerService);
|
|
3408
|
-
else
|
|
3409
|
-
return {
|
|
3410
|
-
newSheetTransform: j({ ...t }, this._selectionRenderService),
|
|
3411
|
-
newTransform: t,
|
|
3412
|
-
axisAlignSheetTransform: F({ ...t }, this._selectionRenderService)
|
|
3413
|
-
};
|
|
3414
|
-
return d != null && l != null ? {
|
|
3415
|
-
newSheetTransform: d,
|
|
3416
|
-
newTransform: l,
|
|
3417
|
-
axisAlignSheetTransform: g
|
|
3418
|
-
} : null;
|
|
3419
|
-
}
|
|
3420
|
-
_shrinkCol(i, t, e, n, r = U.Position) {
|
|
3421
|
-
const s = n - e + 1, { from: o, to: a } = i, { column: c } = o, { column: u } = a;
|
|
3422
|
-
if (r === U.None)
|
|
3423
|
-
return {
|
|
3424
|
-
newSheetTransform: j({ ...t }, this._selectionRenderService),
|
|
3425
|
-
newTransform: t,
|
|
3426
|
-
axisAlignSheetTransform: F({ ...t }, this._selectionRenderService)
|
|
3427
|
-
};
|
|
3428
|
-
let d = null, l = null, g = null;
|
|
3429
|
-
if (c > n)
|
|
3430
|
-
d = {
|
|
3431
|
-
from: { ...o, column: c - s },
|
|
3432
|
-
to: { ...a, column: u - s }
|
|
3433
|
-
}, l = Q(d, this._selectionRenderService, this._skeletonManagerService);
|
|
3434
|
-
else {
|
|
3435
|
-
if (c >= e && u <= n)
|
|
3436
|
-
return null;
|
|
3437
|
-
if (c < e && u > n)
|
|
3438
|
-
if (r === U.Both)
|
|
3439
|
-
d = {
|
|
3440
|
-
from: { ...o },
|
|
3441
|
-
to: { ...a, column: u - s }
|
|
3442
|
-
}, l = Q(d, this._selectionRenderService, this._skeletonManagerService);
|
|
3443
|
-
else
|
|
3444
|
-
return {
|
|
3445
|
-
newSheetTransform: j({ ...t }, this._selectionRenderService),
|
|
3446
|
-
newTransform: t,
|
|
3447
|
-
axisAlignSheetTransform: F({ ...t }, this._selectionRenderService)
|
|
3448
|
-
};
|
|
3449
|
-
else if (c >= e && c <= n) {
|
|
3450
|
-
if (c === e)
|
|
3451
|
-
l = { ...t, left: (t.left || 0) - i.from.columnOffset };
|
|
3452
|
-
else {
|
|
3453
|
-
const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: e, endColumn: c - 1, startRow: o.row, endRow: a.row });
|
|
3454
|
-
if (h == null)
|
|
3455
|
-
return;
|
|
3456
|
-
l = { ...t, left: (t.left || 0) - h.endX + h.startX - i.from.columnOffset };
|
|
3457
|
-
}
|
|
3458
|
-
d = j(l, this._selectionRenderService), g = F(l, this._selectionRenderService);
|
|
3459
|
-
} else if (u >= e && u <= n && r === U.Both) {
|
|
3460
|
-
const h = this._skeletonManagerService.attachRangeWithCoord({
|
|
3461
|
-
startColumn: e - 1,
|
|
3462
|
-
endColumn: e - 1,
|
|
3463
|
-
startRow: o.row,
|
|
3464
|
-
endRow: a.row
|
|
3465
|
-
});
|
|
3466
|
-
if (h == null)
|
|
3467
|
-
return;
|
|
3468
|
-
d = {
|
|
3469
|
-
from: { ...o },
|
|
3470
|
-
to: { ...a, column: e - 1, columnOffset: h.endX - h.startX }
|
|
3471
|
-
}, l = Q(d, this._selectionRenderService, this._skeletonManagerService);
|
|
3472
|
-
}
|
|
3473
|
-
}
|
|
3474
|
-
return d != null && l != null ? {
|
|
3475
|
-
newSheetTransform: d,
|
|
3476
|
-
newTransform: l,
|
|
3477
|
-
axisAlignSheetTransform: g
|
|
3478
|
-
} : null;
|
|
3479
|
-
}
|
|
3480
|
-
_expandRow(i, t, e, n, r = U.Position) {
|
|
3481
|
-
const s = n - e + 1, { from: o, to: a } = i, { row: c } = o, { row: u } = a;
|
|
3482
|
-
if (r === U.None)
|
|
3483
|
-
return {
|
|
3484
|
-
newSheetTransform: j({ ...t }, this._selectionRenderService),
|
|
3485
|
-
newTransform: t,
|
|
3486
|
-
axisAlignSheetTransform: F({ ...t }, this._selectionRenderService)
|
|
3487
|
-
};
|
|
3488
|
-
let d = null, l = null, g = null;
|
|
3489
|
-
if (c >= e) {
|
|
3490
|
-
const h = this._skeletonManagerService.attachRangeWithCoord({ startRow: e, endRow: n, startColumn: o.column, endColumn: a.column });
|
|
3491
|
-
if (h == null)
|
|
3492
|
-
return;
|
|
3493
|
-
l = { ...t, top: (t.top || 0) + h.endY - h.startY }, d = j(l, this._selectionRenderService), g = F(l, this._selectionRenderService);
|
|
3494
|
-
} else if (u >= n)
|
|
3495
|
-
if (r === U.Both)
|
|
3496
|
-
d = {
|
|
3497
|
-
from: { ...o },
|
|
3498
|
-
to: {
|
|
3499
|
-
...a,
|
|
3500
|
-
row: u + s
|
|
3501
|
-
}
|
|
3502
|
-
}, l = Q(d, this._selectionRenderService, this._skeletonManagerService);
|
|
3503
|
-
else
|
|
3504
|
-
return {
|
|
3505
|
-
newSheetTransform: j({ ...t }, this._selectionRenderService),
|
|
3506
|
-
newTransform: t,
|
|
3507
|
-
axisAlignSheetTransform: F({ ...t }, this._selectionRenderService)
|
|
3508
|
-
};
|
|
3509
|
-
return d != null && l != null ? {
|
|
3510
|
-
newSheetTransform: d,
|
|
3511
|
-
newTransform: l,
|
|
3512
|
-
axisAlignSheetTransform: g
|
|
3513
|
-
} : null;
|
|
3514
|
-
}
|
|
3515
|
-
_shrinkRow(i, t, e, n, r = U.Position) {
|
|
3516
|
-
const s = n - e + 1, { from: o, to: a } = i, { row: c } = o, { row: u } = a;
|
|
3517
|
-
if (r === U.None)
|
|
3518
|
-
return {
|
|
3519
|
-
newSheetTransform: j({ ...t }, this._selectionRenderService),
|
|
3520
|
-
newTransform: t,
|
|
3521
|
-
axisAlignSheetTransform: F({ ...t }, this._selectionRenderService)
|
|
3522
|
-
};
|
|
3523
|
-
let d = null, l = null, g = null;
|
|
3524
|
-
if (c > n)
|
|
3525
|
-
d = {
|
|
3526
|
-
from: { ...o, row: c - s },
|
|
3527
|
-
to: { ...a, row: u - s }
|
|
3528
|
-
}, l = Q(d, this._selectionRenderService, this._skeletonManagerService);
|
|
3529
|
-
else {
|
|
3530
|
-
if (c >= e && u <= n)
|
|
3531
|
-
return null;
|
|
3532
|
-
if (c < e && u > n)
|
|
3533
|
-
if (r === U.Both)
|
|
3534
|
-
d = {
|
|
3535
|
-
from: { ...o },
|
|
3536
|
-
to: { ...a, row: u - s }
|
|
3537
|
-
}, l = Q(d, this._selectionRenderService, this._skeletonManagerService);
|
|
3538
|
-
else
|
|
3539
|
-
return {
|
|
3540
|
-
newSheetTransform: j({ ...t }, this._selectionRenderService),
|
|
3541
|
-
newTransform: t,
|
|
3542
|
-
axisAlignSheetTransform: F({ ...t }, this._selectionRenderService)
|
|
3543
|
-
};
|
|
3544
|
-
else if (c >= e && c <= n) {
|
|
3545
|
-
if (c === e)
|
|
3546
|
-
l = { ...t, top: (t.top || 0) - i.from.rowOffset };
|
|
3547
|
-
else {
|
|
3548
|
-
const h = this._skeletonManagerService.attachRangeWithCoord({ startRow: e, endRow: c - 1, startColumn: o.column, endColumn: a.column });
|
|
3549
|
-
if (h == null)
|
|
3550
|
-
return;
|
|
3551
|
-
l = { ...t, top: (t.top || 0) - h.endY + h.startY - i.from.rowOffset };
|
|
3552
|
-
}
|
|
3553
|
-
d = j(l, this._selectionRenderService), g = F(l, this._selectionRenderService);
|
|
3554
|
-
} else if (u >= e && u <= n && r === U.Both) {
|
|
3555
|
-
const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: o.column, endColumn: o.column, startRow: e - 1, endRow: e - 1 });
|
|
3556
|
-
if (h == null)
|
|
3557
|
-
return;
|
|
3558
|
-
d = {
|
|
3559
|
-
from: { ...o },
|
|
3560
|
-
to: { ...a, row: e - 1, rowOffset: h.endY - h.startY }
|
|
3561
|
-
}, l = Q(d, this._selectionRenderService, this._skeletonManagerService);
|
|
3562
|
-
}
|
|
3563
|
-
}
|
|
3564
|
-
return d != null && l != null ? {
|
|
3565
|
-
newSheetTransform: d,
|
|
3566
|
-
newTransform: l,
|
|
3567
|
-
axisAlignSheetTransform: g
|
|
3568
|
-
} : null;
|
|
3569
|
-
}
|
|
3570
|
-
_commandListener() {
|
|
3571
|
-
this.disposeWithMe(
|
|
3572
|
-
// TODO@weird94: this should subscribe to the command service
|
|
3573
|
-
// but the skeleton changes like other render modules. These two signals are not equivalent.
|
|
3574
|
-
// As a temp solution, I subscribed to activate$ here.
|
|
3575
|
-
this._commandService.onCommandExecuted((i) => {
|
|
3576
|
-
if (i.id === Zi.id) {
|
|
3577
|
-
const { unitId: t, subUnitId: e } = i.params;
|
|
3578
|
-
this._updateDrawings(t, e);
|
|
3579
|
-
}
|
|
3580
|
-
})
|
|
3581
|
-
), this.disposeWithMe(
|
|
3582
|
-
this._context.activated$.subscribe((i) => {
|
|
3583
|
-
const { unit: t, unitId: e } = this._context;
|
|
3584
|
-
if (i) {
|
|
3585
|
-
const n = t.getActiveSheet().getSheetId();
|
|
3586
|
-
this._updateDrawings(e, n);
|
|
3587
|
-
} else
|
|
3588
|
-
this._clearDrawings(e);
|
|
3589
|
-
})
|
|
3590
|
-
);
|
|
3591
|
-
}
|
|
3592
|
-
_clearDrawings(i) {
|
|
3593
|
-
setTimeout(() => {
|
|
3594
|
-
const t = this._drawingManagerService.drawingManagerData, e = [];
|
|
3595
|
-
Object.keys(t).forEach((n) => {
|
|
3596
|
-
const r = t[n];
|
|
3597
|
-
r != null && Object.keys(r).forEach((s) => {
|
|
3598
|
-
const o = r[s].data;
|
|
3599
|
-
o != null && Object.keys(o).forEach((a) => {
|
|
3600
|
-
n === i && e.push(o[a]);
|
|
3601
|
-
});
|
|
3602
|
-
});
|
|
3603
|
-
}), this._sheetDrawingService.removeNotification(e), this._drawingManagerService.removeNotification(e);
|
|
3604
|
-
});
|
|
3605
|
-
}
|
|
3606
|
-
_updateDrawings(i, t) {
|
|
3607
|
-
setTimeout(() => {
|
|
3608
|
-
const e = this._drawingManagerService.drawingManagerData, n = [], r = [];
|
|
3609
|
-
Object.keys(e).forEach((s) => {
|
|
3610
|
-
const o = e[s];
|
|
3611
|
-
o != null && Object.keys(o).forEach((a) => {
|
|
3612
|
-
const c = o[a].data;
|
|
3613
|
-
c != null && Object.keys(c).forEach((u) => {
|
|
3614
|
-
if (s === i && a === t) {
|
|
3615
|
-
const d = c[u];
|
|
3616
|
-
d.sheetTransform && (d.transform = Q(d.sheetTransform, this._selectionRenderService, this._skeletonManagerService)), n.push(c[u]);
|
|
3617
|
-
} else
|
|
3618
|
-
r.push(c[u]);
|
|
3619
|
-
});
|
|
3620
|
-
});
|
|
3621
|
-
}), this._sheetDrawingService.removeNotification(r), this._sheetDrawingService.addNotification(n), this._drawingManagerService.removeNotification(r), this._drawingManagerService.addNotification(n);
|
|
3622
|
-
}, 0);
|
|
3623
|
-
}
|
|
3624
|
-
_sheetRefreshListener() {
|
|
3625
|
-
this.disposeWithMe(
|
|
3626
|
-
this._commandService.onCommandExecuted((i) => {
|
|
3627
|
-
wo.includes(i.id) && requestIdleCallback(() => {
|
|
3628
|
-
const t = i.params, e = ce(this._univerInstanceService, t);
|
|
3629
|
-
if (!e) return;
|
|
3630
|
-
const { unitId: n, subUnitId: r, worksheet: s } = e;
|
|
3631
|
-
let o = [];
|
|
3632
|
-
"ranges" in t ? o = t.ranges : "rowsAutoHeightInfo" in t && (o = t.rowsAutoHeightInfo.map((a) => ({
|
|
3633
|
-
startRow: a.row,
|
|
3634
|
-
endRow: a.row,
|
|
3635
|
-
startColumn: 0,
|
|
3636
|
-
endColumn: s.getColumnCount() - 1
|
|
3637
|
-
}))), this._refreshDrawingTransform(n, r, o);
|
|
3638
|
-
});
|
|
3639
|
-
})
|
|
3640
|
-
);
|
|
3641
|
-
}
|
|
3642
|
-
_refreshDrawingTransform(i, t, e) {
|
|
3643
|
-
const n = this._drawingManagerService.getDrawingData(i, t), r = [];
|
|
3644
|
-
Object.keys(n).forEach((s) => {
|
|
3645
|
-
const o = n[s], { sheetTransform: a, transform: c, anchorType: u = U.Position } = o;
|
|
3646
|
-
if (u === U.None)
|
|
3647
|
-
return !0;
|
|
3648
|
-
const { from: d, to: l } = a, { row: g, column: h } = d, { row: f, column: m } = l;
|
|
3649
|
-
for (let p = 0; p < e.length; p++) {
|
|
3650
|
-
const S = e[p], { startRow: _, endRow: R, startColumn: M, endColumn: I } = S;
|
|
3651
|
-
if (bi.intersects(
|
|
3652
|
-
{
|
|
3653
|
-
startRow: _,
|
|
3654
|
-
endRow: R,
|
|
3655
|
-
startColumn: M,
|
|
3656
|
-
endColumn: I
|
|
3657
|
-
},
|
|
3658
|
-
{
|
|
3659
|
-
startRow: g,
|
|
3660
|
-
endRow: f,
|
|
3661
|
-
startColumn: h,
|
|
3662
|
-
endColumn: m
|
|
3663
|
-
}
|
|
3664
|
-
) || g > R || h > I) {
|
|
3665
|
-
const v = u === U.Position, C = Q(a, this._selectionRenderService, this._skeletonManagerService);
|
|
3666
|
-
r.push({
|
|
3667
|
-
...o,
|
|
3668
|
-
transform: {
|
|
3669
|
-
...C,
|
|
3670
|
-
width: v ? c == null ? void 0 : c.width : C == null ? void 0 : C.width,
|
|
3671
|
-
height: v ? c == null ? void 0 : c.height : C == null ? void 0 : C.height
|
|
3672
|
-
}
|
|
3673
|
-
});
|
|
3674
|
-
break;
|
|
3675
|
-
}
|
|
3676
|
-
}
|
|
3677
|
-
}), r.length !== 0 && (this._sheetDrawingService.refreshTransform(r), this._drawingManagerService.refreshTransform(r), this._commandService.syncExecuteCommand(L.id, [i]));
|
|
3678
|
-
}
|
|
3679
|
-
};
|
|
3680
|
-
Mn = mo([
|
|
3681
|
-
be(1, ee),
|
|
3682
|
-
be(2, K),
|
|
3683
|
-
be(3, Oe),
|
|
3684
|
-
be(4, N(Z)),
|
|
3685
|
-
be(5, N(St)),
|
|
3686
|
-
be(6, ie),
|
|
3687
|
-
be(7, de),
|
|
3688
|
-
be(8, he)
|
|
3689
|
-
], Mn);
|
|
3690
|
-
const yn = {
|
|
3691
|
-
id: "sheet.command.toggle-flip-drawings",
|
|
3692
|
-
type: te.COMMAND,
|
|
3693
|
-
// eslint-disable-next-line max-lines-per-function, complexity
|
|
3694
|
-
handler: (i, t) => {
|
|
3695
|
-
const e = i.get(K), n = i.get(Be), r = i.get(ie), s = i.get(ee);
|
|
3696
|
-
if (!t) return !1;
|
|
3697
|
-
const { drawings: o } = t, a = t.flipH, c = t.flipV, u = [], d = [];
|
|
3698
|
-
for (const M of o) {
|
|
3699
|
-
const { unitId: I, subUnitId: v, drawingId: C } = M;
|
|
3700
|
-
u.push(I);
|
|
3701
|
-
const D = r.getDrawingData(I, v), T = D == null ? void 0 : D[C];
|
|
3702
|
-
if (!T)
|
|
3703
|
-
continue;
|
|
3704
|
-
const b = { ...T.transform };
|
|
3705
|
-
a && (b.flipX = !b.flipX), c && (b.flipY = !b.flipY);
|
|
3706
|
-
const E = s.getRenderById(I), w = E == null ? void 0 : E.with(Oe);
|
|
3707
|
-
if (!w)
|
|
3708
|
-
continue;
|
|
3709
|
-
const y = j(b, w), O = F(b, w), x = {
|
|
3710
|
-
unitId: I,
|
|
3711
|
-
subUnitId: v,
|
|
3712
|
-
drawingType: T.drawingType,
|
|
3713
|
-
drawingId: C,
|
|
3714
|
-
transform: b,
|
|
3715
|
-
sheetTransform: y,
|
|
3716
|
-
axisAlignSheetTransform: O
|
|
3717
|
-
};
|
|
3718
|
-
if (T.drawingType === B.DRAWING_IMAGE) {
|
|
3719
|
-
const z = So(i, I);
|
|
3720
|
-
if (z) {
|
|
3721
|
-
const V = ye({ unitId: I, subUnitId: v, drawingId: C }), G = z.getObject(V);
|
|
3722
|
-
if (G) {
|
|
3723
|
-
const J = G.srcRect;
|
|
3724
|
-
if (J) {
|
|
3725
|
-
let Y;
|
|
3726
|
-
const { left: k = 0, top: se = 0, right: ge = 0, bottom: fe = 0 } = J;
|
|
3727
|
-
if (a) {
|
|
3728
|
-
const le = k + (ge - k) / 2, Re = le - (ge - k) / 2, Ue = le + (ge - k) / 2;
|
|
3729
|
-
Y = {
|
|
3730
|
-
left: Re,
|
|
3731
|
-
top: se,
|
|
3732
|
-
right: Ue,
|
|
3733
|
-
bottom: fe
|
|
3734
|
-
};
|
|
3735
|
-
}
|
|
3736
|
-
if (c) {
|
|
3737
|
-
const le = se + (fe - se) / 2, Re = le - (fe - se) / 2, Ue = le + (fe - se) / 2;
|
|
3738
|
-
Y = {
|
|
3739
|
-
left: k,
|
|
3740
|
-
top: Re,
|
|
3741
|
-
right: ge,
|
|
3742
|
-
bottom: Ue
|
|
3743
|
-
};
|
|
3744
|
-
}
|
|
3745
|
-
Y && (x.srcRect = Y);
|
|
3746
|
-
}
|
|
3747
|
-
}
|
|
3748
|
-
}
|
|
3749
|
-
}
|
|
3750
|
-
d.push(x);
|
|
3751
|
-
}
|
|
3752
|
-
if (d.length === 0) return !1;
|
|
3753
|
-
const l = r.getBatchUpdateOp(d), { unitId: g, subUnitId: h, undo: f, redo: m, objects: p } = l, S = { id: A.id, params: { unitId: g, subUnitId: h, op: m, objects: p, type: P.UPDATE } }, _ = { id: A.id, params: { unitId: g, subUnitId: h, op: f, objects: p, type: P.UPDATE } };
|
|
3754
|
-
return zt([S], e) ? (n.pushUndoRedo({
|
|
3755
|
-
unitID: g,
|
|
3756
|
-
undoMutations: [_, { id: L.id, params: u }],
|
|
3757
|
-
redoMutations: [S, { id: L.id, params: u }]
|
|
3758
|
-
}), !0) : !1;
|
|
3759
|
-
}
|
|
3760
|
-
};
|
|
3761
|
-
function So(i, t) {
|
|
3762
|
-
const n = i.get(ee).getRenderById(t);
|
|
3763
|
-
return n ? n.scene : null;
|
|
3764
|
-
}
|
|
3765
|
-
function _o(i) {
|
|
3766
|
-
var t, e, n, r;
|
|
3767
|
-
return !!((e = (t = i == null ? void 0 : i.p) == null ? void 0 : t.drawingsOrder) != null && e.length && ((r = (n = i == null ? void 0 : i.p) == null ? void 0 : n.drawingsOrder) == null ? void 0 : r.length) > 0);
|
|
3768
|
-
}
|
|
3769
|
-
function vo(i, t) {
|
|
3770
|
-
const e = i.getActiveSheet();
|
|
3771
|
-
if (!e) return !1;
|
|
3772
|
-
const n = e.getCellMatrix(), { startRow: r, endRow: s, startColumn: o, endColumn: a } = t;
|
|
3773
|
-
for (let c = r; c <= s; c++)
|
|
3774
|
-
for (let u = o; u <= a; u++) {
|
|
3775
|
-
const d = n.getValue(c, u);
|
|
3776
|
-
if (_o(d))
|
|
3777
|
-
return !0;
|
|
3778
|
-
}
|
|
3779
|
-
return !1;
|
|
3780
|
-
}
|
|
3781
|
-
function Io() {
|
|
3782
|
-
return "showDirectoryPicker" in window;
|
|
3783
|
-
}
|
|
3784
|
-
function hn(i) {
|
|
3785
|
-
const t = i.get(he), e = i.get(_t), n = ft([
|
|
3786
|
-
Jt(i, $.UNIVER_SHEET),
|
|
3787
|
-
t.getCurrentTypeOfUnit$($.UNIVER_SHEET).pipe(
|
|
3788
|
-
ve((r) => r ? e.selectionMoveEnd$.pipe(
|
|
3789
|
-
Ie(() => {
|
|
3790
|
-
if (!Io())
|
|
3791
|
-
return !0;
|
|
3792
|
-
const s = e.getCurrentSelections();
|
|
3793
|
-
if (!s || s.length === 0)
|
|
3794
|
-
return !0;
|
|
3795
|
-
for (const o of s)
|
|
3796
|
-
if (vo(r, o.range))
|
|
3797
|
-
return !1;
|
|
3798
|
-
return !0;
|
|
3799
|
-
})
|
|
3800
|
-
) : vn(!0))
|
|
3801
|
-
)
|
|
3802
|
-
]).pipe(
|
|
3803
|
-
Ie(([r, s]) => r || s)
|
|
3804
|
-
);
|
|
3805
|
-
return {
|
|
3806
|
-
id: mt.id,
|
|
3807
|
-
type: Zt.BUTTON,
|
|
3808
|
-
icon: "DownloadImageIcon",
|
|
3809
|
-
title: "sheetImage.save.menuLabel",
|
|
3810
|
-
hidden$: n
|
|
3811
|
-
};
|
|
3812
|
-
}
|
|
3813
|
-
const Co = {
|
|
3814
|
-
[ms.MEDIA]: {
|
|
3815
|
-
[Gr]: {
|
|
3816
|
-
order: 0,
|
|
3817
|
-
menuItemFactory: Bs,
|
|
3818
|
-
[Qt.id]: {
|
|
3819
|
-
order: 0,
|
|
3820
|
-
menuItemFactory: $s
|
|
3821
|
-
},
|
|
3822
|
-
[On.id]: {
|
|
3823
|
-
order: 1,
|
|
3824
|
-
menuItemFactory: Ws
|
|
3825
|
-
}
|
|
3826
|
-
}
|
|
3827
|
-
},
|
|
3828
|
-
[cn.MAIN_AREA]: {
|
|
3829
|
-
[dn.OTHERS]: {
|
|
3830
|
-
[mt.id]: {
|
|
3831
|
-
order: 10,
|
|
3832
|
-
menuItemFactory: hn
|
|
3833
|
-
}
|
|
3834
|
-
}
|
|
3835
|
-
},
|
|
3836
|
-
[cn.COL_HEADER]: {
|
|
3837
|
-
[dn.OTHERS]: {
|
|
3838
|
-
[mt.id]: {
|
|
3839
|
-
order: 10,
|
|
3840
|
-
menuItemFactory: hn
|
|
3841
|
-
}
|
|
3842
|
-
}
|
|
3843
|
-
},
|
|
3844
|
-
[cn.ROW_HEADER]: {
|
|
3845
|
-
[dn.OTHERS]: {
|
|
3846
|
-
[mt.id]: {
|
|
3847
|
-
order: 10,
|
|
3848
|
-
menuItemFactory: hn
|
|
3849
|
-
}
|
|
3850
|
-
}
|
|
3851
|
-
}
|
|
3852
|
-
};
|
|
3853
|
-
function Ro() {
|
|
3854
|
-
const i = Ee($e), t = Ee(En), e = Ee(Un), [n, r] = ke([xe.CELL_ADDRESS]), [s, o] = ke(!1), [a, c] = ke(null), u = Ke(() => e.getCellImagesInSelection(), [e]), d = Ke(() => e.getDataColumns(), [e]), l = Ke(() => e.getSelectionRowRange(), [e]), g = d.length > 0, h = Ke(() => d.map((v) => ({
|
|
3855
|
-
label: v.label,
|
|
3856
|
-
value: String(v.index)
|
|
3857
|
-
})), [d]), [f, m] = ke(
|
|
3858
|
-
() => h.length > 0 ? h[0].value : "0"
|
|
3859
|
-
), p = Ke(() => {
|
|
3860
|
-
if (!n.includes(xe.COLUMN_VALUE) || !l)
|
|
3861
|
-
return [];
|
|
3862
|
-
const C = Number(f);
|
|
3863
|
-
return [{
|
|
3864
|
-
startRow: l.startRow,
|
|
3865
|
-
endRow: l.endRow,
|
|
3866
|
-
startColumn: C,
|
|
3867
|
-
endColumn: C
|
|
3868
|
-
}];
|
|
3869
|
-
}, [n, f, l]);
|
|
3870
|
-
gi(p);
|
|
3871
|
-
const S = At((v) => {
|
|
3872
|
-
v.length !== 0 && r(v);
|
|
3873
|
-
}, []), _ = At((v) => {
|
|
3874
|
-
m(String(v));
|
|
3875
|
-
}, []), R = At(() => {
|
|
3876
|
-
t.close(nt);
|
|
3877
|
-
}, [t]), M = At(async () => {
|
|
3878
|
-
if (u.length !== 0) {
|
|
3879
|
-
o(!0), c(null);
|
|
3880
|
-
try {
|
|
3881
|
-
await e.saveImages(u, {
|
|
3882
|
-
fileNameParts: n,
|
|
3883
|
-
columnIndex: n.includes(xe.COLUMN_VALUE) ? Number(f) : void 0
|
|
3884
|
-
}), t.close(nt);
|
|
3885
|
-
} catch (v) {
|
|
3886
|
-
console.error("Failed to save images:", v), c(i.t("sheetImage.save.error"));
|
|
3887
|
-
} finally {
|
|
3888
|
-
o(!1);
|
|
3889
|
-
}
|
|
3890
|
-
}
|
|
3891
|
-
}, [e, u, n, f, t, i]), I = n.includes(xe.COLUMN_VALUE);
|
|
3892
|
-
return /* @__PURE__ */ tt("div", { className: "univer-flex univer-flex-col", children: [
|
|
3893
|
-
/* @__PURE__ */ X(sn, { label: i.t("sheetImage.save.imageCount"), children: /* @__PURE__ */ X("div", { className: "univer-text-sm univer-text-gray-600", children: u.length }) }),
|
|
3894
|
-
/* @__PURE__ */ X(sn, { label: i.t("sheetImage.save.fileNameConfig"), children: /* @__PURE__ */ tt(es, { value: n, onChange: S, direction: "vertical", children: [
|
|
3895
|
-
/* @__PURE__ */ X(Kn, { value: xe.CELL_ADDRESS, disabled: !g, children: i.t("sheetImage.save.useRowCol") }),
|
|
3896
|
-
g && /* @__PURE__ */ X(Kn, { value: xe.COLUMN_VALUE, children: i.t("sheetImage.save.useColumnValue") })
|
|
3897
|
-
] }) }),
|
|
3898
|
-
I && /* @__PURE__ */ X(sn, { label: i.t("sheetImage.save.selectColumn"), children: /* @__PURE__ */ X(
|
|
3899
|
-
ts,
|
|
3900
|
-
{
|
|
3901
|
-
value: f,
|
|
3902
|
-
options: h,
|
|
3903
|
-
onChange: _
|
|
3904
|
-
}
|
|
3905
|
-
) }),
|
|
3906
|
-
a && /* @__PURE__ */ X("div", { className: "univer-text-xs univer-text-red-500", children: a }),
|
|
3907
|
-
/* @__PURE__ */ tt(
|
|
3908
|
-
"div",
|
|
3909
|
-
{
|
|
3910
|
-
className: "univer-flex univer-justify-end univer-gap-2 univer-border-t univer-border-gray-200 univer-pt-3",
|
|
3911
|
-
children: [
|
|
3912
|
-
/* @__PURE__ */ X(Jn, { onClick: R, disabled: s, children: i.t("sheetImage.save.cancel") }),
|
|
3913
|
-
/* @__PURE__ */ X(
|
|
3914
|
-
Jn,
|
|
3915
|
-
{
|
|
3916
|
-
variant: "primary",
|
|
3917
|
-
onClick: M,
|
|
3918
|
-
disabled: s || u.length === 0,
|
|
3919
|
-
children: s ? i.t("sheetImage.save.saving") : i.t("sheetImage.save.confirm")
|
|
3920
|
-
}
|
|
3921
|
-
)
|
|
3922
|
-
]
|
|
3923
|
-
}
|
|
3924
|
-
)
|
|
3925
|
-
] });
|
|
3926
|
-
}
|
|
3927
|
-
const Do = (i) => {
|
|
3928
|
-
var _;
|
|
3929
|
-
const t = Ee(K), e = Ee($e), n = Ee(de), r = Ee(ee), { drawings: s } = i, o = s[0];
|
|
3930
|
-
if (o == null)
|
|
3931
|
-
return;
|
|
3932
|
-
const { unitId: a } = o, c = r.getRenderById(a), u = c == null ? void 0 : c.scene;
|
|
3933
|
-
if (u == null)
|
|
3934
|
-
return;
|
|
3935
|
-
const d = u.getTransformerByCreate(), [l, g] = ke(!0), h = (_ = o.anchorType) != null ? _ : U.Position, [f, m] = ke(h);
|
|
3936
|
-
function p(R, M) {
|
|
3937
|
-
const I = [];
|
|
3938
|
-
return R.forEach((v) => {
|
|
3939
|
-
const { oKey: C } = v, D = M.getDrawingOKey(C);
|
|
3940
|
-
if (D == null)
|
|
3941
|
-
return I.push(null), !0;
|
|
3942
|
-
const { unitId: T, subUnitId: b, drawingId: E, drawingType: w, anchorType: y, sheetTransform: O, axisAlignSheetTransform: x } = D;
|
|
3943
|
-
I.push({
|
|
3944
|
-
unitId: T,
|
|
3945
|
-
subUnitId: b,
|
|
3946
|
-
drawingId: E,
|
|
3947
|
-
anchorType: y,
|
|
3948
|
-
sheetTransform: O,
|
|
3949
|
-
drawingType: w,
|
|
3950
|
-
axisAlignSheetTransform: x
|
|
3951
|
-
});
|
|
3952
|
-
}), I;
|
|
3953
|
-
}
|
|
3954
|
-
Br(() => {
|
|
3955
|
-
const R = d.clearControl$.subscribe((I) => {
|
|
3956
|
-
I === !0 && g(!1);
|
|
3957
|
-
}), M = d.changeStart$.subscribe((I) => {
|
|
3958
|
-
var D;
|
|
3959
|
-
const { objects: v } = I, C = p(v, n);
|
|
3960
|
-
if (C.length === 0)
|
|
3961
|
-
g(!1);
|
|
3962
|
-
else if (C.length >= 1) {
|
|
3963
|
-
g(!0);
|
|
3964
|
-
const T = ((D = C[0]) == null ? void 0 : D.anchorType) || U.Position;
|
|
3965
|
-
m(T);
|
|
3966
|
-
}
|
|
3967
|
-
});
|
|
3968
|
-
return () => {
|
|
3969
|
-
M.unsubscribe(), R.unsubscribe();
|
|
3970
|
-
};
|
|
3971
|
-
}, []);
|
|
3972
|
-
function S(R) {
|
|
3973
|
-
m(R);
|
|
3974
|
-
const M = n.getFocusDrawings();
|
|
3975
|
-
if (M.length === 0)
|
|
3976
|
-
return;
|
|
3977
|
-
const I = M.map((v) => ({
|
|
3978
|
-
unitId: v.unitId,
|
|
3979
|
-
subUnitId: v.subUnitId,
|
|
3980
|
-
drawingId: v.drawingId,
|
|
3981
|
-
anchorType: R
|
|
3982
|
-
}));
|
|
3983
|
-
t.executeCommand(It.id, {
|
|
3984
|
-
unitId: M[0].unitId,
|
|
3985
|
-
drawings: I
|
|
3986
|
-
});
|
|
3987
|
-
}
|
|
3988
|
-
return /* @__PURE__ */ tt(
|
|
3989
|
-
"div",
|
|
3990
|
-
{
|
|
3991
|
-
className: ns("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", {
|
|
3992
|
-
"univer-hidden": !l
|
|
3993
|
-
}),
|
|
3994
|
-
children: [
|
|
3995
|
-
/* @__PURE__ */ X(
|
|
3996
|
-
"header",
|
|
3997
|
-
{
|
|
3998
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
3999
|
-
children: /* @__PURE__ */ X("div", { children: e.t("drawing-anchor.title") })
|
|
4000
|
-
}
|
|
4001
|
-
),
|
|
4002
|
-
/* @__PURE__ */ X("div", { children: /* @__PURE__ */ tt(rs, { value: f, onChange: S, direction: "vertical", children: [
|
|
4003
|
-
/* @__PURE__ */ X(on, { value: U.Both, children: e.t("drawing-anchor.both") }),
|
|
4004
|
-
/* @__PURE__ */ X(on, { value: U.Position, children: e.t("drawing-anchor.position") }),
|
|
4005
|
-
/* @__PURE__ */ X(on, { value: U.None, children: e.t("drawing-anchor.none") })
|
|
4006
|
-
] }) })
|
|
4007
|
-
]
|
|
4008
|
-
}
|
|
4009
|
-
);
|
|
4010
|
-
}, bo = () => {
|
|
4011
|
-
const i = Ee(de), t = i.getFocusDrawings(), [e, n] = ke(t);
|
|
4012
|
-
return Br(() => {
|
|
4013
|
-
const r = i.focus$.subscribe((s) => {
|
|
4014
|
-
n(s);
|
|
4015
|
-
});
|
|
4016
|
-
return () => {
|
|
4017
|
-
r.unsubscribe();
|
|
4018
|
-
};
|
|
4019
|
-
}, []), !!(e != null && e.length) && /* @__PURE__ */ tt("div", { className: "univer-text-sm", children: [
|
|
4020
|
-
/* @__PURE__ */ X(vs, { drawings: e }),
|
|
4021
|
-
/* @__PURE__ */ X(Do, { drawings: e })
|
|
4022
|
-
] });
|
|
4023
|
-
};
|
|
4024
|
-
function Rt(i) {
|
|
4025
|
-
return i.getContextValue(Mi) && !i.getContextValue(yi) && !i.getContextValue(Ti) && i.getContextValue(et) && !i.getContextValue(Ei);
|
|
4026
|
-
}
|
|
4027
|
-
const Mo = {
|
|
4028
|
-
id: Ct.id,
|
|
4029
|
-
description: "shortcut.drawing-move-down",
|
|
4030
|
-
group: "4_drawing-view",
|
|
4031
|
-
binding: rt.ARROW_DOWN,
|
|
4032
|
-
priority: 100,
|
|
4033
|
-
preconditions: Rt,
|
|
4034
|
-
staticParameters: {
|
|
4035
|
-
direction: Te.DOWN
|
|
4036
|
-
}
|
|
4037
|
-
}, yo = {
|
|
4038
|
-
id: Ct.id,
|
|
4039
|
-
description: "shortcut.drawing-move-up",
|
|
4040
|
-
group: "4_drawing-view",
|
|
4041
|
-
binding: rt.ARROW_UP,
|
|
4042
|
-
priority: 100,
|
|
4043
|
-
preconditions: Rt,
|
|
4044
|
-
staticParameters: {
|
|
4045
|
-
direction: Te.UP
|
|
4046
|
-
}
|
|
4047
|
-
}, To = {
|
|
4048
|
-
id: Ct.id,
|
|
4049
|
-
description: "shortcut.drawing-move-left",
|
|
4050
|
-
group: "4_drawing-view",
|
|
4051
|
-
binding: rt.ARROW_LEFT,
|
|
4052
|
-
priority: 100,
|
|
4053
|
-
preconditions: Rt,
|
|
4054
|
-
staticParameters: {
|
|
4055
|
-
direction: Te.LEFT
|
|
4056
|
-
}
|
|
4057
|
-
}, Eo = {
|
|
4058
|
-
id: Ct.id,
|
|
4059
|
-
description: "shortcut.drawing-move-right",
|
|
4060
|
-
group: "4_drawing-view",
|
|
4061
|
-
binding: rt.ARROW_RIGHT,
|
|
4062
|
-
priority: 100,
|
|
4063
|
-
preconditions: Rt,
|
|
4064
|
-
staticParameters: {
|
|
4065
|
-
direction: Te.RIGHT
|
|
4066
|
-
}
|
|
4067
|
-
}, Oo = {
|
|
4068
|
-
id: $r.id,
|
|
4069
|
-
description: "shortcut.drawing-delete",
|
|
4070
|
-
group: "4_drawing-view",
|
|
4071
|
-
priority: 100,
|
|
4072
|
-
// when focusing on any other input tag do not trigger this shortcut
|
|
4073
|
-
preconditions: Rt,
|
|
4074
|
-
binding: rt.DELETE,
|
|
4075
|
-
mac: rt.BACKSPACE
|
|
4076
|
-
};
|
|
4077
|
-
var Uo = Object.getOwnPropertyDescriptor, Po = (i, t, e, n) => {
|
|
4078
|
-
for (var r = n > 1 ? void 0 : n ? Uo(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
4079
|
-
(o = i[s]) && (r = o(r) || r);
|
|
4080
|
-
return r;
|
|
4081
|
-
}, Xe = (i, t) => (e, n) => t(e, n, i);
|
|
4082
|
-
let Yt = class extends re {
|
|
4083
|
-
constructor(i, t, e, n, r, s) {
|
|
4084
|
-
super(), this._componentManager = i, this._menuManagerService = t, this._commandService = e, this._shortcutService = n, this._drawingManagerService = r, this._sheetsSelectionsService = s, this._init();
|
|
4085
|
-
}
|
|
4086
|
-
_initCustomComponents() {
|
|
4087
|
-
const i = this._componentManager;
|
|
4088
|
-
this.disposeWithMe(i.register(Lr, bo)), this.disposeWithMe(i.register(nt, Ro));
|
|
4089
|
-
}
|
|
4090
|
-
_initMenus() {
|
|
4091
|
-
this._menuManagerService.mergeMenu(Co);
|
|
4092
|
-
}
|
|
4093
|
-
_initCommands() {
|
|
4094
|
-
[
|
|
4095
|
-
Qt,
|
|
4096
|
-
On,
|
|
4097
|
-
qt,
|
|
4098
|
-
vt,
|
|
4099
|
-
It,
|
|
4100
|
-
Hr,
|
|
4101
|
-
L,
|
|
4102
|
-
Vr,
|
|
4103
|
-
Wr,
|
|
4104
|
-
Fr,
|
|
4105
|
-
Ct,
|
|
4106
|
-
$r,
|
|
4107
|
-
jr,
|
|
4108
|
-
mt,
|
|
4109
|
-
yn
|
|
4110
|
-
].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i)));
|
|
4111
|
-
}
|
|
4112
|
-
_initShortcuts() {
|
|
4113
|
-
[
|
|
4114
|
-
// sheet drawing shortcuts
|
|
4115
|
-
Mo,
|
|
4116
|
-
yo,
|
|
4117
|
-
To,
|
|
4118
|
-
Eo,
|
|
4119
|
-
Oo
|
|
4120
|
-
].forEach((i) => {
|
|
4121
|
-
this.disposeWithMe(this._shortcutService.registerShortcut(i));
|
|
4122
|
-
});
|
|
4123
|
-
}
|
|
4124
|
-
_init() {
|
|
4125
|
-
this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
|
|
4126
|
-
}
|
|
4127
|
-
};
|
|
4128
|
-
Yt = Po([
|
|
4129
|
-
Xe(0, N(xr)),
|
|
4130
|
-
Xe(1, ps),
|
|
4131
|
-
Xe(2, K),
|
|
4132
|
-
Xe(3, ws),
|
|
4133
|
-
Xe(4, de),
|
|
4134
|
-
Xe(5, N(_t))
|
|
4135
|
-
], Yt);
|
|
4136
|
-
var Ao = Object.getOwnPropertyDescriptor, No = (i, t, e, n) => {
|
|
4137
|
-
for (var r = n > 1 ? void 0 : n ? Ao(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
4138
|
-
(o = i[s]) && (r = o(r) || r);
|
|
4139
|
-
return r;
|
|
4140
|
-
}, ue = (i, t) => (e, n) => t(e, n, i);
|
|
4141
|
-
let Xt = class extends Oi {
|
|
4142
|
-
constructor(t, e, n, r, s, o, a, c, u, d) {
|
|
4143
|
-
super();
|
|
4144
|
-
ae(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
|
|
4145
|
-
this._injector = t, this._localeService = e, this._drawingManagerService = n, this._canvasPopManagerService = r, this._renderManagerService = s, this._univerInstanceService = o, this._messageService = a, this._contextService = c, this._ioService = u, this._commandService = d, this._init();
|
|
4146
|
-
}
|
|
4147
|
-
_init() {
|
|
4148
|
-
this._univerInstanceService.getCurrentTypeOfUnit$($.UNIVER_SHEET).subscribe((t) => this._create(t)), this._univerInstanceService.getTypeOfUnitDisposed$($.UNIVER_SHEET).subscribe((t) => this._dispose(t)), this._univerInstanceService.getAllUnitsForType($.UNIVER_SHEET).forEach((t) => this._create(t)), this._setupLoadingStatus();
|
|
4149
|
-
}
|
|
4150
|
-
_setupLoadingStatus() {
|
|
4151
|
-
const t = "image-upload-loading";
|
|
4152
|
-
let e;
|
|
4153
|
-
this.disposeWithMe(this._ioService.change$.subscribe((n) => {
|
|
4154
|
-
n > 0 && !e ? e = this._messageService.show({
|
|
4155
|
-
id: t,
|
|
4156
|
-
type: Me.Loading,
|
|
4157
|
-
content: `${this._localeService.t("uploadLoading.loading")}: ${n}`,
|
|
4158
|
-
duration: 0
|
|
4159
|
-
}) : n === 0 && (e == null || e.dispose(), e = void 0);
|
|
4160
|
-
}));
|
|
4161
|
-
}
|
|
4162
|
-
_dispose(t) {
|
|
4163
|
-
super.dispose();
|
|
4164
|
-
const e = t.getUnitId();
|
|
4165
|
-
this._renderManagerService.removeRender(e), this._initImagePopupMenu.delete(e);
|
|
4166
|
-
}
|
|
4167
|
-
_create(t) {
|
|
4168
|
-
if (!t)
|
|
4169
|
-
return;
|
|
4170
|
-
const e = t.getUnitId();
|
|
4171
|
-
this._renderManagerService.has(e) && !this._initImagePopupMenu.has(e) && (this._popupMenuListener(e), this._initImagePopupMenu.add(e));
|
|
4172
|
-
}
|
|
4173
|
-
_hasCropObject(t) {
|
|
4174
|
-
const e = t.getAllObjectsByOrder();
|
|
4175
|
-
for (const n of e)
|
|
4176
|
-
if (n instanceof Is)
|
|
4177
|
-
return !0;
|
|
4178
|
-
return !1;
|
|
4179
|
-
}
|
|
4180
|
-
_popupMenuListener(t) {
|
|
4181
|
-
var s;
|
|
4182
|
-
const e = (s = this._renderManagerService.getRenderById(t)) == null ? void 0 : s.scene;
|
|
4183
|
-
if (!e)
|
|
4184
|
-
return;
|
|
4185
|
-
const n = e.getTransformerByCreate();
|
|
4186
|
-
if (!n)
|
|
4187
|
-
return;
|
|
4188
|
-
let r;
|
|
4189
|
-
this.disposeWithMe(
|
|
4190
|
-
n.createControl$.subscribe(() => {
|
|
4191
|
-
if (this._contextService.setContextValue(et, !0), this._hasCropObject(e))
|
|
4192
|
-
return;
|
|
4193
|
-
const o = n.getSelectedObjectMap();
|
|
4194
|
-
if (o.size > 1) {
|
|
4195
|
-
r == null || r.dispose();
|
|
4196
|
-
return;
|
|
4197
|
-
}
|
|
4198
|
-
const a = o.values().next().value;
|
|
4199
|
-
if (!a)
|
|
4200
|
-
return;
|
|
4201
|
-
const c = a.oKey, u = this._drawingManagerService.getDrawingOKey(c);
|
|
4202
|
-
if (!u)
|
|
4203
|
-
return;
|
|
4204
|
-
const { unitId: d, subUnitId: l, drawingId: g, drawingType: h } = u, f = u.data;
|
|
4205
|
-
if (f && f.disablePopup)
|
|
4206
|
-
return;
|
|
4207
|
-
r == null || r.dispose();
|
|
4208
|
-
const m = this._canvasPopManagerService.getFeatureMenu(d, l, g, h);
|
|
4209
|
-
r = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(a, {
|
|
4210
|
-
componentKey: Cs,
|
|
4211
|
-
direction: "horizontal",
|
|
4212
|
-
offset: [2, 0],
|
|
4213
|
-
extraProps: {
|
|
4214
|
-
menuItems: m || this._getImageMenuItems(d, l, g, h)
|
|
4215
|
-
}
|
|
4216
|
-
}));
|
|
4217
|
-
})
|
|
4218
|
-
), this.disposeWithMe(
|
|
4219
|
-
n.clearControl$.subscribe(() => {
|
|
4220
|
-
r == null || r.dispose(), this._contextService.setContextValue(et, !1), this._commandService.syncExecuteCommand(Kt.id, []);
|
|
4221
|
-
})
|
|
4222
|
-
), this.disposeWithMe(
|
|
4223
|
-
this._contextService.contextChanged$.subscribe((o) => {
|
|
4224
|
-
o[et] === !1 && (r == null || r.dispose());
|
|
4225
|
-
})
|
|
4226
|
-
), this.disposeWithMe(
|
|
4227
|
-
n.changing$.subscribe(() => {
|
|
4228
|
-
r == null || r.dispose();
|
|
4229
|
-
})
|
|
4230
|
-
);
|
|
4231
|
-
}
|
|
4232
|
-
_getImageMenuItems(t, e, n, r) {
|
|
4233
|
-
return [
|
|
4234
|
-
{
|
|
4235
|
-
label: "image-popup.edit",
|
|
4236
|
-
index: 0,
|
|
4237
|
-
commandId: Vr.id,
|
|
4238
|
-
commandParams: { unitId: t, subUnitId: e, drawingId: n },
|
|
4239
|
-
disable: r === B.DRAWING_DOM
|
|
4240
|
-
},
|
|
4241
|
-
{
|
|
4242
|
-
label: "image-popup.delete",
|
|
4243
|
-
index: 1,
|
|
4244
|
-
commandId: vt.id,
|
|
4245
|
-
commandParams: { unitId: t, drawings: [{ unitId: t, subUnitId: e, drawingId: n }] },
|
|
4246
|
-
disable: !1
|
|
4247
|
-
},
|
|
4248
|
-
{
|
|
4249
|
-
label: "image-popup.crop",
|
|
4250
|
-
index: 2,
|
|
4251
|
-
commandId: Rs.id,
|
|
4252
|
-
commandParams: { unitId: t, subUnitId: e, drawingId: n },
|
|
4253
|
-
disable: r === B.DRAWING_DOM
|
|
4254
|
-
},
|
|
4255
|
-
{
|
|
4256
|
-
label: "image-popup.flipH",
|
|
4257
|
-
index: 2,
|
|
4258
|
-
commandId: yn.id,
|
|
4259
|
-
commandParams: { unitId: t, flipH: !0, drawings: [{ unitId: t, subUnitId: e, drawingId: n }] },
|
|
4260
|
-
disable: r === B.DRAWING_DOM
|
|
4261
|
-
},
|
|
4262
|
-
{
|
|
4263
|
-
label: "image-popup.flipV",
|
|
4264
|
-
index: 2,
|
|
4265
|
-
commandId: yn.id,
|
|
4266
|
-
commandParams: { unitId: t, flipV: !0, drawings: [{ unitId: t, subUnitId: e, drawingId: n }] },
|
|
4267
|
-
disable: r === B.DRAWING_DOM
|
|
4268
|
-
},
|
|
4269
|
-
{
|
|
4270
|
-
label: "image-popup.reset",
|
|
4271
|
-
index: 3,
|
|
4272
|
-
commandId: Ds.id,
|
|
4273
|
-
commandParams: [{ unitId: t, subUnitId: e, drawingId: n }],
|
|
4274
|
-
disable: r === B.DRAWING_DOM
|
|
4275
|
-
}
|
|
4276
|
-
];
|
|
4277
|
-
}
|
|
4278
|
-
};
|
|
4279
|
-
Xt = No([
|
|
4280
|
-
ue(0, N(st)),
|
|
4281
|
-
ue(1, N($e)),
|
|
4282
|
-
ue(2, de),
|
|
4283
|
-
ue(3, N(fi)),
|
|
4284
|
-
ue(4, ee),
|
|
4285
|
-
ue(5, he),
|
|
4286
|
-
ue(6, Nr),
|
|
4287
|
-
ue(7, gr),
|
|
4288
|
-
ue(8, mr),
|
|
4289
|
-
ue(9, K)
|
|
4290
|
-
], Xt);
|
|
4291
|
-
var xo = Object.defineProperty, ko = Object.getOwnPropertyDescriptor, Bo = (i, t, e) => t in i ? xo(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, $o = (i, t, e, n) => {
|
|
4292
|
-
for (var r = n > 1 ? void 0 : n ? ko(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
4293
|
-
(o = i[s]) && (r = o(r) || r);
|
|
4294
|
-
return r;
|
|
4295
|
-
}, gn = (i, t) => (e, n) => t(e, n, i), en = (i, t, e) => Bo(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4296
|
-
let it = class extends Ai {
|
|
4297
|
-
constructor(i = cr, t, e, n) {
|
|
4298
|
-
super(), this._config = i, this._injector = t, this._renderManagerService = e, this._configService = n;
|
|
4299
|
-
const { menu: r, ...s } = Ni(
|
|
4300
|
-
{},
|
|
4301
|
-
cr,
|
|
4302
|
-
this._config
|
|
4303
|
-
);
|
|
4304
|
-
r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Ls, s);
|
|
4305
|
-
}
|
|
4306
|
-
onStarting() {
|
|
4307
|
-
xi(this._injector, [
|
|
4308
|
-
[wt],
|
|
4309
|
-
[Yt],
|
|
4310
|
-
[Xt],
|
|
4311
|
-
[Gt],
|
|
4312
|
-
[Vt],
|
|
4313
|
-
[Ht],
|
|
4314
|
-
[jt],
|
|
4315
|
-
[Ft],
|
|
4316
|
-
[Lt],
|
|
4317
|
-
[Un, { useClass: Rn }]
|
|
4318
|
-
]), rn(this._injector, [
|
|
4319
|
-
[wt]
|
|
4320
|
-
]);
|
|
4321
|
-
}
|
|
4322
|
-
onReady() {
|
|
4323
|
-
rn(this._injector, [
|
|
4324
|
-
[Ht],
|
|
4325
|
-
[Lt]
|
|
4326
|
-
]);
|
|
4327
|
-
}
|
|
4328
|
-
onRendered() {
|
|
4329
|
-
this._registerRenderModules(), rn(this._injector, [
|
|
4330
|
-
[Vt],
|
|
4331
|
-
[Gt],
|
|
4332
|
-
[Yt],
|
|
4333
|
-
[jt],
|
|
4334
|
-
[Ft]
|
|
4335
|
-
]);
|
|
4336
|
-
}
|
|
4337
|
-
onSteady() {
|
|
4338
|
-
this._injector.get(Xt);
|
|
4339
|
-
}
|
|
4340
|
-
_registerRenderModules() {
|
|
4341
|
-
[
|
|
4342
|
-
[pt],
|
|
4343
|
-
[Mn],
|
|
4344
|
-
[bn],
|
|
4345
|
-
[Dn]
|
|
4346
|
-
].forEach((i) => {
|
|
4347
|
-
this.disposeWithMe(this._renderManagerService.registerRenderModule($.UNIVER_SHEET, i));
|
|
4348
|
-
});
|
|
4349
|
-
}
|
|
4350
|
-
};
|
|
4351
|
-
en(it, "type", $.UNIVER_SHEET);
|
|
4352
|
-
en(it, "pluginName", "SHEET_IMAGE_UI_PLUGIN");
|
|
4353
|
-
en(it, "packageName", Yr.name);
|
|
4354
|
-
en(it, "version", Yr.version);
|
|
4355
|
-
it = $o([
|
|
4356
|
-
Ui(cs, _s, bs, ki),
|
|
4357
|
-
gn(1, N(st)),
|
|
4358
|
-
gn(2, ee),
|
|
4359
|
-
gn(3, Pi)
|
|
4360
|
-
], it);
|
|
4361
|
-
export {
|
|
4362
|
-
Rn as BatchSaveImagesService,
|
|
4363
|
-
L as ClearSheetDrawingTransformerOperation,
|
|
4364
|
-
$r as DeleteDrawingsCommand,
|
|
4365
|
-
Vr as EditSheetDrawingOperation,
|
|
4366
|
-
xe as FileNamePart,
|
|
4367
|
-
Wr as GroupSheetDrawingCommand,
|
|
4368
|
-
Un as IBatchSaveImagesService,
|
|
4369
|
-
Qt as InsertFloatImageCommand,
|
|
4370
|
-
qt as InsertSheetDrawingCommand,
|
|
4371
|
-
Ct as MoveDrawingsCommand,
|
|
4372
|
-
vt as RemoveSheetDrawingCommand,
|
|
4373
|
-
Gr as SHEETS_IMAGE_MENU_ID,
|
|
4374
|
-
lo as SHEET_FLOAT_DOM_PREFIX,
|
|
4375
|
-
mt as SaveCellImagesCommand,
|
|
4376
|
-
jr as SetDrawingArrangeCommand,
|
|
4377
|
-
It as SetSheetDrawingCommand,
|
|
4378
|
-
wt as SheetCanvasFloatDomManagerService,
|
|
4379
|
-
Do as SheetDrawingAnchor,
|
|
4380
|
-
pt as SheetDrawingUpdateController,
|
|
4381
|
-
Hr as SidebarSheetDrawingOperation,
|
|
4382
|
-
Fr as UngroupSheetDrawingCommand,
|
|
4383
|
-
it as UniverSheetsDrawingUIPlugin,
|
|
4384
|
-
_e as calcSheetFloatDomPosition,
|
|
4385
|
-
Q as drawingPositionToTransform,
|
|
4386
|
-
F as transformToAxisAlignPosition,
|
|
4387
|
-
j as transformToDrawingPosition
|
|
4388
|
-
};
|
|
1
|
+
import{CURSOR_TYPE as e,DRAWING_OBJECT_LAYER_INDEX as t,IRenderManagerService as n,ObjectType as r,RENDER_CLASS_TYPE as i,Rect as a,SHEET_VIEWPORT_KEY as o,getCurrentTypeOfRenderer as s,getGroupState as c,precisionTo as l,transformObjectOutOfGroup as u}from"@univerjs/engine-render";import{COPY_TYPE as d,EditingRenderController as f,HoverManagerService as p,IEditorBridgeService as m,ISheetClipboardService as h,ISheetSelectionRenderService as g,PREDEFINED_HOOK_NAME_PASTE as _,SetCellEditVisibleOperation as v,SetScrollOperation as y,SetZoomRatioOperation as b,SheetCanvasPopManagerService as x,SheetPrintInterceptorService as S,SheetSkeletonManagerService as C,attachRangeWithCoord as w,convertPositionSheetOverGridToAbsolute as T,getCurrentRangeDisable$ as E,useHighlightRange as D,virtualizeDiscreteRanges as ee}from"@univerjs/sheets-ui";import{ArrangeTypeEnum as O,BooleanNumber as te,BuildTextUtils as k,CommandType as A,DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as j,DOCS_NORMAL_EDITOR_UNIT_ID_KEY as M,DOCS_ZEN_EDITOR_UNIT_ID_KEY as N,DependentOn as ne,Direction as P,Disposable as F,DisposableCollection as re,DrawingTypeEnum as I,FOCUSING_COMMON_DRAWINGS as ie,FOCUSING_FX_BAR_EDITOR as ae,FOCUSING_PANEL_EDITOR as oe,FOCUSING_SHAPE_TEXT_EDITOR as se,FOCUSING_SHEET as ce,ICommandService as L,IConfigService as le,IContextService as ue,IImageIoService as de,IPermissionService as fe,IURLImageService as pe,IUndoRedoService as me,IUniverInstanceService as he,ImageSourceType as ge,Inject as R,Injector as _e,InterceptorEffectEnum as ve,LifecycleService as ye,LifecycleStages as be,LocaleService as xe,ObjectMatrix as Se,ObjectRelativeFromH as Ce,ObjectRelativeFromV as we,PRINT_CHART_COMPONENT_KEY as Te,Plugin as Ee,PositionedObjectLayoutType as De,Rectangle as Oe,RxDisposable as ke,Tools as Ae,UniverInstanceType as z,UserManagerService as je,WrapTextType as Me,createDocumentModelWithStyle as Ne,createIdentifier as Pe,fromEventSubject as Fe,generateRandomId as Ie,merge as Le,registerDependencies as Re,sequenceExecute as ze,touchDependencies as Be}from"@univerjs/core";import{DrawingApplyType as B,ISheetDrawingService as V,SetDrawingApplyMutation as H,SheetDrawingAnchorType as U,UniverSheetsDrawingPlugin as Ve}from"@univerjs/sheets-drawing";import{COMMAND_LISTENER_SKELETON_CHANGE as He,DeleteRangeMoveLeftCommand as Ue,DeleteRangeMoveUpCommand as We,DeltaColumnWidthCommand as Ge,DeltaRowHeightCommand as Ke,IAutoFillService as qe,INTERCEPTOR_POINT as Je,InsertColCommand as Ye,InsertRangeMoveDownCommand as Xe,InsertRangeMoveRightCommand as Ze,InsertRowCommand as Qe,InterceptCellContentPriority as $e,MoveColsCommand as et,MoveRangeCommand as tt,MoveRowsCommand as nt,RangeProtectionPermissionEditPoint as rt,RemoveColCommand as it,RemoveRowCommand as at,SetColHiddenCommand as ot,SetColHiddenMutation as st,SetColVisibleMutation as ct,SetColWidthCommand as lt,SetFrozenMutation as ut,SetRangeValuesCommand as dt,SetRowHeightCommand as ft,SetRowHiddenCommand as pt,SetRowHiddenMutation as mt,SetRowVisibleMutation as ht,SetSelectionsOperation as gt,SetSpecificColsVisibleCommand as _t,SetSpecificRowsVisibleCommand as vt,SetWorksheetActiveOperation as yt,SetWorksheetColWidthMutation as bt,SetWorksheetRowAutoHeightMutation as xt,SetWorksheetRowHeightMutation as St,SetWorksheetRowIsAutoHeightMutation as Ct,SheetInterceptorService as wt,SheetsSelectionsService as Tt,WorkbookEditablePermission as Et,WorkbookViewPermission as Dt,WorksheetEditPermission as Ot,WorksheetViewPermission as kt,discreteRangeToRange as At,getSheetCommandTarget as W}from"@univerjs/sheets";import{Button as jt,Checkbox as Mt,CheckboxGroup as Nt,FormLayout as Pt,MessageType as Ft,Radio as It,RadioGroup as Lt,Select as Rt,clsx as zt,render as Bt,unmount as Vt}from"@univerjs/design";import{InnerPasteCommand as Ht,ReplaceSnapshotCommand as Ut,docDrawingPositionToTransform as Wt}from"@univerjs/docs-ui";import{DRAWING_IMAGE_ALLOW_IMAGE_LIST as Gt,DRAWING_IMAGE_ALLOW_SIZE as Kt,DRAWING_IMAGE_COUNT_LIMIT as qt,DRAWING_IMAGE_HEIGHT_LIMIT as Jt,DRAWING_IMAGE_WIDTH_LIMIT as Yt,IDrawingManagerService as G,IImageIoService as Xt,ImageSourceType as Zt,ImageUploadStatusType as Qt,SetDrawingSelectedOperation as $t,UniverDrawingPlugin as en,getDrawingShapeKeyByDrawingSearch as tn,getImageSize as nn}from"@univerjs/drawing";import{CanvasFloatDomService as rn,ComponentManager as an,ContextMenuGroup as on,ContextMenuPosition as sn,IClipboardInterfaceService as cn,IContextMenuService as ln,IDialogService as un,ILocalFileService as dn,IMenuManagerService as fn,IMessageService as pn,IShortcutService as mn,ISidebarService as hn,KeyCode as gn,MenuItemType as _n,PrintFloatDomSingle as vn,RibbonInsertGroup as yn,connectInjector as bn,getMenuHiddenObservable as xn,useDependency as Sn}from"@univerjs/ui";import{DocDrawingController as Cn,UniverDocsDrawingPlugin as wn}from"@univerjs/docs-drawing";import{COMPONENT_IMAGE_POPUP_MENU as Tn,DrawingCommonPanel as En,DrawingRenderService as Dn,ImageCropperObject as On,ImageResetSizeOperation as kn,OpenImageCropOperation as An,UniverDrawingUIPlugin as jn}from"@univerjs/drawing-ui";import{BehaviorSubject as Mn,EMPTY as Nn,Subject as Pn,combineLatest as Fn,distinctUntilChanged as In,filter as Ln,map as Rn,of as zn,switchMap as Bn,take as Vn,tap as Hn,throttleTime as Un}from"rxjs";import{useCallback as Wn,useEffect as Gn,useMemo as Kn,useState as qn}from"react";import{jsx as K,jsxs as Jn}from"react/jsx-runtime";function q(e,t,n){let{from:r,to:i,flipY:a=!1,flipX:o=!1,angle:s=0,skewX:c=0,skewY:l=0}=e,u=n.getCurrent();if(u==null)return;let{left:d,top:f,width:p,height:m}=T(u.unitId,u.sheetId,{from:r,to:i},n),h=n.getCurrentSkeleton(),g=h.rowHeaderWidth+h.columnTotalWidth,_=h.columnHeaderHeight+h.rowTotalHeight;return d+p>g&&(d=g-p),f+m>_&&(f=_-m),{flipY:a,flipX:o,angle:s,skewX:c,skewY:l,left:d,top:f,width:p,height:m}}function J(e,t){let{left:n=0,top:r=0,width:i=0,height:a=0,flipY:o=!1,flipX:s=!1,angle:c=0,skewX:u=0,skewY:d=0}=e,f=t.getCellWithCoordByOffset(n,r);if(f==null)return;let p={column:f.actualColumn,columnOffset:l(n-f.startX,1),row:f.actualRow,rowOffset:l(r-f.startY,1)},m=t.getCellWithCoordByOffset(n+i,r+a);if(m!=null)return{flipY:o,flipX:s,angle:c,skewX:u,skewY:d,from:p,to:{column:m.actualColumn,columnOffset:l(n+i-m.startX,1),row:m.actualRow,rowOffset:l(r+a-m.startY,1)}}}function Y(e,t){let{left:n=0,top:r=0,width:i=0,height:a=0,angle:o=0}=e,s=(o%360+360)%360;return J(s>=45&&s<135||s>=225&&s<315?{...e,left:n+i/2-a/2,top:r+a/2-i/2,width:a,height:i}:e,t)}const X={id:`sheet.operation.clear-drawing-transformer`,type:A.MUTATION,handler:(e,t)=>{let r=e.get(n);return t.forEach(e=>{var t;(t=r.getRenderById(e))==null||(t=t.scene.getTransformer())==null||t.debounceRefreshControls()}),!0}},Yn={id:`sheet.command.remove-sheet-image`,type:A.COMMAND,handler:(e,t)=>{var n;let r=e.get(L),i=e.get(me),a=e.get(wt),o=e.get(V);if(!t)return!1;let{drawings:s}=t,c=[];s.forEach(e=>{let{unitId:t}=e;c.push(t)});let{unitId:l,subUnitId:u,undo:d,redo:f,objects:p}=o.getBatchRemoveOp(s),m=a.onCommandExecute({id:Yn.id,params:t}),h={id:H.id,params:{unitId:l,subUnitId:u,op:f,objects:p,type:B.REMOVE}},g={id:H.id,params:{unitId:l,subUnitId:u,op:d,objects:p,type:B.INSERT}};if(ze([...(n=m.preRedos)==null?[]:n,h,...m.redos],r)){var _,v;return i.pushUndoRedo({unitID:l,undoMutations:[...(_=m.preUndos)==null?[]:_,g,...m.undos,{id:X.id,params:c}],redoMutations:[...(v=m.preRedos)==null?[]:v,h,...m.redos,{id:X.id,params:c}]}),!0}return!1}},Xn={id:`sheet.command.delete-drawing`,type:A.COMMAND,handler:e=>{let t=e.get(L),n=e.get(V).getFocusDrawings();if(n.length===0)return!1;let r=n[0].unitId,i=n.map(e=>{let{unitId:t,subUnitId:n,drawingId:r,drawingType:i}=e;return{unitId:t,subUnitId:n,drawingId:r,drawingType:i}});return t.executeCommand(Yn.id,{unitId:r,drawings:i})}};function Zn(e){let t=[];return e.forEach(e=>{let{parent:n,children:r}=e,{unitId:i,subUnitId:a,drawingId:o}=n,s=c(0,0,r.map(e=>e.transform||{})),l=r.map(e=>{let t=e.transform||{left:0,top:0},{unitId:n,subUnitId:r,drawingId:i}=e;return{unitId:n,subUnitId:r,drawingId:i,transform:{...t,left:t.left,top:t.top},groupId:o}}),u={unitId:i,subUnitId:a,drawingId:o,drawingType:I.DRAWING_GROUP,groupBaseBound:{...n.groupBaseBound},transform:s};t.push({parent:u,children:l})}),t}function Qn(e){let t=[];return e.forEach(e=>{let{parent:n,children:r}=e,{unitId:i,subUnitId:a,drawingId:o,transform:s={width:0,height:0}}=n;if(s==null)return;let c=r.map(e=>{let{transform:t}=e,{unitId:r,subUnitId:i,drawingId:a}=e;return{unitId:r,subUnitId:i,drawingId:a,transform:u(t||{},s,s.width||0,s.height||0,n.groupBaseBound),groupId:void 0}}),l={unitId:i,subUnitId:a,drawingId:o,drawingType:I.DRAWING_GROUP,transform:{left:0,top:0}};t.push({parent:l,children:c})}),t}function $n(e){var t;let n=new Map;(t=e.flatChildren)==null||t.forEach(e=>n.set(e.drawingId,Ie(10))),e.groups.forEach(e=>n.set(e.drawingId,Ie(10)));let r={};for(let[t,o]of Object.entries(e.nestedIdRecord)){var i,a;let e=(i=n.get(t))==null?t:i;r[e]={drawingId:e,children:(a=o.children)==null?void 0:a.map(e=>{var t;return(t=n.get(e))==null?e:t})}}let o=[],s=[];for(let t of e.groups){var c,l;let e=(c=n.get(t.drawingId))==null?t.drawingId:c,r=t.groupId?(l=n.get(t.groupId))==null?t.groupId:l:void 0;s.push(er(t,e,r))}for(let t of e.flatChildren||[]){var u,d;let e=(u=n.get(t.drawingId))==null?t.drawingId:u,r=t.groupId?(d=n.get(t.groupId))==null?t.groupId:d:void 0;o.push(er(t,e,r))}return{cloned:{nestedIdRecord:r,flatChildren:o,groups:s},idMap:n}}function er(e,t,n){let r={...e};return t&&(r.drawingId=t),n?r.groupId=n:delete r.groupId,JSON.parse(JSON.stringify(r))}const tr={id:`sheet.command.group-sheet-image`,type:A.COMMAND,handler:(e,t)=>{let n=e.get(L),r=e.get(me),i=e.get(V);if(!t)return!1;let a=[];t.forEach(({parent:e,children:t})=>{a.push(e.unitId),t.forEach(e=>{a.push(e.unitId)})});let{unitId:o,subUnitId:s,undo:c,redo:l,objects:u}=i.getGroupDrawingOp(t);return n.syncExecuteCommand(H.id,{op:l,unitId:o,subUnitId:s,objects:u,type:B.GROUP})?(r.pushUndoRedo({unitID:o,undoMutations:[{id:H.id,params:{op:c,unitId:o,subUnitId:s,objects:Qn(u),type:B.UNGROUP}},{id:X.id,params:a}],redoMutations:[{id:H.id,params:{op:l,unitId:o,subUnitId:s,objects:u,type:B.GROUP}},{id:X.id,params:a}]}),!0):!1}},nr={id:`sheet.command.insert-sheet-image`,type:A.COMMAND,handler:(e,t)=>{var n;let r=e.get(L),i=e.get(me),a=e.get(V),o=e.get(wt);if(!t)return!1;let s=t.drawings,c=s.map(e=>e.unitId),{unitId:l,subUnitId:u,undo:d,redo:f,objects:p}=a.getBatchAddOp(s),m=o.onCommandExecute({id:nr.id,params:t}),h={id:H.id,params:{op:f,unitId:l,subUnitId:u,objects:p,type:B.INSERT}},g={id:H.id,params:{op:d,unitId:l,subUnitId:u,objects:p,type:B.REMOVE}};if(ze([...(n=m.preRedos)==null?[]:n,h,...m.redos],r)){var _,v;return i.pushUndoRedo({unitID:l,undoMutations:[...(_=m.preUndos)==null?[]:_,g,...m.undos,{id:X.id,params:c}],redoMutations:[...(v=m.preRedos)==null?[]:v,h,...m.redos,{id:X.id,params:c}]}),!0}return!1}},rr={id:`sheet.command.set-drawing-arrange`,type:A.COMMAND,handler:(e,t)=>{let n=e.get(L),r=e.get(me);if(!t)return!1;let i=e.get(V),{unitId:a,subUnitId:o,drawingIds:s,arrangeType:c}=t,l={unitId:a,subUnitId:o,drawingIds:s},u;if(c===O.forward?u=i.getForwardDrawingsOp(l):c===O.backward?u=i.getBackwardDrawingOp(l):c===O.front?u=i.getFrontDrawingsOp(l):c===O.back&&(u=i.getBackDrawingsOp(l)),u==null)return!1;let{objects:d,redo:f,undo:p}=u;return n.syncExecuteCommand(H.id,{op:f,unitId:a,subUnitId:o,objects:d,type:B.ARRANGE})?(r.pushUndoRedo({unitID:a,undoMutations:[{id:H.id,params:{op:p,unitId:a,subUnitId:o,objects:d,type:B.ARRANGE}}],redoMutations:[{id:H.id,params:{op:f,unitId:a,subUnitId:o,objects:d,type:B.ARRANGE}}]}),!0):!1}},ir={id:`sheet.command.set-sheet-image`,type:A.COMMAND,handler:(e,t)=>{var n,r;let i=e.get(L),a=e.get(me),o=e.get(V),s=e.get(wt);if(!t)return!1;let{drawings:c}=t,{unitId:l,subUnitId:u,undo:d,redo:f,objects:p}=o.getBatchUpdateOp(c),m=s.onCommandExecute({id:ir.id,params:t}),h=[...(n=m.preRedos)==null?[]:n,{id:H.id,params:{unitId:l,subUnitId:u,op:f,objects:p,type:B.UPDATE}},...m.redos,{id:X.id,params:[l]}],g=[...(r=m.preUndos)==null?[]:r,{id:H.id,params:{unitId:l,subUnitId:u,op:d,objects:p,type:B.UPDATE}},...m.undos,{id:X.id,params:[l]}];return ze(h,i)?(a.pushUndoRedo({unitID:l,undoMutations:g,redoMutations:h}),!0):!1}},ar={id:`sheet.command.ungroup-sheet-image`,type:A.COMMAND,handler:(e,t)=>{let n=e.get(L),r=e.get(me),i=e.get(V);if(!t)return!1;let a=[];t.forEach(({parent:e,children:t})=>{a.push(e.unitId),t.forEach(e=>{a.push(e.unitId)})});let{unitId:o,subUnitId:s,undo:c,redo:l,objects:u}=i.getUngroupDrawingOp(t);return n.syncExecuteCommand(H.id,{op:l,unitId:o,subUnitId:s,objects:u,type:B.UNGROUP})?(r.pushUndoRedo({unitID:o,undoMutations:[{id:H.id,params:{op:c,unitId:o,subUnitId:s,objects:Zn(u),type:B.GROUP}},{id:X.id,params:a}],redoMutations:[{id:H.id,params:{op:l,unitId:o,subUnitId:s,objects:u,type:B.UNGROUP}},{id:X.id,params:a}]}),!0):!1}};function or(e){"@babel/helpers - typeof";return or=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},or(e)}function sr(e,t){if(or(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(or(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function cr(e){var t=sr(e,`string`);return or(t)==`symbol`?t:t+``}function Z(e,t,n){return(t=cr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Q(e,t){return function(n,r){t(n,r,e)}}function $(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function lr(e,t,n){let r=n*Math.PI/180;return{rotatedWidth:Math.abs(e*Math.cos(r))+Math.abs(t*Math.sin(r)),rotatedHeight:Math.abs(e*Math.sin(r))+Math.abs(t*Math.cos(r))}}function ur(e,t,r,i,a){var o;let{rotatedHeight:s,rotatedWidth:c}=lr(r,i,a),l=e.get(n).getRenderById(t.unitId);if(!l)return!1;let u=(o=l.with(C).getSkeletonParam(t.subUnitId))==null?void 0:o.skeleton;if(u==null)return!1;let d=u.getCellByIndex(t.row,t.col),f=d.mergeInfo.endX-d.mergeInfo.startX-2,p=d.mergeInfo.endY-d.mergeInfo.startY-2,m=c/s,h=Math.ceil(Math.min(f,p*m))/c,g=!h||Number.isNaN(h)?.001:h;return{width:r*g,height:i*g}}let dr=class extends F{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._context=e,this._skeletonManagerService=t,this._commandService=n,this._selectionRenderService=r,this._imageIoService=i,this._fileOpenerService=a,this._sheetDrawingService=o,this._drawingManagerService=s,this._contextService=c,this._messageService=l,this._localeService=u,this._injector=f,this._urlImageService=p,Z(this,`_workbookSelections`,void 0),this._workbookSelections=d.getWorkbookSelections(this._context.unitId),this._updateDrawingListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){let e=await this._fileOpenerService.openFile({multiple:!0,accept:Gt.map(e=>`.${e.replace(`image/`,``)}`).join(`,`)}),t=e.length;return t>qt?(this._messageService.show({type:Ft.Error,content:this._localeService.t(`update-status.exceedMaxCount`,String(qt))}),!1):t===0?!1:(e.forEach(async e=>await this.insertFloatImageByFile(e)),!0)}async insertCellImage(){let e=(await this._fileOpenerService.openFile({multiple:!1,accept:Gt.map(e=>`.${e.replace(`image/`,``)}`).join(`,`)}))[0];return e?(await this._insertCellImage(e),!0):!1}insertCellImageByFile(e,t){return this._insertCellImage(e,t)}async insertFloatImageByFile(e){var t;let n;try{n=await this._imageIoService.saveImage(e)}catch(e){let t=e.message;t===Qt.ERROR_EXCEED_SIZE?this._messageService.show({type:Ft.Error,content:this._localeService.t(`update-status.exceedMaxSize`,String(Kt/(1024*1024)))}):t===Qt.ERROR_IMAGE_TYPE?this._messageService.show({type:Ft.Error,content:this._localeService.t(`update-status.invalidImageType`)}):t===Qt.ERROR_IMAGE&&this._messageService.show({type:Ft.Error,content:this._localeService.t(`update-status.invalidImage`)})}if(n==null)return;let{unitId:r,subUnitId:i}=this._getUnitInfo(),{imageId:a,imageSourceType:o,source:s,base64Cache:c}=n,{width:l,height:u,image:d}=await nn(c||``),{width:f,height:p}=this._context.scene;this._imageIoService.addImageSourceCache(s,o,d);let m=1;if(l>Yt||u>Jt){let e=Yt/l,t=Jt/u;m=Math.max(e,t)}let h=this._getImagePosition(l*m,u*m,f,p);if(h==null)return;let g=q(h,this._selectionRenderService,this._skeletonManagerService),_={unitId:r,subUnitId:i,drawingId:a,drawingType:I.DRAWING_IMAGE,imageSourceType:o,source:s,transform:g,sheetTransform:h,axisAlignSheetTransform:(t=Y(g,this._selectionRenderService))==null?h:t};return this._commandService.executeCommand(nr.id,{unitId:r,drawings:[_]})}async _insertCellImage(e,t){let n;try{n=await this._imageIoService.saveImage(e)}catch(e){let t=e.message;t===Qt.ERROR_EXCEED_SIZE?this._messageService.show({type:Ft.Error,content:this._localeService.t(`update-status.exceedMaxSize`,String(Kt/(1024*1024)))}):t===Qt.ERROR_IMAGE_TYPE?this._messageService.show({type:Ft.Error,content:this._localeService.t(`update-status.invalidImageType`)}):t===Qt.ERROR_IMAGE&&this._messageService.show({type:Ft.Error,content:this._localeService.t(`update-status.invalidImage`)})}if(n==null)return!1;let{imageId:r,imageSourceType:i,source:a,base64Cache:o}=n,{width:s,height:c,image:l}=await nn(o||``);this._imageIoService.addImageSourceCache(a,i,l);let u=this._workbookSelections.getCurrentLastSelection();if(!u)return!1;let d=u.primary.actualRow,f=u.primary.actualColumn;u.primary.isMerged&&(d=u.primary.startRow,f=u.primary.startColumn);let p=Ne(``,{}),m=ur(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:d,col:f},s,c,0);if(!m)return!1;let h={size:{width:m.width,height:m.height},positionH:{relativeFrom:Ce.PAGE,posOffset:0},positionV:{relativeFrom:we.PARAGRAPH,posOffset:0},angle:0},g={unitId:p.getUnitId(),subUnitId:p.getUnitId(),drawingId:r,drawingType:I.DRAWING_IMAGE,imageSourceType:i,source:a,transform:Wt(h),docTransform:h,behindDoc:te.FALSE,title:``,description:``,layoutType:De.INLINE,wrapText:Me.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},_=k.drawing.add({documentDataModel:p,drawings:[g],selection:{collapsed:!0,startOffset:0,endOffset:0}});if(_){var v,y;return p.apply(_),this._commandService.syncExecuteCommand(dt.id,{value:{[(v=t==null?void 0:t.row)==null?d:v]:{[(y=t==null?void 0:t.col)==null?f:y]:{p:p.getSnapshot(),t:1}}},unitId:t==null?void 0:t.unitId,subUnitId:t==null?void 0:t.subUnitId})}return!1}async insertCellImageByUrl(e,t){let n=e;try{n=await this._urlImageService.getImage(e)}catch(t){console.error(`Failed to get image from URLImageService: ${e}`,t)}let{width:r,height:i,image:a}=await nn(n||``);this._imageIoService.addImageSourceCache(e,ge.URL,a);let o=this._workbookSelections.getCurrentLastSelection();if(!o)return!1;let s=Ne(``,{}),c=ur(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:o.primary.actualRow,col:o.primary.actualColumn},r,i,0);if(!c)return!1;let l={size:{width:c.width,height:c.height},positionH:{relativeFrom:Ce.PAGE,posOffset:0},positionV:{relativeFrom:we.PARAGRAPH,posOffset:0},angle:0},u={unitId:s.getUnitId(),subUnitId:s.getUnitId(),drawingId:Ie(),drawingType:I.DRAWING_IMAGE,imageSourceType:ge.URL,source:e,transform:Wt(l),docTransform:l,behindDoc:te.FALSE,title:``,description:``,layoutType:De.INLINE,wrapText:Me.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},d=k.drawing.add({documentDataModel:s,drawings:[u],selection:{collapsed:!0,startOffset:0,endOffset:0}});if(d){var f,p;return s.apply(d),this._commandService.syncExecuteCommand(dt.id,{value:{[(f=t==null?void 0:t.row)==null?o.primary.actualRow:f]:{[(p=t==null?void 0:t.col)==null?o.primary.actualColumn:p]:{p:s.getSnapshot(),t:1}}},unitId:t==null?void 0:t.unitId,subUnitId:t==null?void 0:t.subUnitId})}return!1}_getUnitInfo(){let e=this._context.unit,t=e.getActiveSheet();return{unitId:e.getUnitId(),subUnitId:t.getSheetId()}}_getImagePosition(e,t,n,r){let i=this._workbookSelections.getCurrentSelections(),a={startRow:0,endRow:0,startColumn:0,endColumn:0};i&&i.length>0&&(a=i[i.length-1].range);let o=w(this._skeletonManagerService.getCurrent().skeleton,a);if(o==null)return;let{startColumn:s,startRow:c,startX:l,startY:u}=o,d=!1;if(l+e>n&&(l=n-e,l<0&&(l=0,e=n),d=!0),u+t>r&&(u=r-t,u<0&&(u=0,t=r),d=!0),d){let e=this._selectionRenderService.getCellWithCoordByOffset(l,u);if(e==null)return;l=e.startX,u=e.startY,s=e.actualColumn,c=e.actualRow}let f={column:s,columnOffset:0,row:c,rowOffset:0},p=this._selectionRenderService.getCellWithCoordByOffset(l+e,u+t);if(p!=null)return{from:f,to:{column:p.actualColumn,columnOffset:l+e-p.startX,row:p.actualRow,rowOffset:u+t-p.startY}}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(e=>{let{unitId:t,subUnitId:n,drawingIds:r,arrangeType:i}=e;this._commandService.executeCommand(rr.id,{unitId:t,subUnitId:n,drawingIds:r,arrangeType:i})}))}_updateDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(e=>{let t=[];e.length!==0&&(e.forEach(e=>{let{unitId:n,subUnitId:r,drawingId:i,drawingType:a,transform:o}=e;if(o==null)return;let s=this._sheetDrawingService.getDrawingByParam({unitId:n,subUnitId:r,drawingId:i});if(s==null||s.unitId!==this._context.unitId)return;let c=J({...s.transform,...o},this._selectionRenderService),l=Y({...s.transform,...o},this._selectionRenderService);if(c==null||l==null)return;let u={...e,transform:{...s.transform,...o,...q(c,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...c},axisAlignSheetTransform:{...l}};t.push(u)}),t.length>0&&this._commandService.executeCommand(ir.id,{unitId:e[0].unitId,drawings:t}))}))}_getSheetTransformByParam(e,t){let{unitId:n,subUnitId:r,drawingId:i,transform:a}=e;if(a==null)return null;let o=this._sheetDrawingService.getDrawingByParam({unitId:n,subUnitId:r,drawingId:i}),s=o==null?void 0:o.transform;if(t&&(s={}),!t&&(o==null||o.unitId!==this._context.unitId))return null;let c=J({...s,...a},this._selectionRenderService),l=Y({...s,...a},this._selectionRenderService);return c==null||l==null?null:{sheetTransform:c,axisAlignSheetTransform:l}}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(e=>{let t=[];for(let n of e){let e=this._getSheetTransformByParam(n.parent,!0),r=[];for(let e of n.children){let t=this._getSheetTransformByParam(e,!1);t!=null&&r.push({...e,sheetTransform:t.sheetTransform,axisAlignSheetTransform:t.axisAlignSheetTransform})}let i={parent:{...n.parent,sheetTransform:e==null?void 0:e.sheetTransform,axisAlignSheetTransform:e==null?void 0:e.axisAlignSheetTransform},children:r};t.push(i)}if(t.length>0){this._commandService.executeCommand(tr.id,t);let{unitId:n,subUnitId:r,drawingId:i}=e[0].parent;this._commandService.syncExecuteCommand($t.id,[{unitId:n,subUnitId:r,drawingId:i}])}})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(e=>{let t=[];for(let n of e){let{children:e}=n,r=[];for(let t of e){let e=this._getSheetTransformByParam(t,!1);e!=null&&r.push({...t,sheetTransform:e.sheetTransform,axisAlignSheetTransform:e.axisAlignSheetTransform})}t.push({...n,children:r})}this._commandService.executeCommand(ar.id,t)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(e=>{e==null||e.length===0?(this._contextService.setContextValue(ie,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(ie,!0),this._sheetDrawingService.focusDrawing(e))}))}};dr=$([Q(1,R(C)),Q(2,L),Q(3,g),Q(4,Xt),Q(5,dn),Q(6,V),Q(7,G),Q(8,ue),Q(9,pn),Q(10,R(xe)),Q(11,R(Tt)),Q(12,R(_e)),Q(13,pe)],dr);const fr={id:`sheet.command.insert-float-image`,type:A.COMMAND,handler:async(e,t)=>{var r;let i=e.get(he),a=e.get(n),o=(r=s(z.UNIVER_SHEET,i,a))==null?void 0:r.with(dr);if(!o)return!1;let c=t==null?void 0:t.files;if(c){let e=c.map(e=>o.insertFloatImageByFile(e));return(await Promise.all(e)).every(e=>e)}else{var l;return(l=o.insertFloatImage())==null?!1:l}}},pr={id:`sheet.command.insert-cell-image`,type:A.COMMAND,handler:e=>{var t,r;let i=e.get(he),a=e.get(n);return(t=(r=s(z.UNIVER_SHEET,i,a))==null?void 0:r.with(dr).insertCellImage())==null?!1:t}},mr={id:`sheet.command.move-drawing`,type:A.COMMAND,handler:(e,t)=>{let n=e.get(L),r=e.get(V),i=e.get(g),{direction:a}=t,o=r.getFocusDrawings();if(o.length===0)return!1;let s=o[0].unitId,c=o.map(e=>{let{transform:t}=e;if(t==null)return null;let n={...t},{left:r=0,top:o=0}=t;return a===P.UP?n.top=o-1:a===P.DOWN?n.top=o+1:a===P.LEFT?n.left=r-1:a===P.RIGHT&&(n.left=r+1),{...e,transform:n,sheetTransform:J(n,i),axisAlignSheetTransform:Y(n,i)}}).filter(e=>e!=null);return n.syncExecuteCommand(ir.id,{unitId:s,drawings:c})?(n.syncExecuteCommand(X.id,[s]),!0):!1}};let hr=function(e){return e.CELL_ADDRESS=`cellAddress`,e.COLUMN_VALUE=`columnValue`,e}({});const gr=Pe(`sheets-drawing-ui.batch-save-images.service`);function _r(e){let t=``,n=e;for(;n>=0;)t=String.fromCharCode(n%26+65)+t,n=Math.floor(n/26)-1;return t}function vr(e,t){return`${_r(t)}${e+1}`}function yr(e){let t=vr(e.startRow,e.startColumn),n=vr(e.endRow,e.endColumn);return t===n?t:`${t}:${n}`}function br(e){var t,n;return!!(!(e==null||(t=e.p)==null||(t=t.drawingsOrder)==null)&&t.length&&(e==null||(n=e.p)==null||(n=n.drawingsOrder)==null?void 0:n.length)>0)}function xr(e){var t,n;if(!(!((t=e.p)==null||(t=t.drawingsOrder)==null)&&t.length)||!((n=e.p)!=null&&n.drawings))return null;let r=e.p.drawingsOrder[0],i=e.p.drawings[r];return!i||!(`source`in i)||!(`imageSourceType`in i)?null:i}function Sr(e,t){if(t===ge.BASE64){let t=e.match(/^data:image\/(\w+);/);if(t)return t[1]===`jpeg`?`jpg`:t[1]}if(t===ge.URL){let t=e.match(/\.(\w+)(?:\?|$)/);if(t)return t[1].toLowerCase()}return`png`}async function Cr(e,t){if(t===ge.BASE64||t===ge.URL)return(await fetch(e)).blob();throw Error(`UUID image type requires additional handling`)}let wr=class extends F{constructor(e,t,n,r){super(),this._univerInstanceService=e,this._selectionService=t,this._imageIoService=n,this._urlImageService=r}registerURLImageDownloader(e){return this._urlImageService.registerURLImageDownloader(e)}getCellImagesInSelection(){let e=this._univerInstanceService.getCurrentUnitForType(z.UNIVER_SHEET);if(!e)return[];let t=e.getActiveSheet();if(!t)return[];let n=this._selectionService.getCurrentSelections();if(!n||n.length===0)return[];let r=t.getCellMatrix(),i=[];for(let e of n){let{startRow:t,endRow:n,startColumn:a,endColumn:o}=e.range;for(let e=t;e<=n;e++)for(let t=a;t<=o;t++){let n=r.getValue(e,t);if(br(n)){let r=xr(n);r&&i.push({row:e,col:t,cellAddress:vr(e,t),source:r.source,imageSourceType:r.imageSourceType,imageId:r.drawingId})}}}return i}getCellImagesFromRanges(e,t,n){let r=this._univerInstanceService.getUnit(e,z.UNIVER_SHEET);if(!r)return[];let i=r.getSheetBySheetId(t);if(!i)return[];let a=i.getCellMatrix(),o=[];for(let e of n){let{startRow:t,endRow:n,startColumn:r,endColumn:i}=e;for(let e=t;e<=n;e++)for(let t=r;t<=i;t++){let n=a.getValue(e,t);if(br(n)){let r=xr(n);r&&o.push({row:e,col:t,cellAddress:vr(e,t),source:r.source,imageSourceType:r.imageSourceType,imageId:r.drawingId})}}}return o}getDataColumns(){let e=this._univerInstanceService.getCurrentUnitForType(z.UNIVER_SHEET);if(!e)return[];let t=e.getActiveSheet();if(!t)return[];let n=this._selectionService.getCurrentSelections();if(!n||n.length===0)return[];let r=t.getCellMatrix(),i=r.getDataRange(),a=1/0,o=-1/0,s=new Set;for(let e of n){a=Math.min(a,e.range.startRow),o=Math.max(o,e.range.endRow);for(let t=e.range.startColumn;t<=e.range.endColumn;t++)s.add(t)}let c=new Set;for(let e=i.startColumn;e<=i.endColumn;e++)if(!s.has(e))for(let t=a;t<=o;t++){let n=r.getValue(t,e);if(n){var l,u;if((l=n.v)!=null&&l.toString()||!((u=n.p)==null||(u=u.body)==null||(u=u.dataStream)==null)&&u.trim()){c.add(e);break}}}let d=[],f=Array.from(c).sort((e,t)=>e-t);for(let e of f)d.push({index:e,label:_r(e)});return d}getDataColumnsForRanges(e,t,n){let r=this._univerInstanceService.getUnit(e,z.UNIVER_SHEET);if(!r)return[];let i=r.getSheetBySheetId(t);if(!i)return[];let a=i.getCellMatrix(),o=a.getDataRange(),s=1/0,c=-1/0,l=new Set;for(let e of n){s=Math.min(s,e.startRow),c=Math.max(c,e.endRow);for(let t=e.startColumn;t<=e.endColumn;t++)l.add(t)}let u=new Set;for(let e=o.startColumn;e<=o.endColumn;e++)if(!l.has(e))for(let t=s;t<=c;t++){let n=a.getValue(t,e);if(n){var d,f;if((d=n.v)!=null&&d.toString()||!((f=n.p)==null||(f=f.body)==null||(f=f.dataStream)==null)&&f.trim()){u.add(e);break}}}let p=[],m=Array.from(u).sort((e,t)=>e-t);for(let e of m)p.push({index:e,label:_r(e)});return p}getSelectionRangeNotation(){let e=this._selectionService.getCurrentSelections();return!e||e.length===0?``:e.map(e=>yr(e.range)).join(`, `)}getSelectionRowRange(){let e=this._selectionService.getCurrentSelections();if(!e||e.length===0)return null;let t=1/0,n=-1/0;for(let r of e)t=Math.min(t,r.range.startRow),n=Math.max(n,r.range.endRow);return{startRow:t,endRow:n}}getSelectionColumnIndices(){let e=this._selectionService.getCurrentSelections();if(!e||e.length===0)return new Set;let t=new Set;for(let n of e)for(let e=n.range.startColumn;e<=n.range.endColumn;e++)t.add(e);return t}generateFileName(e,t){let n=this._univerInstanceService.getCurrentUnitForType(z.UNIVER_SHEET),r=Sr(e.source,e.imageSourceType),i=[];for(let r of t.fileNameParts)if(r===hr.CELL_ADDRESS)i.push(e.cellAddress);else if(r===hr.COLUMN_VALUE&&t.columnIndex!==void 0){let r=n==null?void 0:n.getActiveSheet();if(r){let n=r.getCellMatrix().getValue(e.row,t.columnIndex);if(n){var a,o;let e=((a=n.v)==null?void 0:a.toString())||((o=n.p)==null||(o=o.body)==null||(o=o.dataStream)==null?void 0:o.trim())||``;if(e){let t=e.replace(/[<>:"/\\|?*]/g,`_`).trim();t&&i.push(t)}}}}return i.length===0?`${e.cellAddress}.${r}`:`${i.join(`_`)}.${r}`}generateFileNameWithContext(e,t,n,r){let i=this._univerInstanceService.getUnit(n,z.UNIVER_SHEET),a=Sr(e.source,e.imageSourceType),o=[];for(let n of t.fileNameParts)if(n===hr.CELL_ADDRESS)o.push(e.cellAddress);else if(n===hr.COLUMN_VALUE&&t.columnIndex!==void 0){let n=i==null?void 0:i.getSheetBySheetId(r);if(n){let r=n.getCellMatrix().getValue(e.row,t.columnIndex);if(r){var s,c;let e=((s=r.v)==null?void 0:s.toString())||((c=r.p)==null||(c=c.body)==null||(c=c.dataStream)==null?void 0:c.trim())||``;if(e){let t=e.replace(/[<>:"/\\|?*]/g,`_`).trim();t&&o.push(t)}}}}return o.length===0?`${e.cellAddress}.${a}`:`${o.join(`_`)}.${a}`}async saveImages(e,t){let n=await window.showDirectoryPicker({mode:`readwrite`}),r=new Map;for(let a of e){var i;let e=this.generateFileName(a,t),o=e.replace(/\.\w+$/,``),s=((i=e.match(/\.\w+$/))==null?void 0:i[0])||`.png`,c=r.get(o)||0;c>0&&(e=`${o}_${c}${s}`),r.set(o,c+1);try{let t=await this._getImageBlob(a),r=await(await n.getFileHandle(e,{create:!0})).createWritable();await r.write(t),await r.close()}catch(t){throw console.error(`Failed to save image ${e}:`,t),t}}}async saveImagesWithContext(e,t,n,r){let i=await window.showDirectoryPicker({mode:`readwrite`}),a=new Map;for(let s of e){var o;let e=this.generateFileNameWithContext(s,t,n,r),c=e.replace(/\.\w+$/,``),l=((o=e.match(/\.\w+$/))==null?void 0:o[0])||`.png`,u=a.get(c)||0;u>0&&(e=`${c}_${u}${l}`),a.set(c,u+1);try{let t=await this._getImageBlob(s),n=await(await i.getFileHandle(e,{create:!0})).createWritable();await n.write(t),await n.close()}catch(t){throw console.error(`Failed to save image ${e}:`,t),t}}}async downloadSingleImage(e){let t=Sr(e.source,e.imageSourceType),n=`${e.cellAddress}.${t}`;try{let t=await this._getImageBlob(e),r=URL.createObjectURL(t),i=document.createElement(`a`);i.href=r,i.download=n,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}catch(e){throw console.error(`Failed to download image ${n}:`,e),e}}async _getImageBlob(e){return e.imageSourceType===ge.UUID?Cr(await this._imageIoService.getImage(e.source),ge.URL):e.imageSourceType===ge.URL?this._urlImageService.downloadImage(e.source):Cr(e.source,e.imageSourceType)}};wr=$([Q(0,he),Q(1,R(Tt)),Q(2,de),Q(3,pe)],wr);const Tr=`sheet.dialog.batch-save-images`,Er={id:`sheet.command.save-cell-images`,type:A.COMMAND,handler:async e=>{let t=e.get(un),n=e.get(gr),r=n.getCellImagesInSelection();if(r.length===1)try{return await n.downloadSingleImage(r[0]),!0}catch(e){return console.error(`Failed to download image:`,e),!1}let i=e.get(xe),a=n.getSelectionRangeNotation(),o=`${i.t(`sheetImage.save.title`)} (${a})`;return t.open({id:Tr,draggable:!0,width:360,title:{title:o},children:{label:Tr},destroyOnClose:!0,preservePositionOnDestroy:!0,onClose:()=>t.close(Tr)}),!0}},Dr=`COMPONENT_SHEET_DRAWING_PANEL`,Or={id:`sidebar.operation.sheet-image`,type:A.COMMAND,handler:async(e,t)=>{let n=e.get(hn),r=e.get(xe),i=e.get(he),a=e.get(L);if(!W(i))return!1;switch(t.value){case`open`:n.open({header:{title:r.t(`sheetImage.panel.title`)},children:{label:Dr},onClose:()=>{a.syncExecuteCommand($t.id,[])},width:360});break;default:n.close();break}return!0}},kr={id:`sheet.operation.edit-sheet-image`,type:A.OPERATION,handler:(e,t)=>{let n=e.get(L);return t==null?!1:(n.syncExecuteCommand($t.id,[t]),n.executeCommand(Or.id,{value:`open`}),!0)}},Ar=[_.SPECIAL_PASTE_COL_WIDTH,_.SPECIAL_PASTE_VALUE,_.SPECIAL_PASTE_FORMAT,_.SPECIAL_PASTE_FORMULA];let jr=class extends F{constructor(e,t,n,r){super(),this._sheetClipboardService=e,this._renderManagerService=t,this._sheetDrawingService=n,this._drawingManagerService=r,Z(this,`_featurePasteHooks`,[]),Z(this,`_copyInfo`,void 0),this._initCopyPaste()}get _focusedDrawings(){return this._sheetDrawingService.getFocusDrawings()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:`SHEET_DRAWING_GROUP`,onBeforeCopy:(e,t)=>{this._copyInfo=null;let n=this._focusedDrawings;if(n.length===0)return;let r=n.find(e=>e.drawingType===I.DRAWING_GROUP);if(!r)return;let i=this._drawingManagerService.getDrawingsByGroupNested({unitId:r.unitId,subUnitId:r.subUnitId,drawingId:r.drawingId});i&&(this._copyInfo={unitId:r.unitId,subUnitId:r.subUnitId,groupNestedParam:i})},onPasteCells:(e,t,n,r)=>{if(!this._copyInfo)return{redos:[],undos:[]};let{pasteType:i}=r;return Ar.includes(i)?{redos:[],undos:[]}:this._generateGroupPasteMutations(t)},onPasteUnrecognized:e=>this._copyInfo?this._generateGroupPasteMutations(e):{redos:[],undos:[]}})}registerFeaturePasteHook(e){this._featurePasteHooks.push(e)}_getGroupFeaturePasteMutations(e){let t=[],n=[];for(let r of this._featurePasteHooks){let i=r(e);t.push(...i.redos),n.push(...i.undos)}return{redos:t,undos:n}}_generateGroupPasteMutations(e){var t;let{unitId:n,subUnitId:r,range:i}=e,a=this._renderManagerService.getRenderById(n),o=a==null?void 0:a.with(C),s=a==null?void 0:a.with(g);if(!o||!s||!this._copyInfo)return{redos:[],undos:[]};let{groupNestedParam:c}=this._copyInfo,l=c.groups[c.groups.length-1],{cloned:u,idMap:d}=$n(c),f=u.groups[u.groups.length-1].drawingId,p=At(i),m=o.attachRangeWithCoord({startRow:p.startRow,endRow:p.endRow,startColumn:p.startColumn,endColumn:p.endColumn});if(!m)return{redos:[],undos:[]};let h={...l.transform,left:m.startX,top:m.startY},_=[...((t=u.flatChildren)==null?[]:t).map(e=>({...e,unitId:n,subUnitId:r})),...u.groups.map(e=>{var t,i;return e.drawingId===f?{...e,unitId:n,subUnitId:r,transform:h,sheetTransform:(t=J(h,s))==null?l.sheetTransform:t,axisAlignSheetTransform:(i=Y(h,s))==null?l.sheetTransform:i}:{...e,unitId:n,subUnitId:r}})],{undo:v,redo:y,objects:b}=this._sheetDrawingService.getBatchAddOp(_),x=[{id:H.id,params:{op:y,unitId:n,subUnitId:r,objects:b,type:B.INSERT}}],S=[{id:H.id,params:{op:v,unitId:n,subUnitId:r,objects:b,type:B.REMOVE}}],w=this._getGroupFeaturePasteMutations({fromUnitId:this._copyInfo.unitId,fromSubUnitId:this._copyInfo.subUnitId,toUnitId:n,toSubUnitId:r,idMap:d,cloned:u});return x.push(...w.redos),S.push(...w.undos),{redos:x,undos:S}}dispose(){this._copyInfo=null,this._featurePasteHooks.length=0,super.dispose()}};jr=$([Q(0,h),Q(1,n),Q(2,V),Q(3,G)],jr);const Mr=`sheet.menu.image`;function Nr(e){return{id:Mr,type:_n.SUBITEMS,icon:`AddImageIcon`,tooltip:`sheetImage.title`,hidden$:xn(e,z.UNIVER_SHEET),disabled$:E(e,{workbookTypes:[Et],worksheetTypes:[Ot],rangeTypes:[rt]})}}function Pr(e){return{id:fr.id,title:`sheetImage.upload.float`,type:_n.BUTTON,hidden$:xn(e,z.UNIVER_SHEET)}}function Fr(e){return{id:pr.id,title:`sheetImage.upload.cell`,type:_n.BUTTON,hidden$:xn(e,z.UNIVER_SHEET)}}var Ir=`@univerjs/sheets-drawing-ui`,Lr=`0.18.0`;const Rr=`sheets-drawing-ui.config`;Symbol(Rr);const zr={};let Br=class extends ke{constructor(e,t,n,r){super(),this._drawingManagerService=e,this._contextMenuService=t,this._renderManagerService=n,this._univerInstanceService=r,this._init()}_init(){this._univerInstanceService.getAllUnitsForType(z.UNIVER_SHEET).forEach(e=>this._contextMenuListener(e))}_contextMenuListener(e){var t;if(!e)return;let n=(t=this._renderManagerService.getRenderById(e.getUnitId()))==null?void 0:t.scene;if(!n)return;let r=n.getTransformerByCreate();r&&this.disposeWithMe(r.changeEnd$.subscribe(e=>{let{event:t}=e;if(t.button!==2)return;let n=r.getSelectedObjectMap();if(n.size!==0){for(let e of n.values()){let t=e.oKey;if(!this._drawingManagerService.getDrawingOKey(t))return}this._contextMenuService.triggerContextMenu(t,sn.DRAWING)}}))}};Br=$([Q(0,G),Q(1,ln),Q(2,n),Q(3,he)],Br);let Vr=class extends F{constructor(e,t,n,r,i){super(),this._context=e,this._hoverManagerService=t,this._selectionsService=n,this._drawingRenderService=r,this._sheetSkeletonManagerService=i,Z(this,`_isSetCursor`,!1),this._initHover(),this._initImageClick()}_initHover(){this.disposeWithMe(this._hoverManagerService.currentRichTextNoDistinct$.pipe(Un(33)).subscribe(t=>{var n,r;let i=[];t!==null&&(i=this._selectionsService.getWorkbookSelections(this._context.unitId).getCurrentSelections()),i.length>0&&(t==null?void 0:t.unitId)===this._context.unitId&&t!=null&&t.drawing&&i.length===1&&((n=i[0].primary)==null?void 0:n.actualRow)===t.row&&((r=i[0].primary)==null?void 0:r.actualColumn)===t.col?(this._isSetCursor=!0,this._context.scene.setCursor(e.ZOOM_IN)):this._isSetCursor&&(this._isSetCursor=!1,this._context.scene.resetCursor())}))}_initImageClick(){this.disposeWithMe(this._hoverManagerService.currentClickedCell$.subscribe(e=>{if(e!=null&&e.drawing&&this._isSetCursor){var t;let n=e.drawing.drawing.drawingOrigin,r=(t=this._sheetSkeletonManagerService.getCurrentSkeleton())==null?void 0:t.imageCacheMap.getImage(n.imageSourceType,n.source);if(!r)return;this._drawingRenderService.previewImage(`preview-cell-image`,r.src,r.width,r.height),this._context.scene.resetCursor(),this._isSetCursor=!1}}))}};Vr=$([Q(1,R(p)),Q(2,R(Tt)),Q(3,R(Dn)),Q(4,R(C))],Vr);let Hr=class extends F{constructor(e,t,n,r,i){super(),this._context=e,this._sheetDrawingService=t,this._drawingManagerService=n,this._sheetSelectionRenderService=r,this._sheetSkeletonManagerService=i,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);let e=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(let t in e){let n=e[t];for(let e in n.data){let t=n.data[e];t.sheetTransform&&(t.transform=q(t.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService))}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};Hr=$([Q(1,V),Q(2,G),Q(3,R(g)),Q(4,R(C))],Hr);function Ur(e,t,n){var r,i;if((n==null||(r=n.p)==null||(r=r.body)==null?void 0:r.dataStream.length)===3&&((i=n.p)==null||(i=i.drawingsOrder)==null?void 0:i.length)===1){let r=n.p.drawings[n.p.drawingsOrder[0]],i=ur(e,{unitId:t.unitId,subUnitId:t.subUnitId,row:t.row,col:t.col},r.docTransform.size.width,r.docTransform.size.height,r.docTransform.angle);if(i)return r.transform.width=i.width,r.transform.height=i.height,r.docTransform.size.width=i.width,r.docTransform.size.height=i.height,r.transform.left=0,r.transform.top=0,r.docTransform.positionH.posOffset=0,r.docTransform.positionV.posOffset=0,n.p.documentStyle.pageSize.width=1/0,n.p.documentStyle.pageSize.height=1/0,!0}return!1}let Wr=class extends F{constructor(e,t,n,r,i,a){super(),this._commandService=e,this._sheetInterceptorService=t,this._injector=n,this._drawingManagerService=r,this._docDrawingController=i,this._editorBridgeService=a,this._handleInitEditor(),this._initCellContentInterceptor()}_handleInitEditor(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible?e.visible&&(this._drawingManagerService.removeDrawingDataForUnit(M),this._docDrawingController.loadDrawingDataForUnit(M),this._drawingManagerService.initializeNotification(M)):this._drawingManagerService.removeDrawingDataForUnit(M)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{e.id===Ut.id&&e.params.unitId===N&&(this._drawingManagerService.removeDrawingDataForUnit(N),this._docDrawingController.loadDrawingDataForUnit(N),this._drawingManagerService.initializeNotification(N))}))}_initCellContentInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(Je.CELL_CONTENT,{effect:ve.Style,priority:$e.CELL_IMAGE,handler:(e,t,n)=>{var r;return e!=null&&e.p&&(r=e.p.drawingsOrder)!=null&&r.length&&(e===t.rawData&&(e={...t.rawData}),e.interceptorStyle||(e.interceptorStyle={}),e.interceptorStyle.tr={a:0},Ur(this._injector,{unitId:t.unitId,subUnitId:t.subUnitId,row:t.row,col:t.col},e)),n(e)}}))}};Wr=$([Q(0,L),Q(1,R(wt)),Q(2,R(_e)),Q(3,G),Q(4,R(Cn)),Q(5,R(m))],Wr);let Gr=class extends F{constructor(e,t){super(),this._autoFillService=e,this._injector=t,this._initAutoFillHooks()}_initAutoFillHooks(){this.disposeWithMe(this._autoFillService.addHook({id:`sheet-cell-image-autofill`,onBeforeSubmit:(e,t,n,r)=>{new Se(r).forValue((t,n,r)=>{Ur(this._injector,{unitId:e.unitId,subUnitId:e.subUnitId,row:t,col:n},r)})}}))}};Gr=$([Q(0,R(qe)),Q(1,R(_e))],Gr);const Kr=[M,j,N];let qr=class extends F{constructor(e,t,n,r,i){super(),this._commandService=e,this._univerInstanceService=t,this._dialogService=n,this._renderManagerService=r,this._localeService=i,this._initDocImageCopyPasteHooks()}_setCellImage(e){var t;let n=Ne(``,{}),r=(t=s(z.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:t.with(f),i=k.drawing.add({documentDataModel:n,drawings:[e],selection:{collapsed:!0,startOffset:0,endOffset:0}});i&&(n.apply(i),r&&r.submitCellData(n))}_initDocImageCopyPasteHooks(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===Ht.id){var t;let{doc:r}=e.params,i=this._univerInstanceService.getCurrentUnitOfType(z.UNIVER_DOC);if(i==null||!Object.keys((t=r.drawings)==null?{}:t).length)return;let a=i.getUnitId();if(Kr.includes(a)){if(a!==N){var n;let e=()=>{this._dialogService.close(`sheet-cell-image-copy-paste`),this._commandService.syncExecuteCommand(v.id,{visible:!1})};((n=i.getBody())==null?void 0:n.dataStream)===`\r
|
|
2
|
+
`?(this._commandService.syncExecuteCommand(v.id,{visible:!1}),this._setCellImage(Object.values(r.drawings)[0])):this._dialogService.open({id:`sheet-cell-image-copy-paste`,title:{label:this._localeService.t(`cell-image.pasteTitle`)},children:{label:this._localeService.t(`cell-image.pasteContent`)},width:320,destroyOnClose:!0,onClose:e,showOk:!0,showCancel:!0,onOk:()=>{e(),this._setCellImage(Object.values(r.drawings)[0])},onCancel:e})}throw Error(`Sheet cell image copy paste is not supported in this unit`)}}}))}};qr=$([Q(0,L),Q(1,he),Q(2,un),Q(3,n),Q(4,R(xe))],qr);const Jr=`image/png`;function Yr(e){let t=e.split(`,`),n=atob(t[1]),r=n.length,i=new Uint8Array(r);for(let e=0;e<r;e++)i[e]=n.charCodeAt(e);return new Blob([i],{type:Jr})}function Xr(e){let t=new ClipboardItem({[Jr]:Yr(e)});navigator.clipboard.write([t]).catch(e=>{console.error(`Could not copy image using clipboard API: `,e)})}function Zr(){function e(){let e=document.createElement(`input`);return e.style.position=`absolute`,e.style.height=`1px`,e.style.width=`1px`,e.style.opacity=`0`,e}let t=document.activeElement,n=e();return document.body.appendChild(n),n.focus(),()=>{n.blur(),document.body.removeChild(n),t instanceof HTMLElement&&t.focus()}}const Qr=[_.SPECIAL_PASTE_COL_WIDTH,_.SPECIAL_PASTE_VALUE,_.SPECIAL_PASTE_FORMAT,_.SPECIAL_PASTE_FORMULA];let $r=class extends F{constructor(e,t,n,r,i){super(),this._sheetClipboardService=e,this._renderManagerService=t,this._drawingService=n,this._clipboardInterfaceService=r,this._commandService=i,Z(this,`_copyInfo`,void 0),this._initCopyPaste()}get _focusedDrawings(){return this._drawingService.getFocusDrawings()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:`SHEET_IMAGE_UI_PLUGIN`,onBeforeCopy:(e,t,n,r)=>{this._copyInfo=null;let i=this._focusedDrawings;if(i.length>0){let[t]=i;if(t.drawingType!==I.DRAWING_IMAGE)return;if(r===d.CUT){let n={unitId:e,drawings:[t]};this._commandService.executeCommand(Yn.id,n)}setTimeout(()=>{let e=Zr();t.drawingType===I.DRAWING_IMAGE&&t.imageSourceType===Zt.BASE64?Xr(t.source):this._clipboardInterfaceService.writeText(``),e()},200),this._copyInfo={unitId:t.unitId,subUnitId:t.subUnitId,drawings:[t]}}else this._copyInfo=this._createDrawingsCopyInfoByRange(e,t,n)},onPasteCells:(e,t,n,r)=>{if(!this._copyInfo)return{redos:[],undos:[]};let{copyType:i=d.COPY,pasteType:a}=r,{range:o}=e||{},{range:s,unitId:c,subUnitId:l}=t;return this._copyInfo.copyRange?this._generateRangeDrawingsPasteMutations({pasteType:a,unitId:c,subUnitId:l,pasteRange:s},{copyRange:o,copyType:i}):this._generateSingleDrawingPasteMutations({pasteTo:t,pasteType:a},d.COPY)},onPastePlainText:(e,t)=>({undos:[],redos:[]}),onPasteUnrecognized:e=>this._copyInfo?this._generateSingleDrawingPasteMutations({pasteTo:e,pasteType:_.DEFAULT_PASTE},d.COPY):{undos:[],redos:[]},onPasteFiles:(e,t)=>{if(this._copyInfo)return this._generateSingleDrawingPasteMutations({pasteTo:e,pasteType:_.DEFAULT_PASTE},d.COPY);{let e=t.filter(e=>e.type.includes(`image`));if(e.length)return{undos:[],redos:[{id:fr.id,params:{files:e}}]}}return{undos:[],redos:[]}}})}_createDrawingsCopyInfoByRange(e,t,n){var r;let i=(r=this._renderManagerService.getRenderById(e))==null?void 0:r.with(C);if(!i)return;let a=i.attachRangeWithCoord(n);if(!a)return;let{startX:o,endX:s,startY:c,endY:l}=a,u=this._drawingService.getDrawingData(e,t),d=this._focusedDrawings.slice();if(Object.keys(u).forEach(e=>{let t=u[e];if(t.drawingType!==I.DRAWING_IMAGE)return;let{transform:n}=t;if(t.anchorType!==U.Both||!n)return;let{left:r=0,top:i=0,width:a=0,height:f=0}=n,{drawingStartX:p,drawingEndX:m,drawingStartY:h,drawingEndY:g}={drawingStartX:r,drawingEndX:r+a,drawingStartY:i,drawingEndY:i+f};o<=p&&m<=s&&c<=h&&g<=l&&d.push(t)}),d.length)return{copyRange:n,drawings:d,unitId:e,subUnitId:t}}_generateSingleDrawingPasteMutations(e,t){let{pasteType:n,pasteTo:r}=e;if(Qr.includes(n))return{redos:[],undos:[]};let{unitId:i,subUnitId:a,range:o}=r,s=this._renderManagerService.getRenderById(i),c=s==null?void 0:s.with(C),l=s==null?void 0:s.with(g),u=this._copyInfo;if(!c||!l)return{redos:[],undos:[]};let{drawings:f}=u,p=At(o);return this._generateMutations(f,{unitId:i,subUnitId:a,isCut:t===d.CUT,getTransform:(e,t)=>{var n,r;let i=c.attachRangeWithCoord({startRow:p.startRow,endRow:p.endRow,startColumn:p.startColumn,endColumn:p.endColumn}),a={...e,left:i==null?void 0:i.startX,top:i==null?void 0:i.startY};return{transform:a,sheetTransform:(n=J(a,l))==null?t:n,axisAlignSheetTransform:(r=Y(a,l))==null?t:r}}})}_generateMutations(e,t){let{unitId:n,subUnitId:r,getTransform:i,isCut:a}=t,o=[],s=[],{_drawingService:c}=this;return e.forEach(e=>{let{transform:t,sheetTransform:l}=e;if(!t)return;let u=i(t,l),d={...e,unitId:n,subUnitId:r,drawingId:a?e.drawingId:Ie(),transform:u.transform,sheetTransform:u.sheetTransform,axisAlignSheetTransform:u.axisAlignSheetTransform};if(a){let{undo:e,redo:t,objects:i}=c.getBatchUpdateOp([d]);o.push({id:H.id,params:{unitId:n,subUnitId:r,type:B.UPDATE,op:t,objects:i}}),s.push({id:H.id,params:{unitId:n,subUnitId:r,type:B.UPDATE,op:e,objects:i}})}else{let{undo:e,redo:t,objects:i}=c.getBatchAddOp([d]);o.push({id:H.id,params:{op:t,unitId:n,subUnitId:r,objects:i,type:B.INSERT}}),s.push({id:H.id,params:{op:e,unitId:n,subUnitId:r,objects:i,type:B.REMOVE}})}}),{redos:o,undos:s}}_generateRangeDrawingsPasteMutations(e,t){var n;let{unitId:r,subUnitId:i,pasteType:a,pasteRange:o}=e,{copyRange:s,copyType:c}=t;if(Qr.includes(a))return{redos:[],undos:[]};let l=(n=this._renderManagerService.getRenderById(r))==null?void 0:n.with(C);if(!l||!this._copyInfo)return{redos:[],undos:[]};let{drawings:u}=this._copyInfo;if(!s)return this._generateSingleDrawingPasteMutations({pasteTo:{unitId:r,subUnitId:i,range:At(o)},pasteType:a},c);let{ranges:[f,p],mapFunc:m}=ee([s,o]),{row:h,col:_}=m(f.startRow,f.startColumn),{row:v,col:y}=m(p.startRow,p.startColumn),b=l.attachRangeWithCoord({startRow:h,endRow:h,startColumn:_,endColumn:_}),x=l.attachRangeWithCoord({startRow:v,endRow:v,startColumn:y,endColumn:y});if(!b||!x||!this._copyInfo)return{redos:[],undos:[]};let S=x.startX-b.startX,w=x.startY-b.startY,T=v-h,E=y-_;return this._generateMutations(u,{unitId:r,subUnitId:i,getTransform:(e,t)=>{var n,i,a;let o={...e,left:((n=e==null?void 0:e.left)==null?0:n)+S,top:((i=e==null?void 0:e.top)==null?0:i)+w},s=this._renderManagerService.getRenderById(r),c=s==null?void 0:s.with(g);return c?{transform:o,sheetTransform:{...t,to:{...t.to,row:t.to.row+T,column:t.to.column+E},from:{...t.from,row:t.from.row+T,column:t.from.column+E}},axisAlignSheetTransform:(a=Y(o,c))==null?t:a}:{transform:o,sheetTransform:{...t,to:{...t.to,row:t.to.row+T,column:t.to.column+E},from:{...t.from,row:t.from.row+T,column:t.from.column+E}},axisAlignSheetTransform:{...t,to:{...t.to,row:t.to.row+T,column:t.to.column+E},from:{...t.from,row:t.from.row+T,column:t.from.column+E}}}},isCut:c===d.CUT})}};$r=$([Q(0,h),Q(1,n),Q(2,G),Q(3,cn),Q(4,L)],$r);let ei=class extends F{constructor(e,t,n,r,i){super(),this._drawingManagerService=e,this._renderManagerService=t,this._permissionService=n,this._univerInstanceService=r,this._userManagerService=i,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){let e=this._univerInstanceService.getCurrentTypeOfUnit$(z.UNIVER_SHEET),t=this._userManagerService.currentUser$,n=Fn([e,t]);this.disposeWithMe(n.pipe(Bn(([e,t])=>e?e.activeSheet$.pipe(Hn(t=>{if(!t){this._drawingManagerService.setDrawingVisible(!1);return}let n=e.getUnitId(),r=t.getSheetId();this._permissionService.composePermission([new Dt(n).id,new kt(n,r).id]).every(e=>e.value)?this._drawingManagerService.setDrawingVisible(!0):this._handleDrawingVisibilityFalse(e,t)})):(this._drawingManagerService.setDrawingVisible(!1),Nn))).subscribe())}_handleDrawingVisibilityFalse(e,t){this._drawingManagerService.setDrawingVisible(!1);let n=e.getUnitId(),r=t.getSheetId(),a=this._drawingManagerService.getDrawingData(n,r),o=Object.values(a),s=this._renderManagerService.getRenderById(n),c=s==null?void 0:s.scene;c&&c.getAllObjectsByOrder().forEach(e=>{e.classType===i.IMAGE&&o.some(t=>e.oKey.includes(t.drawingId))&&c.removeObject(e)})}_initDrawingEditable(){let e=this._univerInstanceService.getCurrentTypeOfUnit$(z.UNIVER_SHEET),t=this._userManagerService.currentUser$,n=Fn([e,t]);this.disposeWithMe(n.pipe(Bn(([e,t])=>e?e.activeSheet$.pipe(Hn(t=>{if(!t){this._drawingManagerService.setDrawingEditable(!1);return}let n=e.getUnitId(),r=t.getSheetId();this._permissionService.composePermission([new Et(n).id,new Ot(n,r).id]).every(e=>e.value)?this._drawingManagerService.setDrawingEditable(!0):this._handleDrawingEditableFalse(e,t)})):(this._drawingManagerService.setDrawingEditable(!1),Nn))).subscribe())}_handleDrawingEditableFalse(e,t){this._drawingManagerService.setDrawingEditable(!1);let n=e.getUnitId(),r=t.getSheetId(),a=this._drawingManagerService.getDrawingData(n,r),o=Object.values(a),s=this._renderManagerService.getRenderById(n),c=s==null?void 0:s.scene;c&&c.getAllObjectsByOrder().forEach(e=>{e.classType===i.IMAGE&&o.some(t=>e.oKey.includes(t.drawingId))&&c.detachTransformerFrom(e)})}_initViewPermissionChange(){let e=this._univerInstanceService.getCurrentTypeOfUnit$(z.UNIVER_SHEET),t=this._userManagerService.currentUser$;this.disposeWithMe(Fn([e,t]).pipe(Bn(([e,t])=>e?e.activeSheet$.pipe(Bn(t=>{if(!t)return Nn;let n=e.getUnitId(),r=t.getSheetId(),i=this._renderManagerService.getRenderById(n),a=i==null?void 0:i.scene;if(!a)return Nn;let o=a.getTransformerByCreate();return this._permissionService.composePermission$([new Dt(n).id,new kt(n,r).id]).pipe(Rn(e=>e.every(e=>e.value)),In()).pipe(Rn(e=>({permission:e,scene:a,transformer:o,unitId:n,subUnitId:r})))})):Nn)).subscribe({next:({permission:e,scene:t,transformer:n,unitId:r,subUnitId:a})=>{this._drawingManagerService.setDrawingVisible(e);let o=t.getAllObjectsByOrder(),s=this._drawingManagerService.getDrawingData(r,a),c=Object.values(s);e?this._drawingManagerService.addNotification(c):(o.forEach(e=>{e.classType===i.IMAGE&&c.some(t=>e.oKey.includes(t.drawingId))&&t.removeObject(e)}),n.clearSelectedObjects())},complete:()=>{this._drawingManagerService.setDrawingVisible(!0);let e=this._univerInstanceService.getCurrentUnitForType(z.UNIVER_SHEET),t=e==null?void 0:e.getActiveSheet(),n=e==null?void 0:e.getUnitId(),r=t==null?void 0:t.getSheetId();if(!n||!r)return;let i=this._drawingManagerService.getDrawingData(n,r),a=Object.values(i);this._drawingManagerService.addNotification(a)}}))}_initEditPermissionChange(){let e=this._univerInstanceService.getCurrentTypeOfUnit$(z.UNIVER_SHEET),t=this._userManagerService.currentUser$;this.disposeWithMe(Fn([e,t]).pipe(Bn(([e,t])=>e?e.activeSheet$.pipe(Bn(t=>{if(!t)return Nn;let n=e.getUnitId(),r=t.getSheetId(),i=this._renderManagerService.getRenderById(n),a=i==null?void 0:i.scene;if(!a)return Nn;let o=a.getTransformerByCreate();return this._permissionService.composePermission$([new Et(n).id,new Ot(n,r).id]).pipe(Rn(e=>e.every(e=>e.value)),In()).pipe(Rn(e=>({permission:e,scene:a,transformer:o,unitId:n,subUnitId:r})))})):Nn)).subscribe({next:({permission:e,scene:t,transformer:n,unitId:r,subUnitId:a})=>{this._drawingManagerService.setDrawingEditable(e);let o=t.getAllObjectsByOrder(),s=this._drawingManagerService.getDrawingData(r,a),c=Object.values(s);e?(o.forEach(e=>{e.classType===i.IMAGE&&c.some(t=>e.oKey.includes(t.drawingId))&&t.attachTransformerTo(e)}),this._drawingManagerService.addNotification(c)):(o.forEach(e=>{e.classType===i.IMAGE&&c.some(t=>e.oKey.includes(t.drawingId))&&t.detachTransformerFrom(e)}),n.clearSelectedObjects())},complete:()=>{let e=this._univerInstanceService.getCurrentUnitForType(z.UNIVER_SHEET);if(!e)return;let t=e.getUnitId(),n=e.getActiveSheet();if(!n)return;let r=n.getSheetId(),a=this._renderManagerService.getRenderById(t),o=a==null?void 0:a.scene;if(!o)return;let s=this._drawingManagerService.getDrawingData(t,r),c=Object.values(s);this._drawingManagerService.setDrawingEditable(!0),o.getAllObjectsByOrder().forEach(e=>{e.classType===i.IMAGE&&c.some(t=>e.oKey.includes(t.drawingId))&&o.detachTransformerFrom(e)})}}))}};ei=$([Q(0,G),Q(1,n),Q(2,fe),Q(3,he),Q(4,R(je))],ei);var ti=function(e){return e.ALL=`ALL`,e.HORIZONTAL=`HORIZONTAL`,e.VERTICAL=`VERTICAL`,e}(ti||{});const ni=`univer-sheet-float-dom-`;function ri(e,t,n,r,i,a=!1){let{scaleX:s,scaleY:c}=t.getAncestorScale(),l=t.getViewport(o.VIEW_MAIN),{startColumn:u,startRow:d,xSplit:f,ySplit:p}=r.getFreeze(),m={left:!0,top:!0};if(!l)return{...e,absolute:m};let{left:h,right:g,top:_,bottom:v}=e,{top:y,left:b,viewportScrollX:x,viewportScrollY:S}=l,{boundsOfViewArea:C,scrollDirectionResponse:w}=i||{},{rowHeaderWidth:T,columnHeaderHeight:E}=n,D={top:a?0:E,left:a?0:T};C&&(Ae.isDefine(D.top)&&(D.top=C.top),Ae.isDefine(D.left)&&(D.left=C.left)),w===ti.HORIZONTAL&&(S=0),w===ti.VERTICAL&&(x=0);let ee=0,O=0,te=n.rowStartY(d-p)+E,k=n.colStartX(u-f)+T,A=n.rowStartY(d)+E,j=n.colStartX(u)+T;if(f===0)m.left=!1,ee=(h-x)*s,O=(g-x)*s;else{let e=h-(k-T),t=g-(k-T);g<j?(ee=e*s,O=t*s):h<=j&&g>=j?(ee=e*s,O=Math.max(b,(g-x)*s)):h>j&&(m.left=!1,ee=Math.max((h-x)*s,b),O=Math.max((g-x)*s,b))}let M=0,N=0;if(p===0)m.top=!1,M=(_-S)*c,N=(v-S)*c;else{let e=_-(te-E),t=v-(te-E);v<A?(M=e*c,N=t*c):_<=A&&v>=A?(M=e*c,N=Math.max(y,(v-S)*c)):_>A&&(m.top=!1,M=Math.max((_-S)*c,y),N=Math.max((v-S)*c,y))}return ee=Math.max(ee,D.left),M=Math.max(M,D.top),O=Math.max(O,D.left),N=Math.max(N,D.top),{left:ee,right:O,top:M,bottom:N,absolute:m}}const ii=(e,t,n,r,i)=>{let{left:a,top:o,width:s,height:c,angle:l}=e,u=ri({left:a,right:a+s,top:o,bottom:o+c},t,n,r,i),{scaleX:d,scaleY:f}=t.getAncestorScale();return{startX:u.left,endX:u.right,startY:u.top,endY:u.bottom,rotate:l,width:s*d,height:c*f,absolute:u.absolute}};let ai=class extends F{constructor(e,t,n,r,i,a,o){super(),this._renderManagerService=e,this._univerInstanceService=t,this._commandService=n,this._drawingManagerService=r,this._canvasFloatDomService=i,this._sheetDrawingService=a,this._lifecycleService=o,Z(this,`_domLayerInfoMap`,new Map),Z(this,`_transformChange$`,new Pn),Z(this,`transformChange$`,this._transformChange$.asObservable()),Z(this,`_add$`,new Pn),Z(this,`add$`,this._add$.asObservable()),Z(this,`_remove$`,new Pn),Z(this,`remove$`,this._remove$.asObservable()),this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(Ln(e=>e===be.Rendered),Vn(1)).subscribe(()=>{this._scrollUpdateListener()})}getFloatDomInfo(e){return this._domLayerInfoMap.get(e)}getFloatDomsBySubUnitId(e,t){return Array.from(this._domLayerInfoMap.values()).filter(n=>n.subUnitId===t&&n.unitId===e)}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderById(e),n=t==null?void 0:t.scene;return t==null||n==null?null:{scene:n,transformer:n.getTransformerByCreate(),renderUnit:t,canvas:t.engine.getCanvasElement()}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{e.forEach(e=>{var n;let{unitId:i,subUnitId:o,drawingId:s}=e,c=W(this._univerInstanceService,{unitId:i,subUnitId:o}),l=this._drawingManagerService.getDrawingByParam(e),u=this._univerInstanceService.getUnit(i,z.UNIVER_SHEET);if(!u)return;let d=u.getActiveSheet().getSheetId();if(!l||!c)return;let f=(n=this._renderManagerService.getRenderById(i))==null?void 0:n.with(C).getSkeletonParam(o);if(!f)return;let{transform:p,drawingType:m,data:h}=l;if(m!==I.DRAWING_DOM&&m!==I.DRAWING_CHART)return;let g=this._getSceneAndTransformerByDrawingSearch(i);if(g==null)return;let{scene:_,canvas:v}=g;if(p==null)return!0;if(d!==o)return;let{left:y,top:b,width:x,height:S,angle:w,flipX:T,flipY:E,skewX:D,skewY:ee}=p,O=tn({unitId:i,subUnitId:o,drawingId:s}),te=_.getObject(O);if(te!=null){te.transformByState({left:y,top:b,width:x,height:S,angle:w,flipX:T,flipY:E,skewX:D,skewY:ee});return}let k={left:y,top:b,width:x,height:S,zIndex:this._drawingManagerService.getDrawingOrder(i,o).length-1},A=m===I.DRAWING_CHART;k.rotateEnabled=!1,A&&(k.fill=h?h.backgroundColor:`white`,h&&h.border&&(k.stroke=h.border),k.paintFirst=`stroke`,k.strokeWidth=1,k.borderEnabled=!1,k.radius=8);let j=new a(O,k);A&&j.setObjectType(r.CHART),_.addObject(j,t),l.allowTransform!==!1&&_.attachTransformerTo(j);let M=new re,N=new Mn(ii(j,g.renderUnit.scene,f.skeleton,c.worksheet)),ne=`${ni}${Ie(6)}`,P={dispose:M,rect:j,position$:N,unitId:i,subUnitId:o,id:s,domId:ne};this._canvasFloatDomService.addFloatDom({position$:N,id:s,domId:ne,componentKey:l.componentKey,onPointerDown:e=>{v.dispatchEvent(new PointerEvent(e.type,e))},onPointerMove:e=>{v.dispatchEvent(new PointerEvent(e.type,e))},onPointerUp:e=>{v.dispatchEvent(new PointerEvent(e.type,e))},onWheel:e=>{v.dispatchEvent(new WheelEvent(e.type,e))},data:h,unitId:i});let F=j.onTransformChange$.subscribeEvent(()=>{let e=ii(j,g.renderUnit.scene,f.skeleton,c.worksheet);N.next(e)});M.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),F&&M.add(F),this._domLayerInfoMap.set(s,P)})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e,i=tn({unitId:t,subUnitId:n,drawingId:r}),a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;let{transformer:o,scene:s}=a,c=s.getObject(i);if(c!=null&&c.oKey){var l;o.clearControlByIds([c==null?void 0:c.oKey]),(l=s.getTransformer())==null||l.clearSelectedObjects()}})}))}_scrollUpdateListener(){let e=(e,t)=>{var n;let r=this._getSceneAndTransformerByDrawingSearch(e),i=Array.from(this._domLayerInfoMap.keys()).map(e=>({id:e,...this._domLayerInfoMap.get(e)})).filter(n=>n.subUnitId===t&&n.unitId===e).map(e=>e.id),a=W(this._univerInstanceService,{unitId:e,subUnitId:t}),o=(n=this._renderManagerService.getRenderById(e))==null?void 0:n.with(C).getSkeletonParam(t);!r||!a||!o||i.forEach(e=>{let t=this._domLayerInfoMap.get(e);if(t){let e=ii(t.rect,r.renderUnit.scene,o.skeleton,a.worksheet,t);t.position$.next(e)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(z.UNIVER_SHEET).pipe(Bn(e=>e?e.activeSheet$:zn(null)),Rn(e=>{if(!e)return null;let t=e.getUnitId(),n=this._renderManagerService.getRenderById(t);return n?{render:n,unitId:t,subUnitId:e.getSheetId()}:null}),Bn(e=>e?Fe(e.render.scene.getViewport(o.VIEW_MAIN).onScrollAfter$).pipe(Rn(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))):zn(null))).subscribe(t=>{if(!t)return;let{unitId:n,subUnitId:r}=t;e(n,r)})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===b.id){let{unitId:n}=t.params;Array.from(this._domLayerInfoMap.values()).filter(e=>e.unitId===n).map(e=>e.subUnitId).forEach(t=>{e(n,t)})}else if(t.id===ut.id){let{unitId:n,subUnitId:r}=t.params;e(n,r)}else if(t.id===gt.id){let{unitId:n,subUnitId:r}=t.params;e(n,r)}}))}updateFloatDomProps(e,t,n,r){let i=this._domLayerInfoMap.get(n),o=this._getSceneAndTransformerByDrawingSearch(e);if(i&&o){let{scene:i}=o,s=tn({unitId:e,subUnitId:t,drawingId:n}),c=i.getObject(s);c&&c instanceof a&&c.setProps(r)}}_getPosition(e,t){var n;let{startX:r,endX:i,startY:a,endY:o}=e,s=(n=this._renderManagerService.getRenderById(t))==null?void 0:n.with(g);if(s==null)return;let c=s.getCellWithCoordByOffset(r,a);if(c==null)return;let l={column:c.actualColumn,columnOffset:r-c.startX,row:c.actualRow,rowOffset:a-c.startY},u=s.getCellWithCoordByOffset(i,o);if(u!=null)return{from:l,to:{column:u.actualColumn,columnOffset:i-u.startX,row:u.actualRow,rowOffset:o-u.startY}}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{let t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==I.DRAWING_DOM&&t.drawingType!==I.DRAWING_CHART)return;let n={...t.transform};this._transformChange$.next({id:e.drawingId,value:n}),this._canvasFloatDomService.updateFloatDom(e.drawingId,{...t});let r=this._getSceneAndTransformerByDrawingSearch(e.unitId);if(r&&t.drawingType!==I.DRAWING_CHART){let{scene:n}=r,i=this._domLayerInfoMap.get(e.drawingId);i!=null&&i.rect&&(t.allowTransform===!1?n.detachTransformerFrom(i.rect):n.attachTransformerTo(i.rect))}})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(e=>{this._removeDom(e.drawingId)})}))}addFloatDomToPosition(e,t){let n=W(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId});if(!n)throw Error(`cannot find current target!`);let{unitId:r,subUnitId:i}=n,{initPosition:a,componentKey:o,data:s,allowTransform:c=!0}=e,l=t==null?Ie():t,u=this._getPosition(a,r);if(u==null)return;let d={unitId:r,subUnitId:i,drawingId:l,drawingType:e.type||I.DRAWING_DOM,componentKey:o,sheetTransform:u,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY},axisAlignSheetTransform:u,data:s,allowTransform:c};return this._commandService.executeCommand(nr.id,{unitId:r,drawings:[d]}),this._add$.next({unitId:r,subUnitId:i,id:l}),{id:l,dispose:()=>{this._removeDom(l,!0)}}}_removeDom(e,t=!1){let n=this._domLayerInfoMap.get(e);if(!n)return;let{unitId:r,subUnitId:i}=n;this._domLayerInfoMap.delete(e),n.dispose.dispose();let a=this._getSceneAndTransformerByDrawingSearch(r);if(a&&a.scene.removeObject(n.rect),t){let t=this._drawingManagerService.getDrawingByParam({unitId:r,subUnitId:i,drawingId:e});if(!t)return;let{redo:n,objects:a}=this._sheetDrawingService.getBatchRemoveOp([t]);this._commandService.syncExecuteCommand(H.id,{unitId:r,subUnitId:i,op:n,objects:a,type:B.REMOVE})}}addFloatDomToRange(e,n,i,o){var s;let c=W(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!c)throw Error(`cannot find current target!`);let{unitId:l,subUnitId:u}=c,d=this._getSceneAndTransformerByDrawingSearch(l);if(!d)return;let f=this._renderManagerService.getRenderById(l);if(!f)return;let p=(s=this._renderManagerService.getRenderById(l))==null?void 0:s.with(C).getWorksheetSkeleton(u);if(!p)return;let{componentKey:m,data:h,allowTransform:g=!0}=n,_=o==null?Ie():o,{position:v,position$:y}=this._createRangePositionObserver(e,f,p.skeleton),b=this._getPosition(v,l);if(b==null)return;let{scaleX:x}=d.scene.getAncestorScale(),S=si(v,i,x),w={unitId:l,subUnitId:u,drawingId:_,drawingType:n.type||I.DRAWING_DOM,componentKey:m,sheetTransform:b,axisAlignSheetTransform:b,transform:{left:S.startX,top:S.startY,width:S.width,height:S.height},data:h,allowTransform:g};{var T,E;let{unitId:e,subUnitId:o,drawingId:s}=w,c=W(this._univerInstanceService,{unitId:e,subUnitId:o}),l=w,u=this._univerInstanceService.getUnit(e,z.UNIVER_SHEET);if(!u)return;let d=u.getActiveSheet().getSheetId();if(!l||!c)return;let f=(T=this._renderManagerService.getRenderById(e))==null?void 0:T.with(C);if(!f)return;let p=f.getWorksheetSkeleton(o);if(!p)return;let{transform:m,drawingType:h,data:g}=l;if(h!==I.DRAWING_DOM&&h!==I.DRAWING_CHART)return;let b=this._getSceneAndTransformerByDrawingSearch(e);if(b==null)return;let{scene:x,canvas:S}=b;if(m==null||d!==o)return;let{left:D,top:ee,width:O,height:te,angle:k,flipX:A,flipY:j,skewX:M,skewY:N}=m,ne=tn({unitId:e,subUnitId:o,drawingId:s}),P=x.getObject(ne);if(P!=null){P.transformByState({left:D,top:ee,width:O,height:te,angle:k,flipX:A,flipY:j,skewX:M,skewY:N});return}let F={left:D,top:ee,width:O,height:te,zIndex:this._drawingManagerService.getDrawingOrder(e,o).length-1},ie=h===I.DRAWING_CHART;ie&&(F.fill=g?g.backgroundColor:`white`,F.rotateEnabled=!1,g&&g.border&&(F.stroke=g.border),F.paintFirst=`stroke`,F.strokeWidth=1,F.borderEnabled=!1,F.radius=8);let ae=new a(ne,F);ie&&ae.setObjectType(r.CHART),x.addObject(ae,t),l.allowTransform!==!1&&x.attachTransformerTo(ae);let oe=new re,se=x.getMainViewport(),{rowHeaderWidth:ce,columnHeaderHeight:L}=p.skeleton,le={dispose:oe,rect:ae,boundsOfViewArea:{top:L,left:ce,bottom:se.bottom,right:se.right},domAnchor:i,unitId:e,subUnitId:o},ue=new Mn(ii(ae,b.renderUnit.scene,p.skeleton,c.worksheet,le));le.position$=ue;let de={position$:ue,id:s,componentKey:l.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:e=>{S.dispatchEvent(new WheelEvent(e.type,e))},data:g,unitId:e};n.eventPassThrough&&(de={...de,onPointerDown:e=>{S.dispatchEvent(new PointerEvent(e.type,e))},onPointerMove:e=>{S.dispatchEvent(new PointerEvent(e.type,e))},onPointerUp:e=>{S.dispatchEvent(new PointerEvent(e.type,e))}}),this._canvasFloatDomService.addFloatDom(de),this.disposeWithMe(y.subscribe(t=>{var n,r,l,u;let d=si({rotate:0,startX:t.startX,startY:t.startY,endX:t.endX,endY:t.endY,width:(n=i.width)==null?t.width:n,height:(r=i.height)==null?t.height:r,absolute:{left:v.absolute.left,top:v.absolute.top}},i),f=ii(new a(tn({unitId:e,subUnitId:o,drawingId:s}),{left:d.startX,top:d.startY,width:(l=i.width)==null?t.width:l,height:(u=i.height)==null?t.height:u,zIndex:this._drawingManagerService.getDrawingOrder(e,o).length-1}),b.renderUnit.scene,p.skeleton,c.worksheet,le);ue.next(f)}));let fe=(E=this._renderManagerService.getRenderById(e))==null?void 0:E.with(C),pe=fe==null?void 0:fe.currentSkeleton$.subscribe(e=>{e&&p.sheetId!==e.sheetId&&this._removeDom(_,!0)});pe&&oe.add(pe);let me=ae.onTransformChange$.subscribeEvent(()=>{let e=ii(ae,b.renderUnit.scene,p.skeleton,c.worksheet,le);ue.next(e)});oe.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),me&&oe.add(me),this._domLayerInfoMap.set(s,le)}return{id:_,dispose:()=>{this._removeDom(_,!0)}}}addFloatDomToColumnHeader(e,n,r,i){var o;let s=W(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!s)throw Error(`cannot find current target!`);let{unitId:c,subUnitId:l}=s;if(!this._getSceneAndTransformerByDrawingSearch(c))return;let u=this._renderManagerService.getRenderById(c);if(!u)return;let d=(o=this._renderManagerService.getRenderById(c))==null?void 0:o.with(C).getWorksheetSkeleton(l);if(!d)return;let{componentKey:f,data:p,allowTransform:m=!0}=n,h=i==null?Ie():i,{position:g,position$:_}=this._createRangePositionObserver({startRow:0,endRow:0,startColumn:e,endColumn:e},u,d.skeleton),v=g;v.startY=0;let y=this._getPosition(g,c);if(y==null)return;let b={unitId:c,subUnitId:l,drawingId:h,drawingType:n.type||I.DRAWING_DOM,componentKey:f,sheetTransform:y,axisAlignSheetTransform:y,transform:{left:v.startX,top:v.startY,width:v.width,height:v.height},data:p,allowTransform:m};{var x,S;let{unitId:e,subUnitId:i,drawingId:o}=b,s=W(this._univerInstanceService,{unitId:e,subUnitId:i}),c=b,l=this._univerInstanceService.getUnit(e,z.UNIVER_SHEET);if(!l)return;let u=l.getActiveSheet().getSheetId();if(!c||!s)return;let f=(x=this._renderManagerService.getRenderById(e))==null?void 0:x.with(C);if(!f)return;let p=f.getWorksheetSkeleton(i);if(!p)return;let{transform:m,data:y}=c,w=this._getSceneAndTransformerByDrawingSearch(e);if(w==null)return;let{scene:T,canvas:E}=w;if(m==null||u!==i)return;let{left:D,top:ee,width:O,height:te,angle:k,flipX:A,flipY:j,skewX:M,skewY:N}=m,ne=tn({unitId:e,subUnitId:i,drawingId:o}),P=T.getObject(ne);if(P!=null){P.transformByState({left:D,top:ee,width:O,height:te,angle:k,flipX:A,flipY:j,skewX:M,skewY:N});return}let F=si({rotate:0,startX:v.startX,startY:0,endX:g.endX,endY:g.endY,width:r.width,height:r.height,absolute:{left:g.absolute.left,top:g.absolute.top}},r),I=new a(ne,{left:F.startX,top:F.startY,width:F.width,height:F.height,zIndex:this._drawingManagerService.getDrawingOrder(e,i).length-1});T.addObject(I,t),c.allowTransform!==!1&&T.attachTransformerTo(I);let ie=new re,ae=T.getMainViewport(),oe={dispose:ie,rect:I,unitId:e,subUnitId:i,boundsOfViewArea:{top:0,left:ae.left,bottom:ae.bottom,right:ae.right},domAnchor:r,scrollDirectionResponse:ti.HORIZONTAL},se=new Mn(ii(I,w.renderUnit.scene,p.skeleton,s.worksheet,oe));oe.position$=se;let ce={position$:se,id:o,componentKey:c.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:e=>{E.dispatchEvent(new WheelEvent(e.type,e))},data:y,unitId:e};n.eventPassThrough&&(ce={...ce,onPointerDown:e=>{E.dispatchEvent(new PointerEvent(e.type,e))},onPointerMove:e=>{E.dispatchEvent(new PointerEvent(e.type,e))},onPointerUp:e=>{E.dispatchEvent(new PointerEvent(e.type,e))}}),this._canvasFloatDomService.addFloatDom(ce);let L=I.onTransformChange$.subscribeEvent(()=>{let e=ii(I,w.renderUnit.scene,p.skeleton,s.worksheet,oe);se.next(e)});this.disposeWithMe(_.subscribe(t=>{let n=si({rotate:0,startX:t.startX,startY:0,endX:t.endX,endY:t.endY,width:r.width,height:r.height,absolute:{left:g.absolute.left,top:g.absolute.top}},r),c=ii(new a(tn({unitId:e,subUnitId:i,drawingId:o}),{left:n.startX,top:0,width:r.width,height:r.height,zIndex:this._drawingManagerService.getDrawingOrder(e,i).length-1}),w.renderUnit.scene,p.skeleton,s.worksheet,oe);se.next(c)}));let le=(S=this._renderManagerService.getRenderById(e))==null?void 0:S.with(C);le==null||le.currentSkeleton$.subscribe(e=>{e&&d.sheetId!==e.sheetId&&this._removeDom(h,!0)}),ie.add(()=>{this._canvasFloatDomService.removeFloatDom(o)}),L&&ie.add(L),this._domLayerInfoMap.set(o,oe)}return{id:h,dispose:()=>{this._removeDom(h,!0)}}}_createRangePositionObserver(e,t,n){let{startRow:r,startColumn:i}=e,a=oi(r,i,n),o=new Mn(a),s=oi(e.endRow,e.endColumn,n),c=new Mn(s),l=()=>{let t=oi(r,i,n),a=oi(e.endRow,e.endColumn,n);o.next(t),c.next(a)},u=new re;return u.add(t.engine.clientRect$.subscribe(()=>l())),u.add(this._commandService.onCommandExecuted(e=>{if(e.id===xt.id&&e.params.rowsAutoHeightInfo.findIndex(e=>e.row===r)>-1){l();return}(He.indexOf(e.id)>-1||e.id===y.id||e.id===b.id)&&l()})),{position$:o.pipe(Rn(t=>{let r=oi(e.endRow,e.endColumn,n);return{rotate:0,width:r.right-t.left,height:r.bottom-t.top,absolute:{left:!0,top:!0},startX:t.left,startY:t.top,endX:r.right,endY:r.bottom}})),position:{rotate:0,width:s.right-a.left,height:s.bottom-a.top,absolute:{left:!0,top:!0},startX:a.left,startY:a.top,endX:s.right,endY:s.bottom},updateRowCol:(e,t)=>{r=e,i=t,l()},topLeftPos$:o,rightBottomPos$:c,disposable:u}}};ai=$([Q(0,R(n)),Q(1,he),Q(2,R(L)),Q(3,G),Q(4,R(rn)),Q(5,V),Q(6,R(ye))],ai);function oi(e,t,n){let r=n.getCellWithCoordByIndex(e,t),i=r.isMergedMainCell?r.mergeInfo:r;return{left:i.startX,right:i.endX,top:i.startY,bottom:i.endY}}function si(e,t,n){var r,i,a;n=(r=n)==null?1:r;let o=e.endX-e.startX,s=e.endY-e.startY,c=(i=t==null?void 0:t.width)==null?o:i,l=(a=t==null?void 0:t.height)==null?s:a,u=0,d=0;if(t){if(t.horizonOffsetAlign===`right`){let r=ci(t.marginX,o*n);u=e.endX-r-c}else u=e.startX+ci(t.marginX,o);if(t.verticalOffsetAlign===`bottom`){let r=ci(t.marginY,s*n);d=e.endY-r-l}else d=e.startY+ci(t.marginY,s)}return{rotate:0,startX:u,startY:d,endX:e.endX,endY:e.endY,width:c,height:l,absolute:{left:e.absolute.left,top:e.absolute.top}}}function ci(e,t){return e===void 0?0:typeof e==`number`?e:t*Number.parseFloat(e)/100}const li=e=>{let{floatDomInfos:t,scene:n,skeleton:r,worksheet:i}=e;return K(`div`,{style:{position:`absolute`,top:0,left:0},children:Kn(()=>t.map(e=>{let{width:t,height:a,angle:o,left:s,top:c}=e.transform,l=ri({left:s==null?0:s,right:(s==null?0:s)+(t==null?0:t),top:c==null?0:c,bottom:(c==null?0:c)+(a==null?0:a)},n,r,i,void 0,!0),{scaleX:u,scaleY:d}=n.getAncestorScale(),f={startX:l.left,endX:l.right,startY:l.top,endY:l.bottom,rotate:o,width:t*u,height:a*d,absolute:l.absolute},p={position$:new Mn(f),position:f,id:e.drawingId,componentKey:e.componentKey,onPointerMove:()=>{},onPointerDown:()=>{},onPointerUp:()=>{},onWheel:()=>{},unitId:e.unitId,data:e.data};return[e.drawingId,p]}),[t,n,r,i]).map(([e,t])=>K(vn,{layer:t,id:e,position:t.position},e))})};let ui=class extends F{constructor(e,t,n,r,i,a,o){super(),this._sheetPrintInterceptorService=e,this._drawingRenderService=t,this._drawingManagerService=n,this._renderManagerService=r,this._canvasFloatDomManagerService=i,this._componetManager=a,this._injector=o,this._initPrinting(),this._initPrintingDom()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(e,t,n)=>{let{unitId:r,scene:i,subUnitId:a}=t,o=this._drawingManagerService.getDrawingDataForUnit(r),s=o==null?void 0:o[a];return s&&s.order.forEach(e=>{let t=s.data[e];t.drawingType!==I.DRAWING_CHART&&t.drawingType!==I.DRAWING_DOM&&this._drawingRenderService.renderDrawing(t,i)}),n()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(e,t,n)=>{let{unitId:r,subUnitId:i}=t,a=this._renderManagerService.getRenderById(r);if(!a)return n(e);let o=a.with(C).getSkeletonParam(i);if(!o)return n(e);let s=this._drawingManagerService.getDrawingDataForUnit(r),c=s==null?void 0:s[t.subUnitId];if(!c)return n(e);let{scaleX:l,scaleY:u}=a.scene,d=e?{...e}:{startColumn:0,endColumn:0,endRow:0,startRow:0},f=c.order.map(e=>c.data[e]);return f.length?(f.forEach(e=>{if(!e.groupId&&e.transform&&Ae.isDefine(e.transform.left)&&Ae.isDefine(e.transform.top)&&Ae.isDefine(e.transform.width)&&Ae.isDefine(e.transform.height)){let t=o.skeleton.getCellIndexByOffset(e.transform.left,e.transform.top,l,u,{x:0,y:0}),n=o.skeleton.getCellIndexByOffset(e.transform.left+e.transform.width,e.transform.top+e.transform.height,l,u,{x:0,y:0});t.column<d.startColumn&&(d.startColumn=t.column),t.row<d.startRow&&(d.startRow=t.row),d.endRow<n.row&&(d.endRow=n.row),d.endColumn<n.column&&(d.endColumn=n.column)}}),n(d)):n(e)}}))}_initPrintingDom(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_DOM_COLLECT,{handler:(e,t,n)=>{let{unitId:r,subUnitId:i}=t,a=this._drawingManagerService.getDrawingDataForUnit(r),o=a==null?void 0:a[i];if(o){let r=o.order.map(e=>{let t=o.data[e];if(t.drawingType===I.DRAWING_CHART)return{...t,componentKey:this._componetManager.get(Te)};if(t.drawingType===I.DRAWING_DOM){let e=this._sheetPrintInterceptorService.getPrintComponent(t.componentKey);return{...t,componentKey:this._componetManager.get(e||t.componentKey)}}return null}).filter(Boolean);return Bt(K(bn(li,this._injector),{floatDomInfos:r,scene:t.scene,skeleton:t.skeleton,worksheet:t.worksheet}),t.root),e==null||e.add(()=>{Vt(t.root)}),n(e)}}}))}};ui=$([Q(0,R(S)),Q(1,R(Dn)),Q(2,G),Q(3,n),Q(4,R(ai)),Q(5,R(an)),Q(6,R(_e))],ui);var di=function(e){return e[e.deleteLeft=0]=`deleteLeft`,e[e.deleteUp=1]=`deleteUp`,e[e.insertDown=2]=`insertDown`,e[e.insertRight=3]=`insertRight`,e}(di||{});const fi=[Qe.id,Ye.id,at.id,it.id,Ue.id,We.id,Xe.id,Ze.id,Ke.id,ft.id,Ge.id,lt.id,pt.id,vt.id,_t.id,ot.id,et.id,nt.id,tt.id],pi=[ht.id,mt.id,ct.id,st.id,St.id,xt.id,Ct.id,bt.id];let mi=class extends F{constructor(e,t,n,r,i,a,o,s,c){super(),this._context=e,this._renderManagerService=t,this._commandService=n,this._selectionRenderService=r,this._skeletonManagerService=i,this._sheetInterceptorService=a,this._sheetDrawingService=o,this._drawingManagerService=s,this._univerInstanceService=c,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptAfterCommand({getMutations:e=>{if(!fi.includes(e.id)||e.params==null)return{redos:[],undos:[]};let t=e.id;if(t===Qe.id)return this._moveRowInterceptor(e.params,`insert`);if([et.id,nt.id,tt.id].includes(t))return this._moveRangeInterceptor(e.params);if(t===Ye.id)return this._moveColInterceptor(e.params,`insert`);if(t===at.id)return this._moveRowInterceptor(e.params,`remove`);if(t===it.id)return this._moveColInterceptor(e.params,`remove`);if(t===Ue.id){let{range:t}=e.params;return this._getRangeMoveUndo(t,di.deleteLeft)}else if(t===We.id){let{range:t}=e.params;return this._getRangeMoveUndo(t,di.deleteUp)}else if(t===Xe.id){let{range:t}=e.params;return this._getRangeMoveUndo(t,di.insertDown)}else if(t===Ze.id){let{range:t}=e.params;return this._getRangeMoveUndo(t,di.insertRight)}else if(t===pt.id||t===vt.id){let{unitId:t,subUnitId:n,ranges:r}=e.params;return this._getDrawingUndoForRowVisible(t,n,r)}else if(t===_t.id||t===ot.id){let{unitId:t,subUnitId:n,ranges:r}=e.params;return this._getDrawingUndoForColVisible(t,n,r)}else if(t===Ke.id||t===ft.id||t===Ge.id||t===lt.id){let{unitId:n,subUnitId:r,ranges:i}=e.params,a=t===Ke.id||t===ft.id;return this._getDrawingUndoForRowAndColSize(n,r,i,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(e,t){let n=W(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};let r=n.unitId,i=n.subUnitId,a=[],o=[],s=this._sheetDrawingService.getDrawingData(r,i),c=[],l=[];if(Object.keys(s).forEach(n=>{let r=s[n],{updateDrawings:i,deleteDrawings:a}=this._getUpdateOrDeleteDrawings(e,t,r);c.push(...i),l.push(...a)}),c.length===0&&l.length===0)return{redos:[],undos:[]};if(c.length>0){let{undo:e,redo:t,objects:n}=this._sheetDrawingService.getBatchUpdateOp(c);a.push({id:H.id,params:{unitId:r,subUnitId:i,op:t,objects:n,type:B.UPDATE}}),o.push({id:H.id,params:{unitId:r,subUnitId:i,op:e,objects:n,type:B.UPDATE}})}if(l.length>0){let e=this._sheetDrawingService.getBatchRemoveOp(l),t=e.undo,n=e.redo,s=e.objects;a.push({id:H.id,params:{unitId:r,subUnitId:i,op:n,objects:s,type:B.REMOVE}}),o.push({id:H.id,params:{unitId:r,subUnitId:i,op:t,objects:s,type:B.INSERT}})}return a.push({id:X.id,params:[r]}),o.push({id:X.id,params:[r]}),{redos:a,undos:o}}_getUpdateOrDeleteDrawings(e,t,n){let r=[],i=[],{sheetTransform:a,anchorType:o=U.Position,transform:s,unitId:c,subUnitId:l,drawingId:u}=n,{from:d,to:f}=a,{row:p,column:m}=d,{row:h,column:g}=f;if(a==null||s==null)return{updateDrawings:r,deleteDrawings:i};let{startRow:_,endRow:v,startColumn:y,endColumn:b}=e,x=null,S=null,C;if(t===di.deleteLeft&&p>=_&&h<=v)if(m>=y&&g<=b)i.push({unitId:c,subUnitId:l,drawingId:u});else{var w;let e=this._shrinkCol(a,s,y,b,o);x=e==null?void 0:e.newSheetTransform,S=e==null?void 0:e.newTransform,C=(w=e==null?void 0:e.axisAlignSheetTransform)==null?void 0:w}else if(t===di.deleteUp&&m>=y&&g<=b)if(p>=_&&h<=v)i.push({unitId:c,subUnitId:l,drawingId:u});else{var T;let e=this._shrinkRow(a,s,_,v,o);x=e==null?void 0:e.newSheetTransform,S=e==null?void 0:e.newTransform,C=(T=e==null?void 0:e.axisAlignSheetTransform)==null?void 0:T}else if(t===di.insertDown){var E;let e=this._expandRow(a,s,_,v,o);x=e==null?void 0:e.newSheetTransform,S=e==null?void 0:e.newTransform,C=(E=e==null?void 0:e.axisAlignSheetTransform)==null?void 0:E}else if(t===di.insertRight){var D;let e=this._expandCol(a,s,y,b,o);x=e==null?void 0:e.newSheetTransform,S=e==null?void 0:e.newTransform,C=(D=e==null?void 0:e.axisAlignSheetTransform)==null?void 0:D}if(x!=null&&S!=null){let e=q(x,this._selectionRenderService,this._skeletonManagerService);r.push({...n,sheetTransform:x,transform:e,axisAlignSheetTransform:C})}return{updateDrawings:r,deleteDrawings:i}}_remainDrawingSize(e,t,n){let r=J({...e},this._selectionRenderService);if(r!=null){let i=Y({...e},this._selectionRenderService);t.push({...n,sheetTransform:r,axisAlignSheetTransform:i})}}_getDrawingUndoForColVisible(e,t,n){let r=this._drawingManagerService.getDrawingData(e,t),i=[],a=[];if(Object.keys(r).forEach(e=>{let t=r[e],{sheetTransform:o,transform:s,anchorType:c=U.Position}=t;if(c===U.None)this._remainDrawingSize(s,i,t);else{let{from:e,to:r}=o,{row:l,column:u}=e,{row:d,column:f}=r;for(let o=0;o<n.length;o++){let{startRow:l,endRow:d,startColumn:p,endColumn:m}=n[o];if(f<p)continue;if(c===U.Position){let n=null,a=null;if(u>=p&&u<=m){let t=this._skeletonManagerService.attachRangeWithCoord({startColumn:u,endColumn:m,startRow:e.row,endRow:r.row});if(t==null)return;a={...s,left:t.startX}}if(a!=null){n=J(a,this._selectionRenderService);let e=Y(a,this._selectionRenderService);if(n!=null&&a!=null){i.push({...t,sheetTransform:n,transform:a,axisAlignSheetTransform:e});break}}this._remainDrawingSize(s,i,t);continue}if(u>=p&&f<=m)continue;let h=null,g=null;if(u>=p&&u<=m){let t=this._skeletonManagerService.attachRangeWithCoord({startColumn:u,endColumn:m,startRow:e.row,endRow:r.row});if(t==null)return;g={...s,left:(t==null?void 0:t.startX)||0,width:((s==null?void 0:s.width)||0)-t.endX+t.startX}}else if(f>=p&&f<=m){let t=this._skeletonManagerService.attachRangeWithCoord({startColumn:p,endColumn:f,startRow:e.row,endRow:r.row});if(t==null)return;g={...s,left:t.startX-((s==null?void 0:s.width)||0)}}else{let n=this._skeletonManagerService.attachRangeWithCoord({startColumn:p,endColumn:m,startRow:e.row,endRow:r.row});if(n==null)return;if(g={...s,width:((s==null?void 0:s.width)||0)-n.endX+n.startX},h=J(g,this._selectionRenderService),h!=null&&g!=null){let e=Y(g,this._selectionRenderService);a.push({...t,sheetTransform:h,transform:g,axisAlignSheetTransform:e});break}}if(g!=null&&(h=J(g,this._selectionRenderService)),g!=null&&h!=null){let e=Y(g,this._selectionRenderService);i.push({...t,sheetTransform:h,transform:g,axisAlignSheetTransform:e});break}else this._remainDrawingSize(s,i,t)}}}),i.length===0&&a.length===0)return{redos:[],undos:[]};let{redos:o,undos:s}=this._createUndoAndRedoMutation(e,t,i),c=[],l=[];if(a.length>0){let{redos:n,undos:r}=this._createUndoAndRedoMutation(e,t,a);c.push(...n),l.push(...r)}return{redos:o,undos:s,preRedos:c,preUndos:l}}_createUndoAndRedoMutation(e,t,n){let{undo:r,redo:i,objects:a}=this._sheetDrawingService.getBatchUpdateOp(n);return{redos:[{id:H.id,params:{unitId:e,subUnitId:t,op:i,objects:a,type:B.UPDATE}},{id:X.id,params:[e]}],undos:[{id:H.id,params:{unitId:e,subUnitId:t,op:r,objects:a,type:B.UPDATE}},{id:X.id,params:[e]}]}}_getDrawingUndoForRowVisible(e,t,n){let r=this._drawingManagerService.getDrawingData(e,t),i=[],a=[];if(Object.keys(r).forEach(e=>{let t=r[e],{sheetTransform:o,transform:s,anchorType:c=U.Position}=t;if(c===U.None)this._remainDrawingSize(s,i,t);else{let{from:e,to:r}=o,{row:l,column:u}=e,{row:d,column:f}=r;for(let o=0;o<n.length;o++){let{startRow:u,endRow:f,startColumn:p,endColumn:m}=n[o];if(d<u)continue;if(c===U.Position){let n=null,a=null;if(l>=u&&l<=f){let t=this._skeletonManagerService.attachRangeWithCoord({startColumn:e.column,endColumn:r.column,startRow:l,endRow:f});if(t==null)return;a={...s,top:t.startY}}if(a!=null){n=J(a,this._selectionRenderService);let e=Y(a,this._selectionRenderService);if(n!=null&&a!=null){i.push({...t,sheetTransform:n,transform:a,axisAlignSheetTransform:e});break}}this._remainDrawingSize(s,i,t);continue}if(l>=u&&d<=f)continue;let h=null,g=null;if(l>=u&&l<=f){let t=this._skeletonManagerService.attachRangeWithCoord({startColumn:e.column,endColumn:r.column,startRow:l,endRow:f});if(t==null)return;g={...s,top:(t==null?void 0:t.startY)||0,height:((s==null?void 0:s.height)||0)-t.endY+t.startY}}else if(d>=u&&d<=f){let t=this._skeletonManagerService.attachRangeWithCoord({startColumn:e.column,endColumn:r.column,startRow:u,endRow:d});if(t==null)return;g={...s,top:t.startY-((s==null?void 0:s.height)||0)}}else{let n=this._skeletonManagerService.attachRangeWithCoord({startColumn:e.column,endColumn:r.column,startRow:u,endRow:f});if(n==null)return;if(g={...s,height:((s==null?void 0:s.height)||0)-n.endY+n.startY},h=J(g,this._selectionRenderService),h!=null&&g!=null){let e=Y(g,this._selectionRenderService);a.push({...t,sheetTransform:h,transform:g,axisAlignSheetTransform:e});break}}if(g!=null&&(h=J(g,this._selectionRenderService)),g!=null&&h!=null){let e=Y(g,this._selectionRenderService);i.push({...t,sheetTransform:h,transform:g,axisAlignSheetTransform:e});break}else this._remainDrawingSize(s,i,t)}}}),i.length===0&&a.length===0)return{redos:[],undos:[]};let{redos:o,undos:s}=this._createUndoAndRedoMutation(e,t,i),c=[],l=[];if(a.length>0){let{redos:n,undos:r}=this._createUndoAndRedoMutation(e,t,a);c.push(...n),l.push(...r)}return{redos:o,undos:s,preRedos:c,preUndos:l}}_getDrawingUndoForRowAndColSize(e,t,n,r){let i=this._drawingManagerService.getDrawingData(e,t),a=[];return Object.keys(i).forEach(e=>{let t=i[e],{sheetTransform:r,transform:o,anchorType:s=U.Position}=t;if(s===U.None)this._remainDrawingSize(o,a,t);else{let{from:e,to:i}=r,{row:c,column:l}=e,{row:u,column:d}=i;for(let e=0;e<n.length;e++){let{startRow:i,endRow:f,startColumn:p,endColumn:m}=n[e];if(u<i||d<p)continue;if(s===U.Position&&(c<=i&&u>=f||l<=p&&d>=m)){this._remainDrawingSize(o,a,t);continue}let h=q({...r},this._selectionRenderService,this._skeletonManagerService);if(h!=null){a.push({...t,transform:h});break}}}}),a.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(e,t,a)}_getUnitIdAndSubUnitId(e,t){let n,r;if(t===`insert`)n=e.unitId,r=e.subUnitId;else{let e=W(this._univerInstanceService);if(e==null)return;n=e.unitId,r=e.subUnitId}return{unitId:n,subUnitId:r}}_moveRangeInterceptor(e){var t;let{toRange:n,fromRange:r}=e,i=W(this._univerInstanceService);if(!i)return{redos:[],undos:[]};let{unitId:a,subUnitId:o}=i,s=(t=this._renderManagerService.getRenderById(a))==null||(t=t.with(C))==null?void 0:t.getCurrentSkeleton();if(!s)return{redos:[],undos:[]};let c=w(s,r);if(!c)return{redos:[],undos:[]};let{startX:l,endX:u,startY:d,endY:f}=c,p=this._sheetDrawingService.getDrawingData(a,o),m=[];Object.keys(p).forEach(e=>{let t=p[e];if(t.anchorType!==U.Both)return;let{transform:n}=t;if(!n)return;let{left:r=0,top:i=0,width:a=0,height:o=0}=n,{drawingStartX:s,drawingEndX:c,drawingStartY:h,drawingEndY:g}={drawingStartX:r,drawingEndX:r+a,drawingStartY:i,drawingEndY:i+o};l<=s&&c<=u&&d<=h&&g<=f&&m.push(t)});let h=[],g=[],_=n.startRow-r.startRow,v=n.startColumn-r.startColumn,y=m.map(e=>{let t=e.sheetTransform,n={to:{...t.to,row:t.to.row+_,column:t.to.column+v},from:{...t.from,row:t.from.row+_,column:t.from.column+v}},r=q(n,this._selectionRenderService,this._skeletonManagerService);return{unitId:a,subUnitId:o,drawingId:e.drawingId,transform:r,sheetTransform:n}});if(y.length){let{undo:e,redo:t,objects:n}=this._sheetDrawingService.getBatchUpdateOp(y);h.push({id:H.id,params:{unitId:a,subUnitId:o,op:t,objects:n,type:B.UPDATE}}),g.push({id:H.id,params:{unitId:a,subUnitId:o,op:e,objects:n,type:B.UPDATE}})}return{redos:h,undos:g}}_moveRowInterceptor(e,t){let n=this._getUnitIdAndSubUnitId(e,t);if(n==null)return{redos:[],undos:[]};let{unitId:r,subUnitId:i}=n,{range:a}=e,o=a.startRow,s=a.endRow,c=[],l=[],u=this._sheetDrawingService.getDrawingData(r,i),d=[],f=[];if(Object.keys(u).forEach(e=>{let{sheetTransform:n,transform:a,anchorType:c=U.Position}=u[e];if(n==null||a==null)return;let l,p,m;if(t===`insert`){var h;let e=this._expandRow(n,a,o,s,c);l=e==null?void 0:e.newSheetTransform,p=e==null?void 0:e.newTransform,m=(h=e==null?void 0:e.axisAlignSheetTransform)==null?void 0:h}else{let{from:t,to:u}=n,{row:d}=t,{row:h}=u;if(c===U.Both&&d>=o&&h<=s)f.push({unitId:r,subUnitId:i,drawingId:e});else{var g;let e=this._shrinkRow(n,a,o,s,c);l=e==null?void 0:e.newSheetTransform,p=e==null?void 0:e.newTransform,m=(g=e==null?void 0:e.axisAlignSheetTransform)==null?void 0:g}}if(!l||!p)return;let _={unitId:r,subUnitId:i,drawingId:e,transform:p,sheetTransform:l,axisAlignSheetTransform:m};d.push(_)}),d.length===0&&f.length===0)return{redos:[],undos:[]};if(d.length>0){let{undo:e,redo:t,objects:n}=this._sheetDrawingService.getBatchUpdateOp(d);c.push({id:H.id,params:{unitId:r,subUnitId:i,op:t,objects:n,type:B.UPDATE}}),l.push({id:H.id,params:{unitId:r,subUnitId:i,op:e,objects:n,type:B.UPDATE}})}if(f.length>0){let e=this._sheetDrawingService.getBatchRemoveOp(f),t=e.undo,n=e.redo,a=e.objects;c.push({id:H.id,params:{unitId:r,subUnitId:i,op:n,objects:a,type:B.REMOVE}}),l.push({id:H.id,params:{unitId:r,subUnitId:i,op:t,objects:a,type:B.INSERT}})}return c.push({id:X.id,params:[r]}),l.push({id:X.id,params:[r]}),{redos:c,undos:l}}_moveColInterceptor(e,t){let n=this._getUnitIdAndSubUnitId(e,t);if(n==null)return{redos:[],undos:[]};let{unitId:r,subUnitId:i}=n,{range:a}=e,o=a.startColumn,s=a.endColumn,c=[],l=[],u=this._sheetDrawingService.getDrawingData(r,i),d=[],f=[];if(Object.keys(u).forEach(e=>{let{sheetTransform:n,transform:a,anchorType:c=U.Position}=u[e];if(n==null||a==null)return;let l,p,m;if(t===`insert`){var h;let e=this._expandCol(n,a,o,s,c);l=e==null?void 0:e.newSheetTransform,p=e==null?void 0:e.newTransform,m=(h=e==null?void 0:e.axisAlignSheetTransform)==null?void 0:h}else{let{from:t,to:u}=n,{column:d}=t,{column:h}=u;if(c===U.Both&&d>=o&&h<=s)f.push({unitId:r,subUnitId:i,drawingId:e});else{var g;let e=this._shrinkCol(n,a,o,s,c);l=e==null?void 0:e.newSheetTransform,p=e==null?void 0:e.newTransform,m=(g=e==null?void 0:e.axisAlignSheetTransform)==null?void 0:g}}if(!l||!p)return;let _={unitId:r,subUnitId:i,drawingId:e,transform:p,sheetTransform:l,axisAlignSheetTransform:m};d.push(_)}),d.length===0&&f.length===0)return{redos:[],undos:[]};if(d.length>0){let{undo:e,redo:t,objects:n}=this._sheetDrawingService.getBatchUpdateOp(d);c.push({id:H.id,params:{unitId:r,subUnitId:i,op:t,objects:n,type:B.UPDATE}}),l.push({id:H.id,params:{unitId:r,subUnitId:i,op:e,objects:n,type:B.UPDATE}})}if(f.length>0){let e=this._sheetDrawingService.getBatchRemoveOp(f),t=e.undo,n=e.redo,a=e.objects;c.push({id:H.id,params:{unitId:r,subUnitId:i,op:n,objects:a,type:B.REMOVE}}),l.push({id:H.id,params:{unitId:r,subUnitId:i,op:t,objects:a,type:B.INSERT}})}return c.push({id:X.id,params:[r]}),l.push({id:X.id,params:[r]}),{redos:c,undos:l}}_expandCol(e,t,n,r,i=U.Position){let a=r-n+1,{from:o,to:s}=e,{column:c}=o,{column:l}=s;if(i===U.None)return{newSheetTransform:J({...t},this._selectionRenderService),newTransform:t,axisAlignSheetTransform:Y({...t},this._selectionRenderService)};let u=null,d=null,f=null;if(c>=n){let e=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:r,startRow:o.row,endRow:s.row});if(e==null)return;d={...t,left:(t.left||0)+e.endX-e.startX},u=J(d,this._selectionRenderService),f=Y(d,this._selectionRenderService)}else if(l>=r)if(i===U.Both)u={from:{...o},to:{...s,column:l+a}},d=q(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:J({...t},this._selectionRenderService),newTransform:t,axisAlignSheetTransform:Y({...t},this._selectionRenderService)};return u!=null&&d!=null?{newSheetTransform:u,newTransform:d,axisAlignSheetTransform:f}:null}_shrinkCol(e,t,n,r,i=U.Position){let a=r-n+1,{from:o,to:s}=e,{column:c}=o,{column:l}=s;if(i===U.None)return{newSheetTransform:J({...t},this._selectionRenderService),newTransform:t,axisAlignSheetTransform:Y({...t},this._selectionRenderService)};let u=null,d=null,f=null;if(c>r)u={from:{...o,column:c-a},to:{...s,column:l-a}},d=q(u,this._selectionRenderService,this._skeletonManagerService);else if(c>=n&&l<=r)return null;else if(c<n&&l>r)if(i===U.Both)u={from:{...o},to:{...s,column:l-a}},d=q(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:J({...t},this._selectionRenderService),newTransform:t,axisAlignSheetTransform:Y({...t},this._selectionRenderService)};else if(c>=n&&c<=r){if(c===n)d={...t,left:(t.left||0)-e.from.columnOffset};else{let r=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:c-1,startRow:o.row,endRow:s.row});if(r==null)return;d={...t,left:(t.left||0)-r.endX+r.startX-e.from.columnOffset}}u=J(d,this._selectionRenderService),f=Y(d,this._selectionRenderService)}else if(l>=n&&l<=r&&i===U.Both){let e=this._skeletonManagerService.attachRangeWithCoord({startColumn:n-1,endColumn:n-1,startRow:o.row,endRow:s.row});if(e==null)return;u={from:{...o},to:{...s,column:n-1,columnOffset:e.endX-e.startX}},d=q(u,this._selectionRenderService,this._skeletonManagerService)}return u!=null&&d!=null?{newSheetTransform:u,newTransform:d,axisAlignSheetTransform:f}:null}_expandRow(e,t,n,r,i=U.Position){let a=r-n+1,{from:o,to:s}=e,{row:c}=o,{row:l}=s;if(i===U.None)return{newSheetTransform:J({...t},this._selectionRenderService),newTransform:t,axisAlignSheetTransform:Y({...t},this._selectionRenderService)};let u=null,d=null,f=null;if(c>=n){let e=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:r,startColumn:o.column,endColumn:s.column});if(e==null)return;d={...t,top:(t.top||0)+e.endY-e.startY},u=J(d,this._selectionRenderService),f=Y(d,this._selectionRenderService)}else if(l>=r)if(i===U.Both)u={from:{...o},to:{...s,row:l+a}},d=q(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:J({...t},this._selectionRenderService),newTransform:t,axisAlignSheetTransform:Y({...t},this._selectionRenderService)};return u!=null&&d!=null?{newSheetTransform:u,newTransform:d,axisAlignSheetTransform:f}:null}_shrinkRow(e,t,n,r,i=U.Position){let a=r-n+1,{from:o,to:s}=e,{row:c}=o,{row:l}=s;if(i===U.None)return{newSheetTransform:J({...t},this._selectionRenderService),newTransform:t,axisAlignSheetTransform:Y({...t},this._selectionRenderService)};let u=null,d=null,f=null;if(c>r)u={from:{...o,row:c-a},to:{...s,row:l-a}},d=q(u,this._selectionRenderService,this._skeletonManagerService);else if(c>=n&&l<=r)return null;else if(c<n&&l>r)if(i===U.Both)u={from:{...o},to:{...s,row:l-a}},d=q(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:J({...t},this._selectionRenderService),newTransform:t,axisAlignSheetTransform:Y({...t},this._selectionRenderService)};else if(c>=n&&c<=r){if(c===n)d={...t,top:(t.top||0)-e.from.rowOffset};else{let r=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:c-1,startColumn:o.column,endColumn:s.column});if(r==null)return;d={...t,top:(t.top||0)-r.endY+r.startY-e.from.rowOffset}}u=J(d,this._selectionRenderService),f=Y(d,this._selectionRenderService)}else if(l>=n&&l<=r&&i===U.Both){let e=this._skeletonManagerService.attachRangeWithCoord({startColumn:o.column,endColumn:o.column,startRow:n-1,endRow:n-1});if(e==null)return;u={from:{...o},to:{...s,row:n-1,rowOffset:e.endY-e.startY}},d=q(u,this._selectionRenderService,this._skeletonManagerService)}return u!=null&&d!=null?{newSheetTransform:u,newTransform:d,axisAlignSheetTransform:f}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===yt.id){let{unitId:t,subUnitId:n}=e.params;this._updateDrawings(t,n)}})),this.disposeWithMe(this._context.activated$.subscribe(e=>{let{unit:t,unitId:n}=this._context;if(e){let e=t.getActiveSheet().getSheetId();this._updateDrawings(n,e)}else this._clearDrawings(n)}))}_clearDrawings(e){setTimeout(()=>{let t=this._drawingManagerService.drawingManagerData,n=[];Object.keys(t).forEach(r=>{let i=t[r];i!=null&&Object.keys(i).forEach(t=>{let a=i[t].data;a!=null&&Object.keys(a).forEach(t=>{r===e&&n.push(a[t])})})}),this._sheetDrawingService.removeNotification(n),this._drawingManagerService.removeNotification(n)})}_updateDrawings(e,t){setTimeout(()=>{let n=this._drawingManagerService.drawingManagerData,r=[],i=[];Object.keys(n).forEach(a=>{let o=n[a];o!=null&&Object.keys(o).forEach(n=>{let s=o[n].data;s!=null&&Object.keys(s).forEach(o=>{if(a===e&&n===t){let e=s[o];e.sheetTransform&&(e.transform=q(e.sheetTransform,this._selectionRenderService,this._skeletonManagerService)),r.push(s[o])}else i.push(s[o])})})}),this._sheetDrawingService.removeNotification(i),this._sheetDrawingService.addNotification(r),this._drawingManagerService.removeNotification(i),this._drawingManagerService.addNotification(r)},0)}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{pi.includes(e.id)&&requestIdleCallback(()=>{let t=e.params,n=W(this._univerInstanceService,t);if(!n)return;let{unitId:r,subUnitId:i,worksheet:a}=n,o=[];`ranges`in t?o=t.ranges:`rowsAutoHeightInfo`in t&&(o=t.rowsAutoHeightInfo.map(e=>({startRow:e.row,endRow:e.row,startColumn:0,endColumn:a.getColumnCount()-1}))),this._refreshDrawingTransform(r,i,o)})}))}_refreshDrawingTransform(e,t,n){let r=this._drawingManagerService.getDrawingData(e,t),i=[];Object.keys(r).forEach(e=>{let t=r[e],{sheetTransform:a,transform:o,anchorType:s=U.Position}=t;if(s===U.None)return!0;let{from:c,to:l}=a,{row:u,column:d}=c,{row:f,column:p}=l;for(let e=0;e<n.length;e++){let{startRow:r,endRow:c,startColumn:l,endColumn:m}=n[e];if(Oe.intersects({startRow:r,endRow:c,startColumn:l,endColumn:m},{startRow:u,endRow:f,startColumn:d,endColumn:p})||u>c||d>m){let e=s===U.Position,n=q(a,this._selectionRenderService,this._skeletonManagerService);i.push({...t,transform:{...n,width:e?o==null?void 0:o.width:n==null?void 0:n.width,height:e?o==null?void 0:o.height:n==null?void 0:n.height}});break}}}),i.length!==0&&(this._sheetDrawingService.refreshTransform(i),this._drawingManagerService.refreshTransform(i),this._commandService.syncExecuteCommand(X.id,[e]))}};mi=$([Q(1,n),Q(2,L),Q(3,g),Q(4,R(C)),Q(5,R(wt)),Q(6,V),Q(7,G),Q(8,he)],mi);const hi={id:`sheet.command.toggle-flip-drawings`,type:A.COMMAND,handler:(e,t)=>{let r=e.get(L),i=e.get(me),a=e.get(V),o=e.get(n);if(!t)return!1;let{drawings:s}=t,c=t.flipH,l=t.flipV,u=[],d=[];for(let t of s){let{unitId:n,subUnitId:r,drawingId:i}=t;u.push(n);let s=a.getDrawingData(n,r),f=s==null?void 0:s[i];if(!f)continue;let p={...f.transform};c&&(p.flipX=!p.flipX),l&&(p.flipY=!p.flipY);let m=o.getRenderById(n),h=m==null?void 0:m.with(g);if(!h)continue;let _=J(p,h),v=Y(p,h),y={unitId:n,subUnitId:r,drawingType:f.drawingType,drawingId:i,transform:p,sheetTransform:_,axisAlignSheetTransform:v};if(f.drawingType===I.DRAWING_IMAGE){let t=gi(e,n);if(t){let e=tn({unitId:n,subUnitId:r,drawingId:i}),a=t.getObject(e);if(a){let e=a.srcRect;if(e){let t,{left:n=0,top:r=0,right:i=0,bottom:a=0}=e;if(c){let e=n+(i-n)/2;t={left:e-(i-n)/2,top:r,right:e+(i-n)/2,bottom:a}}if(l){let e=r+(a-r)/2;t={left:n,top:e-(a-r)/2,right:i,bottom:e+(a-r)/2}}t&&(y.srcRect=t)}}}}d.push(y)}if(d.length===0)return!1;let{unitId:f,subUnitId:p,undo:m,redo:h,objects:_}=a.getBatchUpdateOp(d),v={id:H.id,params:{unitId:f,subUnitId:p,op:h,objects:_,type:B.UPDATE}},y={id:H.id,params:{unitId:f,subUnitId:p,op:m,objects:_,type:B.UPDATE}};return ze([v],r)?(i.pushUndoRedo({unitID:f,undoMutations:[y,{id:X.id,params:u}],redoMutations:[v,{id:X.id,params:u}]}),!0):!1}};function gi(e,t){let r=e.get(n).getRenderById(t);return r?r.scene:null}function _i(e){var t,n;return!!(!(e==null||(t=e.p)==null||(t=t.drawingsOrder)==null)&&t.length&&(e==null||(n=e.p)==null||(n=n.drawingsOrder)==null?void 0:n.length)>0)}function vi(e,t){let n=e.getActiveSheet();if(!n)return!1;let r=n.getCellMatrix(),{startRow:i,endRow:a,startColumn:o,endColumn:s}=t;for(let e=i;e<=a;e++)for(let t=o;t<=s;t++)if(_i(r.getValue(e,t)))return!0;return!1}function yi(){return`showDirectoryPicker`in window}function bi(e){let t=e.get(he),n=e.get(Tt),r=Fn([xn(e,z.UNIVER_SHEET),t.getCurrentTypeOfUnit$(z.UNIVER_SHEET).pipe(Bn(e=>e?n.selectionMoveEnd$.pipe(Rn(()=>{if(!yi())return!0;let t=n.getCurrentSelections();if(!t||t.length===0)return!0;for(let n of t)if(vi(e,n.range))return!1;return!0})):zn(!0)))]).pipe(Rn(([e,t])=>e||t));return{id:Er.id,type:_n.BUTTON,icon:`DownloadImageIcon`,title:`sheetImage.save.menuLabel`,hidden$:r}}const xi={[yn.MEDIA]:{[Mr]:{order:0,menuItemFactory:Nr,[fr.id]:{order:0,menuItemFactory:Pr},[pr.id]:{order:1,menuItemFactory:Fr}}},[sn.MAIN_AREA]:{[on.OTHERS]:{[Er.id]:{order:10,menuItemFactory:bi}}},[sn.COL_HEADER]:{[on.OTHERS]:{[Er.id]:{order:10,menuItemFactory:bi}}},[sn.ROW_HEADER]:{[on.OTHERS]:{[Er.id]:{order:10,menuItemFactory:bi}}}};function Si(){let e=Sn(xe),t=Sn(un),n=Sn(gr),[r,i]=qn([hr.CELL_ADDRESS]),[a,o]=qn(!1),[s,c]=qn(null),l=Kn(()=>n.getCellImagesInSelection(),[n]),u=Kn(()=>n.getDataColumns(),[n]),d=Kn(()=>n.getSelectionRowRange(),[n]),f=u.length>0,p=Kn(()=>u.map(e=>({label:e.label,value:String(e.index)})),[u]),[m,h]=qn(()=>p.length>0?p[0].value:`0`);D(Kn(()=>{if(!r.includes(hr.COLUMN_VALUE)||!d)return[];let e=Number(m);return[{startRow:d.startRow,endRow:d.endRow,startColumn:e,endColumn:e}]},[r,m,d]));let g=Wn(e=>{e.length!==0&&i(e)},[]),_=Wn(e=>{h(String(e))},[]),v=Wn(()=>{t.close(Tr)},[t]),y=Wn(async()=>{if(l.length!==0){o(!0),c(null);try{await n.saveImages(l,{fileNameParts:r,columnIndex:r.includes(hr.COLUMN_VALUE)?Number(m):void 0}),t.close(Tr)}catch(t){console.error(`Failed to save images:`,t),c(e.t(`sheetImage.save.error`))}finally{o(!1)}}},[n,l,r,m,t,e]),b=r.includes(hr.COLUMN_VALUE);return Jn(`div`,{className:`univer-flex univer-flex-col`,children:[K(Pt,{label:e.t(`sheetImage.save.imageCount`),children:K(`div`,{className:`univer-text-sm univer-text-gray-600`,children:l.length})}),K(Pt,{label:e.t(`sheetImage.save.fileNameConfig`),children:Jn(Nt,{value:r,onChange:g,direction:`vertical`,children:[K(Mt,{value:hr.CELL_ADDRESS,disabled:!f,children:e.t(`sheetImage.save.useRowCol`)}),f&&K(Mt,{value:hr.COLUMN_VALUE,children:e.t(`sheetImage.save.useColumnValue`)})]})}),b&&K(Pt,{label:e.t(`sheetImage.save.selectColumn`),children:K(Rt,{value:m,options:p,onChange:_})}),s&&K(`div`,{className:`univer-text-xs univer-text-red-500`,children:s}),Jn(`div`,{className:`
|
|
3
|
+
univer-flex univer-justify-end univer-gap-2 univer-border-t univer-border-gray-200 univer-pt-3
|
|
4
|
+
`,children:[K(jt,{onClick:v,disabled:a,children:e.t(`sheetImage.save.cancel`)}),K(jt,{variant:`primary`,onClick:y,disabled:a||l.length===0,children:a?e.t(`sheetImage.save.saving`):e.t(`sheetImage.save.confirm`)})]})]})}const Ci=e=>{var t;let r=Sn(L),i=Sn(xe),a=Sn(G),o=Sn(n),{drawings:s}=e,c=s[0];if(c==null)return;let{unitId:l}=c,u=o.getRenderById(l),d=u==null?void 0:u.scene;if(d==null)return;let f=d.getTransformerByCreate(),[p,m]=qn(!0),[h,g]=qn((t=c.anchorType)==null?U.Position:t);function _(e,t){let n=[];return e.forEach(e=>{let{oKey:r}=e,i=t.getDrawingOKey(r);if(i==null)return n.push(null),!0;let{unitId:a,subUnitId:o,drawingId:s,drawingType:c,anchorType:l,sheetTransform:u,axisAlignSheetTransform:d}=i;n.push({unitId:a,subUnitId:o,drawingId:s,anchorType:l,sheetTransform:u,drawingType:c,axisAlignSheetTransform:d})}),n}Gn(()=>{let e=f.clearControl$.subscribe(e=>{e===!0&&m(!1)}),t=f.changeStart$.subscribe(e=>{let{objects:t}=e,n=_(t,a);if(n.length===0)m(!1);else if(n.length>=1){var r;m(!0),g(((r=n[0])==null?void 0:r.anchorType)||U.Position)}});return()=>{t.unsubscribe(),e.unsubscribe()}},[]);function v(e){g(e);let t=a.getFocusDrawings();if(t.length===0)return;let n=t.map(t=>({unitId:t.unitId,subUnitId:t.subUnitId,drawingId:t.drawingId,anchorType:e}));r.executeCommand(ir.id,{unitId:t[0].unitId,drawings:n})}return Jn(`div`,{className:zt(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!p}),children:[K(`header`,{className:`
|
|
5
|
+
univer-text-gray-600
|
|
6
|
+
dark:!univer-text-gray-200
|
|
7
|
+
`,children:K(`div`,{children:i.t(`drawing-anchor.title`)})}),K(`div`,{children:Jn(Lt,{value:h,onChange:v,direction:`vertical`,children:[K(It,{value:U.Both,children:i.t(`drawing-anchor.both`)}),K(It,{value:U.Position,children:i.t(`drawing-anchor.position`)}),K(It,{value:U.None,children:i.t(`drawing-anchor.none`)})]})})]})},wi=()=>{let e=Sn(G),[t,n]=qn(e.getFocusDrawings());return Gn(()=>{let t=e.focus$.subscribe(e=>{n(e)});return()=>{t.unsubscribe()}},[]),!!(t!=null&&t.length)&&Jn(`div`,{className:`univer-text-sm`,children:[K(En,{drawings:t}),K(Ci,{drawings:t})]})};function Ti(e){return e.getContextValue(ce)&&!e.getContextValue(ae)&&!e.getContextValue(oe)&&e.getContextValue(ie)&&!e.getContextValue(se)}const Ei={id:mr.id,description:`shortcut.drawing-move-down`,group:`4_drawing-view`,binding:gn.ARROW_DOWN,priority:100,preconditions:Ti,staticParameters:{direction:P.DOWN}},Di={id:mr.id,description:`shortcut.drawing-move-up`,group:`4_drawing-view`,binding:gn.ARROW_UP,priority:100,preconditions:Ti,staticParameters:{direction:P.UP}},Oi={id:mr.id,description:`shortcut.drawing-move-left`,group:`4_drawing-view`,binding:gn.ARROW_LEFT,priority:100,preconditions:Ti,staticParameters:{direction:P.LEFT}},ki={id:mr.id,description:`shortcut.drawing-move-right`,group:`4_drawing-view`,binding:gn.ARROW_RIGHT,priority:100,preconditions:Ti,staticParameters:{direction:P.RIGHT}},Ai={id:Xn.id,description:`shortcut.drawing-delete`,group:`4_drawing-view`,priority:100,preconditions:Ti,binding:gn.DELETE,mac:gn.BACKSPACE};let ji=class extends F{constructor(e,t,n,r,i,a){super(),this._componentManager=e,this._menuManagerService=t,this._commandService=n,this._shortcutService=r,this._drawingManagerService=i,this._sheetsSelectionsService=a,this._init()}_initCustomComponents(){let e=this._componentManager;this.disposeWithMe(e.register(Dr,wi)),this.disposeWithMe(e.register(Tr,Si))}_initMenus(){this._menuManagerService.mergeMenu(xi)}_initCommands(){[fr,pr,nr,Yn,ir,Or,X,kr,tr,ar,mr,Xn,rr,Er,hi].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initShortcuts(){[Ei,Di,Oi,ki,Ai].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};ji=$([Q(0,R(an)),Q(1,fn),Q(2,L),Q(3,mn),Q(4,G),Q(5,R(Tt))],ji);let Mi=class extends ke{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._injector=e,this._localeService=t,this._drawingManagerService=n,this._canvasPopManagerService=r,this._renderManagerService=i,this._univerInstanceService=a,this._messageService=o,this._contextService=s,this._ioService=c,this._commandService=l,Z(this,`_initImagePopupMenu`,new Set),this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(z.UNIVER_SHEET).subscribe(e=>this._create(e)),this._univerInstanceService.getTypeOfUnitDisposed$(z.UNIVER_SHEET).subscribe(e=>this._dispose(e)),this._univerInstanceService.getAllUnitsForType(z.UNIVER_SHEET).forEach(e=>this._create(e)),this._setupLoadingStatus()}_setupLoadingStatus(){let e;this.disposeWithMe(this._ioService.change$.subscribe(t=>{t>0&&!e?e=this._messageService.show({id:`image-upload-loading`,type:Ft.Loading,content:`${this._localeService.t(`uploadLoading.loading`)}: ${t}`,duration:0}):t===0&&(e==null||e.dispose(),e=void 0)}))}_dispose(e){super.dispose();let t=e.getUnitId();this._renderManagerService.removeRender(t),this._initImagePopupMenu.delete(t)}_create(e){if(!e)return;let t=e.getUnitId();this._renderManagerService.has(t)&&!this._initImagePopupMenu.has(t)&&(this._popupMenuListener(t),this._initImagePopupMenu.add(t))}_hasCropObject(e){let t=e.getAllObjectsByOrder();for(let e of t)if(e instanceof On)return!0;return!1}_popupMenuListener(e){var t;let n=(t=this._renderManagerService.getRenderById(e))==null?void 0:t.scene;if(!n)return;let r=n.getTransformerByCreate();if(!r)return;let i;this.disposeWithMe(r.createControl$.subscribe(()=>{if(this._contextService.setContextValue(ie,!0),this._hasCropObject(n))return;let e=r.getSelectedObjectMap();if(e.size>1){i==null||i.dispose();return}let t=e.values().next().value;if(!t)return;let a=t.oKey,o=this._drawingManagerService.getDrawingOKey(a);if(!o)return;let{unitId:s,subUnitId:c,drawingId:l,drawingType:u}=o,d=o.data;if(d&&d.disablePopup)return;i==null||i.dispose();let f=this._canvasPopManagerService.getFeatureMenu(s,c,l,u);i=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(t,{componentKey:Tn,direction:`horizontal`,offset:[2,0],extraProps:{menuItems:f||this._getImageMenuItems(s,c,l,u)}}))})),this.disposeWithMe(r.clearControl$.subscribe(()=>{i==null||i.dispose(),this._contextService.setContextValue(ie,!1),this._commandService.syncExecuteCommand($t.id,[])})),this.disposeWithMe(this._contextService.contextChanged$.subscribe(e=>{e[ie]===!1&&(i==null||i.dispose())})),this.disposeWithMe(r.changing$.subscribe(()=>{i==null||i.dispose()}))}_getImageMenuItems(e,t,n,r){return[{label:`image-popup.edit`,index:0,commandId:kr.id,commandParams:{unitId:e,subUnitId:t,drawingId:n},disable:r===I.DRAWING_DOM},{label:`image-popup.delete`,index:1,commandId:Yn.id,commandParams:{unitId:e,drawings:[{unitId:e,subUnitId:t,drawingId:n}]},disable:!1},{label:`image-popup.crop`,index:2,commandId:An.id,commandParams:{unitId:e,subUnitId:t,drawingId:n},disable:r===I.DRAWING_DOM},{label:`image-popup.flipH`,index:2,commandId:hi.id,commandParams:{unitId:e,flipH:!0,drawings:[{unitId:e,subUnitId:t,drawingId:n}]},disable:r===I.DRAWING_DOM},{label:`image-popup.flipV`,index:2,commandId:hi.id,commandParams:{unitId:e,flipV:!0,drawings:[{unitId:e,subUnitId:t,drawingId:n}]},disable:r===I.DRAWING_DOM},{label:`image-popup.reset`,index:3,commandId:kn.id,commandParams:[{unitId:e,subUnitId:t,drawingId:n}],disable:r===I.DRAWING_DOM}]}};Mi=$([Q(0,R(_e)),Q(1,R(xe)),Q(2,G),Q(3,R(x)),Q(4,n),Q(5,he),Q(6,pn),Q(7,ue),Q(8,de),Q(9,L)],Mi);let Ni=class extends Ee{constructor(e=zr,t,n,r){super(),this._config=e,this._injector=t,this._renderManagerService=n,this._configService=r;let{menu:i,...a}=Le({},zr,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(Rr,a)}onStarting(){Re(this._injector,[[ai],[ji],[Mi],[ui],[ei],[$r],[jr],[Wr],[Gr],[qr],[gr,{useClass:wr}],[Br]]),Be(this._injector,[[ai]])}onReady(){Be(this._injector,[[$r],[qr],[jr]])}onRendered(){this._registerRenderModules(),Be(this._injector,[[ei],[ui],[ji],[Wr],[Gr]])}onSteady(){this._injector.get(Mi),this._injector.get(Br)}_registerRenderModules(){[[dr],[mi],[Hr],[Vr]].forEach(e=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(z.UNIVER_SHEET,e))})}};Z(Ni,`type`,z.UNIVER_SHEET),Z(Ni,`pluginName`,`SHEET_IMAGE_UI_PLUGIN`),Z(Ni,`packageName`,Ir),Z(Ni,`version`,Lr),Ni=$([ne(en,wn,jn,Ve),Q(1,R(_e)),Q(2,n),Q(3,le)],Ni);export{wr as BatchSaveImagesService,X as ClearSheetDrawingTransformerOperation,Xn as DeleteDrawingsCommand,kr as EditSheetDrawingOperation,hr as FileNamePart,tr as GroupSheetDrawingCommand,gr as IBatchSaveImagesService,fr as InsertFloatImageCommand,nr as InsertSheetDrawingCommand,mr as MoveDrawingsCommand,Yn as RemoveSheetDrawingCommand,Mr as SHEETS_IMAGE_MENU_ID,ni as SHEET_FLOAT_DOM_PREFIX,Er as SaveCellImagesCommand,rr as SetDrawingArrangeCommand,ir as SetSheetDrawingCommand,ai as SheetCanvasFloatDomManagerService,Ci as SheetDrawingAnchor,dr as SheetDrawingUpdateController,jr as SheetsDrawingGroupCopyPasteController,Or as SidebarSheetDrawingOperation,ar as UngroupSheetDrawingCommand,Ni as UniverSheetsDrawingUIPlugin,ii as calcSheetFloatDomPosition,q as drawingPositionToTransform,Y as transformToAxisAlignPosition,J as transformToDrawingPosition};
|