@univerjs/sheets-drawing-ui 0.4.2-nightly.202411071606 → 0.4.2-nightly.202411081606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/locale/en-US.js +1 -0
- package/lib/cjs/locale/fa-IR.js +1 -0
- package/lib/cjs/locale/ru-RU.js +1 -0
- package/lib/cjs/locale/vi-VN.js +1 -0
- package/lib/cjs/locale/zh-CN.js +1 -0
- package/lib/cjs/locale/zh-TW.js +1 -0
- package/lib/es/facade.js +420 -18
- package/lib/es/index.js +1904 -1512
- package/lib/{locale → es/locale}/en-US.js +2 -2
- package/lib/{locale → es/locale}/fa-IR.js +2 -2
- package/lib/{locale → es/locale}/ru-RU.js +2 -2
- package/lib/{locale → es/locale}/vi-VN.js +2 -2
- package/lib/{locale → es/locale}/zh-CN.js +2 -2
- package/lib/{locale → es/locale}/zh-TW.js +2 -2
- package/lib/umd/index.js +1 -9
- package/package.json +27 -19
- package/lib/canvas-float-dom-manager.service-t4WyJLnC.mjs +0 -416
package/lib/es/facade.js
CHANGED
|
@@ -1,20 +1,422 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
var de = Object.defineProperty;
|
|
2
|
+
var he = (h, n, e) => n in h ? de(h, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[n] = e;
|
|
3
|
+
var w = (h, n, e) => he(h, typeof n != "symbol" ? n + "" : n, e);
|
|
4
|
+
import { FWorksheet as te } from "@univerjs/sheets/facade";
|
|
5
|
+
import { transformComponentKey as le } from "@univerjs/sheets-ui/facade";
|
|
6
|
+
import { CanvasFloatDomService as ge, ComponentManager as pe } from "@univerjs/ui";
|
|
7
|
+
import { CommandType as ne, ICommandService as re, IUndoRedoService as fe, sequenceExecute as me, Inject as W, LifecycleService as ue, IUniverInstanceService as Se, Disposable as _e, LifecycleStages as ve, DisposableCollection as we, UniverInstanceType as Ie, fromEventSubject as Me, generateRandomId as ye } from "@univerjs/core";
|
|
8
|
+
import { IDrawingManagerService as be, DrawingTypeEnum as P, getDrawingShapeKeyByDrawingSearch as x } from "@univerjs/drawing";
|
|
9
|
+
import { IRenderManagerService as oe, Rect as J, ObjectType as De, DRAWING_OBJECT_LAYER_INDEX as Ee, SHEET_VIEWPORT_KEY as Oe } from "@univerjs/engine-render";
|
|
10
|
+
import { SheetInterceptorService as Te, getSheetCommandTarget as $, SetFrozenMutation as Ce } from "@univerjs/sheets";
|
|
11
|
+
import { ISheetDrawingService as se, SetDrawingApplyMutation as X, DrawingApplyType as H } from "@univerjs/sheets-drawing";
|
|
12
|
+
import { SheetSkeletonManagerService as Z, VIEWPORT_KEY as Re, SetZoomRatioOperation as Pe, ISheetSelectionRenderService as Ae } from "@univerjs/sheets-ui";
|
|
13
|
+
import { Subject as F, filter as Y, take as Be, BehaviorSubject as Ue, map as Q, switchMap as We } from "rxjs";
|
|
14
|
+
const ee = {
|
|
15
|
+
id: "sheet.operation.clear-drawing-transformer",
|
|
16
|
+
type: ne.MUTATION,
|
|
17
|
+
handler: (h, n) => {
|
|
18
|
+
const e = h.get(oe);
|
|
19
|
+
return n.forEach((t) => {
|
|
20
|
+
var r, o;
|
|
21
|
+
(o = (r = e.getRenderById(t)) == null ? void 0 : r.scene.getTransformer()) == null || o.debounceRefreshControls();
|
|
22
|
+
}), !0;
|
|
16
23
|
}
|
|
24
|
+
}, ie = {
|
|
25
|
+
id: "sheet.command.insert-sheet-image",
|
|
26
|
+
type: ne.COMMAND,
|
|
27
|
+
handler: (h, n) => {
|
|
28
|
+
var b, S, _;
|
|
29
|
+
const e = h.get(re), t = h.get(fe), r = h.get(se), o = h.get(Te);
|
|
30
|
+
if (!n) return !1;
|
|
31
|
+
const s = n.drawings, i = s.map((I) => I.unitId), a = r.getBatchAddOp(s), { unitId: d, subUnitId: c, undo: l, redo: g, objects: p } = a, f = o.onCommandExecute({ id: ie.id, params: n }), M = { id: X.id, params: { op: g, unitId: d, subUnitId: c, objects: p, type: H.INSERT } }, y = { id: X.id, params: { op: l, unitId: d, subUnitId: c, objects: p, type: H.REMOVE } };
|
|
32
|
+
return me([...(b = f.preRedos) != null ? b : [], M, ...f.redos], e) ? (t.pushUndoRedo({
|
|
33
|
+
unitID: d,
|
|
34
|
+
undoMutations: [
|
|
35
|
+
...(S = f.preUndos) != null ? S : [],
|
|
36
|
+
y,
|
|
37
|
+
...f.undos,
|
|
38
|
+
{ id: ee.id, params: i }
|
|
39
|
+
],
|
|
40
|
+
redoMutations: [
|
|
41
|
+
...(_ = f.preRedos) != null ? _ : [],
|
|
42
|
+
M,
|
|
43
|
+
...f.redos,
|
|
44
|
+
{ id: ee.id, params: i }
|
|
45
|
+
]
|
|
46
|
+
}), !0) : !1;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var ke = Object.defineProperty, je = Object.getOwnPropertyDescriptor, Le = (h, n, e, t) => {
|
|
50
|
+
for (var r = t > 1 ? void 0 : t ? je(n, e) : n, o = h.length - 1, s; o >= 0; o--)
|
|
51
|
+
(s = h[o]) && (r = (t ? s(n, e, r) : s(r)) || r);
|
|
52
|
+
return t && r && ke(n, e, r), r;
|
|
53
|
+
}, E = (h, n) => (e, t) => n(e, t, h);
|
|
54
|
+
function xe(h, n, e, t) {
|
|
55
|
+
const { scaleX: r, scaleY: o } = n.getAncestorScale(), s = n.getViewport(Oe.VIEW_MAIN), i = {
|
|
56
|
+
left: !0,
|
|
57
|
+
top: !0
|
|
58
|
+
};
|
|
59
|
+
if (!s)
|
|
60
|
+
return {
|
|
61
|
+
...h,
|
|
62
|
+
absolute: i
|
|
63
|
+
};
|
|
64
|
+
const { left: a, right: d, top: c, bottom: l } = h, g = t.getFreeze(), { startColumn: p, startRow: f, xSplit: M, ySplit: y } = g, O = e.getNoMergeCellPositionByIndexWithNoHeader(f - y, p - M), b = e.getNoMergeCellPositionByIndexWithNoHeader(f, p), { rowHeaderWidth: S, columnHeaderHeight: _ } = e, I = b.startX - O.startX, D = b.startY - O.startY, { top: A, left: B, viewportScrollX: U, viewportScrollY: T } = s;
|
|
65
|
+
let C, u;
|
|
66
|
+
a < B ? (i.left = !0, C = (I + S + (a - B)) * r, u = Math.max(
|
|
67
|
+
Math.min(
|
|
68
|
+
(I + S + (d - B)) * r,
|
|
69
|
+
(I + S) * r
|
|
70
|
+
),
|
|
71
|
+
(d - U) * r
|
|
72
|
+
)) : (i.left = !1, C = Math.max((a - U) * r, (I + S) * r), u = Math.max((d - U) * r, (I + S) * r));
|
|
73
|
+
let R, v;
|
|
74
|
+
return c < A ? (i.top = !0, R = (D + _ + (c - A)) * o, v = Math.max(
|
|
75
|
+
Math.min(
|
|
76
|
+
(D + _ + (d - A)) * o,
|
|
77
|
+
(D + _) * o
|
|
78
|
+
),
|
|
79
|
+
(l - T) * o
|
|
80
|
+
)) : (i.top = !1, R = Math.max((c - T) * o, (D + _) * o), v = Math.max((l - T) * o, (D + _) * o)), {
|
|
81
|
+
left: C,
|
|
82
|
+
right: u,
|
|
83
|
+
top: R,
|
|
84
|
+
bottom: v,
|
|
85
|
+
absolute: i
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const N = (h, n, e, t) => {
|
|
89
|
+
const { scene: r } = n, { left: o, top: s, width: i, height: a, angle: d } = h, c = {
|
|
90
|
+
left: o,
|
|
91
|
+
right: o + i,
|
|
92
|
+
top: s,
|
|
93
|
+
bottom: s + a
|
|
94
|
+
}, l = xe(c, r, e, t), { scaleX: g, scaleY: p } = r.getAncestorScale();
|
|
95
|
+
return {
|
|
96
|
+
startX: l.left,
|
|
97
|
+
endX: l.right,
|
|
98
|
+
startY: l.top,
|
|
99
|
+
endY: l.bottom,
|
|
100
|
+
rotate: d,
|
|
101
|
+
width: i * g,
|
|
102
|
+
height: a * p,
|
|
103
|
+
absolute: l.absolute
|
|
104
|
+
};
|
|
17
105
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
106
|
+
let K = class extends _e {
|
|
107
|
+
constructor(n, e, t, r, o, s, i) {
|
|
108
|
+
super();
|
|
109
|
+
w(this, "_domLayerMap", /* @__PURE__ */ new Map());
|
|
110
|
+
w(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
|
|
111
|
+
w(this, "_transformChange$", new F());
|
|
112
|
+
w(this, "transformChange$", this._transformChange$.asObservable());
|
|
113
|
+
w(this, "_add$", new F());
|
|
114
|
+
w(this, "add$", this._add$.asObservable());
|
|
115
|
+
w(this, "_remove$", new F());
|
|
116
|
+
w(this, "remove$", this._remove$.asObservable());
|
|
117
|
+
w(this, "_hooks", []);
|
|
118
|
+
this._renderManagerService = n, this._univerInstanceService = e, this._commandService = t, this._drawingManagerService = r, this._canvasFloatDomService = o, this._sheetDrawingService = s, this._lifecycleService = i, this._drawingAddListener(), this._featureUpdateListener(), this._deleteListener(), this._bindScrollEvent();
|
|
119
|
+
}
|
|
120
|
+
_bindScrollEvent() {
|
|
121
|
+
this._lifecycleService.lifecycle$.pipe(Y((n) => n === ve.Rendered), Be(1)).subscribe(() => {
|
|
122
|
+
this._scrollUpdateListener();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
_ensureMap(n, e) {
|
|
126
|
+
let t = this._domLayerMap.get(n);
|
|
127
|
+
t || (t = /* @__PURE__ */ new Map(), this._domLayerMap.set(n, t));
|
|
128
|
+
let r = t.get(e);
|
|
129
|
+
return r || (r = /* @__PURE__ */ new Map(), t.set(e, r)), r;
|
|
130
|
+
}
|
|
131
|
+
getFloatDomInfo(n) {
|
|
132
|
+
return this._domLayerInfoMap.get(n);
|
|
133
|
+
}
|
|
134
|
+
_getSceneAndTransformerByDrawingSearch(n) {
|
|
135
|
+
if (n == null)
|
|
136
|
+
return;
|
|
137
|
+
const e = this._renderManagerService.getRenderById(n), t = e == null ? void 0 : e.scene;
|
|
138
|
+
if (e == null || t == null)
|
|
139
|
+
return null;
|
|
140
|
+
const r = t.getTransformerByCreate(), o = e.engine.getCanvasElement();
|
|
141
|
+
return { scene: t, transformer: r, renderObject: e, canvas: o };
|
|
142
|
+
}
|
|
143
|
+
_getFloatDomProps(n) {
|
|
144
|
+
let e;
|
|
145
|
+
return this._hooks.forEach((t) => {
|
|
146
|
+
e = t.onGetFloatDomProps(n);
|
|
147
|
+
}), e;
|
|
148
|
+
}
|
|
149
|
+
// eslint-disable-next-line max-lines-per-function
|
|
150
|
+
_drawingAddListener() {
|
|
151
|
+
this.disposeWithMe(
|
|
152
|
+
// eslint-disable-next-line max-lines-per-function
|
|
153
|
+
this._drawingManagerService.add$.subscribe((n) => {
|
|
154
|
+
n.forEach((e) => {
|
|
155
|
+
var z, G, q;
|
|
156
|
+
const { unitId: t, subUnitId: r, drawingId: o } = e, s = $(this._univerInstanceService, { unitId: t, subUnitId: r }), i = this._drawingManagerService.getDrawingByParam(e), a = this._univerInstanceService.getUnit(t);
|
|
157
|
+
if (!a)
|
|
158
|
+
return;
|
|
159
|
+
const d = a.getActiveSheet().getSheetId();
|
|
160
|
+
if (!i || !s)
|
|
161
|
+
return;
|
|
162
|
+
const c = (z = this._renderManagerService.getRenderById(t)) == null ? void 0 : z.with(Z).getWorksheetSkeleton(r);
|
|
163
|
+
if (!c)
|
|
164
|
+
return;
|
|
165
|
+
const { transform: l, drawingType: g, data: p } = i;
|
|
166
|
+
if (g !== P.DRAWING_DOM && g !== P.DRAWING_CHART)
|
|
167
|
+
return;
|
|
168
|
+
const f = this._getSceneAndTransformerByDrawingSearch(t);
|
|
169
|
+
if (f == null)
|
|
170
|
+
return;
|
|
171
|
+
const { scene: M, canvas: y } = f;
|
|
172
|
+
if (l == null)
|
|
173
|
+
return !0;
|
|
174
|
+
if (d !== r)
|
|
175
|
+
return;
|
|
176
|
+
const { left: O, top: b, width: S, height: _, angle: I, flipX: D, flipY: A, skewX: B, skewY: U } = l, T = x({ unitId: t, subUnitId: r, drawingId: o }), C = M.getObject(T);
|
|
177
|
+
if (C != null) {
|
|
178
|
+
C.transformByState({ left: O, top: b, width: S, height: _, angle: I, flipX: D, flipY: A, skewX: B, skewY: U });
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const u = {
|
|
182
|
+
left: O,
|
|
183
|
+
top: b,
|
|
184
|
+
width: S,
|
|
185
|
+
height: _,
|
|
186
|
+
zIndex: this._drawingManagerService.getDrawingOrder(t, r).length - 1
|
|
187
|
+
}, R = g === P.DRAWING_CHART;
|
|
188
|
+
R && (u.fill = "white", u.rotateEnabled = !1, p && p.border && (u.stroke = p.border), u.paintFirst = "stroke", u.strokeWidth = 1, u.borderEnabled = !1, u.radius = 8);
|
|
189
|
+
const v = new J(T, u);
|
|
190
|
+
R && v.setObjectType(De.CHART), M.addObject(v, Ee), i.allowTransform !== !1 && M.attachTransformerTo(v);
|
|
191
|
+
const k = this._ensureMap(t, r), j = new we(), ae = N(v, f.renderObject, c.skeleton, s.worksheet), L = new Ue(ae), ce = {
|
|
192
|
+
dispose: j,
|
|
193
|
+
rect: v,
|
|
194
|
+
position$: L,
|
|
195
|
+
unitId: t,
|
|
196
|
+
subUnitId: r
|
|
197
|
+
};
|
|
198
|
+
this._canvasFloatDomService.addFloatDom({
|
|
199
|
+
position$: L,
|
|
200
|
+
id: o,
|
|
201
|
+
componentKey: i.componentKey,
|
|
202
|
+
onPointerDown: (m) => {
|
|
203
|
+
y.dispatchEvent(new PointerEvent(m.type, m));
|
|
204
|
+
},
|
|
205
|
+
onPointerMove: (m) => {
|
|
206
|
+
y.dispatchEvent(new PointerEvent(m.type, m));
|
|
207
|
+
},
|
|
208
|
+
onPointerUp: (m) => {
|
|
209
|
+
y.dispatchEvent(new PointerEvent(m.type, m));
|
|
210
|
+
},
|
|
211
|
+
onWheel: (m) => {
|
|
212
|
+
y.dispatchEvent(new WheelEvent(m.type, m));
|
|
213
|
+
},
|
|
214
|
+
props: (q = (G = k.get(o)) == null ? void 0 : G.props) != null ? q : this._getFloatDomProps(o),
|
|
215
|
+
data: p,
|
|
216
|
+
unitId: t
|
|
217
|
+
});
|
|
218
|
+
const V = v.onTransformChange$.subscribeEvent(() => {
|
|
219
|
+
const m = N(v, f.renderObject, c.skeleton, s.worksheet);
|
|
220
|
+
L.next(
|
|
221
|
+
m
|
|
222
|
+
);
|
|
223
|
+
});
|
|
224
|
+
j.add(() => {
|
|
225
|
+
this._canvasFloatDomService.removeFloatDom(o);
|
|
226
|
+
}), V && j.add(V), this._domLayerInfoMap.set(o, ce), k.set(o, {
|
|
227
|
+
...k.get(o)
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
})
|
|
231
|
+
), this.disposeWithMe(
|
|
232
|
+
this._drawingManagerService.remove$.subscribe((n) => {
|
|
233
|
+
n.forEach((e) => {
|
|
234
|
+
const { unitId: t, subUnitId: r, drawingId: o } = e, s = x({ unitId: t, subUnitId: r, drawingId: o }), i = this._getSceneAndTransformerByDrawingSearch(t);
|
|
235
|
+
if (i == null)
|
|
236
|
+
return;
|
|
237
|
+
const { transformer: a, scene: d } = i, c = d.getObject(s);
|
|
238
|
+
c != null && c.oKey && a.clearControlByIds([c == null ? void 0 : c.oKey]);
|
|
239
|
+
});
|
|
240
|
+
})
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
_scrollUpdateListener() {
|
|
244
|
+
const n = (e, t) => {
|
|
245
|
+
var d;
|
|
246
|
+
const r = this._getSceneAndTransformerByDrawingSearch(e), o = this._ensureMap(e, t), s = Array.from(o.keys()), i = $(this._univerInstanceService, { unitId: e, subUnitId: t }), a = (d = this._renderManagerService.getRenderById(e)) == null ? void 0 : d.with(Z).getWorksheetSkeleton(t);
|
|
247
|
+
!r || !i || !a || s.forEach((c) => {
|
|
248
|
+
const l = this._domLayerInfoMap.get(c);
|
|
249
|
+
if (l) {
|
|
250
|
+
const g = N(l.rect, r.renderObject, a.skeleton, i.worksheet);
|
|
251
|
+
l.position$.next(g);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
this.disposeWithMe(
|
|
256
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(Ie.UNIVER_SHEET).pipe(
|
|
257
|
+
Y((e) => !!e),
|
|
258
|
+
Q((e) => {
|
|
259
|
+
const t = this._renderManagerService.getRenderById(e.getUnitId());
|
|
260
|
+
return t ? { render: t, unitId: e.getUnitId(), subUnitId: e.getActiveSheet().getSheetId() } : null;
|
|
261
|
+
}),
|
|
262
|
+
Y((e) => !!e),
|
|
263
|
+
We(
|
|
264
|
+
(e) => Me(e.render.scene.getViewport(Re.VIEW_MAIN).onScrollAfter$).pipe(Q(() => ({ unitId: e.unitId, subUnitId: e.subUnitId })))
|
|
265
|
+
)
|
|
266
|
+
).subscribe(({ unitId: e, subUnitId: t }) => {
|
|
267
|
+
n(e, t);
|
|
268
|
+
})
|
|
269
|
+
), this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
|
|
270
|
+
var t, r;
|
|
271
|
+
if (e.id === Pe.id) {
|
|
272
|
+
const o = e.params, { unitId: s } = o;
|
|
273
|
+
Array.from((r = (t = this._domLayerMap.get(s)) == null ? void 0 : t.keys()) != null ? r : []).forEach((a) => {
|
|
274
|
+
n(s, a);
|
|
275
|
+
});
|
|
276
|
+
} else if (e.id === Ce.id) {
|
|
277
|
+
const { unitId: o, subUnitId: s } = e.params;
|
|
278
|
+
n(o, s);
|
|
279
|
+
}
|
|
280
|
+
}));
|
|
281
|
+
}
|
|
282
|
+
_getPosition(n, e) {
|
|
283
|
+
var g;
|
|
284
|
+
const { startX: t, endX: r, startY: o, endY: s } = n, i = (g = this._renderManagerService.getRenderById(e)) == null ? void 0 : g.with(Ae);
|
|
285
|
+
if (i == null)
|
|
286
|
+
return;
|
|
287
|
+
const a = i.getSelectionCellByPosition(t, o);
|
|
288
|
+
if (a == null)
|
|
289
|
+
return;
|
|
290
|
+
const d = {
|
|
291
|
+
column: a.actualColumn,
|
|
292
|
+
columnOffset: t - a.startX,
|
|
293
|
+
row: a.actualRow,
|
|
294
|
+
rowOffset: o - a.startY
|
|
295
|
+
}, c = i.getSelectionCellByPosition(r, s);
|
|
296
|
+
if (c == null)
|
|
297
|
+
return;
|
|
298
|
+
const l = {
|
|
299
|
+
column: c.actualColumn,
|
|
300
|
+
columnOffset: r - c.startX,
|
|
301
|
+
row: c.actualRow,
|
|
302
|
+
rowOffset: s - c.startY
|
|
303
|
+
};
|
|
304
|
+
return {
|
|
305
|
+
from: d,
|
|
306
|
+
to: l
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
_featureUpdateListener() {
|
|
310
|
+
this.disposeWithMe(
|
|
311
|
+
this._drawingManagerService.update$.subscribe((n) => {
|
|
312
|
+
n.forEach((e) => {
|
|
313
|
+
const t = this._drawingManagerService.getDrawingByParam(e);
|
|
314
|
+
if (!t || t.drawingType !== P.DRAWING_DOM && t.drawingType !== P.DRAWING_CHART)
|
|
315
|
+
return;
|
|
316
|
+
const r = {
|
|
317
|
+
...t.transform
|
|
318
|
+
};
|
|
319
|
+
this._transformChange$.next({ id: e.drawingId, value: r });
|
|
320
|
+
});
|
|
321
|
+
})
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
_deleteListener() {
|
|
325
|
+
this.disposeWithMe(
|
|
326
|
+
this._drawingManagerService.remove$.subscribe((n) => {
|
|
327
|
+
n.forEach((e) => {
|
|
328
|
+
this._removeDom(e.drawingId);
|
|
329
|
+
});
|
|
330
|
+
})
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
updateFloatDomProps(n, e, t, r) {
|
|
334
|
+
const o = this._domLayerInfoMap.get(t), s = this._getSceneAndTransformerByDrawingSearch(n);
|
|
335
|
+
if (o && s) {
|
|
336
|
+
const { scene: i } = s, a = x({ unitId: n, subUnitId: e, drawingId: t }), d = i.getObject(a);
|
|
337
|
+
d && d instanceof J && d.setProps(r);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
addFloatDomToPosition(n, e) {
|
|
341
|
+
const t = $(this._univerInstanceService, {
|
|
342
|
+
unitId: n.unitId,
|
|
343
|
+
subUnitId: n.subUnitId
|
|
344
|
+
});
|
|
345
|
+
if (!t)
|
|
346
|
+
throw new Error("cannot find current target!");
|
|
347
|
+
const { unitId: r, subUnitId: o } = t, { initPosition: s, componentKey: i, data: a, allowTransform: d = !0 } = n, c = e != null ? e : ye(), l = this._getPosition(s, r);
|
|
348
|
+
if (l == null)
|
|
349
|
+
return;
|
|
350
|
+
this._ensureMap(r, o).set(c, n);
|
|
351
|
+
const p = {
|
|
352
|
+
unitId: r,
|
|
353
|
+
subUnitId: o,
|
|
354
|
+
drawingId: c,
|
|
355
|
+
drawingType: n.type || P.DRAWING_DOM,
|
|
356
|
+
componentKey: i,
|
|
357
|
+
sheetTransform: l,
|
|
358
|
+
transform: {
|
|
359
|
+
left: s.startX,
|
|
360
|
+
top: s.startY,
|
|
361
|
+
width: s.endX - s.startX,
|
|
362
|
+
height: s.endY - s.startY
|
|
363
|
+
},
|
|
364
|
+
data: a,
|
|
365
|
+
allowTransform: d
|
|
366
|
+
};
|
|
367
|
+
return this._commandService.executeCommand(ie.id, {
|
|
368
|
+
unitId: r,
|
|
369
|
+
drawings: [p]
|
|
370
|
+
}), this._add$.next({ unitId: r, subUnitId: o, id: c }), {
|
|
371
|
+
id: c,
|
|
372
|
+
dispose: () => {
|
|
373
|
+
this._removeDom(c, !0);
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
_removeDom(n, e = !1) {
|
|
378
|
+
const t = this._domLayerInfoMap.get(n);
|
|
379
|
+
if (!t)
|
|
380
|
+
return;
|
|
381
|
+
const { unitId: r, subUnitId: o } = t;
|
|
382
|
+
this._domLayerInfoMap.delete(n), t.dispose.dispose();
|
|
383
|
+
const s = this._getSceneAndTransformerByDrawingSearch(r);
|
|
384
|
+
if (s && s.scene.removeObject(t.rect), e) {
|
|
385
|
+
this._ensureMap(r, o).delete(n);
|
|
386
|
+
const a = this._drawingManagerService.getDrawingByParam({ unitId: r, subUnitId: o, drawingId: n });
|
|
387
|
+
if (!a)
|
|
388
|
+
return;
|
|
389
|
+
const d = this._sheetDrawingService.getBatchRemoveOp([a]), { redo: c, objects: l } = d;
|
|
390
|
+
this._commandService.syncExecuteCommand(X.id, { unitId: r, subUnitId: o, op: c, objects: l, type: H.REMOVE });
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
addHook(n) {
|
|
394
|
+
return this._hooks.push(n), {
|
|
395
|
+
dispose: () => {
|
|
396
|
+
const e = this._hooks.findIndex((t) => t === n);
|
|
397
|
+
this._hooks.splice(e, 1);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
K = Le([
|
|
403
|
+
E(0, W(oe)),
|
|
404
|
+
E(1, Se),
|
|
405
|
+
E(2, W(re)),
|
|
406
|
+
E(3, be),
|
|
407
|
+
E(4, W(ge)),
|
|
408
|
+
E(5, se),
|
|
409
|
+
E(6, W(ue))
|
|
410
|
+
], K);
|
|
411
|
+
class $e extends te {
|
|
412
|
+
addFloatDomToPosition(n, e) {
|
|
413
|
+
const t = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), { key: o, disposableCollection: s } = le(n, this._injector.get(pe)), a = this._injector.get(K).addFloatDomToPosition({ ...n, componentKey: o, unitId: t, subUnitId: r }, e);
|
|
414
|
+
return a ? (s.add(a.dispose), {
|
|
415
|
+
id: a.id,
|
|
416
|
+
dispose: () => {
|
|
417
|
+
s.dispose(), a.dispose();
|
|
418
|
+
}
|
|
419
|
+
}) : (s.dispose(), null);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
te.extend($e);
|