@8btc/whiteboard 0.0.20-alpha.30 → 0.0.20-alpha.32
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/dist/index.js +740 -731
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,11 +4,11 @@ var ai = (n) => {
|
|
|
4
4
|
};
|
|
5
5
|
var kn = (n, i, t) => i in n ? In(n, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[i] = t;
|
|
6
6
|
var p = (n, i, t) => kn(n, typeof i != "symbol" ? i + "" : i, t), Fe = (n, i, t) => i.has(n) || ai("Cannot " + t);
|
|
7
|
-
var r = (n, i, t) => (Fe(n, i, "read from private field"), t ? t.call(n) : i.get(n)),
|
|
7
|
+
var r = (n, i, t) => (Fe(n, i, "read from private field"), t ? t.call(n) : i.get(n)), u = (n, i, t) => i.has(n) ? ai("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(n) : i.set(n, t), C = (n, i, t, e) => (Fe(n, i, "write to private field"), e ? e.call(n, t) : i.set(n, t), t), E = (n, i, t) => (Fe(n, i, "access private method"), t);
|
|
8
8
|
import { jsxs as k, jsx as c, Fragment as Ie } from "react/jsx-runtime";
|
|
9
|
-
import { useState as
|
|
10
|
-
import
|
|
11
|
-
import { N as b, R as N, I as
|
|
9
|
+
import { useState as $, useEffect as U, useRef as Ue, useMemo as St, forwardRef as A, createContext as Rn, isValidElement as li, version as $n, cloneElement as An, useContext as Fn, Fragment as Hn, useCallback as Q, memo as dt } from "react";
|
|
10
|
+
import M from "konva";
|
|
11
|
+
import { N as b, R as N, I as tt } from "./const-BJHbPsA9.js";
|
|
12
12
|
import Ln from "mitt";
|
|
13
13
|
import { Editor as Dn } from "@tiptap/core";
|
|
14
14
|
import Pn from "@tiptap/starter-kit";
|
|
@@ -28,42 +28,42 @@ import { useCurrentEditor as ts, useEditorState as es } from "@tiptap/react";
|
|
|
28
28
|
import { FloatingDelayGroup as is, useMergeRefs as Ni, FloatingPortal as ns, useFloating as ss, offset as os, flip as rs, shift as as, autoUpdate as ls, useHover as hs, useFocus as cs, useDismiss as ds, useRole as gs, useInteractions as us } from "@floating-ui/react";
|
|
29
29
|
import * as ie from "@radix-ui/react-popover";
|
|
30
30
|
import { useHotkeys as Ti } from "react-hotkeys-hook";
|
|
31
|
-
var T, S,
|
|
31
|
+
var T, S, et, ne, se, oe, re, ae, le, he, ce, de, _i;
|
|
32
32
|
class ms {
|
|
33
33
|
constructor(i, t) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
u(this, de);
|
|
35
|
+
u(this, T);
|
|
36
|
+
u(this, S);
|
|
37
|
+
u(this, et, { x: 0, y: 0, scale: 1 });
|
|
38
38
|
/**
|
|
39
39
|
* 处理滚轮缩放和平移
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
u(this, ne, (i) => {
|
|
42
42
|
i.evt.preventDefault();
|
|
43
43
|
const e = r(this, S).getPointerPosition();
|
|
44
44
|
if (e)
|
|
45
45
|
if (i.evt.ctrlKey) {
|
|
46
|
-
const s = r(this,
|
|
47
|
-
x: (e.x - r(this,
|
|
48
|
-
y: (e.y - r(this,
|
|
49
|
-
}, a = 1.01,
|
|
46
|
+
const s = r(this, et).scale, o = {
|
|
47
|
+
x: (e.x - r(this, et).x) / s,
|
|
48
|
+
y: (e.y - r(this, et).y) / s
|
|
49
|
+
}, a = 1.01, l = i.evt.deltaY > 0 ? -1 : 1, h = Math.min(Math.abs(i.evt.deltaY), 10);
|
|
50
50
|
let d = s;
|
|
51
|
-
for (let
|
|
52
|
-
d =
|
|
53
|
-
const
|
|
54
|
-
x: e.x - o.x *
|
|
55
|
-
y: e.y - o.y *
|
|
51
|
+
for (let g = 0; g < h; g++)
|
|
52
|
+
d = l > 0 ? d * a : d / a;
|
|
53
|
+
const m = Math.max(0.1, Math.min(5, d)), f = {
|
|
54
|
+
x: e.x - o.x * m,
|
|
55
|
+
y: e.y - o.y * m
|
|
56
56
|
};
|
|
57
|
-
r(this, T)._updateViewport({ x:
|
|
57
|
+
r(this, T)._updateViewport({ x: f.x, y: f.y, scale: m });
|
|
58
58
|
} else {
|
|
59
59
|
const s = i.evt.shiftKey ? i.evt.deltaY : i.evt.deltaX, o = i.evt.shiftKey ? 0 : i.evt.deltaY;
|
|
60
60
|
r(this, T)._updateViewport({
|
|
61
|
-
x: r(this,
|
|
62
|
-
y: r(this,
|
|
61
|
+
x: r(this, et).x - s,
|
|
62
|
+
y: r(this, et).y - o
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
-
|
|
66
|
+
u(this, se, (i) => {
|
|
67
67
|
const t = r(this, T).getToolType();
|
|
68
68
|
if (i.evt.button !== 0 || t === "hand")
|
|
69
69
|
return;
|
|
@@ -89,7 +89,7 @@ class ms {
|
|
|
89
89
|
if (s) {
|
|
90
90
|
const o = s.width(), a = s.height();
|
|
91
91
|
if (o && a) {
|
|
92
|
-
const
|
|
92
|
+
const l = {
|
|
93
93
|
x: s.x(),
|
|
94
94
|
y: s.y(),
|
|
95
95
|
width: o,
|
|
@@ -97,14 +97,14 @@ class ms {
|
|
|
97
97
|
};
|
|
98
98
|
r(this, T)._createDraftNode(t, {
|
|
99
99
|
$_parentId: s.id(),
|
|
100
|
-
$_bounds:
|
|
100
|
+
$_bounds: l
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
r(this, T)._selectNodes();
|
|
106
106
|
});
|
|
107
|
-
|
|
107
|
+
u(this, oe, () => {
|
|
108
108
|
const i = r(this, T).getState().toolType;
|
|
109
109
|
if (i === "hand")
|
|
110
110
|
return;
|
|
@@ -123,7 +123,7 @@ class ms {
|
|
|
123
123
|
"arrow"
|
|
124
124
|
].includes(i) && r(this, T)._updateDraftNode();
|
|
125
125
|
});
|
|
126
|
-
|
|
126
|
+
u(this, re, () => {
|
|
127
127
|
const i = r(this, T).getState().toolType;
|
|
128
128
|
if (i !== "hand") {
|
|
129
129
|
if (i === "select") {
|
|
@@ -141,25 +141,25 @@ class ms {
|
|
|
141
141
|
].includes(i) && r(this, T)._finalizeDraftNode(), i === "text" && r(this, T)._createTextNodeAtDrawingPosition("");
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
|
-
|
|
144
|
+
u(this, ae, (i) => {
|
|
145
145
|
if (i.target !== r(this, S))
|
|
146
146
|
return;
|
|
147
147
|
const t = r(this, T).getState().toolType;
|
|
148
148
|
t === "hand" ? this.setCursor("grabbing") : t === "select" && this.setCursor("all-scroll");
|
|
149
149
|
});
|
|
150
|
-
|
|
150
|
+
u(this, le, (i) => {
|
|
151
151
|
i.target === r(this, S) && r(this, T)._updateViewport({
|
|
152
152
|
x: r(this, S).x(),
|
|
153
153
|
y: r(this, S).y()
|
|
154
154
|
});
|
|
155
155
|
});
|
|
156
|
-
|
|
156
|
+
u(this, he, (i) => {
|
|
157
157
|
i.target === r(this, S) && (r(this, T)._updateViewport({
|
|
158
158
|
x: r(this, S).x(),
|
|
159
159
|
y: r(this, S).y()
|
|
160
160
|
}), this.resetCursor());
|
|
161
161
|
});
|
|
162
|
-
|
|
162
|
+
u(this, ce, (i) => {
|
|
163
163
|
if (i.evt.preventDefault(), r(this, T).getToolType() !== "select")
|
|
164
164
|
return;
|
|
165
165
|
const t = r(this, S).getPointerPosition(), e = i.target;
|
|
@@ -172,7 +172,7 @@ class ms {
|
|
|
172
172
|
targetIds: Array.isArray(s) ? s.map((o) => o.id()) : s ? [s.id()] : []
|
|
173
173
|
});
|
|
174
174
|
});
|
|
175
|
-
|
|
175
|
+
C(this, T, i), C(this, S, new M.Stage({
|
|
176
176
|
id: "canvas-stage",
|
|
177
177
|
container: t.container,
|
|
178
178
|
width: t.width,
|
|
@@ -195,14 +195,14 @@ class ms {
|
|
|
195
195
|
* 获取当前视口状态
|
|
196
196
|
*/
|
|
197
197
|
getViewport() {
|
|
198
|
-
return { ...r(this,
|
|
198
|
+
return { ...r(this, et) };
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
201
201
|
* 设置视口(包括位置、缩放和尺寸)
|
|
202
202
|
*/
|
|
203
203
|
setViewport(i) {
|
|
204
|
-
const t = { ...r(this,
|
|
205
|
-
|
|
204
|
+
const t = { ...r(this, et), ...i };
|
|
205
|
+
C(this, et, t), i.x !== void 0 && r(this, S).x(i.x), i.y !== void 0 && r(this, S).y(i.y), i.scale !== void 0 && (r(this, S).scaleX(i.scale), r(this, S).scaleY(i.scale));
|
|
206
206
|
}
|
|
207
207
|
/**
|
|
208
208
|
* 设置是否可拖拽
|
|
@@ -235,55 +235,55 @@ class ms {
|
|
|
235
235
|
r(this, S).destroy();
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
T = new WeakMap(), S = new WeakMap(),
|
|
238
|
+
T = new WeakMap(), S = new WeakMap(), et = new WeakMap(), ne = new WeakMap(), se = new WeakMap(), oe = new WeakMap(), re = new WeakMap(), ae = new WeakMap(), le = new WeakMap(), he = new WeakMap(), ce = new WeakMap(), de = new WeakSet(), /**
|
|
239
239
|
* 设置事件监听器
|
|
240
240
|
*/
|
|
241
241
|
_i = function() {
|
|
242
242
|
r(this, S).on("wheel", r(this, ne)), r(this, S).on("pointerdown", r(this, se)), r(this, S).on("pointermove", r(this, oe)), r(this, S).on("pointerup", r(this, re)), r(this, S).on("dragstart", r(this, ae)), r(this, S).on("dragmove", r(this, le)), r(this, S).on("dragend", r(this, he)), r(this, S).on("contextmenu", r(this, ce));
|
|
243
243
|
};
|
|
244
|
-
var Lt,
|
|
244
|
+
var Lt, _, ge, ue, me, fe, pe, ye, ve, Mi;
|
|
245
245
|
class fs {
|
|
246
246
|
constructor(i, t) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
u(this, ve);
|
|
248
|
+
u(this, Lt);
|
|
249
|
+
u(this, _);
|
|
250
250
|
/**
|
|
251
251
|
* 处理 transformstart 事件
|
|
252
252
|
*/
|
|
253
|
-
|
|
253
|
+
u(this, ge, () => {
|
|
254
254
|
this.emitPositionChange();
|
|
255
255
|
});
|
|
256
256
|
/**
|
|
257
257
|
* 处理 transform 事件
|
|
258
258
|
*/
|
|
259
|
-
|
|
259
|
+
u(this, ue, () => {
|
|
260
260
|
this.emitPositionChange();
|
|
261
261
|
});
|
|
262
262
|
/**
|
|
263
263
|
* 处理 transformend 事件
|
|
264
264
|
*/
|
|
265
|
-
|
|
265
|
+
u(this, me, () => {
|
|
266
266
|
this.emitPositionChange();
|
|
267
267
|
});
|
|
268
268
|
/**
|
|
269
269
|
* 处理 dragstart 事件
|
|
270
270
|
*/
|
|
271
|
-
|
|
271
|
+
u(this, fe, () => {
|
|
272
272
|
this.emitPositionChange();
|
|
273
273
|
});
|
|
274
274
|
/**
|
|
275
275
|
* 处理 dragmove 事件
|
|
276
276
|
*/
|
|
277
|
-
|
|
277
|
+
u(this, pe, () => {
|
|
278
278
|
this.emitPositionChange();
|
|
279
279
|
});
|
|
280
280
|
/**
|
|
281
281
|
* 处理 dragend 事件
|
|
282
282
|
*/
|
|
283
|
-
|
|
283
|
+
u(this, ye, () => {
|
|
284
284
|
this.emitPositionChange();
|
|
285
285
|
});
|
|
286
|
-
|
|
286
|
+
C(this, Lt, i), C(this, _, new M.Transformer({
|
|
287
287
|
rotateEnabled: t?.rotateEnabled ?? !0,
|
|
288
288
|
ignoreStroke: t?.ignoreStroke ?? !0,
|
|
289
289
|
anchorSize: t?.anchorSize ?? 8,
|
|
@@ -297,21 +297,21 @@ class fs {
|
|
|
297
297
|
* 获取原生 Konva.Transformer 实例
|
|
298
298
|
*/
|
|
299
299
|
getTransformer() {
|
|
300
|
-
return r(this,
|
|
300
|
+
return r(this, _);
|
|
301
301
|
}
|
|
302
302
|
/**
|
|
303
303
|
* 获取 Transformer 的位置信息
|
|
304
304
|
*/
|
|
305
305
|
getPosition() {
|
|
306
|
-
if (r(this,
|
|
306
|
+
if (r(this, _).nodes().length === 0)
|
|
307
307
|
return null;
|
|
308
|
-
const t = r(this,
|
|
308
|
+
const t = r(this, _).getClientRect();
|
|
309
309
|
return {
|
|
310
310
|
x: t.x,
|
|
311
311
|
y: t.y,
|
|
312
312
|
width: t.width,
|
|
313
313
|
height: t.height,
|
|
314
|
-
rotation: r(this,
|
|
314
|
+
rotation: r(this, _).rotation()
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
317
|
/**
|
|
@@ -322,30 +322,39 @@ class fs {
|
|
|
322
322
|
this.clearNodes();
|
|
323
323
|
return;
|
|
324
324
|
}
|
|
325
|
-
r(this,
|
|
325
|
+
r(this, _).nodes(i), r(this, _).moveToTop(), r(this, _).rotateEnabled(
|
|
326
326
|
!i.some(
|
|
327
327
|
(t) => ["rich-text", "html"].includes(t.getAttr("$_type"))
|
|
328
328
|
)
|
|
329
|
-
), i.length === 1 && i[0].getAttr("$_type") === "rich-text"
|
|
329
|
+
), i.length === 1 && i[0].getAttr("$_type") === "rich-text" ? r(this, _).enabledAnchors([
|
|
330
330
|
"top-left",
|
|
331
331
|
"top-right",
|
|
332
332
|
"bottom-left",
|
|
333
333
|
"bottom-right",
|
|
334
334
|
"middle-left",
|
|
335
335
|
"middle-right"
|
|
336
|
-
])
|
|
336
|
+
]) : i.length === 1 && i[0].getAttr("$_type") === "arrow" ? (r(this, _).enabledAnchors([]), r(this, _).rotateEnabled(!1), r(this, _).borderStroke("transparent")) : (r(this, _).visible(!0), r(this, _).rotateEnabled(!0), r(this, _).enabledAnchors([
|
|
337
|
+
"top-left",
|
|
338
|
+
"top-center",
|
|
339
|
+
"top-right",
|
|
340
|
+
"middle-right",
|
|
341
|
+
"middle-left",
|
|
342
|
+
"bottom-left",
|
|
343
|
+
"bottom-center",
|
|
344
|
+
"bottom-right"
|
|
345
|
+
]), r(this, _).borderStroke("rgb(0, 161, 255)")), this.emitPositionChange();
|
|
337
346
|
}
|
|
338
347
|
/**
|
|
339
348
|
* 获取当前变换的节点
|
|
340
349
|
*/
|
|
341
350
|
getNodes() {
|
|
342
|
-
return r(this,
|
|
351
|
+
return r(this, _).nodes();
|
|
343
352
|
}
|
|
344
353
|
/**
|
|
345
354
|
* 清除所有节点
|
|
346
355
|
*/
|
|
347
356
|
clearNodes() {
|
|
348
|
-
r(this,
|
|
357
|
+
r(this, _).nodes([]), this.emitPositionChange();
|
|
349
358
|
}
|
|
350
359
|
/**
|
|
351
360
|
* emit Transformer 位置
|
|
@@ -358,15 +367,15 @@ class fs {
|
|
|
358
367
|
* 销毁 Transformer
|
|
359
368
|
*/
|
|
360
369
|
destroy() {
|
|
361
|
-
r(this,
|
|
370
|
+
r(this, _).destroy();
|
|
362
371
|
}
|
|
363
372
|
}
|
|
364
|
-
Lt = new WeakMap(),
|
|
373
|
+
Lt = new WeakMap(), _ = new WeakMap(), ge = new WeakMap(), ue = new WeakMap(), me = new WeakMap(), fe = new WeakMap(), pe = new WeakMap(), ye = new WeakMap(), ve = new WeakSet(), /**
|
|
365
374
|
* 设置事件监听器
|
|
366
375
|
*/
|
|
367
376
|
Mi = function() {
|
|
368
|
-
r(this,
|
|
369
|
-
const t = r(this,
|
|
377
|
+
r(this, _).on("transformstart", r(this, ge)), r(this, _).on("transform", r(this, ue)), r(this, _).on("transformend", r(this, me)), r(this, _).on("dragstart", r(this, fe)), r(this, _).on("dragmove", r(this, pe)), r(this, _).on("dragend", r(this, ye)), r(this, _).on("pointerdblclick", (i) => {
|
|
378
|
+
const t = r(this, _).nodes();
|
|
370
379
|
if (t.length === 1) {
|
|
371
380
|
const e = t[0];
|
|
372
381
|
e.fire("pointerdblclick", {
|
|
@@ -376,85 +385,85 @@ Mi = function() {
|
|
|
376
385
|
}
|
|
377
386
|
});
|
|
378
387
|
};
|
|
379
|
-
var
|
|
388
|
+
var P, O, G, Z;
|
|
380
389
|
class ps {
|
|
381
390
|
// todo: 优化 selectedNodeIds 的存储和查询性能
|
|
382
391
|
// private _selectedNodeIds: Set<string> = new Set();
|
|
383
392
|
constructor(i) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
393
|
+
u(this, P, []);
|
|
394
|
+
u(this, O);
|
|
395
|
+
u(this, G, []);
|
|
396
|
+
u(this, Z);
|
|
397
|
+
C(this, O, i), C(this, Z, Ln());
|
|
389
398
|
}
|
|
390
399
|
/**
|
|
391
400
|
* 获取当前状态
|
|
392
401
|
*/
|
|
393
402
|
getState() {
|
|
394
|
-
return { ...r(this,
|
|
403
|
+
return { ...r(this, O) };
|
|
395
404
|
}
|
|
396
405
|
/**
|
|
397
406
|
* 获取完整历史状态
|
|
398
407
|
*/
|
|
399
408
|
getHistory() {
|
|
400
409
|
return {
|
|
401
|
-
past: [...r(this,
|
|
402
|
-
present: { ...r(this,
|
|
403
|
-
future: [...r(this,
|
|
410
|
+
past: [...r(this, P)],
|
|
411
|
+
present: { ...r(this, O) },
|
|
412
|
+
future: [...r(this, G)]
|
|
404
413
|
};
|
|
405
414
|
}
|
|
406
415
|
/**
|
|
407
416
|
* 是否可以撤销
|
|
408
417
|
*/
|
|
409
418
|
canUndo() {
|
|
410
|
-
return r(this,
|
|
419
|
+
return r(this, P).length > 0;
|
|
411
420
|
}
|
|
412
421
|
/**
|
|
413
422
|
* 是否可以重做
|
|
414
423
|
*/
|
|
415
424
|
canRedo() {
|
|
416
|
-
return r(this,
|
|
425
|
+
return r(this, G).length > 0;
|
|
417
426
|
}
|
|
418
427
|
/**
|
|
419
428
|
* 订阅状态事件
|
|
420
429
|
*/
|
|
421
430
|
on(i, t) {
|
|
422
|
-
r(this,
|
|
431
|
+
r(this, Z).on(i, t);
|
|
423
432
|
}
|
|
424
433
|
/**
|
|
425
434
|
* 取消订阅状态事件
|
|
426
435
|
*/
|
|
427
436
|
off(i, t) {
|
|
428
|
-
r(this,
|
|
437
|
+
r(this, Z).off(i, t);
|
|
429
438
|
}
|
|
430
439
|
/**
|
|
431
440
|
* @internal
|
|
432
441
|
* 发送事件
|
|
433
442
|
*/
|
|
434
443
|
_emit(i, t) {
|
|
435
|
-
r(this,
|
|
444
|
+
r(this, Z).emit(i, t);
|
|
436
445
|
}
|
|
437
446
|
/**
|
|
438
447
|
* 撤销操作
|
|
439
448
|
*/
|
|
440
449
|
undo() {
|
|
441
|
-
if (r(this,
|
|
442
|
-
const i = r(this,
|
|
443
|
-
|
|
450
|
+
if (r(this, P).length === 0) return;
|
|
451
|
+
const i = r(this, P)[r(this, P).length - 1], t = r(this, P).slice(0, r(this, P).length - 1);
|
|
452
|
+
C(this, P, t), C(this, G, [r(this, O), ...r(this, G)]), C(this, O, i), this._renderCanvas(i), r(this, Z).emit("state:undo", i), r(this, Z).emit("state:change", i);
|
|
444
453
|
}
|
|
445
454
|
/**
|
|
446
455
|
* 重做操作
|
|
447
456
|
*/
|
|
448
457
|
redo() {
|
|
449
|
-
if (r(this,
|
|
450
|
-
const i = r(this,
|
|
451
|
-
|
|
458
|
+
if (r(this, G).length === 0) return;
|
|
459
|
+
const i = r(this, G)[0], t = r(this, G).slice(1);
|
|
460
|
+
C(this, P, [...r(this, P), r(this, O)]), C(this, G, t), C(this, O, i), this._renderCanvas(i), r(this, Z).emit("state:redo", i), r(this, Z).emit("state:change", i);
|
|
452
461
|
}
|
|
453
462
|
/**
|
|
454
463
|
* 重置历史记录
|
|
455
464
|
*/
|
|
456
465
|
resetHistory() {
|
|
457
|
-
|
|
466
|
+
C(this, P, []), C(this, G, []), r(this, Z).emit("state:reset", r(this, O)), r(this, Z).emit("state:change", r(this, O));
|
|
458
467
|
}
|
|
459
468
|
/**
|
|
460
469
|
* 更新状态
|
|
@@ -462,17 +471,17 @@ class ps {
|
|
|
462
471
|
* @param addToHistory - 是否添加到历史记录
|
|
463
472
|
*/
|
|
464
473
|
_updateState(i, t) {
|
|
465
|
-
const e = { ...r(this,
|
|
466
|
-
t && (
|
|
474
|
+
const e = { ...r(this, O), ...i };
|
|
475
|
+
t && (C(this, P, [...r(this, P), r(this, O)]), C(this, G, [])), C(this, O, e), r(this, Z).emit("state:change", e);
|
|
467
476
|
}
|
|
468
477
|
/**
|
|
469
478
|
* 清理资源
|
|
470
479
|
*/
|
|
471
480
|
_dispose() {
|
|
472
|
-
r(this,
|
|
481
|
+
r(this, Z).all.clear();
|
|
473
482
|
}
|
|
474
483
|
}
|
|
475
|
-
|
|
484
|
+
P = new WeakMap(), O = new WeakMap(), G = new WeakMap(), Z = new WeakMap();
|
|
476
485
|
class st {
|
|
477
486
|
}
|
|
478
487
|
const ys = {
|
|
@@ -574,9 +583,9 @@ function ki(n, i) {
|
|
|
574
583
|
{ x: 0, y: 0.25 }
|
|
575
584
|
// 左上
|
|
576
585
|
]
|
|
577
|
-
}[i].map((
|
|
578
|
-
x: Number((t +
|
|
579
|
-
y: Number((e +
|
|
586
|
+
}[i].map((h) => ({
|
|
587
|
+
x: Number((t + h.x * s).toFixed(2)) - n.x,
|
|
588
|
+
y: Number((e + h.y * o).toFixed(2)) - n.y
|
|
580
589
|
}));
|
|
581
590
|
}
|
|
582
591
|
function hi(n, i) {
|
|
@@ -600,7 +609,7 @@ function hi(n, i) {
|
|
|
600
609
|
};
|
|
601
610
|
}
|
|
602
611
|
function ci(n, i) {
|
|
603
|
-
const t = n.width ??
|
|
612
|
+
const t = n.width ?? tt.MIN_SIZE, e = n.height ?? tt.MIN_SIZE, s = ot(n, i);
|
|
604
613
|
if (!n.image) {
|
|
605
614
|
const a = document.createElement("canvas");
|
|
606
615
|
a.width = t, a.height = e, n.image = a;
|
|
@@ -613,7 +622,7 @@ function ci(n, i) {
|
|
|
613
622
|
};
|
|
614
623
|
}
|
|
615
624
|
function di(n, i) {
|
|
616
|
-
const t = n.width ??
|
|
625
|
+
const t = n.width ?? tt.MIN_SIZE, e = n.height ?? tt.MIN_SIZE, s = ot(n, i);
|
|
617
626
|
if (!n.$_coverUrl) {
|
|
618
627
|
const a = document.createElement("canvas");
|
|
619
628
|
a.width = t, a.height = e, n.image = a;
|
|
@@ -725,7 +734,7 @@ function vi(n, i) {
|
|
|
725
734
|
strokeWidth: 2,
|
|
726
735
|
...n,
|
|
727
736
|
...s,
|
|
728
|
-
points: o.flatMap((
|
|
737
|
+
points: o.flatMap((l) => [l.x, l.y]),
|
|
729
738
|
closed: !0,
|
|
730
739
|
name: `${b.nodeRoot} ${b.selectable} ${b.polygon}`,
|
|
731
740
|
draggable: !0,
|
|
@@ -768,12 +777,12 @@ var Dt, Ce, $i;
|
|
|
768
777
|
class ws extends st {
|
|
769
778
|
constructor(t, e, s = !1) {
|
|
770
779
|
super();
|
|
771
|
-
|
|
780
|
+
u(this, Ce);
|
|
772
781
|
p(this, "core");
|
|
773
782
|
p(this, "config");
|
|
774
783
|
p(this, "element");
|
|
775
784
|
p(this, "isDraft");
|
|
776
|
-
|
|
785
|
+
u(this, Dt, ({ type: t }) => {
|
|
777
786
|
const e = t === "select";
|
|
778
787
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
779
788
|
});
|
|
@@ -790,7 +799,7 @@ class ws extends st {
|
|
|
790
799
|
this.config = e;
|
|
791
800
|
}
|
|
792
801
|
createElement() {
|
|
793
|
-
return new
|
|
802
|
+
return new M.Rect(this.config);
|
|
794
803
|
}
|
|
795
804
|
/**
|
|
796
805
|
* 获取 Konva.Rect 实例
|
|
@@ -831,20 +840,20 @@ $i = function() {
|
|
|
831
840
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
832
841
|
});
|
|
833
842
|
};
|
|
834
|
-
var
|
|
843
|
+
var ct, He, Pt, Bt, Ai, Le;
|
|
835
844
|
class bs extends st {
|
|
836
845
|
constructor(t, e, s = !1) {
|
|
837
846
|
super();
|
|
838
|
-
|
|
847
|
+
u(this, ct);
|
|
839
848
|
p(this, "core");
|
|
840
849
|
p(this, "config");
|
|
841
850
|
p(this, "element");
|
|
842
851
|
p(this, "isDraft");
|
|
843
|
-
|
|
852
|
+
u(this, Pt, ({ type: t }) => {
|
|
844
853
|
const e = t === "select";
|
|
845
854
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
846
855
|
});
|
|
847
|
-
|
|
856
|
+
u(this, Bt, () => {
|
|
848
857
|
const t = this.getElement().getLayer();
|
|
849
858
|
if (!t) return;
|
|
850
859
|
const e = t.find(
|
|
@@ -858,7 +867,7 @@ class bs extends st {
|
|
|
858
867
|
!0
|
|
859
868
|
);
|
|
860
869
|
});
|
|
861
|
-
this.core = t, this.config = ci(e, this.core.getTheme()), this.element = this.createElement(), rt(this.element, this), this.isDraft = s, E(this,
|
|
870
|
+
this.core = t, this.config = ci(e, this.core.getTheme()), this.element = this.createElement(), rt(this.element, this), this.isDraft = s, E(this, ct, He).call(this), E(this, ct, Ai).call(this, this.getElement());
|
|
862
871
|
}
|
|
863
872
|
getID() {
|
|
864
873
|
return this.config.id;
|
|
@@ -870,7 +879,7 @@ class bs extends st {
|
|
|
870
879
|
this.config = e;
|
|
871
880
|
}
|
|
872
881
|
createElement() {
|
|
873
|
-
return new
|
|
882
|
+
return new M.Image(this.config);
|
|
874
883
|
}
|
|
875
884
|
/**
|
|
876
885
|
* 获取 Konva.Image 实例
|
|
@@ -889,7 +898,7 @@ class bs extends st {
|
|
|
889
898
|
...t
|
|
890
899
|
},
|
|
891
900
|
this.core.getTheme()
|
|
892
|
-
), delete this.config.image, this.getElement().setAttrs(this.config), t.$_imageUrl && t.$_imageUrl !== e.$_imageUrl && E(this,
|
|
901
|
+
), delete this.config.image, this.getElement().setAttrs(this.config), t.$_imageUrl && t.$_imageUrl !== e.$_imageUrl && E(this, ct, He).call(this);
|
|
893
902
|
}
|
|
894
903
|
/**
|
|
895
904
|
* 销毁
|
|
@@ -904,7 +913,7 @@ class bs extends st {
|
|
|
904
913
|
};
|
|
905
914
|
}
|
|
906
915
|
}
|
|
907
|
-
|
|
916
|
+
ct = new WeakSet(), /**
|
|
908
917
|
* 加载图片
|
|
909
918
|
*/
|
|
910
919
|
He = function() {
|
|
@@ -917,7 +926,7 @@ He = function() {
|
|
|
917
926
|
e.crossOrigin = "anonymous", e.src = t, e.onload = () => {
|
|
918
927
|
this.getElement().image(e);
|
|
919
928
|
const s = this.config.width ?? e.width, o = this.config.height ?? e.height;
|
|
920
|
-
this.getElement().width(Math.max(s,
|
|
929
|
+
this.getElement().width(Math.max(s, tt.MIN_SIZE)), this.getElement().height(Math.max(o, tt.MIN_SIZE));
|
|
921
930
|
}, e.onerror = () => {
|
|
922
931
|
console.error("Failed to load image:", t);
|
|
923
932
|
};
|
|
@@ -926,12 +935,12 @@ He = function() {
|
|
|
926
935
|
*/
|
|
927
936
|
Ai = function(t) {
|
|
928
937
|
this.core.on("toolType:change", r(this, Pt)), t.on("transform", (e) => {
|
|
929
|
-
const s = e.target, o = Math.max(
|
|
930
|
-
s.scale({ x: 1, y: 1 }), s.width(o), s.height(a), E(this,
|
|
938
|
+
const s = e.target, o = Math.max(tt.MIN_SIZE, s.width() * s.scaleX()), a = Math.max(tt.MIN_SIZE, s.height() * s.scaleY());
|
|
939
|
+
s.scale({ x: 1, y: 1 }), s.width(o), s.height(a), E(this, ct, Le).call(this);
|
|
931
940
|
}), t.on("transformend", () => {
|
|
932
941
|
this.syncConfigFromElement(), r(this, Bt).call(this);
|
|
933
942
|
}), t.on("dragmove", () => {
|
|
934
|
-
E(this,
|
|
943
|
+
E(this, ct, Le).call(this);
|
|
935
944
|
}), t.on("dragend", () => {
|
|
936
945
|
this.syncConfigFromElement(), r(this, Bt).call(this);
|
|
937
946
|
});
|
|
@@ -941,46 +950,46 @@ Ai = function(t) {
|
|
|
941
950
|
Le = function() {
|
|
942
951
|
const t = this.getElement(), e = t.getLayer();
|
|
943
952
|
if (!e) return;
|
|
944
|
-
const s = t.x(), o = t.y(), a = t.width(),
|
|
945
|
-
(
|
|
953
|
+
const s = t.x(), o = t.y(), a = t.width(), l = t.height(), h = e.find(
|
|
954
|
+
(m) => m.hasName(this.config.id)
|
|
946
955
|
), d = this.core.getState().nodes || [];
|
|
947
|
-
|
|
948
|
-
const
|
|
949
|
-
if (
|
|
950
|
-
const { start:
|
|
951
|
-
|
|
952
|
-
x:
|
|
953
|
-
y:
|
|
954
|
-
width:
|
|
955
|
-
height:
|
|
956
|
-
}),
|
|
957
|
-
|
|
958
|
-
}), xi(
|
|
956
|
+
h.forEach((m) => {
|
|
957
|
+
const f = d.find((g) => g.id === m.id());
|
|
958
|
+
if (f?.$_type === "image-marker" && f.$_relativeBox) {
|
|
959
|
+
const { start: g, end: y } = f.$_relativeBox, x = s + g.ratioX * a, v = o + g.ratioY * l, I = s + y.ratioX * a, w = o + y.ratioY * l, z = Math.min(x, I), X = Math.min(v, w), R = Math.abs(I - x), F = Math.abs(w - v);
|
|
960
|
+
m.setAttrs({
|
|
961
|
+
x: z,
|
|
962
|
+
y: X,
|
|
963
|
+
width: R,
|
|
964
|
+
height: F
|
|
965
|
+
}), m.getChildren().forEach((Y) => {
|
|
966
|
+
Y.getClassName() === "Rect" ? Y.setAttrs({ width: R, height: F }) : Y.getClassName() === "Group" && Y.setAttrs({ x: R, y: F });
|
|
967
|
+
}), xi(m)?.syncConfigFromElement();
|
|
959
968
|
}
|
|
960
969
|
});
|
|
961
970
|
};
|
|
962
|
-
var
|
|
971
|
+
var at, K, mt, lt, _t, Mt, $t, Fi, Hi;
|
|
963
972
|
class Es extends st {
|
|
964
973
|
constructor(t, e, s = !1) {
|
|
965
974
|
super();
|
|
966
|
-
|
|
975
|
+
u(this, $t);
|
|
967
976
|
p(this, "core");
|
|
968
977
|
p(this, "config");
|
|
969
978
|
p(this, "element");
|
|
970
979
|
p(this, "isDraft");
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
980
|
+
u(this, at);
|
|
981
|
+
u(this, K);
|
|
982
|
+
u(this, mt);
|
|
983
|
+
u(this, lt);
|
|
984
|
+
u(this, _t);
|
|
985
|
+
u(this, Mt);
|
|
977
986
|
this.core = t, this.config = gi(e, this.core.getTheme()), this.isDraft = s, this.element = this.createElement(), rt(this.element, this);
|
|
978
987
|
const o = this.getElement();
|
|
979
|
-
|
|
988
|
+
C(this, at, o.findOne(".rect")), C(this, K, o.findOne(".marker-group")), C(this, mt, r(this, K).findOne("Circle")), C(this, lt, r(this, K).findOne("Text")), E(this, $t, Hi).call(this), C(this, _t, () => {
|
|
980
989
|
E(this, $t, Fi).call(this);
|
|
981
|
-
}), this.core.on("viewport:scale:change", r(this, _t)),
|
|
982
|
-
const
|
|
983
|
-
this.setFocusState(
|
|
990
|
+
}), this.core.on("viewport:scale:change", r(this, _t)), C(this, Mt, (a) => {
|
|
991
|
+
const l = a.includes(this.config.id);
|
|
992
|
+
this.setFocusState(l);
|
|
984
993
|
}), this.core.on("nodes:selected", r(this, Mt));
|
|
985
994
|
}
|
|
986
995
|
getID() {
|
|
@@ -990,14 +999,14 @@ class Es extends st {
|
|
|
990
999
|
return this.config;
|
|
991
1000
|
}
|
|
992
1001
|
createElement() {
|
|
993
|
-
const t = Math.max(this.config.width ?? N.MIN_SIZE, N.MIN_SIZE), e = Math.max(this.config.height ?? N.MIN_SIZE, N.MIN_SIZE), s = new
|
|
1002
|
+
const t = Math.max(this.config.width ?? N.MIN_SIZE, N.MIN_SIZE), e = Math.max(this.config.height ?? N.MIN_SIZE, N.MIN_SIZE), s = new M.Group({
|
|
994
1003
|
id: this.config.id,
|
|
995
1004
|
name: `${b.nodeRoot} ${b.imageMarker} ${this.config.$_parentId}`,
|
|
996
1005
|
x: this.config.x,
|
|
997
1006
|
y: this.config.y,
|
|
998
1007
|
width: t,
|
|
999
1008
|
height: e
|
|
1000
|
-
}), o = this.core.getStageScale(), a = 2 / o,
|
|
1009
|
+
}), o = this.core.getStageScale(), a = 2 / o, l = N.CORNER_RADIUS / o, h = new M.Rect({
|
|
1001
1010
|
name: "rect",
|
|
1002
1011
|
x: 0,
|
|
1003
1012
|
y: 0,
|
|
@@ -1005,20 +1014,20 @@ class Es extends st {
|
|
|
1005
1014
|
height: e,
|
|
1006
1015
|
stroke: this.config.markerColor,
|
|
1007
1016
|
strokeWidth: a,
|
|
1008
|
-
dash:
|
|
1017
|
+
// dash: rectDash,
|
|
1009
1018
|
cornerRadius: l,
|
|
1010
1019
|
listening: !1
|
|
1011
|
-
}),
|
|
1020
|
+
}), d = new M.Group({
|
|
1012
1021
|
name: "marker-group",
|
|
1013
1022
|
x: t,
|
|
1014
1023
|
y: e,
|
|
1015
1024
|
visible: !this.isDraft
|
|
1016
|
-
}), m = 14 / o,
|
|
1025
|
+
}), m = 14 / o, f = 3 / o, g = 16 / o, y = new M.Circle({
|
|
1017
1026
|
radius: m,
|
|
1018
1027
|
fill: this.config.markerColor,
|
|
1019
1028
|
stroke: "white",
|
|
1020
|
-
strokeWidth:
|
|
1021
|
-
}),
|
|
1029
|
+
strokeWidth: f
|
|
1030
|
+
}), x = new M.Text({
|
|
1022
1031
|
x: -m,
|
|
1023
1032
|
y: -m,
|
|
1024
1033
|
width: m * 2,
|
|
@@ -1026,10 +1035,10 @@ class Es extends st {
|
|
|
1026
1035
|
text: String(this.config.$_markerNumber || ""),
|
|
1027
1036
|
align: "center",
|
|
1028
1037
|
verticalAlign: "middle",
|
|
1029
|
-
fontSize:
|
|
1038
|
+
fontSize: g,
|
|
1030
1039
|
fill: "white"
|
|
1031
1040
|
});
|
|
1032
|
-
return
|
|
1041
|
+
return d.add(y), d.add(x), s.add(h), s.add(d), s;
|
|
1033
1042
|
}
|
|
1034
1043
|
/**
|
|
1035
1044
|
* 获取 Konva.Group 实例
|
|
@@ -1051,7 +1060,7 @@ class Es extends st {
|
|
|
1051
1060
|
const e = this.getElement();
|
|
1052
1061
|
e.x(this.config.x), e.y(this.config.y);
|
|
1053
1062
|
const s = Math.max(this.config.width ?? N.MIN_SIZE, N.MIN_SIZE), o = Math.max(this.config.height ?? N.MIN_SIZE, N.MIN_SIZE);
|
|
1054
|
-
e.width(s), e.height(o), r(this,
|
|
1063
|
+
e.width(s), e.height(o), r(this, at).width(s), r(this, at).height(o), r(this, K).x(s), r(this, K).y(o), t.markerColor && (r(this, at).stroke(t.markerColor), r(this, mt).fill(t.markerColor)), t.$_markerNumber !== void 0 && r(this, lt).text(String(t.$_markerNumber));
|
|
1055
1064
|
}
|
|
1056
1065
|
/**
|
|
1057
1066
|
* 销毁
|
|
@@ -1064,7 +1073,7 @@ class Es extends st {
|
|
|
1064
1073
|
*/
|
|
1065
1074
|
setFocusState(t) {
|
|
1066
1075
|
const e = this.core.getStageScale(), s = t ? 4 / e : 3 / e, o = t ? 1.2 : 1;
|
|
1067
|
-
r(this,
|
|
1076
|
+
r(this, at).strokeWidth(s), r(this, mt).strokeWidth(s), r(this, K).scaleX(o), r(this, K).scaleY(o);
|
|
1068
1077
|
}
|
|
1069
1078
|
syncConfigFromElement() {
|
|
1070
1079
|
const t = this.getElement();
|
|
@@ -1077,22 +1086,22 @@ class Es extends st {
|
|
|
1077
1086
|
};
|
|
1078
1087
|
}
|
|
1079
1088
|
}
|
|
1080
|
-
|
|
1089
|
+
at = new WeakMap(), K = new WeakMap(), mt = new WeakMap(), lt = new WeakMap(), _t = new WeakMap(), Mt = new WeakMap(), $t = new WeakSet(), /**
|
|
1081
1090
|
* 更新标记点的缩放以保持视觉大小不变
|
|
1082
1091
|
*/
|
|
1083
1092
|
Fi = function() {
|
|
1084
|
-
const t = this.core.getStageScale(), e = 14 / t, s = 3 / t, o = 16 / t, a = 3 / t,
|
|
1085
|
-
r(this,
|
|
1093
|
+
const t = this.core.getStageScale(), e = 14 / t, s = 3 / t, o = 16 / t, a = 3 / t, l = N.CORNER_RADIUS / t;
|
|
1094
|
+
r(this, at).strokeWidth(a), r(this, at).cornerRadius(l), r(this, mt).radius(e), r(this, mt).strokeWidth(s), r(this, lt).x(-e), r(this, lt).y(-e), r(this, lt).width(e * 2), r(this, lt).height(e * 2), r(this, lt).fontSize(o);
|
|
1086
1095
|
}, /**
|
|
1087
1096
|
* 设置事件处理器
|
|
1088
1097
|
*/
|
|
1089
1098
|
Hi = function() {
|
|
1090
|
-
r(this,
|
|
1099
|
+
r(this, K).on("pointerover", () => {
|
|
1091
1100
|
this.setFocusState(!0), this.core._setCursor("pointer");
|
|
1092
|
-
}), r(this,
|
|
1101
|
+
}), r(this, K).on("pointerout", () => {
|
|
1093
1102
|
const e = (this.core.getState().selectedNodeIds || []).includes(this.config.id);
|
|
1094
1103
|
this.setFocusState(e), this.core._resetCursor();
|
|
1095
|
-
}), r(this,
|
|
1104
|
+
}), r(this, K).on("pointerdown", () => {
|
|
1096
1105
|
this.core._selectNodes([this.config.id]);
|
|
1097
1106
|
});
|
|
1098
1107
|
};
|
|
@@ -1100,17 +1109,17 @@ var gt, Vt, xe, Li;
|
|
|
1100
1109
|
class Ss extends st {
|
|
1101
1110
|
constructor(t, e, s = !1) {
|
|
1102
1111
|
super();
|
|
1103
|
-
|
|
1112
|
+
u(this, xe);
|
|
1104
1113
|
p(this, "core");
|
|
1105
1114
|
p(this, "config");
|
|
1106
1115
|
p(this, "element");
|
|
1107
1116
|
p(this, "isDraft");
|
|
1108
1117
|
p(this, "htmlElement");
|
|
1109
|
-
|
|
1118
|
+
u(this, gt, () => {
|
|
1110
1119
|
const t = this.element.getClientRect();
|
|
1111
1120
|
this.htmlElement.style.left = `${t.x}px`, this.htmlElement.style.top = `${t.y}px`, this.htmlElement.style.width = `${t.width}px`, this.htmlElement.style.height = `${t.height}px`;
|
|
1112
1121
|
});
|
|
1113
|
-
|
|
1122
|
+
u(this, Vt, ({ type: t }) => {
|
|
1114
1123
|
const e = t === "select";
|
|
1115
1124
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1116
1125
|
});
|
|
@@ -1129,7 +1138,7 @@ class Ss extends st {
|
|
|
1129
1138
|
this.config = e;
|
|
1130
1139
|
}
|
|
1131
1140
|
createElement() {
|
|
1132
|
-
return new
|
|
1141
|
+
return new M.Rect(this.config);
|
|
1133
1142
|
}
|
|
1134
1143
|
/**
|
|
1135
1144
|
* 获取 Konva.Rect 实例
|
|
@@ -1176,50 +1185,50 @@ var Ot, we, be, Di;
|
|
|
1176
1185
|
class Ns extends st {
|
|
1177
1186
|
constructor(t, e, s = !1) {
|
|
1178
1187
|
super();
|
|
1179
|
-
|
|
1188
|
+
u(this, be);
|
|
1180
1189
|
p(this, "core");
|
|
1181
1190
|
p(this, "config");
|
|
1182
1191
|
p(this, "element");
|
|
1183
1192
|
p(this, "isDraft");
|
|
1184
1193
|
p(this, "rect");
|
|
1185
|
-
|
|
1194
|
+
u(this, Ot, ({ type: t }) => {
|
|
1186
1195
|
const e = t === "select";
|
|
1187
1196
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1188
1197
|
});
|
|
1189
1198
|
/**
|
|
1190
1199
|
* 编辑文字
|
|
1191
1200
|
*/
|
|
1192
|
-
|
|
1201
|
+
u(this, we, () => {
|
|
1193
1202
|
const t = this.element, e = this.core.getCanvasTransformer(), s = t.getClientRect(), o = document.createElement("textarea");
|
|
1194
1203
|
this.core.getStage().getContent().appendChild(o), o.name = "text-editor", o.draggable = !1, o.value = t.text(), o.style.position = "absolute", o.style.top = s.y + "px", o.style.left = s.x + "px", o.style.minWidth = "2px", o.style.fieldSizing = "content", o.style.whiteSpace = "nowrap", o.style.height = t.height() + "px", o.style.fontSize = t.fontSize() + "px", o.style.border = "none", o.style.padding = "0px", o.style.margin = "0px", o.style.overflow = "hidden", o.style.background = "none", o.style.outline = "none", o.style.resize = "none", o.style.lineHeight = t.lineHeight().toString(), o.style.fontFamily = t.fontFamily(), o.style.transformOrigin = "left top", o.style.textAlign = t.align(), o.style.color = t.fill().toString();
|
|
1195
1204
|
const a = t.rotation();
|
|
1196
|
-
let
|
|
1197
|
-
a && (
|
|
1198
|
-
const
|
|
1199
|
-
this.core.off("viewport:change",
|
|
1205
|
+
let l = "";
|
|
1206
|
+
a && (l += "rotateZ(" + a + "deg)"), o.style.transform = l + `scale(${t.getAbsoluteScale().x})`, o.focus();
|
|
1207
|
+
const h = () => {
|
|
1208
|
+
this.core.off("viewport:change", m), o.parentNode?.removeChild(o), window.removeEventListener("click", d), window.removeEventListener("touchstart", d), t.show(), e.getTransformer().show(), e.getTransformer().forceUpdate();
|
|
1200
1209
|
};
|
|
1201
|
-
o.addEventListener("keydown", function(
|
|
1202
|
-
if (
|
|
1203
|
-
const
|
|
1204
|
-
t.text(o.value),
|
|
1210
|
+
o.addEventListener("keydown", function(f) {
|
|
1211
|
+
if (f.key === "Escape") {
|
|
1212
|
+
const g = o.value;
|
|
1213
|
+
t.text(o.value), h(), g.trim() || t.destroy();
|
|
1205
1214
|
}
|
|
1206
1215
|
}), o.addEventListener("keydown", function() {
|
|
1207
1216
|
o.style.height = "auto", o.style.height = o.scrollHeight + t.fontSize() * t.lineHeight() + "px";
|
|
1208
1217
|
});
|
|
1209
|
-
const d = (
|
|
1210
|
-
|
|
1211
|
-
},
|
|
1212
|
-
const
|
|
1213
|
-
o.style.top =
|
|
1214
|
-
const
|
|
1218
|
+
const d = (f) => {
|
|
1219
|
+
f.target !== o && (t.text(o.value), h());
|
|
1220
|
+
}, m = () => {
|
|
1221
|
+
const f = t.getClientRect();
|
|
1222
|
+
o.style.top = f.y + "px", o.style.left = f.x + "px";
|
|
1223
|
+
const g = t.rotation();
|
|
1215
1224
|
let y = "";
|
|
1216
|
-
|
|
1225
|
+
g && (y += "rotateZ(" + g + "deg)"), o.style.transform = y + `scale(${t.getAbsoluteScale().x})`;
|
|
1217
1226
|
};
|
|
1218
1227
|
setTimeout(() => {
|
|
1219
|
-
this.core.on("viewport:change",
|
|
1228
|
+
this.core.on("viewport:change", m), window.addEventListener("click", d), window.addEventListener("touchstart", d);
|
|
1220
1229
|
});
|
|
1221
1230
|
});
|
|
1222
|
-
this.core = t, this.config = mi(e, this.core.getTheme()), this.element = this.createElement(), this.rect = new
|
|
1231
|
+
this.core = t, this.config = mi(e, this.core.getTheme()), this.element = this.createElement(), this.rect = new M.Rect(this.config), rt(this.element, this), this.isDraft = s, E(this, be, Di).call(this), setTimeout(() => {
|
|
1223
1232
|
r(this, we).call(this);
|
|
1224
1233
|
});
|
|
1225
1234
|
}
|
|
@@ -1234,7 +1243,7 @@ class Ns extends st {
|
|
|
1234
1243
|
this.config = e;
|
|
1235
1244
|
}
|
|
1236
1245
|
createElement() {
|
|
1237
|
-
return new
|
|
1246
|
+
return new M.Text(this.config);
|
|
1238
1247
|
}
|
|
1239
1248
|
/**
|
|
1240
1249
|
* 获取 Konva.Text 实例
|
|
@@ -1279,7 +1288,7 @@ var It, ft, Ee, Zt, Ut, zt, Wt, Se, Pi;
|
|
|
1279
1288
|
class Ts extends st {
|
|
1280
1289
|
constructor(t, e, s = !1) {
|
|
1281
1290
|
super();
|
|
1282
|
-
|
|
1291
|
+
u(this, Se);
|
|
1283
1292
|
p(this, "core");
|
|
1284
1293
|
p(this, "config");
|
|
1285
1294
|
p(this, "element");
|
|
@@ -1308,7 +1317,7 @@ class Ts extends st {
|
|
|
1308
1317
|
window.addEventListener("click", r(this, Wt));
|
|
1309
1318
|
}), window.addEventListener("keydown", r(this, zt));
|
|
1310
1319
|
});
|
|
1311
|
-
|
|
1320
|
+
u(this, It, async () => {
|
|
1312
1321
|
const t = this.htmlEditorElement.getBoundingClientRect();
|
|
1313
1322
|
if (t.width === 0 || t.height === 0)
|
|
1314
1323
|
return;
|
|
@@ -1339,11 +1348,11 @@ class Ts extends st {
|
|
|
1339
1348
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !1);
|
|
1340
1349
|
}));
|
|
1341
1350
|
});
|
|
1342
|
-
|
|
1351
|
+
u(this, ft, () => {
|
|
1343
1352
|
const t = this.element.getClientRect();
|
|
1344
1353
|
this.htmlElement.style.left = `${t.x}px`, this.htmlElement.style.top = `${t.y}px`, this.config.lockX ? this.htmlEditorElement.style.width = `${this.element.width() / this.config.htmlScale * this.config.scaleWhenCreate}px` : this.htmlEditorElement.style.width = "max-content", this.htmlEditorElement.style.transform = `scale(${this.config.htmlScale})`;
|
|
1345
1354
|
});
|
|
1346
|
-
|
|
1355
|
+
u(this, Ee, () => {
|
|
1347
1356
|
this.resizeObserver = new ResizeObserver((t) => {
|
|
1348
1357
|
for (const e of t) {
|
|
1349
1358
|
let s = !1;
|
|
@@ -1354,18 +1363,18 @@ class Ts extends st {
|
|
|
1354
1363
|
}
|
|
1355
1364
|
}), this.resizeObserver.observe(this.htmlEditorElement);
|
|
1356
1365
|
});
|
|
1357
|
-
|
|
1366
|
+
u(this, Zt, ({ type: t }) => {
|
|
1358
1367
|
const e = t === "select";
|
|
1359
1368
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1360
1369
|
});
|
|
1361
|
-
|
|
1370
|
+
u(this, Ut, (t) => {
|
|
1362
1371
|
const e = this.element.getClientRect();
|
|
1363
1372
|
this.htmlElement.style.left = `${e.x}px`, this.htmlElement.style.top = `${e.y}px`, this.htmlElement.style.transform = `scale(${this.core.getState().viewport.scale / this.config.scaleWhenCreate})`;
|
|
1364
1373
|
});
|
|
1365
|
-
|
|
1374
|
+
u(this, zt, (t) => {
|
|
1366
1375
|
t.key === "Escape" && this.detachEditor();
|
|
1367
1376
|
});
|
|
1368
|
-
|
|
1377
|
+
u(this, Wt, (t) => {
|
|
1369
1378
|
const e = t.target;
|
|
1370
1379
|
this.htmlElement.contains(e) || this.detachEditor();
|
|
1371
1380
|
});
|
|
@@ -1384,7 +1393,7 @@ class Ts extends st {
|
|
|
1384
1393
|
delete e.image, this.config = e;
|
|
1385
1394
|
}
|
|
1386
1395
|
createElement() {
|
|
1387
|
-
return new
|
|
1396
|
+
return new M.Image({ ...this.config });
|
|
1388
1397
|
}
|
|
1389
1398
|
/**
|
|
1390
1399
|
* 获取 Konva.Rect 实例
|
|
@@ -1441,7 +1450,7 @@ var Et, De, Xt, Yt, Bi;
|
|
|
1441
1450
|
class _s extends st {
|
|
1442
1451
|
constructor(t, e, s = !1) {
|
|
1443
1452
|
super();
|
|
1444
|
-
|
|
1453
|
+
u(this, Et);
|
|
1445
1454
|
p(this, "core");
|
|
1446
1455
|
p(this, "config");
|
|
1447
1456
|
p(this, "element");
|
|
@@ -1449,16 +1458,16 @@ class _s extends st {
|
|
|
1449
1458
|
p(this, "imgCover");
|
|
1450
1459
|
p(this, "playIcon");
|
|
1451
1460
|
p(this, "isDraft");
|
|
1452
|
-
|
|
1461
|
+
u(this, Xt, ({ type: t }) => {
|
|
1453
1462
|
const e = t === "select";
|
|
1454
1463
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1455
1464
|
});
|
|
1456
|
-
|
|
1465
|
+
u(this, Yt, () => {
|
|
1457
1466
|
this.getElement().getLayer() && this.core._rebuildStateAfterNodeChange([this], !0);
|
|
1458
1467
|
});
|
|
1459
1468
|
this.core = t, this.config = di(e, this.core.getTheme());
|
|
1460
|
-
const { group: o, image: a, imgCover:
|
|
1461
|
-
this.element = o, this.cover = a, this.imgCover =
|
|
1469
|
+
const { group: o, image: a, imgCover: l, playIcon: h } = this.createElement();
|
|
1470
|
+
this.element = o, this.cover = a, this.imgCover = l, this.playIcon = h, this.element = o, rt(this.element, this), this.isDraft = s, E(this, Et, De).call(this), E(this, Et, Bi).call(this, this.getElement());
|
|
1462
1471
|
}
|
|
1463
1472
|
getID() {
|
|
1464
1473
|
return this.config.id;
|
|
@@ -1470,11 +1479,11 @@ class _s extends st {
|
|
|
1470
1479
|
this.config = e;
|
|
1471
1480
|
}
|
|
1472
1481
|
createElement() {
|
|
1473
|
-
const t = new
|
|
1482
|
+
const t = new M.Group({
|
|
1474
1483
|
...this.config,
|
|
1475
1484
|
width: void 0,
|
|
1476
1485
|
height: void 0
|
|
1477
|
-
}), e = new
|
|
1486
|
+
}), e = new M.Image({
|
|
1478
1487
|
...this.config,
|
|
1479
1488
|
name: "",
|
|
1480
1489
|
id: `${this.config.id}-image`,
|
|
@@ -1483,7 +1492,7 @@ class _s extends st {
|
|
|
1483
1492
|
listening: !1
|
|
1484
1493
|
});
|
|
1485
1494
|
t.add(e);
|
|
1486
|
-
const s = new
|
|
1495
|
+
const s = new M.Rect({
|
|
1487
1496
|
name: "",
|
|
1488
1497
|
x: 0,
|
|
1489
1498
|
y: 0,
|
|
@@ -1493,7 +1502,7 @@ class _s extends st {
|
|
|
1493
1502
|
listening: !1
|
|
1494
1503
|
});
|
|
1495
1504
|
t.add(s);
|
|
1496
|
-
const o = new
|
|
1505
|
+
const o = new M.RegularPolygon({
|
|
1497
1506
|
x: this.config.width / 2,
|
|
1498
1507
|
// 微调使其视觉居中
|
|
1499
1508
|
y: this.config.height / 2,
|
|
@@ -1557,7 +1566,7 @@ De = function() {
|
|
|
1557
1566
|
e.crossOrigin = "anonymous", e.src = t, e.onload = () => {
|
|
1558
1567
|
this.cover.image(e);
|
|
1559
1568
|
let s = this.config.width ?? e.width, o = this.config.height ?? e.height;
|
|
1560
|
-
s = Math.max(s,
|
|
1569
|
+
s = Math.max(s, tt.MIN_SIZE), o = Math.max(o, tt.MIN_SIZE), this.cover.width(s), this.cover.height(o), this.imgCover.width(s), this.imgCover.height(o), this.playIcon.x(s / 2), this.playIcon.y(o / 2);
|
|
1561
1570
|
}, e.onerror = () => {
|
|
1562
1571
|
console.error("Failed to load image:", t);
|
|
1563
1572
|
};
|
|
@@ -1566,8 +1575,8 @@ De = function() {
|
|
|
1566
1575
|
*/
|
|
1567
1576
|
Bi = function(t) {
|
|
1568
1577
|
this.core.on("toolType:change", r(this, Xt)), t.on("transform", (e) => {
|
|
1569
|
-
const s = e.target, o = Math.max(
|
|
1570
|
-
|
|
1578
|
+
const s = e.target, o = Math.max(tt.MIN_SIZE, this.cover.width() * s.scaleX()), a = Math.max(
|
|
1579
|
+
tt.MIN_SIZE,
|
|
1571
1580
|
this.cover.height() * s.scaleY()
|
|
1572
1581
|
);
|
|
1573
1582
|
this.cover.width(o), this.cover.height(a), this.imgCover.width(o), this.imgCover.height(a), this.playIcon.x(o / 2), this.playIcon.y(a / 2), t.scale({ x: 1, y: 1 });
|
|
@@ -1581,12 +1590,12 @@ var Gt, Ne, Vi;
|
|
|
1581
1590
|
class Ms extends st {
|
|
1582
1591
|
constructor(t, e, s = !1) {
|
|
1583
1592
|
super();
|
|
1584
|
-
|
|
1593
|
+
u(this, Ne);
|
|
1585
1594
|
p(this, "core");
|
|
1586
1595
|
p(this, "config");
|
|
1587
1596
|
p(this, "element");
|
|
1588
1597
|
p(this, "isDraft");
|
|
1589
|
-
|
|
1598
|
+
u(this, Gt, ({ type: t }) => {
|
|
1590
1599
|
const e = t === "select";
|
|
1591
1600
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1592
1601
|
});
|
|
@@ -1603,7 +1612,7 @@ class Ms extends st {
|
|
|
1603
1612
|
this.config = e;
|
|
1604
1613
|
}
|
|
1605
1614
|
createElement() {
|
|
1606
|
-
return new
|
|
1615
|
+
return new M.Star(this.config);
|
|
1607
1616
|
}
|
|
1608
1617
|
/**
|
|
1609
1618
|
* 获取 Konva.Star 实例
|
|
@@ -1655,12 +1664,12 @@ var Kt, Te, Oi;
|
|
|
1655
1664
|
class ks extends st {
|
|
1656
1665
|
constructor(t, e, s = !1) {
|
|
1657
1666
|
super();
|
|
1658
|
-
|
|
1667
|
+
u(this, Te);
|
|
1659
1668
|
p(this, "core");
|
|
1660
1669
|
p(this, "config");
|
|
1661
1670
|
p(this, "element");
|
|
1662
1671
|
p(this, "isDraft");
|
|
1663
|
-
|
|
1672
|
+
u(this, Kt, ({ type: t }) => {
|
|
1664
1673
|
const e = t === "select";
|
|
1665
1674
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1666
1675
|
});
|
|
@@ -1677,7 +1686,7 @@ class ks extends st {
|
|
|
1677
1686
|
this.config = e;
|
|
1678
1687
|
}
|
|
1679
1688
|
createElement() {
|
|
1680
|
-
return new
|
|
1689
|
+
return new M.Ellipse(this.config);
|
|
1681
1690
|
}
|
|
1682
1691
|
/**
|
|
1683
1692
|
* 获取 Konva.Ellipse 实例
|
|
@@ -1728,12 +1737,12 @@ var qt, _e, Zi;
|
|
|
1728
1737
|
class $s extends st {
|
|
1729
1738
|
constructor(t, e, s = !1) {
|
|
1730
1739
|
super();
|
|
1731
|
-
|
|
1740
|
+
u(this, _e);
|
|
1732
1741
|
p(this, "core");
|
|
1733
1742
|
p(this, "config");
|
|
1734
1743
|
p(this, "element");
|
|
1735
1744
|
p(this, "isDraft");
|
|
1736
|
-
|
|
1745
|
+
u(this, qt, ({ type: t }) => {
|
|
1737
1746
|
const e = t === "select";
|
|
1738
1747
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1739
1748
|
});
|
|
@@ -1750,7 +1759,7 @@ class $s extends st {
|
|
|
1750
1759
|
this.config = e;
|
|
1751
1760
|
}
|
|
1752
1761
|
createElement() {
|
|
1753
|
-
return new
|
|
1762
|
+
return new M.Line(this.config);
|
|
1754
1763
|
}
|
|
1755
1764
|
/**
|
|
1756
1765
|
* 获取 Konva.Line 实例
|
|
@@ -1785,35 +1794,35 @@ Zi = function() {
|
|
|
1785
1794
|
this.core.on("toolType:change", r(this, qt)), t.on("transform", (e) => {
|
|
1786
1795
|
const s = e.target, { width: o, height: a } = Rs(s);
|
|
1787
1796
|
s.scale({ x: 1, y: 1 }), s.width(o), s.height(a);
|
|
1788
|
-
const
|
|
1797
|
+
const l = ki(
|
|
1789
1798
|
{ x: s.x(), y: s.y(), width: o, height: a },
|
|
1790
1799
|
this.config.$_shape
|
|
1791
1800
|
);
|
|
1792
|
-
s.points(
|
|
1801
|
+
s.points(l.flatMap((h) => [h.x, h.y]));
|
|
1793
1802
|
}), t.on("transformend", (e) => {
|
|
1794
1803
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1795
1804
|
}), t.on("dragend", (e) => {
|
|
1796
1805
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1797
1806
|
});
|
|
1798
1807
|
};
|
|
1799
|
-
var
|
|
1808
|
+
var H, L, wt, bt, V, Ui, Nt, zi, Wi, jt, Xi;
|
|
1800
1809
|
class As extends st {
|
|
1801
1810
|
constructor(t, e, s = !1) {
|
|
1802
1811
|
super();
|
|
1803
|
-
|
|
1812
|
+
u(this, V);
|
|
1804
1813
|
p(this, "core");
|
|
1805
1814
|
p(this, "config");
|
|
1806
1815
|
p(this, "element");
|
|
1807
1816
|
p(this, "isDraft");
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1817
|
+
u(this, H, null);
|
|
1818
|
+
u(this, L, null);
|
|
1819
|
+
u(this, wt, null);
|
|
1820
|
+
u(this, bt, null);
|
|
1821
|
+
u(this, jt, ({ type: t }) => {
|
|
1813
1822
|
const e = t === "select";
|
|
1814
1823
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1815
1824
|
});
|
|
1816
|
-
this.core = t, this.config = Ci(e, this.core.getTheme()), this.element = this.createElement(), rt(this.element, this), this.isDraft = s, E(this,
|
|
1825
|
+
this.core = t, this.config = Ci(e, this.core.getTheme()), this.element = this.createElement(), rt(this.element, this), this.isDraft = s, E(this, V, Ui).call(this), E(this, V, Xi).call(this);
|
|
1817
1826
|
}
|
|
1818
1827
|
getID() {
|
|
1819
1828
|
return this.config.id;
|
|
@@ -1826,7 +1835,7 @@ class As extends st {
|
|
|
1826
1835
|
this.config = e;
|
|
1827
1836
|
}
|
|
1828
1837
|
createElement() {
|
|
1829
|
-
return new
|
|
1838
|
+
return new M.Arrow(this.config);
|
|
1830
1839
|
}
|
|
1831
1840
|
/**
|
|
1832
1841
|
* 获取 Konva.Arrow 实例
|
|
@@ -1844,23 +1853,23 @@ class As extends st {
|
|
|
1844
1853
|
...t
|
|
1845
1854
|
},
|
|
1846
1855
|
this.core.getTheme()
|
|
1847
|
-
), this.getElement().setAttrs(this.config), E(this,
|
|
1856
|
+
), this.getElement().setAttrs(this.config), E(this, V, Nt).call(this);
|
|
1848
1857
|
}
|
|
1849
1858
|
/**
|
|
1850
1859
|
* 销毁
|
|
1851
1860
|
*/
|
|
1852
1861
|
destroy() {
|
|
1853
|
-
this.core.off("toolType:change", r(this, jt)), r(this, bt) && this.core.off("nodes:selected", r(this, bt)), r(this, wt) && this.core.off("viewport:scale:change", r(this, wt)), r(this,
|
|
1862
|
+
this.core.off("toolType:change", r(this, jt)), r(this, bt) && this.core.off("nodes:selected", r(this, bt)), r(this, wt) && this.core.off("viewport:scale:change", r(this, wt)), r(this, H)?.destroy(), r(this, L)?.destroy(), this.element.destroy();
|
|
1854
1863
|
}
|
|
1855
1864
|
}
|
|
1856
|
-
|
|
1865
|
+
H = new WeakMap(), L = new WeakMap(), wt = new WeakMap(), bt = new WeakMap(), V = new WeakSet(), /**
|
|
1857
1866
|
* 创建起点和终点的控制锚点
|
|
1858
1867
|
*/
|
|
1859
1868
|
Ui = function() {
|
|
1860
1869
|
const t = this.core.getMainLayer();
|
|
1861
1870
|
if (!t) return;
|
|
1862
1871
|
const e = this.core.getStageScale(), s = 6 / e, o = 2 / e;
|
|
1863
|
-
|
|
1872
|
+
C(this, H, new M.Circle({
|
|
1864
1873
|
radius: s,
|
|
1865
1874
|
fill: "white",
|
|
1866
1875
|
stroke: "#1976d2",
|
|
@@ -1868,7 +1877,7 @@ Ui = function() {
|
|
|
1868
1877
|
draggable: !0,
|
|
1869
1878
|
visible: !1,
|
|
1870
1879
|
name: "arrow-anchor"
|
|
1871
|
-
})),
|
|
1880
|
+
})), C(this, L, new M.Circle({
|
|
1872
1881
|
radius: s,
|
|
1873
1882
|
fill: "white",
|
|
1874
1883
|
stroke: "#1976d2",
|
|
@@ -1876,33 +1885,33 @@ Ui = function() {
|
|
|
1876
1885
|
draggable: !0,
|
|
1877
1886
|
visible: !1,
|
|
1878
1887
|
name: "arrow-anchor"
|
|
1879
|
-
})), t.add(r(this,
|
|
1888
|
+
})), t.add(r(this, H)), t.add(r(this, L)), E(this, V, Nt).call(this), r(this, H).on("dragmove", () => {
|
|
1880
1889
|
const a = [...this.element.points()];
|
|
1881
1890
|
if (a.length < 4) return;
|
|
1882
|
-
const
|
|
1883
|
-
a[0] =
|
|
1884
|
-
}), r(this,
|
|
1891
|
+
const l = this.element, h = r(this, H).position();
|
|
1892
|
+
a[0] = h.x - l.x(), a[1] = h.y - l.y(), l.points(a), this.core.getCanvasTransformer().emitPositionChange();
|
|
1893
|
+
}), r(this, H).on("dragend", () => {
|
|
1885
1894
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1886
|
-
}), r(this,
|
|
1895
|
+
}), r(this, L).on("dragmove", () => {
|
|
1887
1896
|
const a = [...this.element.points()];
|
|
1888
1897
|
if (a.length < 4) return;
|
|
1889
|
-
const
|
|
1890
|
-
a[a.length - 2] =
|
|
1891
|
-
}), r(this,
|
|
1898
|
+
const l = this.element, h = r(this, L).position();
|
|
1899
|
+
a[a.length - 2] = h.x - l.x(), a[a.length - 1] = h.y - l.y(), l.points(a), this.core.getCanvasTransformer().emitPositionChange();
|
|
1900
|
+
}), r(this, L).on("dragend", () => {
|
|
1892
1901
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1893
1902
|
});
|
|
1894
1903
|
}, /**
|
|
1895
1904
|
* 更新锚点位置
|
|
1896
1905
|
*/
|
|
1897
1906
|
Nt = function() {
|
|
1898
|
-
if (!r(this,
|
|
1907
|
+
if (!r(this, H) || !r(this, L)) return;
|
|
1899
1908
|
const t = this.element.points();
|
|
1900
1909
|
if (t.length < 4) return;
|
|
1901
1910
|
const e = this.element, s = e.x(), o = e.y();
|
|
1902
|
-
r(this,
|
|
1911
|
+
r(this, H).position({
|
|
1903
1912
|
x: s + t[0],
|
|
1904
1913
|
y: o + t[1]
|
|
1905
|
-
}), r(this,
|
|
1914
|
+
}), r(this, L).position({
|
|
1906
1915
|
x: s + t[t.length - 2],
|
|
1907
1916
|
y: o + t[t.length - 1]
|
|
1908
1917
|
});
|
|
@@ -1910,31 +1919,31 @@ Nt = function() {
|
|
|
1910
1919
|
* 更新锚点样式(根据缩放调整大小)
|
|
1911
1920
|
*/
|
|
1912
1921
|
zi = function() {
|
|
1913
|
-
if (!r(this,
|
|
1922
|
+
if (!r(this, H) || !r(this, L)) return;
|
|
1914
1923
|
const t = this.core.getStageScale(), e = 6 / t, s = 2 / t;
|
|
1915
|
-
r(this,
|
|
1924
|
+
r(this, H).radius(e), r(this, H).strokeWidth(s), r(this, L).radius(e), r(this, L).strokeWidth(s);
|
|
1916
1925
|
}, /**
|
|
1917
1926
|
* 显示或隐藏锚点
|
|
1918
1927
|
*/
|
|
1919
1928
|
Wi = function(t) {
|
|
1920
|
-
!r(this,
|
|
1929
|
+
!r(this, H) || !r(this, L) || (r(this, H).visible(t), r(this, L).visible(t), t && (E(this, V, Nt).call(this), r(this, H).moveToTop(), r(this, L).moveToTop()));
|
|
1921
1930
|
}, jt = new WeakMap(), /**
|
|
1922
1931
|
* 设置事件处理器
|
|
1923
1932
|
*/
|
|
1924
1933
|
Xi = function() {
|
|
1925
1934
|
const t = this.getElement();
|
|
1926
|
-
this.core.on("toolType:change", r(this, jt)),
|
|
1935
|
+
this.core.on("toolType:change", r(this, jt)), C(this, bt, (e) => {
|
|
1927
1936
|
const s = e.includes(this.config.id);
|
|
1928
|
-
E(this,
|
|
1929
|
-
}), this.core.on("nodes:selected", r(this, bt)),
|
|
1930
|
-
E(this,
|
|
1937
|
+
E(this, V, Wi).call(this, s);
|
|
1938
|
+
}), this.core.on("nodes:selected", r(this, bt)), C(this, wt, () => {
|
|
1939
|
+
E(this, V, zi).call(this);
|
|
1931
1940
|
}), this.core.on("viewport:scale:change", r(this, wt)), t.on("transform", (e) => {
|
|
1932
|
-
const s = e.target, o = s.scaleX(), a = s.scaleY(),
|
|
1933
|
-
s.points(
|
|
1941
|
+
const s = e.target, o = s.scaleX(), a = s.scaleY(), h = s.points().map((d, m) => m % 2 === 0 ? d * o : d * a);
|
|
1942
|
+
s.points(h), s.scale({ x: 1, y: 1 }), E(this, V, Nt).call(this);
|
|
1934
1943
|
}), t.on("transformend", () => {
|
|
1935
1944
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1936
1945
|
}), t.on("dragmove", () => {
|
|
1937
|
-
E(this,
|
|
1946
|
+
E(this, V, Nt).call(this);
|
|
1938
1947
|
}), t.on("dragend", () => {
|
|
1939
1948
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1940
1949
|
});
|
|
@@ -2064,7 +2073,7 @@ function ee(n, i) {
|
|
|
2064
2073
|
{ x: s, y: o }
|
|
2065
2074
|
];
|
|
2066
2075
|
}
|
|
2067
|
-
var kt,
|
|
2076
|
+
var kt, B, J, it, D, Rt, q, j, ht, pt, Me, W, Yi, Gi, Pe, Be, Ki;
|
|
2068
2077
|
class Ls extends ps {
|
|
2069
2078
|
constructor(t, e) {
|
|
2070
2079
|
const s = e?.state, o = {
|
|
@@ -2079,29 +2088,29 @@ class Ls extends ps {
|
|
|
2079
2088
|
}
|
|
2080
2089
|
};
|
|
2081
2090
|
super(o);
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
+
u(this, W);
|
|
2092
|
+
u(this, kt);
|
|
2093
|
+
u(this, B);
|
|
2094
|
+
u(this, J);
|
|
2095
|
+
u(this, it);
|
|
2096
|
+
u(this, D, null);
|
|
2097
|
+
u(this, Rt);
|
|
2098
|
+
u(this, q, null);
|
|
2099
|
+
u(this, j, null);
|
|
2091
2100
|
/** 节点映射,方便快速查找 */
|
|
2092
|
-
|
|
2093
|
-
|
|
2101
|
+
u(this, ht, /* @__PURE__ */ new Map());
|
|
2102
|
+
u(this, pt, null);
|
|
2094
2103
|
p(this, "isEditingText", !1);
|
|
2095
|
-
|
|
2104
|
+
u(this, Me, (t) => {
|
|
2096
2105
|
(t.key === "Delete" || t.key === "Backspace") && (t.stopPropagation(), this.deleteSelectedNodes());
|
|
2097
2106
|
});
|
|
2098
|
-
|
|
2107
|
+
C(this, kt, e?.theme ?? Ii), C(this, Rt, t), C(this, B, new ms(this, {
|
|
2099
2108
|
container: t,
|
|
2100
2109
|
width: t.clientWidth,
|
|
2101
2110
|
height: t.clientHeight,
|
|
2102
2111
|
draggable: !1,
|
|
2103
2112
|
className: "touch-none"
|
|
2104
|
-
})),
|
|
2113
|
+
})), C(this, J, new M.Layer()), C(this, it, new fs(this)), r(this, B).getStage().add(r(this, J)), r(this, J).add(r(this, it).getTransformer()), this._renderCanvas(o), E(this, W, Yi).call(this), E(this, W, Gi).call(this);
|
|
2105
2114
|
}
|
|
2106
2115
|
/**
|
|
2107
2116
|
* 获取当前主题
|
|
@@ -2113,13 +2122,13 @@ class Ls extends ps {
|
|
|
2113
2122
|
* 设置主题并重新渲染
|
|
2114
2123
|
*/
|
|
2115
2124
|
setTheme(t) {
|
|
2116
|
-
|
|
2125
|
+
C(this, kt, t), this._renderCanvas(this.getState()), this._emit("theme:change", t);
|
|
2117
2126
|
}
|
|
2118
2127
|
/**
|
|
2119
2128
|
* 获取 CanvasStage 实例
|
|
2120
2129
|
*/
|
|
2121
2130
|
getCanvasStage() {
|
|
2122
|
-
return r(this,
|
|
2131
|
+
return r(this, B);
|
|
2123
2132
|
}
|
|
2124
2133
|
/**
|
|
2125
2134
|
* 获取 CanvasTransformer 实例
|
|
@@ -2137,7 +2146,7 @@ class Ls extends ps {
|
|
|
2137
2146
|
* 获取 Konva.Stage 实例
|
|
2138
2147
|
*/
|
|
2139
2148
|
getStage() {
|
|
2140
|
-
return r(this,
|
|
2149
|
+
return r(this, B).getStage();
|
|
2141
2150
|
}
|
|
2142
2151
|
/**
|
|
2143
2152
|
* 获取 Stage 容器元素
|
|
@@ -2149,7 +2158,7 @@ class Ls extends ps {
|
|
|
2149
2158
|
* 获取主图层
|
|
2150
2159
|
*/
|
|
2151
2160
|
getMainLayer() {
|
|
2152
|
-
return r(this,
|
|
2161
|
+
return r(this, J);
|
|
2153
2162
|
}
|
|
2154
2163
|
/**
|
|
2155
2164
|
* 获取当前工具类型
|
|
@@ -2180,46 +2189,46 @@ class Ls extends ps {
|
|
|
2180
2189
|
), this._emit("toolType:change", {
|
|
2181
2190
|
type: t,
|
|
2182
2191
|
meta: e
|
|
2183
|
-
}), t === "hand" ? (r(this,
|
|
2192
|
+
}), t === "hand" ? (r(this, B).setDraggable(!0), r(this, B).setCursor("grab")) : (r(this, B).setDraggable(!1), r(this, B).resetCursor());
|
|
2184
2193
|
}
|
|
2185
2194
|
/**
|
|
2186
2195
|
* 根据 ID 获取 Canvas 节点实例
|
|
2187
2196
|
*/
|
|
2188
2197
|
getCanvasNodeById(t) {
|
|
2189
|
-
return r(this,
|
|
2198
|
+
return r(this, ht).get(t) || null;
|
|
2190
2199
|
}
|
|
2191
2200
|
/**
|
|
2192
2201
|
* 设置是否可拖拽(内部使用)
|
|
2193
2202
|
*/
|
|
2194
2203
|
setDraggable(t) {
|
|
2195
|
-
r(this,
|
|
2204
|
+
r(this, B).setDraggable(t);
|
|
2196
2205
|
}
|
|
2197
2206
|
/**
|
|
2198
2207
|
* 设置光标
|
|
2199
2208
|
* @internal 仅供内部使用
|
|
2200
2209
|
*/
|
|
2201
2210
|
_setCursor(t) {
|
|
2202
|
-
r(this,
|
|
2211
|
+
r(this, B).setCursor(t);
|
|
2203
2212
|
}
|
|
2204
2213
|
/**
|
|
2205
2214
|
* 重置光标
|
|
2206
2215
|
* @internal 仅供内部使用
|
|
2207
2216
|
*/
|
|
2208
2217
|
_resetCursor() {
|
|
2209
|
-
r(this,
|
|
2218
|
+
r(this, B).resetCursor();
|
|
2210
2219
|
}
|
|
2211
2220
|
/**
|
|
2212
2221
|
* 获取当前 Stage 缩放比例
|
|
2213
2222
|
*/
|
|
2214
2223
|
getStageScale() {
|
|
2215
|
-
return r(this,
|
|
2224
|
+
return r(this, B).getStage().scaleX();
|
|
2216
2225
|
}
|
|
2217
2226
|
/**
|
|
2218
2227
|
* 更新视口位置
|
|
2219
2228
|
* @internal 仅供内部使用,外部请使用 CanvasApi
|
|
2220
2229
|
*/
|
|
2221
2230
|
_updateViewport(t, e = !1) {
|
|
2222
|
-
r(this,
|
|
2231
|
+
r(this, B).setViewport(t);
|
|
2223
2232
|
const s = this.getState().viewport, o = {
|
|
2224
2233
|
...s,
|
|
2225
2234
|
...t
|
|
@@ -2234,54 +2243,54 @@ class Ls extends ps {
|
|
|
2234
2243
|
createNodes(t, e) {
|
|
2235
2244
|
const s = t.map((o) => wi(this, o.$_type, o, !1)).filter((o) => o !== null);
|
|
2236
2245
|
s.forEach((o) => {
|
|
2237
|
-
r(this,
|
|
2238
|
-
}), E(this,
|
|
2246
|
+
r(this, J).add(o.getElement());
|
|
2247
|
+
}), E(this, W, Be).call(this, s, e), this._emit("nodes:created", t);
|
|
2239
2248
|
}
|
|
2240
2249
|
/**
|
|
2241
2250
|
* 创建图片标注节点(内部使用)
|
|
2242
2251
|
*/
|
|
2243
2252
|
createImageMarkerNode(t, e, s, o) {
|
|
2244
2253
|
const a = this.getState().nodes || [];
|
|
2245
|
-
let
|
|
2246
|
-
a.forEach((
|
|
2247
|
-
|
|
2254
|
+
let l = 0;
|
|
2255
|
+
a.forEach((w) => {
|
|
2256
|
+
w.$_type === "image-marker" && typeof w.$_markerNumber == "number" && (l = Math.max(l, w.$_markerNumber));
|
|
2248
2257
|
});
|
|
2249
|
-
const
|
|
2258
|
+
const h = (e.x - o.x) / o.width, d = (e.y - o.y) / o.height, m = (s.x - o.x) / o.width, f = (s.y - o.y) / o.height, g = Math.min(e.x, s.x), y = Math.min(e.y, s.y), x = Math.abs(s.x - e.x), v = Math.abs(s.y - e.y), I = {
|
|
2250
2259
|
id: Tt(),
|
|
2251
2260
|
$_type: "image-marker",
|
|
2252
|
-
x:
|
|
2261
|
+
x: g,
|
|
2253
2262
|
y,
|
|
2254
|
-
width:
|
|
2263
|
+
width: x,
|
|
2255
2264
|
height: v,
|
|
2256
2265
|
visible: !0,
|
|
2257
2266
|
line: "dashed",
|
|
2258
2267
|
$_parentId: t,
|
|
2259
|
-
$_markerNumber:
|
|
2268
|
+
$_markerNumber: l + 1,
|
|
2260
2269
|
$_relativeBox: {
|
|
2261
2270
|
start: {
|
|
2262
|
-
ratioX: Math.max(0, Math.min(1,
|
|
2271
|
+
ratioX: Math.max(0, Math.min(1, h)),
|
|
2263
2272
|
ratioY: Math.max(0, Math.min(1, d))
|
|
2264
2273
|
},
|
|
2265
2274
|
end: {
|
|
2266
|
-
ratioX: Math.max(0, Math.min(1,
|
|
2267
|
-
ratioY: Math.max(0, Math.min(1,
|
|
2275
|
+
ratioX: Math.max(0, Math.min(1, m)),
|
|
2276
|
+
ratioY: Math.max(0, Math.min(1, f))
|
|
2268
2277
|
}
|
|
2269
2278
|
}
|
|
2270
2279
|
};
|
|
2271
|
-
this.createNodes([
|
|
2280
|
+
this.createNodes([I], !0);
|
|
2272
2281
|
}
|
|
2273
2282
|
/**
|
|
2274
2283
|
* 在指定位置查找图片节点
|
|
2275
2284
|
* @internal 仅供内部使用
|
|
2276
2285
|
*/
|
|
2277
2286
|
_findImageAtPosition(t) {
|
|
2278
|
-
const a = r(this,
|
|
2279
|
-
(
|
|
2280
|
-
).slice().sort((
|
|
2281
|
-
for (const
|
|
2282
|
-
const
|
|
2283
|
-
if (t.x >=
|
|
2284
|
-
return
|
|
2287
|
+
const a = r(this, J).getChildren().filter(
|
|
2288
|
+
(l) => !l.name().includes("imageMarker")
|
|
2289
|
+
).slice().sort((l, h) => h.zIndex() - l.zIndex());
|
|
2290
|
+
for (const l of a) {
|
|
2291
|
+
const h = l.x(), d = l.y(), m = l.width(), f = l.height();
|
|
2292
|
+
if (t.x >= h && t.x <= h + m && t.y >= d && t.y <= d + f)
|
|
2293
|
+
return l.getAttr("$_type") === "image" ? l : null;
|
|
2285
2294
|
}
|
|
2286
2295
|
return null;
|
|
2287
2296
|
}
|
|
@@ -2289,83 +2298,83 @@ class Ls extends ps {
|
|
|
2289
2298
|
* @internal 仅供内部使用
|
|
2290
2299
|
*/
|
|
2291
2300
|
_setDrawingPosition(t) {
|
|
2292
|
-
|
|
2301
|
+
C(this, j, [t, t]);
|
|
2293
2302
|
}
|
|
2294
2303
|
/**
|
|
2295
2304
|
* @internal 仅供内部使用
|
|
2296
2305
|
*/
|
|
2297
2306
|
_updateDrawingPosition(t) {
|
|
2298
|
-
r(this,
|
|
2307
|
+
r(this, j) && (r(this, j)[1] = t);
|
|
2299
2308
|
}
|
|
2300
2309
|
/**
|
|
2301
2310
|
* @internal 仅供内部使用
|
|
2302
2311
|
*/
|
|
2303
2312
|
_createDraftNode(t, e) {
|
|
2304
|
-
r(this,
|
|
2313
|
+
r(this, D) && r(this, D).destroy();
|
|
2305
2314
|
const s = Fs(
|
|
2306
2315
|
t,
|
|
2307
|
-
r(this,
|
|
2316
|
+
r(this, j)[0],
|
|
2308
2317
|
{
|
|
2309
2318
|
...e,
|
|
2310
2319
|
...this.getToolMeta()
|
|
2311
2320
|
}
|
|
2312
2321
|
);
|
|
2313
|
-
|
|
2322
|
+
C(this, D, wi(this, t, s, !0)), r(this, D) && r(this, J).add(r(this, D).getElement());
|
|
2314
2323
|
}
|
|
2315
2324
|
/**
|
|
2316
2325
|
* @internal 仅供内部使用
|
|
2317
2326
|
*/
|
|
2318
2327
|
_updateDraftNode() {
|
|
2319
|
-
if (!r(this,
|
|
2320
|
-
const t = r(this,
|
|
2328
|
+
if (!r(this, D)) return;
|
|
2329
|
+
const t = r(this, D).getConfig(), e = Hs(
|
|
2321
2330
|
t,
|
|
2322
|
-
r(this,
|
|
2323
|
-
r(this,
|
|
2331
|
+
r(this, j)[1],
|
|
2332
|
+
r(this, j)[0]
|
|
2324
2333
|
);
|
|
2325
|
-
r(this,
|
|
2334
|
+
r(this, D).update(e);
|
|
2326
2335
|
}
|
|
2327
2336
|
/**
|
|
2328
2337
|
* @internal 仅供内部使用
|
|
2329
2338
|
*/
|
|
2330
2339
|
_finalizeDraftNode() {
|
|
2331
|
-
if (!r(this,
|
|
2332
|
-
const t = Tt(), e = r(this,
|
|
2340
|
+
if (!r(this, D)) return;
|
|
2341
|
+
const t = Tt(), e = r(this, D).getConfig();
|
|
2333
2342
|
if (e.$_type === "image-marker") {
|
|
2334
2343
|
const o = e.$_bounds, a = {
|
|
2335
2344
|
x: e.x,
|
|
2336
2345
|
y: e.y
|
|
2337
|
-
},
|
|
2346
|
+
}, l = {
|
|
2338
2347
|
x: e.x + (e.width || 0),
|
|
2339
2348
|
y: e.y + (e.height || 0)
|
|
2340
|
-
},
|
|
2349
|
+
}, h = this.getState().nodes || [];
|
|
2341
2350
|
let d = 0;
|
|
2342
|
-
|
|
2351
|
+
h.forEach((v) => {
|
|
2343
2352
|
v.$_type === "image-marker" && typeof v.$_markerNumber == "number" && (d = Math.max(d, v.$_markerNumber));
|
|
2344
2353
|
});
|
|
2345
|
-
const
|
|
2354
|
+
const m = (a.x - o.x) / o.width, f = (a.y - o.y) / o.height, g = (l.x - o.x) / o.width, y = (l.y - o.y) / o.height, x = {
|
|
2346
2355
|
...e,
|
|
2347
2356
|
$_markerNumber: d + 1,
|
|
2348
2357
|
$_relativeBox: {
|
|
2349
2358
|
start: {
|
|
2350
|
-
ratioX: Math.max(0, Math.min(1,
|
|
2351
|
-
ratioY: Math.max(0, Math.min(1,
|
|
2359
|
+
ratioX: Math.max(0, Math.min(1, m)),
|
|
2360
|
+
ratioY: Math.max(0, Math.min(1, f))
|
|
2352
2361
|
},
|
|
2353
2362
|
end: {
|
|
2354
|
-
ratioX: Math.max(0, Math.min(1,
|
|
2363
|
+
ratioX: Math.max(0, Math.min(1, g)),
|
|
2355
2364
|
ratioY: Math.max(0, Math.min(1, y))
|
|
2356
2365
|
}
|
|
2357
2366
|
},
|
|
2358
2367
|
$_type: "image-marker",
|
|
2359
2368
|
id: t
|
|
2360
2369
|
};
|
|
2361
|
-
this.createNodes([
|
|
2370
|
+
this.createNodes([x], !0), r(this, D).destroy(), C(this, D, null), this.setToolType("select");
|
|
2362
2371
|
return;
|
|
2363
2372
|
}
|
|
2364
2373
|
const s = {
|
|
2365
2374
|
...e,
|
|
2366
2375
|
id: t
|
|
2367
2376
|
};
|
|
2368
|
-
if (s.$_type === "ellipse" && (s.width || 0) < 10 && (s.height || 0) < 10 && (s.width = 10, s.height = 10), s.$_type === "star" && (s.outerRadius || 0) < 10 && (s.outerRadius = 10), this.createNodes([s], !0), r(this,
|
|
2377
|
+
if (s.$_type === "ellipse" && (s.width || 0) < 10 && (s.height || 0) < 10 && (s.width = 10, s.height = 10), s.$_type === "star" && (s.outerRadius || 0) < 10 && (s.outerRadius = 10), this.createNodes([s], !0), r(this, D).destroy(), C(this, D, null), this.setToolType("select"), s.$_type === "rich-text") {
|
|
2369
2378
|
const o = this.getCanvasNodeById(t);
|
|
2370
2379
|
o && o.attachEditor();
|
|
2371
2380
|
}
|
|
@@ -2375,7 +2384,7 @@ class Ls extends ps {
|
|
|
2375
2384
|
* @internal 仅供内部使用
|
|
2376
2385
|
*/
|
|
2377
2386
|
_createTextNodeAtDrawingPosition(t) {
|
|
2378
|
-
const e = r(this,
|
|
2387
|
+
const e = r(this, j)[1], s = {
|
|
2379
2388
|
id: Tt(),
|
|
2380
2389
|
$_type: "text",
|
|
2381
2390
|
x: e.x,
|
|
@@ -2388,34 +2397,34 @@ class Ls extends ps {
|
|
|
2388
2397
|
* @internal 仅供内部使用
|
|
2389
2398
|
*/
|
|
2390
2399
|
_createSelectRect() {
|
|
2391
|
-
this.isEditingText || (r(this,
|
|
2392
|
-
x: r(this,
|
|
2393
|
-
y: r(this,
|
|
2400
|
+
this.isEditingText || (r(this, q) && r(this, q).destroy(), C(this, q, new M.Rect({
|
|
2401
|
+
x: r(this, j)[0].x,
|
|
2402
|
+
y: r(this, j)[0].y,
|
|
2394
2403
|
width: 0,
|
|
2395
2404
|
height: 0,
|
|
2396
2405
|
stroke: this.getTheme()["theme.select-rect-border"],
|
|
2397
2406
|
strokeWidth: 1,
|
|
2398
2407
|
fill: this.getTheme()["theme.select-rect-fill"]
|
|
2399
|
-
})), r(this,
|
|
2408
|
+
})), r(this, J).add(r(this, q)));
|
|
2400
2409
|
}
|
|
2401
2410
|
/*
|
|
2402
2411
|
* @internal 仅供内部使用
|
|
2403
2412
|
*/
|
|
2404
2413
|
_updateSelectRect() {
|
|
2405
|
-
if (!r(this,
|
|
2406
|
-
const [t, e] = ee(...r(this,
|
|
2407
|
-
r(this,
|
|
2414
|
+
if (!r(this, q)) return;
|
|
2415
|
+
const [t, e] = ee(...r(this, j));
|
|
2416
|
+
r(this, q).setAttrs({
|
|
2408
2417
|
x: t.x,
|
|
2409
2418
|
y: t.y,
|
|
2410
2419
|
width: e.x - t.x,
|
|
2411
2420
|
height: e.y - t.y
|
|
2412
2421
|
});
|
|
2413
|
-
const s = r(this,
|
|
2414
|
-
const
|
|
2415
|
-
return
|
|
2422
|
+
const s = r(this, q).getClientRect(), a = r(this, J).find(`.${b.selectable}`).filter((l) => {
|
|
2423
|
+
const h = l.getClientRect();
|
|
2424
|
+
return M.Util.haveIntersection(s, h);
|
|
2416
2425
|
});
|
|
2417
2426
|
this._selectNodes(
|
|
2418
|
-
a.length > 0 ? a.filter((
|
|
2427
|
+
a.length > 0 ? a.filter((l) => l.listening()).map((l) => l.id()) : void 0,
|
|
2419
2428
|
!1
|
|
2420
2429
|
);
|
|
2421
2430
|
}
|
|
@@ -2423,7 +2432,7 @@ class Ls extends ps {
|
|
|
2423
2432
|
* @internal 仅供内部使用
|
|
2424
2433
|
*/
|
|
2425
2434
|
_finalizeSelectRect() {
|
|
2426
|
-
r(this,
|
|
2435
|
+
r(this, q) && (r(this, q).destroy(), C(this, q, null));
|
|
2427
2436
|
}
|
|
2428
2437
|
/**
|
|
2429
2438
|
* 选择节点
|
|
@@ -2437,8 +2446,8 @@ class Ls extends ps {
|
|
|
2437
2446
|
if (a.length === 0)
|
|
2438
2447
|
r(this, it).clearNodes();
|
|
2439
2448
|
else {
|
|
2440
|
-
const
|
|
2441
|
-
r(this, it).setNodes(
|
|
2449
|
+
const l = this.getStage().find(`.${b.selectable}`).filter((h) => a.includes(h.id())).filter((h) => h.listening()).filter((h) => h.isVisible());
|
|
2450
|
+
r(this, it).setNodes(l);
|
|
2442
2451
|
}
|
|
2443
2452
|
this._updateState({ selectedNodeIds: a }, !1), this._emit("nodes:selected", a);
|
|
2444
2453
|
}
|
|
@@ -2454,15 +2463,15 @@ class Ls extends ps {
|
|
|
2454
2463
|
if (t.length === 0) return [];
|
|
2455
2464
|
const e = this.getState().nodes || [], s = new Set(t);
|
|
2456
2465
|
t.forEach((a) => {
|
|
2457
|
-
e.find((
|
|
2458
|
-
|
|
2466
|
+
e.find((h) => h.id === a)?.$_type === "image" && e.forEach((h) => {
|
|
2467
|
+
h.$_type === "image-marker" && h.$_parentId === a && s.add(h.id);
|
|
2459
2468
|
});
|
|
2460
2469
|
});
|
|
2461
2470
|
const o = e.filter((a) => s.has(a.id));
|
|
2462
2471
|
return s.forEach((a) => {
|
|
2463
|
-
const
|
|
2464
|
-
|
|
2465
|
-
}), E(this,
|
|
2472
|
+
const l = this.getStage().findOne(`#${a}`);
|
|
2473
|
+
l && l.destroy();
|
|
2474
|
+
}), E(this, W, Ki).call(this, Array.from(s), !0), r(this, it).clearNodes(), this._updateState(
|
|
2466
2475
|
{
|
|
2467
2476
|
selectedNodeIds: []
|
|
2468
2477
|
},
|
|
@@ -2481,14 +2490,14 @@ class Ls extends ps {
|
|
|
2481
2490
|
* 销毁 canvas
|
|
2482
2491
|
*/
|
|
2483
2492
|
dispose() {
|
|
2484
|
-
r(this, pt) && (r(this, pt).disconnect(),
|
|
2493
|
+
r(this, pt) && (r(this, pt).disconnect(), C(this, pt, null)), this.getCanvasTransformer().destroy(), this.getMainLayer().destroy(), this.getCanvasStage().destroy(), this._dispose();
|
|
2485
2494
|
}
|
|
2486
2495
|
/**
|
|
2487
2496
|
* @internal 仅供内部使用
|
|
2488
2497
|
* 在元素节点改变后(例如 tranfromEnd dragEnd)重建 state.nodes
|
|
2489
2498
|
*/
|
|
2490
2499
|
_rebuildStateAfterNodeChange(t, e) {
|
|
2491
|
-
E(this,
|
|
2500
|
+
E(this, W, Be).call(this, Array.isArray(t) ? t : [t], e);
|
|
2492
2501
|
}
|
|
2493
2502
|
/**
|
|
2494
2503
|
* 实现父类的状态同步方法
|
|
@@ -2502,9 +2511,9 @@ class Ls extends ps {
|
|
|
2502
2511
|
scale: t.viewport.scale
|
|
2503
2512
|
},
|
|
2504
2513
|
!1
|
|
2505
|
-
), r(this,
|
|
2514
|
+
), r(this, ht).forEach((e, s) => {
|
|
2506
2515
|
e.destroy();
|
|
2507
|
-
}), r(this,
|
|
2516
|
+
}), r(this, ht).clear(), this.createNodes(t.nodes || [], !1), this._selectNodes(t.selectedNodeIds || [], !1, !0);
|
|
2508
2517
|
}
|
|
2509
2518
|
_showContextMenu(t) {
|
|
2510
2519
|
this._emit("contextmenu:show", t);
|
|
@@ -2512,12 +2521,12 @@ class Ls extends ps {
|
|
|
2512
2521
|
// 在调整节点上下层级后调用,同步到 store 中
|
|
2513
2522
|
_syncNodesZIndexToStore() {
|
|
2514
2523
|
const t = this.getStage().find(`.${b.nodeRoot}`).map((a) => a.id()).filter((a) => a), e = this.getState().nodes || [], s = /* @__PURE__ */ new Map();
|
|
2515
|
-
t.forEach((a,
|
|
2516
|
-
s.set(a,
|
|
2524
|
+
t.forEach((a, l) => {
|
|
2525
|
+
s.set(a, l);
|
|
2517
2526
|
});
|
|
2518
|
-
const o = [...e].sort((a,
|
|
2519
|
-
const
|
|
2520
|
-
return
|
|
2527
|
+
const o = [...e].sort((a, l) => {
|
|
2528
|
+
const h = s.get(a.id) ?? Number.MIN_SAFE_INTEGER, d = s.get(l.id) ?? Number.MIN_SAFE_INTEGER;
|
|
2529
|
+
return h - d;
|
|
2521
2530
|
});
|
|
2522
2531
|
this._updateState({ nodes: o }, !0), this._emit("nodes:sorted", t);
|
|
2523
2532
|
}
|
|
@@ -2528,7 +2537,7 @@ class Ls extends ps {
|
|
|
2528
2537
|
this._emit("texteditor:unregister", void 0);
|
|
2529
2538
|
}
|
|
2530
2539
|
}
|
|
2531
|
-
kt = new WeakMap(),
|
|
2540
|
+
kt = new WeakMap(), B = new WeakMap(), J = new WeakMap(), it = new WeakMap(), D = new WeakMap(), Rt = new WeakMap(), q = new WeakMap(), j = new WeakMap(), ht = new WeakMap(), pt = new WeakMap(), Me = new WeakMap(), W = new WeakSet(), /**
|
|
2532
2541
|
* 设置键盘事件监听
|
|
2533
2542
|
*/
|
|
2534
2543
|
Yi = function() {
|
|
@@ -2538,14 +2547,14 @@ Yi = function() {
|
|
|
2538
2547
|
* 设置尺寸变化监听
|
|
2539
2548
|
*/
|
|
2540
2549
|
Gi = function() {
|
|
2541
|
-
|
|
2550
|
+
C(this, pt, new ResizeObserver((t) => {
|
|
2542
2551
|
for (const e of t) {
|
|
2543
|
-
const { width: s, height: o } = e.contentRect, a = this.getStage(),
|
|
2552
|
+
const { width: s, height: o } = e.contentRect, a = this.getStage(), l = this.getState().viewport, h = a.width(), d = a.height(), m = l.x + h / 2, f = l.y + d / 2;
|
|
2544
2553
|
a.width(s), a.height(o);
|
|
2545
|
-
const
|
|
2554
|
+
const g = m - s / 2, y = f - o / 2;
|
|
2546
2555
|
this._updateViewport(
|
|
2547
2556
|
{
|
|
2548
|
-
x:
|
|
2557
|
+
x: g,
|
|
2549
2558
|
y
|
|
2550
2559
|
},
|
|
2551
2560
|
!1
|
|
@@ -2557,34 +2566,34 @@ Gi = function() {
|
|
|
2557
2566
|
*/
|
|
2558
2567
|
Pe = function(t) {
|
|
2559
2568
|
const e = this.getState().nodes || [], s = /* @__PURE__ */ new Map();
|
|
2560
|
-
e.forEach((d,
|
|
2561
|
-
s.set(d.id,
|
|
2569
|
+
e.forEach((d, m) => {
|
|
2570
|
+
s.set(d.id, m);
|
|
2562
2571
|
});
|
|
2563
|
-
const o = Array.from(r(this,
|
|
2572
|
+
const o = Array.from(r(this, ht).values()).map(
|
|
2564
2573
|
(d) => d.getConfig()
|
|
2565
|
-
), a = [],
|
|
2574
|
+
), a = [], l = [];
|
|
2566
2575
|
o.forEach((d) => {
|
|
2567
|
-
s.has(d.id) ? a.push(d) :
|
|
2568
|
-
}), a.sort((d,
|
|
2569
|
-
const
|
|
2570
|
-
return
|
|
2576
|
+
s.has(d.id) ? a.push(d) : l.push(d);
|
|
2577
|
+
}), a.sort((d, m) => {
|
|
2578
|
+
const f = s.get(d.id) ?? 0, g = s.get(m.id) ?? 0;
|
|
2579
|
+
return f - g;
|
|
2571
2580
|
});
|
|
2572
|
-
const
|
|
2573
|
-
nodes: [...a, ...
|
|
2581
|
+
const h = {
|
|
2582
|
+
nodes: [...a, ...l]
|
|
2574
2583
|
};
|
|
2575
|
-
this._updateState(
|
|
2584
|
+
this._updateState(h, t);
|
|
2576
2585
|
}, /**
|
|
2577
2586
|
* 更新 state.nodes
|
|
2578
2587
|
*/
|
|
2579
2588
|
Be = function(t, e) {
|
|
2580
2589
|
t.length !== 0 && (t.forEach((s) => {
|
|
2581
|
-
r(this,
|
|
2582
|
-
}), E(this,
|
|
2590
|
+
r(this, ht).set(s.getID(), s);
|
|
2591
|
+
}), E(this, W, Pe).call(this, e));
|
|
2583
2592
|
}, Ki = function(t, e = !1) {
|
|
2584
2593
|
t.length !== 0 && (t.forEach((s) => {
|
|
2585
|
-
const o = r(this,
|
|
2586
|
-
o && o.destroy(), r(this,
|
|
2587
|
-
}), E(this,
|
|
2594
|
+
const o = r(this, ht).get(s);
|
|
2595
|
+
o && o.destroy(), r(this, ht).delete(s);
|
|
2596
|
+
}), E(this, W, Pe).call(this, e));
|
|
2588
2597
|
};
|
|
2589
2598
|
class Ds extends Ls {
|
|
2590
2599
|
/**
|
|
@@ -2665,11 +2674,11 @@ class Ds extends Ls {
|
|
|
2665
2674
|
const t = this.getState().selectedNodeIds || [];
|
|
2666
2675
|
if (t.length === 0)
|
|
2667
2676
|
return console.warn("No selection to export"), null;
|
|
2668
|
-
const e = i?.padding ?? 0, s = new
|
|
2669
|
-
t.forEach((
|
|
2670
|
-
const
|
|
2671
|
-
if (
|
|
2672
|
-
const d =
|
|
2677
|
+
const e = i?.padding ?? 0, s = new M.Group();
|
|
2678
|
+
t.forEach((l) => {
|
|
2679
|
+
const h = this.getStage().findOne(`#${l}`);
|
|
2680
|
+
if (h) {
|
|
2681
|
+
const d = h.clone();
|
|
2673
2682
|
s.add(d);
|
|
2674
2683
|
}
|
|
2675
2684
|
});
|
|
@@ -2694,37 +2703,37 @@ class Ds extends Ls {
|
|
|
2694
2703
|
if (!e)
|
|
2695
2704
|
return console.warn("Image shape not found on stage"), null;
|
|
2696
2705
|
const o = (this.getState().nodes || []).filter(
|
|
2697
|
-
(
|
|
2706
|
+
(x) => x.$_type === "image-marker" && x.$_parentId === i
|
|
2698
2707
|
);
|
|
2699
2708
|
if (o.length === 0)
|
|
2700
2709
|
return console.warn("No image-marker nodes found for the given image ID"), null;
|
|
2701
|
-
const a = new
|
|
2702
|
-
a.add(
|
|
2703
|
-
const
|
|
2704
|
-
o.forEach((
|
|
2705
|
-
const
|
|
2706
|
-
if (
|
|
2707
|
-
const
|
|
2708
|
-
if (w && (w.strokeWidth(3 *
|
|
2709
|
-
const
|
|
2710
|
-
if (
|
|
2711
|
-
const
|
|
2712
|
-
|
|
2710
|
+
const a = new M.Group(), l = e.clone();
|
|
2711
|
+
a.add(l);
|
|
2712
|
+
const h = e.width(), d = e.height(), m = Math.min(h, d), f = t?.markerScale ?? Math.max(1, Math.min(8, m / 400));
|
|
2713
|
+
o.forEach((x) => {
|
|
2714
|
+
const v = this.getStage().findOne(`#${x.id}`);
|
|
2715
|
+
if (v) {
|
|
2716
|
+
const I = v.clone(), w = I.findOne(".rect"), z = I.findOne(".marker-group");
|
|
2717
|
+
if (w && (w.strokeWidth(3 * f), w.cornerRadius(6 * f)), z) {
|
|
2718
|
+
const X = z.findOne("Circle"), R = z.findOne("Text");
|
|
2719
|
+
if (X && (X.radius(14 * f), X.strokeWidth(3 * f)), R) {
|
|
2720
|
+
const F = 14 * f;
|
|
2721
|
+
R.x(-F), R.y(-F), R.width(F * 2), R.height(F * 2), R.fontSize(16 * f);
|
|
2713
2722
|
}
|
|
2714
2723
|
}
|
|
2715
|
-
a.add(
|
|
2724
|
+
a.add(I);
|
|
2716
2725
|
}
|
|
2717
2726
|
});
|
|
2718
|
-
const
|
|
2719
|
-
x:
|
|
2720
|
-
y:
|
|
2721
|
-
width:
|
|
2722
|
-
height:
|
|
2727
|
+
const g = a.getClientRect(), y = a.toDataURL({
|
|
2728
|
+
x: g.x,
|
|
2729
|
+
y: g.y,
|
|
2730
|
+
width: g.width,
|
|
2731
|
+
height: g.height,
|
|
2723
2732
|
pixelRatio: t?.pixelRatio ?? 2,
|
|
2724
2733
|
mimeType: t?.mimeType ?? "image/png",
|
|
2725
2734
|
quality: t?.quality ?? 1
|
|
2726
2735
|
});
|
|
2727
|
-
return a.destroy(),
|
|
2736
|
+
return a.destroy(), y;
|
|
2728
2737
|
}
|
|
2729
2738
|
/**
|
|
2730
2739
|
* 删除当前选中的节点
|
|
@@ -2822,30 +2831,30 @@ class Ds extends Ls {
|
|
|
2822
2831
|
scrollToContent(i) {
|
|
2823
2832
|
if ((this.getState().nodes || []).length === 0) return;
|
|
2824
2833
|
const e = i?.padding ?? 50, s = i?.scale === !0, o = i?.nodeIds;
|
|
2825
|
-
let a = 1 / 0,
|
|
2826
|
-
const
|
|
2827
|
-
if (
|
|
2828
|
-
if (
|
|
2829
|
-
if (
|
|
2830
|
-
const ut =
|
|
2831
|
-
if (!
|
|
2834
|
+
let a = 1 / 0, l = 1 / 0, h = -1 / 0, d = -1 / 0;
|
|
2835
|
+
const m = this.getMainLayer(), f = this.getState().selectedNodeIds || [], g = o && o.length > 0, y = !g && f.length > 0, x = g ? o : y ? f : null;
|
|
2836
|
+
if (m.children.forEach((Y) => {
|
|
2837
|
+
if (Y.visible() && Y.getClassName() !== "Transformer" && Y.hasName(b.selectable)) {
|
|
2838
|
+
if (x) {
|
|
2839
|
+
const ut = Y.id();
|
|
2840
|
+
if (!x.includes(ut)) return;
|
|
2832
2841
|
}
|
|
2833
|
-
const xt =
|
|
2842
|
+
const xt = Y.getAttrs(), ni = xt.x || 0, si = xt.y || 0, En = xt.width || 0, Sn = xt.height || 0;
|
|
2834
2843
|
if (xt.rotation || 0) {
|
|
2835
|
-
const ut =
|
|
2836
|
-
a = Math.min(a, Nn),
|
|
2844
|
+
const ut = Y.getClientRect({ skipTransform: !1 }), Ae = this.getStage(), te = Ae.scaleX(), oi = Ae.x(), ri = Ae.y(), Nn = (ut.x - oi) / te, Tn = (ut.y - ri) / te, _n = (ut.x + ut.width - oi) / te, Mn = (ut.y + ut.height - ri) / te;
|
|
2845
|
+
a = Math.min(a, Nn), l = Math.min(l, Tn), h = Math.max(h, _n), d = Math.max(d, Mn);
|
|
2837
2846
|
} else
|
|
2838
|
-
a = Math.min(a, ni),
|
|
2847
|
+
a = Math.min(a, ni), l = Math.min(l, si), h = Math.max(h, ni + En), d = Math.max(d, si + Sn);
|
|
2839
2848
|
}
|
|
2840
|
-
}), a === 1 / 0 ||
|
|
2841
|
-
const v =
|
|
2842
|
-
let
|
|
2849
|
+
}), a === 1 / 0 || l === 1 / 0) return;
|
|
2850
|
+
const v = h - a, I = d - l, w = a + v / 2, z = l + I / 2;
|
|
2851
|
+
let R = this.getState().viewport.scale;
|
|
2843
2852
|
if (s) {
|
|
2844
|
-
const
|
|
2845
|
-
|
|
2853
|
+
const Y = (this.getStage().width() - e * 2) / v, xt = (this.getStage().height() - e * 2) / I;
|
|
2854
|
+
R = Math.min(Y, xt, 1);
|
|
2846
2855
|
}
|
|
2847
|
-
const
|
|
2848
|
-
this.updateViewport({ x:
|
|
2856
|
+
const F = this.getStage().width() / 2 - w * R, Ct = this.getStage().height() / 2 - z * R;
|
|
2857
|
+
this.updateViewport({ x: F, y: Ct, scale: R }, !0);
|
|
2849
2858
|
}
|
|
2850
2859
|
/**
|
|
2851
2860
|
* 导出当前状态
|
|
@@ -2900,8 +2909,8 @@ class Ds extends Ls {
|
|
|
2900
2909
|
}
|
|
2901
2910
|
}
|
|
2902
2911
|
function Ps(n, i, t, e = !1) {
|
|
2903
|
-
const [s, o] = i, [a,
|
|
2904
|
-
return e ? a <
|
|
2912
|
+
const [s, o] = i, [a, l] = t, h = a + (n - s) / (o - s) * (l - a);
|
|
2913
|
+
return e ? a < l ? Math.max(Math.min(h, l), a) : Math.max(Math.min(h, a), l) : h;
|
|
2905
2914
|
}
|
|
2906
2915
|
const Ei = [
|
|
2907
2916
|
{
|
|
@@ -2932,7 +2941,7 @@ function Bs({
|
|
|
2932
2941
|
size: e = 15,
|
|
2933
2942
|
showGrid: s = !0
|
|
2934
2943
|
}) {
|
|
2935
|
-
const o = n / t, a = i / t,
|
|
2944
|
+
const o = n / t, a = i / t, l = t;
|
|
2936
2945
|
return s ? /* @__PURE__ */ k(
|
|
2937
2946
|
"svg",
|
|
2938
2947
|
{
|
|
@@ -2941,30 +2950,30 @@ function Bs({
|
|
|
2941
2950
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2942
2951
|
"aria-hidden": "true",
|
|
2943
2952
|
children: [
|
|
2944
|
-
/* @__PURE__ */ c("defs", { children: Ei.map(({ min:
|
|
2945
|
-
const
|
|
2953
|
+
/* @__PURE__ */ c("defs", { children: Ei.map(({ min: h, mid: d, step: m }, f) => {
|
|
2954
|
+
const g = m * e * l, y = 0.5 + o * l, x = 0.5 + a * l, v = y > 0 ? y % g : g + y % g, I = x > 0 ? x % g : g + x % g, w = l < d ? Ps(l, [h, d], [0, 1]) : 1;
|
|
2946
2955
|
return /* @__PURE__ */ c(
|
|
2947
2956
|
"pattern",
|
|
2948
2957
|
{
|
|
2949
|
-
id: `grid_${
|
|
2950
|
-
width:
|
|
2951
|
-
height:
|
|
2958
|
+
id: `grid_${m}`,
|
|
2959
|
+
width: g,
|
|
2960
|
+
height: g,
|
|
2952
2961
|
patternUnits: "userSpaceOnUse",
|
|
2953
2962
|
children: /* @__PURE__ */ c(
|
|
2954
2963
|
"circle",
|
|
2955
2964
|
{
|
|
2956
2965
|
className: "grid-dot",
|
|
2957
2966
|
cx: v,
|
|
2958
|
-
cy:
|
|
2967
|
+
cy: I,
|
|
2959
2968
|
r: 1,
|
|
2960
|
-
opacity:
|
|
2969
|
+
opacity: w
|
|
2961
2970
|
}
|
|
2962
2971
|
)
|
|
2963
2972
|
},
|
|
2964
|
-
|
|
2973
|
+
f
|
|
2965
2974
|
);
|
|
2966
2975
|
}) }),
|
|
2967
|
-
Ei.map(({ step:
|
|
2976
|
+
Ei.map(({ step: h }, d) => /* @__PURE__ */ c("rect", { width: "100%", height: "100%", fill: `url(#grid_${h})` }, d))
|
|
2968
2977
|
]
|
|
2969
2978
|
}
|
|
2970
2979
|
) : null;
|
|
@@ -3018,24 +3027,24 @@ function Ft({
|
|
|
3018
3027
|
);
|
|
3019
3028
|
}
|
|
3020
3029
|
function Zs({ api: n }) {
|
|
3021
|
-
const [i, t] =
|
|
3022
|
-
|
|
3023
|
-
n.on("viewport:change", (
|
|
3024
|
-
t(
|
|
3030
|
+
const [i, t] = $(n.getState().viewport);
|
|
3031
|
+
U(() => {
|
|
3032
|
+
n.on("viewport:change", (h) => {
|
|
3033
|
+
t(h);
|
|
3025
3034
|
});
|
|
3026
3035
|
}, [t, n]);
|
|
3027
|
-
const e = (
|
|
3028
|
-
const d = n.getStage().width() / 2,
|
|
3029
|
-
n.updateViewport({ x: y, y:
|
|
3036
|
+
const e = (h) => {
|
|
3037
|
+
const d = n.getStage().width() / 2, m = n.getStage().height() / 2, f = (d - i.x) / i.scale, g = (m - i.y) / i.scale, y = d - f * h, x = m - g * h;
|
|
3038
|
+
n.updateViewport({ x: y, y: x, scale: h });
|
|
3030
3039
|
}, s = () => {
|
|
3031
|
-
const
|
|
3032
|
-
e(
|
|
3040
|
+
const h = Math.min(i.scale * 1.2, 5);
|
|
3041
|
+
e(h);
|
|
3033
3042
|
}, o = () => {
|
|
3034
|
-
const
|
|
3035
|
-
e(
|
|
3043
|
+
const h = Math.max(i.scale / 1.2, 0.1);
|
|
3044
|
+
e(h);
|
|
3036
3045
|
}, a = () => {
|
|
3037
3046
|
e(1);
|
|
3038
|
-
},
|
|
3047
|
+
}, l = Math.round(i.scale * 100);
|
|
3039
3048
|
return /* @__PURE__ */ k("div", { className: "zoom-panel flex items-center gap-2", children: [
|
|
3040
3049
|
/* @__PURE__ */ c(
|
|
3041
3050
|
Ft,
|
|
@@ -3053,10 +3062,10 @@ function Zs({ api: n }) {
|
|
|
3053
3062
|
size: "sm",
|
|
3054
3063
|
variant: "secondary",
|
|
3055
3064
|
onClick: a,
|
|
3056
|
-
title: `${
|
|
3065
|
+
title: `${l}%`,
|
|
3057
3066
|
className: "min-w-16",
|
|
3058
3067
|
children: [
|
|
3059
|
-
|
|
3068
|
+
l,
|
|
3060
3069
|
"%"
|
|
3061
3070
|
]
|
|
3062
3071
|
}
|
|
@@ -3074,8 +3083,8 @@ function Zs({ api: n }) {
|
|
|
3074
3083
|
] });
|
|
3075
3084
|
}
|
|
3076
3085
|
function Us({ api: n }) {
|
|
3077
|
-
const [i, t] =
|
|
3078
|
-
return
|
|
3086
|
+
const [i, t] = $(n.canUndo()), [e, s] = $(n.canRedo());
|
|
3087
|
+
return U(() => {
|
|
3079
3088
|
const o = () => {
|
|
3080
3089
|
t(n.canUndo()), s(n.canRedo());
|
|
3081
3090
|
};
|
|
@@ -3108,18 +3117,18 @@ function Us({ api: n }) {
|
|
|
3108
3117
|
] });
|
|
3109
3118
|
}
|
|
3110
3119
|
function Xo({ setApi: n, theme: i }) {
|
|
3111
|
-
const t = Ue(null), [e, s] =
|
|
3112
|
-
return
|
|
3120
|
+
const t = Ue(null), [e, s] = $(null), [o, a] = $({ x: 0, y: 0, scale: 1 });
|
|
3121
|
+
return U(() => {
|
|
3113
3122
|
if (!t.current) return;
|
|
3114
|
-
const
|
|
3123
|
+
const l = new Ds(t.current, {
|
|
3115
3124
|
theme: i
|
|
3116
3125
|
});
|
|
3117
|
-
return s(
|
|
3118
|
-
a(
|
|
3126
|
+
return s(l), n?.(l), l.on("viewport:change", (h) => {
|
|
3127
|
+
a(h);
|
|
3119
3128
|
}), () => {
|
|
3120
|
-
|
|
3129
|
+
l.dispose();
|
|
3121
3130
|
};
|
|
3122
|
-
}, []),
|
|
3131
|
+
}, []), U(() => {
|
|
3123
3132
|
e && i && e.setTheme(i);
|
|
3124
3133
|
}, [e, i]), /* @__PURE__ */ k("div", { className: "whiteboard relative size-full", children: [
|
|
3125
3134
|
/* @__PURE__ */ c(
|
|
@@ -3144,17 +3153,17 @@ function Xo({ setApi: n, theme: i }) {
|
|
|
3144
3153
|
] });
|
|
3145
3154
|
}
|
|
3146
3155
|
function Yo(n) {
|
|
3147
|
-
const [i, t] =
|
|
3148
|
-
return
|
|
3156
|
+
const [i, t] = $(null);
|
|
3157
|
+
return U(() => {
|
|
3149
3158
|
if (!n) return;
|
|
3150
3159
|
const s = ({
|
|
3151
3160
|
clientX: o,
|
|
3152
3161
|
clientY: a,
|
|
3153
|
-
targetIds:
|
|
3162
|
+
targetIds: l
|
|
3154
3163
|
}) => {
|
|
3155
|
-
let
|
|
3156
|
-
if (
|
|
3157
|
-
|
|
3164
|
+
let h = [];
|
|
3165
|
+
if (l.length > 1)
|
|
3166
|
+
h = [
|
|
3158
3167
|
// {
|
|
3159
3168
|
// label: "组合",
|
|
3160
3169
|
// action: () => {
|
|
@@ -3170,9 +3179,9 @@ function Yo(n) {
|
|
|
3170
3179
|
// },
|
|
3171
3180
|
// },
|
|
3172
3181
|
];
|
|
3173
|
-
else if (
|
|
3174
|
-
const d =
|
|
3175
|
-
d === "canvas-stage" ?
|
|
3182
|
+
else if (l.length === 1) {
|
|
3183
|
+
const d = l[0];
|
|
3184
|
+
d === "canvas-stage" ? h = [] : h = [
|
|
3176
3185
|
{
|
|
3177
3186
|
label: "置顶",
|
|
3178
3187
|
action: () => {
|
|
@@ -3199,20 +3208,20 @@ function Yo(n) {
|
|
|
3199
3208
|
}
|
|
3200
3209
|
];
|
|
3201
3210
|
}
|
|
3202
|
-
if (
|
|
3211
|
+
if (h.length === 0) {
|
|
3203
3212
|
t(null);
|
|
3204
3213
|
return;
|
|
3205
3214
|
}
|
|
3206
3215
|
t({
|
|
3207
3216
|
x: o,
|
|
3208
3217
|
y: a,
|
|
3209
|
-
items:
|
|
3218
|
+
items: h
|
|
3210
3219
|
});
|
|
3211
3220
|
};
|
|
3212
3221
|
return n.on("contextmenu:show", s), () => {
|
|
3213
3222
|
n.off("contextmenu:show", s);
|
|
3214
3223
|
};
|
|
3215
|
-
}, [n]),
|
|
3224
|
+
}, [n]), U(() => {
|
|
3216
3225
|
const s = () => {
|
|
3217
3226
|
i && t(null);
|
|
3218
3227
|
};
|
|
@@ -3312,9 +3321,9 @@ function Ys({
|
|
|
3312
3321
|
delay: s = 600,
|
|
3313
3322
|
closeDelay: o = 0
|
|
3314
3323
|
} = {}) {
|
|
3315
|
-
const [a,
|
|
3324
|
+
const [a, l] = $(n), h = t ?? a, d = e ?? l, m = ss({
|
|
3316
3325
|
placement: i,
|
|
3317
|
-
open:
|
|
3326
|
+
open: h,
|
|
3318
3327
|
onOpenChange: d,
|
|
3319
3328
|
whileElementsMounted: ls,
|
|
3320
3329
|
middleware: [
|
|
@@ -3326,7 +3335,7 @@ function Ys({
|
|
|
3326
3335
|
}),
|
|
3327
3336
|
as({ padding: 4 })
|
|
3328
3337
|
]
|
|
3329
|
-
}),
|
|
3338
|
+
}), f = m.context, g = hs(f, {
|
|
3330
3339
|
mouseOnly: !0,
|
|
3331
3340
|
move: !1,
|
|
3332
3341
|
restMs: s,
|
|
@@ -3334,17 +3343,17 @@ function Ys({
|
|
|
3334
3343
|
delay: {
|
|
3335
3344
|
close: o
|
|
3336
3345
|
}
|
|
3337
|
-
}), y = cs(
|
|
3346
|
+
}), y = cs(f, {
|
|
3338
3347
|
enabled: t == null
|
|
3339
|
-
}),
|
|
3348
|
+
}), x = ds(f), v = gs(f, { role: "tooltip" }), I = us([g, y, x, v]);
|
|
3340
3349
|
return St(
|
|
3341
3350
|
() => ({
|
|
3342
|
-
open:
|
|
3351
|
+
open: h,
|
|
3343
3352
|
setOpen: d,
|
|
3344
|
-
...
|
|
3345
|
-
...
|
|
3353
|
+
...I,
|
|
3354
|
+
...m
|
|
3346
3355
|
}),
|
|
3347
|
-
[
|
|
3356
|
+
[h, d, I, m]
|
|
3348
3357
|
);
|
|
3349
3358
|
}
|
|
3350
3359
|
const Ve = Rn(null);
|
|
@@ -3365,7 +3374,7 @@ function Ji({ children: n, ...i }) {
|
|
|
3365
3374
|
}
|
|
3366
3375
|
) : /* @__PURE__ */ c(Ve.Provider, { value: t, children: n });
|
|
3367
3376
|
}
|
|
3368
|
-
const Qi =
|
|
3377
|
+
const Qi = A(
|
|
3369
3378
|
function({ children: i, asChild: t = !1, ...e }, s) {
|
|
3370
3379
|
const o = ji(), a = li(i) ? parseInt($n, 10) >= 19 ? (
|
|
3371
3380
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -3373,44 +3382,44 @@ const Qi = $(
|
|
|
3373
3382
|
) : (
|
|
3374
3383
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3375
3384
|
i.ref
|
|
3376
|
-
) : void 0,
|
|
3385
|
+
) : void 0, l = Ni([o.refs.setReference, s, a]);
|
|
3377
3386
|
if (t && li(i)) {
|
|
3378
|
-
const
|
|
3387
|
+
const h = {
|
|
3379
3388
|
"data-tooltip-state": o.open ? "open" : "closed"
|
|
3380
3389
|
};
|
|
3381
3390
|
return An(
|
|
3382
3391
|
i,
|
|
3383
3392
|
o.getReferenceProps({
|
|
3384
|
-
ref:
|
|
3393
|
+
ref: l,
|
|
3385
3394
|
...e,
|
|
3386
3395
|
...typeof i.props == "object" ? i.props : {},
|
|
3387
|
-
...
|
|
3396
|
+
...h
|
|
3388
3397
|
})
|
|
3389
3398
|
);
|
|
3390
3399
|
}
|
|
3391
3400
|
return /* @__PURE__ */ c(
|
|
3392
3401
|
"button",
|
|
3393
3402
|
{
|
|
3394
|
-
ref:
|
|
3403
|
+
ref: l,
|
|
3395
3404
|
"data-tooltip-state": o.open ? "open" : "closed",
|
|
3396
3405
|
...o.getReferenceProps(e),
|
|
3397
3406
|
children: i
|
|
3398
3407
|
}
|
|
3399
3408
|
);
|
|
3400
3409
|
}
|
|
3401
|
-
), tn =
|
|
3410
|
+
), tn = A(
|
|
3402
3411
|
function({ style: i, children: t, portal: e = !0, portalProps: s = {}, ...o }, a) {
|
|
3403
|
-
const
|
|
3404
|
-
if (!
|
|
3412
|
+
const l = ji(), h = Ni([l.refs.setFloating, a]);
|
|
3413
|
+
if (!l.open) return null;
|
|
3405
3414
|
const d = /* @__PURE__ */ c(
|
|
3406
3415
|
"div",
|
|
3407
3416
|
{
|
|
3408
|
-
ref:
|
|
3417
|
+
ref: h,
|
|
3409
3418
|
style: {
|
|
3410
|
-
...
|
|
3419
|
+
...l.floatingStyles,
|
|
3411
3420
|
...i
|
|
3412
3421
|
},
|
|
3413
|
-
...
|
|
3422
|
+
...l.getFloatingProps(o),
|
|
3414
3423
|
className: "tiptap-tooltip",
|
|
3415
3424
|
children: t
|
|
3416
3425
|
}
|
|
@@ -3426,7 +3435,7 @@ const Gs = ({
|
|
|
3426
3435
|
}) => n.length === 0 ? null : /* @__PURE__ */ c("div", { children: n.map((i, t) => /* @__PURE__ */ k(Hn, { children: [
|
|
3427
3436
|
t > 0 && /* @__PURE__ */ c("kbd", { children: "+" }),
|
|
3428
3437
|
/* @__PURE__ */ c("kbd", { children: i })
|
|
3429
|
-
] }, t)) }), vt =
|
|
3438
|
+
] }, t)) }), vt = A(
|
|
3430
3439
|
({
|
|
3431
3440
|
className: n,
|
|
3432
3441
|
children: i,
|
|
@@ -3435,8 +3444,8 @@ const Gs = ({
|
|
|
3435
3444
|
shortcutKeys: s,
|
|
3436
3445
|
variant: o,
|
|
3437
3446
|
size: a,
|
|
3438
|
-
...
|
|
3439
|
-
},
|
|
3447
|
+
...l
|
|
3448
|
+
}, h) => {
|
|
3440
3449
|
const d = St(
|
|
3441
3450
|
() => ke({ shortcutKeys: s }),
|
|
3442
3451
|
[s]
|
|
@@ -3445,10 +3454,10 @@ const Gs = ({
|
|
|
3445
3454
|
"button",
|
|
3446
3455
|
{
|
|
3447
3456
|
className: nt("tiptap-button", n),
|
|
3448
|
-
ref:
|
|
3457
|
+
ref: h,
|
|
3449
3458
|
"data-style": o,
|
|
3450
3459
|
"data-size": a,
|
|
3451
|
-
...
|
|
3460
|
+
...l,
|
|
3452
3461
|
children: i
|
|
3453
3462
|
}
|
|
3454
3463
|
) : /* @__PURE__ */ k(Ji, { delay: 200, children: [
|
|
@@ -3456,10 +3465,10 @@ const Gs = ({
|
|
|
3456
3465
|
Qi,
|
|
3457
3466
|
{
|
|
3458
3467
|
className: nt("tiptap-button", n),
|
|
3459
|
-
ref:
|
|
3468
|
+
ref: h,
|
|
3460
3469
|
"data-style": o,
|
|
3461
3470
|
"data-size": a,
|
|
3462
|
-
...
|
|
3471
|
+
...l,
|
|
3463
3472
|
children: i
|
|
3464
3473
|
}
|
|
3465
3474
|
),
|
|
@@ -3471,7 +3480,7 @@ const Gs = ({
|
|
|
3471
3480
|
}
|
|
3472
3481
|
);
|
|
3473
3482
|
vt.displayName = "Button";
|
|
3474
|
-
const Ht =
|
|
3483
|
+
const Ht = A(({ className: n, children: i, orientation: t = "vertical", ...e }, s) => /* @__PURE__ */ c(
|
|
3475
3484
|
"div",
|
|
3476
3485
|
{
|
|
3477
3486
|
ref: s,
|
|
@@ -3483,7 +3492,7 @@ const Ht = $(({ className: n, children: i, orientation: t = "vertical", ...e },
|
|
|
3483
3492
|
}
|
|
3484
3493
|
));
|
|
3485
3494
|
Ht.displayName = "ButtonGroup";
|
|
3486
|
-
const Re =
|
|
3495
|
+
const Re = A(
|
|
3487
3496
|
({
|
|
3488
3497
|
variant: n,
|
|
3489
3498
|
size: i = "default",
|
|
@@ -3492,10 +3501,10 @@ const Re = $(
|
|
|
3492
3501
|
className: s,
|
|
3493
3502
|
children: o,
|
|
3494
3503
|
...a
|
|
3495
|
-
},
|
|
3504
|
+
}, l) => /* @__PURE__ */ c(
|
|
3496
3505
|
"div",
|
|
3497
3506
|
{
|
|
3498
|
-
ref:
|
|
3507
|
+
ref: l,
|
|
3499
3508
|
className: `tiptap-badge ${s || ""}`,
|
|
3500
3509
|
"data-style": n,
|
|
3501
3510
|
"data-size": i,
|
|
@@ -3513,7 +3522,7 @@ function Ks({
|
|
|
3513
3522
|
}) {
|
|
3514
3523
|
return /* @__PURE__ */ c(Re, { children: ke({ shortcutKeys: i }) });
|
|
3515
3524
|
}
|
|
3516
|
-
const At =
|
|
3525
|
+
const At = A(
|
|
3517
3526
|
({
|
|
3518
3527
|
editor: n,
|
|
3519
3528
|
type: i,
|
|
@@ -3522,55 +3531,55 @@ const At = $(
|
|
|
3522
3531
|
onToggled: s,
|
|
3523
3532
|
showShortcut: o = !1,
|
|
3524
3533
|
onClick: a,
|
|
3525
|
-
children:
|
|
3526
|
-
...
|
|
3534
|
+
children: l,
|
|
3535
|
+
...h
|
|
3527
3536
|
}, d) => {
|
|
3528
|
-
const { editor:
|
|
3529
|
-
isVisible:
|
|
3530
|
-
handleMark:
|
|
3537
|
+
const { editor: m } = yt(n), {
|
|
3538
|
+
isVisible: f,
|
|
3539
|
+
handleMark: g,
|
|
3531
3540
|
label: y,
|
|
3532
|
-
canToggle:
|
|
3541
|
+
canToggle: x,
|
|
3533
3542
|
isActive: v,
|
|
3534
|
-
Icon:
|
|
3535
|
-
shortcutKeys:
|
|
3543
|
+
Icon: I,
|
|
3544
|
+
shortcutKeys: w
|
|
3536
3545
|
} = eo({
|
|
3537
|
-
editor:
|
|
3546
|
+
editor: m,
|
|
3538
3547
|
type: i,
|
|
3539
3548
|
hideWhenUnavailable: e,
|
|
3540
3549
|
onToggled: s
|
|
3541
|
-
}),
|
|
3542
|
-
(
|
|
3543
|
-
a?.(
|
|
3550
|
+
}), z = Q(
|
|
3551
|
+
(X) => {
|
|
3552
|
+
a?.(X), !X.defaultPrevented && g();
|
|
3544
3553
|
},
|
|
3545
|
-
[
|
|
3554
|
+
[g, a]
|
|
3546
3555
|
);
|
|
3547
|
-
return
|
|
3556
|
+
return f ? /* @__PURE__ */ c(
|
|
3548
3557
|
vt,
|
|
3549
3558
|
{
|
|
3550
3559
|
type: "button",
|
|
3551
|
-
disabled: !
|
|
3560
|
+
disabled: !x,
|
|
3552
3561
|
variant: "ghost",
|
|
3553
3562
|
"data-active-state": v ? "on" : "off",
|
|
3554
|
-
"data-disabled": !
|
|
3563
|
+
"data-disabled": !x,
|
|
3555
3564
|
role: "button",
|
|
3556
3565
|
tabIndex: -1,
|
|
3557
3566
|
"aria-label": y,
|
|
3558
3567
|
"aria-pressed": v,
|
|
3559
3568
|
tooltip: y,
|
|
3560
|
-
onClick:
|
|
3561
|
-
...
|
|
3569
|
+
onClick: z,
|
|
3570
|
+
...h,
|
|
3562
3571
|
ref: d,
|
|
3563
|
-
children:
|
|
3564
|
-
/* @__PURE__ */ c(
|
|
3572
|
+
children: l ?? /* @__PURE__ */ k(Ie, { children: [
|
|
3573
|
+
/* @__PURE__ */ c(I, { className: "tiptap-button-icon" }),
|
|
3565
3574
|
t && /* @__PURE__ */ c("span", { className: "tiptap-button-text", children: t }),
|
|
3566
|
-
o && /* @__PURE__ */ c(Ks, { type: i, shortcutKeys:
|
|
3575
|
+
o && /* @__PURE__ */ c(Ks, { type: i, shortcutKeys: w })
|
|
3567
3576
|
] })
|
|
3568
3577
|
}
|
|
3569
3578
|
) : null;
|
|
3570
3579
|
}
|
|
3571
3580
|
);
|
|
3572
3581
|
At.displayName = "MarkButton";
|
|
3573
|
-
const en =
|
|
3582
|
+
const en = dt(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3574
3583
|
"svg",
|
|
3575
3584
|
{
|
|
3576
3585
|
width: "24",
|
|
@@ -3592,7 +3601,7 @@ const en = ct(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
|
3592
3601
|
}
|
|
3593
3602
|
));
|
|
3594
3603
|
en.displayName = "BoldIcon";
|
|
3595
|
-
const nn =
|
|
3604
|
+
const nn = dt(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
3596
3605
|
"svg",
|
|
3597
3606
|
{
|
|
3598
3607
|
width: "24",
|
|
@@ -3628,7 +3637,7 @@ const nn = ct(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
|
3628
3637
|
}
|
|
3629
3638
|
));
|
|
3630
3639
|
nn.displayName = "Code2Icon";
|
|
3631
|
-
const sn =
|
|
3640
|
+
const sn = dt(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3632
3641
|
"svg",
|
|
3633
3642
|
{
|
|
3634
3643
|
width: "24",
|
|
@@ -3648,7 +3657,7 @@ const sn = ct(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
|
3648
3657
|
}
|
|
3649
3658
|
));
|
|
3650
3659
|
sn.displayName = "ItalicIcon";
|
|
3651
|
-
const on =
|
|
3660
|
+
const on = dt(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
3652
3661
|
"svg",
|
|
3653
3662
|
{
|
|
3654
3663
|
width: "24",
|
|
@@ -3677,7 +3686,7 @@ const on = ct(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
|
3677
3686
|
}
|
|
3678
3687
|
));
|
|
3679
3688
|
on.displayName = "StrikeIcon";
|
|
3680
|
-
const rn =
|
|
3689
|
+
const rn = dt(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
3681
3690
|
"svg",
|
|
3682
3691
|
{
|
|
3683
3692
|
width: "24",
|
|
@@ -3719,7 +3728,7 @@ const rn = ct(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
|
3719
3728
|
}
|
|
3720
3729
|
));
|
|
3721
3730
|
rn.displayName = "SubscriptIcon";
|
|
3722
|
-
const an =
|
|
3731
|
+
const an = dt(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
3723
3732
|
"svg",
|
|
3724
3733
|
{
|
|
3725
3734
|
width: "24",
|
|
@@ -3761,7 +3770,7 @@ const an = ct(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
|
3761
3770
|
}
|
|
3762
3771
|
));
|
|
3763
3772
|
an.displayName = "SuperscriptIcon";
|
|
3764
|
-
const ln =
|
|
3773
|
+
const ln = dt(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3765
3774
|
"svg",
|
|
3766
3775
|
{
|
|
3767
3776
|
width: "24",
|
|
@@ -3822,26 +3831,26 @@ function eo(n) {
|
|
|
3822
3831
|
type: t,
|
|
3823
3832
|
hideWhenUnavailable: e = !1,
|
|
3824
3833
|
onToggled: s
|
|
3825
|
-
} = n, { editor: o } = yt(i), [a,
|
|
3826
|
-
|
|
3834
|
+
} = n, { editor: o } = yt(i), [a, l] = $(!0), h = We(o, t), d = js(o, t);
|
|
3835
|
+
U(() => {
|
|
3827
3836
|
if (!o) return;
|
|
3828
|
-
const
|
|
3829
|
-
|
|
3837
|
+
const f = () => {
|
|
3838
|
+
l(Qs({ editor: o, type: t, hideWhenUnavailable: e }));
|
|
3830
3839
|
};
|
|
3831
|
-
return
|
|
3832
|
-
o.off("selectionUpdate",
|
|
3840
|
+
return f(), o.on("selectionUpdate", f), () => {
|
|
3841
|
+
o.off("selectionUpdate", f);
|
|
3833
3842
|
};
|
|
3834
3843
|
}, [o, t, e]);
|
|
3835
|
-
const
|
|
3844
|
+
const m = Q(() => {
|
|
3836
3845
|
if (!o) return !1;
|
|
3837
|
-
const
|
|
3838
|
-
return
|
|
3846
|
+
const f = Js(o, t);
|
|
3847
|
+
return f && s?.(), f;
|
|
3839
3848
|
}, [o, t, s]);
|
|
3840
3849
|
return {
|
|
3841
3850
|
isVisible: a,
|
|
3842
3851
|
isActive: d,
|
|
3843
|
-
handleMark:
|
|
3844
|
-
canToggle:
|
|
3852
|
+
handleMark: m,
|
|
3853
|
+
canToggle: h,
|
|
3845
3854
|
label: to(t),
|
|
3846
3855
|
shortcutKeys: hn[t],
|
|
3847
3856
|
Icon: qs[t]
|
|
@@ -3855,44 +3864,44 @@ function cn({
|
|
|
3855
3864
|
onSelect: s,
|
|
3856
3865
|
onClose: o,
|
|
3857
3866
|
orientation: a = "vertical",
|
|
3858
|
-
autoSelectFirstItem:
|
|
3867
|
+
autoSelectFirstItem: l = !0
|
|
3859
3868
|
}) {
|
|
3860
|
-
const [
|
|
3861
|
-
|
|
3869
|
+
const [h, d] = $(
|
|
3870
|
+
l ? 0 : -1
|
|
3862
3871
|
);
|
|
3863
|
-
return
|
|
3864
|
-
const
|
|
3872
|
+
return U(() => {
|
|
3873
|
+
const m = (g) => {
|
|
3865
3874
|
if (!e.length) return !1;
|
|
3866
|
-
const y = () => d((v) => v === -1 ? 0 : (v + 1) % e.length),
|
|
3867
|
-
switch (
|
|
3875
|
+
const y = () => d((v) => v === -1 ? 0 : (v + 1) % e.length), x = () => d((v) => v === -1 ? e.length - 1 : (v - 1 + e.length) % e.length);
|
|
3876
|
+
switch (g.key) {
|
|
3868
3877
|
case "ArrowUp":
|
|
3869
|
-
return a === "horizontal" ? !1 : (
|
|
3878
|
+
return a === "horizontal" ? !1 : (g.preventDefault(), x(), !0);
|
|
3870
3879
|
case "ArrowDown":
|
|
3871
|
-
return a === "horizontal" ? !1 : (
|
|
3880
|
+
return a === "horizontal" ? !1 : (g.preventDefault(), y(), !0);
|
|
3872
3881
|
case "ArrowLeft":
|
|
3873
|
-
return a === "vertical" ? !1 : (
|
|
3882
|
+
return a === "vertical" ? !1 : (g.preventDefault(), x(), !0);
|
|
3874
3883
|
case "ArrowRight":
|
|
3875
|
-
return a === "vertical" ? !1 : (
|
|
3884
|
+
return a === "vertical" ? !1 : (g.preventDefault(), y(), !0);
|
|
3876
3885
|
case "Tab":
|
|
3877
|
-
return
|
|
3886
|
+
return g.preventDefault(), g.shiftKey ? x() : y(), !0;
|
|
3878
3887
|
case "Home":
|
|
3879
|
-
return
|
|
3888
|
+
return g.preventDefault(), d(0), !0;
|
|
3880
3889
|
case "End":
|
|
3881
|
-
return
|
|
3890
|
+
return g.preventDefault(), d(e.length - 1), !0;
|
|
3882
3891
|
case "Enter":
|
|
3883
|
-
return
|
|
3892
|
+
return g.isComposing ? !1 : (g.preventDefault(), h !== -1 && e[h] && s?.(e[h]), !0);
|
|
3884
3893
|
case "Escape":
|
|
3885
|
-
return
|
|
3894
|
+
return g.preventDefault(), o?.(), !0;
|
|
3886
3895
|
default:
|
|
3887
3896
|
return !1;
|
|
3888
3897
|
}
|
|
3889
3898
|
};
|
|
3890
|
-
let
|
|
3891
|
-
if (n ?
|
|
3892
|
-
return
|
|
3893
|
-
|
|
3899
|
+
let f = null;
|
|
3900
|
+
if (n ? f = n.view.dom : i?.current && (f = i.current), f)
|
|
3901
|
+
return f.addEventListener("keydown", m, !0), () => {
|
|
3902
|
+
f?.removeEventListener(
|
|
3894
3903
|
"keydown",
|
|
3895
|
-
|
|
3904
|
+
m,
|
|
3896
3905
|
!0
|
|
3897
3906
|
);
|
|
3898
3907
|
};
|
|
@@ -3900,25 +3909,25 @@ function cn({
|
|
|
3900
3909
|
n,
|
|
3901
3910
|
i,
|
|
3902
3911
|
e,
|
|
3903
|
-
|
|
3912
|
+
h,
|
|
3904
3913
|
s,
|
|
3905
3914
|
o,
|
|
3906
3915
|
a
|
|
3907
|
-
]),
|
|
3908
|
-
t && d(
|
|
3909
|
-
}, [t,
|
|
3910
|
-
selectedIndex: e.length ?
|
|
3916
|
+
]), U(() => {
|
|
3917
|
+
t && d(l ? 0 : -1);
|
|
3918
|
+
}, [t, l]), {
|
|
3919
|
+
selectedIndex: e.length ? h : void 0,
|
|
3911
3920
|
setSelectedIndex: d
|
|
3912
3921
|
};
|
|
3913
3922
|
}
|
|
3914
3923
|
function $e(n = "max", i = 768) {
|
|
3915
|
-
const [t, e] =
|
|
3916
|
-
return
|
|
3917
|
-
const s = n === "min" ? `(min-width: ${i}px)` : `(max-width: ${i - 1}px)`, o = window.matchMedia(s), a = (
|
|
3924
|
+
const [t, e] = $(void 0);
|
|
3925
|
+
return U(() => {
|
|
3926
|
+
const s = n === "min" ? `(min-width: ${i}px)` : `(max-width: ${i - 1}px)`, o = window.matchMedia(s), a = (l) => e(l.matches);
|
|
3918
3927
|
return e(o.matches), o.addEventListener("change", a), () => o.removeEventListener("change", a);
|
|
3919
3928
|
}, [n, i]), !!t;
|
|
3920
3929
|
}
|
|
3921
|
-
const Xe =
|
|
3930
|
+
const Xe = dt(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3922
3931
|
"svg",
|
|
3923
3932
|
{
|
|
3924
3933
|
width: "24",
|
|
@@ -3940,7 +3949,7 @@ const Xe = ct(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
|
3940
3949
|
}
|
|
3941
3950
|
));
|
|
3942
3951
|
Xe.displayName = "BanIcon";
|
|
3943
|
-
const Ye =
|
|
3952
|
+
const Ye = dt(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3944
3953
|
"svg",
|
|
3945
3954
|
{
|
|
3946
3955
|
width: "24",
|
|
@@ -3989,7 +3998,7 @@ function un({
|
|
|
3989
3998
|
}
|
|
3990
3999
|
) });
|
|
3991
4000
|
}
|
|
3992
|
-
const Ge =
|
|
4001
|
+
const Ge = A(
|
|
3993
4002
|
({ decorative: n, orientation: i = "vertical", className: t, ...e }, s) => {
|
|
3994
4003
|
const a = n ? { role: "none" } : { "aria-orientation": i === "vertical" ? i : void 0, role: "separator" };
|
|
3995
4004
|
return /* @__PURE__ */ c(
|
|
@@ -4005,11 +4014,11 @@ const Ge = $(
|
|
|
4005
4014
|
}
|
|
4006
4015
|
);
|
|
4007
4016
|
Ge.displayName = "Separator";
|
|
4008
|
-
const Ke =
|
|
4017
|
+
const Ke = A(
|
|
4009
4018
|
({ className: n, ...i }, t) => /* @__PURE__ */ c("div", { ref: t, className: nt("tiptap-card", n), ...i })
|
|
4010
4019
|
);
|
|
4011
4020
|
Ke.displayName = "Card";
|
|
4012
|
-
const io =
|
|
4021
|
+
const io = A(
|
|
4013
4022
|
({ className: n, ...i }, t) => /* @__PURE__ */ c(
|
|
4014
4023
|
"div",
|
|
4015
4024
|
{
|
|
@@ -4020,11 +4029,11 @@ const io = $(
|
|
|
4020
4029
|
)
|
|
4021
4030
|
);
|
|
4022
4031
|
io.displayName = "CardHeader";
|
|
4023
|
-
const qe =
|
|
4032
|
+
const qe = A(
|
|
4024
4033
|
({ className: n, ...i }, t) => /* @__PURE__ */ c("div", { ref: t, className: nt("tiptap-card-body", n), ...i })
|
|
4025
4034
|
);
|
|
4026
4035
|
qe.displayName = "CardBody";
|
|
4027
|
-
const je =
|
|
4036
|
+
const je = A(({ className: n, orientation: i = "vertical", ...t }, e) => /* @__PURE__ */ c(
|
|
4028
4037
|
"div",
|
|
4029
4038
|
{
|
|
4030
4039
|
ref: e,
|
|
@@ -4034,7 +4043,7 @@ const je = $(({ className: n, orientation: i = "vertical", ...t }, e) => /* @__P
|
|
|
4034
4043
|
}
|
|
4035
4044
|
));
|
|
4036
4045
|
je.displayName = "CardItemGroup";
|
|
4037
|
-
const no =
|
|
4046
|
+
const no = A(
|
|
4038
4047
|
({ className: n, ...i }, t) => /* @__PURE__ */ c(
|
|
4039
4048
|
"div",
|
|
4040
4049
|
{
|
|
@@ -4045,7 +4054,7 @@ const no = $(
|
|
|
4045
4054
|
)
|
|
4046
4055
|
);
|
|
4047
4056
|
no.displayName = "CardGroupLabel";
|
|
4048
|
-
const so =
|
|
4057
|
+
const so = A(
|
|
4049
4058
|
({ className: n, ...i }, t) => /* @__PURE__ */ c(
|
|
4050
4059
|
"div",
|
|
4051
4060
|
{
|
|
@@ -4061,7 +4070,7 @@ function oo({
|
|
|
4061
4070
|
}) {
|
|
4062
4071
|
return /* @__PURE__ */ c(Re, { children: ke({ shortcutKeys: n }) });
|
|
4063
4072
|
}
|
|
4064
|
-
const mn =
|
|
4073
|
+
const mn = A(
|
|
4065
4074
|
({
|
|
4066
4075
|
editor: n,
|
|
4067
4076
|
highlightColor: i,
|
|
@@ -4070,57 +4079,57 @@ const mn = $(
|
|
|
4070
4079
|
mode: s = "mark",
|
|
4071
4080
|
onApplied: o,
|
|
4072
4081
|
showShortcut: a = !1,
|
|
4073
|
-
onClick:
|
|
4074
|
-
children:
|
|
4082
|
+
onClick: l,
|
|
4083
|
+
children: h,
|
|
4075
4084
|
style: d,
|
|
4076
|
-
useColorValue:
|
|
4077
|
-
...
|
|
4078
|
-
},
|
|
4085
|
+
useColorValue: m = !1,
|
|
4086
|
+
...f
|
|
4087
|
+
}, g) => {
|
|
4079
4088
|
const { editor: y } = yt(n), {
|
|
4080
|
-
isVisible:
|
|
4089
|
+
isVisible: x,
|
|
4081
4090
|
canColorHighlight: v,
|
|
4082
|
-
isActive:
|
|
4083
|
-
handleColorHighlight:
|
|
4084
|
-
label:
|
|
4085
|
-
shortcutKeys:
|
|
4091
|
+
isActive: I,
|
|
4092
|
+
handleColorHighlight: w,
|
|
4093
|
+
label: z,
|
|
4094
|
+
shortcutKeys: X
|
|
4086
4095
|
} = Qe({
|
|
4087
4096
|
editor: y,
|
|
4088
4097
|
highlightColor: i,
|
|
4089
|
-
useColorValue:
|
|
4098
|
+
useColorValue: m,
|
|
4090
4099
|
label: t || `Toggle highlight (${i})`,
|
|
4091
4100
|
hideWhenUnavailable: e,
|
|
4092
4101
|
mode: s,
|
|
4093
4102
|
onApplied: o
|
|
4094
|
-
}),
|
|
4103
|
+
}), R = Q(
|
|
4095
4104
|
(Ct) => {
|
|
4096
|
-
|
|
4105
|
+
l?.(Ct), !Ct.defaultPrevented && (w(), Ct.preventDefault(), Ct.stopPropagation());
|
|
4097
4106
|
},
|
|
4098
|
-
[
|
|
4099
|
-
),
|
|
4107
|
+
[w, l]
|
|
4108
|
+
), F = St(
|
|
4100
4109
|
() => ({
|
|
4101
4110
|
...d,
|
|
4102
4111
|
"--highlight-color": i
|
|
4103
4112
|
}),
|
|
4104
4113
|
[i, d]
|
|
4105
4114
|
);
|
|
4106
|
-
return
|
|
4115
|
+
return x ? /* @__PURE__ */ c(
|
|
4107
4116
|
vt,
|
|
4108
4117
|
{
|
|
4109
4118
|
type: "button",
|
|
4110
4119
|
variant: "ghost",
|
|
4111
|
-
"data-active-state":
|
|
4120
|
+
"data-active-state": I ? "on" : "off",
|
|
4112
4121
|
role: "button",
|
|
4113
4122
|
tabIndex: -1,
|
|
4114
4123
|
disabled: !v,
|
|
4115
4124
|
"data-disabled": !v,
|
|
4116
|
-
"aria-label":
|
|
4117
|
-
"aria-pressed":
|
|
4118
|
-
tooltip:
|
|
4119
|
-
onClick:
|
|
4120
|
-
style:
|
|
4121
|
-
...
|
|
4122
|
-
ref:
|
|
4123
|
-
children:
|
|
4125
|
+
"aria-label": z,
|
|
4126
|
+
"aria-pressed": I,
|
|
4127
|
+
tooltip: z,
|
|
4128
|
+
onClick: R,
|
|
4129
|
+
style: F,
|
|
4130
|
+
...f,
|
|
4131
|
+
ref: g,
|
|
4132
|
+
children: h ?? /* @__PURE__ */ k(Ie, { children: [
|
|
4124
4133
|
/* @__PURE__ */ c(
|
|
4125
4134
|
"span",
|
|
4126
4135
|
{
|
|
@@ -4129,7 +4138,7 @@ const mn = $(
|
|
|
4129
4138
|
}
|
|
4130
4139
|
),
|
|
4131
4140
|
t && /* @__PURE__ */ c("span", { className: "tiptap-button-text", children: t }),
|
|
4132
|
-
a && /* @__PURE__ */ c(oo, { shortcutKeys:
|
|
4141
|
+
a && /* @__PURE__ */ c(oo, { shortcutKeys: X })
|
|
4133
4142
|
] })
|
|
4134
4143
|
}
|
|
4135
4144
|
) : null;
|
|
@@ -4228,8 +4237,8 @@ function ao(n, i, t = "mark") {
|
|
|
4228
4237
|
try {
|
|
4229
4238
|
const { state: e } = n, { selection: s } = e, o = s.$anchor;
|
|
4230
4239
|
for (let a = o.depth; a >= 0; a--) {
|
|
4231
|
-
const
|
|
4232
|
-
if (
|
|
4240
|
+
const l = o.node(a);
|
|
4241
|
+
if (l && l.attrs?.backgroundColor === i)
|
|
4233
4242
|
return !0;
|
|
4234
4243
|
}
|
|
4235
4244
|
return !1;
|
|
@@ -4258,62 +4267,62 @@ function Qe(n) {
|
|
|
4258
4267
|
hideWhenUnavailable: s = !1,
|
|
4259
4268
|
mode: o = "mark",
|
|
4260
4269
|
useColorValue: a = !1,
|
|
4261
|
-
onApplied:
|
|
4262
|
-
} = n, { editor:
|
|
4263
|
-
|
|
4264
|
-
if (!
|
|
4265
|
-
const
|
|
4266
|
-
|
|
4270
|
+
onApplied: l
|
|
4271
|
+
} = n, { editor: h } = yt(i), d = $e(), [m, f] = $(!0), g = Je(h, o), y = e && ro(e, a), x = ao(h, y, o);
|
|
4272
|
+
U(() => {
|
|
4273
|
+
if (!h) return;
|
|
4274
|
+
const w = () => {
|
|
4275
|
+
f(ho({ editor: h, hideWhenUnavailable: s, mode: o }));
|
|
4267
4276
|
};
|
|
4268
|
-
return
|
|
4269
|
-
|
|
4277
|
+
return w(), h.on("selectionUpdate", w), () => {
|
|
4278
|
+
h.off("selectionUpdate", w);
|
|
4270
4279
|
};
|
|
4271
|
-
}, [
|
|
4272
|
-
const v =
|
|
4273
|
-
if (!
|
|
4280
|
+
}, [h, s, o]);
|
|
4281
|
+
const v = Q(() => {
|
|
4282
|
+
if (!h || !g || !y || !t)
|
|
4274
4283
|
return !1;
|
|
4275
4284
|
if (o === "mark") {
|
|
4276
|
-
if (
|
|
4277
|
-
const
|
|
4278
|
-
|
|
4279
|
-
|
|
4285
|
+
if (h.state.storedMarks) {
|
|
4286
|
+
const w = h.schema.marks.highlight;
|
|
4287
|
+
w && h.view.dispatch(
|
|
4288
|
+
h.state.tr.removeStoredMark(w)
|
|
4280
4289
|
);
|
|
4281
4290
|
}
|
|
4282
4291
|
return setTimeout(() => {
|
|
4283
|
-
const
|
|
4284
|
-
return
|
|
4292
|
+
const w = h.chain().focus().toggleHighlight({ color: y }).run();
|
|
4293
|
+
return w && l?.({ color: y, label: t, mode: o }), w;
|
|
4285
4294
|
}, 0), !0;
|
|
4286
4295
|
} else {
|
|
4287
|
-
const
|
|
4288
|
-
return
|
|
4296
|
+
const w = h.chain().focus().toggleNodeBackgroundColor(y).run();
|
|
4297
|
+
return w && l?.({ color: y, label: t, mode: o }), w;
|
|
4289
4298
|
}
|
|
4290
|
-
}, [
|
|
4291
|
-
const
|
|
4292
|
-
return
|
|
4293
|
-
}, [
|
|
4299
|
+
}, [g, y, h, t, l, o]), I = Q(() => {
|
|
4300
|
+
const w = lo(h, o);
|
|
4301
|
+
return w && l?.({ color: "", label: "Remove highlight", mode: o }), w;
|
|
4302
|
+
}, [h, l, o]);
|
|
4294
4303
|
return Ti(
|
|
4295
4304
|
Oe,
|
|
4296
|
-
(
|
|
4297
|
-
|
|
4305
|
+
(w) => {
|
|
4306
|
+
w.preventDefault(), v();
|
|
4298
4307
|
},
|
|
4299
4308
|
{
|
|
4300
|
-
enabled:
|
|
4309
|
+
enabled: m && g,
|
|
4301
4310
|
enableOnContentEditable: !d,
|
|
4302
4311
|
enableOnFormTags: !0
|
|
4303
4312
|
}
|
|
4304
4313
|
), {
|
|
4305
|
-
isVisible:
|
|
4306
|
-
isActive:
|
|
4314
|
+
isVisible: m,
|
|
4315
|
+
isActive: x,
|
|
4307
4316
|
handleColorHighlight: v,
|
|
4308
|
-
handleRemoveHighlight:
|
|
4309
|
-
canColorHighlight:
|
|
4317
|
+
handleRemoveHighlight: I,
|
|
4318
|
+
canColorHighlight: g,
|
|
4310
4319
|
label: t || "Highlight",
|
|
4311
4320
|
shortcutKeys: Oe,
|
|
4312
4321
|
Icon: Ye,
|
|
4313
4322
|
mode: o
|
|
4314
4323
|
};
|
|
4315
4324
|
}
|
|
4316
|
-
const yn =
|
|
4325
|
+
const yn = A(({ className: n, children: i, ...t }, e) => /* @__PURE__ */ c(
|
|
4317
4326
|
vt,
|
|
4318
4327
|
{
|
|
4319
4328
|
type: "button",
|
|
@@ -4344,16 +4353,16 @@ function co({
|
|
|
4344
4353
|
const { handleRemoveHighlight: e } = Qe({ editor: n }), s = $e(), o = Ue(null), a = St(
|
|
4345
4354
|
() => [...i, { label: "Remove highlight", value: "none" }],
|
|
4346
4355
|
[i]
|
|
4347
|
-
), { selectedIndex:
|
|
4356
|
+
), { selectedIndex: l } = cn({
|
|
4348
4357
|
containerRef: o,
|
|
4349
4358
|
items: a,
|
|
4350
4359
|
orientation: "both",
|
|
4351
|
-
onSelect: (
|
|
4360
|
+
onSelect: (h) => {
|
|
4352
4361
|
if (!o.current) return !1;
|
|
4353
4362
|
const d = o.current.querySelector(
|
|
4354
4363
|
'[data-highlighted="true"]'
|
|
4355
4364
|
);
|
|
4356
|
-
return d && d.click(),
|
|
4365
|
+
return d && d.click(), h.value === "none" && e(), !0;
|
|
4357
4366
|
},
|
|
4358
4367
|
autoSelectFirstItem: !1
|
|
4359
4368
|
});
|
|
@@ -4364,18 +4373,18 @@ function co({
|
|
|
4364
4373
|
tabIndex: 0,
|
|
4365
4374
|
style: s ? { boxShadow: "none", border: 0 } : {},
|
|
4366
4375
|
children: /* @__PURE__ */ c(qe, { style: s ? { padding: 0 } : {}, children: /* @__PURE__ */ k(je, { orientation: "horizontal", children: [
|
|
4367
|
-
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: i.map((
|
|
4376
|
+
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: i.map((h, d) => /* @__PURE__ */ c(
|
|
4368
4377
|
mn,
|
|
4369
4378
|
{
|
|
4370
4379
|
editor: n,
|
|
4371
|
-
highlightColor: t ?
|
|
4372
|
-
tooltip:
|
|
4373
|
-
"aria-label": `${
|
|
4374
|
-
tabIndex: d ===
|
|
4375
|
-
"data-highlighted":
|
|
4380
|
+
highlightColor: t ? h.colorValue : h.value,
|
|
4381
|
+
tooltip: h.label,
|
|
4382
|
+
"aria-label": `${h.label} highlight color`,
|
|
4383
|
+
tabIndex: d === l ? 0 : -1,
|
|
4384
|
+
"data-highlighted": l === d,
|
|
4376
4385
|
useColorValue: t
|
|
4377
4386
|
},
|
|
4378
|
-
|
|
4387
|
+
h.value
|
|
4379
4388
|
)) }),
|
|
4380
4389
|
/* @__PURE__ */ c(Ge, {}),
|
|
4381
4390
|
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: /* @__PURE__ */ c(
|
|
@@ -4384,11 +4393,11 @@ function co({
|
|
|
4384
4393
|
onClick: e,
|
|
4385
4394
|
"aria-label": "Remove highlight",
|
|
4386
4395
|
tooltip: "Remove highlight",
|
|
4387
|
-
tabIndex:
|
|
4396
|
+
tabIndex: l === i.length ? 0 : -1,
|
|
4388
4397
|
type: "button",
|
|
4389
4398
|
role: "menuitem",
|
|
4390
4399
|
variant: "ghost",
|
|
4391
|
-
"data-highlighted":
|
|
4400
|
+
"data-highlighted": l === i.length,
|
|
4392
4401
|
children: /* @__PURE__ */ c(Xe, { className: "tiptap-button-icon" })
|
|
4393
4402
|
}
|
|
4394
4403
|
) })
|
|
@@ -4410,21 +4419,21 @@ function go({
|
|
|
4410
4419
|
onApplied: s,
|
|
4411
4420
|
...o
|
|
4412
4421
|
}) {
|
|
4413
|
-
const { editor: a } = yt(n), [
|
|
4422
|
+
const { editor: a } = yt(n), [l, h] = $(!1), { isVisible: d, canColorHighlight: m, isActive: f, label: g, Icon: y } = Qe({
|
|
4414
4423
|
editor: a,
|
|
4415
4424
|
hideWhenUnavailable: t,
|
|
4416
4425
|
onApplied: s
|
|
4417
4426
|
});
|
|
4418
|
-
return d ? /* @__PURE__ */ k(dn, { open:
|
|
4427
|
+
return d ? /* @__PURE__ */ k(dn, { open: l, onOpenChange: h, children: [
|
|
4419
4428
|
/* @__PURE__ */ c(gn, { asChild: !0, children: /* @__PURE__ */ c(
|
|
4420
4429
|
yn,
|
|
4421
4430
|
{
|
|
4422
|
-
disabled: !
|
|
4423
|
-
"data-active-state":
|
|
4424
|
-
"data-disabled": !
|
|
4425
|
-
"aria-pressed":
|
|
4426
|
-
"aria-label":
|
|
4427
|
-
tooltip:
|
|
4431
|
+
disabled: !m,
|
|
4432
|
+
"data-active-state": f ? "on" : "off",
|
|
4433
|
+
"data-disabled": !m,
|
|
4434
|
+
"aria-pressed": f,
|
|
4435
|
+
"aria-label": g,
|
|
4436
|
+
tooltip: g,
|
|
4428
4437
|
...o,
|
|
4429
4438
|
children: /* @__PURE__ */ c(y, { className: "tiptap-button-icon" })
|
|
4430
4439
|
}
|
|
@@ -4439,7 +4448,7 @@ function go({
|
|
|
4439
4448
|
) })
|
|
4440
4449
|
] }) : null;
|
|
4441
4450
|
}
|
|
4442
|
-
const ti =
|
|
4451
|
+
const ti = dt(({ className: n, ...i }) => /* @__PURE__ */ k("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: `lucide lucide-palette-icon lucide-palette ${n}`, ...i, children: [
|
|
4443
4452
|
/* @__PURE__ */ c("path", { d: "M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z" }),
|
|
4444
4453
|
/* @__PURE__ */ c("circle", { cx: "13.5", cy: "6.5", r: ".5", fill: "currentColor" }),
|
|
4445
4454
|
/* @__PURE__ */ c("circle", { cx: "17.5", cy: "10.5", r: ".5", fill: "currentColor" }),
|
|
@@ -4452,7 +4461,7 @@ function uo({
|
|
|
4452
4461
|
}) {
|
|
4453
4462
|
return /* @__PURE__ */ c(Re, { children: ke({ shortcutKeys: n }) });
|
|
4454
4463
|
}
|
|
4455
|
-
const vn =
|
|
4464
|
+
const vn = A(
|
|
4456
4465
|
({
|
|
4457
4466
|
editor: n,
|
|
4458
4467
|
textColor: i,
|
|
@@ -4461,36 +4470,36 @@ const vn = $(
|
|
|
4461
4470
|
onApplied: s,
|
|
4462
4471
|
showShortcut: o = !1,
|
|
4463
4472
|
onClick: a,
|
|
4464
|
-
children:
|
|
4465
|
-
style:
|
|
4473
|
+
children: l,
|
|
4474
|
+
style: h,
|
|
4466
4475
|
useColorValue: d = !1,
|
|
4467
|
-
...
|
|
4468
|
-
},
|
|
4469
|
-
const { editor:
|
|
4476
|
+
...m
|
|
4477
|
+
}, f) => {
|
|
4478
|
+
const { editor: g } = yt(n), {
|
|
4470
4479
|
isVisible: y,
|
|
4471
|
-
canTextColor:
|
|
4480
|
+
canTextColor: x,
|
|
4472
4481
|
isActive: v,
|
|
4473
|
-
handleTextColor:
|
|
4474
|
-
label:
|
|
4475
|
-
shortcutKeys:
|
|
4482
|
+
handleTextColor: I,
|
|
4483
|
+
label: w,
|
|
4484
|
+
shortcutKeys: z
|
|
4476
4485
|
} = ii({
|
|
4477
|
-
editor:
|
|
4486
|
+
editor: g,
|
|
4478
4487
|
textColor: i,
|
|
4479
4488
|
useColorValue: d,
|
|
4480
4489
|
label: t || `Toggle text color (${i})`,
|
|
4481
4490
|
hideWhenUnavailable: e,
|
|
4482
4491
|
onApplied: s
|
|
4483
|
-
}),
|
|
4484
|
-
(
|
|
4485
|
-
a?.(
|
|
4492
|
+
}), X = Q(
|
|
4493
|
+
(F) => {
|
|
4494
|
+
a?.(F), !F.defaultPrevented && (I(), F.preventDefault(), F.stopPropagation());
|
|
4486
4495
|
},
|
|
4487
|
-
[
|
|
4488
|
-
),
|
|
4496
|
+
[I, a]
|
|
4497
|
+
), R = St(
|
|
4489
4498
|
() => ({
|
|
4490
|
-
...
|
|
4499
|
+
...h,
|
|
4491
4500
|
"--text-color": i
|
|
4492
4501
|
}),
|
|
4493
|
-
[i,
|
|
4502
|
+
[i, h]
|
|
4494
4503
|
);
|
|
4495
4504
|
return y ? /* @__PURE__ */ k(
|
|
4496
4505
|
vt,
|
|
@@ -4500,24 +4509,24 @@ const vn = $(
|
|
|
4500
4509
|
"data-active-state": v ? "on" : "off",
|
|
4501
4510
|
role: "button",
|
|
4502
4511
|
tabIndex: -1,
|
|
4503
|
-
disabled: !
|
|
4504
|
-
"data-disabled": !
|
|
4505
|
-
"aria-label":
|
|
4512
|
+
disabled: !x,
|
|
4513
|
+
"data-disabled": !x,
|
|
4514
|
+
"aria-label": w,
|
|
4506
4515
|
"aria-pressed": v,
|
|
4507
|
-
tooltip:
|
|
4508
|
-
onClick:
|
|
4509
|
-
ref:
|
|
4510
|
-
style:
|
|
4511
|
-
...
|
|
4516
|
+
tooltip: w,
|
|
4517
|
+
onClick: X,
|
|
4518
|
+
ref: f,
|
|
4519
|
+
style: R,
|
|
4520
|
+
...m,
|
|
4512
4521
|
children: [
|
|
4513
|
-
|
|
4522
|
+
l || /* @__PURE__ */ c(
|
|
4514
4523
|
"span",
|
|
4515
4524
|
{
|
|
4516
4525
|
className: "tiptap-button-text-color",
|
|
4517
4526
|
style: { "--highlight-color": i }
|
|
4518
4527
|
}
|
|
4519
4528
|
),
|
|
4520
|
-
o && /* @__PURE__ */ c(uo, { shortcutKeys:
|
|
4529
|
+
o && /* @__PURE__ */ c(uo, { shortcutKeys: z })
|
|
4521
4530
|
]
|
|
4522
4531
|
}
|
|
4523
4532
|
) : null;
|
|
@@ -4601,31 +4610,31 @@ function ii({
|
|
|
4601
4610
|
useColorValue: s = !1,
|
|
4602
4611
|
onApplied: o
|
|
4603
4612
|
} = {}) {
|
|
4604
|
-
const { editor: a } = yt(n),
|
|
4605
|
-
|
|
4613
|
+
const { editor: a } = yt(n), l = $e(), [h, d] = $(!0), [m, f] = $(!1), g = ei(a);
|
|
4614
|
+
U(() => {
|
|
4606
4615
|
if (!a) {
|
|
4607
4616
|
d(!1);
|
|
4608
4617
|
return;
|
|
4609
4618
|
}
|
|
4610
4619
|
const v = po({ editor: a, hideWhenUnavailable: e });
|
|
4611
4620
|
d(v);
|
|
4612
|
-
}, [a, e]),
|
|
4621
|
+
}, [a, e]), U(() => {
|
|
4613
4622
|
if (!a) {
|
|
4614
|
-
|
|
4623
|
+
f(!1);
|
|
4615
4624
|
return;
|
|
4616
4625
|
}
|
|
4617
4626
|
const v = () => {
|
|
4618
|
-
|
|
4627
|
+
f(Si(a, i));
|
|
4619
4628
|
};
|
|
4620
4629
|
return a.on("selectionUpdate", v), a.on("transaction", v), v(), () => {
|
|
4621
4630
|
a.off("selectionUpdate", v), a.off("transaction", v);
|
|
4622
4631
|
};
|
|
4623
4632
|
}, [a, i]);
|
|
4624
|
-
const y =
|
|
4625
|
-
if (!a || !
|
|
4633
|
+
const y = Q(() => {
|
|
4634
|
+
if (!a || !g) return;
|
|
4626
4635
|
const v = i ? mo(i, s) : "#000000";
|
|
4627
4636
|
Si(a, v) ? a.chain().focus().unsetColor().run() : (a.chain().focus().setColor(v).run(), o?.({ color: v, label: t }));
|
|
4628
|
-
}, [a, i, s, t,
|
|
4637
|
+
}, [a, i, s, t, g, o]), x = Q(() => {
|
|
4629
4638
|
fo(a);
|
|
4630
4639
|
}, [a]);
|
|
4631
4640
|
return Ti(
|
|
@@ -4634,22 +4643,22 @@ function ii({
|
|
|
4634
4643
|
v.preventDefault(), y();
|
|
4635
4644
|
},
|
|
4636
4645
|
{
|
|
4637
|
-
enabled: !
|
|
4646
|
+
enabled: !l && h && g,
|
|
4638
4647
|
enableOnFormTags: ["INPUT", "TEXTAREA", "SELECT"]
|
|
4639
4648
|
},
|
|
4640
|
-
[y,
|
|
4649
|
+
[y, l, h, g]
|
|
4641
4650
|
), {
|
|
4642
|
-
isVisible:
|
|
4643
|
-
canTextColor:
|
|
4644
|
-
isActive:
|
|
4651
|
+
isVisible: h,
|
|
4652
|
+
canTextColor: g,
|
|
4653
|
+
isActive: m,
|
|
4645
4654
|
handleTextColor: y,
|
|
4646
|
-
handleRemoveTextColor:
|
|
4655
|
+
handleRemoveTextColor: x,
|
|
4647
4656
|
label: t,
|
|
4648
4657
|
shortcutKeys: Ze,
|
|
4649
4658
|
Icon: ti
|
|
4650
4659
|
};
|
|
4651
4660
|
}
|
|
4652
|
-
const wn =
|
|
4661
|
+
const wn = A(({ className: n, children: i, ...t }, e) => /* @__PURE__ */ c(
|
|
4653
4662
|
vt,
|
|
4654
4663
|
{
|
|
4655
4664
|
type: "button",
|
|
@@ -4681,16 +4690,16 @@ function yo({
|
|
|
4681
4690
|
const { handleRemoveTextColor: e } = ii({ editor: n }), s = $e(), o = Ue(null), a = St(
|
|
4682
4691
|
() => [...i, { label: "Remove color", value: "none" }],
|
|
4683
4692
|
[i]
|
|
4684
|
-
), { selectedIndex:
|
|
4693
|
+
), { selectedIndex: l } = cn({
|
|
4685
4694
|
containerRef: o,
|
|
4686
4695
|
items: a,
|
|
4687
4696
|
orientation: "both",
|
|
4688
|
-
onSelect: (
|
|
4697
|
+
onSelect: (h) => {
|
|
4689
4698
|
if (!o.current) return !1;
|
|
4690
4699
|
const d = o.current.querySelector(
|
|
4691
4700
|
'[data-highlighted="true"]'
|
|
4692
4701
|
);
|
|
4693
|
-
return d && d.click(),
|
|
4702
|
+
return d && d.click(), h.value === "none" && e(), !0;
|
|
4694
4703
|
},
|
|
4695
4704
|
autoSelectFirstItem: !1
|
|
4696
4705
|
});
|
|
@@ -4701,18 +4710,18 @@ function yo({
|
|
|
4701
4710
|
tabIndex: 0,
|
|
4702
4711
|
style: s ? { boxShadow: "none", border: 0 } : {},
|
|
4703
4712
|
children: /* @__PURE__ */ c(qe, { style: s ? { padding: 0 } : {}, children: /* @__PURE__ */ k(je, { orientation: "horizontal", children: [
|
|
4704
|
-
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: i.map((
|
|
4713
|
+
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: i.map((h, d) => /* @__PURE__ */ c(
|
|
4705
4714
|
vn,
|
|
4706
4715
|
{
|
|
4707
4716
|
editor: n,
|
|
4708
|
-
textColor: t ?
|
|
4709
|
-
tooltip:
|
|
4710
|
-
"aria-label": `${
|
|
4711
|
-
tabIndex: d ===
|
|
4712
|
-
"data-highlighted":
|
|
4717
|
+
textColor: t ? h.colorValue : h.value,
|
|
4718
|
+
tooltip: h.label,
|
|
4719
|
+
"aria-label": `${h.label} text color`,
|
|
4720
|
+
tabIndex: d === l ? 0 : -1,
|
|
4721
|
+
"data-highlighted": l === d,
|
|
4713
4722
|
useColorValue: t
|
|
4714
4723
|
},
|
|
4715
|
-
|
|
4724
|
+
h.value
|
|
4716
4725
|
)) }),
|
|
4717
4726
|
/* @__PURE__ */ c(Ge, {}),
|
|
4718
4727
|
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: /* @__PURE__ */ c(
|
|
@@ -4721,11 +4730,11 @@ function yo({
|
|
|
4721
4730
|
onClick: e,
|
|
4722
4731
|
"aria-label": "Remove text color",
|
|
4723
4732
|
tooltip: "Remove text color",
|
|
4724
|
-
tabIndex:
|
|
4733
|
+
tabIndex: l === i.length ? 0 : -1,
|
|
4725
4734
|
type: "button",
|
|
4726
4735
|
role: "menuitem",
|
|
4727
4736
|
variant: "ghost",
|
|
4728
|
-
"data-highlighted":
|
|
4737
|
+
"data-highlighted": l === i.length,
|
|
4729
4738
|
children: /* @__PURE__ */ c(Xe, { className: "tiptap-button-icon" })
|
|
4730
4739
|
}
|
|
4731
4740
|
) })
|
|
@@ -4747,21 +4756,21 @@ function vo({
|
|
|
4747
4756
|
onApplied: s,
|
|
4748
4757
|
...o
|
|
4749
4758
|
}) {
|
|
4750
|
-
const { editor: a } = yt(n), [
|
|
4759
|
+
const { editor: a } = yt(n), [l, h] = $(!1), { isVisible: d, canTextColor: m, isActive: f, label: g, Icon: y } = ii({
|
|
4751
4760
|
editor: a,
|
|
4752
4761
|
hideWhenUnavailable: t,
|
|
4753
4762
|
onApplied: s
|
|
4754
4763
|
});
|
|
4755
|
-
return d ? /* @__PURE__ */ k(dn, { open:
|
|
4764
|
+
return d ? /* @__PURE__ */ k(dn, { open: l, onOpenChange: h, children: [
|
|
4756
4765
|
/* @__PURE__ */ c(gn, { asChild: !0, children: /* @__PURE__ */ c(
|
|
4757
4766
|
wn,
|
|
4758
4767
|
{
|
|
4759
|
-
disabled: !
|
|
4760
|
-
"data-active-state":
|
|
4761
|
-
"data-disabled": !
|
|
4762
|
-
"aria-pressed":
|
|
4763
|
-
"aria-label":
|
|
4764
|
-
tooltip:
|
|
4768
|
+
disabled: !m,
|
|
4769
|
+
"data-active-state": f ? "on" : "off",
|
|
4770
|
+
"data-disabled": !m,
|
|
4771
|
+
"aria-pressed": f,
|
|
4772
|
+
"aria-label": g,
|
|
4773
|
+
tooltip: g,
|
|
4765
4774
|
...o,
|
|
4766
4775
|
children: /* @__PURE__ */ c(y, { className: "tiptap-button-icon" })
|
|
4767
4776
|
}
|
|
@@ -4790,43 +4799,43 @@ function xo({
|
|
|
4790
4799
|
editor: n,
|
|
4791
4800
|
fonts: i = Co
|
|
4792
4801
|
}) {
|
|
4793
|
-
const [t, e] =
|
|
4802
|
+
const [t, e] = $(
|
|
4794
4803
|
void 0
|
|
4795
|
-
), s =
|
|
4796
|
-
(
|
|
4804
|
+
), s = Q(() => n ? n.can().setFontFamily("") : !1, [n]), o = Q(
|
|
4805
|
+
(h) => n ? h ? n.isActive("textStyle", { fontFamily: h }) : !n.isActive("textStyle", { fontFamily: /.+/ }) : !1,
|
|
4797
4806
|
[n]
|
|
4798
4807
|
);
|
|
4799
|
-
|
|
4808
|
+
U(() => {
|
|
4800
4809
|
if (!n) {
|
|
4801
4810
|
e(void 0);
|
|
4802
4811
|
return;
|
|
4803
4812
|
}
|
|
4804
|
-
const
|
|
4813
|
+
const h = () => {
|
|
4805
4814
|
const d = n.getAttributes("textStyle");
|
|
4806
4815
|
e(d.fontFamily);
|
|
4807
4816
|
};
|
|
4808
|
-
return n.on("selectionUpdate",
|
|
4809
|
-
n.off("selectionUpdate",
|
|
4817
|
+
return n.on("selectionUpdate", h), n.on("transaction", h), h(), () => {
|
|
4818
|
+
n.off("selectionUpdate", h), n.off("transaction", h);
|
|
4810
4819
|
};
|
|
4811
4820
|
}, [n]);
|
|
4812
|
-
const a =
|
|
4813
|
-
(
|
|
4814
|
-
n && (
|
|
4821
|
+
const a = Q(
|
|
4822
|
+
(h) => {
|
|
4823
|
+
n && (h ? n.chain().focus().setFontFamily(h).run() : n.chain().focus().unsetFontFamily().run());
|
|
4815
4824
|
},
|
|
4816
4825
|
[n]
|
|
4817
|
-
),
|
|
4826
|
+
), l = Q(() => {
|
|
4818
4827
|
n && n.chain().focus().unsetFontFamily().run();
|
|
4819
4828
|
}, [n]);
|
|
4820
4829
|
return {
|
|
4821
4830
|
fonts: i,
|
|
4822
4831
|
activeFontFamily: t,
|
|
4823
4832
|
setFontFamily: a,
|
|
4824
|
-
unsetFontFamily:
|
|
4833
|
+
unsetFontFamily: l,
|
|
4825
4834
|
canSetFontFamily: s,
|
|
4826
4835
|
isFontFamilyActive: o
|
|
4827
4836
|
};
|
|
4828
4837
|
}
|
|
4829
|
-
const bn =
|
|
4838
|
+
const bn = A(({ editor: n, fonts: i }, t) => {
|
|
4830
4839
|
const {
|
|
4831
4840
|
fonts: e,
|
|
4832
4841
|
activeFontFamily: s,
|
|
@@ -4842,33 +4851,33 @@ const bn = $(({ editor: n, fonts: i }, t) => {
|
|
|
4842
4851
|
ref: t,
|
|
4843
4852
|
className: "font-family-select",
|
|
4844
4853
|
value: s || "",
|
|
4845
|
-
onChange: (
|
|
4846
|
-
children: e.map((
|
|
4854
|
+
onChange: (l) => o(l.target.value),
|
|
4855
|
+
children: e.map((l) => /* @__PURE__ */ c(
|
|
4847
4856
|
"option",
|
|
4848
4857
|
{
|
|
4849
|
-
value:
|
|
4850
|
-
style: { fontFamily:
|
|
4851
|
-
children:
|
|
4858
|
+
value: l.value,
|
|
4859
|
+
style: { fontFamily: l.value || void 0 },
|
|
4860
|
+
children: l.label
|
|
4852
4861
|
},
|
|
4853
|
-
|
|
4862
|
+
l.label
|
|
4854
4863
|
))
|
|
4855
4864
|
}
|
|
4856
4865
|
);
|
|
4857
4866
|
});
|
|
4858
4867
|
bn.displayName = "FontFamilySelect";
|
|
4859
4868
|
function Go({ api: n }) {
|
|
4860
|
-
const [i, t] =
|
|
4861
|
-
return
|
|
4869
|
+
const [i, t] = $(null), [e, s] = $(1), [o, a] = $(1);
|
|
4870
|
+
return U(() => {
|
|
4862
4871
|
if (!n) return;
|
|
4863
|
-
const
|
|
4864
|
-
t(
|
|
4865
|
-
},
|
|
4872
|
+
const l = (m) => {
|
|
4873
|
+
t(m), s(n.getState().viewport.scale), a(m.scaleWhenCreate || 1);
|
|
4874
|
+
}, h = () => {
|
|
4866
4875
|
t(null);
|
|
4867
|
-
}, d = (
|
|
4868
|
-
s(
|
|
4876
|
+
}, d = (m) => {
|
|
4877
|
+
s(m);
|
|
4869
4878
|
};
|
|
4870
|
-
return n.on("texteditor:register",
|
|
4871
|
-
n.off("texteditor:register",
|
|
4879
|
+
return n.on("texteditor:register", l), n.on("texteditor:unregister", h), n.on("viewport:scale:change", d), () => {
|
|
4880
|
+
n.off("texteditor:register", l), n.off("texteditor:unregister", h), n.off("viewport:scale:change", d);
|
|
4872
4881
|
};
|
|
4873
4882
|
}, [n]), !n || !i ? null : /* @__PURE__ */ c(Ie, { children: i && /* @__PURE__ */ k(Jn, { className: "rich-text-bubble-menu bubble-menu", editor: i, appendTo: () => document.getElementById("rich-text-html-element"), style: {
|
|
4874
4883
|
transformOrigin: "bottom center",
|