@8btc/whiteboard 0.0.20-alpha.31 → 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 +689 -689
- 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
|
|
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
10
|
import M from "konva";
|
|
11
|
-
import { N as b, R as N, I as
|
|
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,7 +235,7 @@ 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() {
|
|
@@ -244,46 +244,46 @@ _i = function() {
|
|
|
244
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,
|
|
@@ -385,85 +385,85 @@ Mi = function() {
|
|
|
385
385
|
}
|
|
386
386
|
});
|
|
387
387
|
};
|
|
388
|
-
var
|
|
388
|
+
var P, O, G, Z;
|
|
389
389
|
class ps {
|
|
390
390
|
// todo: 优化 selectedNodeIds 的存储和查询性能
|
|
391
391
|
// private _selectedNodeIds: Set<string> = new Set();
|
|
392
392
|
constructor(i) {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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());
|
|
398
398
|
}
|
|
399
399
|
/**
|
|
400
400
|
* 获取当前状态
|
|
401
401
|
*/
|
|
402
402
|
getState() {
|
|
403
|
-
return { ...r(this,
|
|
403
|
+
return { ...r(this, O) };
|
|
404
404
|
}
|
|
405
405
|
/**
|
|
406
406
|
* 获取完整历史状态
|
|
407
407
|
*/
|
|
408
408
|
getHistory() {
|
|
409
409
|
return {
|
|
410
|
-
past: [...r(this,
|
|
411
|
-
present: { ...r(this,
|
|
412
|
-
future: [...r(this,
|
|
410
|
+
past: [...r(this, P)],
|
|
411
|
+
present: { ...r(this, O) },
|
|
412
|
+
future: [...r(this, G)]
|
|
413
413
|
};
|
|
414
414
|
}
|
|
415
415
|
/**
|
|
416
416
|
* 是否可以撤销
|
|
417
417
|
*/
|
|
418
418
|
canUndo() {
|
|
419
|
-
return r(this,
|
|
419
|
+
return r(this, P).length > 0;
|
|
420
420
|
}
|
|
421
421
|
/**
|
|
422
422
|
* 是否可以重做
|
|
423
423
|
*/
|
|
424
424
|
canRedo() {
|
|
425
|
-
return r(this,
|
|
425
|
+
return r(this, G).length > 0;
|
|
426
426
|
}
|
|
427
427
|
/**
|
|
428
428
|
* 订阅状态事件
|
|
429
429
|
*/
|
|
430
430
|
on(i, t) {
|
|
431
|
-
r(this,
|
|
431
|
+
r(this, Z).on(i, t);
|
|
432
432
|
}
|
|
433
433
|
/**
|
|
434
434
|
* 取消订阅状态事件
|
|
435
435
|
*/
|
|
436
436
|
off(i, t) {
|
|
437
|
-
r(this,
|
|
437
|
+
r(this, Z).off(i, t);
|
|
438
438
|
}
|
|
439
439
|
/**
|
|
440
440
|
* @internal
|
|
441
441
|
* 发送事件
|
|
442
442
|
*/
|
|
443
443
|
_emit(i, t) {
|
|
444
|
-
r(this,
|
|
444
|
+
r(this, Z).emit(i, t);
|
|
445
445
|
}
|
|
446
446
|
/**
|
|
447
447
|
* 撤销操作
|
|
448
448
|
*/
|
|
449
449
|
undo() {
|
|
450
|
-
if (r(this,
|
|
451
|
-
const i = r(this,
|
|
452
|
-
|
|
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);
|
|
453
453
|
}
|
|
454
454
|
/**
|
|
455
455
|
* 重做操作
|
|
456
456
|
*/
|
|
457
457
|
redo() {
|
|
458
|
-
if (r(this,
|
|
459
|
-
const i = r(this,
|
|
460
|
-
|
|
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);
|
|
461
461
|
}
|
|
462
462
|
/**
|
|
463
463
|
* 重置历史记录
|
|
464
464
|
*/
|
|
465
465
|
resetHistory() {
|
|
466
|
-
|
|
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));
|
|
467
467
|
}
|
|
468
468
|
/**
|
|
469
469
|
* 更新状态
|
|
@@ -471,17 +471,17 @@ class ps {
|
|
|
471
471
|
* @param addToHistory - 是否添加到历史记录
|
|
472
472
|
*/
|
|
473
473
|
_updateState(i, t) {
|
|
474
|
-
const e = { ...r(this,
|
|
475
|
-
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);
|
|
476
476
|
}
|
|
477
477
|
/**
|
|
478
478
|
* 清理资源
|
|
479
479
|
*/
|
|
480
480
|
_dispose() {
|
|
481
|
-
r(this,
|
|
481
|
+
r(this, Z).all.clear();
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
|
-
|
|
484
|
+
P = new WeakMap(), O = new WeakMap(), G = new WeakMap(), Z = new WeakMap();
|
|
485
485
|
class st {
|
|
486
486
|
}
|
|
487
487
|
const ys = {
|
|
@@ -583,9 +583,9 @@ function ki(n, i) {
|
|
|
583
583
|
{ x: 0, y: 0.25 }
|
|
584
584
|
// 左上
|
|
585
585
|
]
|
|
586
|
-
}[i].map((
|
|
587
|
-
x: Number((t +
|
|
588
|
-
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
|
|
589
589
|
}));
|
|
590
590
|
}
|
|
591
591
|
function hi(n, i) {
|
|
@@ -609,7 +609,7 @@ function hi(n, i) {
|
|
|
609
609
|
};
|
|
610
610
|
}
|
|
611
611
|
function ci(n, i) {
|
|
612
|
-
const t = n.width ??
|
|
612
|
+
const t = n.width ?? tt.MIN_SIZE, e = n.height ?? tt.MIN_SIZE, s = ot(n, i);
|
|
613
613
|
if (!n.image) {
|
|
614
614
|
const a = document.createElement("canvas");
|
|
615
615
|
a.width = t, a.height = e, n.image = a;
|
|
@@ -622,7 +622,7 @@ function ci(n, i) {
|
|
|
622
622
|
};
|
|
623
623
|
}
|
|
624
624
|
function di(n, i) {
|
|
625
|
-
const t = n.width ??
|
|
625
|
+
const t = n.width ?? tt.MIN_SIZE, e = n.height ?? tt.MIN_SIZE, s = ot(n, i);
|
|
626
626
|
if (!n.$_coverUrl) {
|
|
627
627
|
const a = document.createElement("canvas");
|
|
628
628
|
a.width = t, a.height = e, n.image = a;
|
|
@@ -734,7 +734,7 @@ function vi(n, i) {
|
|
|
734
734
|
strokeWidth: 2,
|
|
735
735
|
...n,
|
|
736
736
|
...s,
|
|
737
|
-
points: o.flatMap((
|
|
737
|
+
points: o.flatMap((l) => [l.x, l.y]),
|
|
738
738
|
closed: !0,
|
|
739
739
|
name: `${b.nodeRoot} ${b.selectable} ${b.polygon}`,
|
|
740
740
|
draggable: !0,
|
|
@@ -777,12 +777,12 @@ var Dt, Ce, $i;
|
|
|
777
777
|
class ws extends st {
|
|
778
778
|
constructor(t, e, s = !1) {
|
|
779
779
|
super();
|
|
780
|
-
|
|
780
|
+
u(this, Ce);
|
|
781
781
|
p(this, "core");
|
|
782
782
|
p(this, "config");
|
|
783
783
|
p(this, "element");
|
|
784
784
|
p(this, "isDraft");
|
|
785
|
-
|
|
785
|
+
u(this, Dt, ({ type: t }) => {
|
|
786
786
|
const e = t === "select";
|
|
787
787
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
788
788
|
});
|
|
@@ -840,20 +840,20 @@ $i = function() {
|
|
|
840
840
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
841
841
|
});
|
|
842
842
|
};
|
|
843
|
-
var
|
|
843
|
+
var ct, He, Pt, Bt, Ai, Le;
|
|
844
844
|
class bs extends st {
|
|
845
845
|
constructor(t, e, s = !1) {
|
|
846
846
|
super();
|
|
847
|
-
|
|
847
|
+
u(this, ct);
|
|
848
848
|
p(this, "core");
|
|
849
849
|
p(this, "config");
|
|
850
850
|
p(this, "element");
|
|
851
851
|
p(this, "isDraft");
|
|
852
|
-
|
|
852
|
+
u(this, Pt, ({ type: t }) => {
|
|
853
853
|
const e = t === "select";
|
|
854
854
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
855
855
|
});
|
|
856
|
-
|
|
856
|
+
u(this, Bt, () => {
|
|
857
857
|
const t = this.getElement().getLayer();
|
|
858
858
|
if (!t) return;
|
|
859
859
|
const e = t.find(
|
|
@@ -867,7 +867,7 @@ class bs extends st {
|
|
|
867
867
|
!0
|
|
868
868
|
);
|
|
869
869
|
});
|
|
870
|
-
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());
|
|
871
871
|
}
|
|
872
872
|
getID() {
|
|
873
873
|
return this.config.id;
|
|
@@ -898,7 +898,7 @@ class bs extends st {
|
|
|
898
898
|
...t
|
|
899
899
|
},
|
|
900
900
|
this.core.getTheme()
|
|
901
|
-
), 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);
|
|
902
902
|
}
|
|
903
903
|
/**
|
|
904
904
|
* 销毁
|
|
@@ -913,7 +913,7 @@ class bs extends st {
|
|
|
913
913
|
};
|
|
914
914
|
}
|
|
915
915
|
}
|
|
916
|
-
|
|
916
|
+
ct = new WeakSet(), /**
|
|
917
917
|
* 加载图片
|
|
918
918
|
*/
|
|
919
919
|
He = function() {
|
|
@@ -926,7 +926,7 @@ He = function() {
|
|
|
926
926
|
e.crossOrigin = "anonymous", e.src = t, e.onload = () => {
|
|
927
927
|
this.getElement().image(e);
|
|
928
928
|
const s = this.config.width ?? e.width, o = this.config.height ?? e.height;
|
|
929
|
-
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));
|
|
930
930
|
}, e.onerror = () => {
|
|
931
931
|
console.error("Failed to load image:", t);
|
|
932
932
|
};
|
|
@@ -935,12 +935,12 @@ He = function() {
|
|
|
935
935
|
*/
|
|
936
936
|
Ai = function(t) {
|
|
937
937
|
this.core.on("toolType:change", r(this, Pt)), t.on("transform", (e) => {
|
|
938
|
-
const s = e.target, o = Math.max(
|
|
939
|
-
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);
|
|
940
940
|
}), t.on("transformend", () => {
|
|
941
941
|
this.syncConfigFromElement(), r(this, Bt).call(this);
|
|
942
942
|
}), t.on("dragmove", () => {
|
|
943
|
-
E(this,
|
|
943
|
+
E(this, ct, Le).call(this);
|
|
944
944
|
}), t.on("dragend", () => {
|
|
945
945
|
this.syncConfigFromElement(), r(this, Bt).call(this);
|
|
946
946
|
});
|
|
@@ -950,46 +950,46 @@ Ai = function(t) {
|
|
|
950
950
|
Le = function() {
|
|
951
951
|
const t = this.getElement(), e = t.getLayer();
|
|
952
952
|
if (!e) return;
|
|
953
|
-
const s = t.x(), o = t.y(), a = t.width(),
|
|
954
|
-
(
|
|
953
|
+
const s = t.x(), o = t.y(), a = t.width(), l = t.height(), h = e.find(
|
|
954
|
+
(m) => m.hasName(this.config.id)
|
|
955
955
|
), d = this.core.getState().nodes || [];
|
|
956
|
-
|
|
957
|
-
const
|
|
958
|
-
if (
|
|
959
|
-
const { start:
|
|
960
|
-
|
|
961
|
-
x:
|
|
962
|
-
y:
|
|
963
|
-
width:
|
|
964
|
-
height:
|
|
965
|
-
}),
|
|
966
|
-
|
|
967
|
-
}), 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();
|
|
968
968
|
}
|
|
969
969
|
});
|
|
970
970
|
};
|
|
971
|
-
var
|
|
971
|
+
var at, K, mt, lt, _t, Mt, $t, Fi, Hi;
|
|
972
972
|
class Es extends st {
|
|
973
973
|
constructor(t, e, s = !1) {
|
|
974
974
|
super();
|
|
975
|
-
|
|
975
|
+
u(this, $t);
|
|
976
976
|
p(this, "core");
|
|
977
977
|
p(this, "config");
|
|
978
978
|
p(this, "element");
|
|
979
979
|
p(this, "isDraft");
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
980
|
+
u(this, at);
|
|
981
|
+
u(this, K);
|
|
982
|
+
u(this, mt);
|
|
983
|
+
u(this, lt);
|
|
984
|
+
u(this, _t);
|
|
985
|
+
u(this, Mt);
|
|
986
986
|
this.core = t, this.config = gi(e, this.core.getTheme()), this.isDraft = s, this.element = this.createElement(), rt(this.element, this);
|
|
987
987
|
const o = this.getElement();
|
|
988
|
-
|
|
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, () => {
|
|
989
989
|
E(this, $t, Fi).call(this);
|
|
990
|
-
}), this.core.on("viewport:scale:change", r(this, _t)),
|
|
991
|
-
const
|
|
992
|
-
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);
|
|
993
993
|
}), this.core.on("nodes:selected", r(this, Mt));
|
|
994
994
|
}
|
|
995
995
|
getID() {
|
|
@@ -1006,7 +1006,7 @@ class Es extends st {
|
|
|
1006
1006
|
y: this.config.y,
|
|
1007
1007
|
width: t,
|
|
1008
1008
|
height: e
|
|
1009
|
-
}), o = this.core.getStageScale(), a = 2 / o,
|
|
1009
|
+
}), o = this.core.getStageScale(), a = 2 / o, l = N.CORNER_RADIUS / o, h = new M.Rect({
|
|
1010
1010
|
name: "rect",
|
|
1011
1011
|
x: 0,
|
|
1012
1012
|
y: 0,
|
|
@@ -1014,20 +1014,20 @@ class Es extends st {
|
|
|
1014
1014
|
height: e,
|
|
1015
1015
|
stroke: this.config.markerColor,
|
|
1016
1016
|
strokeWidth: a,
|
|
1017
|
-
dash:
|
|
1017
|
+
// dash: rectDash,
|
|
1018
1018
|
cornerRadius: l,
|
|
1019
1019
|
listening: !1
|
|
1020
|
-
}),
|
|
1020
|
+
}), d = new M.Group({
|
|
1021
1021
|
name: "marker-group",
|
|
1022
1022
|
x: t,
|
|
1023
1023
|
y: e,
|
|
1024
1024
|
visible: !this.isDraft
|
|
1025
|
-
}), m = 14 / o,
|
|
1025
|
+
}), m = 14 / o, f = 3 / o, g = 16 / o, y = new M.Circle({
|
|
1026
1026
|
radius: m,
|
|
1027
1027
|
fill: this.config.markerColor,
|
|
1028
1028
|
stroke: "white",
|
|
1029
|
-
strokeWidth:
|
|
1030
|
-
}),
|
|
1029
|
+
strokeWidth: f
|
|
1030
|
+
}), x = new M.Text({
|
|
1031
1031
|
x: -m,
|
|
1032
1032
|
y: -m,
|
|
1033
1033
|
width: m * 2,
|
|
@@ -1035,10 +1035,10 @@ class Es extends st {
|
|
|
1035
1035
|
text: String(this.config.$_markerNumber || ""),
|
|
1036
1036
|
align: "center",
|
|
1037
1037
|
verticalAlign: "middle",
|
|
1038
|
-
fontSize:
|
|
1038
|
+
fontSize: g,
|
|
1039
1039
|
fill: "white"
|
|
1040
1040
|
});
|
|
1041
|
-
return
|
|
1041
|
+
return d.add(y), d.add(x), s.add(h), s.add(d), s;
|
|
1042
1042
|
}
|
|
1043
1043
|
/**
|
|
1044
1044
|
* 获取 Konva.Group 实例
|
|
@@ -1060,7 +1060,7 @@ class Es extends st {
|
|
|
1060
1060
|
const e = this.getElement();
|
|
1061
1061
|
e.x(this.config.x), e.y(this.config.y);
|
|
1062
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);
|
|
1063
|
-
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));
|
|
1064
1064
|
}
|
|
1065
1065
|
/**
|
|
1066
1066
|
* 销毁
|
|
@@ -1073,7 +1073,7 @@ class Es extends st {
|
|
|
1073
1073
|
*/
|
|
1074
1074
|
setFocusState(t) {
|
|
1075
1075
|
const e = this.core.getStageScale(), s = t ? 4 / e : 3 / e, o = t ? 1.2 : 1;
|
|
1076
|
-
r(this,
|
|
1076
|
+
r(this, at).strokeWidth(s), r(this, mt).strokeWidth(s), r(this, K).scaleX(o), r(this, K).scaleY(o);
|
|
1077
1077
|
}
|
|
1078
1078
|
syncConfigFromElement() {
|
|
1079
1079
|
const t = this.getElement();
|
|
@@ -1086,22 +1086,22 @@ class Es extends st {
|
|
|
1086
1086
|
};
|
|
1087
1087
|
}
|
|
1088
1088
|
}
|
|
1089
|
-
|
|
1089
|
+
at = new WeakMap(), K = new WeakMap(), mt = new WeakMap(), lt = new WeakMap(), _t = new WeakMap(), Mt = new WeakMap(), $t = new WeakSet(), /**
|
|
1090
1090
|
* 更新标记点的缩放以保持视觉大小不变
|
|
1091
1091
|
*/
|
|
1092
1092
|
Fi = function() {
|
|
1093
|
-
const t = this.core.getStageScale(), e = 14 / t, s = 3 / t, o = 16 / t, a = 3 / t,
|
|
1094
|
-
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);
|
|
1095
1095
|
}, /**
|
|
1096
1096
|
* 设置事件处理器
|
|
1097
1097
|
*/
|
|
1098
1098
|
Hi = function() {
|
|
1099
|
-
r(this,
|
|
1099
|
+
r(this, K).on("pointerover", () => {
|
|
1100
1100
|
this.setFocusState(!0), this.core._setCursor("pointer");
|
|
1101
|
-
}), r(this,
|
|
1101
|
+
}), r(this, K).on("pointerout", () => {
|
|
1102
1102
|
const e = (this.core.getState().selectedNodeIds || []).includes(this.config.id);
|
|
1103
1103
|
this.setFocusState(e), this.core._resetCursor();
|
|
1104
|
-
}), r(this,
|
|
1104
|
+
}), r(this, K).on("pointerdown", () => {
|
|
1105
1105
|
this.core._selectNodes([this.config.id]);
|
|
1106
1106
|
});
|
|
1107
1107
|
};
|
|
@@ -1109,17 +1109,17 @@ var gt, Vt, xe, Li;
|
|
|
1109
1109
|
class Ss extends st {
|
|
1110
1110
|
constructor(t, e, s = !1) {
|
|
1111
1111
|
super();
|
|
1112
|
-
|
|
1112
|
+
u(this, xe);
|
|
1113
1113
|
p(this, "core");
|
|
1114
1114
|
p(this, "config");
|
|
1115
1115
|
p(this, "element");
|
|
1116
1116
|
p(this, "isDraft");
|
|
1117
1117
|
p(this, "htmlElement");
|
|
1118
|
-
|
|
1118
|
+
u(this, gt, () => {
|
|
1119
1119
|
const t = this.element.getClientRect();
|
|
1120
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`;
|
|
1121
1121
|
});
|
|
1122
|
-
|
|
1122
|
+
u(this, Vt, ({ type: t }) => {
|
|
1123
1123
|
const e = t === "select";
|
|
1124
1124
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1125
1125
|
});
|
|
@@ -1185,47 +1185,47 @@ var Ot, we, be, Di;
|
|
|
1185
1185
|
class Ns extends st {
|
|
1186
1186
|
constructor(t, e, s = !1) {
|
|
1187
1187
|
super();
|
|
1188
|
-
|
|
1188
|
+
u(this, be);
|
|
1189
1189
|
p(this, "core");
|
|
1190
1190
|
p(this, "config");
|
|
1191
1191
|
p(this, "element");
|
|
1192
1192
|
p(this, "isDraft");
|
|
1193
1193
|
p(this, "rect");
|
|
1194
|
-
|
|
1194
|
+
u(this, Ot, ({ type: t }) => {
|
|
1195
1195
|
const e = t === "select";
|
|
1196
1196
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1197
1197
|
});
|
|
1198
1198
|
/**
|
|
1199
1199
|
* 编辑文字
|
|
1200
1200
|
*/
|
|
1201
|
-
|
|
1201
|
+
u(this, we, () => {
|
|
1202
1202
|
const t = this.element, e = this.core.getCanvasTransformer(), s = t.getClientRect(), o = document.createElement("textarea");
|
|
1203
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();
|
|
1204
1204
|
const a = t.rotation();
|
|
1205
|
-
let
|
|
1206
|
-
a && (
|
|
1207
|
-
const
|
|
1208
|
-
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();
|
|
1209
1209
|
};
|
|
1210
|
-
o.addEventListener("keydown", function(
|
|
1211
|
-
if (
|
|
1212
|
-
const
|
|
1213
|
-
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();
|
|
1214
1214
|
}
|
|
1215
1215
|
}), o.addEventListener("keydown", function() {
|
|
1216
1216
|
o.style.height = "auto", o.style.height = o.scrollHeight + t.fontSize() * t.lineHeight() + "px";
|
|
1217
1217
|
});
|
|
1218
|
-
const d = (
|
|
1219
|
-
|
|
1220
|
-
},
|
|
1221
|
-
const
|
|
1222
|
-
o.style.top =
|
|
1223
|
-
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();
|
|
1224
1224
|
let y = "";
|
|
1225
|
-
|
|
1225
|
+
g && (y += "rotateZ(" + g + "deg)"), o.style.transform = y + `scale(${t.getAbsoluteScale().x})`;
|
|
1226
1226
|
};
|
|
1227
1227
|
setTimeout(() => {
|
|
1228
|
-
this.core.on("viewport:change",
|
|
1228
|
+
this.core.on("viewport:change", m), window.addEventListener("click", d), window.addEventListener("touchstart", d);
|
|
1229
1229
|
});
|
|
1230
1230
|
});
|
|
1231
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(() => {
|
|
@@ -1288,7 +1288,7 @@ var It, ft, Ee, Zt, Ut, zt, Wt, Se, Pi;
|
|
|
1288
1288
|
class Ts extends st {
|
|
1289
1289
|
constructor(t, e, s = !1) {
|
|
1290
1290
|
super();
|
|
1291
|
-
|
|
1291
|
+
u(this, Se);
|
|
1292
1292
|
p(this, "core");
|
|
1293
1293
|
p(this, "config");
|
|
1294
1294
|
p(this, "element");
|
|
@@ -1317,7 +1317,7 @@ class Ts extends st {
|
|
|
1317
1317
|
window.addEventListener("click", r(this, Wt));
|
|
1318
1318
|
}), window.addEventListener("keydown", r(this, zt));
|
|
1319
1319
|
});
|
|
1320
|
-
|
|
1320
|
+
u(this, It, async () => {
|
|
1321
1321
|
const t = this.htmlEditorElement.getBoundingClientRect();
|
|
1322
1322
|
if (t.width === 0 || t.height === 0)
|
|
1323
1323
|
return;
|
|
@@ -1348,11 +1348,11 @@ class Ts extends st {
|
|
|
1348
1348
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !1);
|
|
1349
1349
|
}));
|
|
1350
1350
|
});
|
|
1351
|
-
|
|
1351
|
+
u(this, ft, () => {
|
|
1352
1352
|
const t = this.element.getClientRect();
|
|
1353
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})`;
|
|
1354
1354
|
});
|
|
1355
|
-
|
|
1355
|
+
u(this, Ee, () => {
|
|
1356
1356
|
this.resizeObserver = new ResizeObserver((t) => {
|
|
1357
1357
|
for (const e of t) {
|
|
1358
1358
|
let s = !1;
|
|
@@ -1363,18 +1363,18 @@ class Ts extends st {
|
|
|
1363
1363
|
}
|
|
1364
1364
|
}), this.resizeObserver.observe(this.htmlEditorElement);
|
|
1365
1365
|
});
|
|
1366
|
-
|
|
1366
|
+
u(this, Zt, ({ type: t }) => {
|
|
1367
1367
|
const e = t === "select";
|
|
1368
1368
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1369
1369
|
});
|
|
1370
|
-
|
|
1370
|
+
u(this, Ut, (t) => {
|
|
1371
1371
|
const e = this.element.getClientRect();
|
|
1372
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})`;
|
|
1373
1373
|
});
|
|
1374
|
-
|
|
1374
|
+
u(this, zt, (t) => {
|
|
1375
1375
|
t.key === "Escape" && this.detachEditor();
|
|
1376
1376
|
});
|
|
1377
|
-
|
|
1377
|
+
u(this, Wt, (t) => {
|
|
1378
1378
|
const e = t.target;
|
|
1379
1379
|
this.htmlElement.contains(e) || this.detachEditor();
|
|
1380
1380
|
});
|
|
@@ -1450,7 +1450,7 @@ var Et, De, Xt, Yt, Bi;
|
|
|
1450
1450
|
class _s extends st {
|
|
1451
1451
|
constructor(t, e, s = !1) {
|
|
1452
1452
|
super();
|
|
1453
|
-
|
|
1453
|
+
u(this, Et);
|
|
1454
1454
|
p(this, "core");
|
|
1455
1455
|
p(this, "config");
|
|
1456
1456
|
p(this, "element");
|
|
@@ -1458,16 +1458,16 @@ class _s extends st {
|
|
|
1458
1458
|
p(this, "imgCover");
|
|
1459
1459
|
p(this, "playIcon");
|
|
1460
1460
|
p(this, "isDraft");
|
|
1461
|
-
|
|
1461
|
+
u(this, Xt, ({ type: t }) => {
|
|
1462
1462
|
const e = t === "select";
|
|
1463
1463
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1464
1464
|
});
|
|
1465
|
-
|
|
1465
|
+
u(this, Yt, () => {
|
|
1466
1466
|
this.getElement().getLayer() && this.core._rebuildStateAfterNodeChange([this], !0);
|
|
1467
1467
|
});
|
|
1468
1468
|
this.core = t, this.config = di(e, this.core.getTheme());
|
|
1469
|
-
const { group: o, image: a, imgCover:
|
|
1470
|
-
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());
|
|
1471
1471
|
}
|
|
1472
1472
|
getID() {
|
|
1473
1473
|
return this.config.id;
|
|
@@ -1566,7 +1566,7 @@ De = function() {
|
|
|
1566
1566
|
e.crossOrigin = "anonymous", e.src = t, e.onload = () => {
|
|
1567
1567
|
this.cover.image(e);
|
|
1568
1568
|
let s = this.config.width ?? e.width, o = this.config.height ?? e.height;
|
|
1569
|
-
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);
|
|
1570
1570
|
}, e.onerror = () => {
|
|
1571
1571
|
console.error("Failed to load image:", t);
|
|
1572
1572
|
};
|
|
@@ -1575,8 +1575,8 @@ De = function() {
|
|
|
1575
1575
|
*/
|
|
1576
1576
|
Bi = function(t) {
|
|
1577
1577
|
this.core.on("toolType:change", r(this, Xt)), t.on("transform", (e) => {
|
|
1578
|
-
const s = e.target, o = Math.max(
|
|
1579
|
-
|
|
1578
|
+
const s = e.target, o = Math.max(tt.MIN_SIZE, this.cover.width() * s.scaleX()), a = Math.max(
|
|
1579
|
+
tt.MIN_SIZE,
|
|
1580
1580
|
this.cover.height() * s.scaleY()
|
|
1581
1581
|
);
|
|
1582
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 });
|
|
@@ -1590,12 +1590,12 @@ var Gt, Ne, Vi;
|
|
|
1590
1590
|
class Ms extends st {
|
|
1591
1591
|
constructor(t, e, s = !1) {
|
|
1592
1592
|
super();
|
|
1593
|
-
|
|
1593
|
+
u(this, Ne);
|
|
1594
1594
|
p(this, "core");
|
|
1595
1595
|
p(this, "config");
|
|
1596
1596
|
p(this, "element");
|
|
1597
1597
|
p(this, "isDraft");
|
|
1598
|
-
|
|
1598
|
+
u(this, Gt, ({ type: t }) => {
|
|
1599
1599
|
const e = t === "select";
|
|
1600
1600
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1601
1601
|
});
|
|
@@ -1664,12 +1664,12 @@ var Kt, Te, Oi;
|
|
|
1664
1664
|
class ks extends st {
|
|
1665
1665
|
constructor(t, e, s = !1) {
|
|
1666
1666
|
super();
|
|
1667
|
-
|
|
1667
|
+
u(this, Te);
|
|
1668
1668
|
p(this, "core");
|
|
1669
1669
|
p(this, "config");
|
|
1670
1670
|
p(this, "element");
|
|
1671
1671
|
p(this, "isDraft");
|
|
1672
|
-
|
|
1672
|
+
u(this, Kt, ({ type: t }) => {
|
|
1673
1673
|
const e = t === "select";
|
|
1674
1674
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1675
1675
|
});
|
|
@@ -1737,12 +1737,12 @@ var qt, _e, Zi;
|
|
|
1737
1737
|
class $s extends st {
|
|
1738
1738
|
constructor(t, e, s = !1) {
|
|
1739
1739
|
super();
|
|
1740
|
-
|
|
1740
|
+
u(this, _e);
|
|
1741
1741
|
p(this, "core");
|
|
1742
1742
|
p(this, "config");
|
|
1743
1743
|
p(this, "element");
|
|
1744
1744
|
p(this, "isDraft");
|
|
1745
|
-
|
|
1745
|
+
u(this, qt, ({ type: t }) => {
|
|
1746
1746
|
const e = t === "select";
|
|
1747
1747
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1748
1748
|
});
|
|
@@ -1794,35 +1794,35 @@ Zi = function() {
|
|
|
1794
1794
|
this.core.on("toolType:change", r(this, qt)), t.on("transform", (e) => {
|
|
1795
1795
|
const s = e.target, { width: o, height: a } = Rs(s);
|
|
1796
1796
|
s.scale({ x: 1, y: 1 }), s.width(o), s.height(a);
|
|
1797
|
-
const
|
|
1797
|
+
const l = ki(
|
|
1798
1798
|
{ x: s.x(), y: s.y(), width: o, height: a },
|
|
1799
1799
|
this.config.$_shape
|
|
1800
1800
|
);
|
|
1801
|
-
s.points(
|
|
1801
|
+
s.points(l.flatMap((h) => [h.x, h.y]));
|
|
1802
1802
|
}), t.on("transformend", (e) => {
|
|
1803
1803
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1804
1804
|
}), t.on("dragend", (e) => {
|
|
1805
1805
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1806
1806
|
});
|
|
1807
1807
|
};
|
|
1808
|
-
var
|
|
1808
|
+
var H, L, wt, bt, V, Ui, Nt, zi, Wi, jt, Xi;
|
|
1809
1809
|
class As extends st {
|
|
1810
1810
|
constructor(t, e, s = !1) {
|
|
1811
1811
|
super();
|
|
1812
|
-
|
|
1812
|
+
u(this, V);
|
|
1813
1813
|
p(this, "core");
|
|
1814
1814
|
p(this, "config");
|
|
1815
1815
|
p(this, "element");
|
|
1816
1816
|
p(this, "isDraft");
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
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 }) => {
|
|
1822
1822
|
const e = t === "select";
|
|
1823
1823
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1824
1824
|
});
|
|
1825
|
-
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);
|
|
1826
1826
|
}
|
|
1827
1827
|
getID() {
|
|
1828
1828
|
return this.config.id;
|
|
@@ -1853,23 +1853,23 @@ class As extends st {
|
|
|
1853
1853
|
...t
|
|
1854
1854
|
},
|
|
1855
1855
|
this.core.getTheme()
|
|
1856
|
-
), this.getElement().setAttrs(this.config), E(this,
|
|
1856
|
+
), this.getElement().setAttrs(this.config), E(this, V, Nt).call(this);
|
|
1857
1857
|
}
|
|
1858
1858
|
/**
|
|
1859
1859
|
* 销毁
|
|
1860
1860
|
*/
|
|
1861
1861
|
destroy() {
|
|
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,
|
|
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();
|
|
1863
1863
|
}
|
|
1864
1864
|
}
|
|
1865
|
-
|
|
1865
|
+
H = new WeakMap(), L = new WeakMap(), wt = new WeakMap(), bt = new WeakMap(), V = new WeakSet(), /**
|
|
1866
1866
|
* 创建起点和终点的控制锚点
|
|
1867
1867
|
*/
|
|
1868
1868
|
Ui = function() {
|
|
1869
1869
|
const t = this.core.getMainLayer();
|
|
1870
1870
|
if (!t) return;
|
|
1871
1871
|
const e = this.core.getStageScale(), s = 6 / e, o = 2 / e;
|
|
1872
|
-
|
|
1872
|
+
C(this, H, new M.Circle({
|
|
1873
1873
|
radius: s,
|
|
1874
1874
|
fill: "white",
|
|
1875
1875
|
stroke: "#1976d2",
|
|
@@ -1877,7 +1877,7 @@ Ui = function() {
|
|
|
1877
1877
|
draggable: !0,
|
|
1878
1878
|
visible: !1,
|
|
1879
1879
|
name: "arrow-anchor"
|
|
1880
|
-
})),
|
|
1880
|
+
})), C(this, L, new M.Circle({
|
|
1881
1881
|
radius: s,
|
|
1882
1882
|
fill: "white",
|
|
1883
1883
|
stroke: "#1976d2",
|
|
@@ -1885,33 +1885,33 @@ Ui = function() {
|
|
|
1885
1885
|
draggable: !0,
|
|
1886
1886
|
visible: !1,
|
|
1887
1887
|
name: "arrow-anchor"
|
|
1888
|
-
})), 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", () => {
|
|
1889
1889
|
const a = [...this.element.points()];
|
|
1890
1890
|
if (a.length < 4) return;
|
|
1891
|
-
const
|
|
1892
|
-
a[0] =
|
|
1893
|
-
}), 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", () => {
|
|
1894
1894
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1895
|
-
}), r(this,
|
|
1895
|
+
}), r(this, L).on("dragmove", () => {
|
|
1896
1896
|
const a = [...this.element.points()];
|
|
1897
1897
|
if (a.length < 4) return;
|
|
1898
|
-
const
|
|
1899
|
-
a[a.length - 2] =
|
|
1900
|
-
}), 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", () => {
|
|
1901
1901
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1902
1902
|
});
|
|
1903
1903
|
}, /**
|
|
1904
1904
|
* 更新锚点位置
|
|
1905
1905
|
*/
|
|
1906
1906
|
Nt = function() {
|
|
1907
|
-
if (!r(this,
|
|
1907
|
+
if (!r(this, H) || !r(this, L)) return;
|
|
1908
1908
|
const t = this.element.points();
|
|
1909
1909
|
if (t.length < 4) return;
|
|
1910
1910
|
const e = this.element, s = e.x(), o = e.y();
|
|
1911
|
-
r(this,
|
|
1911
|
+
r(this, H).position({
|
|
1912
1912
|
x: s + t[0],
|
|
1913
1913
|
y: o + t[1]
|
|
1914
|
-
}), r(this,
|
|
1914
|
+
}), r(this, L).position({
|
|
1915
1915
|
x: s + t[t.length - 2],
|
|
1916
1916
|
y: o + t[t.length - 1]
|
|
1917
1917
|
});
|
|
@@ -1919,31 +1919,31 @@ Nt = function() {
|
|
|
1919
1919
|
* 更新锚点样式(根据缩放调整大小)
|
|
1920
1920
|
*/
|
|
1921
1921
|
zi = function() {
|
|
1922
|
-
if (!r(this,
|
|
1922
|
+
if (!r(this, H) || !r(this, L)) return;
|
|
1923
1923
|
const t = this.core.getStageScale(), e = 6 / t, s = 2 / t;
|
|
1924
|
-
r(this,
|
|
1924
|
+
r(this, H).radius(e), r(this, H).strokeWidth(s), r(this, L).radius(e), r(this, L).strokeWidth(s);
|
|
1925
1925
|
}, /**
|
|
1926
1926
|
* 显示或隐藏锚点
|
|
1927
1927
|
*/
|
|
1928
1928
|
Wi = function(t) {
|
|
1929
|
-
!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()));
|
|
1930
1930
|
}, jt = new WeakMap(), /**
|
|
1931
1931
|
* 设置事件处理器
|
|
1932
1932
|
*/
|
|
1933
1933
|
Xi = function() {
|
|
1934
1934
|
const t = this.getElement();
|
|
1935
|
-
this.core.on("toolType:change", r(this, jt)),
|
|
1935
|
+
this.core.on("toolType:change", r(this, jt)), C(this, bt, (e) => {
|
|
1936
1936
|
const s = e.includes(this.config.id);
|
|
1937
|
-
E(this,
|
|
1938
|
-
}), this.core.on("nodes:selected", r(this, bt)),
|
|
1939
|
-
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);
|
|
1940
1940
|
}), this.core.on("viewport:scale:change", r(this, wt)), t.on("transform", (e) => {
|
|
1941
|
-
const s = e.target, o = s.scaleX(), a = s.scaleY(),
|
|
1942
|
-
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);
|
|
1943
1943
|
}), t.on("transformend", () => {
|
|
1944
1944
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1945
1945
|
}), t.on("dragmove", () => {
|
|
1946
|
-
E(this,
|
|
1946
|
+
E(this, V, Nt).call(this);
|
|
1947
1947
|
}), t.on("dragend", () => {
|
|
1948
1948
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1949
1949
|
});
|
|
@@ -2073,7 +2073,7 @@ function ee(n, i) {
|
|
|
2073
2073
|
{ x: s, y: o }
|
|
2074
2074
|
];
|
|
2075
2075
|
}
|
|
2076
|
-
var kt,
|
|
2076
|
+
var kt, B, J, it, D, Rt, q, j, ht, pt, Me, W, Yi, Gi, Pe, Be, Ki;
|
|
2077
2077
|
class Ls extends ps {
|
|
2078
2078
|
constructor(t, e) {
|
|
2079
2079
|
const s = e?.state, o = {
|
|
@@ -2088,29 +2088,29 @@ class Ls extends ps {
|
|
|
2088
2088
|
}
|
|
2089
2089
|
};
|
|
2090
2090
|
super(o);
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
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);
|
|
2100
2100
|
/** 节点映射,方便快速查找 */
|
|
2101
|
-
|
|
2102
|
-
|
|
2101
|
+
u(this, ht, /* @__PURE__ */ new Map());
|
|
2102
|
+
u(this, pt, null);
|
|
2103
2103
|
p(this, "isEditingText", !1);
|
|
2104
|
-
|
|
2104
|
+
u(this, Me, (t) => {
|
|
2105
2105
|
(t.key === "Delete" || t.key === "Backspace") && (t.stopPropagation(), this.deleteSelectedNodes());
|
|
2106
2106
|
});
|
|
2107
|
-
|
|
2107
|
+
C(this, kt, e?.theme ?? Ii), C(this, Rt, t), C(this, B, new ms(this, {
|
|
2108
2108
|
container: t,
|
|
2109
2109
|
width: t.clientWidth,
|
|
2110
2110
|
height: t.clientHeight,
|
|
2111
2111
|
draggable: !1,
|
|
2112
2112
|
className: "touch-none"
|
|
2113
|
-
})),
|
|
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);
|
|
2114
2114
|
}
|
|
2115
2115
|
/**
|
|
2116
2116
|
* 获取当前主题
|
|
@@ -2122,13 +2122,13 @@ class Ls extends ps {
|
|
|
2122
2122
|
* 设置主题并重新渲染
|
|
2123
2123
|
*/
|
|
2124
2124
|
setTheme(t) {
|
|
2125
|
-
|
|
2125
|
+
C(this, kt, t), this._renderCanvas(this.getState()), this._emit("theme:change", t);
|
|
2126
2126
|
}
|
|
2127
2127
|
/**
|
|
2128
2128
|
* 获取 CanvasStage 实例
|
|
2129
2129
|
*/
|
|
2130
2130
|
getCanvasStage() {
|
|
2131
|
-
return r(this,
|
|
2131
|
+
return r(this, B);
|
|
2132
2132
|
}
|
|
2133
2133
|
/**
|
|
2134
2134
|
* 获取 CanvasTransformer 实例
|
|
@@ -2146,7 +2146,7 @@ class Ls extends ps {
|
|
|
2146
2146
|
* 获取 Konva.Stage 实例
|
|
2147
2147
|
*/
|
|
2148
2148
|
getStage() {
|
|
2149
|
-
return r(this,
|
|
2149
|
+
return r(this, B).getStage();
|
|
2150
2150
|
}
|
|
2151
2151
|
/**
|
|
2152
2152
|
* 获取 Stage 容器元素
|
|
@@ -2158,7 +2158,7 @@ class Ls extends ps {
|
|
|
2158
2158
|
* 获取主图层
|
|
2159
2159
|
*/
|
|
2160
2160
|
getMainLayer() {
|
|
2161
|
-
return r(this,
|
|
2161
|
+
return r(this, J);
|
|
2162
2162
|
}
|
|
2163
2163
|
/**
|
|
2164
2164
|
* 获取当前工具类型
|
|
@@ -2189,46 +2189,46 @@ class Ls extends ps {
|
|
|
2189
2189
|
), this._emit("toolType:change", {
|
|
2190
2190
|
type: t,
|
|
2191
2191
|
meta: e
|
|
2192
|
-
}), 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());
|
|
2193
2193
|
}
|
|
2194
2194
|
/**
|
|
2195
2195
|
* 根据 ID 获取 Canvas 节点实例
|
|
2196
2196
|
*/
|
|
2197
2197
|
getCanvasNodeById(t) {
|
|
2198
|
-
return r(this,
|
|
2198
|
+
return r(this, ht).get(t) || null;
|
|
2199
2199
|
}
|
|
2200
2200
|
/**
|
|
2201
2201
|
* 设置是否可拖拽(内部使用)
|
|
2202
2202
|
*/
|
|
2203
2203
|
setDraggable(t) {
|
|
2204
|
-
r(this,
|
|
2204
|
+
r(this, B).setDraggable(t);
|
|
2205
2205
|
}
|
|
2206
2206
|
/**
|
|
2207
2207
|
* 设置光标
|
|
2208
2208
|
* @internal 仅供内部使用
|
|
2209
2209
|
*/
|
|
2210
2210
|
_setCursor(t) {
|
|
2211
|
-
r(this,
|
|
2211
|
+
r(this, B).setCursor(t);
|
|
2212
2212
|
}
|
|
2213
2213
|
/**
|
|
2214
2214
|
* 重置光标
|
|
2215
2215
|
* @internal 仅供内部使用
|
|
2216
2216
|
*/
|
|
2217
2217
|
_resetCursor() {
|
|
2218
|
-
r(this,
|
|
2218
|
+
r(this, B).resetCursor();
|
|
2219
2219
|
}
|
|
2220
2220
|
/**
|
|
2221
2221
|
* 获取当前 Stage 缩放比例
|
|
2222
2222
|
*/
|
|
2223
2223
|
getStageScale() {
|
|
2224
|
-
return r(this,
|
|
2224
|
+
return r(this, B).getStage().scaleX();
|
|
2225
2225
|
}
|
|
2226
2226
|
/**
|
|
2227
2227
|
* 更新视口位置
|
|
2228
2228
|
* @internal 仅供内部使用,外部请使用 CanvasApi
|
|
2229
2229
|
*/
|
|
2230
2230
|
_updateViewport(t, e = !1) {
|
|
2231
|
-
r(this,
|
|
2231
|
+
r(this, B).setViewport(t);
|
|
2232
2232
|
const s = this.getState().viewport, o = {
|
|
2233
2233
|
...s,
|
|
2234
2234
|
...t
|
|
@@ -2243,37 +2243,37 @@ class Ls extends ps {
|
|
|
2243
2243
|
createNodes(t, e) {
|
|
2244
2244
|
const s = t.map((o) => wi(this, o.$_type, o, !1)).filter((o) => o !== null);
|
|
2245
2245
|
s.forEach((o) => {
|
|
2246
|
-
r(this,
|
|
2247
|
-
}), E(this,
|
|
2246
|
+
r(this, J).add(o.getElement());
|
|
2247
|
+
}), E(this, W, Be).call(this, s, e), this._emit("nodes:created", t);
|
|
2248
2248
|
}
|
|
2249
2249
|
/**
|
|
2250
2250
|
* 创建图片标注节点(内部使用)
|
|
2251
2251
|
*/
|
|
2252
2252
|
createImageMarkerNode(t, e, s, o) {
|
|
2253
2253
|
const a = this.getState().nodes || [];
|
|
2254
|
-
let
|
|
2255
|
-
a.forEach((
|
|
2256
|
-
|
|
2254
|
+
let l = 0;
|
|
2255
|
+
a.forEach((w) => {
|
|
2256
|
+
w.$_type === "image-marker" && typeof w.$_markerNumber == "number" && (l = Math.max(l, w.$_markerNumber));
|
|
2257
2257
|
});
|
|
2258
|
-
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 = {
|
|
2259
2259
|
id: Tt(),
|
|
2260
2260
|
$_type: "image-marker",
|
|
2261
|
-
x:
|
|
2261
|
+
x: g,
|
|
2262
2262
|
y,
|
|
2263
|
-
width:
|
|
2263
|
+
width: x,
|
|
2264
2264
|
height: v,
|
|
2265
2265
|
visible: !0,
|
|
2266
2266
|
line: "dashed",
|
|
2267
2267
|
$_parentId: t,
|
|
2268
|
-
$_markerNumber:
|
|
2268
|
+
$_markerNumber: l + 1,
|
|
2269
2269
|
$_relativeBox: {
|
|
2270
2270
|
start: {
|
|
2271
|
-
ratioX: Math.max(0, Math.min(1,
|
|
2271
|
+
ratioX: Math.max(0, Math.min(1, h)),
|
|
2272
2272
|
ratioY: Math.max(0, Math.min(1, d))
|
|
2273
2273
|
},
|
|
2274
2274
|
end: {
|
|
2275
|
-
ratioX: Math.max(0, Math.min(1,
|
|
2276
|
-
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))
|
|
2277
2277
|
}
|
|
2278
2278
|
}
|
|
2279
2279
|
};
|
|
@@ -2284,13 +2284,13 @@ class Ls extends ps {
|
|
|
2284
2284
|
* @internal 仅供内部使用
|
|
2285
2285
|
*/
|
|
2286
2286
|
_findImageAtPosition(t) {
|
|
2287
|
-
const a = r(this,
|
|
2288
|
-
(
|
|
2289
|
-
).slice().sort((
|
|
2290
|
-
for (const
|
|
2291
|
-
const
|
|
2292
|
-
if (t.x >=
|
|
2293
|
-
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;
|
|
2294
2294
|
}
|
|
2295
2295
|
return null;
|
|
2296
2296
|
}
|
|
@@ -2298,83 +2298,83 @@ class Ls extends ps {
|
|
|
2298
2298
|
* @internal 仅供内部使用
|
|
2299
2299
|
*/
|
|
2300
2300
|
_setDrawingPosition(t) {
|
|
2301
|
-
|
|
2301
|
+
C(this, j, [t, t]);
|
|
2302
2302
|
}
|
|
2303
2303
|
/**
|
|
2304
2304
|
* @internal 仅供内部使用
|
|
2305
2305
|
*/
|
|
2306
2306
|
_updateDrawingPosition(t) {
|
|
2307
|
-
r(this,
|
|
2307
|
+
r(this, j) && (r(this, j)[1] = t);
|
|
2308
2308
|
}
|
|
2309
2309
|
/**
|
|
2310
2310
|
* @internal 仅供内部使用
|
|
2311
2311
|
*/
|
|
2312
2312
|
_createDraftNode(t, e) {
|
|
2313
|
-
r(this,
|
|
2313
|
+
r(this, D) && r(this, D).destroy();
|
|
2314
2314
|
const s = Fs(
|
|
2315
2315
|
t,
|
|
2316
|
-
r(this,
|
|
2316
|
+
r(this, j)[0],
|
|
2317
2317
|
{
|
|
2318
2318
|
...e,
|
|
2319
2319
|
...this.getToolMeta()
|
|
2320
2320
|
}
|
|
2321
2321
|
);
|
|
2322
|
-
|
|
2322
|
+
C(this, D, wi(this, t, s, !0)), r(this, D) && r(this, J).add(r(this, D).getElement());
|
|
2323
2323
|
}
|
|
2324
2324
|
/**
|
|
2325
2325
|
* @internal 仅供内部使用
|
|
2326
2326
|
*/
|
|
2327
2327
|
_updateDraftNode() {
|
|
2328
|
-
if (!r(this,
|
|
2329
|
-
const t = r(this,
|
|
2328
|
+
if (!r(this, D)) return;
|
|
2329
|
+
const t = r(this, D).getConfig(), e = Hs(
|
|
2330
2330
|
t,
|
|
2331
|
-
r(this,
|
|
2332
|
-
r(this,
|
|
2331
|
+
r(this, j)[1],
|
|
2332
|
+
r(this, j)[0]
|
|
2333
2333
|
);
|
|
2334
|
-
r(this,
|
|
2334
|
+
r(this, D).update(e);
|
|
2335
2335
|
}
|
|
2336
2336
|
/**
|
|
2337
2337
|
* @internal 仅供内部使用
|
|
2338
2338
|
*/
|
|
2339
2339
|
_finalizeDraftNode() {
|
|
2340
|
-
if (!r(this,
|
|
2341
|
-
const t = Tt(), e = r(this,
|
|
2340
|
+
if (!r(this, D)) return;
|
|
2341
|
+
const t = Tt(), e = r(this, D).getConfig();
|
|
2342
2342
|
if (e.$_type === "image-marker") {
|
|
2343
2343
|
const o = e.$_bounds, a = {
|
|
2344
2344
|
x: e.x,
|
|
2345
2345
|
y: e.y
|
|
2346
|
-
},
|
|
2346
|
+
}, l = {
|
|
2347
2347
|
x: e.x + (e.width || 0),
|
|
2348
2348
|
y: e.y + (e.height || 0)
|
|
2349
|
-
},
|
|
2349
|
+
}, h = this.getState().nodes || [];
|
|
2350
2350
|
let d = 0;
|
|
2351
|
-
|
|
2351
|
+
h.forEach((v) => {
|
|
2352
2352
|
v.$_type === "image-marker" && typeof v.$_markerNumber == "number" && (d = Math.max(d, v.$_markerNumber));
|
|
2353
2353
|
});
|
|
2354
|
-
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 = {
|
|
2355
2355
|
...e,
|
|
2356
2356
|
$_markerNumber: d + 1,
|
|
2357
2357
|
$_relativeBox: {
|
|
2358
2358
|
start: {
|
|
2359
|
-
ratioX: Math.max(0, Math.min(1,
|
|
2360
|
-
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))
|
|
2361
2361
|
},
|
|
2362
2362
|
end: {
|
|
2363
|
-
ratioX: Math.max(0, Math.min(1,
|
|
2363
|
+
ratioX: Math.max(0, Math.min(1, g)),
|
|
2364
2364
|
ratioY: Math.max(0, Math.min(1, y))
|
|
2365
2365
|
}
|
|
2366
2366
|
},
|
|
2367
2367
|
$_type: "image-marker",
|
|
2368
2368
|
id: t
|
|
2369
2369
|
};
|
|
2370
|
-
this.createNodes([
|
|
2370
|
+
this.createNodes([x], !0), r(this, D).destroy(), C(this, D, null), this.setToolType("select");
|
|
2371
2371
|
return;
|
|
2372
2372
|
}
|
|
2373
2373
|
const s = {
|
|
2374
2374
|
...e,
|
|
2375
2375
|
id: t
|
|
2376
2376
|
};
|
|
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,
|
|
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") {
|
|
2378
2378
|
const o = this.getCanvasNodeById(t);
|
|
2379
2379
|
o && o.attachEditor();
|
|
2380
2380
|
}
|
|
@@ -2384,7 +2384,7 @@ class Ls extends ps {
|
|
|
2384
2384
|
* @internal 仅供内部使用
|
|
2385
2385
|
*/
|
|
2386
2386
|
_createTextNodeAtDrawingPosition(t) {
|
|
2387
|
-
const e = r(this,
|
|
2387
|
+
const e = r(this, j)[1], s = {
|
|
2388
2388
|
id: Tt(),
|
|
2389
2389
|
$_type: "text",
|
|
2390
2390
|
x: e.x,
|
|
@@ -2397,34 +2397,34 @@ class Ls extends ps {
|
|
|
2397
2397
|
* @internal 仅供内部使用
|
|
2398
2398
|
*/
|
|
2399
2399
|
_createSelectRect() {
|
|
2400
|
-
this.isEditingText || (r(this,
|
|
2401
|
-
x: r(this,
|
|
2402
|
-
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,
|
|
2403
2403
|
width: 0,
|
|
2404
2404
|
height: 0,
|
|
2405
2405
|
stroke: this.getTheme()["theme.select-rect-border"],
|
|
2406
2406
|
strokeWidth: 1,
|
|
2407
2407
|
fill: this.getTheme()["theme.select-rect-fill"]
|
|
2408
|
-
})), r(this,
|
|
2408
|
+
})), r(this, J).add(r(this, q)));
|
|
2409
2409
|
}
|
|
2410
2410
|
/*
|
|
2411
2411
|
* @internal 仅供内部使用
|
|
2412
2412
|
*/
|
|
2413
2413
|
_updateSelectRect() {
|
|
2414
|
-
if (!r(this,
|
|
2415
|
-
const [t, e] = ee(...r(this,
|
|
2416
|
-
r(this,
|
|
2414
|
+
if (!r(this, q)) return;
|
|
2415
|
+
const [t, e] = ee(...r(this, j));
|
|
2416
|
+
r(this, q).setAttrs({
|
|
2417
2417
|
x: t.x,
|
|
2418
2418
|
y: t.y,
|
|
2419
2419
|
width: e.x - t.x,
|
|
2420
2420
|
height: e.y - t.y
|
|
2421
2421
|
});
|
|
2422
|
-
const s = r(this,
|
|
2423
|
-
const
|
|
2424
|
-
return M.Util.haveIntersection(s,
|
|
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);
|
|
2425
2425
|
});
|
|
2426
2426
|
this._selectNodes(
|
|
2427
|
-
a.length > 0 ? a.filter((
|
|
2427
|
+
a.length > 0 ? a.filter((l) => l.listening()).map((l) => l.id()) : void 0,
|
|
2428
2428
|
!1
|
|
2429
2429
|
);
|
|
2430
2430
|
}
|
|
@@ -2432,7 +2432,7 @@ class Ls extends ps {
|
|
|
2432
2432
|
* @internal 仅供内部使用
|
|
2433
2433
|
*/
|
|
2434
2434
|
_finalizeSelectRect() {
|
|
2435
|
-
r(this,
|
|
2435
|
+
r(this, q) && (r(this, q).destroy(), C(this, q, null));
|
|
2436
2436
|
}
|
|
2437
2437
|
/**
|
|
2438
2438
|
* 选择节点
|
|
@@ -2446,8 +2446,8 @@ class Ls extends ps {
|
|
|
2446
2446
|
if (a.length === 0)
|
|
2447
2447
|
r(this, it).clearNodes();
|
|
2448
2448
|
else {
|
|
2449
|
-
const
|
|
2450
|
-
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);
|
|
2451
2451
|
}
|
|
2452
2452
|
this._updateState({ selectedNodeIds: a }, !1), this._emit("nodes:selected", a);
|
|
2453
2453
|
}
|
|
@@ -2463,15 +2463,15 @@ class Ls extends ps {
|
|
|
2463
2463
|
if (t.length === 0) return [];
|
|
2464
2464
|
const e = this.getState().nodes || [], s = new Set(t);
|
|
2465
2465
|
t.forEach((a) => {
|
|
2466
|
-
e.find((
|
|
2467
|
-
|
|
2466
|
+
e.find((h) => h.id === a)?.$_type === "image" && e.forEach((h) => {
|
|
2467
|
+
h.$_type === "image-marker" && h.$_parentId === a && s.add(h.id);
|
|
2468
2468
|
});
|
|
2469
2469
|
});
|
|
2470
2470
|
const o = e.filter((a) => s.has(a.id));
|
|
2471
2471
|
return s.forEach((a) => {
|
|
2472
|
-
const
|
|
2473
|
-
|
|
2474
|
-
}), 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(
|
|
2475
2475
|
{
|
|
2476
2476
|
selectedNodeIds: []
|
|
2477
2477
|
},
|
|
@@ -2490,14 +2490,14 @@ class Ls extends ps {
|
|
|
2490
2490
|
* 销毁 canvas
|
|
2491
2491
|
*/
|
|
2492
2492
|
dispose() {
|
|
2493
|
-
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();
|
|
2494
2494
|
}
|
|
2495
2495
|
/**
|
|
2496
2496
|
* @internal 仅供内部使用
|
|
2497
2497
|
* 在元素节点改变后(例如 tranfromEnd dragEnd)重建 state.nodes
|
|
2498
2498
|
*/
|
|
2499
2499
|
_rebuildStateAfterNodeChange(t, e) {
|
|
2500
|
-
E(this,
|
|
2500
|
+
E(this, W, Be).call(this, Array.isArray(t) ? t : [t], e);
|
|
2501
2501
|
}
|
|
2502
2502
|
/**
|
|
2503
2503
|
* 实现父类的状态同步方法
|
|
@@ -2511,9 +2511,9 @@ class Ls extends ps {
|
|
|
2511
2511
|
scale: t.viewport.scale
|
|
2512
2512
|
},
|
|
2513
2513
|
!1
|
|
2514
|
-
), r(this,
|
|
2514
|
+
), r(this, ht).forEach((e, s) => {
|
|
2515
2515
|
e.destroy();
|
|
2516
|
-
}), r(this,
|
|
2516
|
+
}), r(this, ht).clear(), this.createNodes(t.nodes || [], !1), this._selectNodes(t.selectedNodeIds || [], !1, !0);
|
|
2517
2517
|
}
|
|
2518
2518
|
_showContextMenu(t) {
|
|
2519
2519
|
this._emit("contextmenu:show", t);
|
|
@@ -2521,12 +2521,12 @@ class Ls extends ps {
|
|
|
2521
2521
|
// 在调整节点上下层级后调用,同步到 store 中
|
|
2522
2522
|
_syncNodesZIndexToStore() {
|
|
2523
2523
|
const t = this.getStage().find(`.${b.nodeRoot}`).map((a) => a.id()).filter((a) => a), e = this.getState().nodes || [], s = /* @__PURE__ */ new Map();
|
|
2524
|
-
t.forEach((a,
|
|
2525
|
-
s.set(a,
|
|
2524
|
+
t.forEach((a, l) => {
|
|
2525
|
+
s.set(a, l);
|
|
2526
2526
|
});
|
|
2527
|
-
const o = [...e].sort((a,
|
|
2528
|
-
const
|
|
2529
|
-
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;
|
|
2530
2530
|
});
|
|
2531
2531
|
this._updateState({ nodes: o }, !0), this._emit("nodes:sorted", t);
|
|
2532
2532
|
}
|
|
@@ -2537,7 +2537,7 @@ class Ls extends ps {
|
|
|
2537
2537
|
this._emit("texteditor:unregister", void 0);
|
|
2538
2538
|
}
|
|
2539
2539
|
}
|
|
2540
|
-
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(), /**
|
|
2541
2541
|
* 设置键盘事件监听
|
|
2542
2542
|
*/
|
|
2543
2543
|
Yi = function() {
|
|
@@ -2547,14 +2547,14 @@ Yi = function() {
|
|
|
2547
2547
|
* 设置尺寸变化监听
|
|
2548
2548
|
*/
|
|
2549
2549
|
Gi = function() {
|
|
2550
|
-
|
|
2550
|
+
C(this, pt, new ResizeObserver((t) => {
|
|
2551
2551
|
for (const e of t) {
|
|
2552
|
-
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;
|
|
2553
2553
|
a.width(s), a.height(o);
|
|
2554
|
-
const
|
|
2554
|
+
const g = m - s / 2, y = f - o / 2;
|
|
2555
2555
|
this._updateViewport(
|
|
2556
2556
|
{
|
|
2557
|
-
x:
|
|
2557
|
+
x: g,
|
|
2558
2558
|
y
|
|
2559
2559
|
},
|
|
2560
2560
|
!1
|
|
@@ -2566,34 +2566,34 @@ Gi = function() {
|
|
|
2566
2566
|
*/
|
|
2567
2567
|
Pe = function(t) {
|
|
2568
2568
|
const e = this.getState().nodes || [], s = /* @__PURE__ */ new Map();
|
|
2569
|
-
e.forEach((d,
|
|
2570
|
-
s.set(d.id,
|
|
2569
|
+
e.forEach((d, m) => {
|
|
2570
|
+
s.set(d.id, m);
|
|
2571
2571
|
});
|
|
2572
|
-
const o = Array.from(r(this,
|
|
2572
|
+
const o = Array.from(r(this, ht).values()).map(
|
|
2573
2573
|
(d) => d.getConfig()
|
|
2574
|
-
), a = [],
|
|
2574
|
+
), a = [], l = [];
|
|
2575
2575
|
o.forEach((d) => {
|
|
2576
|
-
s.has(d.id) ? a.push(d) :
|
|
2577
|
-
}), a.sort((d,
|
|
2578
|
-
const
|
|
2579
|
-
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;
|
|
2580
2580
|
});
|
|
2581
|
-
const
|
|
2582
|
-
nodes: [...a, ...
|
|
2581
|
+
const h = {
|
|
2582
|
+
nodes: [...a, ...l]
|
|
2583
2583
|
};
|
|
2584
|
-
this._updateState(
|
|
2584
|
+
this._updateState(h, t);
|
|
2585
2585
|
}, /**
|
|
2586
2586
|
* 更新 state.nodes
|
|
2587
2587
|
*/
|
|
2588
2588
|
Be = function(t, e) {
|
|
2589
2589
|
t.length !== 0 && (t.forEach((s) => {
|
|
2590
|
-
r(this,
|
|
2591
|
-
}), E(this,
|
|
2590
|
+
r(this, ht).set(s.getID(), s);
|
|
2591
|
+
}), E(this, W, Pe).call(this, e));
|
|
2592
2592
|
}, Ki = function(t, e = !1) {
|
|
2593
2593
|
t.length !== 0 && (t.forEach((s) => {
|
|
2594
|
-
const o = r(this,
|
|
2595
|
-
o && o.destroy(), r(this,
|
|
2596
|
-
}), 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));
|
|
2597
2597
|
};
|
|
2598
2598
|
class Ds extends Ls {
|
|
2599
2599
|
/**
|
|
@@ -2675,10 +2675,10 @@ class Ds extends Ls {
|
|
|
2675
2675
|
if (t.length === 0)
|
|
2676
2676
|
return console.warn("No selection to export"), null;
|
|
2677
2677
|
const e = i?.padding ?? 0, s = new M.Group();
|
|
2678
|
-
t.forEach((
|
|
2679
|
-
const
|
|
2680
|
-
if (
|
|
2681
|
-
const d =
|
|
2678
|
+
t.forEach((l) => {
|
|
2679
|
+
const h = this.getStage().findOne(`#${l}`);
|
|
2680
|
+
if (h) {
|
|
2681
|
+
const d = h.clone();
|
|
2682
2682
|
s.add(d);
|
|
2683
2683
|
}
|
|
2684
2684
|
});
|
|
@@ -2703,37 +2703,37 @@ class Ds extends Ls {
|
|
|
2703
2703
|
if (!e)
|
|
2704
2704
|
return console.warn("Image shape not found on stage"), null;
|
|
2705
2705
|
const o = (this.getState().nodes || []).filter(
|
|
2706
|
-
(
|
|
2706
|
+
(x) => x.$_type === "image-marker" && x.$_parentId === i
|
|
2707
2707
|
);
|
|
2708
2708
|
if (o.length === 0)
|
|
2709
2709
|
return console.warn("No image-marker nodes found for the given image ID"), null;
|
|
2710
|
-
const a = new M.Group(),
|
|
2711
|
-
a.add(
|
|
2712
|
-
const
|
|
2713
|
-
o.forEach((
|
|
2714
|
-
const
|
|
2715
|
-
if (
|
|
2716
|
-
const
|
|
2717
|
-
if (w && (w.strokeWidth(3 *
|
|
2718
|
-
const
|
|
2719
|
-
if (
|
|
2720
|
-
const
|
|
2721
|
-
|
|
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);
|
|
2722
2722
|
}
|
|
2723
2723
|
}
|
|
2724
|
-
a.add(
|
|
2724
|
+
a.add(I);
|
|
2725
2725
|
}
|
|
2726
2726
|
});
|
|
2727
|
-
const
|
|
2728
|
-
x:
|
|
2729
|
-
y:
|
|
2730
|
-
width:
|
|
2731
|
-
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,
|
|
2732
2732
|
pixelRatio: t?.pixelRatio ?? 2,
|
|
2733
2733
|
mimeType: t?.mimeType ?? "image/png",
|
|
2734
2734
|
quality: t?.quality ?? 1
|
|
2735
2735
|
});
|
|
2736
|
-
return a.destroy(),
|
|
2736
|
+
return a.destroy(), y;
|
|
2737
2737
|
}
|
|
2738
2738
|
/**
|
|
2739
2739
|
* 删除当前选中的节点
|
|
@@ -2831,30 +2831,30 @@ class Ds extends Ls {
|
|
|
2831
2831
|
scrollToContent(i) {
|
|
2832
2832
|
if ((this.getState().nodes || []).length === 0) return;
|
|
2833
2833
|
const e = i?.padding ?? 50, s = i?.scale === !0, o = i?.nodeIds;
|
|
2834
|
-
let a = 1 / 0,
|
|
2835
|
-
const
|
|
2836
|
-
if (
|
|
2837
|
-
if (
|
|
2838
|
-
if (
|
|
2839
|
-
const ut =
|
|
2840
|
-
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;
|
|
2841
2841
|
}
|
|
2842
|
-
const xt =
|
|
2842
|
+
const xt = Y.getAttrs(), ni = xt.x || 0, si = xt.y || 0, En = xt.width || 0, Sn = xt.height || 0;
|
|
2843
2843
|
if (xt.rotation || 0) {
|
|
2844
|
-
const ut =
|
|
2845
|
-
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);
|
|
2846
2846
|
} else
|
|
2847
|
-
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);
|
|
2848
2848
|
}
|
|
2849
|
-
}), a === 1 / 0 ||
|
|
2850
|
-
const v =
|
|
2851
|
-
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;
|
|
2852
2852
|
if (s) {
|
|
2853
|
-
const
|
|
2854
|
-
|
|
2853
|
+
const Y = (this.getStage().width() - e * 2) / v, xt = (this.getStage().height() - e * 2) / I;
|
|
2854
|
+
R = Math.min(Y, xt, 1);
|
|
2855
2855
|
}
|
|
2856
|
-
const
|
|
2857
|
-
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);
|
|
2858
2858
|
}
|
|
2859
2859
|
/**
|
|
2860
2860
|
* 导出当前状态
|
|
@@ -2909,8 +2909,8 @@ class Ds extends Ls {
|
|
|
2909
2909
|
}
|
|
2910
2910
|
}
|
|
2911
2911
|
function Ps(n, i, t, e = !1) {
|
|
2912
|
-
const [s, o] = i, [a,
|
|
2913
|
-
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;
|
|
2914
2914
|
}
|
|
2915
2915
|
const Ei = [
|
|
2916
2916
|
{
|
|
@@ -2941,7 +2941,7 @@ function Bs({
|
|
|
2941
2941
|
size: e = 15,
|
|
2942
2942
|
showGrid: s = !0
|
|
2943
2943
|
}) {
|
|
2944
|
-
const o = n / t, a = i / t,
|
|
2944
|
+
const o = n / t, a = i / t, l = t;
|
|
2945
2945
|
return s ? /* @__PURE__ */ k(
|
|
2946
2946
|
"svg",
|
|
2947
2947
|
{
|
|
@@ -2950,14 +2950,14 @@ function Bs({
|
|
|
2950
2950
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2951
2951
|
"aria-hidden": "true",
|
|
2952
2952
|
children: [
|
|
2953
|
-
/* @__PURE__ */ c("defs", { children: Ei.map(({ min:
|
|
2954
|
-
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;
|
|
2955
2955
|
return /* @__PURE__ */ c(
|
|
2956
2956
|
"pattern",
|
|
2957
2957
|
{
|
|
2958
|
-
id: `grid_${
|
|
2959
|
-
width:
|
|
2960
|
-
height:
|
|
2958
|
+
id: `grid_${m}`,
|
|
2959
|
+
width: g,
|
|
2960
|
+
height: g,
|
|
2961
2961
|
patternUnits: "userSpaceOnUse",
|
|
2962
2962
|
children: /* @__PURE__ */ c(
|
|
2963
2963
|
"circle",
|
|
@@ -2966,14 +2966,14 @@ function Bs({
|
|
|
2966
2966
|
cx: v,
|
|
2967
2967
|
cy: I,
|
|
2968
2968
|
r: 1,
|
|
2969
|
-
opacity:
|
|
2969
|
+
opacity: w
|
|
2970
2970
|
}
|
|
2971
2971
|
)
|
|
2972
2972
|
},
|
|
2973
|
-
|
|
2973
|
+
f
|
|
2974
2974
|
);
|
|
2975
2975
|
}) }),
|
|
2976
|
-
Ei.map(({ step:
|
|
2976
|
+
Ei.map(({ step: h }, d) => /* @__PURE__ */ c("rect", { width: "100%", height: "100%", fill: `url(#grid_${h})` }, d))
|
|
2977
2977
|
]
|
|
2978
2978
|
}
|
|
2979
2979
|
) : null;
|
|
@@ -3027,24 +3027,24 @@ function Ft({
|
|
|
3027
3027
|
);
|
|
3028
3028
|
}
|
|
3029
3029
|
function Zs({ api: n }) {
|
|
3030
|
-
const [i, t] =
|
|
3031
|
-
|
|
3032
|
-
n.on("viewport:change", (
|
|
3033
|
-
t(
|
|
3030
|
+
const [i, t] = $(n.getState().viewport);
|
|
3031
|
+
U(() => {
|
|
3032
|
+
n.on("viewport:change", (h) => {
|
|
3033
|
+
t(h);
|
|
3034
3034
|
});
|
|
3035
3035
|
}, [t, n]);
|
|
3036
|
-
const e = (
|
|
3037
|
-
const d = n.getStage().width() / 2,
|
|
3038
|
-
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 });
|
|
3039
3039
|
}, s = () => {
|
|
3040
|
-
const
|
|
3041
|
-
e(
|
|
3040
|
+
const h = Math.min(i.scale * 1.2, 5);
|
|
3041
|
+
e(h);
|
|
3042
3042
|
}, o = () => {
|
|
3043
|
-
const
|
|
3044
|
-
e(
|
|
3043
|
+
const h = Math.max(i.scale / 1.2, 0.1);
|
|
3044
|
+
e(h);
|
|
3045
3045
|
}, a = () => {
|
|
3046
3046
|
e(1);
|
|
3047
|
-
},
|
|
3047
|
+
}, l = Math.round(i.scale * 100);
|
|
3048
3048
|
return /* @__PURE__ */ k("div", { className: "zoom-panel flex items-center gap-2", children: [
|
|
3049
3049
|
/* @__PURE__ */ c(
|
|
3050
3050
|
Ft,
|
|
@@ -3062,10 +3062,10 @@ function Zs({ api: n }) {
|
|
|
3062
3062
|
size: "sm",
|
|
3063
3063
|
variant: "secondary",
|
|
3064
3064
|
onClick: a,
|
|
3065
|
-
title: `${
|
|
3065
|
+
title: `${l}%`,
|
|
3066
3066
|
className: "min-w-16",
|
|
3067
3067
|
children: [
|
|
3068
|
-
|
|
3068
|
+
l,
|
|
3069
3069
|
"%"
|
|
3070
3070
|
]
|
|
3071
3071
|
}
|
|
@@ -3083,8 +3083,8 @@ function Zs({ api: n }) {
|
|
|
3083
3083
|
] });
|
|
3084
3084
|
}
|
|
3085
3085
|
function Us({ api: n }) {
|
|
3086
|
-
const [i, t] =
|
|
3087
|
-
return
|
|
3086
|
+
const [i, t] = $(n.canUndo()), [e, s] = $(n.canRedo());
|
|
3087
|
+
return U(() => {
|
|
3088
3088
|
const o = () => {
|
|
3089
3089
|
t(n.canUndo()), s(n.canRedo());
|
|
3090
3090
|
};
|
|
@@ -3117,18 +3117,18 @@ function Us({ api: n }) {
|
|
|
3117
3117
|
] });
|
|
3118
3118
|
}
|
|
3119
3119
|
function Xo({ setApi: n, theme: i }) {
|
|
3120
|
-
const t = Ue(null), [e, s] =
|
|
3121
|
-
return
|
|
3120
|
+
const t = Ue(null), [e, s] = $(null), [o, a] = $({ x: 0, y: 0, scale: 1 });
|
|
3121
|
+
return U(() => {
|
|
3122
3122
|
if (!t.current) return;
|
|
3123
|
-
const
|
|
3123
|
+
const l = new Ds(t.current, {
|
|
3124
3124
|
theme: i
|
|
3125
3125
|
});
|
|
3126
|
-
return s(
|
|
3127
|
-
a(
|
|
3126
|
+
return s(l), n?.(l), l.on("viewport:change", (h) => {
|
|
3127
|
+
a(h);
|
|
3128
3128
|
}), () => {
|
|
3129
|
-
|
|
3129
|
+
l.dispose();
|
|
3130
3130
|
};
|
|
3131
|
-
}, []),
|
|
3131
|
+
}, []), U(() => {
|
|
3132
3132
|
e && i && e.setTheme(i);
|
|
3133
3133
|
}, [e, i]), /* @__PURE__ */ k("div", { className: "whiteboard relative size-full", children: [
|
|
3134
3134
|
/* @__PURE__ */ c(
|
|
@@ -3153,17 +3153,17 @@ function Xo({ setApi: n, theme: i }) {
|
|
|
3153
3153
|
] });
|
|
3154
3154
|
}
|
|
3155
3155
|
function Yo(n) {
|
|
3156
|
-
const [i, t] =
|
|
3157
|
-
return
|
|
3156
|
+
const [i, t] = $(null);
|
|
3157
|
+
return U(() => {
|
|
3158
3158
|
if (!n) return;
|
|
3159
3159
|
const s = ({
|
|
3160
3160
|
clientX: o,
|
|
3161
3161
|
clientY: a,
|
|
3162
|
-
targetIds:
|
|
3162
|
+
targetIds: l
|
|
3163
3163
|
}) => {
|
|
3164
|
-
let
|
|
3165
|
-
if (
|
|
3166
|
-
|
|
3164
|
+
let h = [];
|
|
3165
|
+
if (l.length > 1)
|
|
3166
|
+
h = [
|
|
3167
3167
|
// {
|
|
3168
3168
|
// label: "组合",
|
|
3169
3169
|
// action: () => {
|
|
@@ -3179,9 +3179,9 @@ function Yo(n) {
|
|
|
3179
3179
|
// },
|
|
3180
3180
|
// },
|
|
3181
3181
|
];
|
|
3182
|
-
else if (
|
|
3183
|
-
const d =
|
|
3184
|
-
d === "canvas-stage" ?
|
|
3182
|
+
else if (l.length === 1) {
|
|
3183
|
+
const d = l[0];
|
|
3184
|
+
d === "canvas-stage" ? h = [] : h = [
|
|
3185
3185
|
{
|
|
3186
3186
|
label: "置顶",
|
|
3187
3187
|
action: () => {
|
|
@@ -3208,20 +3208,20 @@ function Yo(n) {
|
|
|
3208
3208
|
}
|
|
3209
3209
|
];
|
|
3210
3210
|
}
|
|
3211
|
-
if (
|
|
3211
|
+
if (h.length === 0) {
|
|
3212
3212
|
t(null);
|
|
3213
3213
|
return;
|
|
3214
3214
|
}
|
|
3215
3215
|
t({
|
|
3216
3216
|
x: o,
|
|
3217
3217
|
y: a,
|
|
3218
|
-
items:
|
|
3218
|
+
items: h
|
|
3219
3219
|
});
|
|
3220
3220
|
};
|
|
3221
3221
|
return n.on("contextmenu:show", s), () => {
|
|
3222
3222
|
n.off("contextmenu:show", s);
|
|
3223
3223
|
};
|
|
3224
|
-
}, [n]),
|
|
3224
|
+
}, [n]), U(() => {
|
|
3225
3225
|
const s = () => {
|
|
3226
3226
|
i && t(null);
|
|
3227
3227
|
};
|
|
@@ -3321,9 +3321,9 @@ function Ys({
|
|
|
3321
3321
|
delay: s = 600,
|
|
3322
3322
|
closeDelay: o = 0
|
|
3323
3323
|
} = {}) {
|
|
3324
|
-
const [a,
|
|
3324
|
+
const [a, l] = $(n), h = t ?? a, d = e ?? l, m = ss({
|
|
3325
3325
|
placement: i,
|
|
3326
|
-
open:
|
|
3326
|
+
open: h,
|
|
3327
3327
|
onOpenChange: d,
|
|
3328
3328
|
whileElementsMounted: ls,
|
|
3329
3329
|
middleware: [
|
|
@@ -3335,7 +3335,7 @@ function Ys({
|
|
|
3335
3335
|
}),
|
|
3336
3336
|
as({ padding: 4 })
|
|
3337
3337
|
]
|
|
3338
|
-
}),
|
|
3338
|
+
}), f = m.context, g = hs(f, {
|
|
3339
3339
|
mouseOnly: !0,
|
|
3340
3340
|
move: !1,
|
|
3341
3341
|
restMs: s,
|
|
@@ -3343,17 +3343,17 @@ function Ys({
|
|
|
3343
3343
|
delay: {
|
|
3344
3344
|
close: o
|
|
3345
3345
|
}
|
|
3346
|
-
}), y = cs(
|
|
3346
|
+
}), y = cs(f, {
|
|
3347
3347
|
enabled: t == null
|
|
3348
|
-
}),
|
|
3348
|
+
}), x = ds(f), v = gs(f, { role: "tooltip" }), I = us([g, y, x, v]);
|
|
3349
3349
|
return St(
|
|
3350
3350
|
() => ({
|
|
3351
|
-
open:
|
|
3351
|
+
open: h,
|
|
3352
3352
|
setOpen: d,
|
|
3353
3353
|
...I,
|
|
3354
|
-
...
|
|
3354
|
+
...m
|
|
3355
3355
|
}),
|
|
3356
|
-
[
|
|
3356
|
+
[h, d, I, m]
|
|
3357
3357
|
);
|
|
3358
3358
|
}
|
|
3359
3359
|
const Ve = Rn(null);
|
|
@@ -3374,7 +3374,7 @@ function Ji({ children: n, ...i }) {
|
|
|
3374
3374
|
}
|
|
3375
3375
|
) : /* @__PURE__ */ c(Ve.Provider, { value: t, children: n });
|
|
3376
3376
|
}
|
|
3377
|
-
const Qi =
|
|
3377
|
+
const Qi = A(
|
|
3378
3378
|
function({ children: i, asChild: t = !1, ...e }, s) {
|
|
3379
3379
|
const o = ji(), a = li(i) ? parseInt($n, 10) >= 19 ? (
|
|
3380
3380
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -3382,44 +3382,44 @@ const Qi = $(
|
|
|
3382
3382
|
) : (
|
|
3383
3383
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3384
3384
|
i.ref
|
|
3385
|
-
) : void 0,
|
|
3385
|
+
) : void 0, l = Ni([o.refs.setReference, s, a]);
|
|
3386
3386
|
if (t && li(i)) {
|
|
3387
|
-
const
|
|
3387
|
+
const h = {
|
|
3388
3388
|
"data-tooltip-state": o.open ? "open" : "closed"
|
|
3389
3389
|
};
|
|
3390
3390
|
return An(
|
|
3391
3391
|
i,
|
|
3392
3392
|
o.getReferenceProps({
|
|
3393
|
-
ref:
|
|
3393
|
+
ref: l,
|
|
3394
3394
|
...e,
|
|
3395
3395
|
...typeof i.props == "object" ? i.props : {},
|
|
3396
|
-
...
|
|
3396
|
+
...h
|
|
3397
3397
|
})
|
|
3398
3398
|
);
|
|
3399
3399
|
}
|
|
3400
3400
|
return /* @__PURE__ */ c(
|
|
3401
3401
|
"button",
|
|
3402
3402
|
{
|
|
3403
|
-
ref:
|
|
3403
|
+
ref: l,
|
|
3404
3404
|
"data-tooltip-state": o.open ? "open" : "closed",
|
|
3405
3405
|
...o.getReferenceProps(e),
|
|
3406
3406
|
children: i
|
|
3407
3407
|
}
|
|
3408
3408
|
);
|
|
3409
3409
|
}
|
|
3410
|
-
), tn =
|
|
3410
|
+
), tn = A(
|
|
3411
3411
|
function({ style: i, children: t, portal: e = !0, portalProps: s = {}, ...o }, a) {
|
|
3412
|
-
const
|
|
3413
|
-
if (!
|
|
3412
|
+
const l = ji(), h = Ni([l.refs.setFloating, a]);
|
|
3413
|
+
if (!l.open) return null;
|
|
3414
3414
|
const d = /* @__PURE__ */ c(
|
|
3415
3415
|
"div",
|
|
3416
3416
|
{
|
|
3417
|
-
ref:
|
|
3417
|
+
ref: h,
|
|
3418
3418
|
style: {
|
|
3419
|
-
...
|
|
3419
|
+
...l.floatingStyles,
|
|
3420
3420
|
...i
|
|
3421
3421
|
},
|
|
3422
|
-
...
|
|
3422
|
+
...l.getFloatingProps(o),
|
|
3423
3423
|
className: "tiptap-tooltip",
|
|
3424
3424
|
children: t
|
|
3425
3425
|
}
|
|
@@ -3435,7 +3435,7 @@ const Gs = ({
|
|
|
3435
3435
|
}) => n.length === 0 ? null : /* @__PURE__ */ c("div", { children: n.map((i, t) => /* @__PURE__ */ k(Hn, { children: [
|
|
3436
3436
|
t > 0 && /* @__PURE__ */ c("kbd", { children: "+" }),
|
|
3437
3437
|
/* @__PURE__ */ c("kbd", { children: i })
|
|
3438
|
-
] }, t)) }), vt =
|
|
3438
|
+
] }, t)) }), vt = A(
|
|
3439
3439
|
({
|
|
3440
3440
|
className: n,
|
|
3441
3441
|
children: i,
|
|
@@ -3444,8 +3444,8 @@ const Gs = ({
|
|
|
3444
3444
|
shortcutKeys: s,
|
|
3445
3445
|
variant: o,
|
|
3446
3446
|
size: a,
|
|
3447
|
-
...
|
|
3448
|
-
},
|
|
3447
|
+
...l
|
|
3448
|
+
}, h) => {
|
|
3449
3449
|
const d = St(
|
|
3450
3450
|
() => ke({ shortcutKeys: s }),
|
|
3451
3451
|
[s]
|
|
@@ -3454,10 +3454,10 @@ const Gs = ({
|
|
|
3454
3454
|
"button",
|
|
3455
3455
|
{
|
|
3456
3456
|
className: nt("tiptap-button", n),
|
|
3457
|
-
ref:
|
|
3457
|
+
ref: h,
|
|
3458
3458
|
"data-style": o,
|
|
3459
3459
|
"data-size": a,
|
|
3460
|
-
...
|
|
3460
|
+
...l,
|
|
3461
3461
|
children: i
|
|
3462
3462
|
}
|
|
3463
3463
|
) : /* @__PURE__ */ k(Ji, { delay: 200, children: [
|
|
@@ -3465,10 +3465,10 @@ const Gs = ({
|
|
|
3465
3465
|
Qi,
|
|
3466
3466
|
{
|
|
3467
3467
|
className: nt("tiptap-button", n),
|
|
3468
|
-
ref:
|
|
3468
|
+
ref: h,
|
|
3469
3469
|
"data-style": o,
|
|
3470
3470
|
"data-size": a,
|
|
3471
|
-
...
|
|
3471
|
+
...l,
|
|
3472
3472
|
children: i
|
|
3473
3473
|
}
|
|
3474
3474
|
),
|
|
@@ -3480,7 +3480,7 @@ const Gs = ({
|
|
|
3480
3480
|
}
|
|
3481
3481
|
);
|
|
3482
3482
|
vt.displayName = "Button";
|
|
3483
|
-
const Ht =
|
|
3483
|
+
const Ht = A(({ className: n, children: i, orientation: t = "vertical", ...e }, s) => /* @__PURE__ */ c(
|
|
3484
3484
|
"div",
|
|
3485
3485
|
{
|
|
3486
3486
|
ref: s,
|
|
@@ -3492,7 +3492,7 @@ const Ht = $(({ className: n, children: i, orientation: t = "vertical", ...e },
|
|
|
3492
3492
|
}
|
|
3493
3493
|
));
|
|
3494
3494
|
Ht.displayName = "ButtonGroup";
|
|
3495
|
-
const Re =
|
|
3495
|
+
const Re = A(
|
|
3496
3496
|
({
|
|
3497
3497
|
variant: n,
|
|
3498
3498
|
size: i = "default",
|
|
@@ -3501,10 +3501,10 @@ const Re = $(
|
|
|
3501
3501
|
className: s,
|
|
3502
3502
|
children: o,
|
|
3503
3503
|
...a
|
|
3504
|
-
},
|
|
3504
|
+
}, l) => /* @__PURE__ */ c(
|
|
3505
3505
|
"div",
|
|
3506
3506
|
{
|
|
3507
|
-
ref:
|
|
3507
|
+
ref: l,
|
|
3508
3508
|
className: `tiptap-badge ${s || ""}`,
|
|
3509
3509
|
"data-style": n,
|
|
3510
3510
|
"data-size": i,
|
|
@@ -3522,7 +3522,7 @@ function Ks({
|
|
|
3522
3522
|
}) {
|
|
3523
3523
|
return /* @__PURE__ */ c(Re, { children: ke({ shortcutKeys: i }) });
|
|
3524
3524
|
}
|
|
3525
|
-
const At =
|
|
3525
|
+
const At = A(
|
|
3526
3526
|
({
|
|
3527
3527
|
editor: n,
|
|
3528
3528
|
type: i,
|
|
@@ -3531,55 +3531,55 @@ const At = $(
|
|
|
3531
3531
|
onToggled: s,
|
|
3532
3532
|
showShortcut: o = !1,
|
|
3533
3533
|
onClick: a,
|
|
3534
|
-
children:
|
|
3535
|
-
...
|
|
3534
|
+
children: l,
|
|
3535
|
+
...h
|
|
3536
3536
|
}, d) => {
|
|
3537
|
-
const { editor:
|
|
3538
|
-
isVisible:
|
|
3539
|
-
handleMark:
|
|
3537
|
+
const { editor: m } = yt(n), {
|
|
3538
|
+
isVisible: f,
|
|
3539
|
+
handleMark: g,
|
|
3540
3540
|
label: y,
|
|
3541
|
-
canToggle:
|
|
3541
|
+
canToggle: x,
|
|
3542
3542
|
isActive: v,
|
|
3543
3543
|
Icon: I,
|
|
3544
|
-
shortcutKeys:
|
|
3544
|
+
shortcutKeys: w
|
|
3545
3545
|
} = eo({
|
|
3546
|
-
editor:
|
|
3546
|
+
editor: m,
|
|
3547
3547
|
type: i,
|
|
3548
3548
|
hideWhenUnavailable: e,
|
|
3549
3549
|
onToggled: s
|
|
3550
|
-
}),
|
|
3551
|
-
(
|
|
3552
|
-
a?.(
|
|
3550
|
+
}), z = Q(
|
|
3551
|
+
(X) => {
|
|
3552
|
+
a?.(X), !X.defaultPrevented && g();
|
|
3553
3553
|
},
|
|
3554
|
-
[
|
|
3554
|
+
[g, a]
|
|
3555
3555
|
);
|
|
3556
|
-
return
|
|
3556
|
+
return f ? /* @__PURE__ */ c(
|
|
3557
3557
|
vt,
|
|
3558
3558
|
{
|
|
3559
3559
|
type: "button",
|
|
3560
|
-
disabled: !
|
|
3560
|
+
disabled: !x,
|
|
3561
3561
|
variant: "ghost",
|
|
3562
3562
|
"data-active-state": v ? "on" : "off",
|
|
3563
|
-
"data-disabled": !
|
|
3563
|
+
"data-disabled": !x,
|
|
3564
3564
|
role: "button",
|
|
3565
3565
|
tabIndex: -1,
|
|
3566
3566
|
"aria-label": y,
|
|
3567
3567
|
"aria-pressed": v,
|
|
3568
3568
|
tooltip: y,
|
|
3569
|
-
onClick:
|
|
3570
|
-
...
|
|
3569
|
+
onClick: z,
|
|
3570
|
+
...h,
|
|
3571
3571
|
ref: d,
|
|
3572
|
-
children:
|
|
3572
|
+
children: l ?? /* @__PURE__ */ k(Ie, { children: [
|
|
3573
3573
|
/* @__PURE__ */ c(I, { className: "tiptap-button-icon" }),
|
|
3574
3574
|
t && /* @__PURE__ */ c("span", { className: "tiptap-button-text", children: t }),
|
|
3575
|
-
o && /* @__PURE__ */ c(Ks, { type: i, shortcutKeys:
|
|
3575
|
+
o && /* @__PURE__ */ c(Ks, { type: i, shortcutKeys: w })
|
|
3576
3576
|
] })
|
|
3577
3577
|
}
|
|
3578
3578
|
) : null;
|
|
3579
3579
|
}
|
|
3580
3580
|
);
|
|
3581
3581
|
At.displayName = "MarkButton";
|
|
3582
|
-
const en =
|
|
3582
|
+
const en = dt(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3583
3583
|
"svg",
|
|
3584
3584
|
{
|
|
3585
3585
|
width: "24",
|
|
@@ -3601,7 +3601,7 @@ const en = ct(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
|
3601
3601
|
}
|
|
3602
3602
|
));
|
|
3603
3603
|
en.displayName = "BoldIcon";
|
|
3604
|
-
const nn =
|
|
3604
|
+
const nn = dt(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
3605
3605
|
"svg",
|
|
3606
3606
|
{
|
|
3607
3607
|
width: "24",
|
|
@@ -3637,7 +3637,7 @@ const nn = ct(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
|
3637
3637
|
}
|
|
3638
3638
|
));
|
|
3639
3639
|
nn.displayName = "Code2Icon";
|
|
3640
|
-
const sn =
|
|
3640
|
+
const sn = dt(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3641
3641
|
"svg",
|
|
3642
3642
|
{
|
|
3643
3643
|
width: "24",
|
|
@@ -3657,7 +3657,7 @@ const sn = ct(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
|
3657
3657
|
}
|
|
3658
3658
|
));
|
|
3659
3659
|
sn.displayName = "ItalicIcon";
|
|
3660
|
-
const on =
|
|
3660
|
+
const on = dt(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
3661
3661
|
"svg",
|
|
3662
3662
|
{
|
|
3663
3663
|
width: "24",
|
|
@@ -3686,7 +3686,7 @@ const on = ct(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
|
3686
3686
|
}
|
|
3687
3687
|
));
|
|
3688
3688
|
on.displayName = "StrikeIcon";
|
|
3689
|
-
const rn =
|
|
3689
|
+
const rn = dt(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
3690
3690
|
"svg",
|
|
3691
3691
|
{
|
|
3692
3692
|
width: "24",
|
|
@@ -3728,7 +3728,7 @@ const rn = ct(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
|
3728
3728
|
}
|
|
3729
3729
|
));
|
|
3730
3730
|
rn.displayName = "SubscriptIcon";
|
|
3731
|
-
const an =
|
|
3731
|
+
const an = dt(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
3732
3732
|
"svg",
|
|
3733
3733
|
{
|
|
3734
3734
|
width: "24",
|
|
@@ -3770,7 +3770,7 @@ const an = ct(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
|
3770
3770
|
}
|
|
3771
3771
|
));
|
|
3772
3772
|
an.displayName = "SuperscriptIcon";
|
|
3773
|
-
const ln =
|
|
3773
|
+
const ln = dt(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3774
3774
|
"svg",
|
|
3775
3775
|
{
|
|
3776
3776
|
width: "24",
|
|
@@ -3831,26 +3831,26 @@ function eo(n) {
|
|
|
3831
3831
|
type: t,
|
|
3832
3832
|
hideWhenUnavailable: e = !1,
|
|
3833
3833
|
onToggled: s
|
|
3834
|
-
} = n, { editor: o } = yt(i), [a,
|
|
3835
|
-
|
|
3834
|
+
} = n, { editor: o } = yt(i), [a, l] = $(!0), h = We(o, t), d = js(o, t);
|
|
3835
|
+
U(() => {
|
|
3836
3836
|
if (!o) return;
|
|
3837
|
-
const
|
|
3838
|
-
|
|
3837
|
+
const f = () => {
|
|
3838
|
+
l(Qs({ editor: o, type: t, hideWhenUnavailable: e }));
|
|
3839
3839
|
};
|
|
3840
|
-
return
|
|
3841
|
-
o.off("selectionUpdate",
|
|
3840
|
+
return f(), o.on("selectionUpdate", f), () => {
|
|
3841
|
+
o.off("selectionUpdate", f);
|
|
3842
3842
|
};
|
|
3843
3843
|
}, [o, t, e]);
|
|
3844
|
-
const
|
|
3844
|
+
const m = Q(() => {
|
|
3845
3845
|
if (!o) return !1;
|
|
3846
|
-
const
|
|
3847
|
-
return
|
|
3846
|
+
const f = Js(o, t);
|
|
3847
|
+
return f && s?.(), f;
|
|
3848
3848
|
}, [o, t, s]);
|
|
3849
3849
|
return {
|
|
3850
3850
|
isVisible: a,
|
|
3851
3851
|
isActive: d,
|
|
3852
|
-
handleMark:
|
|
3853
|
-
canToggle:
|
|
3852
|
+
handleMark: m,
|
|
3853
|
+
canToggle: h,
|
|
3854
3854
|
label: to(t),
|
|
3855
3855
|
shortcutKeys: hn[t],
|
|
3856
3856
|
Icon: qs[t]
|
|
@@ -3864,44 +3864,44 @@ function cn({
|
|
|
3864
3864
|
onSelect: s,
|
|
3865
3865
|
onClose: o,
|
|
3866
3866
|
orientation: a = "vertical",
|
|
3867
|
-
autoSelectFirstItem:
|
|
3867
|
+
autoSelectFirstItem: l = !0
|
|
3868
3868
|
}) {
|
|
3869
|
-
const [
|
|
3870
|
-
|
|
3869
|
+
const [h, d] = $(
|
|
3870
|
+
l ? 0 : -1
|
|
3871
3871
|
);
|
|
3872
|
-
return
|
|
3873
|
-
const
|
|
3872
|
+
return U(() => {
|
|
3873
|
+
const m = (g) => {
|
|
3874
3874
|
if (!e.length) return !1;
|
|
3875
|
-
const y = () => d((v) => v === -1 ? 0 : (v + 1) % e.length),
|
|
3876
|
-
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) {
|
|
3877
3877
|
case "ArrowUp":
|
|
3878
|
-
return a === "horizontal" ? !1 : (
|
|
3878
|
+
return a === "horizontal" ? !1 : (g.preventDefault(), x(), !0);
|
|
3879
3879
|
case "ArrowDown":
|
|
3880
|
-
return a === "horizontal" ? !1 : (
|
|
3880
|
+
return a === "horizontal" ? !1 : (g.preventDefault(), y(), !0);
|
|
3881
3881
|
case "ArrowLeft":
|
|
3882
|
-
return a === "vertical" ? !1 : (
|
|
3882
|
+
return a === "vertical" ? !1 : (g.preventDefault(), x(), !0);
|
|
3883
3883
|
case "ArrowRight":
|
|
3884
|
-
return a === "vertical" ? !1 : (
|
|
3884
|
+
return a === "vertical" ? !1 : (g.preventDefault(), y(), !0);
|
|
3885
3885
|
case "Tab":
|
|
3886
|
-
return
|
|
3886
|
+
return g.preventDefault(), g.shiftKey ? x() : y(), !0;
|
|
3887
3887
|
case "Home":
|
|
3888
|
-
return
|
|
3888
|
+
return g.preventDefault(), d(0), !0;
|
|
3889
3889
|
case "End":
|
|
3890
|
-
return
|
|
3890
|
+
return g.preventDefault(), d(e.length - 1), !0;
|
|
3891
3891
|
case "Enter":
|
|
3892
|
-
return
|
|
3892
|
+
return g.isComposing ? !1 : (g.preventDefault(), h !== -1 && e[h] && s?.(e[h]), !0);
|
|
3893
3893
|
case "Escape":
|
|
3894
|
-
return
|
|
3894
|
+
return g.preventDefault(), o?.(), !0;
|
|
3895
3895
|
default:
|
|
3896
3896
|
return !1;
|
|
3897
3897
|
}
|
|
3898
3898
|
};
|
|
3899
|
-
let
|
|
3900
|
-
if (n ?
|
|
3901
|
-
return
|
|
3902
|
-
|
|
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(
|
|
3903
3903
|
"keydown",
|
|
3904
|
-
|
|
3904
|
+
m,
|
|
3905
3905
|
!0
|
|
3906
3906
|
);
|
|
3907
3907
|
};
|
|
@@ -3909,25 +3909,25 @@ function cn({
|
|
|
3909
3909
|
n,
|
|
3910
3910
|
i,
|
|
3911
3911
|
e,
|
|
3912
|
-
|
|
3912
|
+
h,
|
|
3913
3913
|
s,
|
|
3914
3914
|
o,
|
|
3915
3915
|
a
|
|
3916
|
-
]),
|
|
3917
|
-
t && d(
|
|
3918
|
-
}, [t,
|
|
3919
|
-
selectedIndex: e.length ?
|
|
3916
|
+
]), U(() => {
|
|
3917
|
+
t && d(l ? 0 : -1);
|
|
3918
|
+
}, [t, l]), {
|
|
3919
|
+
selectedIndex: e.length ? h : void 0,
|
|
3920
3920
|
setSelectedIndex: d
|
|
3921
3921
|
};
|
|
3922
3922
|
}
|
|
3923
3923
|
function $e(n = "max", i = 768) {
|
|
3924
|
-
const [t, e] =
|
|
3925
|
-
return
|
|
3926
|
-
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);
|
|
3927
3927
|
return e(o.matches), o.addEventListener("change", a), () => o.removeEventListener("change", a);
|
|
3928
3928
|
}, [n, i]), !!t;
|
|
3929
3929
|
}
|
|
3930
|
-
const Xe =
|
|
3930
|
+
const Xe = dt(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3931
3931
|
"svg",
|
|
3932
3932
|
{
|
|
3933
3933
|
width: "24",
|
|
@@ -3949,7 +3949,7 @@ const Xe = ct(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
|
3949
3949
|
}
|
|
3950
3950
|
));
|
|
3951
3951
|
Xe.displayName = "BanIcon";
|
|
3952
|
-
const Ye =
|
|
3952
|
+
const Ye = dt(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3953
3953
|
"svg",
|
|
3954
3954
|
{
|
|
3955
3955
|
width: "24",
|
|
@@ -3998,7 +3998,7 @@ function un({
|
|
|
3998
3998
|
}
|
|
3999
3999
|
) });
|
|
4000
4000
|
}
|
|
4001
|
-
const Ge =
|
|
4001
|
+
const Ge = A(
|
|
4002
4002
|
({ decorative: n, orientation: i = "vertical", className: t, ...e }, s) => {
|
|
4003
4003
|
const a = n ? { role: "none" } : { "aria-orientation": i === "vertical" ? i : void 0, role: "separator" };
|
|
4004
4004
|
return /* @__PURE__ */ c(
|
|
@@ -4014,11 +4014,11 @@ const Ge = $(
|
|
|
4014
4014
|
}
|
|
4015
4015
|
);
|
|
4016
4016
|
Ge.displayName = "Separator";
|
|
4017
|
-
const Ke =
|
|
4017
|
+
const Ke = A(
|
|
4018
4018
|
({ className: n, ...i }, t) => /* @__PURE__ */ c("div", { ref: t, className: nt("tiptap-card", n), ...i })
|
|
4019
4019
|
);
|
|
4020
4020
|
Ke.displayName = "Card";
|
|
4021
|
-
const io =
|
|
4021
|
+
const io = A(
|
|
4022
4022
|
({ className: n, ...i }, t) => /* @__PURE__ */ c(
|
|
4023
4023
|
"div",
|
|
4024
4024
|
{
|
|
@@ -4029,11 +4029,11 @@ const io = $(
|
|
|
4029
4029
|
)
|
|
4030
4030
|
);
|
|
4031
4031
|
io.displayName = "CardHeader";
|
|
4032
|
-
const qe =
|
|
4032
|
+
const qe = A(
|
|
4033
4033
|
({ className: n, ...i }, t) => /* @__PURE__ */ c("div", { ref: t, className: nt("tiptap-card-body", n), ...i })
|
|
4034
4034
|
);
|
|
4035
4035
|
qe.displayName = "CardBody";
|
|
4036
|
-
const je =
|
|
4036
|
+
const je = A(({ className: n, orientation: i = "vertical", ...t }, e) => /* @__PURE__ */ c(
|
|
4037
4037
|
"div",
|
|
4038
4038
|
{
|
|
4039
4039
|
ref: e,
|
|
@@ -4043,7 +4043,7 @@ const je = $(({ className: n, orientation: i = "vertical", ...t }, e) => /* @__P
|
|
|
4043
4043
|
}
|
|
4044
4044
|
));
|
|
4045
4045
|
je.displayName = "CardItemGroup";
|
|
4046
|
-
const no =
|
|
4046
|
+
const no = A(
|
|
4047
4047
|
({ className: n, ...i }, t) => /* @__PURE__ */ c(
|
|
4048
4048
|
"div",
|
|
4049
4049
|
{
|
|
@@ -4054,7 +4054,7 @@ const no = $(
|
|
|
4054
4054
|
)
|
|
4055
4055
|
);
|
|
4056
4056
|
no.displayName = "CardGroupLabel";
|
|
4057
|
-
const so =
|
|
4057
|
+
const so = A(
|
|
4058
4058
|
({ className: n, ...i }, t) => /* @__PURE__ */ c(
|
|
4059
4059
|
"div",
|
|
4060
4060
|
{
|
|
@@ -4070,7 +4070,7 @@ function oo({
|
|
|
4070
4070
|
}) {
|
|
4071
4071
|
return /* @__PURE__ */ c(Re, { children: ke({ shortcutKeys: n }) });
|
|
4072
4072
|
}
|
|
4073
|
-
const mn =
|
|
4073
|
+
const mn = A(
|
|
4074
4074
|
({
|
|
4075
4075
|
editor: n,
|
|
4076
4076
|
highlightColor: i,
|
|
@@ -4079,40 +4079,40 @@ const mn = $(
|
|
|
4079
4079
|
mode: s = "mark",
|
|
4080
4080
|
onApplied: o,
|
|
4081
4081
|
showShortcut: a = !1,
|
|
4082
|
-
onClick:
|
|
4083
|
-
children:
|
|
4082
|
+
onClick: l,
|
|
4083
|
+
children: h,
|
|
4084
4084
|
style: d,
|
|
4085
|
-
useColorValue:
|
|
4086
|
-
...
|
|
4087
|
-
},
|
|
4085
|
+
useColorValue: m = !1,
|
|
4086
|
+
...f
|
|
4087
|
+
}, g) => {
|
|
4088
4088
|
const { editor: y } = yt(n), {
|
|
4089
|
-
isVisible:
|
|
4089
|
+
isVisible: x,
|
|
4090
4090
|
canColorHighlight: v,
|
|
4091
4091
|
isActive: I,
|
|
4092
|
-
handleColorHighlight:
|
|
4093
|
-
label:
|
|
4094
|
-
shortcutKeys:
|
|
4092
|
+
handleColorHighlight: w,
|
|
4093
|
+
label: z,
|
|
4094
|
+
shortcutKeys: X
|
|
4095
4095
|
} = Qe({
|
|
4096
4096
|
editor: y,
|
|
4097
4097
|
highlightColor: i,
|
|
4098
|
-
useColorValue:
|
|
4098
|
+
useColorValue: m,
|
|
4099
4099
|
label: t || `Toggle highlight (${i})`,
|
|
4100
4100
|
hideWhenUnavailable: e,
|
|
4101
4101
|
mode: s,
|
|
4102
4102
|
onApplied: o
|
|
4103
|
-
}),
|
|
4103
|
+
}), R = Q(
|
|
4104
4104
|
(Ct) => {
|
|
4105
|
-
|
|
4105
|
+
l?.(Ct), !Ct.defaultPrevented && (w(), Ct.preventDefault(), Ct.stopPropagation());
|
|
4106
4106
|
},
|
|
4107
|
-
[
|
|
4108
|
-
),
|
|
4107
|
+
[w, l]
|
|
4108
|
+
), F = St(
|
|
4109
4109
|
() => ({
|
|
4110
4110
|
...d,
|
|
4111
4111
|
"--highlight-color": i
|
|
4112
4112
|
}),
|
|
4113
4113
|
[i, d]
|
|
4114
4114
|
);
|
|
4115
|
-
return
|
|
4115
|
+
return x ? /* @__PURE__ */ c(
|
|
4116
4116
|
vt,
|
|
4117
4117
|
{
|
|
4118
4118
|
type: "button",
|
|
@@ -4122,14 +4122,14 @@ const mn = $(
|
|
|
4122
4122
|
tabIndex: -1,
|
|
4123
4123
|
disabled: !v,
|
|
4124
4124
|
"data-disabled": !v,
|
|
4125
|
-
"aria-label":
|
|
4125
|
+
"aria-label": z,
|
|
4126
4126
|
"aria-pressed": I,
|
|
4127
|
-
tooltip:
|
|
4128
|
-
onClick:
|
|
4129
|
-
style:
|
|
4130
|
-
...
|
|
4131
|
-
ref:
|
|
4132
|
-
children:
|
|
4127
|
+
tooltip: z,
|
|
4128
|
+
onClick: R,
|
|
4129
|
+
style: F,
|
|
4130
|
+
...f,
|
|
4131
|
+
ref: g,
|
|
4132
|
+
children: h ?? /* @__PURE__ */ k(Ie, { children: [
|
|
4133
4133
|
/* @__PURE__ */ c(
|
|
4134
4134
|
"span",
|
|
4135
4135
|
{
|
|
@@ -4138,7 +4138,7 @@ const mn = $(
|
|
|
4138
4138
|
}
|
|
4139
4139
|
),
|
|
4140
4140
|
t && /* @__PURE__ */ c("span", { className: "tiptap-button-text", children: t }),
|
|
4141
|
-
a && /* @__PURE__ */ c(oo, { shortcutKeys:
|
|
4141
|
+
a && /* @__PURE__ */ c(oo, { shortcutKeys: X })
|
|
4142
4142
|
] })
|
|
4143
4143
|
}
|
|
4144
4144
|
) : null;
|
|
@@ -4237,8 +4237,8 @@ function ao(n, i, t = "mark") {
|
|
|
4237
4237
|
try {
|
|
4238
4238
|
const { state: e } = n, { selection: s } = e, o = s.$anchor;
|
|
4239
4239
|
for (let a = o.depth; a >= 0; a--) {
|
|
4240
|
-
const
|
|
4241
|
-
if (
|
|
4240
|
+
const l = o.node(a);
|
|
4241
|
+
if (l && l.attrs?.backgroundColor === i)
|
|
4242
4242
|
return !0;
|
|
4243
4243
|
}
|
|
4244
4244
|
return !1;
|
|
@@ -4267,62 +4267,62 @@ function Qe(n) {
|
|
|
4267
4267
|
hideWhenUnavailable: s = !1,
|
|
4268
4268
|
mode: o = "mark",
|
|
4269
4269
|
useColorValue: a = !1,
|
|
4270
|
-
onApplied:
|
|
4271
|
-
} = n, { editor:
|
|
4272
|
-
|
|
4273
|
-
if (!
|
|
4274
|
-
const
|
|
4275
|
-
|
|
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 }));
|
|
4276
4276
|
};
|
|
4277
|
-
return
|
|
4278
|
-
|
|
4277
|
+
return w(), h.on("selectionUpdate", w), () => {
|
|
4278
|
+
h.off("selectionUpdate", w);
|
|
4279
4279
|
};
|
|
4280
|
-
}, [
|
|
4281
|
-
const v =
|
|
4282
|
-
if (!
|
|
4280
|
+
}, [h, s, o]);
|
|
4281
|
+
const v = Q(() => {
|
|
4282
|
+
if (!h || !g || !y || !t)
|
|
4283
4283
|
return !1;
|
|
4284
4284
|
if (o === "mark") {
|
|
4285
|
-
if (
|
|
4286
|
-
const
|
|
4287
|
-
|
|
4288
|
-
|
|
4285
|
+
if (h.state.storedMarks) {
|
|
4286
|
+
const w = h.schema.marks.highlight;
|
|
4287
|
+
w && h.view.dispatch(
|
|
4288
|
+
h.state.tr.removeStoredMark(w)
|
|
4289
4289
|
);
|
|
4290
4290
|
}
|
|
4291
4291
|
return setTimeout(() => {
|
|
4292
|
-
const
|
|
4293
|
-
return
|
|
4292
|
+
const w = h.chain().focus().toggleHighlight({ color: y }).run();
|
|
4293
|
+
return w && l?.({ color: y, label: t, mode: o }), w;
|
|
4294
4294
|
}, 0), !0;
|
|
4295
4295
|
} else {
|
|
4296
|
-
const
|
|
4297
|
-
return
|
|
4296
|
+
const w = h.chain().focus().toggleNodeBackgroundColor(y).run();
|
|
4297
|
+
return w && l?.({ color: y, label: t, mode: o }), w;
|
|
4298
4298
|
}
|
|
4299
|
-
}, [
|
|
4300
|
-
const
|
|
4301
|
-
return
|
|
4302
|
-
}, [
|
|
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]);
|
|
4303
4303
|
return Ti(
|
|
4304
4304
|
Oe,
|
|
4305
|
-
(
|
|
4306
|
-
|
|
4305
|
+
(w) => {
|
|
4306
|
+
w.preventDefault(), v();
|
|
4307
4307
|
},
|
|
4308
4308
|
{
|
|
4309
|
-
enabled:
|
|
4309
|
+
enabled: m && g,
|
|
4310
4310
|
enableOnContentEditable: !d,
|
|
4311
4311
|
enableOnFormTags: !0
|
|
4312
4312
|
}
|
|
4313
4313
|
), {
|
|
4314
|
-
isVisible:
|
|
4315
|
-
isActive:
|
|
4314
|
+
isVisible: m,
|
|
4315
|
+
isActive: x,
|
|
4316
4316
|
handleColorHighlight: v,
|
|
4317
4317
|
handleRemoveHighlight: I,
|
|
4318
|
-
canColorHighlight:
|
|
4318
|
+
canColorHighlight: g,
|
|
4319
4319
|
label: t || "Highlight",
|
|
4320
4320
|
shortcutKeys: Oe,
|
|
4321
4321
|
Icon: Ye,
|
|
4322
4322
|
mode: o
|
|
4323
4323
|
};
|
|
4324
4324
|
}
|
|
4325
|
-
const yn =
|
|
4325
|
+
const yn = A(({ className: n, children: i, ...t }, e) => /* @__PURE__ */ c(
|
|
4326
4326
|
vt,
|
|
4327
4327
|
{
|
|
4328
4328
|
type: "button",
|
|
@@ -4353,16 +4353,16 @@ function co({
|
|
|
4353
4353
|
const { handleRemoveHighlight: e } = Qe({ editor: n }), s = $e(), o = Ue(null), a = St(
|
|
4354
4354
|
() => [...i, { label: "Remove highlight", value: "none" }],
|
|
4355
4355
|
[i]
|
|
4356
|
-
), { selectedIndex:
|
|
4356
|
+
), { selectedIndex: l } = cn({
|
|
4357
4357
|
containerRef: o,
|
|
4358
4358
|
items: a,
|
|
4359
4359
|
orientation: "both",
|
|
4360
|
-
onSelect: (
|
|
4360
|
+
onSelect: (h) => {
|
|
4361
4361
|
if (!o.current) return !1;
|
|
4362
4362
|
const d = o.current.querySelector(
|
|
4363
4363
|
'[data-highlighted="true"]'
|
|
4364
4364
|
);
|
|
4365
|
-
return d && d.click(),
|
|
4365
|
+
return d && d.click(), h.value === "none" && e(), !0;
|
|
4366
4366
|
},
|
|
4367
4367
|
autoSelectFirstItem: !1
|
|
4368
4368
|
});
|
|
@@ -4373,18 +4373,18 @@ function co({
|
|
|
4373
4373
|
tabIndex: 0,
|
|
4374
4374
|
style: s ? { boxShadow: "none", border: 0 } : {},
|
|
4375
4375
|
children: /* @__PURE__ */ c(qe, { style: s ? { padding: 0 } : {}, children: /* @__PURE__ */ k(je, { orientation: "horizontal", children: [
|
|
4376
|
-
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: i.map((
|
|
4376
|
+
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: i.map((h, d) => /* @__PURE__ */ c(
|
|
4377
4377
|
mn,
|
|
4378
4378
|
{
|
|
4379
4379
|
editor: n,
|
|
4380
|
-
highlightColor: t ?
|
|
4381
|
-
tooltip:
|
|
4382
|
-
"aria-label": `${
|
|
4383
|
-
tabIndex: d ===
|
|
4384
|
-
"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,
|
|
4385
4385
|
useColorValue: t
|
|
4386
4386
|
},
|
|
4387
|
-
|
|
4387
|
+
h.value
|
|
4388
4388
|
)) }),
|
|
4389
4389
|
/* @__PURE__ */ c(Ge, {}),
|
|
4390
4390
|
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: /* @__PURE__ */ c(
|
|
@@ -4393,11 +4393,11 @@ function co({
|
|
|
4393
4393
|
onClick: e,
|
|
4394
4394
|
"aria-label": "Remove highlight",
|
|
4395
4395
|
tooltip: "Remove highlight",
|
|
4396
|
-
tabIndex:
|
|
4396
|
+
tabIndex: l === i.length ? 0 : -1,
|
|
4397
4397
|
type: "button",
|
|
4398
4398
|
role: "menuitem",
|
|
4399
4399
|
variant: "ghost",
|
|
4400
|
-
"data-highlighted":
|
|
4400
|
+
"data-highlighted": l === i.length,
|
|
4401
4401
|
children: /* @__PURE__ */ c(Xe, { className: "tiptap-button-icon" })
|
|
4402
4402
|
}
|
|
4403
4403
|
) })
|
|
@@ -4419,21 +4419,21 @@ function go({
|
|
|
4419
4419
|
onApplied: s,
|
|
4420
4420
|
...o
|
|
4421
4421
|
}) {
|
|
4422
|
-
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({
|
|
4423
4423
|
editor: a,
|
|
4424
4424
|
hideWhenUnavailable: t,
|
|
4425
4425
|
onApplied: s
|
|
4426
4426
|
});
|
|
4427
|
-
return d ? /* @__PURE__ */ k(dn, { open:
|
|
4427
|
+
return d ? /* @__PURE__ */ k(dn, { open: l, onOpenChange: h, children: [
|
|
4428
4428
|
/* @__PURE__ */ c(gn, { asChild: !0, children: /* @__PURE__ */ c(
|
|
4429
4429
|
yn,
|
|
4430
4430
|
{
|
|
4431
|
-
disabled: !
|
|
4432
|
-
"data-active-state":
|
|
4433
|
-
"data-disabled": !
|
|
4434
|
-
"aria-pressed":
|
|
4435
|
-
"aria-label":
|
|
4436
|
-
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,
|
|
4437
4437
|
...o,
|
|
4438
4438
|
children: /* @__PURE__ */ c(y, { className: "tiptap-button-icon" })
|
|
4439
4439
|
}
|
|
@@ -4448,7 +4448,7 @@ function go({
|
|
|
4448
4448
|
) })
|
|
4449
4449
|
] }) : null;
|
|
4450
4450
|
}
|
|
4451
|
-
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: [
|
|
4452
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" }),
|
|
4453
4453
|
/* @__PURE__ */ c("circle", { cx: "13.5", cy: "6.5", r: ".5", fill: "currentColor" }),
|
|
4454
4454
|
/* @__PURE__ */ c("circle", { cx: "17.5", cy: "10.5", r: ".5", fill: "currentColor" }),
|
|
@@ -4461,7 +4461,7 @@ function uo({
|
|
|
4461
4461
|
}) {
|
|
4462
4462
|
return /* @__PURE__ */ c(Re, { children: ke({ shortcutKeys: n }) });
|
|
4463
4463
|
}
|
|
4464
|
-
const vn =
|
|
4464
|
+
const vn = A(
|
|
4465
4465
|
({
|
|
4466
4466
|
editor: n,
|
|
4467
4467
|
textColor: i,
|
|
@@ -4470,36 +4470,36 @@ const vn = $(
|
|
|
4470
4470
|
onApplied: s,
|
|
4471
4471
|
showShortcut: o = !1,
|
|
4472
4472
|
onClick: a,
|
|
4473
|
-
children:
|
|
4474
|
-
style:
|
|
4473
|
+
children: l,
|
|
4474
|
+
style: h,
|
|
4475
4475
|
useColorValue: d = !1,
|
|
4476
|
-
...
|
|
4477
|
-
},
|
|
4478
|
-
const { editor:
|
|
4476
|
+
...m
|
|
4477
|
+
}, f) => {
|
|
4478
|
+
const { editor: g } = yt(n), {
|
|
4479
4479
|
isVisible: y,
|
|
4480
|
-
canTextColor:
|
|
4480
|
+
canTextColor: x,
|
|
4481
4481
|
isActive: v,
|
|
4482
4482
|
handleTextColor: I,
|
|
4483
|
-
label:
|
|
4484
|
-
shortcutKeys:
|
|
4483
|
+
label: w,
|
|
4484
|
+
shortcutKeys: z
|
|
4485
4485
|
} = ii({
|
|
4486
|
-
editor:
|
|
4486
|
+
editor: g,
|
|
4487
4487
|
textColor: i,
|
|
4488
4488
|
useColorValue: d,
|
|
4489
4489
|
label: t || `Toggle text color (${i})`,
|
|
4490
4490
|
hideWhenUnavailable: e,
|
|
4491
4491
|
onApplied: s
|
|
4492
|
-
}),
|
|
4493
|
-
(
|
|
4494
|
-
a?.(
|
|
4492
|
+
}), X = Q(
|
|
4493
|
+
(F) => {
|
|
4494
|
+
a?.(F), !F.defaultPrevented && (I(), F.preventDefault(), F.stopPropagation());
|
|
4495
4495
|
},
|
|
4496
4496
|
[I, a]
|
|
4497
|
-
),
|
|
4497
|
+
), R = St(
|
|
4498
4498
|
() => ({
|
|
4499
|
-
...
|
|
4499
|
+
...h,
|
|
4500
4500
|
"--text-color": i
|
|
4501
4501
|
}),
|
|
4502
|
-
[i,
|
|
4502
|
+
[i, h]
|
|
4503
4503
|
);
|
|
4504
4504
|
return y ? /* @__PURE__ */ k(
|
|
4505
4505
|
vt,
|
|
@@ -4509,24 +4509,24 @@ const vn = $(
|
|
|
4509
4509
|
"data-active-state": v ? "on" : "off",
|
|
4510
4510
|
role: "button",
|
|
4511
4511
|
tabIndex: -1,
|
|
4512
|
-
disabled: !
|
|
4513
|
-
"data-disabled": !
|
|
4514
|
-
"aria-label":
|
|
4512
|
+
disabled: !x,
|
|
4513
|
+
"data-disabled": !x,
|
|
4514
|
+
"aria-label": w,
|
|
4515
4515
|
"aria-pressed": v,
|
|
4516
|
-
tooltip:
|
|
4517
|
-
onClick:
|
|
4518
|
-
ref:
|
|
4519
|
-
style:
|
|
4520
|
-
...
|
|
4516
|
+
tooltip: w,
|
|
4517
|
+
onClick: X,
|
|
4518
|
+
ref: f,
|
|
4519
|
+
style: R,
|
|
4520
|
+
...m,
|
|
4521
4521
|
children: [
|
|
4522
|
-
|
|
4522
|
+
l || /* @__PURE__ */ c(
|
|
4523
4523
|
"span",
|
|
4524
4524
|
{
|
|
4525
4525
|
className: "tiptap-button-text-color",
|
|
4526
4526
|
style: { "--highlight-color": i }
|
|
4527
4527
|
}
|
|
4528
4528
|
),
|
|
4529
|
-
o && /* @__PURE__ */ c(uo, { shortcutKeys:
|
|
4529
|
+
o && /* @__PURE__ */ c(uo, { shortcutKeys: z })
|
|
4530
4530
|
]
|
|
4531
4531
|
}
|
|
4532
4532
|
) : null;
|
|
@@ -4610,31 +4610,31 @@ function ii({
|
|
|
4610
4610
|
useColorValue: s = !1,
|
|
4611
4611
|
onApplied: o
|
|
4612
4612
|
} = {}) {
|
|
4613
|
-
const { editor: a } = yt(n),
|
|
4614
|
-
|
|
4613
|
+
const { editor: a } = yt(n), l = $e(), [h, d] = $(!0), [m, f] = $(!1), g = ei(a);
|
|
4614
|
+
U(() => {
|
|
4615
4615
|
if (!a) {
|
|
4616
4616
|
d(!1);
|
|
4617
4617
|
return;
|
|
4618
4618
|
}
|
|
4619
4619
|
const v = po({ editor: a, hideWhenUnavailable: e });
|
|
4620
4620
|
d(v);
|
|
4621
|
-
}, [a, e]),
|
|
4621
|
+
}, [a, e]), U(() => {
|
|
4622
4622
|
if (!a) {
|
|
4623
|
-
|
|
4623
|
+
f(!1);
|
|
4624
4624
|
return;
|
|
4625
4625
|
}
|
|
4626
4626
|
const v = () => {
|
|
4627
|
-
|
|
4627
|
+
f(Si(a, i));
|
|
4628
4628
|
};
|
|
4629
4629
|
return a.on("selectionUpdate", v), a.on("transaction", v), v(), () => {
|
|
4630
4630
|
a.off("selectionUpdate", v), a.off("transaction", v);
|
|
4631
4631
|
};
|
|
4632
4632
|
}, [a, i]);
|
|
4633
|
-
const y =
|
|
4634
|
-
if (!a || !
|
|
4633
|
+
const y = Q(() => {
|
|
4634
|
+
if (!a || !g) return;
|
|
4635
4635
|
const v = i ? mo(i, s) : "#000000";
|
|
4636
4636
|
Si(a, v) ? a.chain().focus().unsetColor().run() : (a.chain().focus().setColor(v).run(), o?.({ color: v, label: t }));
|
|
4637
|
-
}, [a, i, s, t,
|
|
4637
|
+
}, [a, i, s, t, g, o]), x = Q(() => {
|
|
4638
4638
|
fo(a);
|
|
4639
4639
|
}, [a]);
|
|
4640
4640
|
return Ti(
|
|
@@ -4643,22 +4643,22 @@ function ii({
|
|
|
4643
4643
|
v.preventDefault(), y();
|
|
4644
4644
|
},
|
|
4645
4645
|
{
|
|
4646
|
-
enabled: !
|
|
4646
|
+
enabled: !l && h && g,
|
|
4647
4647
|
enableOnFormTags: ["INPUT", "TEXTAREA", "SELECT"]
|
|
4648
4648
|
},
|
|
4649
|
-
[y,
|
|
4649
|
+
[y, l, h, g]
|
|
4650
4650
|
), {
|
|
4651
|
-
isVisible:
|
|
4652
|
-
canTextColor:
|
|
4653
|
-
isActive:
|
|
4651
|
+
isVisible: h,
|
|
4652
|
+
canTextColor: g,
|
|
4653
|
+
isActive: m,
|
|
4654
4654
|
handleTextColor: y,
|
|
4655
|
-
handleRemoveTextColor:
|
|
4655
|
+
handleRemoveTextColor: x,
|
|
4656
4656
|
label: t,
|
|
4657
4657
|
shortcutKeys: Ze,
|
|
4658
4658
|
Icon: ti
|
|
4659
4659
|
};
|
|
4660
4660
|
}
|
|
4661
|
-
const wn =
|
|
4661
|
+
const wn = A(({ className: n, children: i, ...t }, e) => /* @__PURE__ */ c(
|
|
4662
4662
|
vt,
|
|
4663
4663
|
{
|
|
4664
4664
|
type: "button",
|
|
@@ -4690,16 +4690,16 @@ function yo({
|
|
|
4690
4690
|
const { handleRemoveTextColor: e } = ii({ editor: n }), s = $e(), o = Ue(null), a = St(
|
|
4691
4691
|
() => [...i, { label: "Remove color", value: "none" }],
|
|
4692
4692
|
[i]
|
|
4693
|
-
), { selectedIndex:
|
|
4693
|
+
), { selectedIndex: l } = cn({
|
|
4694
4694
|
containerRef: o,
|
|
4695
4695
|
items: a,
|
|
4696
4696
|
orientation: "both",
|
|
4697
|
-
onSelect: (
|
|
4697
|
+
onSelect: (h) => {
|
|
4698
4698
|
if (!o.current) return !1;
|
|
4699
4699
|
const d = o.current.querySelector(
|
|
4700
4700
|
'[data-highlighted="true"]'
|
|
4701
4701
|
);
|
|
4702
|
-
return d && d.click(),
|
|
4702
|
+
return d && d.click(), h.value === "none" && e(), !0;
|
|
4703
4703
|
},
|
|
4704
4704
|
autoSelectFirstItem: !1
|
|
4705
4705
|
});
|
|
@@ -4710,18 +4710,18 @@ function yo({
|
|
|
4710
4710
|
tabIndex: 0,
|
|
4711
4711
|
style: s ? { boxShadow: "none", border: 0 } : {},
|
|
4712
4712
|
children: /* @__PURE__ */ c(qe, { style: s ? { padding: 0 } : {}, children: /* @__PURE__ */ k(je, { orientation: "horizontal", children: [
|
|
4713
|
-
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: i.map((
|
|
4713
|
+
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: i.map((h, d) => /* @__PURE__ */ c(
|
|
4714
4714
|
vn,
|
|
4715
4715
|
{
|
|
4716
4716
|
editor: n,
|
|
4717
|
-
textColor: t ?
|
|
4718
|
-
tooltip:
|
|
4719
|
-
"aria-label": `${
|
|
4720
|
-
tabIndex: d ===
|
|
4721
|
-
"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,
|
|
4722
4722
|
useColorValue: t
|
|
4723
4723
|
},
|
|
4724
|
-
|
|
4724
|
+
h.value
|
|
4725
4725
|
)) }),
|
|
4726
4726
|
/* @__PURE__ */ c(Ge, {}),
|
|
4727
4727
|
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: /* @__PURE__ */ c(
|
|
@@ -4730,11 +4730,11 @@ function yo({
|
|
|
4730
4730
|
onClick: e,
|
|
4731
4731
|
"aria-label": "Remove text color",
|
|
4732
4732
|
tooltip: "Remove text color",
|
|
4733
|
-
tabIndex:
|
|
4733
|
+
tabIndex: l === i.length ? 0 : -1,
|
|
4734
4734
|
type: "button",
|
|
4735
4735
|
role: "menuitem",
|
|
4736
4736
|
variant: "ghost",
|
|
4737
|
-
"data-highlighted":
|
|
4737
|
+
"data-highlighted": l === i.length,
|
|
4738
4738
|
children: /* @__PURE__ */ c(Xe, { className: "tiptap-button-icon" })
|
|
4739
4739
|
}
|
|
4740
4740
|
) })
|
|
@@ -4756,21 +4756,21 @@ function vo({
|
|
|
4756
4756
|
onApplied: s,
|
|
4757
4757
|
...o
|
|
4758
4758
|
}) {
|
|
4759
|
-
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({
|
|
4760
4760
|
editor: a,
|
|
4761
4761
|
hideWhenUnavailable: t,
|
|
4762
4762
|
onApplied: s
|
|
4763
4763
|
});
|
|
4764
|
-
return d ? /* @__PURE__ */ k(dn, { open:
|
|
4764
|
+
return d ? /* @__PURE__ */ k(dn, { open: l, onOpenChange: h, children: [
|
|
4765
4765
|
/* @__PURE__ */ c(gn, { asChild: !0, children: /* @__PURE__ */ c(
|
|
4766
4766
|
wn,
|
|
4767
4767
|
{
|
|
4768
|
-
disabled: !
|
|
4769
|
-
"data-active-state":
|
|
4770
|
-
"data-disabled": !
|
|
4771
|
-
"aria-pressed":
|
|
4772
|
-
"aria-label":
|
|
4773
|
-
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,
|
|
4774
4774
|
...o,
|
|
4775
4775
|
children: /* @__PURE__ */ c(y, { className: "tiptap-button-icon" })
|
|
4776
4776
|
}
|
|
@@ -4799,43 +4799,43 @@ function xo({
|
|
|
4799
4799
|
editor: n,
|
|
4800
4800
|
fonts: i = Co
|
|
4801
4801
|
}) {
|
|
4802
|
-
const [t, e] =
|
|
4802
|
+
const [t, e] = $(
|
|
4803
4803
|
void 0
|
|
4804
|
-
), s =
|
|
4805
|
-
(
|
|
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,
|
|
4806
4806
|
[n]
|
|
4807
4807
|
);
|
|
4808
|
-
|
|
4808
|
+
U(() => {
|
|
4809
4809
|
if (!n) {
|
|
4810
4810
|
e(void 0);
|
|
4811
4811
|
return;
|
|
4812
4812
|
}
|
|
4813
|
-
const
|
|
4813
|
+
const h = () => {
|
|
4814
4814
|
const d = n.getAttributes("textStyle");
|
|
4815
4815
|
e(d.fontFamily);
|
|
4816
4816
|
};
|
|
4817
|
-
return n.on("selectionUpdate",
|
|
4818
|
-
n.off("selectionUpdate",
|
|
4817
|
+
return n.on("selectionUpdate", h), n.on("transaction", h), h(), () => {
|
|
4818
|
+
n.off("selectionUpdate", h), n.off("transaction", h);
|
|
4819
4819
|
};
|
|
4820
4820
|
}, [n]);
|
|
4821
|
-
const a =
|
|
4822
|
-
(
|
|
4823
|
-
n && (
|
|
4821
|
+
const a = Q(
|
|
4822
|
+
(h) => {
|
|
4823
|
+
n && (h ? n.chain().focus().setFontFamily(h).run() : n.chain().focus().unsetFontFamily().run());
|
|
4824
4824
|
},
|
|
4825
4825
|
[n]
|
|
4826
|
-
),
|
|
4826
|
+
), l = Q(() => {
|
|
4827
4827
|
n && n.chain().focus().unsetFontFamily().run();
|
|
4828
4828
|
}, [n]);
|
|
4829
4829
|
return {
|
|
4830
4830
|
fonts: i,
|
|
4831
4831
|
activeFontFamily: t,
|
|
4832
4832
|
setFontFamily: a,
|
|
4833
|
-
unsetFontFamily:
|
|
4833
|
+
unsetFontFamily: l,
|
|
4834
4834
|
canSetFontFamily: s,
|
|
4835
4835
|
isFontFamilyActive: o
|
|
4836
4836
|
};
|
|
4837
4837
|
}
|
|
4838
|
-
const bn =
|
|
4838
|
+
const bn = A(({ editor: n, fonts: i }, t) => {
|
|
4839
4839
|
const {
|
|
4840
4840
|
fonts: e,
|
|
4841
4841
|
activeFontFamily: s,
|
|
@@ -4851,33 +4851,33 @@ const bn = $(({ editor: n, fonts: i }, t) => {
|
|
|
4851
4851
|
ref: t,
|
|
4852
4852
|
className: "font-family-select",
|
|
4853
4853
|
value: s || "",
|
|
4854
|
-
onChange: (
|
|
4855
|
-
children: e.map((
|
|
4854
|
+
onChange: (l) => o(l.target.value),
|
|
4855
|
+
children: e.map((l) => /* @__PURE__ */ c(
|
|
4856
4856
|
"option",
|
|
4857
4857
|
{
|
|
4858
|
-
value:
|
|
4859
|
-
style: { fontFamily:
|
|
4860
|
-
children:
|
|
4858
|
+
value: l.value,
|
|
4859
|
+
style: { fontFamily: l.value || void 0 },
|
|
4860
|
+
children: l.label
|
|
4861
4861
|
},
|
|
4862
|
-
|
|
4862
|
+
l.label
|
|
4863
4863
|
))
|
|
4864
4864
|
}
|
|
4865
4865
|
);
|
|
4866
4866
|
});
|
|
4867
4867
|
bn.displayName = "FontFamilySelect";
|
|
4868
4868
|
function Go({ api: n }) {
|
|
4869
|
-
const [i, t] =
|
|
4870
|
-
return
|
|
4869
|
+
const [i, t] = $(null), [e, s] = $(1), [o, a] = $(1);
|
|
4870
|
+
return U(() => {
|
|
4871
4871
|
if (!n) return;
|
|
4872
|
-
const
|
|
4873
|
-
t(
|
|
4874
|
-
},
|
|
4872
|
+
const l = (m) => {
|
|
4873
|
+
t(m), s(n.getState().viewport.scale), a(m.scaleWhenCreate || 1);
|
|
4874
|
+
}, h = () => {
|
|
4875
4875
|
t(null);
|
|
4876
|
-
}, d = (
|
|
4877
|
-
s(
|
|
4876
|
+
}, d = (m) => {
|
|
4877
|
+
s(m);
|
|
4878
4878
|
};
|
|
4879
|
-
return n.on("texteditor:register",
|
|
4880
|
-
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);
|
|
4881
4881
|
};
|
|
4882
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: {
|
|
4883
4883
|
transformOrigin: "bottom center",
|