@univerjs/drawing-ui 0.6.7 → 0.6.8
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/index.js +1932 -0
- package/lib/locale/en-US.js +57 -0
- package/lib/locale/fa-IR.js +57 -0
- package/lib/locale/fr-FR.js +57 -0
- package/lib/locale/ru-RU.js +57 -0
- package/lib/locale/vi-VN.js +57 -0
- package/lib/locale/zh-CN.js +57 -0
- package/lib/locale/zh-TW.js +57 -0
- package/package.json +9 -9
package/lib/index.js
ADDED
|
@@ -0,0 +1,1932 @@
|
|
|
1
|
+
var En = Object.defineProperty;
|
|
2
|
+
var Bn = (i, t, n) => t in i ? En(i, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[t] = n;
|
|
3
|
+
var ee = (i, t, n) => Bn(i, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { UniverInstanceType as Oe, DrawingTypeEnum as ne, CommandType as ve, ICommandService as me, LocaleService as te, ArrangeTypeEnum as be, Tools as jn, debounce as Ie, Inject as Le, Disposable as xe, checkIfMove as sn, toDisposable as Ce, IUniverInstanceService as Ke, ImageSourceType as Xe, Injector as Un, IConfigService as An, Plugin as Hn, merge as Ln } from "@univerjs/core";
|
|
5
|
+
import { getDrawingShapeKeyByDrawingSearch as G, ImageSourceType as xn, IDrawingManagerService as re, IImageIoService as cn, SetDrawingSelectedOperation as Ne } from "@univerjs/drawing";
|
|
6
|
+
import { Group as we, DRAWING_OBJECT_LAYER_INDEX as De, Image as ze, Rect as ln, IRenderManagerService as ue, getGroupState as Vn, transformObjectOutOfGroup as kn, RENDER_CLASS_TYPE as Je, Shape as Gn, Canvas as Wn, precisionTo as ye, CURSOR_TYPE as Te, Vector2 as Ge, degToRad as qe } from "@univerjs/engine-render";
|
|
7
|
+
import { IDialogService as gn, useDependency as V, ComponentManager as $n, IMessageService as zn } from "@univerjs/ui";
|
|
8
|
+
import { jsxs as j, jsx as u, Fragment as Fn } from "react/jsx-runtime";
|
|
9
|
+
import { useState as x, forwardRef as Z, useRef as mn, createElement as X, useEffect as _e } from "react";
|
|
10
|
+
import { clsx as B, Select as dn, Button as le, InputNumber as pe, Checkbox as Kn, DropdownMenu as Yn, MessageType as Qe } from "@univerjs/design";
|
|
11
|
+
import { switchMap as Zn, of as Xn } from "rxjs";
|
|
12
|
+
function en(i, t, n, e) {
|
|
13
|
+
const r = e.getDrawingByParam(i);
|
|
14
|
+
if (r == null)
|
|
15
|
+
return;
|
|
16
|
+
const o = G(i), a = n.getObject(o);
|
|
17
|
+
if (a && !(a instanceof we))
|
|
18
|
+
return;
|
|
19
|
+
if (a != null) {
|
|
20
|
+
a.addObject(t);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const s = new we(o);
|
|
24
|
+
n.addObject(s, De).attachTransformerTo(s), s.addObject(t);
|
|
25
|
+
const { transform: c } = r;
|
|
26
|
+
c && s.transformByState(
|
|
27
|
+
{
|
|
28
|
+
left: c.left,
|
|
29
|
+
top: c.top,
|
|
30
|
+
angle: c.angle
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function un(i, t) {
|
|
35
|
+
var o;
|
|
36
|
+
const n = t ? i.getUnit(t) : i.getFocusedUnit();
|
|
37
|
+
if (n == null)
|
|
38
|
+
return;
|
|
39
|
+
const e = n.getUnitId();
|
|
40
|
+
let r;
|
|
41
|
+
return n.type === Oe.UNIVER_SHEET ? r = (o = n.getActiveSheet()) == null ? void 0 : o.getSheetId() : (n.type === Oe.UNIVER_DOC || n.type === Oe.UNIVER_SLIDE) && (r = e), { unitId: e, subUnitId: r, current: n };
|
|
42
|
+
}
|
|
43
|
+
const hn = "COMPONENT_IMAGE_VIEWER";
|
|
44
|
+
var Jn = Object.getOwnPropertyDescriptor, qn = (i, t, n, e) => {
|
|
45
|
+
for (var r = e > 1 ? void 0 : e ? Jn(t, n) : t, o = i.length - 1, a; o >= 0; o--)
|
|
46
|
+
(a = i[o]) && (r = a(r) || r);
|
|
47
|
+
return r;
|
|
48
|
+
}, We = (i, t) => (n, e) => t(n, e, i);
|
|
49
|
+
const nn = 50;
|
|
50
|
+
let Ee = class {
|
|
51
|
+
constructor(i, t, n) {
|
|
52
|
+
this._drawingManagerService = i, this._imageIoService = t, this._dialogService = n;
|
|
53
|
+
}
|
|
54
|
+
// eslint-disable-next-line max-lines-per-function
|
|
55
|
+
async renderImages(i, t) {
|
|
56
|
+
const {
|
|
57
|
+
transform: n,
|
|
58
|
+
drawingType: e,
|
|
59
|
+
source: r,
|
|
60
|
+
imageSourceType: o,
|
|
61
|
+
srcRect: a,
|
|
62
|
+
prstGeom: s,
|
|
63
|
+
groupId: c,
|
|
64
|
+
unitId: l,
|
|
65
|
+
subUnitId: m,
|
|
66
|
+
drawingId: d,
|
|
67
|
+
isMultiTransform: h,
|
|
68
|
+
transforms: f
|
|
69
|
+
} = i;
|
|
70
|
+
if (e !== ne.DRAWING_IMAGE || !this._drawingManagerService.getDrawingVisible() || n == null)
|
|
71
|
+
return;
|
|
72
|
+
const v = h && f ? f : [n], w = [];
|
|
73
|
+
for (const p of v) {
|
|
74
|
+
const { left: S, top: _, width: M, height: I, angle: N, flipX: P, flipY: b, skewX: y, skewY: R } = p, O = v.indexOf(p), U = G({ unitId: l, subUnitId: m, drawingId: d }, h ? O : void 0), T = t.getObject(U);
|
|
75
|
+
if (T != null) {
|
|
76
|
+
T.transformByState({ left: S, top: _, width: M, height: I, angle: N, flipX: P, flipY: b, skewX: y, skewY: R });
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const ie = this._drawingManagerService.getDrawingOrder(l, m), W = ie.indexOf(d), q = { ...p, zIndex: W === -1 ? ie.length - 1 : W }, Se = this._imageIoService.getImageSourceCache(r, o);
|
|
80
|
+
let ae = !1;
|
|
81
|
+
if (Se != null)
|
|
82
|
+
q.image = Se;
|
|
83
|
+
else {
|
|
84
|
+
if (o === xn.UUID)
|
|
85
|
+
try {
|
|
86
|
+
q.url = await this._imageIoService.getImage(r);
|
|
87
|
+
} catch (ke) {
|
|
88
|
+
console.error(ke);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
else
|
|
92
|
+
q.url = r;
|
|
93
|
+
ae = !0;
|
|
94
|
+
}
|
|
95
|
+
if (t.getObject(U))
|
|
96
|
+
continue;
|
|
97
|
+
q.printable = !0;
|
|
98
|
+
const z = new ze(U, q);
|
|
99
|
+
ae && this._imageIoService.addImageSourceCache(r, o, z.getNative()), this._drawingManagerService.getDrawingVisible() && (t.addObject(z, De), this._drawingManagerService.getDrawingEditable() && t.attachTransformerTo(z), c && en({ drawingId: c, unitId: l, subUnitId: m }, z, t, this._drawingManagerService), s != null && z.setPrstGeom(s), a != null && z.setSrcRect(a), w.push(z));
|
|
100
|
+
}
|
|
101
|
+
return w;
|
|
102
|
+
}
|
|
103
|
+
renderFloatDom(i, t) {
|
|
104
|
+
const {
|
|
105
|
+
transform: n,
|
|
106
|
+
drawingType: e,
|
|
107
|
+
groupId: r,
|
|
108
|
+
unitId: o,
|
|
109
|
+
subUnitId: a,
|
|
110
|
+
drawingId: s,
|
|
111
|
+
isMultiTransform: c,
|
|
112
|
+
transforms: l
|
|
113
|
+
} = i;
|
|
114
|
+
if (e !== ne.DRAWING_DOM || !this._drawingManagerService.getDrawingVisible() || n == null)
|
|
115
|
+
return;
|
|
116
|
+
const m = c && l ? l : [n], d = [];
|
|
117
|
+
for (const h of m) {
|
|
118
|
+
const { left: f, top: v, width: w, height: p, angle: S, flipX: _, flipY: M, skewX: I, skewY: N } = h, P = m.indexOf(h), b = G({ unitId: o, subUnitId: a, drawingId: s }, c ? P : void 0), y = t.getObject(b);
|
|
119
|
+
if (y != null) {
|
|
120
|
+
y.transformByState({ left: f, top: v, width: w, height: p, angle: S, flipX: _, flipY: M, skewX: I, skewY: N });
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const R = this._drawingManagerService.getDrawingOrder(o, a), O = R.indexOf(s), U = { ...h, zIndex: O === -1 ? R.length - 1 : O };
|
|
124
|
+
if (t.getObject(b))
|
|
125
|
+
continue;
|
|
126
|
+
U.printable = !1;
|
|
127
|
+
const T = new ln(b, U);
|
|
128
|
+
this._drawingManagerService.getDrawingVisible() && (t.addObject(T, De), this._drawingManagerService.getDrawingEditable() && i.allowTransform !== !1 && t.attachTransformerTo(T), r && en({ drawingId: r, unitId: o, subUnitId: a }, T, t, this._drawingManagerService), d.push(T));
|
|
129
|
+
}
|
|
130
|
+
return d;
|
|
131
|
+
}
|
|
132
|
+
renderDrawing(i, t) {
|
|
133
|
+
const n = this._drawingManagerService.getDrawingByParam(i);
|
|
134
|
+
if (n != null)
|
|
135
|
+
switch (n.drawingType) {
|
|
136
|
+
case ne.DRAWING_IMAGE:
|
|
137
|
+
return this.renderImages(n, t);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
previewImage(i, t, n, e) {
|
|
141
|
+
const r = `${i}-viewer-dialog`, o = window.innerWidth - nn, a = window.innerHeight - nn, s = this._adjustImageSize(n, e, o, a), c = this._dialogService.open({
|
|
142
|
+
width: Math.max(s.width, 200),
|
|
143
|
+
id: r,
|
|
144
|
+
style: { margin: "0", top: "50%", left: "50%", transform: "translate(-50%, -50%)" },
|
|
145
|
+
children: {
|
|
146
|
+
label: {
|
|
147
|
+
name: hn,
|
|
148
|
+
props: {
|
|
149
|
+
src: t,
|
|
150
|
+
width: s.width,
|
|
151
|
+
height: s.height
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
destroyOnClose: !0,
|
|
156
|
+
draggable: !1,
|
|
157
|
+
onClose: () => {
|
|
158
|
+
this._dialogService.close(r), c.dispose();
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
_adjustImageSize(i, t, n, e) {
|
|
163
|
+
if (i <= n && t <= e)
|
|
164
|
+
return {
|
|
165
|
+
width: i,
|
|
166
|
+
height: t
|
|
167
|
+
};
|
|
168
|
+
const r = n / i, o = e / t, a = Math.min(r, o);
|
|
169
|
+
return {
|
|
170
|
+
width: Math.floor(i * a),
|
|
171
|
+
height: Math.floor(t * a)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
Ee = qn([
|
|
176
|
+
We(0, re),
|
|
177
|
+
We(1, cn),
|
|
178
|
+
We(2, gn)
|
|
179
|
+
], Ee);
|
|
180
|
+
function Ve(i, t) {
|
|
181
|
+
const n = [];
|
|
182
|
+
return i.forEach((e) => {
|
|
183
|
+
const { oKey: r, left: o, top: a, height: s, width: c, angle: l } = e, m = t.getDrawingOKey(r);
|
|
184
|
+
if (m == null)
|
|
185
|
+
return n.push(null), !0;
|
|
186
|
+
const { unitId: d, subUnitId: h, drawingId: f, drawingType: v } = m, w = {
|
|
187
|
+
unitId: d,
|
|
188
|
+
subUnitId: h,
|
|
189
|
+
drawingId: f,
|
|
190
|
+
drawingType: v,
|
|
191
|
+
transform: {
|
|
192
|
+
left: o,
|
|
193
|
+
top: a,
|
|
194
|
+
height: s,
|
|
195
|
+
width: c,
|
|
196
|
+
angle: l
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
v === ne.DRAWING_IMAGE && (w.srcRect = e.srcRect), n.push(w);
|
|
200
|
+
}), n;
|
|
201
|
+
}
|
|
202
|
+
var D = /* @__PURE__ */ ((i) => (i.default = "0", i.left = "1", i.center = "2", i.right = "3", i.top = "4", i.middle = "5", i.bottom = "6", i.horizon = "7", i.vertical = "8", i))(D || {});
|
|
203
|
+
const Ye = {
|
|
204
|
+
id: "sheet.operation.set-image-align",
|
|
205
|
+
type: ve.OPERATION,
|
|
206
|
+
handler: (i, t) => !0
|
|
207
|
+
}, Qn = "univer-image-common-panel-grid", et = "univer-image-common-panel-border", nt = "univer-image-common-panel-title", tt = "univer-image-common-panel-row", rt = "univer-image-common-panel-row-vertical", it = "univer-image-common-panel-column", at = "univer-image-common-panel-column-center", ot = "univer-image-common-panel-inline", st = "univer-image-common-panel-span2", ct = "univer-image-common-panel-span3", lt = "univer-image-common-panel-input", g = {
|
|
208
|
+
imageCommonPanelGrid: Qn,
|
|
209
|
+
imageCommonPanelBorder: et,
|
|
210
|
+
imageCommonPanelTitle: nt,
|
|
211
|
+
imageCommonPanelRow: tt,
|
|
212
|
+
imageCommonPanelRowVertical: rt,
|
|
213
|
+
imageCommonPanelColumn: it,
|
|
214
|
+
imageCommonPanelColumnCenter: at,
|
|
215
|
+
imageCommonPanelInline: ot,
|
|
216
|
+
imageCommonPanelSpan2: st,
|
|
217
|
+
imageCommonPanelSpan3: ct,
|
|
218
|
+
imageCommonPanelInput: lt
|
|
219
|
+
}, gt = (i) => {
|
|
220
|
+
const t = V(me), n = V(te), { alignShow: e } = i, [r, o] = x(D.default), a = [
|
|
221
|
+
{
|
|
222
|
+
label: n.t("image-panel.align.default"),
|
|
223
|
+
value: D.default
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
options: [
|
|
227
|
+
{
|
|
228
|
+
label: n.t("image-panel.align.left"),
|
|
229
|
+
value: D.left
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
label: n.t("image-panel.align.center"),
|
|
233
|
+
value: D.center
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
label: n.t("image-panel.align.right"),
|
|
237
|
+
value: D.right
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
options: [
|
|
243
|
+
{
|
|
244
|
+
label: n.t("image-panel.align.top"),
|
|
245
|
+
value: D.top
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
label: n.t("image-panel.align.middle"),
|
|
249
|
+
value: D.middle
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
label: n.t("image-panel.align.bottom"),
|
|
253
|
+
value: D.bottom
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
options: [
|
|
259
|
+
{
|
|
260
|
+
label: n.t("image-panel.align.horizon"),
|
|
261
|
+
value: D.horizon
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
label: n.t("image-panel.align.vertical"),
|
|
265
|
+
value: D.vertical
|
|
266
|
+
}
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
];
|
|
270
|
+
function s(l) {
|
|
271
|
+
o(l), t.executeCommand(Ye.id, {
|
|
272
|
+
alignType: l
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const c = (l) => l ? "block" : "none";
|
|
276
|
+
return /* @__PURE__ */ j("div", { className: B(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: c(e) }, children: [
|
|
277
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelTitle), children: /* @__PURE__ */ u("div", { children: n.t("image-panel.align.title") }) }) }),
|
|
278
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn), children: /* @__PURE__ */ u(dn, { value: r, options: a, onChange: s }) }) })
|
|
279
|
+
] });
|
|
280
|
+
};
|
|
281
|
+
var $ = function() {
|
|
282
|
+
return $ = Object.assign || function(i) {
|
|
283
|
+
for (var t, n = 1, e = arguments.length; n < e; n++) {
|
|
284
|
+
t = arguments[n];
|
|
285
|
+
for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && (i[r] = t[r]);
|
|
286
|
+
}
|
|
287
|
+
return i;
|
|
288
|
+
}, $.apply(this, arguments);
|
|
289
|
+
}, mt = function(i, t) {
|
|
290
|
+
var n = {};
|
|
291
|
+
for (var e in i) Object.prototype.hasOwnProperty.call(i, e) && t.indexOf(e) < 0 && (n[e] = i[e]);
|
|
292
|
+
if (i != null && typeof Object.getOwnPropertySymbols == "function")
|
|
293
|
+
for (var r = 0, e = Object.getOwnPropertySymbols(i); r < e.length; r++)
|
|
294
|
+
t.indexOf(e[r]) < 0 && Object.prototype.propertyIsEnumerable.call(i, e[r]) && (n[e[r]] = i[e[r]]);
|
|
295
|
+
return n;
|
|
296
|
+
}, J = Z(function(i, t) {
|
|
297
|
+
var n = i.icon, e = i.id, r = i.className, o = i.extend, a = mt(i, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(e, " ").concat(r || "").trim(), c = mn("_".concat(ht()));
|
|
298
|
+
return fn(n, "".concat(e), { defIds: n.defIds, idSuffix: c.current }, $({ ref: t, className: s }, a), o);
|
|
299
|
+
});
|
|
300
|
+
function fn(i, t, n, e, r) {
|
|
301
|
+
return X(i.tag, $($({ key: t }, dt(i, n, r)), e), (ut(i, n).children || []).map(function(o, a) {
|
|
302
|
+
return fn(o, "".concat(t, "-").concat(i.tag, "-").concat(a), n, void 0, r);
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
305
|
+
function dt(i, t, n) {
|
|
306
|
+
var e = $({}, i.attrs);
|
|
307
|
+
n != null && n.colorChannel1 && e.fill === "colorChannel1" && (e.fill = n.colorChannel1), i.tag === "mask" && e.id && (e.id = e.id + t.idSuffix), Object.entries(e).forEach(function(o) {
|
|
308
|
+
var a = o[0], s = o[1];
|
|
309
|
+
a === "mask" && typeof s == "string" && (e[a] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
|
|
310
|
+
});
|
|
311
|
+
var r = t.defIds;
|
|
312
|
+
return !r || r.length === 0 || (i.tag === "use" && e["xlink:href"] && (e["xlink:href"] = e["xlink:href"] + t.idSuffix), Object.entries(e).forEach(function(o) {
|
|
313
|
+
var a = o[0], s = o[1];
|
|
314
|
+
typeof s == "string" && (e[a] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
|
|
315
|
+
})), e;
|
|
316
|
+
}
|
|
317
|
+
function ut(i, t) {
|
|
318
|
+
var n, e = t.defIds;
|
|
319
|
+
return !e || e.length === 0 ? i : i.tag === "defs" && (!((n = i.children) === null || n === void 0) && n.length) ? $($({}, i), { children: i.children.map(function(r) {
|
|
320
|
+
return typeof r.attrs.id == "string" && e && e.indexOf(r.attrs.id) > -1 ? $($({}, r), { attrs: $($({}, r.attrs), { id: r.attrs.id + t.idSuffix }) }) : r;
|
|
321
|
+
}) }) : i;
|
|
322
|
+
}
|
|
323
|
+
function ht() {
|
|
324
|
+
return Math.random().toString(36).substring(2, 8);
|
|
325
|
+
}
|
|
326
|
+
J.displayName = "UniverIcon";
|
|
327
|
+
var ft = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "colorChannel1", d: "M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z", fillRule: "evenodd", clipRule: "evenodd" } }] }, pn = Z(function(i, t) {
|
|
328
|
+
return X(J, Object.assign({}, i, {
|
|
329
|
+
id: "autofill",
|
|
330
|
+
ref: t,
|
|
331
|
+
icon: ft
|
|
332
|
+
}));
|
|
333
|
+
});
|
|
334
|
+
pn.displayName = "Autofill";
|
|
335
|
+
var pt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045zM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544zM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999 3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421 6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641 9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946" } }] }, Cn = Z(function(i, t) {
|
|
336
|
+
return X(J, Object.assign({}, i, {
|
|
337
|
+
id: "bottom-single",
|
|
338
|
+
ref: t,
|
|
339
|
+
icon: pt
|
|
340
|
+
}));
|
|
341
|
+
});
|
|
342
|
+
Cn.displayName = "BottomSingle";
|
|
343
|
+
var Ct = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296 9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296zM6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103 5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103 11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z" } }] }, wn = Z(function(i, t) {
|
|
344
|
+
return X(J, Object.assign({}, i, {
|
|
345
|
+
id: "create-copy-single",
|
|
346
|
+
ref: t,
|
|
347
|
+
icon: Ct
|
|
348
|
+
}));
|
|
349
|
+
});
|
|
350
|
+
wn.displayName = "CreateCopySingle";
|
|
351
|
+
var wt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, vn = Z(function(i, t) {
|
|
352
|
+
return X(J, Object.assign({}, i, {
|
|
353
|
+
id: "group-single",
|
|
354
|
+
ref: t,
|
|
355
|
+
icon: wt
|
|
356
|
+
}));
|
|
357
|
+
});
|
|
358
|
+
vn.displayName = "GroupSingle";
|
|
359
|
+
var vt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, _n = Z(function(i, t) {
|
|
360
|
+
return X(J, Object.assign({}, i, {
|
|
361
|
+
id: "more-down-single",
|
|
362
|
+
ref: t,
|
|
363
|
+
icon: vt
|
|
364
|
+
}));
|
|
365
|
+
});
|
|
366
|
+
_n.displayName = "MoreDownSingle";
|
|
367
|
+
var _t = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z" } }] }, Sn = Z(function(i, t) {
|
|
368
|
+
return X(J, Object.assign({}, i, {
|
|
369
|
+
id: "move-down-single",
|
|
370
|
+
ref: t,
|
|
371
|
+
icon: _t
|
|
372
|
+
}));
|
|
373
|
+
});
|
|
374
|
+
Sn.displayName = "MoveDownSingle";
|
|
375
|
+
var St = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z" } }] }, bn = Z(function(i, t) {
|
|
376
|
+
return X(J, Object.assign({}, i, {
|
|
377
|
+
id: "move-up-single",
|
|
378
|
+
ref: t,
|
|
379
|
+
icon: St
|
|
380
|
+
}));
|
|
381
|
+
});
|
|
382
|
+
bn.displayName = "MoveUpSingle";
|
|
383
|
+
var bt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9 15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9zM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665 15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665zM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z", fillRule: "evenodd", clipRule: "evenodd" } }] }, In = Z(function(i, t) {
|
|
384
|
+
return X(J, Object.assign({}, i, {
|
|
385
|
+
id: "topmost-single",
|
|
386
|
+
ref: t,
|
|
387
|
+
icon: bt
|
|
388
|
+
}));
|
|
389
|
+
});
|
|
390
|
+
In.displayName = "TopmostSingle";
|
|
391
|
+
var It = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, yn = Z(function(i, t) {
|
|
392
|
+
return X(J, Object.assign({}, i, {
|
|
393
|
+
id: "ungroup-single",
|
|
394
|
+
ref: t,
|
|
395
|
+
icon: It
|
|
396
|
+
}));
|
|
397
|
+
});
|
|
398
|
+
yn.displayName = "UngroupSingle";
|
|
399
|
+
const yt = (i) => {
|
|
400
|
+
const { arrangeShow: t, drawings: n } = i, e = V(te), r = V(re), o = (l) => l ? "block" : "none", [a, s] = x(n);
|
|
401
|
+
_e(() => {
|
|
402
|
+
const l = r.focus$.subscribe((m) => {
|
|
403
|
+
s(m);
|
|
404
|
+
});
|
|
405
|
+
return () => {
|
|
406
|
+
l.unsubscribe();
|
|
407
|
+
};
|
|
408
|
+
}, []);
|
|
409
|
+
const c = (l) => {
|
|
410
|
+
const m = a[0].unitId, d = a[0].subUnitId, h = a.map((f) => f.drawingId);
|
|
411
|
+
r.featurePluginOrderUpdateNotification({ unitId: m, subUnitId: d, drawingIds: h, arrangeType: l });
|
|
412
|
+
};
|
|
413
|
+
return /* @__PURE__ */ j("div", { className: g.imageCommonPanelGrid, style: { display: o(t) }, children: [
|
|
414
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelTitle), children: /* @__PURE__ */ u("div", { children: e.t("image-panel.arrange.title") }) }) }),
|
|
415
|
+
/* @__PURE__ */ j("div", { className: g.imageCommonPanelRow, children: [
|
|
416
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan2), children: /* @__PURE__ */ u(le, { size: "small", onClick: () => {
|
|
417
|
+
c(be.forward);
|
|
418
|
+
}, children: /* @__PURE__ */ j("span", { className: g.imageCommonPanelInline, children: [
|
|
419
|
+
/* @__PURE__ */ u(bn, {}),
|
|
420
|
+
e.t("image-panel.arrange.forward")
|
|
421
|
+
] }) }) }),
|
|
422
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan2), children: /* @__PURE__ */ u(le, { size: "small", onClick: () => {
|
|
423
|
+
c(be.backward);
|
|
424
|
+
}, children: /* @__PURE__ */ j("span", { className: g.imageCommonPanelInline, children: [
|
|
425
|
+
/* @__PURE__ */ u(Sn, {}),
|
|
426
|
+
e.t("image-panel.arrange.backward")
|
|
427
|
+
] }) }) })
|
|
428
|
+
] }),
|
|
429
|
+
/* @__PURE__ */ j("div", { className: g.imageCommonPanelRow, children: [
|
|
430
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan2), children: /* @__PURE__ */ u(le, { size: "small", onClick: () => {
|
|
431
|
+
c(be.front);
|
|
432
|
+
}, children: /* @__PURE__ */ j("span", { className: g.imageCommonPanelInline, children: [
|
|
433
|
+
/* @__PURE__ */ u(In, {}),
|
|
434
|
+
e.t("image-panel.arrange.front")
|
|
435
|
+
] }) }) }),
|
|
436
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan2), children: /* @__PURE__ */ u(le, { size: "small", onClick: () => {
|
|
437
|
+
c(be.back);
|
|
438
|
+
}, children: /* @__PURE__ */ j("span", { className: g.imageCommonPanelInline, children: [
|
|
439
|
+
/* @__PURE__ */ u(Cn, {}),
|
|
440
|
+
e.t("image-panel.arrange.back")
|
|
441
|
+
] }) }) })
|
|
442
|
+
] })
|
|
443
|
+
] });
|
|
444
|
+
}, Pt = (i) => {
|
|
445
|
+
const t = V(te), n = V(ue), e = V(re), { hasGroup: r, drawings: o } = i, [a, s] = x(!1), [c, l] = x(!0), [m, d] = x(!0), h = (p) => p ? "block" : "none", f = () => {
|
|
446
|
+
const p = e.getFocusDrawings(), { unitId: S, subUnitId: _ } = p[0], M = jn.generateRandomId(10), I = Vn(0, 0, p.map((b) => b.transform || {})), N = {
|
|
447
|
+
unitId: S,
|
|
448
|
+
subUnitId: _,
|
|
449
|
+
drawingId: M,
|
|
450
|
+
drawingType: ne.DRAWING_GROUP,
|
|
451
|
+
transform: I
|
|
452
|
+
}, P = p.map((b) => {
|
|
453
|
+
const y = b.transform || { left: 0, top: 0 }, { unitId: R, subUnitId: O, drawingId: U } = b;
|
|
454
|
+
return {
|
|
455
|
+
unitId: R,
|
|
456
|
+
subUnitId: O,
|
|
457
|
+
drawingId: U,
|
|
458
|
+
transform: {
|
|
459
|
+
...y,
|
|
460
|
+
left: y.left - I.left,
|
|
461
|
+
top: y.top - I.top
|
|
462
|
+
},
|
|
463
|
+
groupId: M
|
|
464
|
+
};
|
|
465
|
+
});
|
|
466
|
+
e.featurePluginGroupUpdateNotification([{
|
|
467
|
+
parent: N,
|
|
468
|
+
children: P
|
|
469
|
+
}]);
|
|
470
|
+
}, v = (p) => {
|
|
471
|
+
if (p.drawingType !== ne.DRAWING_GROUP)
|
|
472
|
+
return;
|
|
473
|
+
const { unitId: S, subUnitId: _, drawingId: M, transform: I = { width: 0, height: 0 } } = p;
|
|
474
|
+
if (I == null)
|
|
475
|
+
return;
|
|
476
|
+
const N = e.getDrawingsByGroup({ unitId: S, subUnitId: _, drawingId: M });
|
|
477
|
+
if (N.length === 0)
|
|
478
|
+
return;
|
|
479
|
+
const P = N.map((b) => {
|
|
480
|
+
const { transform: y } = b, { unitId: R, subUnitId: O, drawingId: U } = b, T = kn(y || {}, I, I.width || 0, I.height || 0);
|
|
481
|
+
return {
|
|
482
|
+
unitId: R,
|
|
483
|
+
subUnitId: O,
|
|
484
|
+
drawingId: U,
|
|
485
|
+
transform: {
|
|
486
|
+
...y,
|
|
487
|
+
...T
|
|
488
|
+
},
|
|
489
|
+
groupId: void 0
|
|
490
|
+
};
|
|
491
|
+
});
|
|
492
|
+
return {
|
|
493
|
+
parent: p,
|
|
494
|
+
children: P
|
|
495
|
+
};
|
|
496
|
+
}, w = () => {
|
|
497
|
+
const S = e.getFocusDrawings().map(
|
|
498
|
+
(_) => v(_)
|
|
499
|
+
).filter((_) => _ != null);
|
|
500
|
+
S.length !== 0 && e.featurePluginUngroupUpdateNotification(S);
|
|
501
|
+
};
|
|
502
|
+
return _e(() => {
|
|
503
|
+
const p = o[0];
|
|
504
|
+
if (p == null)
|
|
505
|
+
return;
|
|
506
|
+
const { unitId: S } = p, _ = n.getRenderById(S), M = _ == null ? void 0 : _.scene;
|
|
507
|
+
if (M == null)
|
|
508
|
+
return;
|
|
509
|
+
const I = M.getTransformerByCreate(), N = I.clearControl$.subscribe((b) => {
|
|
510
|
+
b === !0 && s(!1);
|
|
511
|
+
}), P = I.changeStart$.subscribe((b) => {
|
|
512
|
+
const { objects: y } = b, R = Ve(y, e), O = R.filter((W) => (W == null ? void 0 : W.drawingType) === ne.DRAWING_GROUP);
|
|
513
|
+
let U = !1, T = !1;
|
|
514
|
+
R.length > 1 && (U = !0), O.length > 0 && (T = !0), s(U || T), l(U), d(T);
|
|
515
|
+
});
|
|
516
|
+
return () => {
|
|
517
|
+
P.unsubscribe(), N.unsubscribe();
|
|
518
|
+
};
|
|
519
|
+
}, []), /* @__PURE__ */ j("div", { className: B(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: h(r === !0 ? a : !1) }, children: [
|
|
520
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelTitle), children: /* @__PURE__ */ u("div", { children: t.t("image-panel.group.title") }) }) }),
|
|
521
|
+
/* @__PURE__ */ j("div", { className: g.imageCommonPanelRow, children: [
|
|
522
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan2, g.imageCommonPanelColumnCenter), children: /* @__PURE__ */ u(le, { size: "small", onClick: () => {
|
|
523
|
+
f();
|
|
524
|
+
}, style: { display: h(c) }, children: /* @__PURE__ */ j("span", { className: g.imageCommonPanelInline, children: [
|
|
525
|
+
/* @__PURE__ */ u(vn, {}),
|
|
526
|
+
t.t("image-panel.group.group")
|
|
527
|
+
] }) }) }),
|
|
528
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan2, g.imageCommonPanelColumnCenter), children: /* @__PURE__ */ u(le, { size: "small", onClick: () => {
|
|
529
|
+
w();
|
|
530
|
+
}, style: { display: h(m) }, children: /* @__PURE__ */ j("span", { className: g.imageCommonPanelInline, children: [
|
|
531
|
+
/* @__PURE__ */ u(yn, {}),
|
|
532
|
+
t.t("image-panel.group.unGroup")
|
|
533
|
+
] }) }) })
|
|
534
|
+
] })
|
|
535
|
+
] });
|
|
536
|
+
}, se = 20, Rt = 20, Mt = [-3600, 3600], Pe = 300, Ot = (i) => {
|
|
537
|
+
var Ze;
|
|
538
|
+
const t = V(te), n = V(re), e = V(ue), { drawings: r, transformShow: o } = i, a = r[0];
|
|
539
|
+
if (a == null)
|
|
540
|
+
return;
|
|
541
|
+
const s = a.transform;
|
|
542
|
+
if (s == null)
|
|
543
|
+
return;
|
|
544
|
+
const { unitId: c, subUnitId: l, drawingId: m, drawingType: d } = a, h = e.getRenderById(c), f = h == null ? void 0 : h.scene;
|
|
545
|
+
if (f == null)
|
|
546
|
+
return;
|
|
547
|
+
const v = (Ze = f.getEngine()) == null ? void 0 : Ze.activeScene;
|
|
548
|
+
if (v == null)
|
|
549
|
+
return;
|
|
550
|
+
const w = f.getTransformerByCreate(), {
|
|
551
|
+
width: p = 0,
|
|
552
|
+
height: S = 0,
|
|
553
|
+
left: _ = 0,
|
|
554
|
+
top: M = 0,
|
|
555
|
+
angle: I = 0
|
|
556
|
+
} = s, [N, P] = x(p), [b, y] = x(S), [R, O] = x(_), [U, T] = x(M), [ie, W] = x(I), [q, Se] = x(w.keepRatio), ae = (C, E, L, k) => {
|
|
557
|
+
const { width: H, height: Q } = v, { ancestorLeft: F, ancestorTop: K } = f;
|
|
558
|
+
let Y = C, oe = E, he = L, fe = k;
|
|
559
|
+
return C + F < 0 && (Y = -F), E + K < 0 && (oe = -K), he = H - Y - F, he < se && (he = se), fe = Q - oe - K, fe < se && (fe = se), C + he + F > H && (Y = H - L - F), E + fe + K > Q && (oe = Q - k - K), {
|
|
560
|
+
limitLeft: Y,
|
|
561
|
+
limitTop: oe,
|
|
562
|
+
limitWidth: he,
|
|
563
|
+
limitHeight: fe
|
|
564
|
+
};
|
|
565
|
+
}, z = (C) => {
|
|
566
|
+
const { objects: E } = C, L = Ve(E, n);
|
|
567
|
+
if (L.length !== 1)
|
|
568
|
+
return;
|
|
569
|
+
const k = L[0];
|
|
570
|
+
if (k == null)
|
|
571
|
+
return;
|
|
572
|
+
const { transform: H } = k;
|
|
573
|
+
if (H == null)
|
|
574
|
+
return;
|
|
575
|
+
const {
|
|
576
|
+
width: Q,
|
|
577
|
+
height: F,
|
|
578
|
+
left: K,
|
|
579
|
+
top: Y,
|
|
580
|
+
angle: oe
|
|
581
|
+
} = H;
|
|
582
|
+
Q != null && P(Q), F != null && y(F), K != null && O(K), Y != null && T(Y), oe != null && W(oe);
|
|
583
|
+
};
|
|
584
|
+
_e(() => {
|
|
585
|
+
const C = [
|
|
586
|
+
w.changeStart$.subscribe((E) => {
|
|
587
|
+
z(E);
|
|
588
|
+
}),
|
|
589
|
+
w.changing$.subscribe((E) => {
|
|
590
|
+
z(E);
|
|
591
|
+
}),
|
|
592
|
+
w.changeEnd$.subscribe((E) => {
|
|
593
|
+
z(E);
|
|
594
|
+
}),
|
|
595
|
+
n.focus$.subscribe((E) => {
|
|
596
|
+
if (E.length !== 1)
|
|
597
|
+
return;
|
|
598
|
+
const L = n.getDrawingByParam(E[0]);
|
|
599
|
+
if (L == null)
|
|
600
|
+
return;
|
|
601
|
+
const k = L.transform;
|
|
602
|
+
if (k == null)
|
|
603
|
+
return;
|
|
604
|
+
const {
|
|
605
|
+
width: H,
|
|
606
|
+
height: Q,
|
|
607
|
+
left: F,
|
|
608
|
+
top: K,
|
|
609
|
+
angle: Y
|
|
610
|
+
} = k;
|
|
611
|
+
H != null && P(H), Q != null && y(Q), F != null && O(F), K != null && T(K), Y != null && W(Y);
|
|
612
|
+
})
|
|
613
|
+
];
|
|
614
|
+
return () => {
|
|
615
|
+
C.forEach((E) => E.unsubscribe());
|
|
616
|
+
};
|
|
617
|
+
}, []);
|
|
618
|
+
const ke = Ie((C) => {
|
|
619
|
+
if (C == null)
|
|
620
|
+
return;
|
|
621
|
+
C = Math.max(C, se);
|
|
622
|
+
const { limitWidth: E, limitHeight: L } = ae(R, U, C, b);
|
|
623
|
+
C = Math.min(C, E);
|
|
624
|
+
const k = { unitId: c, subUnitId: l, drawingId: m, drawingType: d, transform: { width: C } };
|
|
625
|
+
if (q) {
|
|
626
|
+
let H = C / N * b;
|
|
627
|
+
if (H = Math.max(H, Rt), H > L)
|
|
628
|
+
return;
|
|
629
|
+
y(H), k.transform.height = H;
|
|
630
|
+
}
|
|
631
|
+
P(C), n.featurePluginUpdateNotification([k]), w.refreshControls().changeNotification();
|
|
632
|
+
}, Pe), Rn = Ie((C) => {
|
|
633
|
+
if (C == null)
|
|
634
|
+
return;
|
|
635
|
+
C = Math.max(C, se);
|
|
636
|
+
const { limitHeight: E, limitWidth: L } = ae(R, U, N, C);
|
|
637
|
+
C = Math.min(C, E);
|
|
638
|
+
const k = { unitId: c, subUnitId: l, drawingId: m, drawingType: d, transform: { height: C } };
|
|
639
|
+
if (q) {
|
|
640
|
+
let H = C / b * N;
|
|
641
|
+
if (H = Math.max(H, se), H > L)
|
|
642
|
+
return;
|
|
643
|
+
P(H), k.transform.width = H;
|
|
644
|
+
}
|
|
645
|
+
y(C), n.featurePluginUpdateNotification([k]), w.refreshControls().changeNotification();
|
|
646
|
+
}, Pe), Mn = Ie((C) => {
|
|
647
|
+
if (C == null)
|
|
648
|
+
return;
|
|
649
|
+
const { limitLeft: E } = ae(C, U, N, b);
|
|
650
|
+
C = E;
|
|
651
|
+
const L = { unitId: c, subUnitId: l, drawingId: m, drawingType: d, transform: { left: C } };
|
|
652
|
+
O(C), n.featurePluginUpdateNotification([L]), w.refreshControls().changeNotification();
|
|
653
|
+
}, Pe), On = Ie((C) => {
|
|
654
|
+
if (C == null)
|
|
655
|
+
return;
|
|
656
|
+
const { limitTop: E } = ae(R, C, N, b);
|
|
657
|
+
C = E;
|
|
658
|
+
const L = { unitId: c, subUnitId: l, drawingId: m, drawingType: d, transform: { top: C } };
|
|
659
|
+
T(C), n.featurePluginUpdateNotification([L]), w.refreshControls().changeNotification();
|
|
660
|
+
}, Pe), Nn = (C) => {
|
|
661
|
+
if (C == null)
|
|
662
|
+
return;
|
|
663
|
+
const [E, L] = Mt;
|
|
664
|
+
C < E && (C = E), C > L && (C = L);
|
|
665
|
+
const k = { unitId: c, subUnitId: l, drawingId: m, drawingType: d, transform: { angle: C } };
|
|
666
|
+
W(C), n.featurePluginUpdateNotification([k]), w.refreshControls().changeNotification();
|
|
667
|
+
}, Dn = (C) => {
|
|
668
|
+
Se(C), w.keepRatio = C;
|
|
669
|
+
}, Tn = (C) => C ? "block" : "none";
|
|
670
|
+
return /* @__PURE__ */ j("div", { className: B(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: Tn(o) }, children: [
|
|
671
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelTitle), children: /* @__PURE__ */ u("div", { children: t.t("image-panel.transform.title") }) }) }),
|
|
672
|
+
/* @__PURE__ */ j("div", { className: g.imageCommonPanelRow, children: [
|
|
673
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan3), children: /* @__PURE__ */ j("label", { children: [
|
|
674
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: t.t("image-panel.transform.width") }) }),
|
|
675
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: /* @__PURE__ */ u(pe, { precision: 1, value: N, onChange: (C) => {
|
|
676
|
+
ke(C);
|
|
677
|
+
}, className: g.imageCommonPanelInput }) }) })
|
|
678
|
+
] }) }),
|
|
679
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan3), children: /* @__PURE__ */ j("label", { children: [
|
|
680
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: t.t("image-panel.transform.height") }) }),
|
|
681
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: /* @__PURE__ */ u(pe, { precision: 1, value: b, onChange: (C) => {
|
|
682
|
+
Rn(C);
|
|
683
|
+
}, className: g.imageCommonPanelInput }) }) })
|
|
684
|
+
] }) }),
|
|
685
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan3), children: /* @__PURE__ */ j("label", { children: [
|
|
686
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: t.t("image-panel.transform.lock") }) }),
|
|
687
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelRow, g.imageCommonPanelRowVertical), children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: /* @__PURE__ */ u(Kn, { checked: q, onChange: Dn }) }) })
|
|
688
|
+
] }) })
|
|
689
|
+
] }),
|
|
690
|
+
/* @__PURE__ */ j("div", { className: g.imageCommonPanelRow, children: [
|
|
691
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan3), children: /* @__PURE__ */ j("label", { children: [
|
|
692
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: t.t("image-panel.transform.x") }) }),
|
|
693
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: /* @__PURE__ */ u(pe, { precision: 1, value: R, onChange: (C) => {
|
|
694
|
+
Mn(C);
|
|
695
|
+
}, className: g.imageCommonPanelInput }) }) })
|
|
696
|
+
] }) }),
|
|
697
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan3), children: /* @__PURE__ */ j("label", { children: [
|
|
698
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: t.t("image-panel.transform.y") }) }),
|
|
699
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: /* @__PURE__ */ u(pe, { precision: 1, value: U, onChange: (C) => {
|
|
700
|
+
On(C);
|
|
701
|
+
}, className: g.imageCommonPanelInput }) }) })
|
|
702
|
+
] }) }),
|
|
703
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan3), children: /* @__PURE__ */ j("label", { children: [
|
|
704
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: t.t("image-panel.transform.rotate") }) }),
|
|
705
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: g.imageCommonPanelColumn, children: /* @__PURE__ */ u(pe, { precision: 1, value: ie, onChange: Nn, className: g.imageCommonPanelInput }) }) })
|
|
706
|
+
] }) })
|
|
707
|
+
] })
|
|
708
|
+
] });
|
|
709
|
+
}, Fe = {
|
|
710
|
+
id: "sheet.operation.open-image-crop",
|
|
711
|
+
type: ve.OPERATION,
|
|
712
|
+
handler: (i, t) => !0
|
|
713
|
+
}, ge = {
|
|
714
|
+
id: "sheet.operation.close-image-crop",
|
|
715
|
+
type: ve.OPERATION,
|
|
716
|
+
handler: (i, t) => !0
|
|
717
|
+
};
|
|
718
|
+
var A = /* @__PURE__ */ ((i) => (i.FREE = "0", i.R1_1 = "1", i.R16_9 = "2", i.R9_16 = "3", i.R5_4 = "4", i.R4_5 = "5", i.R4_3 = "6", i.R3_4 = "7", i.R3_2 = "8", i.R2_3 = "9", i))(A || {});
|
|
719
|
+
const Be = {
|
|
720
|
+
id: "sheet.operation.Auto-image-crop",
|
|
721
|
+
type: ve.OPERATION,
|
|
722
|
+
handler: (i, t) => !0
|
|
723
|
+
}, Nt = (i) => {
|
|
724
|
+
const t = V(me), n = V(te), { drawings: e, cropperShow: r } = i;
|
|
725
|
+
if (e[0] == null)
|
|
726
|
+
return;
|
|
727
|
+
const [a, s] = x(A.FREE), c = mn(!1), l = [
|
|
728
|
+
{
|
|
729
|
+
label: n.t("image-panel.crop.mode"),
|
|
730
|
+
value: A.FREE
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
label: "1:1",
|
|
734
|
+
value: A.R1_1
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
label: "16:9",
|
|
738
|
+
value: A.R16_9
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
label: "9:16",
|
|
742
|
+
value: A.R9_16
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
label: "5:4",
|
|
746
|
+
value: A.R5_4
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
label: "4:5",
|
|
750
|
+
value: A.R4_5
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
label: "4:3",
|
|
754
|
+
value: A.R4_3
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
label: "3:4",
|
|
758
|
+
value: A.R3_4
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
label: "3:2",
|
|
762
|
+
value: A.R3_2
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
label: "2:3",
|
|
766
|
+
value: A.R2_3
|
|
767
|
+
}
|
|
768
|
+
];
|
|
769
|
+
_e(() => {
|
|
770
|
+
const f = t.onCommandExecuted((v) => {
|
|
771
|
+
if (v.id === ge.id) {
|
|
772
|
+
const w = v.params;
|
|
773
|
+
w != null && w.isAuto || (c.current = !1);
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
return () => {
|
|
777
|
+
f == null || f.dispose();
|
|
778
|
+
};
|
|
779
|
+
}, []);
|
|
780
|
+
function m(f) {
|
|
781
|
+
s(f), c.current && t.executeCommand(Be.id, {
|
|
782
|
+
cropType: f
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
const d = (f) => f ? "block" : "none", h = (f) => {
|
|
786
|
+
t.executeCommand(Be.id, {
|
|
787
|
+
cropType: f
|
|
788
|
+
}), c.current = !0;
|
|
789
|
+
};
|
|
790
|
+
return /* @__PURE__ */ j("div", { className: B(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: d(r) }, children: [
|
|
791
|
+
/* @__PURE__ */ u("div", { className: g.imageCommonPanelRow, children: /* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelTitle), children: /* @__PURE__ */ u("div", { children: n.t("image-panel.crop.title") }) }) }),
|
|
792
|
+
/* @__PURE__ */ j("div", { className: B(g.imageCommonPanelRow, g.imageCommonPanelRowVertical), children: [
|
|
793
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan2), children: /* @__PURE__ */ u(le, { size: "small", onClick: () => {
|
|
794
|
+
h(a);
|
|
795
|
+
}, children: /* @__PURE__ */ j("span", { className: g.imageCommonPanelInline, children: [
|
|
796
|
+
/* @__PURE__ */ u(wn, {}),
|
|
797
|
+
n.t("image-panel.crop.start")
|
|
798
|
+
] }) }) }),
|
|
799
|
+
/* @__PURE__ */ u("div", { className: B(g.imageCommonPanelColumn, g.imageCommonPanelSpan2), children: /* @__PURE__ */ u(dn, { value: a, options: l, onChange: m }) })
|
|
800
|
+
] })
|
|
801
|
+
] });
|
|
802
|
+
}, er = (i) => {
|
|
803
|
+
const t = V(re), n = V(ue), e = V(te), { drawings: r, hasArrange: o = !0, hasTransform: a = !0, hasAlign: s = !0, hasCropper: c = !0, hasGroup: l = !0 } = i, m = r[0];
|
|
804
|
+
if (m == null)
|
|
805
|
+
return;
|
|
806
|
+
const { unitId: d } = m, h = n.getRenderById(d), f = h == null ? void 0 : h.scene;
|
|
807
|
+
if (f == null)
|
|
808
|
+
return;
|
|
809
|
+
const v = f.getTransformerByCreate(), [w, p] = x(!0), [S, _] = x(!0), [M, I] = x(!1), [N, P] = x(!0), [b, y] = x(!1);
|
|
810
|
+
return _e(() => {
|
|
811
|
+
const R = v.clearControl$.subscribe((T) => {
|
|
812
|
+
T === !0 && (p(!1), _(!1), I(!1), P(!1), y(!0));
|
|
813
|
+
}), O = v.changeStart$.subscribe((T) => {
|
|
814
|
+
const { objects: ie } = T, W = Ve(ie, t);
|
|
815
|
+
W.length === 0 ? (p(!1), _(!1), I(!1), P(!1), y(!0)) : W.length === 1 ? (p(!0), _(!0), I(!1), P(!0), y(!1)) : (p(!0), _(!1), I(!0), P(!1), y(!1));
|
|
816
|
+
}), U = t.focus$.subscribe((T) => {
|
|
817
|
+
T.length === 0 ? (p(!1), _(!1), I(!1), P(!1), y(!0)) : T.length === 1 ? (p(!0), _(!0), I(!1), P(!0), y(!1)) : (p(!0), _(!1), I(!0), P(!1), y(!1));
|
|
818
|
+
});
|
|
819
|
+
return () => {
|
|
820
|
+
O.unsubscribe(), R.unsubscribe(), U.unsubscribe();
|
|
821
|
+
};
|
|
822
|
+
}, []), /* @__PURE__ */ j(Fn, { children: [
|
|
823
|
+
/* @__PURE__ */ u("div", { style: { display: b === !0 ? "block" : "none", height: "100%" }, children: /* @__PURE__ */ u("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", height: "100%", top: "50%", marginTop: "-100px" }, children: /* @__PURE__ */ u("span", { children: e.t("image-panel.null") }) }) }),
|
|
824
|
+
/* @__PURE__ */ u(yt, { arrangeShow: o === !0 ? w : !1, drawings: r }),
|
|
825
|
+
/* @__PURE__ */ u(Ot, { transformShow: a === !0 ? S : !1, drawings: r }),
|
|
826
|
+
/* @__PURE__ */ u(gt, { alignShow: s === !0 ? M : !1, drawings: r }),
|
|
827
|
+
/* @__PURE__ */ u(Nt, { cropperShow: c === !0 ? N : !1, drawings: r }),
|
|
828
|
+
/* @__PURE__ */ u(Pt, { hasGroup: l, drawings: r })
|
|
829
|
+
] });
|
|
830
|
+
}, Dt = (i) => {
|
|
831
|
+
var w;
|
|
832
|
+
const { popup: t } = i, n = (w = t == null ? void 0 : t.extraProps) == null ? void 0 : w.menuItems;
|
|
833
|
+
if (!n) return null;
|
|
834
|
+
const e = V(me), r = V(te), [o, a] = x(!1), [s, c] = x(!1), l = () => {
|
|
835
|
+
c(!0);
|
|
836
|
+
}, m = () => {
|
|
837
|
+
c(!1);
|
|
838
|
+
}, d = (p) => {
|
|
839
|
+
a(p);
|
|
840
|
+
}, h = (p) => {
|
|
841
|
+
e.executeCommand(p.commandId, p.commandParams), a(!1);
|
|
842
|
+
}, f = o || s, v = n.filter((p) => !p.disable);
|
|
843
|
+
return /* @__PURE__ */ u(
|
|
844
|
+
"div",
|
|
845
|
+
{
|
|
846
|
+
onMouseEnter: l,
|
|
847
|
+
onMouseLeave: m,
|
|
848
|
+
children: /* @__PURE__ */ u(
|
|
849
|
+
Yn,
|
|
850
|
+
{
|
|
851
|
+
align: "start",
|
|
852
|
+
items: v.map((p) => ({
|
|
853
|
+
type: "item",
|
|
854
|
+
children: r.t(p.label),
|
|
855
|
+
onSelect: () => h(p)
|
|
856
|
+
})),
|
|
857
|
+
open: o,
|
|
858
|
+
onOpenChange: d,
|
|
859
|
+
children: /* @__PURE__ */ j(
|
|
860
|
+
"div",
|
|
861
|
+
{
|
|
862
|
+
className: B(`
|
|
863
|
+
univer-flex univer-items-center univer-gap-2 univer-rounded univer-border univer-border-solid
|
|
864
|
+
univer-border-gray-200 univer-p-1
|
|
865
|
+
hover:univer-bg-gray-100
|
|
866
|
+
`, {
|
|
867
|
+
"univer-bg-gray-100": o,
|
|
868
|
+
"univer-bg-white": !o
|
|
869
|
+
}),
|
|
870
|
+
children: [
|
|
871
|
+
/* @__PURE__ */ u(
|
|
872
|
+
pn,
|
|
873
|
+
{
|
|
874
|
+
style: { color: "#35322B" },
|
|
875
|
+
extend: { colorChannel1: "rgb(var(--green-700, #409f11))" }
|
|
876
|
+
}
|
|
877
|
+
),
|
|
878
|
+
f && /* @__PURE__ */ u(_n, { className: "univer-text-[10px] univer-text-gray-400" })
|
|
879
|
+
]
|
|
880
|
+
}
|
|
881
|
+
)
|
|
882
|
+
}
|
|
883
|
+
)
|
|
884
|
+
}
|
|
885
|
+
);
|
|
886
|
+
}, Tt = "COMPONENT_IMAGE_POPUP_MENU", Et = "drawing-ui.config", tn = {}, Pn = {
|
|
887
|
+
id: "sheet.operation.image-reset-size",
|
|
888
|
+
type: ve.OPERATION,
|
|
889
|
+
handler: (i, t) => !0
|
|
890
|
+
}, Bt = (i) => {
|
|
891
|
+
const { src: t } = i;
|
|
892
|
+
return t ? /* @__PURE__ */ u("div", { children: /* @__PURE__ */ u("img", { src: t, alt: "Univer Image Viewer", style: { width: "100%", height: "100%", position: "relative" } }) }) : null;
|
|
893
|
+
};
|
|
894
|
+
var jt = Object.getOwnPropertyDescriptor, Ut = (i, t, n, e) => {
|
|
895
|
+
for (var r = e > 1 ? void 0 : e ? jt(t, n) : t, o = i.length - 1, a; o >= 0; o--)
|
|
896
|
+
(a = i[o]) && (r = a(r) || r);
|
|
897
|
+
return r;
|
|
898
|
+
}, rn = (i, t) => (n, e) => t(n, e, i);
|
|
899
|
+
let je = class extends xe {
|
|
900
|
+
constructor(i, t) {
|
|
901
|
+
super(), this._componentManager = i, this._commandService = t, this._init();
|
|
902
|
+
}
|
|
903
|
+
_initCustomComponents() {
|
|
904
|
+
const i = this._componentManager;
|
|
905
|
+
this.disposeWithMe(i.register(Tt, Dt)), this.disposeWithMe(i.register(hn, Bt));
|
|
906
|
+
}
|
|
907
|
+
_initCommands() {
|
|
908
|
+
[
|
|
909
|
+
Fe,
|
|
910
|
+
ge,
|
|
911
|
+
Pn,
|
|
912
|
+
Ye,
|
|
913
|
+
Be
|
|
914
|
+
].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i)));
|
|
915
|
+
}
|
|
916
|
+
_init() {
|
|
917
|
+
this._initCommands(), this._initCustomComponents();
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
je = Ut([
|
|
921
|
+
rn(0, Le($n)),
|
|
922
|
+
rn(1, me)
|
|
923
|
+
], je);
|
|
924
|
+
var At = Object.getOwnPropertyDescriptor, Ht = (i, t, n, e) => {
|
|
925
|
+
for (var r = e > 1 ? void 0 : e ? At(t, n) : t, o = i.length - 1, a; o >= 0; o--)
|
|
926
|
+
(a = i[o]) && (r = a(r) || r);
|
|
927
|
+
return r;
|
|
928
|
+
}, Re = (i, t) => (n, e) => t(n, e, i);
|
|
929
|
+
let Ue = class extends xe {
|
|
930
|
+
constructor(t, n, e, r) {
|
|
931
|
+
super();
|
|
932
|
+
ee(this, "_sceneListenerOnDrawingMap", /* @__PURE__ */ new WeakSet());
|
|
933
|
+
this._currentUniverService = t, this._commandService = n, this._renderManagerService = e, this._drawingManagerService = r, this._initialize();
|
|
934
|
+
}
|
|
935
|
+
dispose() {
|
|
936
|
+
super.dispose();
|
|
937
|
+
}
|
|
938
|
+
_initialize() {
|
|
939
|
+
this._recoveryImages(), this._drawingAddListener(), this._drawingRemoveListener(), this._drawingUpdateListener(), this._commandExecutedListener(), this._drawingArrangeListener(), this._drawingGroupListener(), this._drawingRefreshListener(), this._drawingVisibleListener();
|
|
940
|
+
}
|
|
941
|
+
_recoveryImages() {
|
|
942
|
+
const t = this._drawingManagerService.drawingManagerData, n = un(this._currentUniverService);
|
|
943
|
+
if (n == null)
|
|
944
|
+
return;
|
|
945
|
+
const { unitId: e, subUnitId: r } = n;
|
|
946
|
+
Object.keys(t).forEach((o) => {
|
|
947
|
+
Object.keys(t[o]).forEach((a) => {
|
|
948
|
+
const s = t[o][a].data;
|
|
949
|
+
s == null || o !== e || a !== r || Object.keys(s).forEach((c) => {
|
|
950
|
+
s[c] && this._insertDrawing([{ unitId: o, subUnitId: a, drawingId: c }]);
|
|
951
|
+
});
|
|
952
|
+
});
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
_commandExecutedListener() {
|
|
956
|
+
this.disposeWithMe(
|
|
957
|
+
this._commandService.onCommandExecuted((t) => {
|
|
958
|
+
if (t.id === Ye.id) {
|
|
959
|
+
const n = t.params;
|
|
960
|
+
if (n == null)
|
|
961
|
+
return;
|
|
962
|
+
this._drawingAlign(n);
|
|
963
|
+
}
|
|
964
|
+
})
|
|
965
|
+
);
|
|
966
|
+
}
|
|
967
|
+
_drawingGroupListener() {
|
|
968
|
+
this.disposeWithMe(
|
|
969
|
+
this._drawingManagerService.group$.subscribe((t) => {
|
|
970
|
+
this._groupDrawings(t);
|
|
971
|
+
})
|
|
972
|
+
), this.disposeWithMe(
|
|
973
|
+
this._drawingManagerService.ungroup$.subscribe((t) => {
|
|
974
|
+
this._ungroupDrawings(t);
|
|
975
|
+
})
|
|
976
|
+
);
|
|
977
|
+
}
|
|
978
|
+
// private _drawingGroup(params: ISetImageGroupOperationParams) {
|
|
979
|
+
// const { groupType } = params;
|
|
980
|
+
// const drawings = this._drawingManagerService.getFocusDrawings();
|
|
981
|
+
// if (drawings.length === 0) {
|
|
982
|
+
// return;
|
|
983
|
+
// }
|
|
984
|
+
// switch (groupType) {
|
|
985
|
+
// case GroupType.group:
|
|
986
|
+
// this._groupDrawings(drawings);
|
|
987
|
+
// break;
|
|
988
|
+
// case GroupType.regroup:
|
|
989
|
+
// this._regroupDrawings(drawings);
|
|
990
|
+
// break;
|
|
991
|
+
// case GroupType.ungroup:
|
|
992
|
+
// this._ungroupDrawings(drawings);
|
|
993
|
+
// break;
|
|
994
|
+
// default:
|
|
995
|
+
// break;
|
|
996
|
+
// }
|
|
997
|
+
// }
|
|
998
|
+
_getSceneAndTransformerByDrawingSearch(t) {
|
|
999
|
+
if (t == null)
|
|
1000
|
+
return;
|
|
1001
|
+
const n = this._renderManagerService.getRenderById(t), e = n == null ? void 0 : n.scene;
|
|
1002
|
+
if (e == null)
|
|
1003
|
+
return null;
|
|
1004
|
+
const r = e.getTransformerByCreate();
|
|
1005
|
+
return { scene: e, transformer: r };
|
|
1006
|
+
}
|
|
1007
|
+
_groupDrawings(t) {
|
|
1008
|
+
t.forEach((n) => {
|
|
1009
|
+
this._groupDrawing(n);
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
_groupDrawing(t) {
|
|
1013
|
+
const { parent: n, children: e } = t, { unitId: r, subUnitId: o, drawingId: a } = n, s = this._getSceneAndTransformerByDrawingSearch(n.unitId);
|
|
1014
|
+
if (s == null)
|
|
1015
|
+
return;
|
|
1016
|
+
const { scene: c, transformer: l } = s;
|
|
1017
|
+
this._commandService.syncExecuteCommand(ge.id);
|
|
1018
|
+
const m = [];
|
|
1019
|
+
if (e.forEach((f) => {
|
|
1020
|
+
const v = G(f), w = c.getObjectIncludeInGroup(v);
|
|
1021
|
+
if (w == null || m.includes(w))
|
|
1022
|
+
return;
|
|
1023
|
+
m.push(w);
|
|
1024
|
+
const { transform: p } = f;
|
|
1025
|
+
p != null && (w.classType === Je.GROUP ? w.transformByState({ left: p.left, top: p.top }) : w.transformByState(p));
|
|
1026
|
+
}), m.length === 0)
|
|
1027
|
+
return;
|
|
1028
|
+
const d = G({ unitId: r, subUnitId: o, drawingId: a }), h = new we(d);
|
|
1029
|
+
c.addObject(h, De).attachTransformerTo(h), h.addObjects(...m), n.transform && h.transformByState({ left: n.transform.left, top: n.transform.top }), l.clearSelectedObjects(), l.setSelectedControl(h);
|
|
1030
|
+
}
|
|
1031
|
+
// private _regroupDrawings(drawings: IDrawingSearch[]) {
|
|
1032
|
+
// const renderObject = this._getSceneAndTransformerByDrawingSearch(drawings[0].unitId);
|
|
1033
|
+
// if (renderObject == null) {
|
|
1034
|
+
// return;
|
|
1035
|
+
// }
|
|
1036
|
+
// const { scene, transformer } = renderObject;
|
|
1037
|
+
// const objects: BaseObject[] = [];
|
|
1038
|
+
// let firstGroup: Nullable<Group> = null;
|
|
1039
|
+
// drawings.forEach((drawing) => {
|
|
1040
|
+
// const imageShapeKey = getDrawingShapeKeyByDrawingSearch(drawing);
|
|
1041
|
+
// const o = scene.getObject(imageShapeKey);
|
|
1042
|
+
// if (o == null) {
|
|
1043
|
+
// return true;
|
|
1044
|
+
// }
|
|
1045
|
+
// const group = o.ancestorGroup as Nullable<Group>;
|
|
1046
|
+
// if (group != null && firstGroup == null) {
|
|
1047
|
+
// firstGroup = group;
|
|
1048
|
+
// } else if (group != null && !objects.includes(group)) {
|
|
1049
|
+
// objects.push(group);
|
|
1050
|
+
// } else if (!objects.includes(o)) {
|
|
1051
|
+
// objects.push(o);
|
|
1052
|
+
// }
|
|
1053
|
+
// });
|
|
1054
|
+
// if (firstGroup == null) {
|
|
1055
|
+
// return;
|
|
1056
|
+
// }
|
|
1057
|
+
// if (objects.length === 0) {
|
|
1058
|
+
// return;
|
|
1059
|
+
// }
|
|
1060
|
+
// (firstGroup as Group).addObjects(...objects);
|
|
1061
|
+
// (firstGroup as Group).reCalculateObjects();
|
|
1062
|
+
// transformer.clearSelectedObjects();
|
|
1063
|
+
// transformer.setSelectedControl(firstGroup);
|
|
1064
|
+
// }
|
|
1065
|
+
_ungroupDrawings(t) {
|
|
1066
|
+
t.forEach((n) => {
|
|
1067
|
+
this._ungroupDrawing(n);
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
_ungroupDrawing(t) {
|
|
1071
|
+
const { parent: n, children: e } = t, r = this._getSceneAndTransformerByDrawingSearch(n.unitId);
|
|
1072
|
+
if (r == null)
|
|
1073
|
+
return;
|
|
1074
|
+
const { scene: o, transformer: a } = r;
|
|
1075
|
+
e.forEach((d) => {
|
|
1076
|
+
const h = G(d), f = o.getObjectIncludeInGroup(h);
|
|
1077
|
+
if (f == null)
|
|
1078
|
+
return !0;
|
|
1079
|
+
if (f == null)
|
|
1080
|
+
return;
|
|
1081
|
+
const { transform: v } = d;
|
|
1082
|
+
v != null && (f.classType === Je.GROUP ? f.transformByState({ left: v.left, top: v.top }) : f.transformByState(v));
|
|
1083
|
+
});
|
|
1084
|
+
const s = G(n), c = o.getObject(s), { width: l, height: m } = c;
|
|
1085
|
+
c.getObjects().forEach((d) => {
|
|
1086
|
+
c.removeSelfObjectAndTransform(d.oKey, l, m);
|
|
1087
|
+
}), c.dispose(), a.clearSelectedObjects();
|
|
1088
|
+
}
|
|
1089
|
+
_drawingAlign(t) {
|
|
1090
|
+
const { alignType: n } = t, e = this._drawingManagerService.getFocusDrawings();
|
|
1091
|
+
if (n === D.default)
|
|
1092
|
+
return;
|
|
1093
|
+
const r = [];
|
|
1094
|
+
let o = Number.POSITIVE_INFINITY, a = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY, c = Number.NEGATIVE_INFINITY, l = 0;
|
|
1095
|
+
e.forEach((m) => {
|
|
1096
|
+
const { unitId: d, subUnitId: h, drawingId: f, drawingType: v } = m, w = this._drawingManagerService.getDrawingByParam({ unitId: d, subUnitId: h, drawingId: f });
|
|
1097
|
+
if (w == null || w.transform == null)
|
|
1098
|
+
return;
|
|
1099
|
+
r.push({
|
|
1100
|
+
unitId: d,
|
|
1101
|
+
subUnitId: h,
|
|
1102
|
+
drawingId: f,
|
|
1103
|
+
drawingType: v,
|
|
1104
|
+
transform: w.transform
|
|
1105
|
+
});
|
|
1106
|
+
const { left: p = 0, top: S = 0, width: _ = 0, height: M = 0 } = w.transform;
|
|
1107
|
+
o = Math.min(o, p), a = Math.min(a, S), s = Math.max(s, p + _), c = Math.max(c, S + M), l++;
|
|
1108
|
+
}), l !== 0 && (this._sortDrawingTransform(r, n), this._applyAlignType(r, n, o, a, s, c, l));
|
|
1109
|
+
}
|
|
1110
|
+
_applyAlignType(t, n, e, r, o, a, s) {
|
|
1111
|
+
const c = Math.round((o - e) / s * 10) / 10, l = Math.round((a - r) / s * 10) / 10, m = [], d = this._getSceneAndTransformerByDrawingSearch(t[0].unitId);
|
|
1112
|
+
if (d == null)
|
|
1113
|
+
return;
|
|
1114
|
+
const { scene: h, transformer: f } = d;
|
|
1115
|
+
t.forEach((v, w) => {
|
|
1116
|
+
const { unitId: p, subUnitId: S, drawingId: _, transform: M, drawingType: I } = v, { left: N = 0, top: P = 0, width: b = 0, height: y = 0 } = M;
|
|
1117
|
+
let R = N, O = P;
|
|
1118
|
+
switch (n) {
|
|
1119
|
+
case D.left:
|
|
1120
|
+
R = e;
|
|
1121
|
+
break;
|
|
1122
|
+
case D.center:
|
|
1123
|
+
R = e + (o - e) / 2 - b / 2;
|
|
1124
|
+
break;
|
|
1125
|
+
case D.right:
|
|
1126
|
+
R = o - b;
|
|
1127
|
+
break;
|
|
1128
|
+
case D.top:
|
|
1129
|
+
O = r;
|
|
1130
|
+
break;
|
|
1131
|
+
case D.middle:
|
|
1132
|
+
O = r + (a - r) / 2 - y / 2;
|
|
1133
|
+
break;
|
|
1134
|
+
case D.bottom:
|
|
1135
|
+
O = a - y;
|
|
1136
|
+
break;
|
|
1137
|
+
case D.horizon:
|
|
1138
|
+
R = e + c * w;
|
|
1139
|
+
break;
|
|
1140
|
+
case D.vertical:
|
|
1141
|
+
O = r + l * w;
|
|
1142
|
+
break;
|
|
1143
|
+
}
|
|
1144
|
+
(R !== N || O !== P) && m.push({
|
|
1145
|
+
unitId: p,
|
|
1146
|
+
subUnitId: S,
|
|
1147
|
+
drawingId: _,
|
|
1148
|
+
drawingType: I,
|
|
1149
|
+
transform: {
|
|
1150
|
+
left: R,
|
|
1151
|
+
top: O
|
|
1152
|
+
}
|
|
1153
|
+
});
|
|
1154
|
+
}), this._drawingManagerService.featurePluginUpdateNotification(m), f.refreshControls().changeNotification();
|
|
1155
|
+
}
|
|
1156
|
+
_sortDrawingTransform(t, n) {
|
|
1157
|
+
t.sort((e, r) => {
|
|
1158
|
+
const o = e.transform, a = r.transform, {
|
|
1159
|
+
left: s = 0,
|
|
1160
|
+
top: c = 0,
|
|
1161
|
+
width: l = 0,
|
|
1162
|
+
height: m = 0
|
|
1163
|
+
} = o, {
|
|
1164
|
+
left: d = 0,
|
|
1165
|
+
top: h = 0,
|
|
1166
|
+
width: f = 0,
|
|
1167
|
+
height: v = 0
|
|
1168
|
+
} = a;
|
|
1169
|
+
switch (n) {
|
|
1170
|
+
case D.left:
|
|
1171
|
+
return s - d;
|
|
1172
|
+
case D.center:
|
|
1173
|
+
return s + l / 2 - (d + f / 2);
|
|
1174
|
+
case D.right:
|
|
1175
|
+
return s + l - (d + f);
|
|
1176
|
+
case D.top:
|
|
1177
|
+
return c - h;
|
|
1178
|
+
case D.middle:
|
|
1179
|
+
return c + m / 2 - (h + v / 2);
|
|
1180
|
+
case D.bottom:
|
|
1181
|
+
return c + m - (h + v);
|
|
1182
|
+
case D.horizon:
|
|
1183
|
+
return s + l / 2 - (d + f / 2);
|
|
1184
|
+
case D.vertical:
|
|
1185
|
+
return c + m / 2 - (h + v / 2);
|
|
1186
|
+
default:
|
|
1187
|
+
return 0;
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
_drawingArrangeListener() {
|
|
1192
|
+
this.disposeWithMe(
|
|
1193
|
+
this._drawingManagerService.order$.subscribe((t) => {
|
|
1194
|
+
this._drawingArrange(t);
|
|
1195
|
+
})
|
|
1196
|
+
);
|
|
1197
|
+
}
|
|
1198
|
+
_drawingArrange(t) {
|
|
1199
|
+
const { unitId: n, subUnitId: e, drawingIds: r } = t, o = this._getSceneAndTransformerByDrawingSearch(n);
|
|
1200
|
+
if (o == null)
|
|
1201
|
+
return;
|
|
1202
|
+
const { scene: a } = o;
|
|
1203
|
+
r.forEach((s) => {
|
|
1204
|
+
const c = G({ unitId: n, subUnitId: e, drawingId: s }), l = a.fuzzyMathObjects(c, !0);
|
|
1205
|
+
if (l == null || l.length === 0)
|
|
1206
|
+
return;
|
|
1207
|
+
const m = this._drawingManagerService.getDrawingOrder(n, e).indexOf(s);
|
|
1208
|
+
for (const d of l)
|
|
1209
|
+
d.setProps({ zIndex: m }), d.makeDirty();
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
_drawingAddListener() {
|
|
1213
|
+
this.disposeWithMe(
|
|
1214
|
+
this._drawingManagerService.add$.subscribe((t) => {
|
|
1215
|
+
this._insertDrawing(t);
|
|
1216
|
+
})
|
|
1217
|
+
);
|
|
1218
|
+
}
|
|
1219
|
+
_insertDrawing(t) {
|
|
1220
|
+
const n = [];
|
|
1221
|
+
t.forEach((e) => {
|
|
1222
|
+
const { unitId: r } = e;
|
|
1223
|
+
if (this._drawingManagerService.getDrawingByParam(e) == null)
|
|
1224
|
+
return;
|
|
1225
|
+
const a = this._getSceneAndTransformerByDrawingSearch(r);
|
|
1226
|
+
if (a == null)
|
|
1227
|
+
return;
|
|
1228
|
+
const { scene: s } = a;
|
|
1229
|
+
n.includes(s) || n.push(s);
|
|
1230
|
+
}), n.forEach((e) => {
|
|
1231
|
+
this._sceneListenerOnDrawingMap.has(e) || (this._addListenerOnDrawing(e), this._sceneListenerOnDrawingMap.add(e));
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
_drawingRemoveListener() {
|
|
1235
|
+
this.disposeWithMe(
|
|
1236
|
+
this._drawingManagerService.remove$.subscribe((t) => {
|
|
1237
|
+
t.forEach((n) => {
|
|
1238
|
+
var m;
|
|
1239
|
+
const { unitId: e, subUnitId: r, drawingId: o } = n, a = this._getSceneAndTransformerByDrawingSearch(e);
|
|
1240
|
+
if (a == null)
|
|
1241
|
+
return;
|
|
1242
|
+
const { scene: s } = a, c = G({ unitId: e, subUnitId: r, drawingId: o }), l = s.fuzzyMathObjects(c, !0);
|
|
1243
|
+
if (l.length > 0) {
|
|
1244
|
+
for (const d of l)
|
|
1245
|
+
d.dispose();
|
|
1246
|
+
(m = s.getTransformer()) == null || m.clearSelectedObjects();
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
})
|
|
1250
|
+
);
|
|
1251
|
+
}
|
|
1252
|
+
_drawingUpdateListener() {
|
|
1253
|
+
this.disposeWithMe(
|
|
1254
|
+
this._drawingManagerService.update$.subscribe((t) => {
|
|
1255
|
+
t.forEach((n) => {
|
|
1256
|
+
var b;
|
|
1257
|
+
const { unitId: e, subUnitId: r, drawingId: o } = n, a = this._drawingManagerService.getDrawingByParam(n);
|
|
1258
|
+
if (a == null)
|
|
1259
|
+
return;
|
|
1260
|
+
const { transform: s, drawingType: c } = a, l = this._getSceneAndTransformerByDrawingSearch(e);
|
|
1261
|
+
if (l == null)
|
|
1262
|
+
return;
|
|
1263
|
+
const { scene: m, transformer: d } = l;
|
|
1264
|
+
if (s == null)
|
|
1265
|
+
return !0;
|
|
1266
|
+
const { left: h = 0, top: f = 0, width: v = 0, height: w = 0, angle: p = 0, flipX: S = !1, flipY: _ = !1, skewX: M = 0, skewY: I = 0 } = s, N = G({ unitId: e, subUnitId: r, drawingId: o }), P = m.getObject(N);
|
|
1267
|
+
if (P == null)
|
|
1268
|
+
return !0;
|
|
1269
|
+
P.transformByState({ left: h, top: f, width: v, height: w, angle: p, flipX: S, flipY: _, skewX: M, skewY: I }), (b = m.getTransformer()) == null || b.debounceRefreshControls();
|
|
1270
|
+
});
|
|
1271
|
+
})
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1274
|
+
_drawingRefreshListener() {
|
|
1275
|
+
this.disposeWithMe(
|
|
1276
|
+
this._drawingManagerService.refreshTransform$.subscribe((t) => {
|
|
1277
|
+
t.forEach((n) => {
|
|
1278
|
+
const { unitId: e, subUnitId: r, drawingId: o } = n, a = this._getSceneAndTransformerByDrawingSearch(e);
|
|
1279
|
+
if (a == null)
|
|
1280
|
+
return;
|
|
1281
|
+
const s = this._drawingManagerService.getDrawingByParam(n);
|
|
1282
|
+
if (s == null)
|
|
1283
|
+
return;
|
|
1284
|
+
const { transform: c } = s, { scene: l } = a, m = G({ unitId: e, subUnitId: r, drawingId: o }), d = l.getObject(m);
|
|
1285
|
+
if (d == null || c == null)
|
|
1286
|
+
return !0;
|
|
1287
|
+
const {
|
|
1288
|
+
left: h = 0,
|
|
1289
|
+
top: f = 0,
|
|
1290
|
+
width: v = 0,
|
|
1291
|
+
height: w = 0,
|
|
1292
|
+
angle: p = 0,
|
|
1293
|
+
flipX: S = !1,
|
|
1294
|
+
flipY: _ = !1,
|
|
1295
|
+
skewX: M = 0,
|
|
1296
|
+
skewY: I = 0
|
|
1297
|
+
} = c;
|
|
1298
|
+
d.transformByState({ left: h, top: f, width: v, height: w, angle: p, flipX: S, flipY: _, skewX: M, skewY: I });
|
|
1299
|
+
});
|
|
1300
|
+
})
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1303
|
+
_drawingVisibleListener() {
|
|
1304
|
+
this.disposeWithMe(
|
|
1305
|
+
this._drawingManagerService.visible$.subscribe((t) => {
|
|
1306
|
+
t.forEach((n) => {
|
|
1307
|
+
const { unitId: e, subUnitId: r, drawingId: o, visible: a } = n, s = this._getSceneAndTransformerByDrawingSearch(e);
|
|
1308
|
+
if (s == null)
|
|
1309
|
+
return;
|
|
1310
|
+
const { scene: c } = s, l = G({ unitId: e, subUnitId: r, drawingId: o }), m = c.getObject(l);
|
|
1311
|
+
if (m == null)
|
|
1312
|
+
return !0;
|
|
1313
|
+
a ? m.show() : m.hide();
|
|
1314
|
+
});
|
|
1315
|
+
})
|
|
1316
|
+
);
|
|
1317
|
+
}
|
|
1318
|
+
_filterUpdateParams(t, n) {
|
|
1319
|
+
return t.filter((e, r) => {
|
|
1320
|
+
if (e == null)
|
|
1321
|
+
return !1;
|
|
1322
|
+
const { transform: o } = e;
|
|
1323
|
+
return sn(o, n == null ? void 0 : n[r]);
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
// group?.getObjects().forEach((o) => {
|
|
1327
|
+
// const drawing = this._drawingManagerService.getDrawingOKey(o.oKey);
|
|
1328
|
+
// if (drawing != null) {
|
|
1329
|
+
// const { unitId, subUnitId, drawingId } = drawing;
|
|
1330
|
+
// drawings.push({ unitId, subUnitId, drawingId });
|
|
1331
|
+
// }
|
|
1332
|
+
// });
|
|
1333
|
+
_addListenerOnDrawing(t) {
|
|
1334
|
+
const n = t.getTransformerByCreate();
|
|
1335
|
+
let e = null;
|
|
1336
|
+
this.disposeWithMe(
|
|
1337
|
+
Ce(
|
|
1338
|
+
n.changeStart$.subscribe((r) => {
|
|
1339
|
+
const { objects: o } = r, a = Array.from(o.values()), s = [];
|
|
1340
|
+
e = a.map((c) => {
|
|
1341
|
+
const { left: l, top: m, height: d, width: h, angle: f, oKey: v, isInGroup: w } = c, p = this._drawingManagerService.getDrawingOKey(v);
|
|
1342
|
+
if (w || c instanceof we) {
|
|
1343
|
+
let S = c.ancestorGroup;
|
|
1344
|
+
if (S == null && c instanceof we && (S = c), S == null)
|
|
1345
|
+
return null;
|
|
1346
|
+
const _ = this._drawingManagerService.getDrawingOKey(S.oKey);
|
|
1347
|
+
if (_) {
|
|
1348
|
+
const { unitId: M, subUnitId: I, drawingId: N } = _;
|
|
1349
|
+
s.push({ unitId: M, subUnitId: I, drawingId: N });
|
|
1350
|
+
const { left: P, top: b, height: y, width: R, angle: O } = S;
|
|
1351
|
+
return { left: P, top: b, height: y, width: R, angle: O };
|
|
1352
|
+
}
|
|
1353
|
+
} else if (p != null) {
|
|
1354
|
+
const { unitId: S, subUnitId: _, drawingId: M } = p;
|
|
1355
|
+
return s.push({ unitId: S, subUnitId: _, drawingId: M }), { left: l, top: m, height: d, width: h, angle: f };
|
|
1356
|
+
}
|
|
1357
|
+
return null;
|
|
1358
|
+
}).filter((c) => c != null), s.length > 0 ? this._commandService.syncExecuteCommand(Ne.id, s) : this._commandService.syncExecuteCommand(Ne.id, []);
|
|
1359
|
+
})
|
|
1360
|
+
)
|
|
1361
|
+
), this.disposeWithMe(
|
|
1362
|
+
Ce(
|
|
1363
|
+
n.changeEnd$.subscribe((r) => {
|
|
1364
|
+
const { objects: o } = r, a = this._filterUpdateParams(Ve(o, this._drawingManagerService), e);
|
|
1365
|
+
a.length > 0 && this._drawingManagerService.featurePluginUpdateNotification(a);
|
|
1366
|
+
})
|
|
1367
|
+
)
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
};
|
|
1371
|
+
Ue = Ht([
|
|
1372
|
+
Re(0, Ke),
|
|
1373
|
+
Re(1, me),
|
|
1374
|
+
Re(2, ue),
|
|
1375
|
+
Re(3, re)
|
|
1376
|
+
], Ue);
|
|
1377
|
+
class Me extends Gn {
|
|
1378
|
+
constructor(n, e) {
|
|
1379
|
+
e == null && (e = {}), e.transformerConfig = {
|
|
1380
|
+
keepRatio: !1,
|
|
1381
|
+
isCropper: !0,
|
|
1382
|
+
anchorFill: "rgb(0, 0, 0)",
|
|
1383
|
+
anchorStroke: "rgb(255, 255, 255)",
|
|
1384
|
+
anchorSize: 24
|
|
1385
|
+
};
|
|
1386
|
+
super(n, e);
|
|
1387
|
+
ee(this, "_srcRect");
|
|
1388
|
+
ee(this, "_prstGeom");
|
|
1389
|
+
ee(this, "_applyTransform");
|
|
1390
|
+
ee(this, "_dragPadding", 8);
|
|
1391
|
+
ee(this, "_cacheCanvas");
|
|
1392
|
+
e != null && e.srcRect && (this._srcRect = e.srcRect), e != null && e.prstGeom && (this._prstGeom = e.prstGeom), e != null && e.applyTransform && (this._applyTransform = e.applyTransform), e != null && e.dragPadding && (this._dragPadding = e.dragPadding), this._applyProps();
|
|
1393
|
+
}
|
|
1394
|
+
refreshSrcRect(n, e) {
|
|
1395
|
+
this._srcRect = n, this._applyTransform = e, this._applyProps();
|
|
1396
|
+
}
|
|
1397
|
+
get srcRect() {
|
|
1398
|
+
return this._srcRect;
|
|
1399
|
+
}
|
|
1400
|
+
dispose() {
|
|
1401
|
+
var n;
|
|
1402
|
+
super.dispose(), (n = this._cacheCanvas) == null || n.dispose(), this._srcRect = null;
|
|
1403
|
+
}
|
|
1404
|
+
isHit(n) {
|
|
1405
|
+
const e = this.getInverseCoord(n);
|
|
1406
|
+
return e.x >= -this.strokeWidth / 2 && e.x <= this.width + this.strokeWidth / 2 && e.y >= -this.strokeWidth / 2 && e.y <= this.height + this.strokeWidth / 2 && !this._inSurround(e);
|
|
1407
|
+
}
|
|
1408
|
+
_inSurround(n) {
|
|
1409
|
+
const e = this._dragPadding;
|
|
1410
|
+
return n.x >= e - this.strokeWidth / 2 && n.x <= this.width + this.strokeWidth / 2 - e && n.y >= e - this.strokeWidth / 2 && n.y <= this.height + this.strokeWidth / 2 - e;
|
|
1411
|
+
}
|
|
1412
|
+
render(n, e) {
|
|
1413
|
+
return this.visible ? (n.save(), this._draw(n), n.restore(), this.makeDirty(!1), this) : (this.makeDirty(!1), this);
|
|
1414
|
+
}
|
|
1415
|
+
_draw(n) {
|
|
1416
|
+
var c, l;
|
|
1417
|
+
const r = this.getScene().getEngine(), { width: o, height: a } = r;
|
|
1418
|
+
this._initialCacheCanvas(), (c = this._cacheCanvas) == null || c.clear();
|
|
1419
|
+
const s = (l = this._cacheCanvas) == null ? void 0 : l.getContext();
|
|
1420
|
+
s != null && (s.save(), ln.drawWith(s, {
|
|
1421
|
+
left: 0,
|
|
1422
|
+
top: 0,
|
|
1423
|
+
width: o,
|
|
1424
|
+
height: a,
|
|
1425
|
+
fill: "rgba(0, 0, 0, 0.5)"
|
|
1426
|
+
}), s.setTransform(n.getTransform()), this._clipForApplyObject(s), this._applyCache(n), s.restore());
|
|
1427
|
+
}
|
|
1428
|
+
_clipForApplyObject(n) {
|
|
1429
|
+
let e = 0;
|
|
1430
|
+
if (this._prstGeom != null && (e = 1), n.globalCompositeOperation = "destination-out", n.beginPath(), e === 0) {
|
|
1431
|
+
const r = this.transform.getMatrix();
|
|
1432
|
+
n.transform(r[0], r[1], r[2], r[3], r[4], r[5]), n.rect(0, 0, this.width, this.height), n.fill();
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
_applyProps() {
|
|
1436
|
+
if (this._applyTransform == null)
|
|
1437
|
+
return;
|
|
1438
|
+
let n = 0, e = 0, r = 0, o = 0;
|
|
1439
|
+
const { left: a = 0, top: s = 0, width: c = 0, height: l = 0, angle: m } = this._applyTransform;
|
|
1440
|
+
if (this._srcRect != null) {
|
|
1441
|
+
const { left: f = 0, top: v = 0, right: w = 0, bottom: p = 0 } = this._srcRect;
|
|
1442
|
+
n = f, e = v, r = w, o = p;
|
|
1443
|
+
}
|
|
1444
|
+
const d = a + n, h = s + e;
|
|
1445
|
+
this.transformByState({
|
|
1446
|
+
left: d,
|
|
1447
|
+
top: h,
|
|
1448
|
+
width: a + c - r - d,
|
|
1449
|
+
height: s + l - o - h,
|
|
1450
|
+
angle: m
|
|
1451
|
+
});
|
|
1452
|
+
}
|
|
1453
|
+
_applyCache(n) {
|
|
1454
|
+
if (!n || this._cacheCanvas == null)
|
|
1455
|
+
return;
|
|
1456
|
+
const e = this._cacheCanvas.getContext();
|
|
1457
|
+
e.save(), n.save(), n.setTransform(1, 0, 0, 1, 0, 0), e.setTransform(1, 0, 0, 1, 0, 0), n.drawImage(this._cacheCanvas.getCanvasEle(), 0, 0), n.restore(), e.restore();
|
|
1458
|
+
}
|
|
1459
|
+
_initialCacheCanvas() {
|
|
1460
|
+
if (this._cacheCanvas != null)
|
|
1461
|
+
return;
|
|
1462
|
+
const n = this.getScene();
|
|
1463
|
+
if (n == null) return;
|
|
1464
|
+
this._cacheCanvas = new Wn();
|
|
1465
|
+
const e = n.getEngine();
|
|
1466
|
+
this._cacheCanvas.setSize(e.width, e.height), e.onTransformChange$.subscribeEvent(() => {
|
|
1467
|
+
var r;
|
|
1468
|
+
(r = this._cacheCanvas) == null || r.setSize(e.width, e.height), this.makeDirty(!0);
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
var Lt = Object.getOwnPropertyDescriptor, xt = (i, t, n, e) => {
|
|
1473
|
+
for (var r = e > 1 ? void 0 : e ? Lt(t, n) : t, o = i.length - 1, a; o >= 0; o--)
|
|
1474
|
+
(a = i[o]) && (r = a(r) || r);
|
|
1475
|
+
return r;
|
|
1476
|
+
}, de = (i, t) => (n, e) => t(n, e, i);
|
|
1477
|
+
let Ae = class extends xe {
|
|
1478
|
+
constructor(t, n, e, r, o, a) {
|
|
1479
|
+
super();
|
|
1480
|
+
ee(this, "_sceneListenerOnImageMap", /* @__PURE__ */ new WeakSet());
|
|
1481
|
+
this._commandService = t, this._drawingManagerService = n, this._renderManagerService = e, this._univerInstanceService = r, this._messageService = o, this._localeService = a, this._init();
|
|
1482
|
+
}
|
|
1483
|
+
_init() {
|
|
1484
|
+
this._initOpenCrop(), this._initCloseCrop(), this._initAutoCrop();
|
|
1485
|
+
}
|
|
1486
|
+
_initAutoCrop() {
|
|
1487
|
+
this.disposeWithMe(
|
|
1488
|
+
this._commandService.onCommandExecuted((t) => {
|
|
1489
|
+
if (t.id !== Be.id)
|
|
1490
|
+
return;
|
|
1491
|
+
const n = t.params;
|
|
1492
|
+
if (n == null)
|
|
1493
|
+
return;
|
|
1494
|
+
const { cropType: e } = n, r = this._drawingManagerService.getFocusDrawings();
|
|
1495
|
+
if (r.length !== 1)
|
|
1496
|
+
return;
|
|
1497
|
+
const o = r[0], { unitId: a, subUnitId: s, drawingId: c } = o, l = this._renderManagerService.getRenderById(a), m = l == null ? void 0 : l.scene;
|
|
1498
|
+
if (m == null)
|
|
1499
|
+
return !0;
|
|
1500
|
+
this._searchCropObject(m) != null && this._commandService.syncExecuteCommand(ge.id, { isAuto: !0 });
|
|
1501
|
+
const h = G({ unitId: a, subUnitId: s, drawingId: c }), f = m.getObject(h);
|
|
1502
|
+
if (!(f instanceof ze)) {
|
|
1503
|
+
this._messageService.show({
|
|
1504
|
+
type: Qe.Error,
|
|
1505
|
+
content: this._localeService.t("image-cropper.error")
|
|
1506
|
+
});
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
f != null && (this._updateCropperObject(e, f), this._commandService.executeCommand(Fe.id, { unitId: a, subUnitId: s, drawingId: c }));
|
|
1510
|
+
})
|
|
1511
|
+
);
|
|
1512
|
+
}
|
|
1513
|
+
_calculateSrcRectByRatio(t, n, e, r, o, a) {
|
|
1514
|
+
const s = e / r, c = o / a;
|
|
1515
|
+
let l = e, m = r;
|
|
1516
|
+
s > c ? l = r * c : m = e / c;
|
|
1517
|
+
const d = (e - l) / 2, h = (r - m) / 2;
|
|
1518
|
+
return {
|
|
1519
|
+
left: ye(d, 1),
|
|
1520
|
+
top: ye(h, 1),
|
|
1521
|
+
right: ye(e - (d + l), 1),
|
|
1522
|
+
bottom: ye(r - (h + m), 1)
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1525
|
+
_updateCropperObject(t, n) {
|
|
1526
|
+
const { left: e, top: r, width: o, height: a } = n.calculateTransformWithSrcRect();
|
|
1527
|
+
let s;
|
|
1528
|
+
switch (t) {
|
|
1529
|
+
case A.R1_1:
|
|
1530
|
+
s = this._calculateSrcRectByRatio(e, r, o, a, 1, 1);
|
|
1531
|
+
break;
|
|
1532
|
+
case A.R16_9:
|
|
1533
|
+
s = this._calculateSrcRectByRatio(e, r, o, a, 16, 9);
|
|
1534
|
+
break;
|
|
1535
|
+
case A.R9_16:
|
|
1536
|
+
s = this._calculateSrcRectByRatio(e, r, o, a, 9, 16);
|
|
1537
|
+
break;
|
|
1538
|
+
case A.R5_4:
|
|
1539
|
+
s = this._calculateSrcRectByRatio(e, r, o, a, 5, 4);
|
|
1540
|
+
break;
|
|
1541
|
+
case A.R4_5:
|
|
1542
|
+
s = this._calculateSrcRectByRatio(e, r, o, a, 4, 5);
|
|
1543
|
+
break;
|
|
1544
|
+
case A.R4_3:
|
|
1545
|
+
s = this._calculateSrcRectByRatio(e, r, o, a, 4, 3);
|
|
1546
|
+
break;
|
|
1547
|
+
case A.R3_4:
|
|
1548
|
+
s = this._calculateSrcRectByRatio(e, r, o, a, 3, 4);
|
|
1549
|
+
break;
|
|
1550
|
+
case A.R3_2:
|
|
1551
|
+
s = this._calculateSrcRectByRatio(e, r, o, a, 3, 2);
|
|
1552
|
+
break;
|
|
1553
|
+
case A.R2_3:
|
|
1554
|
+
s = this._calculateSrcRectByRatio(e, r, o, a, 2, 3);
|
|
1555
|
+
break;
|
|
1556
|
+
case A.FREE:
|
|
1557
|
+
}
|
|
1558
|
+
if (s == null)
|
|
1559
|
+
return;
|
|
1560
|
+
n.setSrcRect(s);
|
|
1561
|
+
const { left: c = 0, top: l = 0, bottom: m = 0, right: d = 0 } = s;
|
|
1562
|
+
n.transformByStateCloseCropper({
|
|
1563
|
+
left: e + c,
|
|
1564
|
+
top: r + l,
|
|
1565
|
+
width: o - d - c,
|
|
1566
|
+
height: a - m - l
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1569
|
+
_initOpenCrop() {
|
|
1570
|
+
this.disposeWithMe(
|
|
1571
|
+
this._commandService.onCommandExecuted((t) => {
|
|
1572
|
+
if (t.id !== Fe.id)
|
|
1573
|
+
return;
|
|
1574
|
+
const n = t.params;
|
|
1575
|
+
if (n == null)
|
|
1576
|
+
return;
|
|
1577
|
+
const { unitId: e, subUnitId: r, drawingId: o } = n, a = this._renderManagerService.getRenderById(e), s = a == null ? void 0 : a.scene;
|
|
1578
|
+
if (s == null)
|
|
1579
|
+
return !0;
|
|
1580
|
+
if (this._sceneListenerOnImageMap.has(s) || (this._addListenerOnImage(s), this._sceneListenerOnImageMap.add(s)), this._drawingManagerService.getDrawingByParam({ unitId: e, subUnitId: r, drawingId: o }) == null)
|
|
1581
|
+
return;
|
|
1582
|
+
const l = G({ unitId: e, subUnitId: r, drawingId: o }), m = s.getObject(l);
|
|
1583
|
+
if (m == null)
|
|
1584
|
+
return;
|
|
1585
|
+
if (!(m instanceof ze)) {
|
|
1586
|
+
this._messageService.show({
|
|
1587
|
+
type: Qe.Error,
|
|
1588
|
+
content: this._localeService.t("image-cropper.error")
|
|
1589
|
+
});
|
|
1590
|
+
return;
|
|
1591
|
+
}
|
|
1592
|
+
const d = s.getTransformer();
|
|
1593
|
+
d == null || d.clearControls();
|
|
1594
|
+
const h = new Me(`${l}-crop`, {
|
|
1595
|
+
srcRect: m.srcRect,
|
|
1596
|
+
prstGeom: m.prstGeom,
|
|
1597
|
+
applyTransform: m.calculateTransformWithSrcRect()
|
|
1598
|
+
});
|
|
1599
|
+
s.addObject(h, m.getLayerIndex() + 1).attachTransformerTo(h), d == null || d.createControlForCopper(h), this._addHoverForImageCopper(h), m.openRenderByCropper(), d == null || d.refreshControls(), h.makeDirty(!0), this._commandService.syncExecuteCommand(Ne.id, [{ unitId: e, subUnitId: r, drawingId: o }]);
|
|
1600
|
+
})
|
|
1601
|
+
);
|
|
1602
|
+
}
|
|
1603
|
+
_searchCropObject(t) {
|
|
1604
|
+
const n = t.getAllObjectsByOrder();
|
|
1605
|
+
for (const e of n)
|
|
1606
|
+
if (e instanceof Me)
|
|
1607
|
+
return e;
|
|
1608
|
+
}
|
|
1609
|
+
_initCloseCrop() {
|
|
1610
|
+
this.disposeWithMe(
|
|
1611
|
+
this._commandService.onCommandExecuted((n) => {
|
|
1612
|
+
if (n.id !== ge.id)
|
|
1613
|
+
return;
|
|
1614
|
+
const e = this._univerInstanceService.getFocusedUnit();
|
|
1615
|
+
if (e == null)
|
|
1616
|
+
return;
|
|
1617
|
+
const r = e.getUnitId(), o = this._renderManagerService.getRenderById(r), a = o == null ? void 0 : o.scene;
|
|
1618
|
+
if (a == null)
|
|
1619
|
+
return !0;
|
|
1620
|
+
const s = this._searchCropObject(a);
|
|
1621
|
+
if (s == null)
|
|
1622
|
+
return;
|
|
1623
|
+
const c = this._getApplyObjectByCropObject(s);
|
|
1624
|
+
if (c == null)
|
|
1625
|
+
return;
|
|
1626
|
+
const l = a.getTransformerByCreate();
|
|
1627
|
+
l.detachFrom(s), l.clearCopperControl();
|
|
1628
|
+
const m = this._getSrcRectByTransformState(c, s), d = this._drawingManagerService.getDrawingOKey(c.oKey);
|
|
1629
|
+
if (d != null) {
|
|
1630
|
+
const { left: h, top: f, height: v, width: w } = s;
|
|
1631
|
+
this._drawingManagerService.featurePluginUpdateNotification([{
|
|
1632
|
+
...d,
|
|
1633
|
+
transform: {
|
|
1634
|
+
...d.transform,
|
|
1635
|
+
left: h,
|
|
1636
|
+
top: f,
|
|
1637
|
+
height: v,
|
|
1638
|
+
width: w
|
|
1639
|
+
},
|
|
1640
|
+
srcRect: m.srcRectAngle
|
|
1641
|
+
}]);
|
|
1642
|
+
}
|
|
1643
|
+
c.setSrcRect({ ...m.srcRectAngle }), c.closeRenderByCropper(), c.makeDirty(!0), s == null || s.dispose();
|
|
1644
|
+
})
|
|
1645
|
+
);
|
|
1646
|
+
const t = this._univerInstanceService.getCurrentTypeOfUnit$(Oe.UNIVER_SHEET).pipe(
|
|
1647
|
+
Zn((n) => n ? n.activeSheet$ : Xn(null))
|
|
1648
|
+
);
|
|
1649
|
+
this.disposeWithMe(t.subscribe(() => {
|
|
1650
|
+
this._commandService.syncExecuteCommand(ge.id);
|
|
1651
|
+
}));
|
|
1652
|
+
}
|
|
1653
|
+
_getApplyObjectByCropObject(t) {
|
|
1654
|
+
const n = t.oKey, e = n.slice(0, n.length - 5), r = t.getScene();
|
|
1655
|
+
if (!r) return null;
|
|
1656
|
+
const o = r.getObject(e);
|
|
1657
|
+
return o == null ? null : o;
|
|
1658
|
+
}
|
|
1659
|
+
_addListenerOnImage(t) {
|
|
1660
|
+
const n = t.getTransformerByCreate();
|
|
1661
|
+
let e = null;
|
|
1662
|
+
this.disposeWithMe(
|
|
1663
|
+
n.changeStart$.subscribe((r) => {
|
|
1664
|
+
const { objects: o } = r, a = o.values().next().value;
|
|
1665
|
+
if (a == null || !(a instanceof Me))
|
|
1666
|
+
return;
|
|
1667
|
+
const { left: s, top: c, height: l, width: m, angle: d } = a;
|
|
1668
|
+
e = { left: s, top: c, height: l, width: m, angle: d }, n.clearCopperControl();
|
|
1669
|
+
})
|
|
1670
|
+
), this.disposeWithMe(
|
|
1671
|
+
n.changeEnd$.subscribe((r) => {
|
|
1672
|
+
const { objects: o } = r, a = o.values().next().value;
|
|
1673
|
+
if (a == null || !(a instanceof Me))
|
|
1674
|
+
return;
|
|
1675
|
+
const { left: s, top: c, height: l, width: m, angle: d } = a;
|
|
1676
|
+
if (!sn({ left: s, top: c, height: l, width: m, angle: d }, e))
|
|
1677
|
+
return;
|
|
1678
|
+
const h = this._getApplyObjectByCropObject(a);
|
|
1679
|
+
if (h == null)
|
|
1680
|
+
return;
|
|
1681
|
+
const f = this._getSrcRectByTransformState(h, a);
|
|
1682
|
+
a.refreshSrcRect(f.srcRect, h.getState()), n.createControlForCopper(a);
|
|
1683
|
+
})
|
|
1684
|
+
), this._endCropListener(t);
|
|
1685
|
+
}
|
|
1686
|
+
_addHoverForImageCopper(t) {
|
|
1687
|
+
this.disposeWithMe(
|
|
1688
|
+
t.onPointerEnter$.subscribeEvent(() => {
|
|
1689
|
+
t.cursor = Te.MOVE;
|
|
1690
|
+
})
|
|
1691
|
+
), this.disposeWithMe(
|
|
1692
|
+
t.onPointerLeave$.subscribeEvent(() => {
|
|
1693
|
+
t.cursor = Te.DEFAULT;
|
|
1694
|
+
})
|
|
1695
|
+
);
|
|
1696
|
+
}
|
|
1697
|
+
_endCropListener(t) {
|
|
1698
|
+
const n = t.getTransformerByCreate();
|
|
1699
|
+
this.disposeWithMe(
|
|
1700
|
+
n.clearControl$.subscribe((e) => {
|
|
1701
|
+
e === !0 && this._commandService.syncExecuteCommand(ge.id);
|
|
1702
|
+
})
|
|
1703
|
+
);
|
|
1704
|
+
}
|
|
1705
|
+
_getSrcRectByTransformState(t, n) {
|
|
1706
|
+
const { left: e, top: r, height: o, width: a, strokeWidth: s, angle: c } = n, { left: l, top: m, width: d, height: h, angle: f, strokeWidth: v } = t, w = e - l, p = r - m, S = {
|
|
1707
|
+
left: w,
|
|
1708
|
+
top: p,
|
|
1709
|
+
right: d - w - a,
|
|
1710
|
+
bottom: h - p - o
|
|
1711
|
+
}, _ = { ...S };
|
|
1712
|
+
if (f !== 0) {
|
|
1713
|
+
const M = e + a / 2, I = r + o / 2, N = new Ge(M, I), P = d / 2 + l, b = h / 2 + m, y = new Ge(P, b), R = new Ge(l, m);
|
|
1714
|
+
R.rotateByPoint(qe(f), y);
|
|
1715
|
+
const O = R.clone();
|
|
1716
|
+
O.rotateByPoint(qe(-f), N);
|
|
1717
|
+
const U = e - O.x, T = r - O.y;
|
|
1718
|
+
_.left = U, _.top = T, _.right = d - U - a, _.bottom = h - T - o;
|
|
1719
|
+
}
|
|
1720
|
+
return {
|
|
1721
|
+
srcRect: S,
|
|
1722
|
+
srcRectAngle: _
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
};
|
|
1726
|
+
Ae = xt([
|
|
1727
|
+
de(0, me),
|
|
1728
|
+
de(1, re),
|
|
1729
|
+
de(2, ue),
|
|
1730
|
+
de(3, Ke),
|
|
1731
|
+
de(4, zn),
|
|
1732
|
+
de(5, Le(te))
|
|
1733
|
+
], Ae);
|
|
1734
|
+
var Vt = Object.getOwnPropertyDescriptor, kt = (i, t, n, e) => {
|
|
1735
|
+
for (var r = e > 1 ? void 0 : e ? Vt(t, n) : t, o = i.length - 1, a; o >= 0; o--)
|
|
1736
|
+
(a = i[o]) && (r = a(r) || r);
|
|
1737
|
+
return r;
|
|
1738
|
+
}, ce = (i, t) => (n, e) => t(n, e, i);
|
|
1739
|
+
let He = class extends xe {
|
|
1740
|
+
constructor(i, t, n, e, r, o, a) {
|
|
1741
|
+
super(), this._commandService = i, this._renderManagerService = t, this._drawingManagerService = n, this._dialogService = e, this._imageIoService = r, this._currentUniverService = o, this._drawingRenderService = a, this._initialize();
|
|
1742
|
+
}
|
|
1743
|
+
dispose() {
|
|
1744
|
+
super.dispose();
|
|
1745
|
+
}
|
|
1746
|
+
_initialize() {
|
|
1747
|
+
this._drawingAddListener(), this._commandExecutedListener(), this._imageUpdateListener();
|
|
1748
|
+
}
|
|
1749
|
+
_commandExecutedListener() {
|
|
1750
|
+
this.disposeWithMe(
|
|
1751
|
+
this._commandService.onCommandExecuted((i) => {
|
|
1752
|
+
if (i.id === Pn.id) {
|
|
1753
|
+
const t = i.params;
|
|
1754
|
+
if (t == null)
|
|
1755
|
+
return;
|
|
1756
|
+
this._resetImageSize(t);
|
|
1757
|
+
}
|
|
1758
|
+
})
|
|
1759
|
+
);
|
|
1760
|
+
}
|
|
1761
|
+
_getSceneAndTransformerByDrawingSearch(i) {
|
|
1762
|
+
if (i == null)
|
|
1763
|
+
return;
|
|
1764
|
+
const t = this._renderManagerService.getRenderById(i), n = t == null ? void 0 : t.scene;
|
|
1765
|
+
if (n == null)
|
|
1766
|
+
return null;
|
|
1767
|
+
const e = n.getTransformerByCreate();
|
|
1768
|
+
return { scene: n, transformer: e };
|
|
1769
|
+
}
|
|
1770
|
+
_resetImageSize(i) {
|
|
1771
|
+
const t = [], n = [];
|
|
1772
|
+
i.forEach((e) => {
|
|
1773
|
+
const { unitId: r, subUnitId: o, drawingId: a } = e, s = this._getSceneAndTransformerByDrawingSearch(r);
|
|
1774
|
+
if (s == null)
|
|
1775
|
+
return;
|
|
1776
|
+
const { scene: c } = s, l = G({ unitId: r, subUnitId: o, drawingId: a }), m = c.getObject(l);
|
|
1777
|
+
if (m == null)
|
|
1778
|
+
return !0;
|
|
1779
|
+
const d = this._drawingManagerService.getDrawingByParam(e);
|
|
1780
|
+
if (d == null)
|
|
1781
|
+
return !0;
|
|
1782
|
+
if (d.drawingType !== ne.DRAWING_IMAGE)
|
|
1783
|
+
return;
|
|
1784
|
+
m.resetSize();
|
|
1785
|
+
const { width: h, height: f } = m.getNativeSize();
|
|
1786
|
+
n.includes(c) === !1 && n.push(c), t.push({
|
|
1787
|
+
...d,
|
|
1788
|
+
transform: {
|
|
1789
|
+
...d.transform,
|
|
1790
|
+
height: f,
|
|
1791
|
+
width: h,
|
|
1792
|
+
angle: 0
|
|
1793
|
+
},
|
|
1794
|
+
srcRect: null,
|
|
1795
|
+
prstGeom: null
|
|
1796
|
+
});
|
|
1797
|
+
}), this._drawingManagerService.featurePluginUpdateNotification(t), n.forEach((e) => {
|
|
1798
|
+
e.getTransformerByCreate().refreshControls().changeNotification();
|
|
1799
|
+
}), this._commandService.syncExecuteCommand(Ne.id, i);
|
|
1800
|
+
}
|
|
1801
|
+
_drawingAddListener() {
|
|
1802
|
+
this.disposeWithMe(
|
|
1803
|
+
this._drawingManagerService.add$.subscribe((i) => {
|
|
1804
|
+
this._insertImages(i);
|
|
1805
|
+
})
|
|
1806
|
+
);
|
|
1807
|
+
}
|
|
1808
|
+
_insertImages(i) {
|
|
1809
|
+
i.forEach(async (t) => {
|
|
1810
|
+
var c;
|
|
1811
|
+
const { unitId: n, subUnitId: e } = t, r = this._getSceneAndTransformerByDrawingSearch(n), o = (c = un(this._currentUniverService, n)) == null ? void 0 : c.subUnitId;
|
|
1812
|
+
if (r == null || o !== e)
|
|
1813
|
+
return;
|
|
1814
|
+
const a = this._drawingManagerService.getDrawingByParam(t);
|
|
1815
|
+
if (a == null)
|
|
1816
|
+
return;
|
|
1817
|
+
const s = await this._drawingRenderService.renderImages(a, r.scene);
|
|
1818
|
+
if (!(s == null || s.length === 0))
|
|
1819
|
+
for (const l of s)
|
|
1820
|
+
this._addHoverForImage(l), this._addDialogForImage(l);
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1823
|
+
_imageUpdateListener() {
|
|
1824
|
+
this.disposeWithMe(
|
|
1825
|
+
this._drawingManagerService.update$.subscribe((i) => {
|
|
1826
|
+
i.forEach((t) => {
|
|
1827
|
+
const { unitId: n, subUnitId: e, drawingId: r } = t, o = this._drawingManagerService.getDrawingByParam(t);
|
|
1828
|
+
if (o == null)
|
|
1829
|
+
return;
|
|
1830
|
+
const { transform: a, drawingType: s, srcRect: c, prstGeom: l, source: m, imageSourceType: d } = o;
|
|
1831
|
+
if (s !== ne.DRAWING_IMAGE)
|
|
1832
|
+
return;
|
|
1833
|
+
const h = this._getSceneAndTransformerByDrawingSearch(n);
|
|
1834
|
+
if (h == null)
|
|
1835
|
+
return;
|
|
1836
|
+
const { scene: f, transformer: v } = h;
|
|
1837
|
+
if (a == null)
|
|
1838
|
+
return !0;
|
|
1839
|
+
const w = G({ unitId: n, subUnitId: e, drawingId: r }), p = f.getObject(w);
|
|
1840
|
+
if (p == null)
|
|
1841
|
+
return !0;
|
|
1842
|
+
p.setSrcRect(c), p.setPrstGeom(l), m != null && m.length > 0 && (d === Xe.BASE64 || d === Xe.URL) && p.changeSource(m);
|
|
1843
|
+
});
|
|
1844
|
+
})
|
|
1845
|
+
);
|
|
1846
|
+
}
|
|
1847
|
+
_addHoverForImage(i) {
|
|
1848
|
+
this.disposeWithMe(
|
|
1849
|
+
Ce(
|
|
1850
|
+
i.onPointerEnter$.subscribeEvent(() => {
|
|
1851
|
+
i.cursor = Te.GRAB;
|
|
1852
|
+
})
|
|
1853
|
+
)
|
|
1854
|
+
), this.disposeWithMe(
|
|
1855
|
+
Ce(
|
|
1856
|
+
i.onPointerLeave$.subscribeEvent(() => {
|
|
1857
|
+
i.cursor = Te.DEFAULT;
|
|
1858
|
+
})
|
|
1859
|
+
)
|
|
1860
|
+
);
|
|
1861
|
+
}
|
|
1862
|
+
_addDialogForImage(i) {
|
|
1863
|
+
this.disposeWithMe(
|
|
1864
|
+
Ce(
|
|
1865
|
+
i.onDblclick$.subscribeEvent(() => {
|
|
1866
|
+
const t = `${i.oKey}-viewer-dialog`;
|
|
1867
|
+
this._drawingRenderService.previewImage(t, i.getNative().src, i.getNativeSize().width, i.getNativeSize().height);
|
|
1868
|
+
})
|
|
1869
|
+
)
|
|
1870
|
+
);
|
|
1871
|
+
}
|
|
1872
|
+
};
|
|
1873
|
+
He = kt([
|
|
1874
|
+
ce(0, me),
|
|
1875
|
+
ce(1, ue),
|
|
1876
|
+
ce(2, re),
|
|
1877
|
+
ce(3, gn),
|
|
1878
|
+
ce(4, cn),
|
|
1879
|
+
ce(5, Ke),
|
|
1880
|
+
ce(6, Le(Ee))
|
|
1881
|
+
], He);
|
|
1882
|
+
var Gt = Object.getOwnPropertyDescriptor, Wt = (i, t, n, e) => {
|
|
1883
|
+
for (var r = e > 1 ? void 0 : e ? Gt(t, n) : t, o = i.length - 1, a; o >= 0; o--)
|
|
1884
|
+
(a = i[o]) && (r = a(r) || r);
|
|
1885
|
+
return r;
|
|
1886
|
+
}, an = (i, t) => (n, e) => t(n, e, i);
|
|
1887
|
+
const $t = "UNIVER_DRAWING_UI_PLUGIN";
|
|
1888
|
+
var $e;
|
|
1889
|
+
let on = ($e = class extends Hn {
|
|
1890
|
+
constructor(i = tn, t, n) {
|
|
1891
|
+
super(), this._config = i, this._injector = t, this._configService = n;
|
|
1892
|
+
const { menu: e, ...r } = Ln(
|
|
1893
|
+
{},
|
|
1894
|
+
tn,
|
|
1895
|
+
this._config
|
|
1896
|
+
);
|
|
1897
|
+
e && this._configService.setConfig("menu", e, { merge: !0 }), this._configService.setConfig(Et, r);
|
|
1898
|
+
}
|
|
1899
|
+
onStarting() {
|
|
1900
|
+
this._initDependencies();
|
|
1901
|
+
}
|
|
1902
|
+
onRendered() {
|
|
1903
|
+
this._injector.get(Ue), this._injector.get(je), this._injector.get(Ae), this._injector.get(He);
|
|
1904
|
+
}
|
|
1905
|
+
_initDependencies() {
|
|
1906
|
+
[
|
|
1907
|
+
[Ee],
|
|
1908
|
+
[Ue],
|
|
1909
|
+
[je],
|
|
1910
|
+
[Ae],
|
|
1911
|
+
[He]
|
|
1912
|
+
].forEach((t) => this._injector.add(t));
|
|
1913
|
+
}
|
|
1914
|
+
}, ee($e, "pluginName", $t), $e);
|
|
1915
|
+
on = Wt([
|
|
1916
|
+
an(1, Le(Un)),
|
|
1917
|
+
an(2, An)
|
|
1918
|
+
], on);
|
|
1919
|
+
export {
|
|
1920
|
+
Be as AutoImageCropOperation,
|
|
1921
|
+
Tt as COMPONENT_IMAGE_POPUP_MENU,
|
|
1922
|
+
ge as CloseImageCropOperation,
|
|
1923
|
+
er as DrawingCommonPanel,
|
|
1924
|
+
Ee as DrawingRenderService,
|
|
1925
|
+
Me as ImageCropperObject,
|
|
1926
|
+
Dt as ImagePopupMenu,
|
|
1927
|
+
Pn as ImageResetSizeOperation,
|
|
1928
|
+
Fe as OpenImageCropOperation,
|
|
1929
|
+
Ye as SetDrawingAlignOperation,
|
|
1930
|
+
on as UniverDrawingUIPlugin,
|
|
1931
|
+
Ve as getUpdateParams
|
|
1932
|
+
};
|