@univerjs/drawing-ui 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +32 -1
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/index.js +32 -2332
- package/lib/es/locale/ca-ES.js +1 -65
- package/lib/es/locale/en-US.js +1 -65
- package/lib/es/locale/es-ES.js +1 -65
- package/lib/es/locale/fa-IR.js +1 -65
- package/lib/es/locale/fr-FR.js +1 -65
- package/lib/es/locale/ja-JP.js +1 -65
- package/lib/es/locale/ko-KR.js +1 -65
- package/lib/es/locale/ru-RU.js +1 -65
- package/lib/es/locale/sk-SK.js +1 -65
- package/lib/es/locale/vi-VN.js +1 -65
- package/lib/es/locale/zh-CN.js +1 -65
- package/lib/es/locale/zh-TW.js +1 -65
- package/lib/index.css +128 -1
- package/lib/index.js +32 -2332
- package/lib/locale/ca-ES.js +1 -65
- package/lib/locale/en-US.js +1 -65
- package/lib/locale/es-ES.js +1 -65
- package/lib/locale/fa-IR.js +1 -65
- package/lib/locale/fr-FR.js +1 -65
- package/lib/locale/ja-JP.js +1 -65
- package/lib/locale/ko-KR.js +1 -65
- package/lib/locale/ru-RU.js +1 -65
- package/lib/locale/sk-SK.js +1 -65
- package/lib/locale/vi-VN.js +1 -65
- package/lib/locale/zh-CN.js +1 -65
- package/lib/locale/zh-TW.js +1 -65
- package/lib/types/commands/operations/drawing-align.operation.d.ts +28 -1
- package/lib/types/commands/operations/drawing-arrange.operation.d.ts +29 -0
- package/lib/types/commands/operations/drawing-group.operation.d.ts +35 -0
- package/lib/types/commands/operations/image-crop.operation.d.ts +16 -1
- package/lib/types/commands/operations/image-reset-size.operation.d.ts +16 -1
- package/lib/types/config/config.d.ts +16 -1
- package/lib/types/controllers/drawing-ui.controller.d.ts +21 -4
- package/lib/types/controllers/drawing-update.controller.d.ts +15 -0
- package/lib/types/controllers/image-cropper.controller.d.ts +15 -0
- package/lib/types/controllers/image-update.controller.d.ts +15 -0
- package/lib/types/controllers/utils.d.ts +19 -4
- package/lib/types/index.d.ts +2 -0
- package/lib/types/locale/ca-ES.d.ts +16 -1
- package/lib/types/locale/es-ES.d.ts +16 -1
- package/lib/types/locale/fa-IR.d.ts +16 -1
- package/lib/types/locale/fr-FR.d.ts +16 -1
- package/lib/types/locale/ja-JP.d.ts +16 -1
- package/lib/types/locale/ko-KR.d.ts +16 -1
- package/lib/types/locale/ru-RU.d.ts +16 -1
- package/lib/types/locale/sk-SK.d.ts +16 -1
- package/lib/types/locale/vi-VN.d.ts +16 -1
- package/lib/types/locale/zh-CN.d.ts +16 -1
- package/lib/types/locale/zh-TW.d.ts +16 -1
- package/lib/types/menu/align.menu.d.ts +27 -0
- package/lib/types/menu/arrange.menu.d.ts +22 -0
- package/lib/types/menu/group.menu.d.ts +21 -0
- package/lib/types/menu/schema.d.ts +17 -0
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/services/drawing-render.service.d.ts +21 -3
- package/lib/types/utils/get-update-params.d.ts +18 -3
- package/lib/types/views/crop/image-cropper-object.d.ts +18 -2
- package/lib/types/views/image-popup-menu/ImagePopupMenu.d.ts +16 -1
- package/lib/types/views/panel/DrawingAlign.d.ts +16 -1
- package/lib/types/views/panel/DrawingArrange.d.ts +16 -1
- package/lib/types/views/panel/DrawingCommonPanel.d.ts +16 -1
- package/lib/types/views/panel/DrawingGroup.d.ts +16 -1
- package/lib/types/views/panel/DrawingTransform.d.ts +16 -1
- package/lib/types/views/panel/ImageCropper.d.ts +16 -1
- package/lib/umd/index.js +32 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +11 -10
package/lib/es/index.js
CHANGED
|
@@ -1,2332 +1,32 @@
|
|
|
1
|
-
var Pt = Object.defineProperty;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { jsx as v, jsxs as N, Fragment as zt } from "react/jsx-runtime";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
type: _e.OPERATION,
|
|
34
|
-
handler: (i, r) => !0
|
|
35
|
-
};
|
|
36
|
-
function rt(i, r, e, t) {
|
|
37
|
-
const n = t.getDrawingByParam(i);
|
|
38
|
-
if (n == null)
|
|
39
|
-
return;
|
|
40
|
-
const s = L(i), a = e.getObject(s);
|
|
41
|
-
if (a && !(a instanceof We))
|
|
42
|
-
return;
|
|
43
|
-
if (a != null) {
|
|
44
|
-
const l = a.getObjects();
|
|
45
|
-
for (const g of l)
|
|
46
|
-
if (g.oKey === r.oKey)
|
|
47
|
-
return;
|
|
48
|
-
a.addObject(r);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const o = new gt(s);
|
|
52
|
-
e.addObject(o, Ne).attachTransformerTo(o), o.addObject(r);
|
|
53
|
-
const { transform: c, groupBaseBound: u } = n;
|
|
54
|
-
u && o.setBaseBound(u), c && o.transformByState(
|
|
55
|
-
{
|
|
56
|
-
left: c.left,
|
|
57
|
-
top: c.top,
|
|
58
|
-
angle: c.angle,
|
|
59
|
-
width: c.width,
|
|
60
|
-
height: c.height
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
function mt(i, r) {
|
|
65
|
-
var s;
|
|
66
|
-
const e = r ? i.getUnit(r) : i.getFocusedUnit();
|
|
67
|
-
if (e == null)
|
|
68
|
-
return;
|
|
69
|
-
const t = e.getUnitId();
|
|
70
|
-
let n;
|
|
71
|
-
return e.type === ue.UNIVER_SHEET ? n = (s = e.getActiveSheet()) == null ? void 0 : s.getSheetId() : (e.type === ue.UNIVER_DOC || e.type === ue.UNIVER_SLIDE) && (n = t), { unitId: t, subUnitId: n, current: e };
|
|
72
|
-
}
|
|
73
|
-
const tr = "@univerjs/drawing-ui", rr = "0.17.0", nt = {
|
|
74
|
-
name: tr,
|
|
75
|
-
version: rr
|
|
76
|
-
}, nr = "drawing-ui.config", it = {}, ir = "COMPONENT_IMAGE_POPUP_MENU";
|
|
77
|
-
function Y({ ref: i, ...r }) {
|
|
78
|
-
const { icon: e, id: t, className: n, extend: s, ...a } = r, o = `univerjs-icon univerjs-icon-${t} ${n || ""}`.trim(), c = ft(`_${or()}`);
|
|
79
|
-
return wt(e, `${t}`, {
|
|
80
|
-
defIds: e.defIds,
|
|
81
|
-
idSuffix: c.current
|
|
82
|
-
}, {
|
|
83
|
-
ref: i,
|
|
84
|
-
className: o,
|
|
85
|
-
...a
|
|
86
|
-
}, s);
|
|
87
|
-
}
|
|
88
|
-
function wt(i, r, e, t, n) {
|
|
89
|
-
return z(i.tag, {
|
|
90
|
-
key: r,
|
|
91
|
-
...ar(i, e, n),
|
|
92
|
-
...t
|
|
93
|
-
}, (sr(i, e).children || []).map((s, a) => wt(s, `${r}-${i.tag}-${a}`, e, void 0, n)));
|
|
94
|
-
}
|
|
95
|
-
function ar(i, r, e) {
|
|
96
|
-
const t = { ...i.attrs };
|
|
97
|
-
e != null && e.colorChannel1 && t.fill === "colorChannel1" && (t.fill = e.colorChannel1), i.tag === "mask" && t.id && (t.id = t.id + r.idSuffix), Object.entries(t).forEach(([s, a]) => {
|
|
98
|
-
s === "mask" && typeof a == "string" && (t[s] = a.replace(/url\(#(.*)\)/, `url(#$1${r.idSuffix})`));
|
|
99
|
-
});
|
|
100
|
-
const { defIds: n } = r;
|
|
101
|
-
return !n || n.length === 0 || (i.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + r.idSuffix), Object.entries(t).forEach(([s, a]) => {
|
|
102
|
-
typeof a == "string" && (t[s] = a.replace(/url\(#(.*)\)/, `url(#$1${r.idSuffix})`));
|
|
103
|
-
})), t;
|
|
104
|
-
}
|
|
105
|
-
function sr(i, r) {
|
|
106
|
-
var t;
|
|
107
|
-
const { defIds: e } = r;
|
|
108
|
-
return !e || e.length === 0 ? i : i.tag === "defs" && ((t = i.children) != null && t.length) ? {
|
|
109
|
-
...i,
|
|
110
|
-
children: i.children.map((n) => typeof n.attrs.id == "string" && e && e.includes(n.attrs.id) ? {
|
|
111
|
-
...n,
|
|
112
|
-
attrs: {
|
|
113
|
-
...n.attrs,
|
|
114
|
-
id: n.attrs.id + r.idSuffix
|
|
115
|
-
}
|
|
116
|
-
} : n)
|
|
117
|
-
} : i;
|
|
118
|
-
}
|
|
119
|
-
function or() {
|
|
120
|
-
return Math.random().toString(36).substring(2, 8);
|
|
121
|
-
}
|
|
122
|
-
Y.displayName = "UniverIcon";
|
|
123
|
-
const cr = {
|
|
124
|
-
tag: "svg",
|
|
125
|
-
attrs: {
|
|
126
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
127
|
-
fill: "none",
|
|
128
|
-
viewBox: "0 0 17 16",
|
|
129
|
-
width: "1em",
|
|
130
|
-
height: "1em"
|
|
131
|
-
},
|
|
132
|
-
children: [
|
|
133
|
-
{
|
|
134
|
-
tag: "path",
|
|
135
|
-
attrs: {
|
|
136
|
-
fill: "currentColor",
|
|
137
|
-
d: "M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334C15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334C2.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.8334C3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334Z",
|
|
138
|
-
fillRule: "evenodd",
|
|
139
|
-
clipRule: "evenodd"
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
tag: "path",
|
|
144
|
-
attrs: {
|
|
145
|
-
fill: "currentColor",
|
|
146
|
-
d: "M14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999C15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999C2.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.9999C3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999Z",
|
|
147
|
-
fillRule: "evenodd",
|
|
148
|
-
clipRule: "evenodd"
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
tag: "path",
|
|
153
|
-
attrs: {
|
|
154
|
-
fill: "currentColor",
|
|
155
|
-
d: "M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421C6.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.56641C9.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.7421C11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902"
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
tag: "path",
|
|
160
|
-
attrs: {
|
|
161
|
-
fill: "currentColor",
|
|
162
|
-
d: "M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946C8.64077 14.6502 8.70566 14.6923 8.77482 14.7209C8.84557 14.7502 8.92314 14.7664 9.00449 14.7664C9.08585 14.7664 9.16342 14.7502 9.23416 14.7209C9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
}, vt = ee(function(r, e) {
|
|
167
|
-
return z(Y, Object.assign({}, r, {
|
|
168
|
-
id: "bottom-icon",
|
|
169
|
-
ref: e,
|
|
170
|
-
icon: cr
|
|
171
|
-
}));
|
|
172
|
-
});
|
|
173
|
-
vt.displayName = "BottomIcon";
|
|
174
|
-
const lr = {
|
|
175
|
-
tag: "svg",
|
|
176
|
-
attrs: {
|
|
177
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
178
|
-
fill: "none",
|
|
179
|
-
viewBox: "0 0 16 16",
|
|
180
|
-
width: "1em",
|
|
181
|
-
height: "1em"
|
|
182
|
-
},
|
|
183
|
-
children: [
|
|
184
|
-
{
|
|
185
|
-
tag: "path",
|
|
186
|
-
attrs: {
|
|
187
|
-
fill: "currentColor",
|
|
188
|
-
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.51296C9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296Z"
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
tag: "path",
|
|
193
|
-
attrs: {
|
|
194
|
-
fill: "currentColor",
|
|
195
|
-
d: "M6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103C5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103C11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705Z"
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
tag: "path",
|
|
200
|
-
attrs: {
|
|
201
|
-
fill: "currentColor",
|
|
202
|
-
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",
|
|
203
|
-
fillRule: "evenodd",
|
|
204
|
-
clipRule: "evenodd"
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
tag: "path",
|
|
209
|
-
attrs: {
|
|
210
|
-
fill: "currentColor",
|
|
211
|
-
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"
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
]
|
|
215
|
-
}, _t = ee(function(r, e) {
|
|
216
|
-
return z(Y, Object.assign({}, r, {
|
|
217
|
-
id: "create-copy-icon",
|
|
218
|
-
ref: e,
|
|
219
|
-
icon: lr
|
|
220
|
-
}));
|
|
221
|
-
});
|
|
222
|
-
_t.displayName = "CreateCopyIcon";
|
|
223
|
-
const ur = {
|
|
224
|
-
tag: "svg",
|
|
225
|
-
attrs: {
|
|
226
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
227
|
-
fill: "none",
|
|
228
|
-
viewBox: "0 0 17 16",
|
|
229
|
-
width: "1em",
|
|
230
|
-
height: "1em"
|
|
231
|
-
},
|
|
232
|
-
children: [{
|
|
233
|
-
tag: "path",
|
|
234
|
-
attrs: {
|
|
235
|
-
fill: "currentColor",
|
|
236
|
-
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",
|
|
237
|
-
fillRule: "evenodd",
|
|
238
|
-
clipRule: "evenodd"
|
|
239
|
-
}
|
|
240
|
-
}]
|
|
241
|
-
}, Ct = ee(function(r, e) {
|
|
242
|
-
return z(Y, Object.assign({}, r, {
|
|
243
|
-
id: "group-icon",
|
|
244
|
-
ref: e,
|
|
245
|
-
icon: ur
|
|
246
|
-
}));
|
|
247
|
-
});
|
|
248
|
-
Ct.displayName = "GroupIcon";
|
|
249
|
-
const gr = {
|
|
250
|
-
tag: "svg",
|
|
251
|
-
attrs: {
|
|
252
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
253
|
-
fill: "none",
|
|
254
|
-
viewBox: "0 0 16 16",
|
|
255
|
-
width: "1em",
|
|
256
|
-
height: "1em"
|
|
257
|
-
},
|
|
258
|
-
children: [{
|
|
259
|
-
tag: "path",
|
|
260
|
-
attrs: {
|
|
261
|
-
fill: "currentColor",
|
|
262
|
-
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",
|
|
263
|
-
fillRule: "evenodd",
|
|
264
|
-
clipRule: "evenodd"
|
|
265
|
-
}
|
|
266
|
-
}]
|
|
267
|
-
}, St = ee(function(r, e) {
|
|
268
|
-
return z(Y, Object.assign({}, r, {
|
|
269
|
-
id: "more-down-icon",
|
|
270
|
-
ref: e,
|
|
271
|
-
icon: gr
|
|
272
|
-
}));
|
|
273
|
-
});
|
|
274
|
-
St.displayName = "MoreDownIcon";
|
|
275
|
-
const dr = {
|
|
276
|
-
tag: "svg",
|
|
277
|
-
attrs: {
|
|
278
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
279
|
-
fill: "none",
|
|
280
|
-
viewBox: "0 0 16 16",
|
|
281
|
-
width: "1em",
|
|
282
|
-
height: "1em"
|
|
283
|
-
},
|
|
284
|
-
children: [{
|
|
285
|
-
tag: "path",
|
|
286
|
-
attrs: {
|
|
287
|
-
fill: "currentColor",
|
|
288
|
-
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",
|
|
289
|
-
fillRule: "evenodd",
|
|
290
|
-
clipRule: "evenodd"
|
|
291
|
-
}
|
|
292
|
-
}, {
|
|
293
|
-
tag: "path",
|
|
294
|
-
attrs: {
|
|
295
|
-
fill: "currentColor",
|
|
296
|
-
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"
|
|
297
|
-
}
|
|
298
|
-
}]
|
|
299
|
-
}, It = ee(function(r, e) {
|
|
300
|
-
return z(Y, Object.assign({}, r, {
|
|
301
|
-
id: "move-down-icon",
|
|
302
|
-
ref: e,
|
|
303
|
-
icon: dr
|
|
304
|
-
}));
|
|
305
|
-
});
|
|
306
|
-
It.displayName = "MoveDownIcon";
|
|
307
|
-
const hr = {
|
|
308
|
-
tag: "svg",
|
|
309
|
-
attrs: {
|
|
310
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
311
|
-
fill: "none",
|
|
312
|
-
viewBox: "0 0 16 16",
|
|
313
|
-
width: "1em",
|
|
314
|
-
height: "1em"
|
|
315
|
-
},
|
|
316
|
-
children: [{
|
|
317
|
-
tag: "path",
|
|
318
|
-
attrs: {
|
|
319
|
-
fill: "currentColor",
|
|
320
|
-
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",
|
|
321
|
-
fillRule: "evenodd",
|
|
322
|
-
clipRule: "evenodd"
|
|
323
|
-
}
|
|
324
|
-
}, {
|
|
325
|
-
tag: "path",
|
|
326
|
-
attrs: {
|
|
327
|
-
fill: "currentColor",
|
|
328
|
-
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"
|
|
329
|
-
}
|
|
330
|
-
}]
|
|
331
|
-
}, bt = ee(function(r, e) {
|
|
332
|
-
return z(Y, Object.assign({}, r, {
|
|
333
|
-
id: "move-up-icon",
|
|
334
|
-
ref: e,
|
|
335
|
-
icon: hr
|
|
336
|
-
}));
|
|
337
|
-
});
|
|
338
|
-
bt.displayName = "MoveUpIcon";
|
|
339
|
-
const fr = {
|
|
340
|
-
tag: "svg",
|
|
341
|
-
attrs: {
|
|
342
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
343
|
-
fill: "none",
|
|
344
|
-
viewBox: "0 0 17 16",
|
|
345
|
-
width: "1em",
|
|
346
|
-
height: "1em"
|
|
347
|
-
},
|
|
348
|
-
children: [
|
|
349
|
-
{
|
|
350
|
-
tag: "path",
|
|
351
|
-
attrs: {
|
|
352
|
-
fill: "currentColor",
|
|
353
|
-
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"
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
tag: "path",
|
|
358
|
-
attrs: {
|
|
359
|
-
fill: "currentColor",
|
|
360
|
-
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 9C15.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 9C2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9C13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439Z",
|
|
361
|
-
fillRule: "evenodd",
|
|
362
|
-
clipRule: "evenodd"
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
tag: "path",
|
|
367
|
-
attrs: {
|
|
368
|
-
fill: "currentColor",
|
|
369
|
-
d: "M1.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.1665C15.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.1665C2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665C13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543Z",
|
|
370
|
-
fillRule: "evenodd",
|
|
371
|
-
clipRule: "evenodd"
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
]
|
|
375
|
-
}, yt = ee(function(r, e) {
|
|
376
|
-
return z(Y, Object.assign({}, r, {
|
|
377
|
-
id: "topmost-icon",
|
|
378
|
-
ref: e,
|
|
379
|
-
icon: fr
|
|
380
|
-
}));
|
|
381
|
-
});
|
|
382
|
-
yt.displayName = "TopmostIcon";
|
|
383
|
-
const pr = {
|
|
384
|
-
tag: "svg",
|
|
385
|
-
attrs: {
|
|
386
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
387
|
-
fill: "none",
|
|
388
|
-
viewBox: "0 0 17 16",
|
|
389
|
-
width: "1em",
|
|
390
|
-
height: "1em"
|
|
391
|
-
},
|
|
392
|
-
children: [{
|
|
393
|
-
tag: "path",
|
|
394
|
-
attrs: {
|
|
395
|
-
fill: "currentColor",
|
|
396
|
-
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"
|
|
397
|
-
}
|
|
398
|
-
}, {
|
|
399
|
-
tag: "path",
|
|
400
|
-
attrs: {
|
|
401
|
-
fill: "currentColor",
|
|
402
|
-
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",
|
|
403
|
-
fillRule: "evenodd",
|
|
404
|
-
clipRule: "evenodd"
|
|
405
|
-
}
|
|
406
|
-
}]
|
|
407
|
-
}, Rt = ee(function(r, e) {
|
|
408
|
-
return z(Y, Object.assign({}, r, {
|
|
409
|
-
id: "ungroup-icon",
|
|
410
|
-
ref: e,
|
|
411
|
-
icon: pr
|
|
412
|
-
}));
|
|
413
|
-
});
|
|
414
|
-
Rt.displayName = "UngroupIcon";
|
|
415
|
-
const mr = {
|
|
416
|
-
tag: "svg",
|
|
417
|
-
attrs: {
|
|
418
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
419
|
-
fill: "none",
|
|
420
|
-
viewBox: "0 0 16 16",
|
|
421
|
-
width: "1em",
|
|
422
|
-
height: "1em"
|
|
423
|
-
},
|
|
424
|
-
children: [
|
|
425
|
-
{
|
|
426
|
-
tag: "path",
|
|
427
|
-
attrs: {
|
|
428
|
-
fill: "colorChannel1",
|
|
429
|
-
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"
|
|
430
|
-
}
|
|
431
|
-
},
|
|
432
|
-
{
|
|
433
|
-
tag: "path",
|
|
434
|
-
attrs: {
|
|
435
|
-
fill: "currentColor",
|
|
436
|
-
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.56377Z",
|
|
437
|
-
fillRule: "evenodd",
|
|
438
|
-
clipRule: "evenodd"
|
|
439
|
-
}
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
tag: "path",
|
|
443
|
-
attrs: {
|
|
444
|
-
fill: "currentColor",
|
|
445
|
-
d: "M2.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.83647Z",
|
|
446
|
-
fillRule: "evenodd",
|
|
447
|
-
clipRule: "evenodd"
|
|
448
|
-
}
|
|
449
|
-
},
|
|
450
|
-
{
|
|
451
|
-
tag: "path",
|
|
452
|
-
attrs: {
|
|
453
|
-
fill: "currentColor",
|
|
454
|
-
d: "M9.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",
|
|
455
|
-
fillRule: "evenodd",
|
|
456
|
-
clipRule: "evenodd"
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
]
|
|
460
|
-
}, Mt = ee(function(r, e) {
|
|
461
|
-
return z(Y, Object.assign({}, r, {
|
|
462
|
-
id: "autofill-double-icon",
|
|
463
|
-
ref: e,
|
|
464
|
-
icon: mr
|
|
465
|
-
}));
|
|
466
|
-
});
|
|
467
|
-
Mt.displayName = "AutofillDoubleIcon";
|
|
468
|
-
function wr(i) {
|
|
469
|
-
var h;
|
|
470
|
-
const { popup: r } = i, e = (h = r == null ? void 0 : r.extraProps) == null ? void 0 : h.menuItems;
|
|
471
|
-
if (!e) return null;
|
|
472
|
-
const t = A(ce), n = A(re), [s, a] = j(!1), [o, c] = j(!1), u = () => {
|
|
473
|
-
c(!0);
|
|
474
|
-
}, l = () => {
|
|
475
|
-
c(!1);
|
|
476
|
-
}, g = (p) => {
|
|
477
|
-
a(p);
|
|
478
|
-
}, d = (p) => {
|
|
479
|
-
t.executeCommand(p.commandId, p.commandParams), a(!1);
|
|
480
|
-
}, f = s || o, w = e.filter((p) => !p.disable);
|
|
481
|
-
return /* @__PURE__ */ v(
|
|
482
|
-
"div",
|
|
483
|
-
{
|
|
484
|
-
onMouseEnter: u,
|
|
485
|
-
onMouseLeave: l,
|
|
486
|
-
children: /* @__PURE__ */ v(
|
|
487
|
-
Yt,
|
|
488
|
-
{
|
|
489
|
-
align: "start",
|
|
490
|
-
items: w.map((p) => ({
|
|
491
|
-
type: "item",
|
|
492
|
-
children: n.t(p.label),
|
|
493
|
-
onSelect: () => d(p)
|
|
494
|
-
})),
|
|
495
|
-
open: s,
|
|
496
|
-
onOpenChange: g,
|
|
497
|
-
children: /* @__PURE__ */ N(
|
|
498
|
-
"div",
|
|
499
|
-
{
|
|
500
|
-
className: Q("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", Xt, {
|
|
501
|
-
"univer-bg-gray-100 dark:!univer-bg-gray-800": s,
|
|
502
|
-
"univer-bg-white dark:!univer-bg-gray-900": !s
|
|
503
|
-
}),
|
|
504
|
-
children: [
|
|
505
|
-
/* @__PURE__ */ v(
|
|
506
|
-
Mt,
|
|
507
|
-
{
|
|
508
|
-
className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"
|
|
509
|
-
}
|
|
510
|
-
),
|
|
511
|
-
f && /* @__PURE__ */ v(St, { className: "dark:!univer-text-white" })
|
|
512
|
-
]
|
|
513
|
-
}
|
|
514
|
-
)
|
|
515
|
-
}
|
|
516
|
-
)
|
|
517
|
-
}
|
|
518
|
-
);
|
|
519
|
-
}
|
|
520
|
-
var vr = Object.getOwnPropertyDescriptor, _r = (i, r, e, t) => {
|
|
521
|
-
for (var n = t > 1 ? void 0 : t ? vr(r, e) : r, s = i.length - 1, a; s >= 0; s--)
|
|
522
|
-
(a = i[s]) && (n = a(n) || n);
|
|
523
|
-
return n;
|
|
524
|
-
}, at = (i, r) => (e, t) => r(e, t, i);
|
|
525
|
-
let Ue = class extends ke {
|
|
526
|
-
constructor(i, r) {
|
|
527
|
-
super(), this._componentManager = i, this._commandService = r, this._init();
|
|
528
|
-
}
|
|
529
|
-
_initCustomComponents() {
|
|
530
|
-
const i = this._componentManager;
|
|
531
|
-
this.disposeWithMe(i.register(ir, wr));
|
|
532
|
-
}
|
|
533
|
-
_initCommands() {
|
|
534
|
-
[
|
|
535
|
-
Fe,
|
|
536
|
-
oe,
|
|
537
|
-
pt,
|
|
538
|
-
Ke,
|
|
539
|
-
Be
|
|
540
|
-
].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i)));
|
|
541
|
-
}
|
|
542
|
-
_init() {
|
|
543
|
-
this._initCommands(), this._initCustomComponents();
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
Ue = _r([
|
|
547
|
-
at(0, Le(Wt)),
|
|
548
|
-
at(1, ce)
|
|
549
|
-
], Ue);
|
|
550
|
-
function Ve(i, r) {
|
|
551
|
-
const e = [];
|
|
552
|
-
return i.forEach((t) => {
|
|
553
|
-
const { oKey: n, left: s, top: a, height: o, width: c, angle: u } = t, l = r.getDrawingOKey(n);
|
|
554
|
-
if (l == null)
|
|
555
|
-
return e.push(null), !0;
|
|
556
|
-
const { unitId: g, subUnitId: d, drawingId: f, drawingType: w } = l, h = {
|
|
557
|
-
unitId: g,
|
|
558
|
-
subUnitId: d,
|
|
559
|
-
drawingId: f,
|
|
560
|
-
drawingType: w,
|
|
561
|
-
transform: {
|
|
562
|
-
left: s,
|
|
563
|
-
top: a,
|
|
564
|
-
height: o,
|
|
565
|
-
width: c,
|
|
566
|
-
angle: u
|
|
567
|
-
}
|
|
568
|
-
};
|
|
569
|
-
w === q.DRAWING_IMAGE && (h.srcRect = t.srcRect), e.push(h);
|
|
570
|
-
}), e;
|
|
571
|
-
}
|
|
572
|
-
var Cr = Object.getOwnPropertyDescriptor, Sr = (i, r, e, t) => {
|
|
573
|
-
for (var n = t > 1 ? void 0 : t ? Cr(r, e) : r, s = i.length - 1, a; s >= 0; s--)
|
|
574
|
-
(a = i[s]) && (n = a(n) || n);
|
|
575
|
-
return n;
|
|
576
|
-
}, Re = (i, r) => (e, t) => r(e, t, i);
|
|
577
|
-
let xe = class extends ke {
|
|
578
|
-
constructor(r, e, t, n) {
|
|
579
|
-
super();
|
|
580
|
-
Z(this, "_sceneListenerOnDrawingMap", /* @__PURE__ */ new WeakSet());
|
|
581
|
-
this._currentUniverService = r, this._commandService = e, this._renderManagerService = t, this._drawingManagerService = n, this._initialize();
|
|
582
|
-
}
|
|
583
|
-
dispose() {
|
|
584
|
-
super.dispose();
|
|
585
|
-
}
|
|
586
|
-
_initialize() {
|
|
587
|
-
this._recoveryImages(), this._drawingAddListener(), this._drawingRemoveListener(), this._drawingUpdateListener(), this._commandExecutedListener(), this._drawingArrangeListener(), this._drawingGroupListener(), this._drawingRefreshListener(), this._drawingVisibleListener();
|
|
588
|
-
}
|
|
589
|
-
_recoveryImages() {
|
|
590
|
-
const r = this._drawingManagerService.drawingManagerData, e = mt(this._currentUniverService);
|
|
591
|
-
if (e == null)
|
|
592
|
-
return;
|
|
593
|
-
const { unitId: t, subUnitId: n } = e;
|
|
594
|
-
Object.keys(r).forEach((s) => {
|
|
595
|
-
Object.keys(r[s]).forEach((a) => {
|
|
596
|
-
const o = r[s][a].data;
|
|
597
|
-
o == null || s !== t || a !== n || Object.keys(o).forEach((c) => {
|
|
598
|
-
o[c] && this._insertDrawing([{ unitId: s, subUnitId: a, drawingId: c }]);
|
|
599
|
-
});
|
|
600
|
-
});
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
_commandExecutedListener() {
|
|
604
|
-
this.disposeWithMe(
|
|
605
|
-
this._commandService.onCommandExecuted((r) => {
|
|
606
|
-
if (r.id === Ke.id) {
|
|
607
|
-
const e = r.params;
|
|
608
|
-
if (e == null)
|
|
609
|
-
return;
|
|
610
|
-
this._drawingAlign(e);
|
|
611
|
-
}
|
|
612
|
-
})
|
|
613
|
-
);
|
|
614
|
-
}
|
|
615
|
-
_drawingGroupListener() {
|
|
616
|
-
this.disposeWithMe(
|
|
617
|
-
this._drawingManagerService.group$.subscribe((r) => {
|
|
618
|
-
this._groupDrawings(r);
|
|
619
|
-
})
|
|
620
|
-
), this.disposeWithMe(
|
|
621
|
-
this._drawingManagerService.ungroup$.subscribe((r) => {
|
|
622
|
-
this._ungroupDrawings(r);
|
|
623
|
-
})
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
// private _drawingGroup(params: ISetImageGroupOperationParams) {
|
|
627
|
-
// const { groupType } = params;
|
|
628
|
-
// const drawings = this._drawingManagerService.getFocusDrawings();
|
|
629
|
-
// if (drawings.length === 0) {
|
|
630
|
-
// return;
|
|
631
|
-
// }
|
|
632
|
-
// switch (groupType) {
|
|
633
|
-
// case GroupType.group:
|
|
634
|
-
// this._groupDrawings(drawings);
|
|
635
|
-
// break;
|
|
636
|
-
// case GroupType.regroup:
|
|
637
|
-
// this._regroupDrawings(drawings);
|
|
638
|
-
// break;
|
|
639
|
-
// case GroupType.ungroup:
|
|
640
|
-
// this._ungroupDrawings(drawings);
|
|
641
|
-
// break;
|
|
642
|
-
// default:
|
|
643
|
-
// break;
|
|
644
|
-
// }
|
|
645
|
-
// }
|
|
646
|
-
_getSceneAndTransformerByDrawingSearch(r) {
|
|
647
|
-
if (r == null)
|
|
648
|
-
return;
|
|
649
|
-
const e = this._renderManagerService.getRenderById(r), t = e == null ? void 0 : e.scene;
|
|
650
|
-
if (t == null)
|
|
651
|
-
return null;
|
|
652
|
-
const n = t.getTransformerByCreate();
|
|
653
|
-
return { scene: t, transformer: n };
|
|
654
|
-
}
|
|
655
|
-
_groupDrawings(r) {
|
|
656
|
-
r.forEach((e) => {
|
|
657
|
-
this._groupDrawing(e);
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
_groupDrawing(r) {
|
|
661
|
-
const { parent: e, children: t } = r, { unitId: n, subUnitId: s, drawingId: a } = e, o = this._getSceneAndTransformerByDrawingSearch(e.unitId);
|
|
662
|
-
if (o == null)
|
|
663
|
-
return;
|
|
664
|
-
const { scene: c, transformer: u } = o;
|
|
665
|
-
this._commandService.syncExecuteCommand(oe.id);
|
|
666
|
-
const l = [];
|
|
667
|
-
if (t.forEach((f) => {
|
|
668
|
-
const w = L(f), h = c.getObjectIncludeInGroup(w);
|
|
669
|
-
if (h == null || l.includes(h))
|
|
670
|
-
return;
|
|
671
|
-
l.push(h);
|
|
672
|
-
const { transform: p } = f;
|
|
673
|
-
p != null && (h.classType === Je.GROUP ? h.transformByState({ left: p.left, top: p.top }) : h.transformByState(p));
|
|
674
|
-
}), l.length === 0)
|
|
675
|
-
return;
|
|
676
|
-
const g = L({ unitId: n, subUnitId: s, drawingId: a }), d = new gt(g);
|
|
677
|
-
c.addObject(d, Ne).attachTransformerTo(d), d.addObjects(...l), e.groupBaseBound && d.setBaseBound(e.groupBaseBound), e.transform && d.transformByState({ left: e.transform.left, top: e.transform.top, width: e.transform.width, height: e.transform.height, angle: e.transform.angle }), u.clearSelectedObjects(), u.setSelectedControl(d);
|
|
678
|
-
}
|
|
679
|
-
// private _regroupDrawings(drawings: IDrawingSearch[]) {
|
|
680
|
-
// const renderObject = this._getSceneAndTransformerByDrawingSearch(drawings[0].unitId);
|
|
681
|
-
// if (renderObject == null) {
|
|
682
|
-
// return;
|
|
683
|
-
// }
|
|
684
|
-
// const { scene, transformer } = renderObject;
|
|
685
|
-
// const objects: BaseObject[] = [];
|
|
686
|
-
// let firstGroup: Nullable<Group> = null;
|
|
687
|
-
// drawings.forEach((drawing) => {
|
|
688
|
-
// const imageShapeKey = getDrawingShapeKeyByDrawingSearch(drawing);
|
|
689
|
-
// const o = scene.getObject(imageShapeKey);
|
|
690
|
-
// if (o == null) {
|
|
691
|
-
// return true;
|
|
692
|
-
// }
|
|
693
|
-
// const group = o.ancestorGroup as Nullable<Group>;
|
|
694
|
-
// if (group != null && firstGroup == null) {
|
|
695
|
-
// firstGroup = group;
|
|
696
|
-
// } else if (group != null && !objects.includes(group)) {
|
|
697
|
-
// objects.push(group);
|
|
698
|
-
// } else if (!objects.includes(o)) {
|
|
699
|
-
// objects.push(o);
|
|
700
|
-
// }
|
|
701
|
-
// });
|
|
702
|
-
// if (firstGroup == null) {
|
|
703
|
-
// return;
|
|
704
|
-
// }
|
|
705
|
-
// if (objects.length === 0) {
|
|
706
|
-
// return;
|
|
707
|
-
// }
|
|
708
|
-
// (firstGroup as Group).addObjects(...objects);
|
|
709
|
-
// (firstGroup as Group).reCalculateObjects();
|
|
710
|
-
// transformer.clearSelectedObjects();
|
|
711
|
-
// transformer.setSelectedControl(firstGroup);
|
|
712
|
-
// }
|
|
713
|
-
_ungroupDrawings(r) {
|
|
714
|
-
r.forEach((e) => {
|
|
715
|
-
this._ungroupDrawing(e);
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
_ungroupDrawing(r) {
|
|
719
|
-
const { parent: e, children: t } = r, n = this._getSceneAndTransformerByDrawingSearch(e.unitId);
|
|
720
|
-
if (n == null)
|
|
721
|
-
return;
|
|
722
|
-
const { scene: s, transformer: a } = n;
|
|
723
|
-
t.forEach((g) => {
|
|
724
|
-
const d = L(g), f = s.getObjectIncludeInGroup(d);
|
|
725
|
-
if (f == null)
|
|
726
|
-
return !0;
|
|
727
|
-
if (f == null)
|
|
728
|
-
return;
|
|
729
|
-
const { transform: w } = g;
|
|
730
|
-
w != null && (f.classType === Je.GROUP ? f.transformByState({ left: w.left, top: w.top }) : f.transformByState(w));
|
|
731
|
-
});
|
|
732
|
-
const o = L(e), c = s.getObject(o), { width: u, height: l } = c;
|
|
733
|
-
c.getObjects().forEach((g) => {
|
|
734
|
-
c.removeSelfObjectAndTransform(g.oKey, u, l);
|
|
735
|
-
}), c.dispose(), a.clearSelectedObjects();
|
|
736
|
-
}
|
|
737
|
-
_drawingAlign(r) {
|
|
738
|
-
const { alignType: e } = r, t = this._drawingManagerService.getFocusDrawings();
|
|
739
|
-
if (e === T.default)
|
|
740
|
-
return;
|
|
741
|
-
const n = [];
|
|
742
|
-
let s = Number.POSITIVE_INFINITY, a = Number.POSITIVE_INFINITY, o = Number.NEGATIVE_INFINITY, c = Number.NEGATIVE_INFINITY, u = 0;
|
|
743
|
-
t.forEach((l) => {
|
|
744
|
-
const { unitId: g, subUnitId: d, drawingId: f, drawingType: w } = l, h = this._drawingManagerService.getDrawingByParam({ unitId: g, subUnitId: d, drawingId: f });
|
|
745
|
-
if (h == null || h.transform == null)
|
|
746
|
-
return;
|
|
747
|
-
n.push({
|
|
748
|
-
unitId: g,
|
|
749
|
-
subUnitId: d,
|
|
750
|
-
drawingId: f,
|
|
751
|
-
drawingType: w,
|
|
752
|
-
transform: h.transform
|
|
753
|
-
});
|
|
754
|
-
const { left: p = 0, top: C = 0, width: _ = 0, height: I = 0 } = h.transform;
|
|
755
|
-
s = Math.min(s, p), a = Math.min(a, C), o = Math.max(o, p + _), c = Math.max(c, C + I), u++;
|
|
756
|
-
}), u !== 0 && (this._sortDrawingTransform(n, e), this._applyAlignType(n, e, s, a, o, c, u));
|
|
757
|
-
}
|
|
758
|
-
_applyAlignType(r, e, t, n, s, a, o) {
|
|
759
|
-
const c = Math.round((s - t) / o * 10) / 10, u = Math.round((a - n) / o * 10) / 10, l = [], g = this._getSceneAndTransformerByDrawingSearch(r[0].unitId);
|
|
760
|
-
if (g == null)
|
|
761
|
-
return;
|
|
762
|
-
const { scene: d, transformer: f } = g;
|
|
763
|
-
r.forEach((w, h) => {
|
|
764
|
-
const { unitId: p, subUnitId: C, drawingId: _, transform: I, drawingType: M } = w, { left: D = 0, top: S = 0, width: y = 0, height: b = 0 } = I;
|
|
765
|
-
let O = D, R = S;
|
|
766
|
-
switch (e) {
|
|
767
|
-
case T.left:
|
|
768
|
-
O = t;
|
|
769
|
-
break;
|
|
770
|
-
case T.center:
|
|
771
|
-
O = t + (s - t) / 2 - y / 2;
|
|
772
|
-
break;
|
|
773
|
-
case T.right:
|
|
774
|
-
O = s - y;
|
|
775
|
-
break;
|
|
776
|
-
case T.top:
|
|
777
|
-
R = n;
|
|
778
|
-
break;
|
|
779
|
-
case T.middle:
|
|
780
|
-
R = n + (a - n) / 2 - b / 2;
|
|
781
|
-
break;
|
|
782
|
-
case T.bottom:
|
|
783
|
-
R = a - b;
|
|
784
|
-
break;
|
|
785
|
-
case T.horizon:
|
|
786
|
-
O = t + c * h;
|
|
787
|
-
break;
|
|
788
|
-
case T.vertical:
|
|
789
|
-
R = n + u * h;
|
|
790
|
-
break;
|
|
791
|
-
}
|
|
792
|
-
(O !== D || R !== S) && l.push({
|
|
793
|
-
unitId: p,
|
|
794
|
-
subUnitId: C,
|
|
795
|
-
drawingId: _,
|
|
796
|
-
drawingType: M,
|
|
797
|
-
transform: {
|
|
798
|
-
left: O,
|
|
799
|
-
top: R
|
|
800
|
-
}
|
|
801
|
-
});
|
|
802
|
-
}), this._drawingManagerService.featurePluginUpdateNotification(l), f.refreshControls().changeNotification();
|
|
803
|
-
}
|
|
804
|
-
_sortDrawingTransform(r, e) {
|
|
805
|
-
r.sort((t, n) => {
|
|
806
|
-
const s = t.transform, a = n.transform, {
|
|
807
|
-
left: o = 0,
|
|
808
|
-
top: c = 0,
|
|
809
|
-
width: u = 0,
|
|
810
|
-
height: l = 0
|
|
811
|
-
} = s, {
|
|
812
|
-
left: g = 0,
|
|
813
|
-
top: d = 0,
|
|
814
|
-
width: f = 0,
|
|
815
|
-
height: w = 0
|
|
816
|
-
} = a;
|
|
817
|
-
switch (e) {
|
|
818
|
-
case T.left:
|
|
819
|
-
return o - g;
|
|
820
|
-
case T.center:
|
|
821
|
-
return o + u / 2 - (g + f / 2);
|
|
822
|
-
case T.right:
|
|
823
|
-
return o + u - (g + f);
|
|
824
|
-
case T.top:
|
|
825
|
-
return c - d;
|
|
826
|
-
case T.middle:
|
|
827
|
-
return c + l / 2 - (d + w / 2);
|
|
828
|
-
case T.bottom:
|
|
829
|
-
return c + l - (d + w);
|
|
830
|
-
case T.horizon:
|
|
831
|
-
return o + u / 2 - (g + f / 2);
|
|
832
|
-
case T.vertical:
|
|
833
|
-
return c + l / 2 - (d + w / 2);
|
|
834
|
-
default:
|
|
835
|
-
return 0;
|
|
836
|
-
}
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
_drawingArrangeListener() {
|
|
840
|
-
this.disposeWithMe(
|
|
841
|
-
this._drawingManagerService.order$.subscribe((r) => {
|
|
842
|
-
this._drawingArrange(r);
|
|
843
|
-
})
|
|
844
|
-
);
|
|
845
|
-
}
|
|
846
|
-
_drawingArrange(r) {
|
|
847
|
-
const { unitId: e, subUnitId: t, drawingIds: n } = r, s = this._getSceneAndTransformerByDrawingSearch(e);
|
|
848
|
-
if (s == null)
|
|
849
|
-
return;
|
|
850
|
-
const { scene: a } = s;
|
|
851
|
-
n.forEach((o) => {
|
|
852
|
-
const c = L({ unitId: e, subUnitId: t, drawingId: o }), u = a.fuzzyMathObjects(c, !0);
|
|
853
|
-
if (u == null || u.length === 0)
|
|
854
|
-
return;
|
|
855
|
-
const l = this._drawingManagerService.getDrawingOrder(e, t).indexOf(o);
|
|
856
|
-
for (const g of u)
|
|
857
|
-
g.setProps({ zIndex: l }), g.makeDirty();
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
_drawingAddListener() {
|
|
861
|
-
this.disposeWithMe(
|
|
862
|
-
this._drawingManagerService.add$.subscribe((r) => {
|
|
863
|
-
this._insertDrawing(r);
|
|
864
|
-
})
|
|
865
|
-
);
|
|
866
|
-
}
|
|
867
|
-
_insertDrawing(r) {
|
|
868
|
-
const e = [];
|
|
869
|
-
r.forEach((t) => {
|
|
870
|
-
const { unitId: n } = t;
|
|
871
|
-
if (this._drawingManagerService.getDrawingByParam(t) == null)
|
|
872
|
-
return;
|
|
873
|
-
const a = this._getSceneAndTransformerByDrawingSearch(n);
|
|
874
|
-
if (a == null)
|
|
875
|
-
return;
|
|
876
|
-
const { scene: o } = a;
|
|
877
|
-
e.includes(o) || e.push(o);
|
|
878
|
-
}), e.forEach((t) => {
|
|
879
|
-
this._sceneListenerOnDrawingMap.has(t) || (this._addListenerOnDrawing(t), this._sceneListenerOnDrawingMap.add(t));
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
_drawingRemoveListener() {
|
|
883
|
-
this.disposeWithMe(
|
|
884
|
-
this._drawingManagerService.remove$.subscribe((r) => {
|
|
885
|
-
r.forEach((e) => {
|
|
886
|
-
var l;
|
|
887
|
-
const { unitId: t, subUnitId: n, drawingId: s } = e, a = this._getSceneAndTransformerByDrawingSearch(t);
|
|
888
|
-
if (a == null)
|
|
889
|
-
return;
|
|
890
|
-
const { scene: o } = a, c = L({ unitId: t, subUnitId: n, drawingId: s }), u = o.fuzzyMathObjects(c, !0);
|
|
891
|
-
if (u.length > 0) {
|
|
892
|
-
for (const g of u)
|
|
893
|
-
g.dispose();
|
|
894
|
-
(l = o.getTransformer()) == null || l.clearSelectedObjects();
|
|
895
|
-
}
|
|
896
|
-
});
|
|
897
|
-
})
|
|
898
|
-
);
|
|
899
|
-
}
|
|
900
|
-
_drawingUpdateListener() {
|
|
901
|
-
this.disposeWithMe(
|
|
902
|
-
this._drawingManagerService.update$.subscribe((r) => {
|
|
903
|
-
r.forEach((e) => {
|
|
904
|
-
var y;
|
|
905
|
-
const { unitId: t, subUnitId: n, drawingId: s } = e, a = this._drawingManagerService.getDrawingByParam(e);
|
|
906
|
-
if (a == null)
|
|
907
|
-
return;
|
|
908
|
-
const { transform: o, drawingType: c } = a, u = this._getSceneAndTransformerByDrawingSearch(t);
|
|
909
|
-
if (u == null)
|
|
910
|
-
return;
|
|
911
|
-
const { scene: l, transformer: g } = u;
|
|
912
|
-
if (o == null)
|
|
913
|
-
return !0;
|
|
914
|
-
const { left: d = 0, top: f = 0, width: w = 0, height: h = 0, angle: p = 0, flipX: C = !1, flipY: _ = !1, skewX: I = 0, skewY: M = 0 } = o, D = L({ unitId: t, subUnitId: n, drawingId: s }), S = l.getObject(D);
|
|
915
|
-
if (S == null)
|
|
916
|
-
return !0;
|
|
917
|
-
S.transformByState({ left: d, top: f, width: w, height: h, angle: p, flipX: C, flipY: _, skewX: I, skewY: M }), (y = l.getTransformer()) == null || y.debounceRefreshControls();
|
|
918
|
-
});
|
|
919
|
-
})
|
|
920
|
-
);
|
|
921
|
-
}
|
|
922
|
-
_drawingRefreshListener() {
|
|
923
|
-
this.disposeWithMe(
|
|
924
|
-
this._drawingManagerService.refreshTransform$.subscribe((r) => {
|
|
925
|
-
r.forEach((e) => {
|
|
926
|
-
const { unitId: t, subUnitId: n, drawingId: s } = e, a = this._getSceneAndTransformerByDrawingSearch(t);
|
|
927
|
-
if (a == null)
|
|
928
|
-
return;
|
|
929
|
-
const o = this._drawingManagerService.getDrawingByParam(e);
|
|
930
|
-
if (o == null)
|
|
931
|
-
return;
|
|
932
|
-
const { transform: c } = o, { scene: u } = a, l = L({ unitId: t, subUnitId: n, drawingId: s }), g = u.getObject(l);
|
|
933
|
-
if (g == null || c == null)
|
|
934
|
-
return !0;
|
|
935
|
-
const {
|
|
936
|
-
left: d = 0,
|
|
937
|
-
top: f = 0,
|
|
938
|
-
width: w = 0,
|
|
939
|
-
height: h = 0,
|
|
940
|
-
angle: p = 0,
|
|
941
|
-
flipX: C = !1,
|
|
942
|
-
flipY: _ = !1,
|
|
943
|
-
skewX: I = 0,
|
|
944
|
-
skewY: M = 0
|
|
945
|
-
} = c;
|
|
946
|
-
g.transformByState({ left: d, top: f, width: w, height: h, angle: p, flipX: C, flipY: _, skewX: I, skewY: M });
|
|
947
|
-
});
|
|
948
|
-
})
|
|
949
|
-
);
|
|
950
|
-
}
|
|
951
|
-
_drawingVisibleListener() {
|
|
952
|
-
this.disposeWithMe(
|
|
953
|
-
this._drawingManagerService.visible$.subscribe((r) => {
|
|
954
|
-
r.forEach((e) => {
|
|
955
|
-
const { unitId: t, subUnitId: n, drawingId: s, visible: a } = e, o = this._getSceneAndTransformerByDrawingSearch(t);
|
|
956
|
-
if (o == null)
|
|
957
|
-
return;
|
|
958
|
-
const { scene: c } = o, u = L({ unitId: t, subUnitId: n, drawingId: s }), l = c.getObject(u);
|
|
959
|
-
if (l == null)
|
|
960
|
-
return !0;
|
|
961
|
-
a ? l.show() : l.hide();
|
|
962
|
-
});
|
|
963
|
-
})
|
|
964
|
-
);
|
|
965
|
-
}
|
|
966
|
-
_filterUpdateParams(r, e) {
|
|
967
|
-
return r.filter((t, n) => {
|
|
968
|
-
if (t == null)
|
|
969
|
-
return !1;
|
|
970
|
-
const { transform: s } = t;
|
|
971
|
-
return lt(s, e == null ? void 0 : e[n]);
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
// group?.getObjects().forEach((o) => {
|
|
975
|
-
// const drawing = this._drawingManagerService.getDrawingOKey(o.oKey);
|
|
976
|
-
// if (drawing != null) {
|
|
977
|
-
// const { unitId, subUnitId, drawingId } = drawing;
|
|
978
|
-
// drawings.push({ unitId, subUnitId, drawingId });
|
|
979
|
-
// }
|
|
980
|
-
// });
|
|
981
|
-
_addListenerOnDrawing(r) {
|
|
982
|
-
const e = r.getTransformerByCreate();
|
|
983
|
-
let t = null;
|
|
984
|
-
this.disposeWithMe(
|
|
985
|
-
ve(
|
|
986
|
-
e.changeStart$.subscribe((n) => {
|
|
987
|
-
const { objects: s } = n, a = Array.from(s.values()), o = [];
|
|
988
|
-
t = a.map((c) => {
|
|
989
|
-
const { left: u, top: l, height: g, width: d, angle: f, oKey: w, isInGroup: h } = c, p = this._drawingManagerService.getDrawingOKey(w);
|
|
990
|
-
if (h || c instanceof We) {
|
|
991
|
-
let C = c.ancestorGroup;
|
|
992
|
-
if (C == null && c instanceof We && (C = c), C == null)
|
|
993
|
-
return null;
|
|
994
|
-
const _ = this._drawingManagerService.getDrawingOKey(C.oKey);
|
|
995
|
-
if (_) {
|
|
996
|
-
const { unitId: I, subUnitId: M, drawingId: D } = _;
|
|
997
|
-
o.push({ unitId: I, subUnitId: M, drawingId: D });
|
|
998
|
-
const { left: S, top: y, height: b, width: O, angle: R } = C;
|
|
999
|
-
return { left: S, top: y, height: b, width: O, angle: R };
|
|
1000
|
-
}
|
|
1001
|
-
} else if (p != null) {
|
|
1002
|
-
const { unitId: C, subUnitId: _, drawingId: I } = p;
|
|
1003
|
-
return o.push({ unitId: C, subUnitId: _, drawingId: I }), { left: u, top: l, height: g, width: d, angle: f };
|
|
1004
|
-
}
|
|
1005
|
-
return null;
|
|
1006
|
-
}).filter((c) => c != null), o.length > 0 ? this._commandService.syncExecuteCommand(Ee.id, o) : this._commandService.syncExecuteCommand(Ee.id, []);
|
|
1007
|
-
})
|
|
1008
|
-
)
|
|
1009
|
-
), this.disposeWithMe(
|
|
1010
|
-
ve(
|
|
1011
|
-
e.changeEnd$.subscribe((n) => {
|
|
1012
|
-
const { objects: s } = n, a = this._filterUpdateParams(Ve(s, this._drawingManagerService), t);
|
|
1013
|
-
a.length > 0 && this._drawingManagerService.featurePluginUpdateNotification(a);
|
|
1014
|
-
})
|
|
1015
|
-
)
|
|
1016
|
-
);
|
|
1017
|
-
}
|
|
1018
|
-
};
|
|
1019
|
-
xe = Sr([
|
|
1020
|
-
Re(0, $e),
|
|
1021
|
-
Re(1, ce),
|
|
1022
|
-
Re(2, ge),
|
|
1023
|
-
Re(3, ne)
|
|
1024
|
-
], xe);
|
|
1025
|
-
class Me extends kt {
|
|
1026
|
-
constructor(e, t) {
|
|
1027
|
-
t == null && (t = {}), t.transformerConfig = {
|
|
1028
|
-
keepRatio: !1,
|
|
1029
|
-
isCropper: !0,
|
|
1030
|
-
anchorFill: "rgb(0, 0, 0)",
|
|
1031
|
-
anchorStroke: "rgb(255, 255, 255)",
|
|
1032
|
-
anchorSize: 24
|
|
1033
|
-
};
|
|
1034
|
-
super(e, t);
|
|
1035
|
-
Z(this, "_srcRect");
|
|
1036
|
-
Z(this, "_prstGeom");
|
|
1037
|
-
Z(this, "_applyTransform");
|
|
1038
|
-
Z(this, "_dragPadding", 8);
|
|
1039
|
-
Z(this, "_cacheCanvas");
|
|
1040
|
-
t != null && t.srcRect && (this._srcRect = t.srcRect), t != null && t.prstGeom && (this._prstGeom = t.prstGeom), t != null && t.applyTransform && (this._applyTransform = t.applyTransform), t != null && t.dragPadding && (this._dragPadding = t.dragPadding), this._applyProps();
|
|
1041
|
-
}
|
|
1042
|
-
refreshSrcRect(e, t) {
|
|
1043
|
-
this._srcRect = e, this._applyTransform = t, this._applyProps();
|
|
1044
|
-
}
|
|
1045
|
-
get srcRect() {
|
|
1046
|
-
return this._srcRect;
|
|
1047
|
-
}
|
|
1048
|
-
dispose() {
|
|
1049
|
-
var e;
|
|
1050
|
-
super.dispose(), (e = this._cacheCanvas) == null || e.dispose(), this._srcRect = null;
|
|
1051
|
-
}
|
|
1052
|
-
isHit(e) {
|
|
1053
|
-
const t = this.getInverseCoord(e);
|
|
1054
|
-
return t.x >= -this.strokeWidth / 2 && t.x <= this.width + this.strokeWidth / 2 && t.y >= -this.strokeWidth / 2 && t.y <= this.height + this.strokeWidth / 2 && !this._inSurround(t);
|
|
1055
|
-
}
|
|
1056
|
-
_inSurround(e) {
|
|
1057
|
-
const t = this._dragPadding;
|
|
1058
|
-
return e.x >= t - this.strokeWidth / 2 && e.x <= this.width + this.strokeWidth / 2 - t && e.y >= t - this.strokeWidth / 2 && e.y <= this.height + this.strokeWidth / 2 - t;
|
|
1059
|
-
}
|
|
1060
|
-
render(e, t) {
|
|
1061
|
-
return this.visible ? (e.save(), this._draw(e), e.restore(), this.makeDirty(!1), this) : (this.makeDirty(!1), this);
|
|
1062
|
-
}
|
|
1063
|
-
_draw(e) {
|
|
1064
|
-
var c, u;
|
|
1065
|
-
const n = this.getScene().getEngine(), { width: s, height: a } = n;
|
|
1066
|
-
this._initialCacheCanvas(), (c = this._cacheCanvas) == null || c.clear();
|
|
1067
|
-
const o = (u = this._cacheCanvas) == null ? void 0 : u.getContext();
|
|
1068
|
-
o != null && (o.save(), dt.drawWith(o, {
|
|
1069
|
-
left: 0,
|
|
1070
|
-
top: 0,
|
|
1071
|
-
width: s,
|
|
1072
|
-
height: a,
|
|
1073
|
-
fill: "rgba(0, 0, 0, 0.5)"
|
|
1074
|
-
}), o.setTransform(e.getTransform()), this._clipForApplyObject(o), this._applyCache(e), o.restore());
|
|
1075
|
-
}
|
|
1076
|
-
_clipForApplyObject(e) {
|
|
1077
|
-
let t = 0;
|
|
1078
|
-
if (this._prstGeom != null && (t = 1), e.globalCompositeOperation = "destination-out", e.beginPath(), t === 0) {
|
|
1079
|
-
const n = this.transform.getMatrix();
|
|
1080
|
-
e.transform(n[0], n[1], n[2], n[3], n[4], n[5]), e.rect(0, 0, this.width, this.height), e.fill();
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
_applyProps() {
|
|
1084
|
-
if (this._applyTransform == null)
|
|
1085
|
-
return;
|
|
1086
|
-
let e = 0, t = 0, n = 0, s = 0;
|
|
1087
|
-
const { left: a = 0, top: o = 0, width: c = 0, height: u = 0, angle: l } = this._applyTransform;
|
|
1088
|
-
if (this._srcRect != null) {
|
|
1089
|
-
const { left: f = 0, top: w = 0, right: h = 0, bottom: p = 0 } = this._srcRect;
|
|
1090
|
-
e = f, t = w, n = h, s = p;
|
|
1091
|
-
}
|
|
1092
|
-
const g = a + e, d = o + t;
|
|
1093
|
-
this.transformByState({
|
|
1094
|
-
left: g,
|
|
1095
|
-
top: d,
|
|
1096
|
-
width: a + c - n - g,
|
|
1097
|
-
height: o + u - s - d,
|
|
1098
|
-
angle: l
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
_applyCache(e) {
|
|
1102
|
-
if (!e || this._cacheCanvas == null)
|
|
1103
|
-
return;
|
|
1104
|
-
const t = this._cacheCanvas.getContext();
|
|
1105
|
-
t.save(), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), t.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(this._cacheCanvas.getCanvasEle(), 0, 0), e.restore(), t.restore();
|
|
1106
|
-
}
|
|
1107
|
-
_initialCacheCanvas() {
|
|
1108
|
-
if (this._cacheCanvas != null)
|
|
1109
|
-
return;
|
|
1110
|
-
const e = this.getScene();
|
|
1111
|
-
if (e == null) return;
|
|
1112
|
-
this._cacheCanvas = new $t();
|
|
1113
|
-
const t = e.getEngine();
|
|
1114
|
-
this._cacheCanvas.setSize(t.width, t.height), t.onTransformChange$.subscribeEvent(() => {
|
|
1115
|
-
var n;
|
|
1116
|
-
(n = this._cacheCanvas) == null || n.setSize(t.width, t.height), this.makeDirty(!0);
|
|
1117
|
-
});
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
var Ir = Object.getOwnPropertyDescriptor, br = (i, r, e, t) => {
|
|
1121
|
-
for (var n = t > 1 ? void 0 : t ? Ir(r, e) : r, s = i.length - 1, a; s >= 0; s--)
|
|
1122
|
-
(a = i[s]) && (n = a(n) || n);
|
|
1123
|
-
return n;
|
|
1124
|
-
}, le = (i, r) => (e, t) => r(e, t, i);
|
|
1125
|
-
let je = class extends ke {
|
|
1126
|
-
constructor(r, e, t, n, s, a) {
|
|
1127
|
-
super();
|
|
1128
|
-
Z(this, "_sceneListenerOnImageMap", /* @__PURE__ */ new WeakSet());
|
|
1129
|
-
this._commandService = r, this._drawingManagerService = e, this._renderManagerService = t, this._univerInstanceService = n, this._messageService = s, this._localeService = a, this._init();
|
|
1130
|
-
}
|
|
1131
|
-
_init() {
|
|
1132
|
-
this._initOpenCrop(), this._initCloseCrop(), this._initAutoCrop();
|
|
1133
|
-
}
|
|
1134
|
-
_initAutoCrop() {
|
|
1135
|
-
this.disposeWithMe(
|
|
1136
|
-
this._commandService.onCommandExecuted((r) => {
|
|
1137
|
-
if (r.id !== Be.id)
|
|
1138
|
-
return;
|
|
1139
|
-
const e = r.params;
|
|
1140
|
-
if (e == null)
|
|
1141
|
-
return;
|
|
1142
|
-
const { cropType: t } = e, n = this._drawingManagerService.getFocusDrawings();
|
|
1143
|
-
if (n.length !== 1)
|
|
1144
|
-
return;
|
|
1145
|
-
const s = n[0], { unitId: a, subUnitId: o, drawingId: c } = s, u = this._renderManagerService.getRenderById(a), l = u == null ? void 0 : u.scene;
|
|
1146
|
-
if (l == null)
|
|
1147
|
-
return !0;
|
|
1148
|
-
this._searchCropObject(l) != null && this._commandService.syncExecuteCommand(oe.id, { isAuto: !0 });
|
|
1149
|
-
const d = L({ unitId: a, subUnitId: o, drawingId: c }), f = l.getObject(d);
|
|
1150
|
-
if (!(f instanceof Ze)) {
|
|
1151
|
-
this._messageService.show({
|
|
1152
|
-
type: Qe.Error,
|
|
1153
|
-
content: this._localeService.t("image-cropper.error")
|
|
1154
|
-
});
|
|
1155
|
-
return;
|
|
1156
|
-
}
|
|
1157
|
-
f != null && (this._updateCropperObject(t, f), this._commandService.executeCommand(Fe.id, { unitId: a, subUnitId: o, drawingId: c }));
|
|
1158
|
-
})
|
|
1159
|
-
);
|
|
1160
|
-
}
|
|
1161
|
-
_calculateSrcRectByRatio(r, e, t, n, s, a) {
|
|
1162
|
-
const o = t / n, c = s / a;
|
|
1163
|
-
let u = t, l = n;
|
|
1164
|
-
o > c ? u = n * c : l = t / c;
|
|
1165
|
-
const g = (t - u) / 2, d = (n - l) / 2;
|
|
1166
|
-
return {
|
|
1167
|
-
left: ye(g, 1),
|
|
1168
|
-
top: ye(d, 1),
|
|
1169
|
-
right: ye(t - (g + u), 1),
|
|
1170
|
-
bottom: ye(n - (d + l), 1)
|
|
1171
|
-
};
|
|
1172
|
-
}
|
|
1173
|
-
_updateCropperObject(r, e) {
|
|
1174
|
-
const { left: t, top: n, width: s, height: a } = e.calculateTransformWithSrcRect();
|
|
1175
|
-
let o;
|
|
1176
|
-
switch (r) {
|
|
1177
|
-
case U.R1_1:
|
|
1178
|
-
o = this._calculateSrcRectByRatio(t, n, s, a, 1, 1);
|
|
1179
|
-
break;
|
|
1180
|
-
case U.R16_9:
|
|
1181
|
-
o = this._calculateSrcRectByRatio(t, n, s, a, 16, 9);
|
|
1182
|
-
break;
|
|
1183
|
-
case U.R9_16:
|
|
1184
|
-
o = this._calculateSrcRectByRatio(t, n, s, a, 9, 16);
|
|
1185
|
-
break;
|
|
1186
|
-
case U.R5_4:
|
|
1187
|
-
o = this._calculateSrcRectByRatio(t, n, s, a, 5, 4);
|
|
1188
|
-
break;
|
|
1189
|
-
case U.R4_5:
|
|
1190
|
-
o = this._calculateSrcRectByRatio(t, n, s, a, 4, 5);
|
|
1191
|
-
break;
|
|
1192
|
-
case U.R4_3:
|
|
1193
|
-
o = this._calculateSrcRectByRatio(t, n, s, a, 4, 3);
|
|
1194
|
-
break;
|
|
1195
|
-
case U.R3_4:
|
|
1196
|
-
o = this._calculateSrcRectByRatio(t, n, s, a, 3, 4);
|
|
1197
|
-
break;
|
|
1198
|
-
case U.R3_2:
|
|
1199
|
-
o = this._calculateSrcRectByRatio(t, n, s, a, 3, 2);
|
|
1200
|
-
break;
|
|
1201
|
-
case U.R2_3:
|
|
1202
|
-
o = this._calculateSrcRectByRatio(t, n, s, a, 2, 3);
|
|
1203
|
-
break;
|
|
1204
|
-
case U.FREE:
|
|
1205
|
-
}
|
|
1206
|
-
if (o == null)
|
|
1207
|
-
return;
|
|
1208
|
-
e.setSrcRect(o);
|
|
1209
|
-
const { left: c = 0, top: u = 0, bottom: l = 0, right: g = 0 } = o;
|
|
1210
|
-
e.transformByStateCloseCropper({
|
|
1211
|
-
left: t + c,
|
|
1212
|
-
top: n + u,
|
|
1213
|
-
width: s - g - c,
|
|
1214
|
-
height: a - l - u
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
_initOpenCrop() {
|
|
1218
|
-
this.disposeWithMe(
|
|
1219
|
-
this._commandService.onCommandExecuted((r) => {
|
|
1220
|
-
if (r.id !== Fe.id)
|
|
1221
|
-
return;
|
|
1222
|
-
const e = r.params;
|
|
1223
|
-
if (e == null)
|
|
1224
|
-
return;
|
|
1225
|
-
const { unitId: t, subUnitId: n, drawingId: s } = e, a = this._renderManagerService.getRenderById(t), o = a == null ? void 0 : a.scene;
|
|
1226
|
-
if (o == null)
|
|
1227
|
-
return !0;
|
|
1228
|
-
if (this._sceneListenerOnImageMap.has(o) || (this._addListenerOnImage(o), this._sceneListenerOnImageMap.add(o)), this._drawingManagerService.getDrawingByParam({ unitId: t, subUnitId: n, drawingId: s }) == null)
|
|
1229
|
-
return;
|
|
1230
|
-
const u = L({ unitId: t, subUnitId: n, drawingId: s }), l = o.getObject(u);
|
|
1231
|
-
if (l == null)
|
|
1232
|
-
return;
|
|
1233
|
-
if (!(l instanceof Ze)) {
|
|
1234
|
-
this._messageService.show({
|
|
1235
|
-
type: Qe.Error,
|
|
1236
|
-
content: this._localeService.t("image-cropper.error")
|
|
1237
|
-
});
|
|
1238
|
-
return;
|
|
1239
|
-
}
|
|
1240
|
-
const g = o.getTransformer();
|
|
1241
|
-
g == null || g.clearControls();
|
|
1242
|
-
const d = new Me(`${u}-crop`, {
|
|
1243
|
-
srcRect: l.srcRect,
|
|
1244
|
-
prstGeom: l.prstGeom,
|
|
1245
|
-
applyTransform: l.calculateTransformWithSrcRect()
|
|
1246
|
-
});
|
|
1247
|
-
o.addObject(d, l.getLayerIndex() + 1).attachTransformerTo(d), g == null || g.createControlForCopper(d), this._addHoverForImageCopper(d), l.openRenderByCropper(), g == null || g.refreshControls(), d.makeDirty(!0), this._commandService.syncExecuteCommand(Ee.id, [{ unitId: t, subUnitId: n, drawingId: s }]);
|
|
1248
|
-
})
|
|
1249
|
-
);
|
|
1250
|
-
}
|
|
1251
|
-
_searchCropObject(r) {
|
|
1252
|
-
const e = r.getAllObjectsByOrder();
|
|
1253
|
-
for (const t of e)
|
|
1254
|
-
if (t instanceof Me)
|
|
1255
|
-
return t;
|
|
1256
|
-
}
|
|
1257
|
-
_initCloseCrop() {
|
|
1258
|
-
this.disposeWithMe(
|
|
1259
|
-
this._commandService.onCommandExecuted((e) => {
|
|
1260
|
-
if (e.id !== oe.id)
|
|
1261
|
-
return;
|
|
1262
|
-
const t = this._univerInstanceService.getFocusedUnit();
|
|
1263
|
-
if (t == null)
|
|
1264
|
-
return;
|
|
1265
|
-
const n = t.getUnitId(), s = this._renderManagerService.getRenderById(n), a = s == null ? void 0 : s.scene;
|
|
1266
|
-
if (a == null)
|
|
1267
|
-
return !0;
|
|
1268
|
-
const o = this._searchCropObject(a);
|
|
1269
|
-
if (o == null)
|
|
1270
|
-
return;
|
|
1271
|
-
const c = this._getApplyObjectByCropObject(o);
|
|
1272
|
-
if (c == null)
|
|
1273
|
-
return;
|
|
1274
|
-
const u = a.getTransformerByCreate();
|
|
1275
|
-
u.detachFrom(o), u.clearCopperControl();
|
|
1276
|
-
const l = this._getSrcRectByTransformState(c, o), g = this._drawingManagerService.getDrawingOKey(c.oKey);
|
|
1277
|
-
if (g != null) {
|
|
1278
|
-
const { left: d, top: f, height: w, width: h } = o;
|
|
1279
|
-
this._drawingManagerService.featurePluginUpdateNotification([{
|
|
1280
|
-
...g,
|
|
1281
|
-
transform: {
|
|
1282
|
-
...g.transform,
|
|
1283
|
-
left: d,
|
|
1284
|
-
top: f,
|
|
1285
|
-
height: w,
|
|
1286
|
-
width: h
|
|
1287
|
-
},
|
|
1288
|
-
srcRect: l.srcRectAngle
|
|
1289
|
-
}]);
|
|
1290
|
-
}
|
|
1291
|
-
c.setSrcRect({ ...l.srcRectAngle }), c.closeRenderByCropper(), c.makeDirty(!0), o == null || o.dispose();
|
|
1292
|
-
})
|
|
1293
|
-
);
|
|
1294
|
-
const r = this._univerInstanceService.getCurrentTypeOfUnit$(ue.UNIVER_SHEET).pipe(
|
|
1295
|
-
qt((e) => e ? e.activeSheet$ : Qt(null))
|
|
1296
|
-
);
|
|
1297
|
-
this.disposeWithMe(r.subscribe(() => {
|
|
1298
|
-
this._commandService.syncExecuteCommand(oe.id);
|
|
1299
|
-
}));
|
|
1300
|
-
}
|
|
1301
|
-
_getApplyObjectByCropObject(r) {
|
|
1302
|
-
const e = r.oKey, t = e.slice(0, e.length - 5), n = r.getScene();
|
|
1303
|
-
if (!n) return null;
|
|
1304
|
-
const s = n.getObject(t);
|
|
1305
|
-
return s == null ? null : s;
|
|
1306
|
-
}
|
|
1307
|
-
_addListenerOnImage(r) {
|
|
1308
|
-
const e = r.getTransformerByCreate();
|
|
1309
|
-
let t = null;
|
|
1310
|
-
this.disposeWithMe(
|
|
1311
|
-
e.changeStart$.subscribe((n) => {
|
|
1312
|
-
const { objects: s } = n, a = s.values().next().value;
|
|
1313
|
-
if (a == null || !(a instanceof Me))
|
|
1314
|
-
return;
|
|
1315
|
-
const { left: o, top: c, height: u, width: l, angle: g } = a;
|
|
1316
|
-
t = { left: o, top: c, height: u, width: l, angle: g }, e.clearCopperControl();
|
|
1317
|
-
})
|
|
1318
|
-
), this.disposeWithMe(
|
|
1319
|
-
e.changeEnd$.subscribe((n) => {
|
|
1320
|
-
const { objects: s } = n, a = s.values().next().value;
|
|
1321
|
-
if (a == null || !(a instanceof Me))
|
|
1322
|
-
return;
|
|
1323
|
-
const { left: o, top: c, height: u, width: l, angle: g } = a;
|
|
1324
|
-
if (!lt({ left: o, top: c, height: u, width: l, angle: g }, t))
|
|
1325
|
-
return;
|
|
1326
|
-
const d = this._getApplyObjectByCropObject(a);
|
|
1327
|
-
if (d == null)
|
|
1328
|
-
return;
|
|
1329
|
-
const f = this._getSrcRectByTransformState(d, a);
|
|
1330
|
-
a.refreshSrcRect(f.srcRect, d.getState()), e.createControlForCopper(a);
|
|
1331
|
-
})
|
|
1332
|
-
), this._endCropListener(r);
|
|
1333
|
-
}
|
|
1334
|
-
_addHoverForImageCopper(r) {
|
|
1335
|
-
this.disposeWithMe(
|
|
1336
|
-
r.onPointerEnter$.subscribeEvent(() => {
|
|
1337
|
-
r.cursor = Pe.MOVE;
|
|
1338
|
-
})
|
|
1339
|
-
), this.disposeWithMe(
|
|
1340
|
-
r.onPointerLeave$.subscribeEvent(() => {
|
|
1341
|
-
r.cursor = Pe.DEFAULT;
|
|
1342
|
-
})
|
|
1343
|
-
);
|
|
1344
|
-
}
|
|
1345
|
-
_endCropListener(r) {
|
|
1346
|
-
const e = r.getTransformerByCreate();
|
|
1347
|
-
this.disposeWithMe(
|
|
1348
|
-
e.clearControl$.subscribe((t) => {
|
|
1349
|
-
t === !0 && this._commandService.syncExecuteCommand(oe.id);
|
|
1350
|
-
})
|
|
1351
|
-
);
|
|
1352
|
-
}
|
|
1353
|
-
_getSrcRectByTransformState(r, e) {
|
|
1354
|
-
const { left: t, top: n, height: s, width: a, strokeWidth: o, angle: c } = e, { left: u, top: l, width: g, height: d, angle: f, strokeWidth: w } = r, h = t - u, p = n - l, C = {
|
|
1355
|
-
left: h,
|
|
1356
|
-
top: p,
|
|
1357
|
-
right: g - h - a,
|
|
1358
|
-
bottom: d - p - s
|
|
1359
|
-
}, _ = { ...C };
|
|
1360
|
-
if (f !== 0) {
|
|
1361
|
-
const I = t + a / 2, M = n + s / 2, D = new Ge(I, M), S = g / 2 + u, y = d / 2 + l, b = new Ge(S, y), O = new Ge(u, l);
|
|
1362
|
-
O.rotateByPoint(qe(f), b);
|
|
1363
|
-
const R = O.clone();
|
|
1364
|
-
R.rotateByPoint(qe(-f), D);
|
|
1365
|
-
const B = t - R.x, P = n - R.y;
|
|
1366
|
-
_.left = B, _.top = P, _.right = g - B - a, _.bottom = d - P - s;
|
|
1367
|
-
}
|
|
1368
|
-
return {
|
|
1369
|
-
srcRect: C,
|
|
1370
|
-
srcRectAngle: _
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
};
|
|
1374
|
-
je = br([
|
|
1375
|
-
le(0, ce),
|
|
1376
|
-
le(1, ne),
|
|
1377
|
-
le(2, ge),
|
|
1378
|
-
le(3, $e),
|
|
1379
|
-
le(4, Zt),
|
|
1380
|
-
le(5, Le(re))
|
|
1381
|
-
], je);
|
|
1382
|
-
var yr = Object.getOwnPropertyDescriptor, Rr = (i, r, e, t) => {
|
|
1383
|
-
for (var n = t > 1 ? void 0 : t ? yr(r, e) : r, s = i.length - 1, a; s >= 0; s--)
|
|
1384
|
-
(a = i[s]) && (n = a(n) || n);
|
|
1385
|
-
return n;
|
|
1386
|
-
}, me = (i, r) => (e, t) => r(e, t, i);
|
|
1387
|
-
let Ae = class {
|
|
1388
|
-
constructor(i, r, e, t, n) {
|
|
1389
|
-
this._drawingManagerService = i, this._imageIoService = r, this._galleryService = e, this._urlImageService = t, this._univerInstanceService = n;
|
|
1390
|
-
}
|
|
1391
|
-
// eslint-disable-next-line max-lines-per-function, complexity
|
|
1392
|
-
async renderImages(i, r) {
|
|
1393
|
-
const {
|
|
1394
|
-
transform: e,
|
|
1395
|
-
drawingType: t,
|
|
1396
|
-
source: n,
|
|
1397
|
-
imageSourceType: s,
|
|
1398
|
-
srcRect: a,
|
|
1399
|
-
prstGeom: o,
|
|
1400
|
-
groupId: c,
|
|
1401
|
-
unitId: u,
|
|
1402
|
-
subUnitId: l,
|
|
1403
|
-
drawingId: g,
|
|
1404
|
-
isMultiTransform: d,
|
|
1405
|
-
transforms: f
|
|
1406
|
-
} = i;
|
|
1407
|
-
if (t !== q.DRAWING_IMAGE || !this._drawingManagerService.getDrawingVisible() || this._univerInstanceService.getUnitType(u) === ue.UNIVER_SHEET && l !== this._getActiveSheetId() || e == null)
|
|
1408
|
-
return;
|
|
1409
|
-
const w = d && f ? f : [e], h = [];
|
|
1410
|
-
for (const p of w) {
|
|
1411
|
-
const { left: C, top: _, width: I, height: M, angle: D, flipX: S, flipY: y, skewX: b, skewY: O } = p, R = w.indexOf(p), B = L({ unitId: u, subUnitId: l, drawingId: g }, d ? R : void 0), P = r.getObject(B);
|
|
1412
|
-
if (P != null) {
|
|
1413
|
-
P.transformByState({ left: C, top: _, width: I, height: M, angle: D, flipX: S, flipY: y, skewX: b, skewY: O });
|
|
1414
|
-
continue;
|
|
1415
|
-
}
|
|
1416
|
-
const F = this._drawingManagerService.getDrawingOrder(u, l), X = F.indexOf(g), $ = { ...p, zIndex: X === -1 ? F.length - 1 : X }, Se = this._imageIoService.getImageSourceCache(n, s);
|
|
1417
|
-
let te = !1;
|
|
1418
|
-
if (Se != null)
|
|
1419
|
-
$.image = Se;
|
|
1420
|
-
else if (s === Xe.UUID)
|
|
1421
|
-
try {
|
|
1422
|
-
$.url = await this._imageIoService.getImage(n);
|
|
1423
|
-
} catch (de) {
|
|
1424
|
-
console.error(de);
|
|
1425
|
-
continue;
|
|
1426
|
-
}
|
|
1427
|
-
else if (s === Xe.URL) {
|
|
1428
|
-
try {
|
|
1429
|
-
$.url = await this._urlImageService.getImage(n);
|
|
1430
|
-
} catch (de) {
|
|
1431
|
-
console.error(de), $.url = n;
|
|
1432
|
-
}
|
|
1433
|
-
te = !0;
|
|
1434
|
-
} else
|
|
1435
|
-
$.url = n, te = !0;
|
|
1436
|
-
if (r.getObject(B))
|
|
1437
|
-
continue;
|
|
1438
|
-
$.printable = !0;
|
|
1439
|
-
const V = new Ze(B, $);
|
|
1440
|
-
te && this._imageIoService.addImageSourceCache(n, s, V.getNative()), r.addObject(V, Ne), this._drawingManagerService.getDrawingEditable() && r.attachTransformerTo(V), c && rt({ drawingId: c, unitId: u, subUnitId: l }, V, r, this._drawingManagerService), o != null && V.setPrstGeom(o), a != null && V.setSrcRect(a), h.push(V);
|
|
1441
|
-
}
|
|
1442
|
-
return h;
|
|
1443
|
-
}
|
|
1444
|
-
_getActiveSheetId() {
|
|
1445
|
-
var i, r;
|
|
1446
|
-
return (r = (i = this._univerInstanceService.getCurrentUnitOfType(ue.UNIVER_SHEET)) == null ? void 0 : i.getActiveSheet()) == null ? void 0 : r.getSheetId();
|
|
1447
|
-
}
|
|
1448
|
-
renderFloatDom(i, r) {
|
|
1449
|
-
const {
|
|
1450
|
-
transform: e,
|
|
1451
|
-
drawingType: t,
|
|
1452
|
-
groupId: n,
|
|
1453
|
-
unitId: s,
|
|
1454
|
-
subUnitId: a,
|
|
1455
|
-
drawingId: o,
|
|
1456
|
-
isMultiTransform: c,
|
|
1457
|
-
transforms: u
|
|
1458
|
-
} = i;
|
|
1459
|
-
if (t !== q.DRAWING_DOM || !this._drawingManagerService.getDrawingVisible() || e == null)
|
|
1460
|
-
return;
|
|
1461
|
-
const l = c && u ? u : [e], g = [];
|
|
1462
|
-
for (const d of l) {
|
|
1463
|
-
const { left: f, top: w, width: h, height: p, angle: C, flipX: _, flipY: I, skewX: M, skewY: D } = d, S = l.indexOf(d), y = L({ unitId: s, subUnitId: a, drawingId: o }, c ? S : void 0), b = r.getObject(y);
|
|
1464
|
-
if (b != null) {
|
|
1465
|
-
b.transformByState({ left: f, top: w, width: h, height: p, angle: C, flipX: _, flipY: I, skewX: M, skewY: D });
|
|
1466
|
-
continue;
|
|
1467
|
-
}
|
|
1468
|
-
const O = this._drawingManagerService.getDrawingOrder(s, a), R = O.indexOf(o), B = { ...d, zIndex: R === -1 ? O.length - 1 : R };
|
|
1469
|
-
if (r.getObject(y))
|
|
1470
|
-
continue;
|
|
1471
|
-
B.printable = !1;
|
|
1472
|
-
const P = new dt(y, B);
|
|
1473
|
-
this._drawingManagerService.getDrawingVisible() && (r.addObject(P, Ne), this._drawingManagerService.getDrawingEditable() && i.allowTransform !== !1 && r.attachTransformerTo(P), n && rt({ drawingId: n, unitId: s, subUnitId: a }, P, r, this._drawingManagerService), g.push(P));
|
|
1474
|
-
}
|
|
1475
|
-
return g;
|
|
1476
|
-
}
|
|
1477
|
-
renderDrawing(i, r) {
|
|
1478
|
-
const e = this._drawingManagerService.getDrawingByParam(i);
|
|
1479
|
-
if (e != null && e.drawingType === q.DRAWING_IMAGE)
|
|
1480
|
-
return this.renderImages(e, r);
|
|
1481
|
-
}
|
|
1482
|
-
previewImage(i, r, e, t) {
|
|
1483
|
-
this._galleryService.open({
|
|
1484
|
-
images: [r],
|
|
1485
|
-
onOpenChange: (n) => {
|
|
1486
|
-
n || this._galleryService.close();
|
|
1487
|
-
}
|
|
1488
|
-
});
|
|
1489
|
-
}
|
|
1490
|
-
_adjustImageSize(i, r, e, t) {
|
|
1491
|
-
if (i <= e && r <= t)
|
|
1492
|
-
return {
|
|
1493
|
-
width: i,
|
|
1494
|
-
height: r
|
|
1495
|
-
};
|
|
1496
|
-
const n = e / i, s = t / r, a = Math.min(n, s);
|
|
1497
|
-
return {
|
|
1498
|
-
width: Math.floor(i * a),
|
|
1499
|
-
height: Math.floor(r * a)
|
|
1500
|
-
};
|
|
1501
|
-
}
|
|
1502
|
-
};
|
|
1503
|
-
Ae = Rr([
|
|
1504
|
-
me(0, ne),
|
|
1505
|
-
me(1, ut),
|
|
1506
|
-
me(2, Ft),
|
|
1507
|
-
me(3, Ut),
|
|
1508
|
-
me(4, $e)
|
|
1509
|
-
], Ae);
|
|
1510
|
-
var Mr = Object.getOwnPropertyDescriptor, Or = (i, r, e, t) => {
|
|
1511
|
-
for (var n = t > 1 ? void 0 : t ? Mr(r, e) : r, s = i.length - 1, a; s >= 0; s--)
|
|
1512
|
-
(a = i[s]) && (n = a(n) || n);
|
|
1513
|
-
return n;
|
|
1514
|
-
}, ae = (i, r) => (e, t) => r(e, t, i);
|
|
1515
|
-
let He = class extends ke {
|
|
1516
|
-
constructor(i, r, e, t, n, s, a) {
|
|
1517
|
-
super(), this._commandService = i, this._renderManagerService = r, this._drawingManagerService = e, this._dialogService = t, this._imageIoService = n, this._currentUniverService = s, this._drawingRenderService = a, this._initialize();
|
|
1518
|
-
}
|
|
1519
|
-
dispose() {
|
|
1520
|
-
super.dispose();
|
|
1521
|
-
}
|
|
1522
|
-
_initialize() {
|
|
1523
|
-
this._drawingAddListener(), this._commandExecutedListener(), this._imageUpdateListener();
|
|
1524
|
-
}
|
|
1525
|
-
_commandExecutedListener() {
|
|
1526
|
-
this.disposeWithMe(
|
|
1527
|
-
this._commandService.onCommandExecuted((i) => {
|
|
1528
|
-
if (i.id === pt.id) {
|
|
1529
|
-
const r = i.params;
|
|
1530
|
-
if (r == null)
|
|
1531
|
-
return;
|
|
1532
|
-
this._resetImageSize(r);
|
|
1533
|
-
}
|
|
1534
|
-
})
|
|
1535
|
-
);
|
|
1536
|
-
}
|
|
1537
|
-
_getSceneAndTransformerByDrawingSearch(i) {
|
|
1538
|
-
if (i == null)
|
|
1539
|
-
return;
|
|
1540
|
-
const r = this._renderManagerService.getRenderById(i), e = r == null ? void 0 : r.scene;
|
|
1541
|
-
if (e == null)
|
|
1542
|
-
return null;
|
|
1543
|
-
const t = e.getTransformerByCreate();
|
|
1544
|
-
return { scene: e, transformer: t };
|
|
1545
|
-
}
|
|
1546
|
-
_resetImageSize(i) {
|
|
1547
|
-
const r = [], e = [];
|
|
1548
|
-
i.forEach((t) => {
|
|
1549
|
-
const { unitId: n, subUnitId: s, drawingId: a } = t, o = this._getSceneAndTransformerByDrawingSearch(n);
|
|
1550
|
-
if (o == null)
|
|
1551
|
-
return;
|
|
1552
|
-
const { scene: c } = o, u = L({ unitId: n, subUnitId: s, drawingId: a }), l = c.getObject(u);
|
|
1553
|
-
if (l == null)
|
|
1554
|
-
return !0;
|
|
1555
|
-
const g = this._drawingManagerService.getDrawingByParam(t);
|
|
1556
|
-
if (g == null)
|
|
1557
|
-
return !0;
|
|
1558
|
-
if (g.drawingType !== q.DRAWING_IMAGE)
|
|
1559
|
-
return;
|
|
1560
|
-
l.resetSize();
|
|
1561
|
-
const { width: d, height: f } = l.getNativeSize();
|
|
1562
|
-
e.includes(c) === !1 && e.push(c), r.push({
|
|
1563
|
-
...g,
|
|
1564
|
-
transform: {
|
|
1565
|
-
...g.transform,
|
|
1566
|
-
height: f,
|
|
1567
|
-
width: d,
|
|
1568
|
-
angle: 0
|
|
1569
|
-
},
|
|
1570
|
-
srcRect: null,
|
|
1571
|
-
prstGeom: null
|
|
1572
|
-
});
|
|
1573
|
-
}), this._drawingManagerService.featurePluginUpdateNotification(r), e.forEach((t) => {
|
|
1574
|
-
t.getTransformerByCreate().refreshControls().changeNotification();
|
|
1575
|
-
}), this._commandService.syncExecuteCommand(Ee.id, i);
|
|
1576
|
-
}
|
|
1577
|
-
_drawingAddListener() {
|
|
1578
|
-
this.disposeWithMe(
|
|
1579
|
-
this._drawingManagerService.add$.pipe(
|
|
1580
|
-
er(33),
|
|
1581
|
-
et((i) => i.length > 0),
|
|
1582
|
-
tt((i) => i.flat()),
|
|
1583
|
-
tt((i) => {
|
|
1584
|
-
const r = /* @__PURE__ */ new Map();
|
|
1585
|
-
for (const e of i)
|
|
1586
|
-
r.set(`${e.unitId}|${e.subUnitId}|${e.drawingId}`, e);
|
|
1587
|
-
return [...r.values()];
|
|
1588
|
-
}),
|
|
1589
|
-
et((i) => i.length > 0)
|
|
1590
|
-
).subscribe((i) => {
|
|
1591
|
-
this._insertImages(i);
|
|
1592
|
-
})
|
|
1593
|
-
);
|
|
1594
|
-
}
|
|
1595
|
-
_insertImages(i) {
|
|
1596
|
-
i.forEach(async (r) => {
|
|
1597
|
-
var c;
|
|
1598
|
-
const { unitId: e, subUnitId: t } = r, n = this._getSceneAndTransformerByDrawingSearch(e), s = (c = mt(this._currentUniverService, e)) == null ? void 0 : c.subUnitId;
|
|
1599
|
-
if (n == null || s !== t)
|
|
1600
|
-
return;
|
|
1601
|
-
const a = this._drawingManagerService.getDrawingByParam(r);
|
|
1602
|
-
if (a == null)
|
|
1603
|
-
return;
|
|
1604
|
-
const o = await this._drawingRenderService.renderImages(a, n.scene);
|
|
1605
|
-
if (this._drawingManagerService.refreshTransform([a]), !(o == null || o.length === 0))
|
|
1606
|
-
for (const u of o)
|
|
1607
|
-
this._addHoverForImage(u), this._addDialogForImage(u);
|
|
1608
|
-
});
|
|
1609
|
-
}
|
|
1610
|
-
_imageUpdateListener() {
|
|
1611
|
-
this.disposeWithMe(
|
|
1612
|
-
this._drawingManagerService.update$.subscribe((i) => {
|
|
1613
|
-
i.forEach((r) => {
|
|
1614
|
-
const { unitId: e, subUnitId: t, drawingId: n } = r, s = this._drawingManagerService.getDrawingByParam(r);
|
|
1615
|
-
if (s == null)
|
|
1616
|
-
return;
|
|
1617
|
-
const { transform: a, drawingType: o, srcRect: c, prstGeom: u, source: l, imageSourceType: g } = s;
|
|
1618
|
-
if (o !== q.DRAWING_IMAGE)
|
|
1619
|
-
return;
|
|
1620
|
-
const d = this._getSceneAndTransformerByDrawingSearch(e);
|
|
1621
|
-
if (d == null)
|
|
1622
|
-
return;
|
|
1623
|
-
const { scene: f, transformer: w } = d;
|
|
1624
|
-
if (a == null)
|
|
1625
|
-
return !0;
|
|
1626
|
-
const h = L({ unitId: e, subUnitId: t, drawingId: n }), p = f.getObject(h);
|
|
1627
|
-
if (p == null)
|
|
1628
|
-
return !0;
|
|
1629
|
-
p.setSrcRect(c), p.setPrstGeom(u), l != null && l.length > 0 && (g === Ye.BASE64 || g === Ye.URL) && p.changeSource(l);
|
|
1630
|
-
});
|
|
1631
|
-
})
|
|
1632
|
-
);
|
|
1633
|
-
}
|
|
1634
|
-
_addHoverForImage(i) {
|
|
1635
|
-
this.disposeWithMe(
|
|
1636
|
-
ve(
|
|
1637
|
-
i.onPointerEnter$.subscribeEvent(() => {
|
|
1638
|
-
i.cursor = Pe.GRAB;
|
|
1639
|
-
})
|
|
1640
|
-
)
|
|
1641
|
-
), this.disposeWithMe(
|
|
1642
|
-
ve(
|
|
1643
|
-
i.onPointerLeave$.subscribeEvent(() => {
|
|
1644
|
-
i.cursor = Pe.DEFAULT;
|
|
1645
|
-
})
|
|
1646
|
-
)
|
|
1647
|
-
);
|
|
1648
|
-
}
|
|
1649
|
-
_addDialogForImage(i) {
|
|
1650
|
-
this.disposeWithMe(
|
|
1651
|
-
ve(
|
|
1652
|
-
i.onDblclick$.subscribeEvent(() => {
|
|
1653
|
-
const r = `${i.oKey}-viewer-dialog`;
|
|
1654
|
-
this._drawingRenderService.previewImage(r, i.getNative().src, i.getNativeSize().width, i.getNativeSize().height);
|
|
1655
|
-
})
|
|
1656
|
-
)
|
|
1657
|
-
);
|
|
1658
|
-
}
|
|
1659
|
-
};
|
|
1660
|
-
He = Or([
|
|
1661
|
-
ae(0, ce),
|
|
1662
|
-
ae(1, ge),
|
|
1663
|
-
ae(2, ne),
|
|
1664
|
-
ae(3, Kt),
|
|
1665
|
-
ae(4, ut),
|
|
1666
|
-
ae(5, $e),
|
|
1667
|
-
ae(6, Le(Ae))
|
|
1668
|
-
], He);
|
|
1669
|
-
var Dr = Object.getOwnPropertyDescriptor, Tr = (i, r, e, t) => {
|
|
1670
|
-
for (var n = t > 1 ? void 0 : t ? Dr(r, e) : r, s = i.length - 1, a; s >= 0; s--)
|
|
1671
|
-
(a = i[s]) && (n = a(n) || n);
|
|
1672
|
-
return n;
|
|
1673
|
-
}, st = (i, r) => (e, t) => r(e, t, i), we;
|
|
1674
|
-
let ot = (we = class extends At {
|
|
1675
|
-
constructor(i = it, r, e) {
|
|
1676
|
-
super(), this._config = i, this._injector = r, this._configService = e;
|
|
1677
|
-
const { menu: t, ...n } = Ht(
|
|
1678
|
-
{},
|
|
1679
|
-
it,
|
|
1680
|
-
this._config
|
|
1681
|
-
);
|
|
1682
|
-
t && this._configService.setConfig("menu", t, { merge: !0 }), this._configService.setConfig(nr, n);
|
|
1683
|
-
}
|
|
1684
|
-
onStarting() {
|
|
1685
|
-
this._initDependencies();
|
|
1686
|
-
}
|
|
1687
|
-
onRendered() {
|
|
1688
|
-
this._injector.get(xe), this._injector.get(Ue), this._injector.get(je), this._injector.get(He);
|
|
1689
|
-
}
|
|
1690
|
-
_initDependencies() {
|
|
1691
|
-
[
|
|
1692
|
-
[Ae],
|
|
1693
|
-
[xe],
|
|
1694
|
-
[Ue],
|
|
1695
|
-
[je],
|
|
1696
|
-
[He]
|
|
1697
|
-
].forEach((r) => this._injector.add(r));
|
|
1698
|
-
}
|
|
1699
|
-
}, Z(we, "pluginName", "UNIVER_DRAWING_UI_PLUGIN"), Z(we, "packageName", nt.name), Z(we, "version", nt.version), we);
|
|
1700
|
-
ot = Tr([
|
|
1701
|
-
st(1, Le(xt)),
|
|
1702
|
-
st(2, jt)
|
|
1703
|
-
], ot);
|
|
1704
|
-
const Er = (i) => {
|
|
1705
|
-
const r = A(ce), e = A(re), { alignShow: t } = i, [n, s] = j(T.default), a = [
|
|
1706
|
-
{
|
|
1707
|
-
label: e.t("image-panel.align.default"),
|
|
1708
|
-
value: T.default
|
|
1709
|
-
},
|
|
1710
|
-
{
|
|
1711
|
-
options: [
|
|
1712
|
-
{
|
|
1713
|
-
label: e.t("image-panel.align.left"),
|
|
1714
|
-
value: T.left
|
|
1715
|
-
},
|
|
1716
|
-
{
|
|
1717
|
-
label: e.t("image-panel.align.center"),
|
|
1718
|
-
value: T.center
|
|
1719
|
-
},
|
|
1720
|
-
{
|
|
1721
|
-
label: e.t("image-panel.align.right"),
|
|
1722
|
-
value: T.right
|
|
1723
|
-
}
|
|
1724
|
-
]
|
|
1725
|
-
},
|
|
1726
|
-
{
|
|
1727
|
-
options: [
|
|
1728
|
-
{
|
|
1729
|
-
label: e.t("image-panel.align.top"),
|
|
1730
|
-
value: T.top
|
|
1731
|
-
},
|
|
1732
|
-
{
|
|
1733
|
-
label: e.t("image-panel.align.middle"),
|
|
1734
|
-
value: T.middle
|
|
1735
|
-
},
|
|
1736
|
-
{
|
|
1737
|
-
label: e.t("image-panel.align.bottom"),
|
|
1738
|
-
value: T.bottom
|
|
1739
|
-
}
|
|
1740
|
-
]
|
|
1741
|
-
},
|
|
1742
|
-
{
|
|
1743
|
-
options: [
|
|
1744
|
-
{
|
|
1745
|
-
label: e.t("image-panel.align.horizon"),
|
|
1746
|
-
value: T.horizon
|
|
1747
|
-
},
|
|
1748
|
-
{
|
|
1749
|
-
label: e.t("image-panel.align.vertical"),
|
|
1750
|
-
value: T.vertical
|
|
1751
|
-
}
|
|
1752
|
-
]
|
|
1753
|
-
}
|
|
1754
|
-
];
|
|
1755
|
-
function o(c) {
|
|
1756
|
-
s(c), r.executeCommand(Ke.id, {
|
|
1757
|
-
alignType: c
|
|
1758
|
-
});
|
|
1759
|
-
}
|
|
1760
|
-
return /* @__PURE__ */ N(
|
|
1761
|
-
"div",
|
|
1762
|
-
{
|
|
1763
|
-
className: Q("univer-relative univer-w-full", {
|
|
1764
|
-
"univer-hidden": !t
|
|
1765
|
-
}),
|
|
1766
|
-
children: [
|
|
1767
|
-
/* @__PURE__ */ v(
|
|
1768
|
-
"header",
|
|
1769
|
-
{
|
|
1770
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1771
|
-
children: /* @__PURE__ */ v("div", { children: e.t("image-panel.align.title") })
|
|
1772
|
-
}
|
|
1773
|
-
),
|
|
1774
|
-
/* @__PURE__ */ v("div", { className: "univer-relative univer-mt-2.5 univer-flex univer-h-full", children: /* @__PURE__ */ v(
|
|
1775
|
-
"div",
|
|
1776
|
-
{
|
|
1777
|
-
className: "univer-w-full univer-text-gray-900 dark:!univer-text-white",
|
|
1778
|
-
children: /* @__PURE__ */ v(ht, { value: n, options: a, onChange: o })
|
|
1779
|
-
}
|
|
1780
|
-
) })
|
|
1781
|
-
]
|
|
1782
|
-
}
|
|
1783
|
-
);
|
|
1784
|
-
}, Nr = (i) => {
|
|
1785
|
-
const { arrangeShow: r, drawings: e } = i, t = A(re), n = A(ne), [s, a] = j(e);
|
|
1786
|
-
Ce(() => {
|
|
1787
|
-
const c = n.focus$.subscribe((u) => {
|
|
1788
|
-
a(u);
|
|
1789
|
-
});
|
|
1790
|
-
return () => {
|
|
1791
|
-
c.unsubscribe();
|
|
1792
|
-
};
|
|
1793
|
-
}, []);
|
|
1794
|
-
const o = (c) => {
|
|
1795
|
-
const u = s[0].unitId, l = s[0].subUnitId, g = s.map((d) => d.drawingId);
|
|
1796
|
-
n.featurePluginOrderUpdateNotification({ unitId: u, subUnitId: l, drawingIds: g, arrangeType: c });
|
|
1797
|
-
};
|
|
1798
|
-
return /* @__PURE__ */ N(
|
|
1799
|
-
"div",
|
|
1800
|
-
{
|
|
1801
|
-
className: Q("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", {
|
|
1802
|
-
"univer-hidden": !r
|
|
1803
|
-
}),
|
|
1804
|
-
children: [
|
|
1805
|
-
/* @__PURE__ */ v(
|
|
1806
|
-
"header",
|
|
1807
|
-
{
|
|
1808
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1809
|
-
children: /* @__PURE__ */ v("div", { children: t.t("image-panel.arrange.title") })
|
|
1810
|
-
}
|
|
1811
|
-
),
|
|
1812
|
-
/* @__PURE__ */ N("div", { className: "univer-grid univer-grid-cols-2 univer-gap-2", children: [
|
|
1813
|
-
/* @__PURE__ */ N(se, { onClick: () => {
|
|
1814
|
-
o(Ie.forward);
|
|
1815
|
-
}, children: [
|
|
1816
|
-
/* @__PURE__ */ v(bt, {}),
|
|
1817
|
-
t.t("image-panel.arrange.forward")
|
|
1818
|
-
] }),
|
|
1819
|
-
/* @__PURE__ */ N(se, { onClick: () => {
|
|
1820
|
-
o(Ie.backward);
|
|
1821
|
-
}, children: [
|
|
1822
|
-
/* @__PURE__ */ v(It, {}),
|
|
1823
|
-
t.t("image-panel.arrange.backward")
|
|
1824
|
-
] }),
|
|
1825
|
-
/* @__PURE__ */ N(se, { onClick: () => {
|
|
1826
|
-
o(Ie.front);
|
|
1827
|
-
}, children: [
|
|
1828
|
-
/* @__PURE__ */ v(yt, {}),
|
|
1829
|
-
t.t("image-panel.arrange.front")
|
|
1830
|
-
] }),
|
|
1831
|
-
/* @__PURE__ */ N(se, { onClick: () => {
|
|
1832
|
-
o(Ie.back);
|
|
1833
|
-
}, children: [
|
|
1834
|
-
/* @__PURE__ */ v(vt, {}),
|
|
1835
|
-
t.t("image-panel.arrange.back")
|
|
1836
|
-
] })
|
|
1837
|
-
] })
|
|
1838
|
-
]
|
|
1839
|
-
}
|
|
1840
|
-
);
|
|
1841
|
-
}, Pr = (i) => {
|
|
1842
|
-
const r = A(re), e = A(ge), t = A(ne), { hasGroup: n, drawings: s } = i, [a, o] = j(!1), [c, u] = j(!0), [l, g] = j(!0), d = () => {
|
|
1843
|
-
const h = t.getFocusDrawings(), { unitId: p, subUnitId: C } = h[0], _ = Lt(10), I = Vt(0, 0, h.map((S) => S.transform || {})), M = {
|
|
1844
|
-
unitId: p,
|
|
1845
|
-
subUnitId: C,
|
|
1846
|
-
drawingId: _,
|
|
1847
|
-
drawingType: q.DRAWING_GROUP,
|
|
1848
|
-
transform: I,
|
|
1849
|
-
groupBaseBound: {
|
|
1850
|
-
left: I.left,
|
|
1851
|
-
top: I.top,
|
|
1852
|
-
width: I.width,
|
|
1853
|
-
height: I.height
|
|
1854
|
-
}
|
|
1855
|
-
}, D = h.map((S) => {
|
|
1856
|
-
const y = S.transform || { left: 0, top: 0 }, { unitId: b, subUnitId: O, drawingId: R } = S;
|
|
1857
|
-
return {
|
|
1858
|
-
unitId: b,
|
|
1859
|
-
subUnitId: O,
|
|
1860
|
-
drawingId: R,
|
|
1861
|
-
transform: {
|
|
1862
|
-
...y
|
|
1863
|
-
// left: transform.left! - groupTransform.left,
|
|
1864
|
-
// top: transform.top! - groupTransform.top,
|
|
1865
|
-
},
|
|
1866
|
-
groupId: _
|
|
1867
|
-
};
|
|
1868
|
-
});
|
|
1869
|
-
t.featurePluginGroupUpdateNotification([{
|
|
1870
|
-
parent: M,
|
|
1871
|
-
children: D
|
|
1872
|
-
}]);
|
|
1873
|
-
}, f = (h) => {
|
|
1874
|
-
if (h.drawingType !== q.DRAWING_GROUP)
|
|
1875
|
-
return;
|
|
1876
|
-
const { unitId: p, subUnitId: C, drawingId: _, transform: I = { width: 0, height: 0 }, groupBaseBound: M } = h;
|
|
1877
|
-
if (I == null)
|
|
1878
|
-
return;
|
|
1879
|
-
const D = t.getDrawingsByGroup({ unitId: p, subUnitId: C, drawingId: _ });
|
|
1880
|
-
if (D.length === 0)
|
|
1881
|
-
return;
|
|
1882
|
-
const S = D.map((y) => {
|
|
1883
|
-
const { transform: b } = y, { unitId: O, subUnitId: R, drawingId: B } = y, P = Gt(b || {}, I, I.width || 0, I.height || 0, M);
|
|
1884
|
-
return {
|
|
1885
|
-
unitId: O,
|
|
1886
|
-
subUnitId: R,
|
|
1887
|
-
drawingId: B,
|
|
1888
|
-
transform: {
|
|
1889
|
-
...b,
|
|
1890
|
-
...P
|
|
1891
|
-
},
|
|
1892
|
-
groupId: void 0
|
|
1893
|
-
};
|
|
1894
|
-
});
|
|
1895
|
-
return {
|
|
1896
|
-
parent: h,
|
|
1897
|
-
children: S
|
|
1898
|
-
};
|
|
1899
|
-
}, w = () => {
|
|
1900
|
-
const p = t.getFocusDrawings().map(
|
|
1901
|
-
(C) => f(C)
|
|
1902
|
-
).filter((C) => C != null);
|
|
1903
|
-
p.length !== 0 && t.featurePluginUngroupUpdateNotification(p);
|
|
1904
|
-
};
|
|
1905
|
-
return Ce(() => {
|
|
1906
|
-
const h = s[0];
|
|
1907
|
-
if (h == null)
|
|
1908
|
-
return;
|
|
1909
|
-
const { unitId: p } = h, C = e.getRenderById(p), _ = C == null ? void 0 : C.scene;
|
|
1910
|
-
if (_ == null)
|
|
1911
|
-
return;
|
|
1912
|
-
const I = _.getTransformerByCreate(), M = I.clearControl$.subscribe((S) => {
|
|
1913
|
-
S === !0 && o(!1);
|
|
1914
|
-
}), D = I.changeStart$.subscribe((S) => {
|
|
1915
|
-
const { objects: y } = S, b = Ve(y, t), O = b.filter((F) => (F == null ? void 0 : F.drawingType) === q.DRAWING_GROUP);
|
|
1916
|
-
let R = !1, B = !1;
|
|
1917
|
-
b.length > 1 && (R = !0), O.length > 0 && (B = !0), o(R || B), u(R), g(B);
|
|
1918
|
-
});
|
|
1919
|
-
return () => {
|
|
1920
|
-
D.unsubscribe(), M.unsubscribe();
|
|
1921
|
-
};
|
|
1922
|
-
}, []), /* @__PURE__ */ N(
|
|
1923
|
-
"div",
|
|
1924
|
-
{
|
|
1925
|
-
className: Q("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", {
|
|
1926
|
-
"univer-hidden": n === !0 && a === !1 || n === !1
|
|
1927
|
-
}),
|
|
1928
|
-
children: [
|
|
1929
|
-
/* @__PURE__ */ v(
|
|
1930
|
-
"header",
|
|
1931
|
-
{
|
|
1932
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1933
|
-
children: /* @__PURE__ */ v("div", { children: r.t("image-panel.group.title") })
|
|
1934
|
-
}
|
|
1935
|
-
),
|
|
1936
|
-
/* @__PURE__ */ N("div", { className: "univer-flex univer-items-center univer-justify-center univer-gap-2", children: [
|
|
1937
|
-
/* @__PURE__ */ N(
|
|
1938
|
-
se,
|
|
1939
|
-
{
|
|
1940
|
-
className: Q({
|
|
1941
|
-
"univer-hidden": !c
|
|
1942
|
-
}),
|
|
1943
|
-
onClick: d,
|
|
1944
|
-
children: [
|
|
1945
|
-
/* @__PURE__ */ v(Ct, {}),
|
|
1946
|
-
r.t("image-panel.group.group")
|
|
1947
|
-
]
|
|
1948
|
-
}
|
|
1949
|
-
),
|
|
1950
|
-
/* @__PURE__ */ N(
|
|
1951
|
-
se,
|
|
1952
|
-
{
|
|
1953
|
-
className: Q({
|
|
1954
|
-
"univer-hidden": !l
|
|
1955
|
-
}),
|
|
1956
|
-
onClick: w,
|
|
1957
|
-
children: [
|
|
1958
|
-
/* @__PURE__ */ v(Rt, {}),
|
|
1959
|
-
r.t("image-panel.group.unGroup")
|
|
1960
|
-
]
|
|
1961
|
-
}
|
|
1962
|
-
)
|
|
1963
|
-
] })
|
|
1964
|
-
]
|
|
1965
|
-
}
|
|
1966
|
-
);
|
|
1967
|
-
}, Oe = 20, De = 20, ct = [-360, 360], Te = 300, Br = (i) => {
|
|
1968
|
-
var ze;
|
|
1969
|
-
const r = A(re), e = A(ne), t = A(ge), { drawings: n, transformShow: s } = i, a = n[0];
|
|
1970
|
-
if (a == null)
|
|
1971
|
-
return;
|
|
1972
|
-
const o = a.transform;
|
|
1973
|
-
if (o == null)
|
|
1974
|
-
return;
|
|
1975
|
-
const { unitId: c, subUnitId: u, drawingId: l, drawingType: g } = a, d = t.getRenderById(c), f = d == null ? void 0 : d.scene;
|
|
1976
|
-
if (f == null)
|
|
1977
|
-
return;
|
|
1978
|
-
const w = (ze = f.getEngine()) == null ? void 0 : ze.activeScene;
|
|
1979
|
-
if (w == null)
|
|
1980
|
-
return;
|
|
1981
|
-
const h = f.getTransformerByCreate(), {
|
|
1982
|
-
width: p = 0,
|
|
1983
|
-
height: C = 0,
|
|
1984
|
-
left: _ = 0,
|
|
1985
|
-
top: I = 0,
|
|
1986
|
-
angle: M = 0
|
|
1987
|
-
} = o, [D, S] = j(p), [y, b] = j(C), [O, R] = j(_), [B, P] = j(I), [F, X] = j(M), [$, Se] = j(h.keepRatio), te = (m, E, H, k) => {
|
|
1988
|
-
const { width: x, height: J } = w, { ancestorLeft: G, ancestorTop: W } = f;
|
|
1989
|
-
let K = m, ie = E, he = H, fe = k;
|
|
1990
|
-
return m + G < 0 && (K = -G), E + W < 0 && (ie = -W), he = x - K - G, he < Oe && (he = Oe), fe = J - ie - W, fe < De && (fe = De), m + he + G > x && (K = x - H - G), E + fe + W > J && (ie = J - k - W), {
|
|
1991
|
-
limitLeft: K,
|
|
1992
|
-
limitTop: ie,
|
|
1993
|
-
limitWidth: he,
|
|
1994
|
-
limitHeight: fe
|
|
1995
|
-
};
|
|
1996
|
-
}, V = (m) => {
|
|
1997
|
-
const { objects: E } = m, H = Ve(E, e);
|
|
1998
|
-
if (H.length !== 1)
|
|
1999
|
-
return;
|
|
2000
|
-
const k = H[0];
|
|
2001
|
-
if (k == null)
|
|
2002
|
-
return;
|
|
2003
|
-
const { transform: x } = k;
|
|
2004
|
-
if (x == null)
|
|
2005
|
-
return;
|
|
2006
|
-
const {
|
|
2007
|
-
width: J,
|
|
2008
|
-
height: G,
|
|
2009
|
-
left: W,
|
|
2010
|
-
top: K,
|
|
2011
|
-
angle: ie
|
|
2012
|
-
} = x;
|
|
2013
|
-
J != null && S(J), G != null && b(G), W != null && R(W), K != null && P(K), ie != null && X(ie);
|
|
2014
|
-
};
|
|
2015
|
-
Ce(() => {
|
|
2016
|
-
const m = [
|
|
2017
|
-
h.changeStart$.subscribe((E) => {
|
|
2018
|
-
V(E);
|
|
2019
|
-
}),
|
|
2020
|
-
h.changing$.subscribe((E) => {
|
|
2021
|
-
V(E);
|
|
2022
|
-
}),
|
|
2023
|
-
h.changeEnd$.subscribe((E) => {
|
|
2024
|
-
V(E);
|
|
2025
|
-
}),
|
|
2026
|
-
e.focus$.subscribe((E) => {
|
|
2027
|
-
if (E.length !== 1)
|
|
2028
|
-
return;
|
|
2029
|
-
const H = e.getDrawingByParam(E[0]);
|
|
2030
|
-
if (H == null)
|
|
2031
|
-
return;
|
|
2032
|
-
const k = H.transform;
|
|
2033
|
-
if (k == null)
|
|
2034
|
-
return;
|
|
2035
|
-
const {
|
|
2036
|
-
width: x,
|
|
2037
|
-
height: J,
|
|
2038
|
-
left: G,
|
|
2039
|
-
top: W,
|
|
2040
|
-
angle: K
|
|
2041
|
-
} = k;
|
|
2042
|
-
x != null && S(x), J != null && b(J), G != null && R(G), W != null && P(W), K != null && X(K);
|
|
2043
|
-
})
|
|
2044
|
-
];
|
|
2045
|
-
return () => {
|
|
2046
|
-
m.forEach((E) => E.unsubscribe());
|
|
2047
|
-
};
|
|
2048
|
-
}, []);
|
|
2049
|
-
const de = be((m) => {
|
|
2050
|
-
if (m == null)
|
|
2051
|
-
return;
|
|
2052
|
-
const { limitWidth: E, limitHeight: H } = te(O, B, m, y);
|
|
2053
|
-
m = Math.min(m, E);
|
|
2054
|
-
const k = { unitId: c, subUnitId: u, drawingId: l, drawingType: g, transform: { width: m } };
|
|
2055
|
-
if ($) {
|
|
2056
|
-
let x = m / D * y;
|
|
2057
|
-
if (x = Math.max(x, De), x > H)
|
|
2058
|
-
return;
|
|
2059
|
-
b(x), k.transform.height = x;
|
|
2060
|
-
}
|
|
2061
|
-
S(m), e.featurePluginUpdateNotification([k]), h.refreshControls().changeNotification();
|
|
2062
|
-
}, Te), Ot = be((m) => {
|
|
2063
|
-
if (m == null)
|
|
2064
|
-
return;
|
|
2065
|
-
const { limitHeight: E, limitWidth: H } = te(O, B, D, m);
|
|
2066
|
-
m = Math.min(m, E);
|
|
2067
|
-
const k = { unitId: c, subUnitId: u, drawingId: l, drawingType: g, transform: { height: m } };
|
|
2068
|
-
if ($) {
|
|
2069
|
-
let x = m / y * D;
|
|
2070
|
-
if (x = Math.max(x, Oe), x > H)
|
|
2071
|
-
return;
|
|
2072
|
-
S(x), k.transform.width = x;
|
|
2073
|
-
}
|
|
2074
|
-
b(m), e.featurePluginUpdateNotification([k]), h.refreshControls().changeNotification();
|
|
2075
|
-
}, Te), Dt = be((m) => {
|
|
2076
|
-
if (m == null)
|
|
2077
|
-
return;
|
|
2078
|
-
const { limitLeft: E } = te(m, B, D, y);
|
|
2079
|
-
m = E;
|
|
2080
|
-
const H = { unitId: c, subUnitId: u, drawingId: l, drawingType: g, transform: { left: m } };
|
|
2081
|
-
R(m), e.featurePluginUpdateNotification([H]), h.refreshControls().changeNotification();
|
|
2082
|
-
}, Te), Tt = be((m) => {
|
|
2083
|
-
if (m == null)
|
|
2084
|
-
return;
|
|
2085
|
-
const { limitTop: E } = te(O, m, D, y);
|
|
2086
|
-
m = E;
|
|
2087
|
-
const H = { unitId: c, subUnitId: u, drawingId: l, drawingType: g, transform: { top: m } };
|
|
2088
|
-
P(m), e.featurePluginUpdateNotification([H]), h.refreshControls().changeNotification();
|
|
2089
|
-
}, Te), Et = (m) => {
|
|
2090
|
-
if (m == null)
|
|
2091
|
-
return;
|
|
2092
|
-
const E = { unitId: c, subUnitId: u, drawingId: l, drawingType: g, transform: { angle: m } };
|
|
2093
|
-
X(m), e.featurePluginUpdateNotification([E]), h.refreshControls().changeNotification();
|
|
2094
|
-
}, Nt = (m) => {
|
|
2095
|
-
Se(m), h.keepRatio = m;
|
|
2096
|
-
};
|
|
2097
|
-
return /* @__PURE__ */ N(
|
|
2098
|
-
"div",
|
|
2099
|
-
{
|
|
2100
|
-
className: Q("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", {
|
|
2101
|
-
"univer-hidden": !s
|
|
2102
|
-
}),
|
|
2103
|
-
children: [
|
|
2104
|
-
/* @__PURE__ */ v(
|
|
2105
|
-
"header",
|
|
2106
|
-
{
|
|
2107
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2108
|
-
children: /* @__PURE__ */ v("div", { children: r.t("image-panel.transform.title") })
|
|
2109
|
-
}
|
|
2110
|
-
),
|
|
2111
|
-
/* @__PURE__ */ N(
|
|
2112
|
-
"div",
|
|
2113
|
-
{
|
|
2114
|
-
className: "univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",
|
|
2115
|
-
children: [
|
|
2116
|
-
/* @__PURE__ */ N("div", { children: [
|
|
2117
|
-
/* @__PURE__ */ v("span", { children: r.t("image-panel.transform.width") }),
|
|
2118
|
-
/* @__PURE__ */ v(
|
|
2119
|
-
pe,
|
|
2120
|
-
{
|
|
2121
|
-
precision: 1,
|
|
2122
|
-
value: D,
|
|
2123
|
-
min: Oe,
|
|
2124
|
-
onChange: (m) => {
|
|
2125
|
-
de(m);
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
)
|
|
2129
|
-
] }),
|
|
2130
|
-
/* @__PURE__ */ N("div", { children: [
|
|
2131
|
-
/* @__PURE__ */ v("span", { children: r.t("image-panel.transform.height") }),
|
|
2132
|
-
/* @__PURE__ */ v(
|
|
2133
|
-
pe,
|
|
2134
|
-
{
|
|
2135
|
-
precision: 1,
|
|
2136
|
-
value: y,
|
|
2137
|
-
min: De,
|
|
2138
|
-
onChange: (m) => {
|
|
2139
|
-
Ot(m);
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2142
|
-
)
|
|
2143
|
-
] }),
|
|
2144
|
-
/* @__PURE__ */ N("div", { children: [
|
|
2145
|
-
/* @__PURE__ */ v("span", { children: r.t("image-panel.transform.lock") }),
|
|
2146
|
-
/* @__PURE__ */ v("div", { className: "univer-text-center", children: /* @__PURE__ */ v(Jt, { checked: $, onChange: Nt }) })
|
|
2147
|
-
] })
|
|
2148
|
-
]
|
|
2149
|
-
}
|
|
2150
|
-
),
|
|
2151
|
-
/* @__PURE__ */ N(
|
|
2152
|
-
"div",
|
|
2153
|
-
{
|
|
2154
|
-
className: "univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",
|
|
2155
|
-
children: [
|
|
2156
|
-
/* @__PURE__ */ N("div", { children: [
|
|
2157
|
-
/* @__PURE__ */ v("span", { children: r.t("image-panel.transform.x") }),
|
|
2158
|
-
/* @__PURE__ */ v(pe, { precision: 1, value: O, onChange: (m) => {
|
|
2159
|
-
Dt(m);
|
|
2160
|
-
} })
|
|
2161
|
-
] }),
|
|
2162
|
-
/* @__PURE__ */ N("div", { children: [
|
|
2163
|
-
/* @__PURE__ */ v("span", { children: r.t("image-panel.transform.y") }),
|
|
2164
|
-
/* @__PURE__ */ v(pe, { precision: 1, value: B, onChange: (m) => {
|
|
2165
|
-
Tt(m);
|
|
2166
|
-
} })
|
|
2167
|
-
] }),
|
|
2168
|
-
/* @__PURE__ */ N("div", { children: [
|
|
2169
|
-
/* @__PURE__ */ v("span", { children: r.t("image-panel.transform.rotate") }),
|
|
2170
|
-
/* @__PURE__ */ v(
|
|
2171
|
-
pe,
|
|
2172
|
-
{
|
|
2173
|
-
precision: 1,
|
|
2174
|
-
value: F,
|
|
2175
|
-
min: ct[0],
|
|
2176
|
-
max: ct[1],
|
|
2177
|
-
onChange: Et
|
|
2178
|
-
}
|
|
2179
|
-
)
|
|
2180
|
-
] })
|
|
2181
|
-
]
|
|
2182
|
-
}
|
|
2183
|
-
)
|
|
2184
|
-
]
|
|
2185
|
-
}
|
|
2186
|
-
);
|
|
2187
|
-
}, Ur = (i) => {
|
|
2188
|
-
const r = A(ce), e = A(re), { drawings: t, cropperShow: n } = i;
|
|
2189
|
-
if (t[0] == null)
|
|
2190
|
-
return;
|
|
2191
|
-
const [a, o] = j(U.FREE), c = ft(!1), u = [
|
|
2192
|
-
{
|
|
2193
|
-
label: e.t("image-panel.crop.mode"),
|
|
2194
|
-
value: U.FREE
|
|
2195
|
-
},
|
|
2196
|
-
{
|
|
2197
|
-
label: "1:1",
|
|
2198
|
-
value: U.R1_1
|
|
2199
|
-
},
|
|
2200
|
-
{
|
|
2201
|
-
label: "16:9",
|
|
2202
|
-
value: U.R16_9
|
|
2203
|
-
},
|
|
2204
|
-
{
|
|
2205
|
-
label: "9:16",
|
|
2206
|
-
value: U.R9_16
|
|
2207
|
-
},
|
|
2208
|
-
{
|
|
2209
|
-
label: "5:4",
|
|
2210
|
-
value: U.R5_4
|
|
2211
|
-
},
|
|
2212
|
-
{
|
|
2213
|
-
label: "4:5",
|
|
2214
|
-
value: U.R4_5
|
|
2215
|
-
},
|
|
2216
|
-
{
|
|
2217
|
-
label: "4:3",
|
|
2218
|
-
value: U.R4_3
|
|
2219
|
-
},
|
|
2220
|
-
{
|
|
2221
|
-
label: "3:4",
|
|
2222
|
-
value: U.R3_4
|
|
2223
|
-
},
|
|
2224
|
-
{
|
|
2225
|
-
label: "3:2",
|
|
2226
|
-
value: U.R3_2
|
|
2227
|
-
},
|
|
2228
|
-
{
|
|
2229
|
-
label: "2:3",
|
|
2230
|
-
value: U.R2_3
|
|
2231
|
-
}
|
|
2232
|
-
];
|
|
2233
|
-
Ce(() => {
|
|
2234
|
-
const d = r.onCommandExecuted((f) => {
|
|
2235
|
-
if (f.id === oe.id) {
|
|
2236
|
-
const w = f.params;
|
|
2237
|
-
w != null && w.isAuto || (c.current = !1);
|
|
2238
|
-
}
|
|
2239
|
-
});
|
|
2240
|
-
return () => {
|
|
2241
|
-
d == null || d.dispose();
|
|
2242
|
-
};
|
|
2243
|
-
}, []);
|
|
2244
|
-
function l(d) {
|
|
2245
|
-
o(d), c.current && r.executeCommand(Be.id, {
|
|
2246
|
-
cropType: d
|
|
2247
|
-
});
|
|
2248
|
-
}
|
|
2249
|
-
const g = (d) => {
|
|
2250
|
-
r.executeCommand(Be.id, {
|
|
2251
|
-
cropType: d
|
|
2252
|
-
}), c.current = !0;
|
|
2253
|
-
};
|
|
2254
|
-
return /* @__PURE__ */ N(
|
|
2255
|
-
"div",
|
|
2256
|
-
{
|
|
2257
|
-
className: Q("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", {
|
|
2258
|
-
"univer-hidden": !n
|
|
2259
|
-
}),
|
|
2260
|
-
children: [
|
|
2261
|
-
/* @__PURE__ */ v(
|
|
2262
|
-
"header",
|
|
2263
|
-
{
|
|
2264
|
-
className: "univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2265
|
-
children: /* @__PURE__ */ v("div", { children: e.t("image-panel.crop.title") })
|
|
2266
|
-
}
|
|
2267
|
-
),
|
|
2268
|
-
/* @__PURE__ */ N("div", { className: "univer-flex univer-items-center univer-justify-center univer-gap-2", children: [
|
|
2269
|
-
/* @__PURE__ */ N(se, { onClick: () => {
|
|
2270
|
-
g(a);
|
|
2271
|
-
}, children: [
|
|
2272
|
-
/* @__PURE__ */ v(_t, {}),
|
|
2273
|
-
e.t("image-panel.crop.start")
|
|
2274
|
-
] }),
|
|
2275
|
-
/* @__PURE__ */ v(ht, { value: a, options: u, onChange: l })
|
|
2276
|
-
] })
|
|
2277
|
-
]
|
|
2278
|
-
}
|
|
2279
|
-
);
|
|
2280
|
-
}, Wr = (i) => {
|
|
2281
|
-
const r = A(ne), e = A(ge), t = A(re), { drawings: n, hasArrange: s = !0, hasTransform: a = !0, hasAlign: o = !0, hasCropper: c = !0, hasGroup: u = !0 } = i, l = n[0];
|
|
2282
|
-
if (l == null)
|
|
2283
|
-
return;
|
|
2284
|
-
const { unitId: g } = l, d = e.getRenderById(g), f = d == null ? void 0 : d.scene;
|
|
2285
|
-
if (f == null)
|
|
2286
|
-
return;
|
|
2287
|
-
const w = f.getTransformerByCreate(), [h, p] = j(!0), [C, _] = j(!0), [I, M] = j(!1), [D, S] = j(!0), [y, b] = j(!1);
|
|
2288
|
-
return Ce(() => {
|
|
2289
|
-
const O = w.clearControl$.subscribe((P) => {
|
|
2290
|
-
P === !0 && (p(!1), _(!1), M(!1), S(!1), b(!0));
|
|
2291
|
-
}), R = w.changeStart$.subscribe((P) => {
|
|
2292
|
-
const { objects: F } = P, X = Ve(F, r);
|
|
2293
|
-
X.length === 0 ? (p(!1), _(!1), M(!1), S(!1), b(!0)) : X.length === 1 ? (p(!0), _(!0), M(!1), S(!0), b(!1)) : (p(!0), _(!1), M(!0), S(!1), b(!1));
|
|
2294
|
-
}), B = r.focus$.subscribe((P) => {
|
|
2295
|
-
P.length === 0 ? (p(!1), _(!1), M(!1), S(!1), b(!0)) : P.length === 1 ? (p(!0), _(!0), M(!1), S(!0), b(!1)) : (p(!0), _(!1), M(!0), S(!1), b(!1));
|
|
2296
|
-
});
|
|
2297
|
-
return () => {
|
|
2298
|
-
R.unsubscribe(), O.unsubscribe(), B.unsubscribe();
|
|
2299
|
-
};
|
|
2300
|
-
}, []), /* @__PURE__ */ N(zt, { children: [
|
|
2301
|
-
/* @__PURE__ */ v(
|
|
2302
|
-
"div",
|
|
2303
|
-
{
|
|
2304
|
-
className: Q("univer-h-full", {
|
|
2305
|
-
"univer-hidden": !y
|
|
2306
|
-
}),
|
|
2307
|
-
children: /* @__PURE__ */ v("div", { className: "univer-flex univer-h-full univer-items-center univer-justify-center", children: /* @__PURE__ */ v("span", { children: t.t("image-panel.null") }) })
|
|
2308
|
-
}
|
|
2309
|
-
),
|
|
2310
|
-
/* @__PURE__ */ v(Nr, { arrangeShow: s === !0 ? h : !1, drawings: n }),
|
|
2311
|
-
/* @__PURE__ */ v(Br, { transformShow: a === !0 ? C : !1, drawings: n }),
|
|
2312
|
-
/* @__PURE__ */ v(Er, { alignShow: o === !0 ? I : !1, drawings: n }),
|
|
2313
|
-
/* @__PURE__ */ v(Ur, { cropperShow: c === !0 ? D : !1, drawings: n }),
|
|
2314
|
-
/* @__PURE__ */ v(Pr, { hasGroup: u, drawings: n })
|
|
2315
|
-
] });
|
|
2316
|
-
};
|
|
2317
|
-
export {
|
|
2318
|
-
Be as AutoImageCropOperation,
|
|
2319
|
-
ir as COMPONENT_IMAGE_POPUP_MENU,
|
|
2320
|
-
oe as CloseImageCropOperation,
|
|
2321
|
-
Wr as DrawingCommonPanel,
|
|
2322
|
-
Ae as DrawingRenderService,
|
|
2323
|
-
Me as ImageCropperObject,
|
|
2324
|
-
wr as ImagePopupMenu,
|
|
2325
|
-
pt as ImageResetSizeOperation,
|
|
2326
|
-
Fe as OpenImageCropOperation,
|
|
2327
|
-
Ke as SetDrawingAlignOperation,
|
|
2328
|
-
ot as UniverDrawingUIPlugin,
|
|
2329
|
-
mt as getCurrentUnitInfo,
|
|
2330
|
-
Ve as getUpdateParams,
|
|
2331
|
-
rt as insertGroupObject
|
|
2332
|
-
};
|
|
1
|
+
import{ArrangeTypeEnum as e,CommandType as t,Disposable as n,DrawingTypeEnum as r,ICommandService as i,IConfigService as a,IURLImageService as o,IUniverInstanceService as s,ImageSourceType as c,Inject as l,Injector as u,LocaleService as d,Plugin as f,UniverInstanceType as p,checkIfMove as m,debounce as h,generateRandomId as g,merge as _,toDisposable as v}from"@univerjs/core";import{IDrawingManagerService as y,IImageIoService as b,ImageSourceType as x,SetDrawingSelectedOperation as S,getDrawingShapeKeyByDrawingSearch as C}from"@univerjs/drawing";import{CURSOR_TYPE as w,Canvas as T,DRAWING_OBJECT_LAYER_INDEX as E,DrawingGroupObject as D,Group as O,IRenderManagerService as k,Image as A,RENDER_CLASS_TYPE as j,Rect as M,Shape as N,Vector2 as P,degToRad as ee,getGroupState as te,precisionTo as ne,transformObjectOutOfGroup as re}from"@univerjs/engine-render";import{AutofillDoubleIcon as ie,BottomIcon as ae,CreateCopyIcon as oe,GroupIcon as se,MoreDownIcon as ce,MoveDownIcon as le,MoveUpIcon as ue,TopmostIcon as de,UngroupIcon as fe}from"@univerjs/icons";import{ComponentManager as pe,ContextMenuGroup as me,ContextMenuPosition as he,IDialogService as ge,IGalleryService as _e,IMenuManagerService as ve,IMessageService as ye,MenuItemType as F,useDependency as I}from"@univerjs/ui";import{Observable as be,bufferTime as xe,filter as Se,map as Ce,of as we,switchMap as Te}from"rxjs";import{Button as L,Checkbox as Ee,DropdownMenu as De,InputNumber as R,MessageType as Oe,Select as ke,borderClassName as Ae,clsx as z}from"@univerjs/design";import{useEffect as je,useRef as Me,useState as B}from"react";import{Fragment as Ne,jsx as V,jsxs as H}from"react/jsx-runtime";let U=function(e){return e.default=`0`,e.left=`1`,e.center=`2`,e.right=`3`,e.top=`4`,e.middle=`5`,e.bottom=`6`,e.horizon=`7`,e.vertical=`8`,e}({});const W={id:`sheet.operation.set-image-align`,type:t.OPERATION,handler:(e,t)=>!0},Pe={id:`sheet.operation.set-drawing-align-left`,type:t.OPERATION,handler:e=>e.get(i).syncExecuteCommand(W.id,{alignType:U.left})},Fe={id:`sheet.operation.set-drawing-align-center`,type:t.OPERATION,handler:e=>e.get(i).syncExecuteCommand(W.id,{alignType:U.center})},Ie={id:`sheet.operation.set-drawing-align-right`,type:t.OPERATION,handler:e=>e.get(i).syncExecuteCommand(W.id,{alignType:U.right})},Le={id:`sheet.operation.set-drawing-align-top`,type:t.OPERATION,handler:e=>e.get(i).syncExecuteCommand(W.id,{alignType:U.top})},Re={id:`sheet.operation.set-drawing-align-middle`,type:t.OPERATION,handler:e=>e.get(i).syncExecuteCommand(W.id,{alignType:U.middle})},ze={id:`sheet.operation.set-drawing-align-bottom`,type:t.OPERATION,handler:e=>e.get(i).syncExecuteCommand(W.id,{alignType:U.bottom})},Be={id:`sheet.operation.set-drawing-align-horizon`,type:t.OPERATION,handler:e=>e.get(i).syncExecuteCommand(W.id,{alignType:U.horizon})},Ve={id:`sheet.operation.set-drawing-align-vertical`,type:t.OPERATION,handler:e=>e.get(i).syncExecuteCommand(W.id,{alignType:U.vertical})},G={id:`drawing.operation.set-drawing-arrange`,type:t.OPERATION,handler:(e,t)=>{let n=e.get(y),{arrangeType:r}=t,i=t.drawings||n.getFocusDrawings(),{unitId:a,subUnitId:o}=i[0],s=i.map(e=>e.drawingId);return n.featurePluginOrderUpdateNotification({unitId:a,subUnitId:o,drawingIds:s,arrangeType:r}),!0}},He={id:`drawing.operation.set-drawing-arrange-front`,type:t.OPERATION,handler:t=>t.get(i).syncExecuteCommand(G.id,{arrangeType:e.front})},Ue={id:`drawing.operation.set-drawing-arrange-forward`,type:t.OPERATION,handler:t=>t.get(i).syncExecuteCommand(G.id,{arrangeType:e.forward})},We={id:`drawing.operation.set-drawing-arrange-back`,type:t.OPERATION,handler:t=>t.get(i).syncExecuteCommand(G.id,{arrangeType:e.back})},Ge={id:`drawing.operation.set-drawing-arrange-backward`,type:t.OPERATION,handler:t=>t.get(i).syncExecuteCommand(G.id,{arrangeType:e.backward})},Ke=[r.DRAWING_IMAGE,r.DRAWING_SHAPE,r.DRAWING_GROUP],K={id:`drawing.operation.set-drawing-group`,type:t.OPERATION,handler:(e,t)=>{let n=e.get(y),i=t.drawings||n.getFocusDrawings();if(i.length<2||!i.every(e=>Ke.includes(e.drawingType)))return!1;let{unitId:a,subUnitId:o}=i[0],s=g(10),c=te(0,0,i.map(e=>e.transform||{})),l={unitId:a,subUnitId:o,drawingId:s,drawingType:r.DRAWING_GROUP,transform:c,groupBaseBound:{left:c.left,top:c.top,width:c.width,height:c.height}},u=i.map(e=>{let t=e.transform||{left:0,top:0},{unitId:n,subUnitId:r,drawingId:i}=e;return{unitId:n,subUnitId:r,drawingId:i,transform:{...t},groupId:s}});return n.featurePluginGroupUpdateNotification([{parent:l,children:u}]),!0}},q={id:`drawing.operation.cancel-drawing-group`,type:t.OPERATION,handler:(e,t)=>{let n=e.get(y),i=(t.drawings||n.getFocusDrawings()).map(e=>{if(e.drawingType!==r.DRAWING_GROUP)return null;let{unitId:t,subUnitId:i,drawingId:a,transform:o={width:0,height:0},groupBaseBound:s}=e;if(o===null)return null;let c=n.getDrawingsByGroup({unitId:t,subUnitId:i,drawingId:a});return c.length===0?null:{parent:e,children:c.map(e=>{let{transform:t}=e,{unitId:n,subUnitId:r,drawingId:i}=e,a=re(t||{},o,o.width||0,o.height||0,s);return{unitId:n,subUnitId:r,drawingId:i,transform:{...t,...a},groupId:void 0}})}}).filter(e=>e!==null);return i.length===0?!1:(n.featurePluginUngroupUpdateNotification(i),!0)}},qe={id:`sheet.operation.open-image-crop`,type:t.OPERATION,handler:(e,t)=>!0},J={id:`sheet.operation.close-image-crop`,type:t.OPERATION,handler:(e,t)=>!0};let Y=function(e){return e.FREE=`0`,e.R1_1=`1`,e.R16_9=`2`,e.R9_16=`3`,e.R5_4=`4`,e.R4_5=`5`,e.R4_3=`6`,e.R3_4=`7`,e.R3_2=`8`,e.R2_3=`9`,e}({});const Je={id:`sheet.operation.Auto-image-crop`,type:t.OPERATION,handler:(e,t)=>!0},Ye={id:`sheet.operation.image-reset-size`,type:t.OPERATION,handler:(e,t)=>!0};function Xe(e,t,n,r){let i=r.getDrawingByParam(e);if(i==null)return;let a=C(e),o=n.getObjectIncludeInGroup(a);if(o&&!(o instanceof O))return;if(o!=null){let e=o.getObjects();for(let n of e)if(n.oKey===t.oKey)return;o.addObject(t);return}let s=new D(a);n.addObject(s,E).attachTransformerTo(s),s.addObject(t);let{transform:c,groupBaseBound:l}=i;l&&s.setBaseBound(l),i.groupId&&(s.isInGroup=!0,Xe({drawingId:i.groupId,unitId:e.unitId,subUnitId:e.subUnitId},s,n,r)),c&&s.transformByState({left:c.left,top:c.top,angle:c.angle,width:c.width,height:c.height})}function Ze(e,t){let n=t?e.getUnit(t):e.getFocusedUnit();if(n==null)return;let r=n.getUnitId(),i;if(n.type===p.UNIVER_SHEET){var a;i=(a=n.getActiveSheet())==null?void 0:a.getSheetId()}else (n.type===p.UNIVER_DOC||n.type===p.UNIVER_SLIDE)&&(i=r);return{unitId:r,subUnitId:i,current:n}}var Qe=`@univerjs/drawing-ui`,$e=`0.18.0`;const et=`drawing-ui.config`;Symbol(et);const tt={},nt=e=>{let t=e.get(y);return new be(e=>{let n=t=>{if(!t||t.length===0||t.length<2)return e.next(!0);e.next(!1)},r=t.focus$.subscribe(t=>{if(!t||t.length===0)return e.next(!0);n(t)});return n(t.getFocusDrawings()),()=>r.unsubscribe()})},rt=`contextMenu.drawing-align`;function it(e){return{id:rt,type:F.SUBITEMS,icon:`HorizontallyIcon`,title:`image-panel.align.title`,hidden$:nt(e)}}function at(){return{id:Pe.id,type:F.BUTTON,icon:`LeftJustifyingIcon`,title:`image-panel.align.left`}}function ot(){return{id:Fe.id,type:F.BUTTON,icon:`HorizontallyIcon`,title:`image-panel.align.center`}}function st(){return{id:Ie.id,type:F.BUTTON,icon:`RightJustifyingIcon`,title:`image-panel.align.right`}}function ct(){return{id:Le.id,type:F.BUTTON,icon:`AlignTopIcon`,title:`image-panel.align.top`}}function lt(){return{id:Re.id,type:F.BUTTON,icon:`VerticalCenterIcon`,title:`image-panel.align.middle`}}function ut(){return{id:ze.id,type:F.BUTTON,icon:`AlignBottomIcon`,title:`image-panel.align.bottom`}}function dt(){return{id:Be.id,type:F.BUTTON,icon:`HorizontallyIcon`,title:`image-panel.align.horizon`}}function ft(){return{id:Ve.id,type:F.BUTTON,icon:`VerticalCenterIcon`,title:`image-panel.align.vertical`}}const pt=`contextMenu.drawing-arrange`;function mt(){return{id:pt,type:F.SUBITEMS,icon:`TopmostIcon`,title:`image-panel.arrange.title`}}function ht(){return{id:He.id,type:F.BUTTON,icon:`TopmostIcon`,title:`image-panel.arrange.front`}}function gt(){return{id:Ue.id,type:F.BUTTON,icon:`MoveUpIcon`,title:`image-panel.arrange.forward`}}function _t(){return{id:We.id,type:F.BUTTON,icon:`BottomIcon`,title:`image-panel.arrange.back`}}function vt(){return{id:Ge.id,type:F.BUTTON,icon:`MoveDownIcon`,title:`image-panel.arrange.backward`}}const yt=(e,t)=>{let n=e.get(y);return new be(e=>{let i=n=>{if(!n||n.length===0)return e.next(!0);if(t===`group`){if(n.length<2||!n.every(e=>Ke.includes(e.drawingType)))return e.next(!0)}else if(t===`unGroup`){if(n.filter(e=>e.drawingType===r.DRAWING_GROUP).length===0)return e.next(!0)}else if(!n.every(e=>Ke.includes(e.drawingType)))return e.next(!0);e.next(!1)},a=n.focus$.subscribe(t=>{if(!t||t.length===0)return e.next(!0);i(t)});return i(n.getFocusDrawings()),()=>a.unsubscribe()})},bt=`contextMenu.drawing-group`;function xt(e){return{id:bt,type:F.SUBITEMS,icon:`GroupIcon`,title:`image-panel.group.title`,hidden$:yt(e)}}function St(e){return{id:K.id,type:F.BUTTON,icon:`GroupIcon`,title:`image-panel.group.group`,disabled$:yt(e,`group`)}}function Ct(e){return{id:q.id,type:F.BUTTON,icon:`UngroupIcon`,title:`image-panel.group.unGroup`,disabled$:yt(e,`unGroup`)}}const wt={[he.DRAWING]:{[me.OTHERS]:{[bt]:{order:1,menuItemFactory:xt,[K.id]:{order:0,menuItemFactory:St},[q.id]:{order:1,menuItemFactory:Ct}},[pt]:{order:2,menuItemFactory:mt,[He.id]:{order:0,menuItemFactory:ht},[Ue.id]:{order:1,menuItemFactory:gt},[We.id]:{order:2,menuItemFactory:_t},[Ge.id]:{order:3,menuItemFactory:vt}},[rt]:{order:3,menuItemFactory:it,[Pe.id]:{order:0,menuItemFactory:at},[Fe.id]:{order:1,menuItemFactory:ot},[Ie.id]:{order:2,menuItemFactory:st},[Le.id]:{order:3,menuItemFactory:ct},[Re.id]:{order:4,menuItemFactory:lt},[ze.id]:{order:5,menuItemFactory:ut},[Be.id]:{order:6,menuItemFactory:dt},[Ve.id]:{order:7,menuItemFactory:ft}}}}},Tt=`COMPONENT_IMAGE_POPUP_MENU`;function Et(e){var t;let{popup:n}=e,r=n==null||(t=n.extraProps)==null?void 0:t.menuItems;if(!r)return null;let a=I(i),o=I(d),[s,c]=B(!1),[l,u]=B(!1),f=()=>{u(!0)},p=()=>{u(!1)},m=e=>{c(e)},h=e=>{a.executeCommand(e.commandId,e.commandParams),c(!1)},g=s||l;return V(`div`,{onMouseEnter:f,onMouseLeave:p,children:V(De,{align:`start`,items:r.filter(e=>!e.disable).map(e=>({type:`item`,children:o.t(e.label),onSelect:()=>h(e)})),open:s,onOpenChange:m,children:H(`div`,{className:z(`
|
|
2
|
+
univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1
|
|
3
|
+
hover:univer-bg-gray-100
|
|
4
|
+
dark:hover:!univer-bg-gray-800
|
|
5
|
+
`,Ae,{"univer-bg-gray-100 dark:!univer-bg-gray-800":s,"univer-bg-white dark:!univer-bg-gray-900":!s}),children:[V(ie,{className:`
|
|
6
|
+
univer-fill-primary-600 univer-text-gray-900
|
|
7
|
+
dark:!univer-text-white
|
|
8
|
+
`}),g&&V(ce,{className:`dark:!univer-text-white`})]})})})}function X(e,t){return function(n,r){t(n,r,e)}}function Z(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let Dt=class extends n{constructor(e,t,n){super(),this._componentManager=e,this._commandService=t,this._menuManagerService=n,this._init()}_init(){this._initMenus(),this._initCommands(),this._initComponents()}_initMenus(){this._menuManagerService.mergeMenu(wt)}_initCommands(){[qe,J,Ye,W,Pe,Fe,Ie,Le,Re,ze,Be,Ve,Je,K,q,G,He,Ue,We,Ge].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initComponents(){[[Tt,Et],[`BottomIcon`,ae],[`GroupIcon`,se],[`MoveDownIcon`,le],[`MoveUpIcon`,ue],[`TopmostIcon`,de],[`UngroupIcon`,fe]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};Dt=Z([X(0,l(pe)),X(1,i),X(2,ve)],Dt);function Ot(e,t){let n=[];return e.forEach(e=>{let{oKey:i,left:a,top:o,height:s,width:c,angle:l}=e,u=t.getDrawingOKey(i);if(u==null)return n.push(null),!0;let{unitId:d,subUnitId:f,drawingId:p,drawingType:m}=u,h={unitId:d,subUnitId:f,drawingId:p,drawingType:m,transform:{left:a,top:o,height:s,width:c,angle:l}};m===r.DRAWING_IMAGE&&(h.srcRect=e.srcRect),n.push(h)}),n}function kt(e){"@babel/helpers - typeof";return kt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},kt(e)}function At(e,t){if(kt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(kt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function jt(e){var t=At(e,`string`);return kt(t)==`symbol`?t:t+``}function Q(e,t,n){return(t=jt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let Mt=class extends n{constructor(e,t,n,r){super(),this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._drawingManagerService=r,Q(this,`_sceneListenerOnDrawingMap`,new WeakSet),this._initialize()}dispose(){super.dispose()}_initialize(){this._recoveryImages(),this._drawingAddListener(),this._drawingRemoveListener(),this._drawingUpdateListener(),this._commandExecutedListener(),this._drawingArrangeListener(),this._drawingGroupListener(),this._drawingRefreshListener(),this._drawingVisibleListener()}_recoveryImages(){let e=this._drawingManagerService.drawingManagerData,t=Ze(this._currentUniverService);if(t==null)return;let{unitId:n,subUnitId:r}=t;Object.keys(e).forEach(t=>{Object.keys(e[t]).forEach(i=>{let a=e[t][i].data;a==null||t!==n||i!==r||Object.keys(a).forEach(e=>{a[e]&&this._insertDrawing([{unitId:t,subUnitId:i,drawingId:e}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===W.id){let t=e.params;if(t==null)return;this._drawingAlign(t)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(e=>{this._groupDrawings(e)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(e=>{this._ungroupDrawings(e)}))}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderById(e),n=t==null?void 0:t.scene;return n==null?null:{scene:n,transformer:n.getTransformerByCreate()}}_groupDrawings(e){e.forEach(e=>{this._groupDrawing(e)})}_groupDrawing(e){let{parent:t,children:n}=e,{unitId:r,subUnitId:i,drawingId:a}=t,o=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(o==null)return;let{scene:s,transformer:c}=o;this._commandService.syncExecuteCommand(J.id);let l=[];if(n.forEach(e=>{let t=C(e),n=s.getObjectIncludeInGroup(t);if(n==null||l.includes(n))return;l.push(n);let{transform:r}=e;r!=null&&(n.classType===j.GROUP?n.transformByState({left:r.left,top:r.top}):n.transformByState(r))}),l.length===0)return;let u=new D(C({unitId:r,subUnitId:i,drawingId:a}));s.addObject(u,E).attachTransformerTo(u),u.addObjects(...l),t.groupBaseBound&&u.setBaseBound(t.groupBaseBound),t.groupId&&(u.isInGroup=!0,Xe({drawingId:t.groupId,unitId:r,subUnitId:i},u,s,this._drawingManagerService)),t.transform&&u.transformByState({left:t.transform.left,top:t.transform.top,width:t.transform.width,height:t.transform.height,angle:t.transform.angle}),c.clearSelectedObjects(),c.setSelectedControl(u)}_ungroupDrawings(e){e.forEach(e=>{this._ungroupDrawing(e)})}_ungroupDrawing(e){let{parent:t,children:n}=e,r=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(r==null)return;let{scene:i,transformer:a}=r;n.forEach(e=>{let t=C(e),n=i.getObjectIncludeInGroup(t);if(n==null)return!0;if(n==null)return;let{transform:r}=e;r!=null&&(n.classType===j.GROUP?n.transformByState({left:r.left,top:r.top}):n.transformByState(r))});let o=C(t),s=i.getObject(o),{width:c,height:l}=s;s.getObjects().forEach(e=>{s.removeSelfObjectAndTransform(e.oKey,c,l)}),s.dispose(),a.clearSelectedObjects()}_drawingAlign(e){let{alignType:t}=e,n=e.drawings||this._drawingManagerService.getFocusDrawings();if(t===U.default)return;let r=[],i=1/0,a=1/0,o=-1/0,s=-1/0,c=0;n.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:l,drawingType:u}=e,d=this._drawingManagerService.getDrawingByParam({unitId:t,subUnitId:n,drawingId:l});if(d==null||d.transform==null)return;r.push({unitId:t,subUnitId:n,drawingId:l,drawingType:u,transform:d.transform});let{left:f=0,top:p=0,width:m=0,height:h=0}=d.transform;i=Math.min(i,f),a=Math.min(a,p),o=Math.max(o,f+m),s=Math.max(s,p+h),c++}),c!==0&&(this._sortDrawingTransform(r,t),this._applyAlignType(r,t,i,a,o,s,c))}_applyAlignType(e,t,n,r,i,a,o){let s=Math.round((i-n)/o*10)/10,c=Math.round((a-r)/o*10)/10,l=[],u=this._getSceneAndTransformerByDrawingSearch(e[0].unitId);if(u==null)return;let{scene:d,transformer:f}=u;e.forEach((e,o)=>{let{unitId:u,subUnitId:d,drawingId:f,transform:p,drawingType:m}=e,{left:h=0,top:g=0,width:_=0,height:v=0}=p,y=h,b=g;switch(t){case U.left:y=n;break;case U.center:y=n+(i-n)/2-_/2;break;case U.right:y=i-_;break;case U.top:b=r;break;case U.middle:b=r+(a-r)/2-v/2;break;case U.bottom:b=a-v;break;case U.horizon:y=n+s*o;break;case U.vertical:b=r+c*o;break;default:break}(y!==h||b!==g)&&l.push({unitId:u,subUnitId:d,drawingId:f,drawingType:m,transform:{left:y,top:b}})}),this._drawingManagerService.featurePluginUpdateNotification(l),f.refreshControls().changeNotification()}_sortDrawingTransform(e,t){e.sort((e,n)=>{let r=e.transform,i=n.transform,{left:a=0,top:o=0,width:s=0,height:c=0}=r,{left:l=0,top:u=0,width:d=0,height:f=0}=i;switch(t){case U.left:return a-l;case U.center:return a+s/2-(l+d/2);case U.right:return a+s-(l+d);case U.top:return o-u;case U.middle:return o+c/2-(u+f/2);case U.bottom:return o+c-(u+f);case U.horizon:return a+s/2-(l+d/2);case U.vertical:return o+c/2-(u+f/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(e=>{this._drawingArrange(e)}))}_drawingArrange(e){let{unitId:t,subUnitId:n,drawingIds:r}=e,i=this._getSceneAndTransformerByDrawingSearch(t);if(i==null)return;let{scene:a}=i;r.forEach(e=>{let r=C({unitId:t,subUnitId:n,drawingId:e}),i=a.fuzzyMathObjects(r,!0);if(i==null||i.length===0)return;let o=this._drawingManagerService.getDrawingOrder(t,n).indexOf(e);for(let e of i)e.setProps({zIndex:o}),e.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{this._insertDrawing(e)}))}_insertDrawing(e){let t=[];e.forEach(e=>{let{unitId:n}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;let r=this._getSceneAndTransformerByDrawingSearch(n);if(r==null)return;let{scene:i}=r;t.includes(i)||t.push(i)}),t.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e,i=this._getSceneAndTransformerByDrawingSearch(t);if(i==null)return;let{scene:a}=i,o=C({unitId:t,subUnitId:n,drawingId:r}),s=a.fuzzyMathObjects(o,!0);if(s.length>0){var c;for(let e of s)e.dispose();(c=a.getTransformer())==null||c.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{var t;let{unitId:n,subUnitId:r,drawingId:i}=e,a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;let{transform:o,drawingType:s}=a,c=this._getSceneAndTransformerByDrawingSearch(n);if(c==null)return;let{scene:l,transformer:u}=c;if(o==null)return!0;let{left:d=0,top:f=0,width:p=0,height:m=0,angle:h=0,flipX:g=!1,flipY:_=!1,skewX:v=0,skewY:y=0}=o,b=C({unitId:n,subUnitId:r,drawingId:i}),x=l.getObject(b);if(x==null)return!0;x.transformByState({left:d,top:f,width:p,height:m,angle:h,flipX:g,flipY:_,skewX:v,skewY:y}),(t=l.getTransformer())==null||t.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r}=e,i=this._getSceneAndTransformerByDrawingSearch(t);if(i==null)return;let a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;let{transform:o}=a,{scene:s}=i,c=C({unitId:t,subUnitId:n,drawingId:r}),l=s.getObject(c);if(l==null||o==null)return!0;let{left:u=0,top:d=0,width:f=0,height:p=0,angle:m=0,flipX:h=!1,flipY:g=!1,skewX:_=0,skewY:v=0}=o;l.transformByState({left:u,top:d,width:f,height:p,angle:m,flipX:h,flipY:g,skewX:_,skewY:v})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:r,visible:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;let{scene:o}=a,s=C({unitId:t,subUnitId:n,drawingId:r}),c=o.getObject(s);if(c==null)return!0;i?c.show():c.hide()})}))}_filterUpdateParams(e,t){return e.filter((e,n)=>{if(e==null)return!1;let{transform:r}=e;return m(r,t==null?void 0:t[n])})}_addListenerOnDrawing(e){let t=e.getTransformerByCreate(),n=null;this.disposeWithMe(v(t.changeStart$.subscribe(e=>{let{objects:t}=e,r=Array.from(t.values()),i=[];n=r.map(e=>{let{left:t,top:n,height:r,width:a,angle:o,oKey:s,isInGroup:c}=e,l=this._drawingManagerService.getDrawingOKey(s);if(c||e instanceof O){let t=e.ancestorGroup;if(t==null&&e instanceof O&&(t=e),t==null)return null;let n=this._drawingManagerService.getDrawingOKey(t.oKey);if(n){let{unitId:e,subUnitId:r,drawingId:a}=n;i.push({unitId:e,subUnitId:r,drawingId:a});let{left:o,top:s,height:c,width:l,angle:u}=t;return{left:o,top:s,height:c,width:l,angle:u}}}else if(l!=null){let{unitId:e,subUnitId:s,drawingId:c}=l;return i.push({unitId:e,subUnitId:s,drawingId:c}),{left:t,top:n,height:r,width:a,angle:o}}return null}).filter(e=>e!=null),i.length>0?this._commandService.syncExecuteCommand(S.id,i):this._commandService.syncExecuteCommand(S.id,[])}))),this.disposeWithMe(v(t.changeEnd$.subscribe(e=>{let{objects:t}=e,r=this._filterUpdateParams(Ot(t,this._drawingManagerService),n);r.length>0&&this._drawingManagerService.featurePluginUpdateNotification(r)})))}};Mt=Z([X(0,s),X(1,i),X(2,k),X(3,y)],Mt);var Nt=function(e){return e[e.RECT=0]=`RECT`,e[e.PATH=1]=`PATH`,e}(Nt||{}),Pt=class extends N{constructor(e,t){t==null&&(t={}),t.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:`rgb(0, 0, 0)`,anchorStroke:`rgb(255, 255, 255)`,anchorSize:24},super(e,t),Q(this,`_srcRect`,void 0),Q(this,`_prstGeom`,void 0),Q(this,`_applyTransform`,void 0),Q(this,`_dragPadding`,8),Q(this,`_cacheCanvas`,void 0),t!=null&&t.srcRect&&(this._srcRect=t.srcRect),t!=null&&t.prstGeom&&(this._prstGeom=t.prstGeom),t!=null&&t.applyTransform&&(this._applyTransform=t.applyTransform),t!=null&&t.dragPadding&&(this._dragPadding=t.dragPadding),this._applyProps()}refreshSrcRect(e,t){this._srcRect=e,this._applyTransform=t,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var e;super.dispose(),(e=this._cacheCanvas)==null||e.dispose(),this._srcRect=null}isHit(e){let t=this.getInverseCoord(e);return t.x>=-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2&&t.y>=-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2&&!this._inSurround(t)}_inSurround(e){let t=this._dragPadding;return e.x>=t-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2-t&&e.y>=t-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2-t}render(e,t){return this.visible?(e.save(),this._draw(e),e.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(e){var t,n;let{width:r,height:i}=this.getScene().getEngine();this._initialCacheCanvas(),(t=this._cacheCanvas)==null||t.clear();let a=(n=this._cacheCanvas)==null?void 0:n.getContext();a!=null&&(a.save(),M.drawWith(a,{left:0,top:0,width:r,height:i,fill:`rgba(0, 0, 0, 0.5)`}),a.setTransform(e.getTransform()),this._clipForApplyObject(a),this._applyCache(e),a.restore())}_clipForApplyObject(e){let t=Nt.RECT;if(this._prstGeom!=null&&(t=Nt.PATH),e.globalCompositeOperation=`destination-out`,e.beginPath(),t===Nt.RECT){let t=this.transform.getMatrix();e.transform(t[0],t[1],t[2],t[3],t[4],t[5]),e.rect(0,0,this.width,this.height),e.fill()}}_applyProps(){if(this._applyTransform==null)return;let e=0,t=0,n=0,r=0,{left:i=0,top:a=0,width:o=0,height:s=0,angle:c}=this._applyTransform;if(this._srcRect!=null){let{left:i=0,top:a=0,right:o=0,bottom:s=0}=this._srcRect;e=i,t=a,n=o,r=s}let l=i+e,u=a+t;this.transformByState({left:l,top:u,width:i+o-n-l,height:a+s-r-u,angle:c})}_applyCache(e){if(!e||this._cacheCanvas==null)return;let t=this._cacheCanvas.getContext();t.save(),e.save(),e.setTransform(1,0,0,1,0,0),t.setTransform(1,0,0,1,0,0),e.drawImage(this._cacheCanvas.getCanvasEle(),0,0),e.restore(),t.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;let e=this.getScene();if(e==null)return;this._cacheCanvas=new T;let t=e.getEngine();this._cacheCanvas.setSize(t.width,t.height),t.onTransformChange$.subscribeEvent(()=>{var e;(e=this._cacheCanvas)==null||e.setSize(t.width,t.height),this.makeDirty(!0)})}};let Ft=class extends n{constructor(e,t,n,r,i,a){super(),this._commandService=e,this._drawingManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._messageService=i,this._localeService=a,Q(this,`_sceneListenerOnImageMap`,new WeakSet),this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==Je.id)return;let t=e.params;if(t==null)return;let{cropType:n}=t,r=this._drawingManagerService.getFocusDrawings();if(r.length!==1)return;let{unitId:i,subUnitId:a,drawingId:o}=r[0],s=this._renderManagerService.getRenderById(i),c=s==null?void 0:s.scene;if(c==null)return!0;this._searchCropObject(c)!=null&&this._commandService.syncExecuteCommand(J.id,{isAuto:!0});let l=C({unitId:i,subUnitId:a,drawingId:o}),u=c.getObject(l);if(!(u instanceof A)){this._messageService.show({type:Oe.Error,content:this._localeService.t(`image-cropper.error`)});return}u!=null&&(this._updateCropperObject(n,u),this._commandService.executeCommand(qe.id,{unitId:i,subUnitId:a,drawingId:o}))}))}_calculateSrcRectByRatio(e,t,n,r,i,a){let o=n/r,s=i/a,c=n,l=r;o>s?c=r*s:l=n/s;let u=(n-c)/2,d=(r-l)/2;return{left:ne(u,1),top:ne(d,1),right:ne(n-(u+c),1),bottom:ne(r-(d+l),1)}}_updateCropperObject(e,t){let{left:n,top:r,width:i,height:a}=t.calculateTransformWithSrcRect(),o;switch(e){case Y.R1_1:o=this._calculateSrcRectByRatio(n,r,i,a,1,1);break;case Y.R16_9:o=this._calculateSrcRectByRatio(n,r,i,a,16,9);break;case Y.R9_16:o=this._calculateSrcRectByRatio(n,r,i,a,9,16);break;case Y.R5_4:o=this._calculateSrcRectByRatio(n,r,i,a,5,4);break;case Y.R4_5:o=this._calculateSrcRectByRatio(n,r,i,a,4,5);break;case Y.R4_3:o=this._calculateSrcRectByRatio(n,r,i,a,4,3);break;case Y.R3_4:o=this._calculateSrcRectByRatio(n,r,i,a,3,4);break;case Y.R3_2:o=this._calculateSrcRectByRatio(n,r,i,a,3,2);break;case Y.R2_3:o=this._calculateSrcRectByRatio(n,r,i,a,2,3);break;case Y.FREE:default:break}if(o==null)return;t.setSrcRect(o);let{left:s=0,top:c=0,bottom:l=0,right:u=0}=o;t.transformByStateCloseCropper({left:n+s,top:r+c,width:i-u-s,height:a-l-c})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==qe.id)return;let t=e.params;if(t==null)return;let{unitId:n,subUnitId:r,drawingId:i}=t,a=this._renderManagerService.getRenderById(n),o=a==null?void 0:a.scene;if(o==null)return!0;if(this._sceneListenerOnImageMap.has(o)||(this._addListenerOnImage(o),this._sceneListenerOnImageMap.add(o)),this._drawingManagerService.getDrawingByParam({unitId:n,subUnitId:r,drawingId:i})==null)return;let s=C({unitId:n,subUnitId:r,drawingId:i}),c=o.getObject(s);if(c==null)return;if(!(c instanceof A)){this._messageService.show({type:Oe.Error,content:this._localeService.t(`image-cropper.error`)});return}let l=o.getTransformer();l==null||l.clearControls();let u=new Pt(`${s}-crop`,{srcRect:c.srcRect,prstGeom:c.prstGeom,applyTransform:c.calculateTransformWithSrcRect()});o.addObject(u,c.getLayerIndex()+1).attachTransformerTo(u),l==null||l.createControlForCopper(u),this._addHoverForImageCopper(u),c.openRenderByCropper(),l==null||l.refreshControls(),u.makeDirty(!0),this._commandService.syncExecuteCommand(S.id,[{unitId:n,subUnitId:r,drawingId:i}])}))}_searchCropObject(e){let t=e.getAllObjectsByOrder();for(let e of t)if(e instanceof Pt)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==J.id)return;let t=this._univerInstanceService.getFocusedUnit();if(t==null)return;let n=t.getUnitId(),r=this._renderManagerService.getRenderById(n),i=r==null?void 0:r.scene;if(i==null)return!0;let a=this._searchCropObject(i);if(a==null)return;let o=this._getApplyObjectByCropObject(a);if(o==null)return;let s=i.getTransformerByCreate();s.detachFrom(a),s.clearCopperControl();let c=this._getSrcRectByTransformState(o,a),l=this._drawingManagerService.getDrawingOKey(o.oKey);if(l!=null){let{left:e,top:t,height:n,width:r}=a;this._drawingManagerService.featurePluginUpdateNotification([{...l,transform:{...l.transform,left:e,top:t,height:n,width:r},srcRect:c.srcRectAngle}])}o.setSrcRect({...c.srcRectAngle}),o.closeRenderByCropper(),o.makeDirty(!0),a==null||a.dispose()}));let e=this._univerInstanceService.getCurrentTypeOfUnit$(p.UNIVER_SHEET).pipe(Te(e=>e?e.activeSheet$:we(null)));this.disposeWithMe(e.subscribe(()=>{this._commandService.syncExecuteCommand(J.id)}))}_getApplyObjectByCropObject(e){let t=e.oKey,n=t.slice(0,t.length-5),r=e.getScene();if(!r)return null;let i=r.getObject(n);return i==null?null:i}_addListenerOnImage(e){let t=e.getTransformerByCreate(),n=null;this.disposeWithMe(t.changeStart$.subscribe(e=>{let{objects:r}=e,i=r.values().next().value;if(i==null||!(i instanceof Pt))return;let{left:a,top:o,height:s,width:c,angle:l}=i;n={left:a,top:o,height:s,width:c,angle:l},t.clearCopperControl()})),this.disposeWithMe(t.changeEnd$.subscribe(e=>{let{objects:r}=e,i=r.values().next().value;if(i==null||!(i instanceof Pt))return;let{left:a,top:o,height:s,width:c,angle:l}=i;if(!m({left:a,top:o,height:s,width:c,angle:l},n))return;let u=this._getApplyObjectByCropObject(i);if(u==null)return;let d=this._getSrcRectByTransformState(u,i);i.refreshSrcRect(d.srcRect,u.getState()),t.createControlForCopper(i)})),this._endCropListener(e)}_addHoverForImageCopper(e){this.disposeWithMe(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=w.MOVE})),this.disposeWithMe(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=w.DEFAULT}))}_endCropListener(e){let t=e.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(J.id)}))}_getSrcRectByTransformState(e,t){let{left:n,top:r,height:i,width:a,strokeWidth:o,angle:s}=t,{left:c,top:l,width:u,height:d,angle:f,strokeWidth:p}=e,m=n-c,h=r-l,g={left:m,top:h,right:u-m-a,bottom:d-h-i},_={...g};if(f!==0){let e=new P(n+a/2,r+i/2),t=new P(u/2+c,d/2+l),o=new P(c,l);o.rotateByPoint(ee(f),t);let s=o.clone();s.rotateByPoint(ee(-f),e);let p=n-s.x,m=r-s.y;_.left=p,_.top=m,_.right=u-p-a,_.bottom=d-m-i}return{srcRect:g,srcRectAngle:_}}};Ft=Z([X(0,i),X(1,y),X(2,k),X(3,s),X(4,ye),X(5,l(d))],Ft);let It=class{constructor(e,t,n,r,i){this._drawingManagerService=e,this._imageIoService=t,this._galleryService=n,this._urlImageService=r,this._univerInstanceService=i}async renderImages(e,t){let{transform:n,drawingType:i,source:a,imageSourceType:o,srcRect:s,prstGeom:c,groupId:l,unitId:u,subUnitId:d,drawingId:f,isMultiTransform:m,transforms:h}=e;if(i!==r.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||this._univerInstanceService.getUnitType(u)===p.UNIVER_SHEET&&d!==this._getActiveSheetId()||n==null)return;let g=m&&h?h:[n],_=[];for(let e of g){let{left:n,top:r,width:i,height:p,angle:h,flipX:v,flipY:y,skewX:b,skewY:S}=e,w=g.indexOf(e),T=C({unitId:u,subUnitId:d,drawingId:f},m?w:void 0),D=t.getObject(T);if(D!=null){D.transformByState({left:n,top:r,width:i,height:p,angle:h,flipX:v,flipY:y,skewX:b,skewY:S});continue}let O=this._drawingManagerService.getDrawingOrder(u,d),k=O.indexOf(f),j={...e,zIndex:k===-1?O.length-1:k},M=this._imageIoService.getImageSourceCache(a,o),N=!1;if(M!=null)j.image=M;else if(o===x.UUID)try{j.url=await this._imageIoService.getImage(a)}catch(e){console.error(e);continue}else if(o===x.URL){try{j.url=await this._urlImageService.getImage(a)}catch(e){console.error(e),j.url=a}N=!0}else j.url=a,N=!0;if(t.getObject(T))continue;j.printable=!0;let P=new A(T,j);N&&this._imageIoService.addImageSourceCache(a,o,P.getNative()),t.addObject(P,E),this._drawingManagerService.getDrawingEditable()&&t.attachTransformerTo(P),l&&Xe({drawingId:l,unitId:u,subUnitId:d},P,t,this._drawingManagerService),c!=null&&P.setPrstGeom(c),s!=null&&P.setSrcRect(s),_.push(P)}return _}_getActiveSheetId(){var e;return(e=this._univerInstanceService.getCurrentUnitOfType(p.UNIVER_SHEET))==null||(e=e.getActiveSheet())==null?void 0:e.getSheetId()}renderFloatDom(e,t){let{transform:n,drawingType:i,groupId:a,unitId:o,subUnitId:s,drawingId:c,isMultiTransform:l,transforms:u}=e;if(i!==r.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||n==null)return;let d=l&&u?u:[n],f=[];for(let n of d){let{left:r,top:i,width:u,height:p,angle:m,flipX:h,flipY:g,skewX:_,skewY:v}=n,y=d.indexOf(n),b=C({unitId:o,subUnitId:s,drawingId:c},l?y:void 0),x=t.getObject(b);if(x!=null){x.transformByState({left:r,top:i,width:u,height:p,angle:m,flipX:h,flipY:g,skewX:_,skewY:v});continue}let S=this._drawingManagerService.getDrawingOrder(o,s),w=S.indexOf(c),T={...n,zIndex:w===-1?S.length-1:w};if(t.getObject(b))continue;T.printable=!1;let D=new M(b,T);this._drawingManagerService.getDrawingVisible()&&(t.addObject(D,E),this._drawingManagerService.getDrawingEditable()&&e.allowTransform!==!1&&t.attachTransformerTo(D),a&&Xe({drawingId:a,unitId:o,subUnitId:s},D,t,this._drawingManagerService),f.push(D))}return f}renderDrawing(e,t){let n=this._drawingManagerService.getDrawingByParam(e);if(n!=null)switch(n.drawingType){case r.DRAWING_IMAGE:return this.renderImages(n,t);default:}}previewImage(e,t,n,r){this._galleryService.open({images:[t],onOpenChange:e=>{e||this._galleryService.close()}})}_adjustImageSize(e,t,n,r){if(e<=n&&t<=r)return{width:e,height:t};let i=n/e,a=r/t,o=Math.min(i,a);return{width:Math.floor(e*o),height:Math.floor(t*o)}}};It=Z([X(0,y),X(1,b),X(2,_e),X(3,o),X(4,s)],It);let Lt=class extends n{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._renderManagerService=t,this._drawingManagerService=n,this._dialogService=r,this._imageIoService=i,this._currentUniverService=a,this._drawingRenderService=o,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===Ye.id){let t=e.params;if(t==null)return;this._resetImageSize(t)}}))}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderById(e),n=t==null?void 0:t.scene;return n==null?null:{scene:n,transformer:n.getTransformerByCreate()}}_resetImageSize(e){let t=[],n=[];e.forEach(e=>{let{unitId:i,subUnitId:a,drawingId:o}=e,s=this._getSceneAndTransformerByDrawingSearch(i);if(s==null)return;let{scene:c}=s,l=C({unitId:i,subUnitId:a,drawingId:o}),u=c.getObject(l);if(u==null)return!0;let d=this._drawingManagerService.getDrawingByParam(e);if(d==null)return!0;if(d.drawingType!==r.DRAWING_IMAGE)return;u.resetSize();let{width:f,height:p}=u.getNativeSize();n.includes(c)===!1&&n.push(c),t.push({...d,transform:{...d.transform,height:p,width:f,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(t),n.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(S.id,e)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.pipe(xe(33),Se(e=>e.length>0),Ce(e=>e.flat()),Ce(e=>{let t=new Map;for(let n of e)t.set(`${n.unitId}|${n.subUnitId}|${n.drawingId}`,n);return[...t.values()]}),Se(e=>e.length>0)).subscribe(e=>{this._insertImages(e)}))}_insertImages(e){e.forEach(async e=>{var t;let{unitId:n,subUnitId:r}=e,i=this._getSceneAndTransformerByDrawingSearch(n),a=(t=Ze(this._currentUniverService,n))==null?void 0:t.subUnitId;if(i==null||a!==r)return;let o=this._drawingManagerService.getDrawingByParam(e);if(o==null)return;let s=await this._drawingRenderService.renderImages(o,i.scene);if(this._drawingManagerService.refreshTransform([o]),!(s==null||s.length===0))for(let e of s)this._addHoverForImage(e),this._addDialogForImage(e)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:i}=e,a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;let{transform:o,drawingType:s,srcRect:l,prstGeom:u,source:d,imageSourceType:f}=a;if(s!==r.DRAWING_IMAGE)return;let p=this._getSceneAndTransformerByDrawingSearch(t);if(p==null)return;let{scene:m,transformer:h}=p;if(o==null)return!0;let g=C({unitId:t,subUnitId:n,drawingId:i}),_=m.getObject(g);if(_==null)return!0;_.setSrcRect(l),_.setPrstGeom(u),d!=null&&d.length>0&&(f===c.BASE64||f===c.URL)&&_.changeSource(d)})}))}_addHoverForImage(e){this.disposeWithMe(v(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=w.GRAB}))),this.disposeWithMe(v(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=w.DEFAULT})))}_addDialogForImage(e){this.disposeWithMe(v(e.onDblclick$.subscribeEvent(()=>{let t=`${e.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(t,e.getNative().src,e.getNativeSize().width,e.getNativeSize().height)})))}};Lt=Z([X(0,i),X(1,k),X(2,y),X(3,ge),X(4,b),X(5,s),X(6,l(It))],Lt);let $=class extends f{constructor(e=tt,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{menu:r,...i}=_({},tt,this._config);r&&this._configService.setConfig(`menu`,r,{merge:!0}),this._configService.setConfig(et,i)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(Mt),this._injector.get(Dt),this._injector.get(Ft),this._injector.get(Lt)}_initDependencies(){[[It],[Mt],[Dt],[Ft],[Lt]].forEach(e=>this._injector.add(e))}};Q($,`pluginName`,`UNIVER_DRAWING_UI_PLUGIN`),Q($,`packageName`,Qe),Q($,`version`,$e),$=Z([X(1,l(u)),X(2,a)],$);const Rt=e=>{let t=I(i),n=I(d),{drawings:r,alignShow:a}=e,[o,s]=B(U.default),c=[{label:n.t(`image-panel.align.default`),value:U.default},{options:[{label:n.t(`image-panel.align.left`),value:U.left},{label:n.t(`image-panel.align.center`),value:U.center},{label:n.t(`image-panel.align.right`),value:U.right}]},{options:[{label:n.t(`image-panel.align.top`),value:U.top},{label:n.t(`image-panel.align.middle`),value:U.middle},{label:n.t(`image-panel.align.bottom`),value:U.bottom}]},{options:[{label:n.t(`image-panel.align.horizon`),value:U.horizon},{label:n.t(`image-panel.align.vertical`),value:U.vertical}]}];function l(e){s(e),t.executeCommand(W.id,{alignType:e,drawings:r})}return H(`div`,{className:z(`univer-relative univer-w-full`,{"univer-hidden":!a}),children:[V(`header`,{className:`
|
|
9
|
+
univer-text-gray-600
|
|
10
|
+
dark:!univer-text-gray-200
|
|
11
|
+
`,children:V(`div`,{children:n.t(`image-panel.align.title`)})}),V(`div`,{className:`univer-relative univer-mt-2.5 univer-flex univer-h-full`,children:V(`div`,{className:`
|
|
12
|
+
univer-w-full univer-text-gray-900
|
|
13
|
+
dark:!univer-text-white
|
|
14
|
+
`,children:V(ke,{value:o,options:c,onChange:l})})})]})},zt=t=>{let{arrangeShow:n,drawings:r}=t,a=I(d),o=I(y),s=I(i),c=I(pe),l=c.get(`MoveUpIcon`),u=c.get(`MoveDownIcon`),f=c.get(`TopmostIcon`),p=c.get(`BottomIcon`),[m,h]=B(r);je(()=>{let e=o.focus$.subscribe(e=>{h(e)});return()=>{e.unsubscribe()}},[]);let g=e=>{s.syncExecuteCommand(G.id,{arrangeType:e,drawings:m})};return H(`div`,{className:z(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!n}),children:[V(`header`,{className:`
|
|
15
|
+
univer-text-gray-600
|
|
16
|
+
dark:!univer-text-gray-200
|
|
17
|
+
`,children:V(`div`,{children:a.t(`image-panel.arrange.title`)})}),H(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2`,children:[H(L,{onClick:()=>{g(e.forward)},children:[V(l,{}),a.t(`image-panel.arrange.forward`)]}),H(L,{onClick:()=>{g(e.backward)},children:[V(u,{}),a.t(`image-panel.arrange.backward`)]}),H(L,{onClick:()=>{g(e.front)},children:[V(f,{}),a.t(`image-panel.arrange.front`)]}),H(L,{onClick:()=>{g(e.back)},children:[V(p,{}),a.t(`image-panel.arrange.back`)]})]})]})},Bt=e=>{let t=I(d),n=I(k),a=I(y),o=I(i),s=I(pe),{hasGroup:c,drawings:l}=e,u=s.get(`GroupIcon`),f=s.get(`UngroupIcon`),[p,m]=B(!1),[h,g]=B(!0),[_,v]=B(!0),b=()=>{o.syncExecuteCommand(K.id,{drawings:l})},x=()=>{o.syncExecuteCommand(q.id,{drawings:l})};return je(()=>{let e=l[0];if(e==null)return;let{unitId:t}=e,i=n.getRenderById(t),o=i==null?void 0:i.scene;if(o==null)return;let s=o.getTransformerByCreate(),c=s.clearControl$.subscribe(e=>{e===!0&&m(!1)}),u=s.changeStart$.subscribe(e=>{let{objects:t}=e,n=Ot(t,a),i=n.filter(e=>(e==null?void 0:e.drawingType)===r.DRAWING_GROUP),o=!1,s=!1;n.length>1&&(o=!0),i.length>0&&(s=!0),m(o||s),g(o),v(s)});return()=>{u.unsubscribe(),c.unsubscribe()}},[]),H(`div`,{className:z(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":c===!0&&p===!1||c===!1}),children:[V(`header`,{className:`
|
|
18
|
+
univer-text-gray-600
|
|
19
|
+
dark:!univer-text-gray-200
|
|
20
|
+
`,children:V(`div`,{children:t.t(`image-panel.group.title`)})}),H(`div`,{className:`univer-flex univer-items-center univer-justify-center univer-gap-2`,children:[H(L,{className:z({"univer-hidden":!h}),onClick:b,children:[V(u,{}),t.t(`image-panel.group.group`)]}),H(L,{className:z({"univer-hidden":!_}),onClick:x,children:[V(f,{}),t.t(`image-panel.group.unGroup`)]})]})]})},Vt=[-360,360],Ht=e=>{var t;let n=I(d),r=I(y),i=I(k),{drawings:a,transformShow:o}=e,s=a[0];if(s==null)return;let c=s.transform;if(c==null)return;let{unitId:l,subUnitId:u,drawingId:f,drawingType:p}=s,m=i.getRenderById(l),g=m==null?void 0:m.scene;if(g==null)return;let _=(t=g.getEngine())==null?void 0:t.activeScene;if(_==null)return;let v=g.getTransformerByCreate(),{width:b=0,height:x=0,left:S=0,top:C=0,angle:w=0}=c,[T,E]=B(b),[D,O]=B(x),[A,j]=B(S),[M,N]=B(C),[P,ee]=B(w),[te,ne]=B(v.keepRatio),re=(e,t,n,r)=>{let{width:i,height:a}=_,{ancestorLeft:o,ancestorTop:s}=g,c=e,l=t,u=n,d=r;return e+o<0&&(c=-o),t+s<0&&(l=-s),u=i-c-o,u<20&&(u=20),d=a-l-s,d<20&&(d=20),e+u+o>i&&(c=i-n-o),t+d+s>a&&(l=a-r-s),{limitLeft:c,limitTop:l,limitWidth:u,limitHeight:d}},ie=e=>{let{objects:t}=e,n=Ot(t,r);if(n.length!==1)return;let i=n[0];if(i==null)return;let{transform:a}=i;if(a==null)return;let{width:o,height:s,left:c,top:l,angle:u}=a;o!=null&&E(o),s!=null&&O(s),c!=null&&j(c),l!=null&&N(l),u!=null&&ee(u)};je(()=>{let e=[v.changeStart$.subscribe(e=>{ie(e)}),v.changing$.subscribe(e=>{ie(e)}),v.changeEnd$.subscribe(e=>{ie(e)}),r.focus$.subscribe(e=>{if(e.length!==1)return;let t=r.getDrawingByParam(e[0]);if(t==null)return;let n=t.transform;if(n==null)return;let{width:i,height:a,left:o,top:s,angle:c}=n;i!=null&&E(i),a!=null&&O(a),o!=null&&j(o),s!=null&&N(s),c!=null&&ee(c)})];return()=>{e.forEach(e=>e.unsubscribe())}},[]);let ae=h(e=>{if(e==null)return;let{limitWidth:t,limitHeight:n}=re(A,M,e,D);e=Math.min(e,t);let i={unitId:l,subUnitId:u,drawingId:f,drawingType:p,transform:{width:e}};if(te){let t=e/T*D;if(t=Math.max(t,20),t>n)return;O(t),i.transform.height=t}E(e),r.featurePluginUpdateNotification([i]),v.refreshControls().changeNotification()},300),oe=h(e=>{if(e==null)return;let{limitHeight:t,limitWidth:n}=re(A,M,T,e);e=Math.min(e,t);let i={unitId:l,subUnitId:u,drawingId:f,drawingType:p,transform:{height:e}};if(te){let t=e/D*T;if(t=Math.max(t,20),t>n)return;E(t),i.transform.width=t}O(e),r.featurePluginUpdateNotification([i]),v.refreshControls().changeNotification()},300),se=h(e=>{if(e==null)return;let{limitLeft:t}=re(e,M,T,D);e=t;let n={unitId:l,subUnitId:u,drawingId:f,drawingType:p,transform:{left:e}};j(e),r.featurePluginUpdateNotification([n]),v.refreshControls().changeNotification()},300),ce=h(e=>{if(e==null)return;let{limitTop:t}=re(A,e,T,D);e=t;let n={unitId:l,subUnitId:u,drawingId:f,drawingType:p,transform:{top:e}};N(e),r.featurePluginUpdateNotification([n]),v.refreshControls().changeNotification()},300),le=e=>{if(e==null)return;let t={unitId:l,subUnitId:u,drawingId:f,drawingType:p,transform:{angle:e}};ee(e),r.featurePluginUpdateNotification([t]),v.refreshControls().changeNotification()},ue=e=>{ne(e),v.keepRatio=e};return H(`div`,{className:z(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!o}),children:[V(`header`,{className:`
|
|
21
|
+
univer-text-gray-600
|
|
22
|
+
dark:!univer-text-gray-200
|
|
23
|
+
`,children:V(`div`,{children:n.t(`image-panel.transform.title`)})}),H(`div`,{className:`
|
|
24
|
+
univer-grid univer-grid-cols-3 univer-gap-2
|
|
25
|
+
[&>div]:univer-grid [&>div]:univer-gap-2
|
|
26
|
+
`,children:[H(`div`,{children:[V(`span`,{children:n.t(`image-panel.transform.width`)}),V(R,{precision:1,value:T,min:20,onChange:e=>{ae(e)}})]}),H(`div`,{children:[V(`span`,{children:n.t(`image-panel.transform.height`)}),V(R,{precision:1,value:D,min:20,onChange:e=>{oe(e)}})]}),H(`div`,{children:[V(`span`,{children:n.t(`image-panel.transform.lock`)}),V(`div`,{className:`univer-text-center`,children:V(Ee,{checked:te,onChange:ue})})]})]}),H(`div`,{className:`
|
|
27
|
+
univer-grid univer-grid-cols-3 univer-gap-2
|
|
28
|
+
[&>div]:univer-grid [&>div]:univer-gap-2
|
|
29
|
+
`,children:[H(`div`,{children:[V(`span`,{children:n.t(`image-panel.transform.x`)}),V(R,{precision:1,value:A,onChange:e=>{se(e)}})]}),H(`div`,{children:[V(`span`,{children:n.t(`image-panel.transform.y`)}),V(R,{precision:1,value:M,onChange:e=>{ce(e)}})]}),H(`div`,{children:[V(`span`,{children:n.t(`image-panel.transform.rotate`)}),V(R,{precision:1,value:P,min:Vt[0],max:Vt[1],onChange:le})]})]})]})},Ut=e=>{let t=I(i),n=I(d),{drawings:r,cropperShow:a}=e;if(r[0]==null)return;let[o,s]=B(Y.FREE),c=Me(!1),l=[{label:n.t(`image-panel.crop.mode`),value:Y.FREE},{label:`1:1`,value:Y.R1_1},{label:`16:9`,value:Y.R16_9},{label:`9:16`,value:Y.R9_16},{label:`5:4`,value:Y.R5_4},{label:`4:5`,value:Y.R4_5},{label:`4:3`,value:Y.R4_3},{label:`3:4`,value:Y.R3_4},{label:`3:2`,value:Y.R3_2},{label:`2:3`,value:Y.R2_3}];je(()=>{let e=t.onCommandExecuted(e=>{if(e.id===J.id){let t=e.params;t!=null&&t.isAuto||(c.current=!1)}});return()=>{e==null||e.dispose()}},[]);function u(e){s(e),c.current&&t.executeCommand(Je.id,{cropType:e})}let f=e=>{t.executeCommand(Je.id,{cropType:e}),c.current=!0};return H(`div`,{className:z(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!a}),children:[V(`header`,{className:`
|
|
30
|
+
univer-text-gray-600
|
|
31
|
+
dark:!univer-text-gray-200
|
|
32
|
+
`,children:V(`div`,{children:n.t(`image-panel.crop.title`)})}),H(`div`,{className:`univer-flex univer-items-center univer-justify-center univer-gap-2`,children:[H(L,{onClick:()=>{f(o)},children:[V(oe,{}),n.t(`image-panel.crop.start`)]}),V(ke,{value:o,options:l,onChange:u})]})]})},Wt=e=>{let t=I(y),n=I(k),r=I(d),{drawings:i,hasArrange:a=!0,hasTransform:o=!0,hasAlign:s=!0,hasCropper:c=!0,hasGroup:l=!0}=e,u=i[0];if(u==null)return;let{unitId:f}=u,p=n.getRenderById(f),m=p==null?void 0:p.scene;if(m==null)return;let h=m.getTransformerByCreate(),[g,_]=B(!0),[v,b]=B(!0),[x,S]=B(!1),[C,w]=B(!0),[T,E]=B(!1);return je(()=>{let e=h.clearControl$.subscribe(e=>{e===!0&&(_(!1),b(!1),S(!1),w(!1),E(!0))}),n=h.changeStart$.subscribe(e=>{let{objects:n}=e,r=Ot(n,t);r.length===0?(_(!1),b(!1),S(!1),w(!1),E(!0)):r.length===1?(_(!0),b(!0),S(!1),w(!0),E(!1)):(_(!0),b(!1),S(!0),w(!1),E(!1))}),r=t.focus$.subscribe(e=>{e.length===0?(_(!1),b(!1),S(!1),w(!1),E(!0)):e.length===1?(_(!0),b(!0),S(!1),w(!0),E(!1)):(_(!0),b(!1),S(!0),w(!1),E(!1))});return()=>{n.unsubscribe(),e.unsubscribe(),r.unsubscribe()}},[]),H(Ne,{children:[V(`div`,{className:z(`univer-h-full`,{"univer-hidden":!T}),children:V(`div`,{className:`univer-flex univer-h-full univer-items-center univer-justify-center`,children:V(`span`,{children:r.t(`image-panel.null`)})})}),V(zt,{arrangeShow:a===!0?g:!1,drawings:i}),V(Ht,{transformShow:o===!0?v:!1,drawings:i}),V(Rt,{alignShow:s===!0?x:!1,drawings:i}),V(Ut,{cropperShow:c===!0?C:!1,drawings:i}),V(Bt,{hasGroup:l,drawings:i})]})};export{Je as AutoImageCropOperation,Tt as COMPONENT_IMAGE_POPUP_MENU,q as CancelDrawingGroupOperation,J as CloseImageCropOperation,Ke as DRAWING_GROUP_TYPES,Wt as DrawingCommonPanel,It as DrawingRenderService,Pt as ImageCropperObject,Et as ImagePopupMenu,Ye as ImageResetSizeOperation,qe as OpenImageCropOperation,W as SetDrawingAlignOperation,G as SetDrawingArrangeOperation,K as SetDrawingGroupOperation,$ as UniverDrawingUIPlugin,Ze as getCurrentUnitInfo,Ot as getUpdateParams,Xe as insertGroupObject};
|