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