@8btc/whiteboard 0.0.20-alpha.29 → 0.0.20-alpha.30
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 +1075 -1005
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var In = Object.defineProperty;
|
|
2
|
+
var ai = (n) => {
|
|
3
3
|
throw TypeError(n);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var p = (n, i, t) =>
|
|
7
|
-
var r = (n, i, t) => (
|
|
8
|
-
import { jsxs as k, jsx as c, Fragment as
|
|
9
|
-
import { useState as R, useEffect as
|
|
10
|
-
import
|
|
11
|
-
import { N as b, R as
|
|
12
|
-
import
|
|
13
|
-
import { Editor as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { TextStyle as
|
|
17
|
-
import { toCanvas as
|
|
18
|
-
import { v4 as
|
|
19
|
-
import { Slot as
|
|
20
|
-
import { cva as
|
|
21
|
-
import { clsx as
|
|
22
|
-
import { twMerge as
|
|
23
|
-
import { Minus as
|
|
24
|
-
import { BubbleMenu as
|
|
25
|
-
import { NodeSelection as
|
|
5
|
+
var kn = (n, i, t) => i in n ? In(n, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[i] = t;
|
|
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)), g = (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), x = (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
|
+
import { jsxs as k, jsx as c, Fragment as Ie } from "react/jsx-runtime";
|
|
9
|
+
import { useState as R, useEffect as Z, useRef as Ue, useMemo as St, forwardRef as $, createContext as Rn, isValidElement as li, version as $n, cloneElement as An, useContext as Fn, Fragment as Hn, useCallback as J, memo as ct } from "react";
|
|
10
|
+
import _ from "konva";
|
|
11
|
+
import { N as b, R as N, I as Q } from "./const-BJHbPsA9.js";
|
|
12
|
+
import Ln from "mitt";
|
|
13
|
+
import { Editor as Dn } from "@tiptap/core";
|
|
14
|
+
import Pn from "@tiptap/starter-kit";
|
|
15
|
+
import Bn from "@tiptap/extension-highlight";
|
|
16
|
+
import { TextStyle as Vn, Color as On, FontFamily as Zn } from "@tiptap/extension-text-style";
|
|
17
|
+
import { toCanvas as Un } from "html-to-image";
|
|
18
|
+
import { v4 as Tt } from "uuid";
|
|
19
|
+
import { Slot as zn } from "@radix-ui/react-slot";
|
|
20
|
+
import { cva as Wn } from "class-variance-authority";
|
|
21
|
+
import { clsx as Xn } from "clsx";
|
|
22
|
+
import { twMerge as Yn } from "tailwind-merge";
|
|
23
|
+
import { Minus as Gn, Plus as Kn, Undo2 as qn, Redo2 as jn } from "lucide-react";
|
|
24
|
+
import { BubbleMenu as Jn } from "@tiptap/react/menus";
|
|
25
|
+
import { NodeSelection as Qn } from "@tiptap/pm/state";
|
|
26
26
|
import "@tiptap/pm/tables";
|
|
27
|
-
import { useCurrentEditor as
|
|
28
|
-
import { FloatingDelayGroup as
|
|
29
|
-
import * as
|
|
30
|
-
import { useHotkeys as
|
|
31
|
-
var
|
|
32
|
-
class
|
|
27
|
+
import { useCurrentEditor as ts, useEditorState as es } from "@tiptap/react";
|
|
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
|
+
import * as ie from "@radix-ui/react-popover";
|
|
30
|
+
import { useHotkeys as Ti } from "react-hotkeys-hook";
|
|
31
|
+
var T, S, tt, ne, se, oe, re, ae, le, he, ce, de, _i;
|
|
32
|
+
class ms {
|
|
33
33
|
constructor(i, t) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
g(this, de);
|
|
35
|
+
g(this, T);
|
|
36
|
+
g(this, S);
|
|
37
|
+
g(this, tt, { x: 0, y: 0, scale: 1 });
|
|
38
38
|
/**
|
|
39
39
|
* 处理滚轮缩放和平移
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
g(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,
|
|
46
|
+
const s = r(this, tt).scale, o = {
|
|
47
|
+
x: (e.x - r(this, tt).x) / s,
|
|
48
|
+
y: (e.y - r(this, tt).y) / s
|
|
49
49
|
}, a = 1.01, h = i.evt.deltaY > 0 ? -1 : 1, l = Math.min(Math.abs(i.evt.deltaY), 10);
|
|
50
50
|
let d = s;
|
|
51
|
-
for (let
|
|
51
|
+
for (let u = 0; u < l; u++)
|
|
52
52
|
d = h > 0 ? d * a : d / a;
|
|
53
|
-
const f = Math.max(0.1, Math.min(5, d)),
|
|
53
|
+
const f = Math.max(0.1, Math.min(5, d)), m = {
|
|
54
54
|
x: e.x - o.x * f,
|
|
55
55
|
y: e.y - o.y * f
|
|
56
56
|
};
|
|
57
|
-
r(this,
|
|
57
|
+
r(this, T)._updateViewport({ x: m.x, y: m.y, scale: f });
|
|
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
|
-
r(this,
|
|
61
|
-
x: r(this,
|
|
62
|
-
y: r(this,
|
|
60
|
+
r(this, T)._updateViewport({
|
|
61
|
+
x: r(this, tt).x - s,
|
|
62
|
+
y: r(this, tt).y - o
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
-
|
|
67
|
-
const t = r(this,
|
|
66
|
+
g(this, se, (i) => {
|
|
67
|
+
const t = r(this, T).getToolType();
|
|
68
68
|
if (i.evt.button !== 0 || t === "hand")
|
|
69
69
|
return;
|
|
70
70
|
const e = r(this, S).getRelativePointerPosition();
|
|
71
|
-
if (r(this,
|
|
71
|
+
if (r(this, T)._setDrawingPosition(e || { x: 0, y: 0 }), t === "select")
|
|
72
72
|
if (i.target === r(this, S)) {
|
|
73
|
-
r(this,
|
|
73
|
+
r(this, T)._selectNodes(), r(this, T)._createSelectRect();
|
|
74
74
|
return;
|
|
75
75
|
} else {
|
|
76
76
|
const o = i.target.id();
|
|
77
|
-
o && r(this,
|
|
77
|
+
o && r(this, T)._selectNodes([o], i.evt.shiftKey);
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
if ([
|
|
@@ -84,8 +84,8 @@ class rs {
|
|
|
84
84
|
"ellipse",
|
|
85
85
|
"polygon",
|
|
86
86
|
"arrow"
|
|
87
|
-
].includes(t) && e && r(this,
|
|
88
|
-
const s = r(this,
|
|
87
|
+
].includes(t) && e && r(this, T)._createDraftNode(t), t === "image-marker" && e) {
|
|
88
|
+
const s = r(this, T)._findImageAtPosition(e);
|
|
89
89
|
if (s) {
|
|
90
90
|
const o = s.width(), a = s.height();
|
|
91
91
|
if (o && a) {
|
|
@@ -95,22 +95,22 @@ class rs {
|
|
|
95
95
|
width: o,
|
|
96
96
|
height: a
|
|
97
97
|
};
|
|
98
|
-
r(this,
|
|
98
|
+
r(this, T)._createDraftNode(t, {
|
|
99
99
|
$_parentId: s.id(),
|
|
100
100
|
$_bounds: h
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
r(this,
|
|
105
|
+
r(this, T)._selectNodes();
|
|
106
106
|
});
|
|
107
|
-
|
|
108
|
-
const i = r(this,
|
|
107
|
+
g(this, oe, () => {
|
|
108
|
+
const i = r(this, T).getState().toolType;
|
|
109
109
|
if (i === "hand")
|
|
110
110
|
return;
|
|
111
111
|
const t = r(this, S).getRelativePointerPosition();
|
|
112
|
-
if (r(this,
|
|
113
|
-
r(this,
|
|
112
|
+
if (r(this, T)._updateDrawingPosition(t || { x: 0, y: 0 }), i === "select") {
|
|
113
|
+
r(this, T)._updateSelectRect();
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
[
|
|
@@ -121,13 +121,13 @@ class rs {
|
|
|
121
121
|
"ellipse",
|
|
122
122
|
"polygon",
|
|
123
123
|
"arrow"
|
|
124
|
-
].includes(i) && r(this,
|
|
124
|
+
].includes(i) && r(this, T)._updateDraftNode();
|
|
125
125
|
});
|
|
126
|
-
|
|
127
|
-
const i = r(this,
|
|
126
|
+
g(this, re, () => {
|
|
127
|
+
const i = r(this, T).getState().toolType;
|
|
128
128
|
if (i !== "hand") {
|
|
129
129
|
if (i === "select") {
|
|
130
|
-
r(this,
|
|
130
|
+
r(this, T)._finalizeSelectRect();
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
133
|
[
|
|
@@ -138,33 +138,33 @@ class rs {
|
|
|
138
138
|
"ellipse",
|
|
139
139
|
"polygon",
|
|
140
140
|
"arrow"
|
|
141
|
-
].includes(i) && r(this,
|
|
141
|
+
].includes(i) && r(this, T)._finalizeDraftNode(), i === "text" && r(this, T)._createTextNodeAtDrawingPosition("");
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
|
-
|
|
144
|
+
g(this, ae, (i) => {
|
|
145
145
|
if (i.target !== r(this, S))
|
|
146
146
|
return;
|
|
147
|
-
const t = r(this,
|
|
147
|
+
const t = r(this, T).getState().toolType;
|
|
148
148
|
t === "hand" ? this.setCursor("grabbing") : t === "select" && this.setCursor("all-scroll");
|
|
149
149
|
});
|
|
150
|
-
|
|
151
|
-
i.target === r(this, S) && r(this,
|
|
150
|
+
g(this, le, (i) => {
|
|
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
|
-
|
|
157
|
-
i.target === r(this, S) && (r(this,
|
|
156
|
+
g(this, he, (i) => {
|
|
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
|
-
|
|
163
|
-
if (i.evt.preventDefault(), r(this,
|
|
162
|
+
g(this, ce, (i) => {
|
|
163
|
+
if (i.evt.preventDefault(), r(this, T).getToolType() !== "select")
|
|
164
164
|
return;
|
|
165
165
|
const t = r(this, S).getPointerPosition(), e = i.target;
|
|
166
166
|
let s = null;
|
|
167
|
-
e.getParent()?.className === "Transformer" ? s = e.getParent().nodes() : e === r(this, S) ? s = e : (s = e.findAncestor((o) => o.hasName(b.selectable), !0), s && r(this,
|
|
167
|
+
e.getParent()?.className === "Transformer" ? s = e.getParent().nodes() : e === r(this, S) ? s = e : (s = e.findAncestor((o) => o.hasName(b.selectable), !0), s && r(this, T)._selectNodes([s.id()])), r(this, T)._showContextMenu({
|
|
168
168
|
x: t ? t.x : 0,
|
|
169
169
|
y: t ? t.y : 0,
|
|
170
170
|
clientX: i.evt.clientX,
|
|
@@ -172,7 +172,7 @@ class rs {
|
|
|
172
172
|
targetIds: Array.isArray(s) ? s.map((o) => o.id()) : s ? [s.id()] : []
|
|
173
173
|
});
|
|
174
174
|
});
|
|
175
|
-
|
|
175
|
+
x(this, T, i), x(this, S, new _.Stage({
|
|
176
176
|
id: "canvas-stage",
|
|
177
177
|
container: t.container,
|
|
178
178
|
width: t.width,
|
|
@@ -183,7 +183,7 @@ class rs {
|
|
|
183
183
|
scaleY: 1,
|
|
184
184
|
draggable: t.draggable ?? !1,
|
|
185
185
|
className: t.className
|
|
186
|
-
})),
|
|
186
|
+
})), E(this, de, _i).call(this);
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
189
189
|
* 获取原生 Konva.Stage 实例
|
|
@@ -195,14 +195,14 @@ class rs {
|
|
|
195
195
|
* 获取当前视口状态
|
|
196
196
|
*/
|
|
197
197
|
getViewport() {
|
|
198
|
-
return { ...r(this,
|
|
198
|
+
return { ...r(this, tt) };
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
201
201
|
* 设置视口(包括位置、缩放和尺寸)
|
|
202
202
|
*/
|
|
203
203
|
setViewport(i) {
|
|
204
|
-
const t = { ...r(this,
|
|
205
|
-
|
|
204
|
+
const t = { ...r(this, tt), ...i };
|
|
205
|
+
x(this, tt, 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
|
* 设置是否可拖拽
|
|
@@ -222,7 +222,7 @@ class rs {
|
|
|
222
222
|
*/
|
|
223
223
|
resetCursor() {
|
|
224
224
|
const i = r(this, S).container();
|
|
225
|
-
if (r(this,
|
|
225
|
+
if (r(this, T).getState().toolType === "hand") {
|
|
226
226
|
i.style.cursor = "grab";
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
@@ -235,55 +235,55 @@ class rs {
|
|
|
235
235
|
r(this, S).destroy();
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
|
|
238
|
+
T = new WeakMap(), S = new WeakMap(), tt = 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
|
-
|
|
242
|
-
r(this, S).on("wheel", r(this,
|
|
241
|
+
_i = function() {
|
|
242
|
+
r(this, S).on("wheel", r(this, ne)), r(this, S).on("pointerdown", r(this, se)), r(this, S).on("pointermove", r(this, oe)), r(this, S).on("pointerup", r(this, re)), r(this, S).on("dragstart", r(this, ae)), r(this, S).on("dragmove", r(this, le)), r(this, S).on("dragend", r(this, he)), r(this, S).on("contextmenu", r(this, ce));
|
|
243
243
|
};
|
|
244
|
-
var
|
|
245
|
-
class
|
|
244
|
+
var Lt, I, ge, ue, me, fe, pe, ye, ve, Mi;
|
|
245
|
+
class fs {
|
|
246
246
|
constructor(i, t) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
g(this, ve);
|
|
248
|
+
g(this, Lt);
|
|
249
|
+
g(this, I);
|
|
250
250
|
/**
|
|
251
251
|
* 处理 transformstart 事件
|
|
252
252
|
*/
|
|
253
|
-
|
|
253
|
+
g(this, ge, () => {
|
|
254
254
|
this.emitPositionChange();
|
|
255
255
|
});
|
|
256
256
|
/**
|
|
257
257
|
* 处理 transform 事件
|
|
258
258
|
*/
|
|
259
|
-
|
|
259
|
+
g(this, ue, () => {
|
|
260
260
|
this.emitPositionChange();
|
|
261
261
|
});
|
|
262
262
|
/**
|
|
263
263
|
* 处理 transformend 事件
|
|
264
264
|
*/
|
|
265
|
-
|
|
265
|
+
g(this, me, () => {
|
|
266
266
|
this.emitPositionChange();
|
|
267
267
|
});
|
|
268
268
|
/**
|
|
269
269
|
* 处理 dragstart 事件
|
|
270
270
|
*/
|
|
271
|
-
|
|
271
|
+
g(this, fe, () => {
|
|
272
272
|
this.emitPositionChange();
|
|
273
273
|
});
|
|
274
274
|
/**
|
|
275
275
|
* 处理 dragmove 事件
|
|
276
276
|
*/
|
|
277
|
-
|
|
277
|
+
g(this, pe, () => {
|
|
278
278
|
this.emitPositionChange();
|
|
279
279
|
});
|
|
280
280
|
/**
|
|
281
281
|
* 处理 dragend 事件
|
|
282
282
|
*/
|
|
283
|
-
|
|
283
|
+
g(this, ye, () => {
|
|
284
284
|
this.emitPositionChange();
|
|
285
285
|
});
|
|
286
|
-
|
|
286
|
+
x(this, Lt, i), x(this, I, new _.Transformer({
|
|
287
287
|
rotateEnabled: t?.rotateEnabled ?? !0,
|
|
288
288
|
ignoreStroke: t?.ignoreStroke ?? !0,
|
|
289
289
|
anchorSize: t?.anchorSize ?? 8,
|
|
@@ -291,7 +291,7 @@ class as {
|
|
|
291
291
|
anchorCornerRadius: t?.anchorCornerRadius ?? 4,
|
|
292
292
|
padding: t?.padding ?? 6,
|
|
293
293
|
shouldOverdrawWholeArea: !0
|
|
294
|
-
})),
|
|
294
|
+
})), E(this, ve, Mi).call(this);
|
|
295
295
|
}
|
|
296
296
|
/**
|
|
297
297
|
* 获取原生 Konva.Transformer 实例
|
|
@@ -333,7 +333,7 @@ class as {
|
|
|
333
333
|
"bottom-right",
|
|
334
334
|
"middle-left",
|
|
335
335
|
"middle-right"
|
|
336
|
-
]), this.emitPositionChange();
|
|
336
|
+
]), i.length === 1 && i[0].getAttr("$_type") === "arrow" ? r(this, I).visible(!1) : r(this, I).visible(!0), this.emitPositionChange();
|
|
337
337
|
}
|
|
338
338
|
/**
|
|
339
339
|
* 获取当前变换的节点
|
|
@@ -352,7 +352,7 @@ class as {
|
|
|
352
352
|
*/
|
|
353
353
|
emitPositionChange() {
|
|
354
354
|
const i = this.getPosition();
|
|
355
|
-
r(this,
|
|
355
|
+
r(this, Lt)._emit("transformer:positionChange", i);
|
|
356
356
|
}
|
|
357
357
|
/**
|
|
358
358
|
* 销毁 Transformer
|
|
@@ -361,11 +361,11 @@ class as {
|
|
|
361
361
|
r(this, I).destroy();
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
|
-
|
|
364
|
+
Lt = new WeakMap(), I = new WeakMap(), ge = new WeakMap(), ue = new WeakMap(), me = new WeakMap(), fe = new WeakMap(), pe = new WeakMap(), ye = new WeakMap(), ve = new WeakSet(), /**
|
|
365
365
|
* 设置事件监听器
|
|
366
366
|
*/
|
|
367
|
-
|
|
368
|
-
r(this, I).on("transformstart", r(this,
|
|
367
|
+
Mi = function() {
|
|
368
|
+
r(this, I).on("transformstart", r(this, ge)), r(this, I).on("transform", r(this, ue)), r(this, I).on("transformend", r(this, me)), r(this, I).on("dragstart", r(this, fe)), r(this, I).on("dragmove", r(this, pe)), r(this, I).on("dragend", r(this, ye)), r(this, I).on("pointerdblclick", (i) => {
|
|
369
369
|
const t = r(this, I).nodes();
|
|
370
370
|
if (t.length === 1) {
|
|
371
371
|
const e = t[0];
|
|
@@ -376,85 +376,85 @@ Ei = function() {
|
|
|
376
376
|
}
|
|
377
377
|
});
|
|
378
378
|
};
|
|
379
|
-
var
|
|
380
|
-
class
|
|
379
|
+
var L, V, W, O;
|
|
380
|
+
class ps {
|
|
381
381
|
// todo: 优化 selectedNodeIds 的存储和查询性能
|
|
382
382
|
// private _selectedNodeIds: Set<string> = new Set();
|
|
383
383
|
constructor(i) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
384
|
+
g(this, L, []);
|
|
385
|
+
g(this, V);
|
|
386
|
+
g(this, W, []);
|
|
387
|
+
g(this, O);
|
|
388
|
+
x(this, V, i), x(this, O, Ln());
|
|
389
389
|
}
|
|
390
390
|
/**
|
|
391
391
|
* 获取当前状态
|
|
392
392
|
*/
|
|
393
393
|
getState() {
|
|
394
|
-
return { ...r(this,
|
|
394
|
+
return { ...r(this, V) };
|
|
395
395
|
}
|
|
396
396
|
/**
|
|
397
397
|
* 获取完整历史状态
|
|
398
398
|
*/
|
|
399
399
|
getHistory() {
|
|
400
400
|
return {
|
|
401
|
-
past: [...r(this,
|
|
402
|
-
present: { ...r(this,
|
|
403
|
-
future: [...r(this,
|
|
401
|
+
past: [...r(this, L)],
|
|
402
|
+
present: { ...r(this, V) },
|
|
403
|
+
future: [...r(this, W)]
|
|
404
404
|
};
|
|
405
405
|
}
|
|
406
406
|
/**
|
|
407
407
|
* 是否可以撤销
|
|
408
408
|
*/
|
|
409
409
|
canUndo() {
|
|
410
|
-
return r(this,
|
|
410
|
+
return r(this, L).length > 0;
|
|
411
411
|
}
|
|
412
412
|
/**
|
|
413
413
|
* 是否可以重做
|
|
414
414
|
*/
|
|
415
415
|
canRedo() {
|
|
416
|
-
return r(this,
|
|
416
|
+
return r(this, W).length > 0;
|
|
417
417
|
}
|
|
418
418
|
/**
|
|
419
419
|
* 订阅状态事件
|
|
420
420
|
*/
|
|
421
421
|
on(i, t) {
|
|
422
|
-
r(this,
|
|
422
|
+
r(this, O).on(i, t);
|
|
423
423
|
}
|
|
424
424
|
/**
|
|
425
425
|
* 取消订阅状态事件
|
|
426
426
|
*/
|
|
427
427
|
off(i, t) {
|
|
428
|
-
r(this,
|
|
428
|
+
r(this, O).off(i, t);
|
|
429
429
|
}
|
|
430
430
|
/**
|
|
431
431
|
* @internal
|
|
432
432
|
* 发送事件
|
|
433
433
|
*/
|
|
434
434
|
_emit(i, t) {
|
|
435
|
-
r(this,
|
|
435
|
+
r(this, O).emit(i, t);
|
|
436
436
|
}
|
|
437
437
|
/**
|
|
438
438
|
* 撤销操作
|
|
439
439
|
*/
|
|
440
440
|
undo() {
|
|
441
|
-
if (r(this,
|
|
442
|
-
const i = r(this,
|
|
443
|
-
|
|
441
|
+
if (r(this, L).length === 0) return;
|
|
442
|
+
const i = r(this, L)[r(this, L).length - 1], t = r(this, L).slice(0, r(this, L).length - 1);
|
|
443
|
+
x(this, L, t), x(this, W, [r(this, V), ...r(this, W)]), x(this, V, i), this._renderCanvas(i), r(this, O).emit("state:undo", i), r(this, O).emit("state:change", i);
|
|
444
444
|
}
|
|
445
445
|
/**
|
|
446
446
|
* 重做操作
|
|
447
447
|
*/
|
|
448
448
|
redo() {
|
|
449
|
-
if (r(this,
|
|
450
|
-
const i = r(this,
|
|
451
|
-
|
|
449
|
+
if (r(this, W).length === 0) return;
|
|
450
|
+
const i = r(this, W)[0], t = r(this, W).slice(1);
|
|
451
|
+
x(this, L, [...r(this, L), r(this, V)]), x(this, W, t), x(this, V, i), this._renderCanvas(i), r(this, O).emit("state:redo", i), r(this, O).emit("state:change", i);
|
|
452
452
|
}
|
|
453
453
|
/**
|
|
454
454
|
* 重置历史记录
|
|
455
455
|
*/
|
|
456
456
|
resetHistory() {
|
|
457
|
-
|
|
457
|
+
x(this, L, []), x(this, W, []), r(this, O).emit("state:reset", r(this, V)), r(this, O).emit("state:change", r(this, V));
|
|
458
458
|
}
|
|
459
459
|
/**
|
|
460
460
|
* 更新状态
|
|
@@ -462,25 +462,25 @@ class ls {
|
|
|
462
462
|
* @param addToHistory - 是否添加到历史记录
|
|
463
463
|
*/
|
|
464
464
|
_updateState(i, t) {
|
|
465
|
-
const e = { ...r(this,
|
|
466
|
-
t && (
|
|
465
|
+
const e = { ...r(this, V), ...i };
|
|
466
|
+
t && (x(this, L, [...r(this, L), r(this, V)]), x(this, W, [])), x(this, V, e), r(this, O).emit("state:change", e);
|
|
467
467
|
}
|
|
468
468
|
/**
|
|
469
469
|
* 清理资源
|
|
470
470
|
*/
|
|
471
471
|
_dispose() {
|
|
472
|
-
r(this,
|
|
472
|
+
r(this, O).all.clear();
|
|
473
473
|
}
|
|
474
474
|
}
|
|
475
|
-
|
|
476
|
-
class
|
|
475
|
+
L = new WeakMap(), V = new WeakMap(), W = new WeakMap(), O = new WeakMap();
|
|
476
|
+
class st {
|
|
477
477
|
}
|
|
478
|
-
const
|
|
478
|
+
const ys = {
|
|
479
479
|
// 将 Konva 的 stroke 属性映射到 NodeStyle 的 $_strokeColor
|
|
480
480
|
stroke: "$_strokeColor",
|
|
481
481
|
// 将 Konva 的 fill 属性映射到 NodeStyle 的 $_fillColor
|
|
482
482
|
fill: "$_fillColor"
|
|
483
|
-
},
|
|
483
|
+
}, Ii = {
|
|
484
484
|
"theme.select-rect-border": "rgb(33, 150, 243)",
|
|
485
485
|
"theme.select-rect-fill": "rgba(33, 150, 243, 0.2)",
|
|
486
486
|
"theme.image-marker-color": "#F44336",
|
|
@@ -498,7 +498,7 @@ const hs = {
|
|
|
498
498
|
"theme.fill-color.4": "#DBEAFE",
|
|
499
499
|
"theme.fill-color.5": "#D1FAE5",
|
|
500
500
|
"theme.fill-color.6": "#FEF3C7"
|
|
501
|
-
},
|
|
501
|
+
}, vs = {
|
|
502
502
|
"theme.select-rect-border": "rgb(144, 202, 249)",
|
|
503
503
|
"theme.select-rect-fill": "rgba(144, 202, 249, 0.15)",
|
|
504
504
|
"theme.image-marker-color": "#EF5350",
|
|
@@ -516,15 +516,15 @@ const hs = {
|
|
|
516
516
|
"theme.fill-color.4": "#DBEAFE",
|
|
517
517
|
"theme.fill-color.5": "#D1FAE5",
|
|
518
518
|
"theme.fill-color.6": "#FEF3C7"
|
|
519
|
-
},
|
|
520
|
-
default:
|
|
521
|
-
dark:
|
|
522
|
-
},
|
|
519
|
+
}, Wo = {
|
|
520
|
+
default: Ii,
|
|
521
|
+
dark: vs
|
|
522
|
+
}, Jt = {
|
|
523
523
|
$_strokeColor: "theme.stroke-color.1"
|
|
524
524
|
};
|
|
525
|
-
function
|
|
525
|
+
function ot(n, i) {
|
|
526
526
|
const t = {};
|
|
527
|
-
return Object.entries(
|
|
527
|
+
return Object.entries(ys).forEach(
|
|
528
528
|
([e, s]) => {
|
|
529
529
|
if (s in n) {
|
|
530
530
|
const o = n[s];
|
|
@@ -534,12 +534,12 @@ function it(n, i) {
|
|
|
534
534
|
}
|
|
535
535
|
), t;
|
|
536
536
|
}
|
|
537
|
-
const
|
|
537
|
+
const Cs = (n, i) => {
|
|
538
538
|
if (n.length !== i.length) return !1;
|
|
539
539
|
const t = new Set(n);
|
|
540
540
|
return i.every((e) => t.has(e));
|
|
541
541
|
};
|
|
542
|
-
function
|
|
542
|
+
function ki(n, i) {
|
|
543
543
|
const { x: t, y: e, width: s, height: o } = n;
|
|
544
544
|
return {
|
|
545
545
|
triangle: [
|
|
@@ -579,16 +579,16 @@ function Ni(n, i) {
|
|
|
579
579
|
y: Number((e + l.y * o).toFixed(2)) - n.y
|
|
580
580
|
}));
|
|
581
581
|
}
|
|
582
|
-
function
|
|
583
|
-
const t = Math.max(n.width ??
|
|
582
|
+
function hi(n, i) {
|
|
583
|
+
const t = Math.max(n.width ?? N.MIN_SIZE, N.MIN_SIZE), e = Math.max(n.height ?? N.MIN_SIZE, N.MIN_SIZE), s = ot(
|
|
584
584
|
{
|
|
585
|
-
...
|
|
585
|
+
...Jt,
|
|
586
586
|
...n
|
|
587
587
|
},
|
|
588
588
|
i
|
|
589
589
|
);
|
|
590
590
|
return {
|
|
591
|
-
cornerRadius:
|
|
591
|
+
cornerRadius: N.CORNER_RADIUS,
|
|
592
592
|
strokeWidth: 2,
|
|
593
593
|
...n,
|
|
594
594
|
...s,
|
|
@@ -599,8 +599,8 @@ function si(n, i) {
|
|
|
599
599
|
listening: n.$_listening ?? !0
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
|
-
function
|
|
603
|
-
const t = n.width ??
|
|
602
|
+
function ci(n, i) {
|
|
603
|
+
const t = n.width ?? Q.MIN_SIZE, e = n.height ?? Q.MIN_SIZE, s = ot(n, i);
|
|
604
604
|
if (!n.image) {
|
|
605
605
|
const a = document.createElement("canvas");
|
|
606
606
|
a.width = t, a.height = e, n.image = a;
|
|
@@ -612,8 +612,8 @@ function oi(n, i) {
|
|
|
612
612
|
draggable: !0
|
|
613
613
|
};
|
|
614
614
|
}
|
|
615
|
-
function
|
|
616
|
-
const t = n.width ??
|
|
615
|
+
function di(n, i) {
|
|
616
|
+
const t = n.width ?? Q.MIN_SIZE, e = n.height ?? Q.MIN_SIZE, s = ot(n, i);
|
|
617
617
|
if (!n.$_coverUrl) {
|
|
618
618
|
const a = document.createElement("canvas");
|
|
619
619
|
a.width = t, a.height = e, n.image = a;
|
|
@@ -625,8 +625,8 @@ function ri(n, i) {
|
|
|
625
625
|
draggable: !0
|
|
626
626
|
};
|
|
627
627
|
}
|
|
628
|
-
function
|
|
629
|
-
const t = Math.max(n.width ??
|
|
628
|
+
function gi(n, i) {
|
|
629
|
+
const t = Math.max(n.width ?? N.MIN_SIZE, N.MIN_SIZE), e = Math.max(n.height ?? N.MIN_SIZE, N.MIN_SIZE), s = ot(n, i);
|
|
630
630
|
return s.markerColor = i["theme.image-marker-color"], {
|
|
631
631
|
...n,
|
|
632
632
|
...s,
|
|
@@ -635,8 +635,8 @@ function ai(n, i) {
|
|
|
635
635
|
name: `${b.nodeRoot} ${b.imageMarker} ${n.$_parentId}`
|
|
636
636
|
};
|
|
637
637
|
}
|
|
638
|
-
function
|
|
639
|
-
const t = Math.max(n.width ??
|
|
638
|
+
function ui(n, i) {
|
|
639
|
+
const t = Math.max(n.width ?? N.MIN_SIZE, N.MIN_SIZE), e = Math.max(n.height ?? N.MIN_SIZE, N.MIN_SIZE), s = ot(n, i);
|
|
640
640
|
return {
|
|
641
641
|
...n,
|
|
642
642
|
...s,
|
|
@@ -646,8 +646,8 @@ function li(n, i) {
|
|
|
646
646
|
draggable: !0
|
|
647
647
|
};
|
|
648
648
|
}
|
|
649
|
-
function
|
|
650
|
-
const t =
|
|
649
|
+
function mi(n, i) {
|
|
650
|
+
const t = ot(n, i);
|
|
651
651
|
return {
|
|
652
652
|
fontSize: 16,
|
|
653
653
|
fontFamily: "Comic Sans MS",
|
|
@@ -660,8 +660,8 @@ function hi(n, i) {
|
|
|
660
660
|
draggable: !0
|
|
661
661
|
};
|
|
662
662
|
}
|
|
663
|
-
function
|
|
664
|
-
const t =
|
|
663
|
+
function fi(n, i) {
|
|
664
|
+
const t = ot(n, i);
|
|
665
665
|
return {
|
|
666
666
|
cornerRadius: 0,
|
|
667
667
|
...n,
|
|
@@ -670,16 +670,16 @@ function ci(n, i) {
|
|
|
670
670
|
draggable: !0
|
|
671
671
|
};
|
|
672
672
|
}
|
|
673
|
-
function
|
|
674
|
-
const t = n.outerRadius || 0, e =
|
|
673
|
+
function pi(n, i) {
|
|
674
|
+
const t = n.outerRadius || 0, e = ot(
|
|
675
675
|
{
|
|
676
|
-
...
|
|
676
|
+
...Jt,
|
|
677
677
|
...n
|
|
678
678
|
},
|
|
679
679
|
i
|
|
680
680
|
);
|
|
681
681
|
return {
|
|
682
|
-
cornerRadius:
|
|
682
|
+
cornerRadius: N.CORNER_RADIUS,
|
|
683
683
|
strokeWidth: 2,
|
|
684
684
|
...n,
|
|
685
685
|
...e,
|
|
@@ -691,10 +691,10 @@ function di(n, i) {
|
|
|
691
691
|
listening: n.$_listening ?? !0
|
|
692
692
|
};
|
|
693
693
|
}
|
|
694
|
-
function
|
|
695
|
-
const t = n.width || 0, e = n.height || 0, s =
|
|
694
|
+
function yi(n, i) {
|
|
695
|
+
const t = n.width || 0, e = n.height || 0, s = ot(
|
|
696
696
|
{
|
|
697
|
-
...
|
|
697
|
+
...Jt,
|
|
698
698
|
...n
|
|
699
699
|
},
|
|
700
700
|
i
|
|
@@ -710,14 +710,14 @@ function gi(n, i) {
|
|
|
710
710
|
listening: n.$_listening ?? !0
|
|
711
711
|
};
|
|
712
712
|
}
|
|
713
|
-
function
|
|
714
|
-
const t = n.width || 0, e = n.height || 0, s =
|
|
713
|
+
function vi(n, i) {
|
|
714
|
+
const t = n.width || 0, e = n.height || 0, s = ot(
|
|
715
715
|
{
|
|
716
|
-
...
|
|
716
|
+
...Jt,
|
|
717
717
|
...n
|
|
718
718
|
},
|
|
719
719
|
i
|
|
720
|
-
), o =
|
|
720
|
+
), o = ki(
|
|
721
721
|
{ x: n.x, y: n.y, width: t, height: e },
|
|
722
722
|
n.$_shape
|
|
723
723
|
);
|
|
@@ -732,10 +732,10 @@ function ui(n, i) {
|
|
|
732
732
|
listening: n.$_listening ?? !0
|
|
733
733
|
};
|
|
734
734
|
}
|
|
735
|
-
function
|
|
736
|
-
const t =
|
|
735
|
+
function Ci(n, i) {
|
|
736
|
+
const t = ot(
|
|
737
737
|
{
|
|
738
|
-
...
|
|
738
|
+
...Jt,
|
|
739
739
|
...n
|
|
740
740
|
},
|
|
741
741
|
i
|
|
@@ -751,33 +751,33 @@ function mi(n, i) {
|
|
|
751
751
|
listening: n.$_listening ?? !0
|
|
752
752
|
};
|
|
753
753
|
}
|
|
754
|
-
const
|
|
755
|
-
function
|
|
756
|
-
|
|
754
|
+
const Ri = /* @__PURE__ */ new WeakMap();
|
|
755
|
+
function rt(n, i) {
|
|
756
|
+
Ri.set(n, i);
|
|
757
757
|
}
|
|
758
|
-
function
|
|
759
|
-
return
|
|
758
|
+
function xi(n) {
|
|
759
|
+
return Ri.get(n);
|
|
760
760
|
}
|
|
761
|
-
function
|
|
761
|
+
function xs(n) {
|
|
762
762
|
return {
|
|
763
|
-
width: Math.max(
|
|
764
|
-
height: Math.max(
|
|
763
|
+
width: Math.max(N.MIN_SIZE, n.width() * n.scaleX()),
|
|
764
|
+
height: Math.max(N.MIN_SIZE, n.height() * n.scaleY())
|
|
765
765
|
};
|
|
766
766
|
}
|
|
767
|
-
var
|
|
768
|
-
class
|
|
767
|
+
var Dt, Ce, $i;
|
|
768
|
+
class ws extends st {
|
|
769
769
|
constructor(t, e, s = !1) {
|
|
770
770
|
super();
|
|
771
|
-
|
|
771
|
+
g(this, Ce);
|
|
772
772
|
p(this, "core");
|
|
773
773
|
p(this, "config");
|
|
774
774
|
p(this, "element");
|
|
775
775
|
p(this, "isDraft");
|
|
776
|
-
|
|
776
|
+
g(this, Dt, ({ type: t }) => {
|
|
777
777
|
const e = t === "select";
|
|
778
778
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
779
779
|
});
|
|
780
|
-
this.core = t, this.config =
|
|
780
|
+
this.core = t, this.config = hi(e, this.core.getTheme()), this.element = this.createElement(), rt(this.element, this), this.isDraft = s, E(this, Ce, $i).call(this);
|
|
781
781
|
}
|
|
782
782
|
getID() {
|
|
783
783
|
return this.config.id;
|
|
@@ -790,7 +790,7 @@ class us extends et {
|
|
|
790
790
|
this.config = e;
|
|
791
791
|
}
|
|
792
792
|
createElement() {
|
|
793
|
-
return new
|
|
793
|
+
return new _.Rect(this.config);
|
|
794
794
|
}
|
|
795
795
|
/**
|
|
796
796
|
* 获取 Konva.Rect 实例
|
|
@@ -802,7 +802,7 @@ class us extends et {
|
|
|
802
802
|
* 更新节点数据
|
|
803
803
|
*/
|
|
804
804
|
update(t) {
|
|
805
|
-
this.config =
|
|
805
|
+
this.config = hi(
|
|
806
806
|
{
|
|
807
807
|
...this.config,
|
|
808
808
|
...t
|
|
@@ -814,16 +814,16 @@ class us extends et {
|
|
|
814
814
|
* 销毁
|
|
815
815
|
*/
|
|
816
816
|
destroy() {
|
|
817
|
-
this.core.off("toolType:change", r(this,
|
|
817
|
+
this.core.off("toolType:change", r(this, Dt)), this.element.destroy();
|
|
818
818
|
}
|
|
819
819
|
}
|
|
820
|
-
|
|
820
|
+
Dt = new WeakMap(), Ce = new WeakSet(), /**
|
|
821
821
|
* 设置事件处理器
|
|
822
822
|
*/
|
|
823
|
-
|
|
823
|
+
$i = function() {
|
|
824
824
|
const t = this.getElement();
|
|
825
|
-
this.core.on("toolType:change", r(this,
|
|
826
|
-
const s = e.target, { width: o, height: a } =
|
|
825
|
+
this.core.on("toolType:change", r(this, Dt)), t.on("transform", (e) => {
|
|
826
|
+
const s = e.target, { width: o, height: a } = xs(s);
|
|
827
827
|
s.scale({ x: 1, y: 1 }), s.width(o), s.height(a);
|
|
828
828
|
}), t.on("transformend", (e) => {
|
|
829
829
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
@@ -831,20 +831,20 @@ Ti = function() {
|
|
|
831
831
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
832
832
|
});
|
|
833
833
|
};
|
|
834
|
-
var
|
|
835
|
-
class
|
|
834
|
+
var ht, He, Pt, Bt, Ai, Le;
|
|
835
|
+
class bs extends st {
|
|
836
836
|
constructor(t, e, s = !1) {
|
|
837
837
|
super();
|
|
838
|
-
|
|
838
|
+
g(this, ht);
|
|
839
839
|
p(this, "core");
|
|
840
840
|
p(this, "config");
|
|
841
841
|
p(this, "element");
|
|
842
842
|
p(this, "isDraft");
|
|
843
|
-
|
|
843
|
+
g(this, Pt, ({ type: t }) => {
|
|
844
844
|
const e = t === "select";
|
|
845
845
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
846
846
|
});
|
|
847
|
-
|
|
847
|
+
g(this, Bt, () => {
|
|
848
848
|
const t = this.getElement().getLayer();
|
|
849
849
|
if (!t) return;
|
|
850
850
|
const e = t.find(
|
|
@@ -853,12 +853,12 @@ class ms extends et {
|
|
|
853
853
|
this.core._rebuildStateAfterNodeChange(
|
|
854
854
|
[
|
|
855
855
|
this,
|
|
856
|
-
...e.map((s) =>
|
|
856
|
+
...e.map((s) => xi(s)).filter((s) => s !== void 0)
|
|
857
857
|
],
|
|
858
858
|
!0
|
|
859
859
|
);
|
|
860
860
|
});
|
|
861
|
-
this.core = t, this.config =
|
|
861
|
+
this.core = t, this.config = ci(e, this.core.getTheme()), this.element = this.createElement(), rt(this.element, this), this.isDraft = s, E(this, ht, He).call(this), E(this, ht, Ai).call(this, this.getElement());
|
|
862
862
|
}
|
|
863
863
|
getID() {
|
|
864
864
|
return this.config.id;
|
|
@@ -870,7 +870,7 @@ class ms extends et {
|
|
|
870
870
|
this.config = e;
|
|
871
871
|
}
|
|
872
872
|
createElement() {
|
|
873
|
-
return new
|
|
873
|
+
return new _.Image(this.config);
|
|
874
874
|
}
|
|
875
875
|
/**
|
|
876
876
|
* 获取 Konva.Image 实例
|
|
@@ -883,19 +883,19 @@ class ms extends et {
|
|
|
883
883
|
*/
|
|
884
884
|
update(t) {
|
|
885
885
|
const e = this.config;
|
|
886
|
-
this.config =
|
|
886
|
+
this.config = ci(
|
|
887
887
|
{
|
|
888
888
|
...e,
|
|
889
889
|
...t
|
|
890
890
|
},
|
|
891
891
|
this.core.getTheme()
|
|
892
|
-
), delete this.config.image, this.getElement().setAttrs(this.config), t.$_imageUrl && t.$_imageUrl !== e.$_imageUrl &&
|
|
892
|
+
), delete this.config.image, this.getElement().setAttrs(this.config), t.$_imageUrl && t.$_imageUrl !== e.$_imageUrl && E(this, ht, He).call(this);
|
|
893
893
|
}
|
|
894
894
|
/**
|
|
895
895
|
* 销毁
|
|
896
896
|
*/
|
|
897
897
|
destroy() {
|
|
898
|
-
this.core.off("toolType:change", r(this,
|
|
898
|
+
this.core.off("toolType:change", r(this, Pt)), this.element.destroy();
|
|
899
899
|
}
|
|
900
900
|
getConfig() {
|
|
901
901
|
return {
|
|
@@ -904,10 +904,10 @@ class ms extends et {
|
|
|
904
904
|
};
|
|
905
905
|
}
|
|
906
906
|
}
|
|
907
|
-
|
|
907
|
+
ht = new WeakSet(), /**
|
|
908
908
|
* 加载图片
|
|
909
909
|
*/
|
|
910
|
-
|
|
910
|
+
He = function() {
|
|
911
911
|
const t = this.config.$_imageUrl;
|
|
912
912
|
if (!t) {
|
|
913
913
|
console.warn("Image URL is missing");
|
|
@@ -917,71 +917,71 @@ ke = function() {
|
|
|
917
917
|
e.crossOrigin = "anonymous", e.src = t, e.onload = () => {
|
|
918
918
|
this.getElement().image(e);
|
|
919
919
|
const s = this.config.width ?? e.width, o = this.config.height ?? e.height;
|
|
920
|
-
this.getElement().width(Math.max(s,
|
|
920
|
+
this.getElement().width(Math.max(s, Q.MIN_SIZE)), this.getElement().height(Math.max(o, Q.MIN_SIZE));
|
|
921
921
|
}, e.onerror = () => {
|
|
922
922
|
console.error("Failed to load image:", t);
|
|
923
923
|
};
|
|
924
|
-
},
|
|
924
|
+
}, Pt = new WeakMap(), Bt = new WeakMap(), /**
|
|
925
925
|
* 设置事件处理器
|
|
926
926
|
*/
|
|
927
|
-
|
|
928
|
-
this.core.on("toolType:change", r(this,
|
|
929
|
-
const s = e.target, o = Math.max(
|
|
930
|
-
s.scale({ x: 1, y: 1 }), s.width(o), s.height(a),
|
|
927
|
+
Ai = function(t) {
|
|
928
|
+
this.core.on("toolType:change", r(this, Pt)), t.on("transform", (e) => {
|
|
929
|
+
const s = e.target, o = Math.max(Q.MIN_SIZE, s.width() * s.scaleX()), a = Math.max(Q.MIN_SIZE, s.height() * s.scaleY());
|
|
930
|
+
s.scale({ x: 1, y: 1 }), s.width(o), s.height(a), E(this, ht, Le).call(this);
|
|
931
931
|
}), t.on("transformend", () => {
|
|
932
|
-
this.syncConfigFromElement(), r(this,
|
|
932
|
+
this.syncConfigFromElement(), r(this, Bt).call(this);
|
|
933
933
|
}), t.on("dragmove", () => {
|
|
934
|
-
|
|
934
|
+
E(this, ht, Le).call(this);
|
|
935
935
|
}), t.on("dragend", () => {
|
|
936
|
-
this.syncConfigFromElement(), r(this,
|
|
936
|
+
this.syncConfigFromElement(), r(this, Bt).call(this);
|
|
937
937
|
});
|
|
938
938
|
}, /**
|
|
939
939
|
* 同步 image-marker 节点的位置(实时更新 Konva 元素)
|
|
940
940
|
*/
|
|
941
|
-
|
|
941
|
+
Le = function() {
|
|
942
942
|
const t = this.getElement(), e = t.getLayer();
|
|
943
943
|
if (!e) return;
|
|
944
944
|
const s = t.x(), o = t.y(), a = t.width(), h = t.height(), l = e.find(
|
|
945
945
|
(f) => f.hasName(this.config.id)
|
|
946
946
|
), d = this.core.getState().nodes || [];
|
|
947
947
|
l.forEach((f) => {
|
|
948
|
-
const
|
|
949
|
-
if (
|
|
950
|
-
const { start:
|
|
948
|
+
const m = d.find((u) => u.id === f.id());
|
|
949
|
+
if (m?.$_type === "image-marker" && m.$_relativeBox) {
|
|
950
|
+
const { start: u, end: y } = m.$_relativeBox, w = s + u.ratioX * a, v = o + u.ratioY * h, M = s + y.ratioX * a, C = o + y.ratioY * h, B = Math.min(w, M), dt = Math.min(v, C), K = Math.abs(M - w), q = Math.abs(C - v);
|
|
951
951
|
f.setAttrs({
|
|
952
|
-
x:
|
|
953
|
-
y:
|
|
954
|
-
width:
|
|
955
|
-
height:
|
|
956
|
-
}), f.getChildren().forEach((
|
|
957
|
-
|
|
958
|
-
}),
|
|
952
|
+
x: B,
|
|
953
|
+
y: dt,
|
|
954
|
+
width: K,
|
|
955
|
+
height: q
|
|
956
|
+
}), f.getChildren().forEach((z) => {
|
|
957
|
+
z.getClassName() === "Rect" ? z.setAttrs({ width: K, height: q }) : z.getClassName() === "Group" && z.setAttrs({ x: K, y: q });
|
|
958
|
+
}), xi(f)?.syncConfigFromElement();
|
|
959
959
|
}
|
|
960
960
|
});
|
|
961
961
|
};
|
|
962
|
-
var
|
|
963
|
-
class
|
|
962
|
+
var et, X, mt, at, _t, Mt, $t, Fi, Hi;
|
|
963
|
+
class Es extends st {
|
|
964
964
|
constructor(t, e, s = !1) {
|
|
965
965
|
super();
|
|
966
|
-
|
|
966
|
+
g(this, $t);
|
|
967
967
|
p(this, "core");
|
|
968
968
|
p(this, "config");
|
|
969
969
|
p(this, "element");
|
|
970
970
|
p(this, "isDraft");
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
this.core = t, this.config =
|
|
971
|
+
g(this, et);
|
|
972
|
+
g(this, X);
|
|
973
|
+
g(this, mt);
|
|
974
|
+
g(this, at);
|
|
975
|
+
g(this, _t);
|
|
976
|
+
g(this, Mt);
|
|
977
|
+
this.core = t, this.config = gi(e, this.core.getTheme()), this.isDraft = s, this.element = this.createElement(), rt(this.element, this);
|
|
978
978
|
const o = this.getElement();
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
}), this.core.on("viewport:scale:change", r(this,
|
|
979
|
+
x(this, et, o.findOne(".rect")), x(this, X, o.findOne(".marker-group")), x(this, mt, r(this, X).findOne("Circle")), x(this, at, r(this, X).findOne("Text")), E(this, $t, Hi).call(this), x(this, _t, () => {
|
|
980
|
+
E(this, $t, Fi).call(this);
|
|
981
|
+
}), this.core.on("viewport:scale:change", r(this, _t)), x(this, Mt, (a) => {
|
|
982
982
|
const h = a.includes(this.config.id);
|
|
983
983
|
this.setFocusState(h);
|
|
984
|
-
}), this.core.on("nodes:selected", r(this,
|
|
984
|
+
}), this.core.on("nodes:selected", r(this, Mt));
|
|
985
985
|
}
|
|
986
986
|
getID() {
|
|
987
987
|
return this.config.id;
|
|
@@ -990,14 +990,14 @@ class fs extends et {
|
|
|
990
990
|
return this.config;
|
|
991
991
|
}
|
|
992
992
|
createElement() {
|
|
993
|
-
const t = Math.max(this.config.width ??
|
|
993
|
+
const t = Math.max(this.config.width ?? N.MIN_SIZE, N.MIN_SIZE), e = Math.max(this.config.height ?? N.MIN_SIZE, N.MIN_SIZE), s = new _.Group({
|
|
994
994
|
id: this.config.id,
|
|
995
995
|
name: `${b.nodeRoot} ${b.imageMarker} ${this.config.$_parentId}`,
|
|
996
996
|
x: this.config.x,
|
|
997
997
|
y: this.config.y,
|
|
998
998
|
width: t,
|
|
999
999
|
height: e
|
|
1000
|
-
}), o = this.core.getStageScale(), a = 2 / o, h = [5 / o, 5 / o], l =
|
|
1000
|
+
}), o = this.core.getStageScale(), a = 2 / o, h = [5 / o, 5 / o], l = N.CORNER_RADIUS / o, d = new _.Rect({
|
|
1001
1001
|
name: "rect",
|
|
1002
1002
|
x: 0,
|
|
1003
1003
|
y: 0,
|
|
@@ -1008,28 +1008,28 @@ class fs extends et {
|
|
|
1008
1008
|
dash: h,
|
|
1009
1009
|
cornerRadius: l,
|
|
1010
1010
|
listening: !1
|
|
1011
|
-
}), f = new
|
|
1011
|
+
}), f = new _.Group({
|
|
1012
1012
|
name: "marker-group",
|
|
1013
1013
|
x: t,
|
|
1014
1014
|
y: e,
|
|
1015
1015
|
visible: !this.isDraft
|
|
1016
|
-
}),
|
|
1017
|
-
radius:
|
|
1016
|
+
}), m = 14 / o, u = 3 / o, y = 16 / o, w = new _.Circle({
|
|
1017
|
+
radius: m,
|
|
1018
1018
|
fill: this.config.markerColor,
|
|
1019
1019
|
stroke: "white",
|
|
1020
|
-
strokeWidth:
|
|
1021
|
-
}), v = new
|
|
1022
|
-
x: -
|
|
1023
|
-
y: -
|
|
1024
|
-
width:
|
|
1025
|
-
height:
|
|
1020
|
+
strokeWidth: u
|
|
1021
|
+
}), v = new _.Text({
|
|
1022
|
+
x: -m,
|
|
1023
|
+
y: -m,
|
|
1024
|
+
width: m * 2,
|
|
1025
|
+
height: m * 2,
|
|
1026
1026
|
text: String(this.config.$_markerNumber || ""),
|
|
1027
1027
|
align: "center",
|
|
1028
1028
|
verticalAlign: "middle",
|
|
1029
1029
|
fontSize: y,
|
|
1030
1030
|
fill: "white"
|
|
1031
1031
|
});
|
|
1032
|
-
return f.add(
|
|
1032
|
+
return f.add(w), f.add(v), s.add(d), s.add(f), s;
|
|
1033
1033
|
}
|
|
1034
1034
|
/**
|
|
1035
1035
|
* 获取 Konva.Group 实例
|
|
@@ -1041,7 +1041,7 @@ class fs extends et {
|
|
|
1041
1041
|
* 更新节点数据
|
|
1042
1042
|
*/
|
|
1043
1043
|
update(t) {
|
|
1044
|
-
this.config =
|
|
1044
|
+
this.config = gi(
|
|
1045
1045
|
{
|
|
1046
1046
|
...this.config,
|
|
1047
1047
|
...t
|
|
@@ -1050,21 +1050,21 @@ class fs extends et {
|
|
|
1050
1050
|
);
|
|
1051
1051
|
const e = this.getElement();
|
|
1052
1052
|
e.x(this.config.x), e.y(this.config.y);
|
|
1053
|
-
const s = Math.max(this.config.width ??
|
|
1054
|
-
e.width(s), e.height(o), r(this,
|
|
1053
|
+
const s = Math.max(this.config.width ?? N.MIN_SIZE, N.MIN_SIZE), o = Math.max(this.config.height ?? N.MIN_SIZE, N.MIN_SIZE);
|
|
1054
|
+
e.width(s), e.height(o), r(this, et).width(s), r(this, et).height(o), r(this, X).x(s), r(this, X).y(o), t.markerColor && (r(this, et).stroke(t.markerColor), r(this, mt).fill(t.markerColor)), t.$_markerNumber !== void 0 && r(this, at).text(String(t.$_markerNumber));
|
|
1055
1055
|
}
|
|
1056
1056
|
/**
|
|
1057
1057
|
* 销毁
|
|
1058
1058
|
*/
|
|
1059
1059
|
destroy() {
|
|
1060
|
-
this.core.off("viewport:scale:change", r(this,
|
|
1060
|
+
this.core.off("viewport:scale:change", r(this, _t)), this.core.off("nodes:selected", r(this, Mt)), this.element.destroy();
|
|
1061
1061
|
}
|
|
1062
1062
|
/**
|
|
1063
1063
|
* 更新焦点状态(hover 或 selected)
|
|
1064
1064
|
*/
|
|
1065
1065
|
setFocusState(t) {
|
|
1066
1066
|
const e = this.core.getStageScale(), s = t ? 4 / e : 3 / e, o = t ? 1.2 : 1;
|
|
1067
|
-
r(this,
|
|
1067
|
+
r(this, et).strokeWidth(s), r(this, mt).strokeWidth(s), r(this, X).scaleX(o), r(this, X).scaleY(o);
|
|
1068
1068
|
}
|
|
1069
1069
|
syncConfigFromElement() {
|
|
1070
1070
|
const t = this.getElement();
|
|
@@ -1077,46 +1077,46 @@ class fs extends et {
|
|
|
1077
1077
|
};
|
|
1078
1078
|
}
|
|
1079
1079
|
}
|
|
1080
|
-
|
|
1080
|
+
et = new WeakMap(), X = new WeakMap(), mt = new WeakMap(), at = new WeakMap(), _t = new WeakMap(), Mt = new WeakMap(), $t = new WeakSet(), /**
|
|
1081
1081
|
* 更新标记点的缩放以保持视觉大小不变
|
|
1082
1082
|
*/
|
|
1083
|
-
|
|
1084
|
-
const t = this.core.getStageScale(), e = 14 / t, s = 3 / t, o = 16 / t, a = 3 / t, h = [5 / t, 5 / t], l =
|
|
1085
|
-
r(this,
|
|
1083
|
+
Fi = function() {
|
|
1084
|
+
const t = this.core.getStageScale(), e = 14 / t, s = 3 / t, o = 16 / t, a = 3 / t, h = [5 / t, 5 / t], l = N.CORNER_RADIUS / t;
|
|
1085
|
+
r(this, et).strokeWidth(a), r(this, et).dash(h), r(this, et).cornerRadius(l), r(this, mt).radius(e), r(this, mt).strokeWidth(s), r(this, at).x(-e), r(this, at).y(-e), r(this, at).width(e * 2), r(this, at).height(e * 2), r(this, at).fontSize(o);
|
|
1086
1086
|
}, /**
|
|
1087
1087
|
* 设置事件处理器
|
|
1088
1088
|
*/
|
|
1089
|
-
|
|
1090
|
-
r(this,
|
|
1089
|
+
Hi = function() {
|
|
1090
|
+
r(this, X).on("pointerover", () => {
|
|
1091
1091
|
this.setFocusState(!0), this.core._setCursor("pointer");
|
|
1092
|
-
}), r(this,
|
|
1092
|
+
}), r(this, X).on("pointerout", () => {
|
|
1093
1093
|
const e = (this.core.getState().selectedNodeIds || []).includes(this.config.id);
|
|
1094
1094
|
this.setFocusState(e), this.core._resetCursor();
|
|
1095
|
-
}), r(this,
|
|
1095
|
+
}), r(this, X).on("pointerdown", () => {
|
|
1096
1096
|
this.core._selectNodes([this.config.id]);
|
|
1097
1097
|
});
|
|
1098
1098
|
};
|
|
1099
|
-
var
|
|
1100
|
-
class
|
|
1099
|
+
var gt, Vt, xe, Li;
|
|
1100
|
+
class Ss extends st {
|
|
1101
1101
|
constructor(t, e, s = !1) {
|
|
1102
1102
|
super();
|
|
1103
|
-
|
|
1103
|
+
g(this, xe);
|
|
1104
1104
|
p(this, "core");
|
|
1105
1105
|
p(this, "config");
|
|
1106
1106
|
p(this, "element");
|
|
1107
1107
|
p(this, "isDraft");
|
|
1108
1108
|
p(this, "htmlElement");
|
|
1109
|
-
|
|
1109
|
+
g(this, gt, () => {
|
|
1110
1110
|
const t = this.element.getClientRect();
|
|
1111
1111
|
this.htmlElement.style.left = `${t.x}px`, this.htmlElement.style.top = `${t.y}px`, this.htmlElement.style.width = `${t.width}px`, this.htmlElement.style.height = `${t.height}px`;
|
|
1112
1112
|
});
|
|
1113
|
-
|
|
1113
|
+
g(this, Vt, ({ type: t }) => {
|
|
1114
1114
|
const e = t === "select";
|
|
1115
1115
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1116
1116
|
});
|
|
1117
|
-
this.core = t, this.config =
|
|
1118
|
-
r(this,
|
|
1119
|
-
}),
|
|
1117
|
+
this.core = t, this.config = ui(e, this.core.getTheme()), this.element = this.createElement(), rt(this.element, this), this.isDraft = s, this.htmlElement = document.createElement("div"), this.htmlElement.style.position = "absolute", this.htmlElement.style.pointerEvents = "none", this.htmlElement.innerHTML = this.config.$_htmlContent, this.core.getContainer().appendChild(this.htmlElement), setTimeout(() => {
|
|
1118
|
+
r(this, gt).call(this);
|
|
1119
|
+
}), E(this, xe, Li).call(this);
|
|
1120
1120
|
}
|
|
1121
1121
|
getID() {
|
|
1122
1122
|
return this.config.id;
|
|
@@ -1129,7 +1129,7 @@ class ps extends et {
|
|
|
1129
1129
|
this.config = e;
|
|
1130
1130
|
}
|
|
1131
1131
|
createElement() {
|
|
1132
|
-
return new
|
|
1132
|
+
return new _.Rect(this.config);
|
|
1133
1133
|
}
|
|
1134
1134
|
/**
|
|
1135
1135
|
* 获取 Konva.Rect 实例
|
|
@@ -1141,55 +1141,55 @@ class ps extends et {
|
|
|
1141
1141
|
* 更新节点数据
|
|
1142
1142
|
*/
|
|
1143
1143
|
update(t) {
|
|
1144
|
-
this.config =
|
|
1144
|
+
this.config = ui(
|
|
1145
1145
|
{
|
|
1146
1146
|
...this.config,
|
|
1147
1147
|
...t
|
|
1148
1148
|
},
|
|
1149
1149
|
this.core.getTheme()
|
|
1150
|
-
), this.getElement().setAttrs(this.config), r(this,
|
|
1150
|
+
), this.getElement().setAttrs(this.config), r(this, gt).call(this);
|
|
1151
1151
|
}
|
|
1152
1152
|
/**
|
|
1153
1153
|
* 销毁
|
|
1154
1154
|
*/
|
|
1155
1155
|
destroy() {
|
|
1156
|
-
this.core.off("toolType:change", r(this,
|
|
1156
|
+
this.core.off("toolType:change", r(this, Vt)), this.core.off("viewport:change", r(this, gt)), this.htmlElement.remove(), this.element.destroy();
|
|
1157
1157
|
}
|
|
1158
1158
|
}
|
|
1159
|
-
|
|
1159
|
+
gt = new WeakMap(), Vt = new WeakMap(), xe = new WeakSet(), /**
|
|
1160
1160
|
* 设置事件处理器
|
|
1161
1161
|
*/
|
|
1162
|
-
|
|
1162
|
+
Li = function() {
|
|
1163
1163
|
const t = this.getElement();
|
|
1164
|
-
this.core.on("toolType:change", r(this,
|
|
1165
|
-
const s = e.target, o = Math.max(
|
|
1166
|
-
s.scale({ x: 1, y: 1 }), s.width(o), s.height(a), r(this,
|
|
1164
|
+
this.core.on("toolType:change", r(this, Vt)), this.core.on("viewport:change", r(this, gt)), t.on("transform", (e) => {
|
|
1165
|
+
const s = e.target, o = Math.max(N.MIN_SIZE, s.width() * s.scaleX()), a = Math.max(N.MIN_SIZE, s.height() * s.scaleY());
|
|
1166
|
+
s.scale({ x: 1, y: 1 }), s.width(o), s.height(a), r(this, gt).call(this);
|
|
1167
1167
|
}), t.on("transformend", (e) => {
|
|
1168
1168
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1169
1169
|
}), t.on("dragmove", () => {
|
|
1170
|
-
r(this,
|
|
1170
|
+
r(this, gt).call(this);
|
|
1171
1171
|
}), t.on("dragend", (e) => {
|
|
1172
1172
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1173
1173
|
});
|
|
1174
1174
|
};
|
|
1175
|
-
var
|
|
1176
|
-
class
|
|
1175
|
+
var Ot, we, be, Di;
|
|
1176
|
+
class Ns extends st {
|
|
1177
1177
|
constructor(t, e, s = !1) {
|
|
1178
1178
|
super();
|
|
1179
|
-
|
|
1179
|
+
g(this, be);
|
|
1180
1180
|
p(this, "core");
|
|
1181
1181
|
p(this, "config");
|
|
1182
1182
|
p(this, "element");
|
|
1183
1183
|
p(this, "isDraft");
|
|
1184
1184
|
p(this, "rect");
|
|
1185
|
-
|
|
1185
|
+
g(this, Ot, ({ type: t }) => {
|
|
1186
1186
|
const e = t === "select";
|
|
1187
1187
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1188
1188
|
});
|
|
1189
1189
|
/**
|
|
1190
1190
|
* 编辑文字
|
|
1191
1191
|
*/
|
|
1192
|
-
|
|
1192
|
+
g(this, we, () => {
|
|
1193
1193
|
const t = this.element, e = this.core.getCanvasTransformer(), s = t.getClientRect(), o = document.createElement("textarea");
|
|
1194
1194
|
this.core.getStage().getContent().appendChild(o), o.name = "text-editor", o.draggable = !1, o.value = t.text(), o.style.position = "absolute", o.style.top = s.y + "px", o.style.left = s.x + "px", o.style.minWidth = "2px", o.style.fieldSizing = "content", o.style.whiteSpace = "nowrap", o.style.height = t.height() + "px", o.style.fontSize = t.fontSize() + "px", o.style.border = "none", o.style.padding = "0px", o.style.margin = "0px", o.style.overflow = "hidden", o.style.background = "none", o.style.outline = "none", o.style.resize = "none", o.style.lineHeight = t.lineHeight().toString(), o.style.fontFamily = t.fontFamily(), o.style.transformOrigin = "left top", o.style.textAlign = t.align(), o.style.color = t.fill().toString();
|
|
1195
1195
|
const a = t.rotation();
|
|
@@ -1198,29 +1198,29 @@ class ys extends et {
|
|
|
1198
1198
|
const l = () => {
|
|
1199
1199
|
this.core.off("viewport:change", f), o.parentNode?.removeChild(o), window.removeEventListener("click", d), window.removeEventListener("touchstart", d), t.show(), e.getTransformer().show(), e.getTransformer().forceUpdate();
|
|
1200
1200
|
};
|
|
1201
|
-
o.addEventListener("keydown", function(
|
|
1202
|
-
if (
|
|
1203
|
-
const
|
|
1204
|
-
t.text(o.value), l(),
|
|
1201
|
+
o.addEventListener("keydown", function(m) {
|
|
1202
|
+
if (m.key === "Escape") {
|
|
1203
|
+
const u = o.value;
|
|
1204
|
+
t.text(o.value), l(), u.trim() || t.destroy();
|
|
1205
1205
|
}
|
|
1206
1206
|
}), o.addEventListener("keydown", function() {
|
|
1207
1207
|
o.style.height = "auto", o.style.height = o.scrollHeight + t.fontSize() * t.lineHeight() + "px";
|
|
1208
1208
|
});
|
|
1209
|
-
const d = (
|
|
1210
|
-
|
|
1209
|
+
const d = (m) => {
|
|
1210
|
+
m.target !== o && (t.text(o.value), l());
|
|
1211
1211
|
}, f = () => {
|
|
1212
|
-
const
|
|
1213
|
-
o.style.top =
|
|
1214
|
-
const
|
|
1212
|
+
const m = t.getClientRect();
|
|
1213
|
+
o.style.top = m.y + "px", o.style.left = m.x + "px";
|
|
1214
|
+
const u = t.rotation();
|
|
1215
1215
|
let y = "";
|
|
1216
|
-
|
|
1216
|
+
u && (y += "rotateZ(" + u + "deg)"), o.style.transform = y + `scale(${t.getAbsoluteScale().x})`;
|
|
1217
1217
|
};
|
|
1218
1218
|
setTimeout(() => {
|
|
1219
1219
|
this.core.on("viewport:change", f), window.addEventListener("click", d), window.addEventListener("touchstart", d);
|
|
1220
1220
|
});
|
|
1221
1221
|
});
|
|
1222
|
-
this.core = t, this.config =
|
|
1223
|
-
r(this,
|
|
1222
|
+
this.core = t, this.config = mi(e, this.core.getTheme()), this.element = this.createElement(), this.rect = new _.Rect(this.config), rt(this.element, this), this.isDraft = s, E(this, be, Di).call(this), setTimeout(() => {
|
|
1223
|
+
r(this, we).call(this);
|
|
1224
1224
|
});
|
|
1225
1225
|
}
|
|
1226
1226
|
getID() {
|
|
@@ -1234,7 +1234,7 @@ class ys extends et {
|
|
|
1234
1234
|
this.config = e;
|
|
1235
1235
|
}
|
|
1236
1236
|
createElement() {
|
|
1237
|
-
return new
|
|
1237
|
+
return new _.Text(this.config);
|
|
1238
1238
|
}
|
|
1239
1239
|
/**
|
|
1240
1240
|
* 获取 Konva.Text 实例
|
|
@@ -1246,7 +1246,7 @@ class ys extends et {
|
|
|
1246
1246
|
* 更新节点数据
|
|
1247
1247
|
*/
|
|
1248
1248
|
update(t) {
|
|
1249
|
-
this.config =
|
|
1249
|
+
this.config = mi(
|
|
1250
1250
|
{
|
|
1251
1251
|
...this.config,
|
|
1252
1252
|
...t
|
|
@@ -1258,16 +1258,16 @@ class ys extends et {
|
|
|
1258
1258
|
* 销毁
|
|
1259
1259
|
*/
|
|
1260
1260
|
destroy() {
|
|
1261
|
-
this.core.off("toolType:change", r(this,
|
|
1261
|
+
this.core.off("toolType:change", r(this, Ot)), this.element.destroy();
|
|
1262
1262
|
}
|
|
1263
1263
|
}
|
|
1264
|
-
|
|
1264
|
+
Ot = new WeakMap(), we = new WeakMap(), be = new WeakSet(), /**
|
|
1265
1265
|
* 设置事件处理器
|
|
1266
1266
|
*/
|
|
1267
|
-
|
|
1267
|
+
Di = function() {
|
|
1268
1268
|
const t = this.getElement();
|
|
1269
|
-
this.core.on("toolType:change", r(this,
|
|
1270
|
-
const s = e.target, o = Math.max(
|
|
1269
|
+
this.core.on("toolType:change", r(this, Ot)), t.on("transform", (e) => {
|
|
1270
|
+
const s = e.target, o = Math.max(N.MIN_SIZE, s.width() * s.scaleX()), a = Math.max(N.MIN_SIZE, s.height() * s.scaleY());
|
|
1271
1271
|
s.scale({ x: 1, y: 1 }), s.width(o), s.height(a);
|
|
1272
1272
|
}), t.on("transformend", (e) => {
|
|
1273
1273
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
@@ -1275,11 +1275,11 @@ $i = function() {
|
|
|
1275
1275
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1276
1276
|
});
|
|
1277
1277
|
};
|
|
1278
|
-
var
|
|
1279
|
-
class
|
|
1278
|
+
var It, ft, Ee, Zt, Ut, zt, Wt, Se, Pi;
|
|
1279
|
+
class Ts extends st {
|
|
1280
1280
|
constructor(t, e, s = !1) {
|
|
1281
1281
|
super();
|
|
1282
|
-
|
|
1282
|
+
g(this, Se);
|
|
1283
1283
|
p(this, "core");
|
|
1284
1284
|
p(this, "config");
|
|
1285
1285
|
p(this, "element");
|
|
@@ -1292,29 +1292,29 @@ class vs extends et {
|
|
|
1292
1292
|
this.htmlElement.id = "rich-text-html-element", this.htmlElement.style.transition = "none", this.htmlElement.style.opacity = "1", this.element.opacity(0), this.core._selectNodes(), this.core.isEditingText = !0, this.htmlElement.style.pointerEvents = "auto";
|
|
1293
1293
|
const t = this.htmlEditorElement.innerHTML;
|
|
1294
1294
|
this.htmlEditorElement.innerHTML = "";
|
|
1295
|
-
const e = new
|
|
1295
|
+
const e = new Dn({
|
|
1296
1296
|
element: this.htmlEditorElement,
|
|
1297
1297
|
extensions: [
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1298
|
+
Pn,
|
|
1299
|
+
Bn.configure({ multicolor: !0 }),
|
|
1300
|
+
Vn,
|
|
1301
|
+
On,
|
|
1302
|
+
Zn
|
|
1303
1303
|
],
|
|
1304
1304
|
content: t,
|
|
1305
1305
|
autofocus: !0
|
|
1306
1306
|
});
|
|
1307
1307
|
e.scaleWhenCreate = this.config.scaleWhenCreate || 1, this.editor = e, this.core._registerTextEditor(e), this.core.getMainLayer().listening(!1), e.on("focus", () => {
|
|
1308
|
-
window.addEventListener("click", r(this,
|
|
1309
|
-
}), window.addEventListener("keydown", r(this,
|
|
1308
|
+
window.addEventListener("click", r(this, Wt));
|
|
1309
|
+
}), window.addEventListener("keydown", r(this, zt));
|
|
1310
1310
|
});
|
|
1311
|
-
|
|
1311
|
+
g(this, It, async () => {
|
|
1312
1312
|
const t = this.htmlEditorElement.getBoundingClientRect();
|
|
1313
1313
|
if (t.width === 0 || t.height === 0)
|
|
1314
1314
|
return;
|
|
1315
1315
|
this.htmlElement.style.opacity = "1", this.element.opacity(0);
|
|
1316
1316
|
const e = t.width / (this.core.getState().viewport.scale / this.config.scaleWhenCreate), s = t.height / (this.core.getState().viewport.scale / this.config.scaleWhenCreate);
|
|
1317
|
-
return
|
|
1317
|
+
return Un(this.htmlEditorElement, {
|
|
1318
1318
|
width: e,
|
|
1319
1319
|
height: s,
|
|
1320
1320
|
pixelRatio: 2,
|
|
@@ -1333,17 +1333,17 @@ class vs extends et {
|
|
|
1333
1333
|
});
|
|
1334
1334
|
});
|
|
1335
1335
|
p(this, "detachEditor", () => {
|
|
1336
|
-
this.editor && (this.htmlElement.id = "", this.htmlEditorElement.innerHTML = this.editor.getHTML(), this.config.$_htmlContent = this.editor.getHTML(), this.editor.commands.blur(), this.htmlElement.style.pointerEvents = "none", this.core.isEditingText = !1, this.core._unregisterTextEditor(), window.removeEventListener("keydown", r(this,
|
|
1336
|
+
this.editor && (this.htmlElement.id = "", this.htmlEditorElement.innerHTML = this.editor.getHTML(), this.config.$_htmlContent = this.editor.getHTML(), this.editor.commands.blur(), this.htmlElement.style.pointerEvents = "none", this.core.isEditingText = !1, this.core._unregisterTextEditor(), window.removeEventListener("keydown", r(this, zt)), window.removeEventListener("click", r(this, Wt)), this.editor.destroy(), this.editor = void 0, this.core.getMainLayer().listening(!0), r(this, It).call(this).then(() => {
|
|
1337
1337
|
this.htmlElement.style.transition = "opacity 0.1s", this.htmlElement.style.opacity = "0", this.element.opacity(1);
|
|
1338
1338
|
}).finally(() => {
|
|
1339
1339
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !1);
|
|
1340
1340
|
}));
|
|
1341
1341
|
});
|
|
1342
|
-
|
|
1342
|
+
g(this, ft, () => {
|
|
1343
1343
|
const t = this.element.getClientRect();
|
|
1344
1344
|
this.htmlElement.style.left = `${t.x}px`, this.htmlElement.style.top = `${t.y}px`, this.config.lockX ? this.htmlEditorElement.style.width = `${this.element.width() / this.config.htmlScale * this.config.scaleWhenCreate}px` : this.htmlEditorElement.style.width = "max-content", this.htmlEditorElement.style.transform = `scale(${this.config.htmlScale})`;
|
|
1345
1345
|
});
|
|
1346
|
-
|
|
1346
|
+
g(this, Ee, () => {
|
|
1347
1347
|
this.resizeObserver = new ResizeObserver((t) => {
|
|
1348
1348
|
for (const e of t) {
|
|
1349
1349
|
let s = !1;
|
|
@@ -1354,23 +1354,23 @@ class vs extends et {
|
|
|
1354
1354
|
}
|
|
1355
1355
|
}), this.resizeObserver.observe(this.htmlEditorElement);
|
|
1356
1356
|
});
|
|
1357
|
-
|
|
1357
|
+
g(this, Zt, ({ type: t }) => {
|
|
1358
1358
|
const e = t === "select";
|
|
1359
1359
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1360
1360
|
});
|
|
1361
|
-
|
|
1361
|
+
g(this, Ut, (t) => {
|
|
1362
1362
|
const e = this.element.getClientRect();
|
|
1363
1363
|
this.htmlElement.style.left = `${e.x}px`, this.htmlElement.style.top = `${e.y}px`, this.htmlElement.style.transform = `scale(${this.core.getState().viewport.scale / this.config.scaleWhenCreate})`;
|
|
1364
1364
|
});
|
|
1365
|
-
|
|
1365
|
+
g(this, zt, (t) => {
|
|
1366
1366
|
t.key === "Escape" && this.detachEditor();
|
|
1367
1367
|
});
|
|
1368
|
-
|
|
1368
|
+
g(this, Wt, (t) => {
|
|
1369
1369
|
const e = t.target;
|
|
1370
1370
|
this.htmlElement.contains(e) || this.detachEditor();
|
|
1371
1371
|
});
|
|
1372
|
-
this.core = t, this.config =
|
|
1373
|
-
r(this,
|
|
1372
|
+
this.core = t, this.config = fi(e, this.core.getTheme()), this.config.scaleWhenCreate = this.config.scaleWhenCreate || this.core.getState().viewport.scale || 1, this.config.htmlScale = this.config.htmlScale || 1, this.element = this.createElement(), rt(this.element, this), this.isDraft = s, this.htmlElement = document.createElement("div"), this.htmlElement.style.position = "absolute", this.htmlElement.style.pointerEvents = "none", this.htmlElement.style.overflowWrap = "break-word", this.htmlElement.style.transformOrigin = "top left", this.htmlElement.style.opacity = "0", this.htmlElement.style.transition = "opacity 0.1s", this.htmlEditorElement = document.createElement("div"), this.htmlEditorElement.style.transformOrigin = "top left", this.htmlEditorElement.style.width = "max-content", this.htmlEditorElement.innerHTML = this.config.$_htmlContent || "", this.htmlElement.appendChild(this.htmlEditorElement), this.core.getStage().content.appendChild(this.htmlElement), r(this, Ee).call(this), E(this, Se, Pi).call(this), setTimeout(() => {
|
|
1373
|
+
r(this, ft).call(this), this.htmlElement.style.transform = `scale(${this.core.getState().viewport.scale / this.config.scaleWhenCreate})`, r(this, It).call(this);
|
|
1374
1374
|
});
|
|
1375
1375
|
}
|
|
1376
1376
|
getID() {
|
|
@@ -1384,7 +1384,7 @@ class vs extends et {
|
|
|
1384
1384
|
delete e.image, this.config = e;
|
|
1385
1385
|
}
|
|
1386
1386
|
createElement() {
|
|
1387
|
-
return new
|
|
1387
|
+
return new _.Image({ ...this.config });
|
|
1388
1388
|
}
|
|
1389
1389
|
/**
|
|
1390
1390
|
* 获取 Konva.Rect 实例
|
|
@@ -1396,52 +1396,52 @@ class vs extends et {
|
|
|
1396
1396
|
* 更新节点数据
|
|
1397
1397
|
*/
|
|
1398
1398
|
update(t) {
|
|
1399
|
-
this.config =
|
|
1399
|
+
this.config = fi(
|
|
1400
1400
|
{
|
|
1401
1401
|
...this.config,
|
|
1402
1402
|
...t
|
|
1403
1403
|
},
|
|
1404
1404
|
this.core.getTheme()
|
|
1405
|
-
), console.log(this.config), delete this.config.image, this.getElement().setAttrs(this.config), r(this,
|
|
1405
|
+
), console.log(this.config), delete this.config.image, this.getElement().setAttrs(this.config), r(this, ft).call(this);
|
|
1406
1406
|
}
|
|
1407
1407
|
/**
|
|
1408
1408
|
* 销毁
|
|
1409
1409
|
*/
|
|
1410
1410
|
destroy() {
|
|
1411
|
-
this.resizeObserver?.disconnect(), this.core.off("toolType:change", r(this,
|
|
1411
|
+
this.resizeObserver?.disconnect(), this.core.off("toolType:change", r(this, Zt)), this.core.off("viewport:change", r(this, Ut)), this.detachEditor(), this.htmlElement.remove(), this.element.destroy();
|
|
1412
1412
|
}
|
|
1413
1413
|
}
|
|
1414
|
-
|
|
1414
|
+
It = new WeakMap(), ft = new WeakMap(), Ee = new WeakMap(), Zt = new WeakMap(), Ut = new WeakMap(), zt = new WeakMap(), Wt = new WeakMap(), Se = new WeakSet(), /**
|
|
1415
1415
|
* 设置事件处理器
|
|
1416
1416
|
*/
|
|
1417
|
-
|
|
1417
|
+
Pi = function() {
|
|
1418
1418
|
const t = this.getElement();
|
|
1419
|
-
this.core.on("toolType:change", r(this,
|
|
1419
|
+
this.core.on("toolType:change", r(this, Zt)), this.core.on("viewport:change", r(this, Ut)), t.on("transformstart", () => {
|
|
1420
1420
|
this.htmlElement.style.opacity = "1", this.element.opacity(0);
|
|
1421
1421
|
}), t.on("transform", (e) => {
|
|
1422
1422
|
const s = this.core.getTransformer().getActiveAnchor();
|
|
1423
1423
|
if (s === "middle-left" || s === "middle-right") {
|
|
1424
|
-
this.config.lockX = !0, t.setAttr("lockX", !0), t.width(t.width() * t.scaleX()), t.scale({ x: 1, y: 1 }), r(this,
|
|
1424
|
+
this.config.lockX = !0, t.setAttr("lockX", !0), t.width(t.width() * t.scaleX()), t.scale({ x: 1, y: 1 }), r(this, ft).call(this);
|
|
1425
1425
|
return;
|
|
1426
1426
|
}
|
|
1427
|
-
t.width(t.width() * t.scaleX()), t.height(t.height() * t.scaleY()), this.config.htmlScale = this.config.htmlScale * t.scaleX(), t.setAttr("htmlScale", this.config.htmlScale), t.scale({ x: 1, y: 1 }), r(this,
|
|
1427
|
+
t.width(t.width() * t.scaleX()), t.height(t.height() * t.scaleY()), this.config.htmlScale = this.config.htmlScale * t.scaleX(), t.setAttr("htmlScale", this.config.htmlScale), t.scale({ x: 1, y: 1 }), r(this, ft).call(this);
|
|
1428
1428
|
}), t.on("transformend", (e) => {
|
|
1429
|
-
r(this,
|
|
1429
|
+
r(this, It).call(this).finally(() => {
|
|
1430
1430
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1431
1431
|
});
|
|
1432
1432
|
}), t.on("dragmove", () => {
|
|
1433
|
-
r(this,
|
|
1433
|
+
r(this, ft).call(this);
|
|
1434
1434
|
}), t.on("dragend", (e) => {
|
|
1435
1435
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1436
1436
|
}), t.on("pointerdblclick", () => {
|
|
1437
1437
|
this.attachEditor();
|
|
1438
1438
|
});
|
|
1439
1439
|
};
|
|
1440
|
-
var
|
|
1441
|
-
class
|
|
1440
|
+
var Et, De, Xt, Yt, Bi;
|
|
1441
|
+
class _s extends st {
|
|
1442
1442
|
constructor(t, e, s = !1) {
|
|
1443
1443
|
super();
|
|
1444
|
-
|
|
1444
|
+
g(this, Et);
|
|
1445
1445
|
p(this, "core");
|
|
1446
1446
|
p(this, "config");
|
|
1447
1447
|
p(this, "element");
|
|
@@ -1449,16 +1449,16 @@ class Cs extends et {
|
|
|
1449
1449
|
p(this, "imgCover");
|
|
1450
1450
|
p(this, "playIcon");
|
|
1451
1451
|
p(this, "isDraft");
|
|
1452
|
-
|
|
1452
|
+
g(this, Xt, ({ type: t }) => {
|
|
1453
1453
|
const e = t === "select";
|
|
1454
1454
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1455
1455
|
});
|
|
1456
|
-
|
|
1456
|
+
g(this, Yt, () => {
|
|
1457
1457
|
this.getElement().getLayer() && this.core._rebuildStateAfterNodeChange([this], !0);
|
|
1458
1458
|
});
|
|
1459
|
-
this.core = t, this.config =
|
|
1459
|
+
this.core = t, this.config = di(e, this.core.getTheme());
|
|
1460
1460
|
const { group: o, image: a, imgCover: h, playIcon: l } = this.createElement();
|
|
1461
|
-
this.element = o, this.cover = a, this.imgCover = h, this.playIcon = l, this.element = o,
|
|
1461
|
+
this.element = o, this.cover = a, this.imgCover = h, this.playIcon = l, this.element = o, rt(this.element, this), this.isDraft = s, E(this, Et, De).call(this), E(this, Et, Bi).call(this, this.getElement());
|
|
1462
1462
|
}
|
|
1463
1463
|
getID() {
|
|
1464
1464
|
return this.config.id;
|
|
@@ -1470,11 +1470,11 @@ class Cs extends et {
|
|
|
1470
1470
|
this.config = e;
|
|
1471
1471
|
}
|
|
1472
1472
|
createElement() {
|
|
1473
|
-
const t = new
|
|
1473
|
+
const t = new _.Group({
|
|
1474
1474
|
...this.config,
|
|
1475
1475
|
width: void 0,
|
|
1476
1476
|
height: void 0
|
|
1477
|
-
}), e = new
|
|
1477
|
+
}), e = new _.Image({
|
|
1478
1478
|
...this.config,
|
|
1479
1479
|
name: "",
|
|
1480
1480
|
id: `${this.config.id}-image`,
|
|
@@ -1483,7 +1483,7 @@ class Cs extends et {
|
|
|
1483
1483
|
listening: !1
|
|
1484
1484
|
});
|
|
1485
1485
|
t.add(e);
|
|
1486
|
-
const s = new
|
|
1486
|
+
const s = new _.Rect({
|
|
1487
1487
|
name: "",
|
|
1488
1488
|
x: 0,
|
|
1489
1489
|
y: 0,
|
|
@@ -1493,7 +1493,7 @@ class Cs extends et {
|
|
|
1493
1493
|
listening: !1
|
|
1494
1494
|
});
|
|
1495
1495
|
t.add(s);
|
|
1496
|
-
const o = new
|
|
1496
|
+
const o = new _.RegularPolygon({
|
|
1497
1497
|
x: this.config.width / 2,
|
|
1498
1498
|
// 微调使其视觉居中
|
|
1499
1499
|
y: this.config.height / 2,
|
|
@@ -1518,7 +1518,7 @@ class Cs extends et {
|
|
|
1518
1518
|
*/
|
|
1519
1519
|
update(t) {
|
|
1520
1520
|
const e = this.config;
|
|
1521
|
-
this.config =
|
|
1521
|
+
this.config = di(
|
|
1522
1522
|
{
|
|
1523
1523
|
...this.config,
|
|
1524
1524
|
...t
|
|
@@ -1527,13 +1527,13 @@ class Cs extends et {
|
|
|
1527
1527
|
), this.getElement().setAttrs(this.config), this.cover.setAttrs({
|
|
1528
1528
|
...this.config,
|
|
1529
1529
|
id: `${this.config.id}-image`
|
|
1530
|
-
}), t.$_coverUrl && t.$_coverUrl !== e.$_coverUrl &&
|
|
1530
|
+
}), t.$_coverUrl && t.$_coverUrl !== e.$_coverUrl && E(this, Et, De).call(this);
|
|
1531
1531
|
}
|
|
1532
1532
|
/**
|
|
1533
1533
|
* 销毁
|
|
1534
1534
|
*/
|
|
1535
1535
|
destroy() {
|
|
1536
|
-
this.core.off("toolType:change", r(this,
|
|
1536
|
+
this.core.off("toolType:change", r(this, Xt)), this.element.destroy();
|
|
1537
1537
|
}
|
|
1538
1538
|
getConfig() {
|
|
1539
1539
|
return {
|
|
@@ -1544,10 +1544,10 @@ class Cs extends et {
|
|
|
1544
1544
|
};
|
|
1545
1545
|
}
|
|
1546
1546
|
}
|
|
1547
|
-
|
|
1547
|
+
Et = new WeakSet(), /**
|
|
1548
1548
|
* 加载图片
|
|
1549
1549
|
*/
|
|
1550
|
-
|
|
1550
|
+
De = function() {
|
|
1551
1551
|
const t = this.config.$_coverUrl;
|
|
1552
1552
|
if (!t) {
|
|
1553
1553
|
console.warn("Image URL is missing");
|
|
@@ -1557,40 +1557,40 @@ $e = function() {
|
|
|
1557
1557
|
e.crossOrigin = "anonymous", e.src = t, e.onload = () => {
|
|
1558
1558
|
this.cover.image(e);
|
|
1559
1559
|
let s = this.config.width ?? e.width, o = this.config.height ?? e.height;
|
|
1560
|
-
s = Math.max(s,
|
|
1560
|
+
s = Math.max(s, Q.MIN_SIZE), o = Math.max(o, Q.MIN_SIZE), this.cover.width(s), this.cover.height(o), this.imgCover.width(s), this.imgCover.height(o), this.playIcon.x(s / 2), this.playIcon.y(o / 2);
|
|
1561
1561
|
}, e.onerror = () => {
|
|
1562
1562
|
console.error("Failed to load image:", t);
|
|
1563
1563
|
};
|
|
1564
|
-
},
|
|
1564
|
+
}, Xt = new WeakMap(), Yt = new WeakMap(), /**
|
|
1565
1565
|
* 设置事件处理器
|
|
1566
1566
|
*/
|
|
1567
|
-
|
|
1568
|
-
this.core.on("toolType:change", r(this,
|
|
1569
|
-
const s = e.target, o = Math.max(
|
|
1570
|
-
|
|
1567
|
+
Bi = function(t) {
|
|
1568
|
+
this.core.on("toolType:change", r(this, Xt)), t.on("transform", (e) => {
|
|
1569
|
+
const s = e.target, o = Math.max(Q.MIN_SIZE, this.cover.width() * s.scaleX()), a = Math.max(
|
|
1570
|
+
Q.MIN_SIZE,
|
|
1571
1571
|
this.cover.height() * s.scaleY()
|
|
1572
1572
|
);
|
|
1573
1573
|
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 });
|
|
1574
1574
|
}), t.on("transformend", () => {
|
|
1575
|
-
this.syncConfigFromElement(), r(this,
|
|
1575
|
+
this.syncConfigFromElement(), r(this, Yt).call(this);
|
|
1576
1576
|
}), t.on("dragend", () => {
|
|
1577
|
-
this.syncConfigFromElement(), r(this,
|
|
1577
|
+
this.syncConfigFromElement(), r(this, Yt).call(this);
|
|
1578
1578
|
});
|
|
1579
1579
|
};
|
|
1580
|
-
var
|
|
1581
|
-
class
|
|
1580
|
+
var Gt, Ne, Vi;
|
|
1581
|
+
class Ms extends st {
|
|
1582
1582
|
constructor(t, e, s = !1) {
|
|
1583
1583
|
super();
|
|
1584
|
-
|
|
1584
|
+
g(this, Ne);
|
|
1585
1585
|
p(this, "core");
|
|
1586
1586
|
p(this, "config");
|
|
1587
1587
|
p(this, "element");
|
|
1588
1588
|
p(this, "isDraft");
|
|
1589
|
-
|
|
1589
|
+
g(this, Gt, ({ type: t }) => {
|
|
1590
1590
|
const e = t === "select";
|
|
1591
1591
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1592
1592
|
});
|
|
1593
|
-
this.core = t, this.config =
|
|
1593
|
+
this.core = t, this.config = pi(e, this.core.getTheme()), this.element = this.createElement(), rt(this.element, this), this.isDraft = s, E(this, Ne, Vi).call(this);
|
|
1594
1594
|
}
|
|
1595
1595
|
getID() {
|
|
1596
1596
|
return this.config.id;
|
|
@@ -1603,7 +1603,7 @@ class xs extends et {
|
|
|
1603
1603
|
this.config = e;
|
|
1604
1604
|
}
|
|
1605
1605
|
createElement() {
|
|
1606
|
-
return new
|
|
1606
|
+
return new _.Star(this.config);
|
|
1607
1607
|
}
|
|
1608
1608
|
/**
|
|
1609
1609
|
* 获取 Konva.Star 实例
|
|
@@ -1615,7 +1615,7 @@ class xs extends et {
|
|
|
1615
1615
|
* 更新节点数据
|
|
1616
1616
|
*/
|
|
1617
1617
|
update(t) {
|
|
1618
|
-
this.config =
|
|
1618
|
+
this.config = pi(
|
|
1619
1619
|
{
|
|
1620
1620
|
...this.config,
|
|
1621
1621
|
...t
|
|
@@ -1627,15 +1627,15 @@ class xs extends et {
|
|
|
1627
1627
|
* 销毁
|
|
1628
1628
|
*/
|
|
1629
1629
|
destroy() {
|
|
1630
|
-
this.core.off("toolType:change", r(this,
|
|
1630
|
+
this.core.off("toolType:change", r(this, Gt)), this.element.destroy();
|
|
1631
1631
|
}
|
|
1632
1632
|
}
|
|
1633
|
-
|
|
1633
|
+
Gt = new WeakMap(), Ne = new WeakSet(), /**
|
|
1634
1634
|
* 设置事件处理器
|
|
1635
1635
|
*/
|
|
1636
|
-
|
|
1636
|
+
Vi = function() {
|
|
1637
1637
|
const t = this.getElement();
|
|
1638
|
-
this.core.on("toolType:change", r(this,
|
|
1638
|
+
this.core.on("toolType:change", r(this, Gt)), t.on("transform", (e) => {
|
|
1639
1639
|
const s = e.target;
|
|
1640
1640
|
let o = s.outerRadius() * s.scaleX();
|
|
1641
1641
|
o < 10 && (o = 10), s.scale({ x: 1, y: 1 }), s.innerRadius(o / 2), s.outerRadius(o);
|
|
@@ -1645,26 +1645,26 @@ Hi = function() {
|
|
|
1645
1645
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1646
1646
|
});
|
|
1647
1647
|
};
|
|
1648
|
-
function
|
|
1648
|
+
function Is(n) {
|
|
1649
1649
|
return {
|
|
1650
|
-
width: Math.max(
|
|
1651
|
-
height: Math.max(
|
|
1650
|
+
width: Math.max(N.MIN_SIZE, n.width() * n.scaleX()),
|
|
1651
|
+
height: Math.max(N.MIN_SIZE, n.height() * n.scaleY())
|
|
1652
1652
|
};
|
|
1653
1653
|
}
|
|
1654
|
-
var
|
|
1655
|
-
class
|
|
1654
|
+
var Kt, Te, Oi;
|
|
1655
|
+
class ks extends st {
|
|
1656
1656
|
constructor(t, e, s = !1) {
|
|
1657
1657
|
super();
|
|
1658
|
-
|
|
1658
|
+
g(this, Te);
|
|
1659
1659
|
p(this, "core");
|
|
1660
1660
|
p(this, "config");
|
|
1661
1661
|
p(this, "element");
|
|
1662
1662
|
p(this, "isDraft");
|
|
1663
|
-
|
|
1663
|
+
g(this, Kt, ({ type: t }) => {
|
|
1664
1664
|
const e = t === "select";
|
|
1665
1665
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1666
1666
|
});
|
|
1667
|
-
this.core = t, this.config =
|
|
1667
|
+
this.core = t, this.config = yi(e, this.core.getTheme()), this.element = this.createElement(), rt(this.element, this), this.isDraft = s, E(this, Te, Oi).call(this);
|
|
1668
1668
|
}
|
|
1669
1669
|
getID() {
|
|
1670
1670
|
return this.config.id;
|
|
@@ -1677,7 +1677,7 @@ class bs extends et {
|
|
|
1677
1677
|
this.config = e;
|
|
1678
1678
|
}
|
|
1679
1679
|
createElement() {
|
|
1680
|
-
return new
|
|
1680
|
+
return new _.Ellipse(this.config);
|
|
1681
1681
|
}
|
|
1682
1682
|
/**
|
|
1683
1683
|
* 获取 Konva.Ellipse 实例
|
|
@@ -1689,7 +1689,7 @@ class bs extends et {
|
|
|
1689
1689
|
* 更新节点数据
|
|
1690
1690
|
*/
|
|
1691
1691
|
update(t) {
|
|
1692
|
-
this.config =
|
|
1692
|
+
this.config = yi(
|
|
1693
1693
|
{
|
|
1694
1694
|
...this.config,
|
|
1695
1695
|
...t
|
|
@@ -1701,16 +1701,16 @@ class bs extends et {
|
|
|
1701
1701
|
* 销毁
|
|
1702
1702
|
*/
|
|
1703
1703
|
destroy() {
|
|
1704
|
-
this.core.off("toolType:change", r(this,
|
|
1704
|
+
this.core.off("toolType:change", r(this, Kt)), this.element.destroy();
|
|
1705
1705
|
}
|
|
1706
1706
|
}
|
|
1707
|
-
|
|
1707
|
+
Kt = new WeakMap(), Te = new WeakSet(), /**
|
|
1708
1708
|
* 设置事件处理器
|
|
1709
1709
|
*/
|
|
1710
|
-
|
|
1710
|
+
Oi = function() {
|
|
1711
1711
|
const t = this.getElement();
|
|
1712
|
-
this.core.on("toolType:change", r(this,
|
|
1713
|
-
const s = e.target, { width: o, height: a } =
|
|
1712
|
+
this.core.on("toolType:change", r(this, Kt)), t.on("transform", (e) => {
|
|
1713
|
+
const s = e.target, { width: o, height: a } = Is(s);
|
|
1714
1714
|
s.scale({ x: 1, y: 1 }), s.width(o), s.height(a);
|
|
1715
1715
|
}), t.on("transformend", (e) => {
|
|
1716
1716
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
@@ -1718,26 +1718,26 @@ Li = function() {
|
|
|
1718
1718
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1719
1719
|
});
|
|
1720
1720
|
};
|
|
1721
|
-
function
|
|
1721
|
+
function Rs(n) {
|
|
1722
1722
|
return {
|
|
1723
|
-
width: Math.max(
|
|
1724
|
-
height: Math.max(
|
|
1723
|
+
width: Math.max(N.MIN_SIZE, n.width() * n.scaleX()),
|
|
1724
|
+
height: Math.max(N.MIN_SIZE, n.height() * n.scaleY())
|
|
1725
1725
|
};
|
|
1726
1726
|
}
|
|
1727
|
-
var
|
|
1728
|
-
class
|
|
1727
|
+
var qt, _e, Zi;
|
|
1728
|
+
class $s extends st {
|
|
1729
1729
|
constructor(t, e, s = !1) {
|
|
1730
1730
|
super();
|
|
1731
|
-
|
|
1731
|
+
g(this, _e);
|
|
1732
1732
|
p(this, "core");
|
|
1733
1733
|
p(this, "config");
|
|
1734
1734
|
p(this, "element");
|
|
1735
1735
|
p(this, "isDraft");
|
|
1736
|
-
|
|
1736
|
+
g(this, qt, ({ type: t }) => {
|
|
1737
1737
|
const e = t === "select";
|
|
1738
1738
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1739
1739
|
});
|
|
1740
|
-
this.core = t, this.config =
|
|
1740
|
+
this.core = t, this.config = vi(e, this.core.getTheme()), this.element = this.createElement(), rt(this.element, this), this.isDraft = s, E(this, _e, Zi).call(this);
|
|
1741
1741
|
}
|
|
1742
1742
|
getID() {
|
|
1743
1743
|
return this.config.id;
|
|
@@ -1750,7 +1750,7 @@ class Ss extends et {
|
|
|
1750
1750
|
this.config = e;
|
|
1751
1751
|
}
|
|
1752
1752
|
createElement() {
|
|
1753
|
-
return new
|
|
1753
|
+
return new _.Line(this.config);
|
|
1754
1754
|
}
|
|
1755
1755
|
/**
|
|
1756
1756
|
* 获取 Konva.Line 实例
|
|
@@ -1762,7 +1762,7 @@ class Ss extends et {
|
|
|
1762
1762
|
* 更新节点数据
|
|
1763
1763
|
*/
|
|
1764
1764
|
update(t) {
|
|
1765
|
-
this.config =
|
|
1765
|
+
this.config = vi(
|
|
1766
1766
|
{
|
|
1767
1767
|
...this.config,
|
|
1768
1768
|
...t
|
|
@@ -1774,18 +1774,18 @@ class Ss extends et {
|
|
|
1774
1774
|
* 销毁
|
|
1775
1775
|
*/
|
|
1776
1776
|
destroy() {
|
|
1777
|
-
this.core.off("toolType:change", r(this,
|
|
1777
|
+
this.core.off("toolType:change", r(this, qt)), this.element.destroy();
|
|
1778
1778
|
}
|
|
1779
1779
|
}
|
|
1780
|
-
|
|
1780
|
+
qt = new WeakMap(), _e = new WeakSet(), /**
|
|
1781
1781
|
* 设置事件处理器
|
|
1782
1782
|
*/
|
|
1783
|
-
|
|
1783
|
+
Zi = function() {
|
|
1784
1784
|
const t = this.getElement();
|
|
1785
|
-
this.core.on("toolType:change", r(this,
|
|
1786
|
-
const s = e.target, { width: o, height: a } =
|
|
1785
|
+
this.core.on("toolType:change", r(this, qt)), t.on("transform", (e) => {
|
|
1786
|
+
const s = e.target, { width: o, height: a } = Rs(s);
|
|
1787
1787
|
s.scale({ x: 1, y: 1 }), s.width(o), s.height(a);
|
|
1788
|
-
const h =
|
|
1788
|
+
const h = ki(
|
|
1789
1789
|
{ x: s.x(), y: s.y(), width: o, height: a },
|
|
1790
1790
|
this.config.$_shape
|
|
1791
1791
|
);
|
|
@@ -1796,26 +1796,24 @@ Di = function() {
|
|
|
1796
1796
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1797
1797
|
});
|
|
1798
1798
|
};
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
width: Math.max(E.MIN_SIZE, n.width() * n.scaleX()),
|
|
1802
|
-
height: Math.max(E.MIN_SIZE, n.height() * n.scaleY())
|
|
1803
|
-
};
|
|
1804
|
-
}
|
|
1805
|
-
var Xt, be, Bi;
|
|
1806
|
-
class _s extends et {
|
|
1799
|
+
var A, F, wt, bt, P, Ui, Nt, zi, Wi, jt, Xi;
|
|
1800
|
+
class As extends st {
|
|
1807
1801
|
constructor(t, e, s = !1) {
|
|
1808
1802
|
super();
|
|
1809
|
-
|
|
1803
|
+
g(this, P);
|
|
1810
1804
|
p(this, "core");
|
|
1811
1805
|
p(this, "config");
|
|
1812
1806
|
p(this, "element");
|
|
1813
1807
|
p(this, "isDraft");
|
|
1814
|
-
|
|
1808
|
+
g(this, A, null);
|
|
1809
|
+
g(this, F, null);
|
|
1810
|
+
g(this, wt, null);
|
|
1811
|
+
g(this, bt, null);
|
|
1812
|
+
g(this, jt, ({ type: t }) => {
|
|
1815
1813
|
const e = t === "select";
|
|
1816
1814
|
this.element.listening(e && (this.config.$_listening ?? !0));
|
|
1817
1815
|
});
|
|
1818
|
-
this.core = t, this.config =
|
|
1816
|
+
this.core = t, this.config = Ci(e, this.core.getTheme()), this.element = this.createElement(), rt(this.element, this), this.isDraft = s, E(this, P, Ui).call(this), E(this, P, Xi).call(this);
|
|
1819
1817
|
}
|
|
1820
1818
|
getID() {
|
|
1821
1819
|
return this.config.id;
|
|
@@ -1828,7 +1826,7 @@ class _s extends et {
|
|
|
1828
1826
|
this.config = e;
|
|
1829
1827
|
}
|
|
1830
1828
|
createElement() {
|
|
1831
|
-
return new
|
|
1829
|
+
return new _.Arrow(this.config);
|
|
1832
1830
|
}
|
|
1833
1831
|
/**
|
|
1834
1832
|
* 获取 Konva.Arrow 实例
|
|
@@ -1840,111 +1838,183 @@ class _s extends et {
|
|
|
1840
1838
|
* 更新节点数据
|
|
1841
1839
|
*/
|
|
1842
1840
|
update(t) {
|
|
1843
|
-
this.config =
|
|
1841
|
+
this.config = Ci(
|
|
1844
1842
|
{
|
|
1845
1843
|
...this.config,
|
|
1846
1844
|
...t
|
|
1847
1845
|
},
|
|
1848
1846
|
this.core.getTheme()
|
|
1849
|
-
), this.getElement().setAttrs(this.config);
|
|
1847
|
+
), this.getElement().setAttrs(this.config), E(this, P, Nt).call(this);
|
|
1850
1848
|
}
|
|
1851
1849
|
/**
|
|
1852
1850
|
* 销毁
|
|
1853
1851
|
*/
|
|
1854
1852
|
destroy() {
|
|
1855
|
-
this.core.off("toolType:change", r(this,
|
|
1853
|
+
this.core.off("toolType:change", r(this, jt)), r(this, bt) && this.core.off("nodes:selected", r(this, bt)), r(this, wt) && this.core.off("viewport:scale:change", r(this, wt)), r(this, A)?.destroy(), r(this, F)?.destroy(), this.element.destroy();
|
|
1856
1854
|
}
|
|
1857
1855
|
}
|
|
1858
|
-
|
|
1856
|
+
A = new WeakMap(), F = new WeakMap(), wt = new WeakMap(), bt = new WeakMap(), P = new WeakSet(), /**
|
|
1857
|
+
* 创建起点和终点的控制锚点
|
|
1858
|
+
*/
|
|
1859
|
+
Ui = function() {
|
|
1860
|
+
const t = this.core.getMainLayer();
|
|
1861
|
+
if (!t) return;
|
|
1862
|
+
const e = this.core.getStageScale(), s = 6 / e, o = 2 / e;
|
|
1863
|
+
x(this, A, new _.Circle({
|
|
1864
|
+
radius: s,
|
|
1865
|
+
fill: "white",
|
|
1866
|
+
stroke: "#1976d2",
|
|
1867
|
+
strokeWidth: o,
|
|
1868
|
+
draggable: !0,
|
|
1869
|
+
visible: !1,
|
|
1870
|
+
name: "arrow-anchor"
|
|
1871
|
+
})), x(this, F, new _.Circle({
|
|
1872
|
+
radius: s,
|
|
1873
|
+
fill: "white",
|
|
1874
|
+
stroke: "#1976d2",
|
|
1875
|
+
strokeWidth: o,
|
|
1876
|
+
draggable: !0,
|
|
1877
|
+
visible: !1,
|
|
1878
|
+
name: "arrow-anchor"
|
|
1879
|
+
})), t.add(r(this, A)), t.add(r(this, F)), E(this, P, Nt).call(this), r(this, A).on("dragmove", () => {
|
|
1880
|
+
const a = [...this.element.points()];
|
|
1881
|
+
if (a.length < 4) return;
|
|
1882
|
+
const h = this.element, l = r(this, A).position();
|
|
1883
|
+
a[0] = l.x - h.x(), a[1] = l.y - h.y(), h.points(a), this.core.getCanvasTransformer().emitPositionChange();
|
|
1884
|
+
}), r(this, A).on("dragend", () => {
|
|
1885
|
+
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1886
|
+
}), r(this, F).on("dragmove", () => {
|
|
1887
|
+
const a = [...this.element.points()];
|
|
1888
|
+
if (a.length < 4) return;
|
|
1889
|
+
const h = this.element, l = r(this, F).position();
|
|
1890
|
+
a[a.length - 2] = l.x - h.x(), a[a.length - 1] = l.y - h.y(), h.points(a), this.core.getCanvasTransformer().emitPositionChange();
|
|
1891
|
+
}), r(this, F).on("dragend", () => {
|
|
1892
|
+
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1893
|
+
});
|
|
1894
|
+
}, /**
|
|
1895
|
+
* 更新锚点位置
|
|
1896
|
+
*/
|
|
1897
|
+
Nt = function() {
|
|
1898
|
+
if (!r(this, A) || !r(this, F)) return;
|
|
1899
|
+
const t = this.element.points();
|
|
1900
|
+
if (t.length < 4) return;
|
|
1901
|
+
const e = this.element, s = e.x(), o = e.y();
|
|
1902
|
+
r(this, A).position({
|
|
1903
|
+
x: s + t[0],
|
|
1904
|
+
y: o + t[1]
|
|
1905
|
+
}), r(this, F).position({
|
|
1906
|
+
x: s + t[t.length - 2],
|
|
1907
|
+
y: o + t[t.length - 1]
|
|
1908
|
+
});
|
|
1909
|
+
}, /**
|
|
1910
|
+
* 更新锚点样式(根据缩放调整大小)
|
|
1911
|
+
*/
|
|
1912
|
+
zi = function() {
|
|
1913
|
+
if (!r(this, A) || !r(this, F)) return;
|
|
1914
|
+
const t = this.core.getStageScale(), e = 6 / t, s = 2 / t;
|
|
1915
|
+
r(this, A).radius(e), r(this, A).strokeWidth(s), r(this, F).radius(e), r(this, F).strokeWidth(s);
|
|
1916
|
+
}, /**
|
|
1917
|
+
* 显示或隐藏锚点
|
|
1918
|
+
*/
|
|
1919
|
+
Wi = function(t) {
|
|
1920
|
+
!r(this, A) || !r(this, F) || (r(this, A).visible(t), r(this, F).visible(t), t && (E(this, P, Nt).call(this), r(this, A).moveToTop(), r(this, F).moveToTop()));
|
|
1921
|
+
}, jt = new WeakMap(), /**
|
|
1859
1922
|
* 设置事件处理器
|
|
1860
1923
|
*/
|
|
1861
|
-
|
|
1924
|
+
Xi = function() {
|
|
1862
1925
|
const t = this.getElement();
|
|
1863
|
-
this.core.on("toolType:change", r(this,
|
|
1864
|
-
const s = e.
|
|
1865
|
-
|
|
1866
|
-
}),
|
|
1926
|
+
this.core.on("toolType:change", r(this, jt)), x(this, bt, (e) => {
|
|
1927
|
+
const s = e.includes(this.config.id);
|
|
1928
|
+
E(this, P, Wi).call(this, s);
|
|
1929
|
+
}), this.core.on("nodes:selected", r(this, bt)), x(this, wt, () => {
|
|
1930
|
+
E(this, P, zi).call(this);
|
|
1931
|
+
}), this.core.on("viewport:scale:change", r(this, wt)), t.on("transform", (e) => {
|
|
1932
|
+
const s = e.target, o = s.scaleX(), a = s.scaleY(), l = s.points().map((d, f) => f % 2 === 0 ? d * o : d * a);
|
|
1933
|
+
s.points(l), s.scale({ x: 1, y: 1 }), E(this, P, Nt).call(this);
|
|
1934
|
+
}), t.on("transformend", () => {
|
|
1867
1935
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1868
|
-
}), t.on("
|
|
1936
|
+
}), t.on("dragmove", () => {
|
|
1937
|
+
E(this, P, Nt).call(this);
|
|
1938
|
+
}), t.on("dragend", () => {
|
|
1869
1939
|
this.syncConfigFromElement(), this.core._rebuildStateAfterNodeChange(this, !0);
|
|
1870
1940
|
});
|
|
1871
1941
|
};
|
|
1872
|
-
function
|
|
1942
|
+
function wi(n, i, t, e = !1) {
|
|
1873
1943
|
switch (i) {
|
|
1874
1944
|
case "rectangle":
|
|
1875
|
-
return new
|
|
1945
|
+
return new ws(
|
|
1876
1946
|
n,
|
|
1877
1947
|
t,
|
|
1878
1948
|
e
|
|
1879
1949
|
);
|
|
1880
1950
|
case "image":
|
|
1881
|
-
return new
|
|
1951
|
+
return new bs(n, t, e);
|
|
1882
1952
|
case "image-marker":
|
|
1883
|
-
return new
|
|
1953
|
+
return new Es(
|
|
1884
1954
|
n,
|
|
1885
1955
|
t,
|
|
1886
1956
|
e
|
|
1887
1957
|
);
|
|
1888
1958
|
case "html":
|
|
1889
|
-
return new
|
|
1959
|
+
return new Ss(n, t, e);
|
|
1890
1960
|
case "text":
|
|
1891
|
-
return new
|
|
1961
|
+
return new Ns(n, t, e);
|
|
1892
1962
|
case "rich-text":
|
|
1893
|
-
return new
|
|
1963
|
+
return new Ts(
|
|
1894
1964
|
n,
|
|
1895
1965
|
t,
|
|
1896
1966
|
e
|
|
1897
1967
|
);
|
|
1898
1968
|
case "video":
|
|
1899
|
-
return new
|
|
1969
|
+
return new _s(n, t, e);
|
|
1900
1970
|
case "star":
|
|
1901
|
-
return new
|
|
1971
|
+
return new Ms(n, t, e);
|
|
1902
1972
|
case "ellipse":
|
|
1903
|
-
return new
|
|
1973
|
+
return new ks(
|
|
1904
1974
|
n,
|
|
1905
1975
|
t,
|
|
1906
1976
|
e
|
|
1907
1977
|
);
|
|
1908
1978
|
case "polygon":
|
|
1909
|
-
return new
|
|
1979
|
+
return new $s(
|
|
1910
1980
|
n,
|
|
1911
1981
|
t,
|
|
1912
1982
|
e
|
|
1913
1983
|
);
|
|
1914
1984
|
case "arrow":
|
|
1915
|
-
return new
|
|
1985
|
+
return new As(n, t, e);
|
|
1916
1986
|
default:
|
|
1917
1987
|
return null;
|
|
1918
1988
|
}
|
|
1919
1989
|
}
|
|
1920
|
-
function
|
|
1990
|
+
function bi(n, i) {
|
|
1921
1991
|
return Math.min(Math.max(n, i[0]), i[1]);
|
|
1922
1992
|
}
|
|
1923
|
-
const
|
|
1993
|
+
const Fs = (n, i, t) => n === "arrow" ? {
|
|
1924
1994
|
...t,
|
|
1925
1995
|
$_type: n,
|
|
1926
|
-
id:
|
|
1996
|
+
id: Tt(),
|
|
1927
1997
|
points: [i.x, i.y, i.x, i.y]
|
|
1928
1998
|
} : {
|
|
1929
1999
|
...t,
|
|
1930
2000
|
$_type: n,
|
|
1931
|
-
id:
|
|
2001
|
+
id: Tt(),
|
|
1932
2002
|
x: i.x,
|
|
1933
2003
|
y: i.y
|
|
1934
2004
|
};
|
|
1935
|
-
function
|
|
2005
|
+
function Hs(n, i, t) {
|
|
1936
2006
|
let e = i;
|
|
1937
2007
|
if (n.$_type === "image-marker" && n.$_bounds) {
|
|
1938
2008
|
const s = n.$_bounds;
|
|
1939
2009
|
e = {
|
|
1940
|
-
x:
|
|
1941
|
-
y:
|
|
2010
|
+
x: bi(i.x, [s.x, s.x + s.width]),
|
|
2011
|
+
y: bi(i.y, [s.y, s.y + s.height])
|
|
1942
2012
|
};
|
|
1943
2013
|
}
|
|
1944
2014
|
if (["rectangle", "image", "image-marker", "html", "polygon"].includes(
|
|
1945
2015
|
n.$_type
|
|
1946
2016
|
)) {
|
|
1947
|
-
const [s, o] =
|
|
2017
|
+
const [s, o] = ee(t, e);
|
|
1948
2018
|
return {
|
|
1949
2019
|
...n,
|
|
1950
2020
|
x: s.x,
|
|
@@ -1954,7 +2024,7 @@ function Ms(n, i, t) {
|
|
|
1954
2024
|
};
|
|
1955
2025
|
}
|
|
1956
2026
|
if (["ellipse"].includes(n.$_type)) {
|
|
1957
|
-
const [s, o] =
|
|
2027
|
+
const [s, o] = ee(t, e);
|
|
1958
2028
|
return {
|
|
1959
2029
|
...n,
|
|
1960
2030
|
x: (o.x - s.x) / 2 + s.x,
|
|
@@ -1964,7 +2034,7 @@ function Ms(n, i, t) {
|
|
|
1964
2034
|
};
|
|
1965
2035
|
}
|
|
1966
2036
|
if (["star"].includes(n.$_type)) {
|
|
1967
|
-
const [s, o] =
|
|
2037
|
+
const [s, o] = ee(t, e);
|
|
1968
2038
|
return {
|
|
1969
2039
|
...n,
|
|
1970
2040
|
x: (o.x - s.x) / 2 + s.x,
|
|
@@ -1987,15 +2057,15 @@ function Ms(n, i, t) {
|
|
|
1987
2057
|
]
|
|
1988
2058
|
} : n;
|
|
1989
2059
|
}
|
|
1990
|
-
function
|
|
2060
|
+
function ee(n, i) {
|
|
1991
2061
|
let t = n.x, e = n.y, s = i.x, o = i.y, a;
|
|
1992
2062
|
return t > s && (a = Math.abs(t - s), t = s, s = t + a), e > o && (a = Math.abs(e - o), e = o, o = e + a), [
|
|
1993
2063
|
{ x: t, y: e },
|
|
1994
2064
|
{ x: s, y: o }
|
|
1995
2065
|
];
|
|
1996
2066
|
}
|
|
1997
|
-
var
|
|
1998
|
-
class
|
|
2067
|
+
var kt, D, j, it, H, Rt, Y, G, lt, pt, Me, U, Yi, Gi, Pe, Be, Ki;
|
|
2068
|
+
class Ls extends ps {
|
|
1999
2069
|
constructor(t, e) {
|
|
2000
2070
|
const s = e?.state, o = {
|
|
2001
2071
|
toolType: "select",
|
|
@@ -2009,77 +2079,77 @@ class Is extends ls {
|
|
|
2009
2079
|
}
|
|
2010
2080
|
};
|
|
2011
2081
|
super(o);
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2082
|
+
g(this, U);
|
|
2083
|
+
g(this, kt);
|
|
2084
|
+
g(this, D);
|
|
2085
|
+
g(this, j);
|
|
2086
|
+
g(this, it);
|
|
2087
|
+
g(this, H, null);
|
|
2088
|
+
g(this, Rt);
|
|
2089
|
+
g(this, Y, null);
|
|
2090
|
+
g(this, G, null);
|
|
2021
2091
|
/** 节点映射,方便快速查找 */
|
|
2022
|
-
|
|
2023
|
-
|
|
2092
|
+
g(this, lt, /* @__PURE__ */ new Map());
|
|
2093
|
+
g(this, pt, null);
|
|
2024
2094
|
p(this, "isEditingText", !1);
|
|
2025
|
-
|
|
2095
|
+
g(this, Me, (t) => {
|
|
2026
2096
|
(t.key === "Delete" || t.key === "Backspace") && (t.stopPropagation(), this.deleteSelectedNodes());
|
|
2027
2097
|
});
|
|
2028
|
-
|
|
2098
|
+
x(this, kt, e?.theme ?? Ii), x(this, Rt, t), x(this, D, new ms(this, {
|
|
2029
2099
|
container: t,
|
|
2030
2100
|
width: t.clientWidth,
|
|
2031
2101
|
height: t.clientHeight,
|
|
2032
2102
|
draggable: !1,
|
|
2033
2103
|
className: "touch-none"
|
|
2034
|
-
})),
|
|
2104
|
+
})), x(this, j, new _.Layer()), x(this, it, new fs(this)), r(this, D).getStage().add(r(this, j)), r(this, j).add(r(this, it).getTransformer()), this._renderCanvas(o), E(this, U, Yi).call(this), E(this, U, Gi).call(this);
|
|
2035
2105
|
}
|
|
2036
2106
|
/**
|
|
2037
2107
|
* 获取当前主题
|
|
2038
2108
|
*/
|
|
2039
2109
|
getTheme() {
|
|
2040
|
-
return r(this,
|
|
2110
|
+
return r(this, kt);
|
|
2041
2111
|
}
|
|
2042
2112
|
/**
|
|
2043
2113
|
* 设置主题并重新渲染
|
|
2044
2114
|
*/
|
|
2045
2115
|
setTheme(t) {
|
|
2046
|
-
|
|
2116
|
+
x(this, kt, t), this._renderCanvas(this.getState()), this._emit("theme:change", t);
|
|
2047
2117
|
}
|
|
2048
2118
|
/**
|
|
2049
2119
|
* 获取 CanvasStage 实例
|
|
2050
2120
|
*/
|
|
2051
2121
|
getCanvasStage() {
|
|
2052
|
-
return r(this,
|
|
2122
|
+
return r(this, D);
|
|
2053
2123
|
}
|
|
2054
2124
|
/**
|
|
2055
2125
|
* 获取 CanvasTransformer 实例
|
|
2056
2126
|
*/
|
|
2057
2127
|
getCanvasTransformer() {
|
|
2058
|
-
return r(this,
|
|
2128
|
+
return r(this, it);
|
|
2059
2129
|
}
|
|
2060
2130
|
/**
|
|
2061
2131
|
* 获取 Konva.Transformer 实例
|
|
2062
2132
|
*/
|
|
2063
2133
|
getTransformer() {
|
|
2064
|
-
return r(this,
|
|
2134
|
+
return r(this, it).getTransformer();
|
|
2065
2135
|
}
|
|
2066
2136
|
/**
|
|
2067
2137
|
* 获取 Konva.Stage 实例
|
|
2068
2138
|
*/
|
|
2069
2139
|
getStage() {
|
|
2070
|
-
return r(this,
|
|
2140
|
+
return r(this, D).getStage();
|
|
2071
2141
|
}
|
|
2072
2142
|
/**
|
|
2073
2143
|
* 获取 Stage 容器元素
|
|
2074
2144
|
*/
|
|
2075
2145
|
getContainer() {
|
|
2076
|
-
return r(this,
|
|
2146
|
+
return r(this, Rt);
|
|
2077
2147
|
}
|
|
2078
2148
|
/**
|
|
2079
2149
|
* 获取主图层
|
|
2080
2150
|
*/
|
|
2081
2151
|
getMainLayer() {
|
|
2082
|
-
return r(this,
|
|
2152
|
+
return r(this, j);
|
|
2083
2153
|
}
|
|
2084
2154
|
/**
|
|
2085
2155
|
* 获取当前工具类型
|
|
@@ -2110,46 +2180,46 @@ class Is extends ls {
|
|
|
2110
2180
|
), this._emit("toolType:change", {
|
|
2111
2181
|
type: t,
|
|
2112
2182
|
meta: e
|
|
2113
|
-
}), t === "hand" ? (r(this,
|
|
2183
|
+
}), t === "hand" ? (r(this, D).setDraggable(!0), r(this, D).setCursor("grab")) : (r(this, D).setDraggable(!1), r(this, D).resetCursor());
|
|
2114
2184
|
}
|
|
2115
2185
|
/**
|
|
2116
2186
|
* 根据 ID 获取 Canvas 节点实例
|
|
2117
2187
|
*/
|
|
2118
2188
|
getCanvasNodeById(t) {
|
|
2119
|
-
return r(this,
|
|
2189
|
+
return r(this, lt).get(t) || null;
|
|
2120
2190
|
}
|
|
2121
2191
|
/**
|
|
2122
2192
|
* 设置是否可拖拽(内部使用)
|
|
2123
2193
|
*/
|
|
2124
2194
|
setDraggable(t) {
|
|
2125
|
-
r(this,
|
|
2195
|
+
r(this, D).setDraggable(t);
|
|
2126
2196
|
}
|
|
2127
2197
|
/**
|
|
2128
2198
|
* 设置光标
|
|
2129
2199
|
* @internal 仅供内部使用
|
|
2130
2200
|
*/
|
|
2131
2201
|
_setCursor(t) {
|
|
2132
|
-
r(this,
|
|
2202
|
+
r(this, D).setCursor(t);
|
|
2133
2203
|
}
|
|
2134
2204
|
/**
|
|
2135
2205
|
* 重置光标
|
|
2136
2206
|
* @internal 仅供内部使用
|
|
2137
2207
|
*/
|
|
2138
2208
|
_resetCursor() {
|
|
2139
|
-
r(this,
|
|
2209
|
+
r(this, D).resetCursor();
|
|
2140
2210
|
}
|
|
2141
2211
|
/**
|
|
2142
2212
|
* 获取当前 Stage 缩放比例
|
|
2143
2213
|
*/
|
|
2144
2214
|
getStageScale() {
|
|
2145
|
-
return r(this,
|
|
2215
|
+
return r(this, D).getStage().scaleX();
|
|
2146
2216
|
}
|
|
2147
2217
|
/**
|
|
2148
2218
|
* 更新视口位置
|
|
2149
2219
|
* @internal 仅供内部使用,外部请使用 CanvasApi
|
|
2150
2220
|
*/
|
|
2151
2221
|
_updateViewport(t, e = !1) {
|
|
2152
|
-
r(this,
|
|
2222
|
+
r(this, D).setViewport(t);
|
|
2153
2223
|
const s = this.getState().viewport, o = {
|
|
2154
2224
|
...s,
|
|
2155
2225
|
...t
|
|
@@ -2159,13 +2229,13 @@ class Is extends ls {
|
|
|
2159
2229
|
viewport: o
|
|
2160
2230
|
},
|
|
2161
2231
|
e
|
|
2162
|
-
), this._emit("viewport:change", o), s.scale !== o.scale && this._emit("viewport:scale:change", o.scale), r(this,
|
|
2232
|
+
), this._emit("viewport:change", o), s.scale !== o.scale && this._emit("viewport:scale:change", o.scale), r(this, it).emitPositionChange();
|
|
2163
2233
|
}
|
|
2164
2234
|
createNodes(t, e) {
|
|
2165
|
-
const s = t.map((o) =>
|
|
2235
|
+
const s = t.map((o) => wi(this, o.$_type, o, !1)).filter((o) => o !== null);
|
|
2166
2236
|
s.forEach((o) => {
|
|
2167
|
-
r(this,
|
|
2168
|
-
}),
|
|
2237
|
+
r(this, j).add(o.getElement());
|
|
2238
|
+
}), E(this, U, Be).call(this, s, e), this._emit("nodes:created", t);
|
|
2169
2239
|
}
|
|
2170
2240
|
/**
|
|
2171
2241
|
* 创建图片标注节点(内部使用)
|
|
@@ -2176,12 +2246,12 @@ class Is extends ls {
|
|
|
2176
2246
|
a.forEach((C) => {
|
|
2177
2247
|
C.$_type === "image-marker" && typeof C.$_markerNumber == "number" && (h = Math.max(h, C.$_markerNumber));
|
|
2178
2248
|
});
|
|
2179
|
-
const l = (e.x - o.x) / o.width, d = (e.y - o.y) / o.height, f = (s.x - o.x) / o.width,
|
|
2180
|
-
id:
|
|
2249
|
+
const l = (e.x - o.x) / o.width, d = (e.y - o.y) / o.height, f = (s.x - o.x) / o.width, m = (s.y - o.y) / o.height, u = Math.min(e.x, s.x), y = Math.min(e.y, s.y), w = Math.abs(s.x - e.x), v = Math.abs(s.y - e.y), M = {
|
|
2250
|
+
id: Tt(),
|
|
2181
2251
|
$_type: "image-marker",
|
|
2182
|
-
x:
|
|
2252
|
+
x: u,
|
|
2183
2253
|
y,
|
|
2184
|
-
width:
|
|
2254
|
+
width: w,
|
|
2185
2255
|
height: v,
|
|
2186
2256
|
visible: !0,
|
|
2187
2257
|
line: "dashed",
|
|
@@ -2194,23 +2264,23 @@ class Is extends ls {
|
|
|
2194
2264
|
},
|
|
2195
2265
|
end: {
|
|
2196
2266
|
ratioX: Math.max(0, Math.min(1, f)),
|
|
2197
|
-
ratioY: Math.max(0, Math.min(1,
|
|
2267
|
+
ratioY: Math.max(0, Math.min(1, m))
|
|
2198
2268
|
}
|
|
2199
2269
|
}
|
|
2200
2270
|
};
|
|
2201
|
-
this.createNodes([
|
|
2271
|
+
this.createNodes([M], !0);
|
|
2202
2272
|
}
|
|
2203
2273
|
/**
|
|
2204
2274
|
* 在指定位置查找图片节点
|
|
2205
2275
|
* @internal 仅供内部使用
|
|
2206
2276
|
*/
|
|
2207
2277
|
_findImageAtPosition(t) {
|
|
2208
|
-
const a = r(this,
|
|
2278
|
+
const a = r(this, j).getChildren().filter(
|
|
2209
2279
|
(h) => !h.name().includes("imageMarker")
|
|
2210
2280
|
).slice().sort((h, l) => l.zIndex() - h.zIndex());
|
|
2211
2281
|
for (const h of a) {
|
|
2212
|
-
const l = h.x(), d = h.y(), f = h.width(),
|
|
2213
|
-
if (t.x >= l && t.x <= l + f && t.y >= d && t.y <= d +
|
|
2282
|
+
const l = h.x(), d = h.y(), f = h.width(), m = h.height();
|
|
2283
|
+
if (t.x >= l && t.x <= l + f && t.y >= d && t.y <= d + m)
|
|
2214
2284
|
return h.getAttr("$_type") === "image" ? h : null;
|
|
2215
2285
|
}
|
|
2216
2286
|
return null;
|
|
@@ -2219,47 +2289,47 @@ class Is extends ls {
|
|
|
2219
2289
|
* @internal 仅供内部使用
|
|
2220
2290
|
*/
|
|
2221
2291
|
_setDrawingPosition(t) {
|
|
2222
|
-
|
|
2292
|
+
x(this, G, [t, t]);
|
|
2223
2293
|
}
|
|
2224
2294
|
/**
|
|
2225
2295
|
* @internal 仅供内部使用
|
|
2226
2296
|
*/
|
|
2227
2297
|
_updateDrawingPosition(t) {
|
|
2228
|
-
r(this,
|
|
2298
|
+
r(this, G) && (r(this, G)[1] = t);
|
|
2229
2299
|
}
|
|
2230
2300
|
/**
|
|
2231
2301
|
* @internal 仅供内部使用
|
|
2232
2302
|
*/
|
|
2233
2303
|
_createDraftNode(t, e) {
|
|
2234
|
-
r(this,
|
|
2235
|
-
const s =
|
|
2304
|
+
r(this, H) && r(this, H).destroy();
|
|
2305
|
+
const s = Fs(
|
|
2236
2306
|
t,
|
|
2237
|
-
r(this,
|
|
2307
|
+
r(this, G)[0],
|
|
2238
2308
|
{
|
|
2239
2309
|
...e,
|
|
2240
2310
|
...this.getToolMeta()
|
|
2241
2311
|
}
|
|
2242
2312
|
);
|
|
2243
|
-
|
|
2313
|
+
x(this, H, wi(this, t, s, !0)), r(this, H) && r(this, j).add(r(this, H).getElement());
|
|
2244
2314
|
}
|
|
2245
2315
|
/**
|
|
2246
2316
|
* @internal 仅供内部使用
|
|
2247
2317
|
*/
|
|
2248
2318
|
_updateDraftNode() {
|
|
2249
|
-
if (!r(this,
|
|
2250
|
-
const t = r(this,
|
|
2319
|
+
if (!r(this, H)) return;
|
|
2320
|
+
const t = r(this, H).getConfig(), e = Hs(
|
|
2251
2321
|
t,
|
|
2252
|
-
r(this,
|
|
2253
|
-
r(this,
|
|
2322
|
+
r(this, G)[1],
|
|
2323
|
+
r(this, G)[0]
|
|
2254
2324
|
);
|
|
2255
|
-
r(this,
|
|
2325
|
+
r(this, H).update(e);
|
|
2256
2326
|
}
|
|
2257
2327
|
/**
|
|
2258
2328
|
* @internal 仅供内部使用
|
|
2259
2329
|
*/
|
|
2260
2330
|
_finalizeDraftNode() {
|
|
2261
|
-
if (!r(this,
|
|
2262
|
-
const t =
|
|
2331
|
+
if (!r(this, H)) return;
|
|
2332
|
+
const t = Tt(), e = r(this, H).getConfig();
|
|
2263
2333
|
if (e.$_type === "image-marker") {
|
|
2264
2334
|
const o = e.$_bounds, a = {
|
|
2265
2335
|
x: e.x,
|
|
@@ -2272,30 +2342,30 @@ class Is extends ls {
|
|
|
2272
2342
|
l.forEach((v) => {
|
|
2273
2343
|
v.$_type === "image-marker" && typeof v.$_markerNumber == "number" && (d = Math.max(d, v.$_markerNumber));
|
|
2274
2344
|
});
|
|
2275
|
-
const f = (a.x - o.x) / o.width,
|
|
2345
|
+
const f = (a.x - o.x) / o.width, m = (a.y - o.y) / o.height, u = (h.x - o.x) / o.width, y = (h.y - o.y) / o.height, w = {
|
|
2276
2346
|
...e,
|
|
2277
2347
|
$_markerNumber: d + 1,
|
|
2278
2348
|
$_relativeBox: {
|
|
2279
2349
|
start: {
|
|
2280
2350
|
ratioX: Math.max(0, Math.min(1, f)),
|
|
2281
|
-
ratioY: Math.max(0, Math.min(1,
|
|
2351
|
+
ratioY: Math.max(0, Math.min(1, m))
|
|
2282
2352
|
},
|
|
2283
2353
|
end: {
|
|
2284
|
-
ratioX: Math.max(0, Math.min(1,
|
|
2354
|
+
ratioX: Math.max(0, Math.min(1, u)),
|
|
2285
2355
|
ratioY: Math.max(0, Math.min(1, y))
|
|
2286
2356
|
}
|
|
2287
2357
|
},
|
|
2288
2358
|
$_type: "image-marker",
|
|
2289
2359
|
id: t
|
|
2290
2360
|
};
|
|
2291
|
-
this.createNodes([
|
|
2361
|
+
this.createNodes([w], !0), r(this, H).destroy(), x(this, H, null), this.setToolType("select");
|
|
2292
2362
|
return;
|
|
2293
2363
|
}
|
|
2294
2364
|
const s = {
|
|
2295
2365
|
...e,
|
|
2296
2366
|
id: t
|
|
2297
2367
|
};
|
|
2298
|
-
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,
|
|
2368
|
+
if (s.$_type === "ellipse" && (s.width || 0) < 10 && (s.height || 0) < 10 && (s.width = 10, s.height = 10), s.$_type === "star" && (s.outerRadius || 0) < 10 && (s.outerRadius = 10), this.createNodes([s], !0), r(this, H).destroy(), x(this, H, null), this.setToolType("select"), s.$_type === "rich-text") {
|
|
2299
2369
|
const o = this.getCanvasNodeById(t);
|
|
2300
2370
|
o && o.attachEditor();
|
|
2301
2371
|
}
|
|
@@ -2305,8 +2375,8 @@ class Is extends ls {
|
|
|
2305
2375
|
* @internal 仅供内部使用
|
|
2306
2376
|
*/
|
|
2307
2377
|
_createTextNodeAtDrawingPosition(t) {
|
|
2308
|
-
const e = r(this,
|
|
2309
|
-
id:
|
|
2378
|
+
const e = r(this, G)[1], s = {
|
|
2379
|
+
id: Tt(),
|
|
2310
2380
|
$_type: "text",
|
|
2311
2381
|
x: e.x,
|
|
2312
2382
|
y: e.y,
|
|
@@ -2318,31 +2388,31 @@ class Is extends ls {
|
|
|
2318
2388
|
* @internal 仅供内部使用
|
|
2319
2389
|
*/
|
|
2320
2390
|
_createSelectRect() {
|
|
2321
|
-
this.isEditingText || (r(this,
|
|
2322
|
-
x: r(this,
|
|
2323
|
-
y: r(this,
|
|
2391
|
+
this.isEditingText || (r(this, Y) && r(this, Y).destroy(), x(this, Y, new _.Rect({
|
|
2392
|
+
x: r(this, G)[0].x,
|
|
2393
|
+
y: r(this, G)[0].y,
|
|
2324
2394
|
width: 0,
|
|
2325
2395
|
height: 0,
|
|
2326
2396
|
stroke: this.getTheme()["theme.select-rect-border"],
|
|
2327
2397
|
strokeWidth: 1,
|
|
2328
2398
|
fill: this.getTheme()["theme.select-rect-fill"]
|
|
2329
|
-
})), r(this,
|
|
2399
|
+
})), r(this, j).add(r(this, Y)));
|
|
2330
2400
|
}
|
|
2331
2401
|
/*
|
|
2332
2402
|
* @internal 仅供内部使用
|
|
2333
2403
|
*/
|
|
2334
2404
|
_updateSelectRect() {
|
|
2335
|
-
if (!r(this,
|
|
2336
|
-
const [t, e] =
|
|
2337
|
-
r(this,
|
|
2405
|
+
if (!r(this, Y)) return;
|
|
2406
|
+
const [t, e] = ee(...r(this, G));
|
|
2407
|
+
r(this, Y).setAttrs({
|
|
2338
2408
|
x: t.x,
|
|
2339
2409
|
y: t.y,
|
|
2340
2410
|
width: e.x - t.x,
|
|
2341
2411
|
height: e.y - t.y
|
|
2342
2412
|
});
|
|
2343
|
-
const s = r(this,
|
|
2413
|
+
const s = r(this, Y).getClientRect(), a = r(this, j).find(`.${b.selectable}`).filter((h) => {
|
|
2344
2414
|
const l = h.getClientRect();
|
|
2345
|
-
return
|
|
2415
|
+
return _.Util.haveIntersection(s, l);
|
|
2346
2416
|
});
|
|
2347
2417
|
this._selectNodes(
|
|
2348
2418
|
a.length > 0 ? a.filter((h) => h.listening()).map((h) => h.id()) : void 0,
|
|
@@ -2353,7 +2423,7 @@ class Is extends ls {
|
|
|
2353
2423
|
* @internal 仅供内部使用
|
|
2354
2424
|
*/
|
|
2355
2425
|
_finalizeSelectRect() {
|
|
2356
|
-
r(this,
|
|
2426
|
+
r(this, Y) && (r(this, Y).destroy(), x(this, Y, null));
|
|
2357
2427
|
}
|
|
2358
2428
|
/**
|
|
2359
2429
|
* 选择节点
|
|
@@ -2363,12 +2433,12 @@ class Is extends ls {
|
|
|
2363
2433
|
if (this.isEditingText) return;
|
|
2364
2434
|
const o = this.getState().selectedNodeIds ?? [];
|
|
2365
2435
|
let a = [];
|
|
2366
|
-
if (t?.length && (e && o.length > 0 ? a = [...o, ...t] : a = [...t]), !(
|
|
2436
|
+
if (t?.length && (e && o.length > 0 ? a = [...o, ...t] : a = [...t]), !(Cs(o, a) && !s)) {
|
|
2367
2437
|
if (a.length === 0)
|
|
2368
|
-
r(this,
|
|
2438
|
+
r(this, it).clearNodes();
|
|
2369
2439
|
else {
|
|
2370
2440
|
const h = this.getStage().find(`.${b.selectable}`).filter((l) => a.includes(l.id())).filter((l) => l.listening()).filter((l) => l.isVisible());
|
|
2371
|
-
r(this,
|
|
2441
|
+
r(this, it).setNodes(h);
|
|
2372
2442
|
}
|
|
2373
2443
|
this._updateState({ selectedNodeIds: a }, !1), this._emit("nodes:selected", a);
|
|
2374
2444
|
}
|
|
@@ -2392,7 +2462,7 @@ class Is extends ls {
|
|
|
2392
2462
|
return s.forEach((a) => {
|
|
2393
2463
|
const h = this.getStage().findOne(`#${a}`);
|
|
2394
2464
|
h && h.destroy();
|
|
2395
|
-
}),
|
|
2465
|
+
}), E(this, U, Ki).call(this, Array.from(s), !0), r(this, it).clearNodes(), this._updateState(
|
|
2396
2466
|
{
|
|
2397
2467
|
selectedNodeIds: []
|
|
2398
2468
|
},
|
|
@@ -2411,14 +2481,14 @@ class Is extends ls {
|
|
|
2411
2481
|
* 销毁 canvas
|
|
2412
2482
|
*/
|
|
2413
2483
|
dispose() {
|
|
2414
|
-
r(this,
|
|
2484
|
+
r(this, pt) && (r(this, pt).disconnect(), x(this, pt, null)), this.getCanvasTransformer().destroy(), this.getMainLayer().destroy(), this.getCanvasStage().destroy(), this._dispose();
|
|
2415
2485
|
}
|
|
2416
2486
|
/**
|
|
2417
2487
|
* @internal 仅供内部使用
|
|
2418
2488
|
* 在元素节点改变后(例如 tranfromEnd dragEnd)重建 state.nodes
|
|
2419
2489
|
*/
|
|
2420
2490
|
_rebuildStateAfterNodeChange(t, e) {
|
|
2421
|
-
|
|
2491
|
+
E(this, U, Be).call(this, Array.isArray(t) ? t : [t], e);
|
|
2422
2492
|
}
|
|
2423
2493
|
/**
|
|
2424
2494
|
* 实现父类的状态同步方法
|
|
@@ -2432,9 +2502,9 @@ class Is extends ls {
|
|
|
2432
2502
|
scale: t.viewport.scale
|
|
2433
2503
|
},
|
|
2434
2504
|
!1
|
|
2435
|
-
), r(this,
|
|
2505
|
+
), r(this, lt).forEach((e, s) => {
|
|
2436
2506
|
e.destroy();
|
|
2437
|
-
}), r(this,
|
|
2507
|
+
}), r(this, lt).clear(), this.createNodes(t.nodes || [], !1), this._selectNodes(t.selectedNodeIds || [], !1, !0);
|
|
2438
2508
|
}
|
|
2439
2509
|
_showContextMenu(t) {
|
|
2440
2510
|
this._emit("contextmenu:show", t);
|
|
@@ -2458,46 +2528,46 @@ class Is extends ls {
|
|
|
2458
2528
|
this._emit("texteditor:unregister", void 0);
|
|
2459
2529
|
}
|
|
2460
2530
|
}
|
|
2461
|
-
|
|
2531
|
+
kt = new WeakMap(), D = new WeakMap(), j = new WeakMap(), it = new WeakMap(), H = new WeakMap(), Rt = new WeakMap(), Y = new WeakMap(), G = new WeakMap(), lt = new WeakMap(), pt = new WeakMap(), Me = new WeakMap(), U = new WeakSet(), /**
|
|
2462
2532
|
* 设置键盘事件监听
|
|
2463
2533
|
*/
|
|
2464
|
-
|
|
2534
|
+
Yi = function() {
|
|
2465
2535
|
const t = this.getStage().getContent();
|
|
2466
|
-
t.tabIndex = 0, t.addEventListener("keydown", r(this,
|
|
2536
|
+
t.tabIndex = 0, t.addEventListener("keydown", r(this, Me));
|
|
2467
2537
|
}, /**
|
|
2468
2538
|
* 设置尺寸变化监听
|
|
2469
2539
|
*/
|
|
2470
|
-
|
|
2471
|
-
|
|
2540
|
+
Gi = function() {
|
|
2541
|
+
x(this, pt, new ResizeObserver((t) => {
|
|
2472
2542
|
for (const e of t) {
|
|
2473
|
-
const { width: s, height: o } = e.contentRect, a = this.getStage(), h = this.getState().viewport, l = a.width(), d = a.height(), f = h.x + l / 2,
|
|
2543
|
+
const { width: s, height: o } = e.contentRect, a = this.getStage(), h = this.getState().viewport, l = a.width(), d = a.height(), f = h.x + l / 2, m = h.y + d / 2;
|
|
2474
2544
|
a.width(s), a.height(o);
|
|
2475
|
-
const
|
|
2545
|
+
const u = f - s / 2, y = m - o / 2;
|
|
2476
2546
|
this._updateViewport(
|
|
2477
2547
|
{
|
|
2478
|
-
x:
|
|
2548
|
+
x: u,
|
|
2479
2549
|
y
|
|
2480
2550
|
},
|
|
2481
2551
|
!1
|
|
2482
2552
|
);
|
|
2483
2553
|
}
|
|
2484
|
-
})), r(this,
|
|
2554
|
+
})), r(this, pt).observe(r(this, Rt));
|
|
2485
2555
|
}, /**
|
|
2486
2556
|
* 根据canvas节点映射重建 state.nodes
|
|
2487
2557
|
*/
|
|
2488
|
-
|
|
2558
|
+
Pe = function(t) {
|
|
2489
2559
|
const e = this.getState().nodes || [], s = /* @__PURE__ */ new Map();
|
|
2490
2560
|
e.forEach((d, f) => {
|
|
2491
2561
|
s.set(d.id, f);
|
|
2492
2562
|
});
|
|
2493
|
-
const o = Array.from(r(this,
|
|
2563
|
+
const o = Array.from(r(this, lt).values()).map(
|
|
2494
2564
|
(d) => d.getConfig()
|
|
2495
2565
|
), a = [], h = [];
|
|
2496
2566
|
o.forEach((d) => {
|
|
2497
2567
|
s.has(d.id) ? a.push(d) : h.push(d);
|
|
2498
2568
|
}), a.sort((d, f) => {
|
|
2499
|
-
const
|
|
2500
|
-
return
|
|
2569
|
+
const m = s.get(d.id) ?? 0, u = s.get(f.id) ?? 0;
|
|
2570
|
+
return m - u;
|
|
2501
2571
|
});
|
|
2502
2572
|
const l = {
|
|
2503
2573
|
nodes: [...a, ...h]
|
|
@@ -2506,17 +2576,17 @@ Ae = function(t) {
|
|
|
2506
2576
|
}, /**
|
|
2507
2577
|
* 更新 state.nodes
|
|
2508
2578
|
*/
|
|
2509
|
-
|
|
2579
|
+
Be = function(t, e) {
|
|
2510
2580
|
t.length !== 0 && (t.forEach((s) => {
|
|
2511
|
-
r(this,
|
|
2512
|
-
}),
|
|
2513
|
-
},
|
|
2581
|
+
r(this, lt).set(s.getID(), s);
|
|
2582
|
+
}), E(this, U, Pe).call(this, e));
|
|
2583
|
+
}, Ki = function(t, e = !1) {
|
|
2514
2584
|
t.length !== 0 && (t.forEach((s) => {
|
|
2515
|
-
const o = r(this,
|
|
2516
|
-
o && o.destroy(), r(this,
|
|
2517
|
-
}),
|
|
2585
|
+
const o = r(this, lt).get(s);
|
|
2586
|
+
o && o.destroy(), r(this, lt).delete(s);
|
|
2587
|
+
}), E(this, U, Pe).call(this, e));
|
|
2518
2588
|
};
|
|
2519
|
-
class
|
|
2589
|
+
class Ds extends Ls {
|
|
2520
2590
|
/**
|
|
2521
2591
|
* 获取所有可用的工具类型
|
|
2522
2592
|
*/
|
|
@@ -2560,7 +2630,7 @@ class ks extends Is {
|
|
|
2560
2630
|
*/
|
|
2561
2631
|
createImageNode(i, t) {
|
|
2562
2632
|
const e = t ?? { x: 100, y: 100 }, s = {
|
|
2563
|
-
id:
|
|
2633
|
+
id: Tt(),
|
|
2564
2634
|
$_type: "image",
|
|
2565
2635
|
x: e.x,
|
|
2566
2636
|
y: e.y,
|
|
@@ -2595,7 +2665,7 @@ class ks extends Is {
|
|
|
2595
2665
|
const t = this.getState().selectedNodeIds || [];
|
|
2596
2666
|
if (t.length === 0)
|
|
2597
2667
|
return console.warn("No selection to export"), null;
|
|
2598
|
-
const e = i?.padding ?? 0, s = new
|
|
2668
|
+
const e = i?.padding ?? 0, s = new _.Group();
|
|
2599
2669
|
t.forEach((h) => {
|
|
2600
2670
|
const l = this.getStage().findOne(`#${h}`);
|
|
2601
2671
|
if (l) {
|
|
@@ -2624,22 +2694,22 @@ class ks extends Is {
|
|
|
2624
2694
|
if (!e)
|
|
2625
2695
|
return console.warn("Image shape not found on stage"), null;
|
|
2626
2696
|
const o = (this.getState().nodes || []).filter(
|
|
2627
|
-
(
|
|
2697
|
+
(m) => m.$_type === "image-marker" && m.$_parentId === i
|
|
2628
2698
|
);
|
|
2629
2699
|
if (o.length === 0)
|
|
2630
2700
|
return console.warn("No image-marker nodes found for the given image ID"), null;
|
|
2631
|
-
const a = new
|
|
2701
|
+
const a = new _.Group(), h = e.clone();
|
|
2632
2702
|
a.add(h);
|
|
2633
2703
|
const l = t?.markerScale ?? 1;
|
|
2634
|
-
o.forEach((
|
|
2635
|
-
const
|
|
2636
|
-
if (
|
|
2637
|
-
const y =
|
|
2638
|
-
if (
|
|
2639
|
-
const
|
|
2640
|
-
if (
|
|
2641
|
-
const
|
|
2642
|
-
C.x(-
|
|
2704
|
+
o.forEach((m) => {
|
|
2705
|
+
const u = this.getStage().findOne(`#${m.id}`);
|
|
2706
|
+
if (u) {
|
|
2707
|
+
const y = u.clone(), w = y.findOne(".rect"), v = y.findOne(".marker-group");
|
|
2708
|
+
if (w && (w.strokeWidth(3 * l), w.dash([5 * l, 5 * l]), w.cornerRadius(6 * l)), v) {
|
|
2709
|
+
const M = v.findOne("Circle"), C = v.findOne("Text");
|
|
2710
|
+
if (M && (M.radius(14 * l), M.strokeWidth(3 * l)), C) {
|
|
2711
|
+
const B = 14 * l;
|
|
2712
|
+
C.x(-B), C.y(-B), C.width(B * 2), C.height(B * 2), C.fontSize(16 * l);
|
|
2643
2713
|
}
|
|
2644
2714
|
}
|
|
2645
2715
|
a.add(y);
|
|
@@ -2753,29 +2823,29 @@ class ks extends Is {
|
|
|
2753
2823
|
if ((this.getState().nodes || []).length === 0) return;
|
|
2754
2824
|
const e = i?.padding ?? 50, s = i?.scale === !0, o = i?.nodeIds;
|
|
2755
2825
|
let a = 1 / 0, h = 1 / 0, l = -1 / 0, d = -1 / 0;
|
|
2756
|
-
const f = this.getMainLayer(),
|
|
2757
|
-
if (f.children.forEach((
|
|
2758
|
-
if (
|
|
2759
|
-
if (
|
|
2760
|
-
const
|
|
2761
|
-
if (!
|
|
2826
|
+
const f = this.getMainLayer(), m = this.getState().selectedNodeIds || [], u = o && o.length > 0, y = !u && m.length > 0, w = u ? o : y ? m : null;
|
|
2827
|
+
if (f.children.forEach((z) => {
|
|
2828
|
+
if (z.visible() && z.getClassName() !== "Transformer" && z.hasName(b.selectable)) {
|
|
2829
|
+
if (w) {
|
|
2830
|
+
const ut = z.id();
|
|
2831
|
+
if (!w.includes(ut)) return;
|
|
2762
2832
|
}
|
|
2763
|
-
const
|
|
2764
|
-
if (
|
|
2765
|
-
const
|
|
2766
|
-
a = Math.min(a,
|
|
2833
|
+
const xt = z.getAttrs(), ni = xt.x || 0, si = xt.y || 0, En = xt.width || 0, Sn = xt.height || 0;
|
|
2834
|
+
if (xt.rotation || 0) {
|
|
2835
|
+
const ut = z.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;
|
|
2836
|
+
a = Math.min(a, Nn), h = Math.min(h, Tn), l = Math.max(l, _n), d = Math.max(d, Mn);
|
|
2767
2837
|
} else
|
|
2768
|
-
a = Math.min(a,
|
|
2838
|
+
a = Math.min(a, ni), h = Math.min(h, si), l = Math.max(l, ni + En), d = Math.max(d, si + Sn);
|
|
2769
2839
|
}
|
|
2770
2840
|
}), a === 1 / 0 || h === 1 / 0) return;
|
|
2771
|
-
const v = l - a,
|
|
2772
|
-
let
|
|
2841
|
+
const v = l - a, M = d - h, C = a + v / 2, B = h + M / 2;
|
|
2842
|
+
let K = this.getState().viewport.scale;
|
|
2773
2843
|
if (s) {
|
|
2774
|
-
const
|
|
2775
|
-
|
|
2844
|
+
const z = (this.getStage().width() - e * 2) / v, xt = (this.getStage().height() - e * 2) / M;
|
|
2845
|
+
K = Math.min(z, xt, 1);
|
|
2776
2846
|
}
|
|
2777
|
-
const
|
|
2778
|
-
this.updateViewport({ x:
|
|
2847
|
+
const q = this.getStage().width() / 2 - C * K, Ct = this.getStage().height() / 2 - B * K;
|
|
2848
|
+
this.updateViewport({ x: q, y: Ct, scale: K }, !0);
|
|
2779
2849
|
}
|
|
2780
2850
|
/**
|
|
2781
2851
|
* 导出当前状态
|
|
@@ -2829,11 +2899,11 @@ class ks extends Is {
|
|
|
2829
2899
|
}
|
|
2830
2900
|
}
|
|
2831
2901
|
}
|
|
2832
|
-
function
|
|
2902
|
+
function Ps(n, i, t, e = !1) {
|
|
2833
2903
|
const [s, o] = i, [a, h] = t, l = a + (n - s) / (o - s) * (h - a);
|
|
2834
2904
|
return e ? a < h ? Math.max(Math.min(l, h), a) : Math.max(Math.min(l, a), h) : l;
|
|
2835
2905
|
}
|
|
2836
|
-
const
|
|
2906
|
+
const Ei = [
|
|
2837
2907
|
{
|
|
2838
2908
|
min: -1,
|
|
2839
2909
|
mid: 0.15,
|
|
@@ -2855,7 +2925,7 @@ const vi = [
|
|
|
2855
2925
|
step: 1
|
|
2856
2926
|
}
|
|
2857
2927
|
];
|
|
2858
|
-
function
|
|
2928
|
+
function Bs({
|
|
2859
2929
|
viewportX: n,
|
|
2860
2930
|
viewportY: i,
|
|
2861
2931
|
scale: t,
|
|
@@ -2871,38 +2941,38 @@ function $s({
|
|
|
2871
2941
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2872
2942
|
"aria-hidden": "true",
|
|
2873
2943
|
children: [
|
|
2874
|
-
/* @__PURE__ */ c("defs", { children:
|
|
2875
|
-
const
|
|
2944
|
+
/* @__PURE__ */ c("defs", { children: Ei.map(({ min: l, mid: d, step: f }, m) => {
|
|
2945
|
+
const u = f * e * h, y = 0.5 + o * h, w = 0.5 + a * h, v = y > 0 ? y % u : u + y % u, M = w > 0 ? w % u : u + w % u, C = h < d ? Ps(h, [l, d], [0, 1]) : 1;
|
|
2876
2946
|
return /* @__PURE__ */ c(
|
|
2877
2947
|
"pattern",
|
|
2878
2948
|
{
|
|
2879
2949
|
id: `grid_${f}`,
|
|
2880
|
-
width:
|
|
2881
|
-
height:
|
|
2950
|
+
width: u,
|
|
2951
|
+
height: u,
|
|
2882
2952
|
patternUnits: "userSpaceOnUse",
|
|
2883
2953
|
children: /* @__PURE__ */ c(
|
|
2884
2954
|
"circle",
|
|
2885
2955
|
{
|
|
2886
2956
|
className: "grid-dot",
|
|
2887
2957
|
cx: v,
|
|
2888
|
-
cy:
|
|
2958
|
+
cy: M,
|
|
2889
2959
|
r: 1,
|
|
2890
2960
|
opacity: C
|
|
2891
2961
|
}
|
|
2892
2962
|
)
|
|
2893
2963
|
},
|
|
2894
|
-
|
|
2964
|
+
m
|
|
2895
2965
|
);
|
|
2896
2966
|
}) }),
|
|
2897
|
-
|
|
2967
|
+
Ei.map(({ step: l }, d) => /* @__PURE__ */ c("rect", { width: "100%", height: "100%", fill: `url(#grid_${l})` }, d))
|
|
2898
2968
|
]
|
|
2899
2969
|
}
|
|
2900
2970
|
) : null;
|
|
2901
2971
|
}
|
|
2902
|
-
function
|
|
2903
|
-
return
|
|
2972
|
+
function Vs(...n) {
|
|
2973
|
+
return Yn(Xn(n));
|
|
2904
2974
|
}
|
|
2905
|
-
const
|
|
2975
|
+
const Os = Wn(
|
|
2906
2976
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
2907
2977
|
{
|
|
2908
2978
|
variants: {
|
|
@@ -2929,7 +2999,7 @@ const Fs = Dn(
|
|
|
2929
2999
|
}
|
|
2930
3000
|
}
|
|
2931
3001
|
);
|
|
2932
|
-
function
|
|
3002
|
+
function Ft({
|
|
2933
3003
|
className: n,
|
|
2934
3004
|
variant: i = "default",
|
|
2935
3005
|
size: t = "default",
|
|
@@ -2937,26 +3007,26 @@ function Mt({
|
|
|
2937
3007
|
...s
|
|
2938
3008
|
}) {
|
|
2939
3009
|
return /* @__PURE__ */ c(
|
|
2940
|
-
e ?
|
|
3010
|
+
e ? zn : "button",
|
|
2941
3011
|
{
|
|
2942
3012
|
"data-slot": "button",
|
|
2943
3013
|
"data-variant": i,
|
|
2944
3014
|
"data-size": t,
|
|
2945
|
-
className:
|
|
3015
|
+
className: Vs(Os({ variant: i, size: t, className: n })),
|
|
2946
3016
|
...s
|
|
2947
3017
|
}
|
|
2948
3018
|
);
|
|
2949
3019
|
}
|
|
2950
|
-
function
|
|
3020
|
+
function Zs({ api: n }) {
|
|
2951
3021
|
const [i, t] = R(n.getState().viewport);
|
|
2952
|
-
|
|
3022
|
+
Z(() => {
|
|
2953
3023
|
n.on("viewport:change", (l) => {
|
|
2954
3024
|
t(l);
|
|
2955
3025
|
});
|
|
2956
3026
|
}, [t, n]);
|
|
2957
3027
|
const e = (l) => {
|
|
2958
|
-
const d = n.getStage().width() / 2, f = n.getStage().height() / 2,
|
|
2959
|
-
n.updateViewport({ x: y, y:
|
|
3028
|
+
const d = n.getStage().width() / 2, f = n.getStage().height() / 2, m = (d - i.x) / i.scale, u = (f - i.y) / i.scale, y = d - m * l, w = f - u * l;
|
|
3029
|
+
n.updateViewport({ x: y, y: w, scale: l });
|
|
2960
3030
|
}, s = () => {
|
|
2961
3031
|
const l = Math.min(i.scale * 1.2, 5);
|
|
2962
3032
|
e(l);
|
|
@@ -2968,17 +3038,17 @@ function Hs({ api: n }) {
|
|
|
2968
3038
|
}, h = Math.round(i.scale * 100);
|
|
2969
3039
|
return /* @__PURE__ */ k("div", { className: "zoom-panel flex items-center gap-2", children: [
|
|
2970
3040
|
/* @__PURE__ */ c(
|
|
2971
|
-
|
|
3041
|
+
Ft,
|
|
2972
3042
|
{
|
|
2973
3043
|
size: "sm",
|
|
2974
3044
|
variant: "secondary",
|
|
2975
3045
|
onClick: o,
|
|
2976
3046
|
title: "缩小",
|
|
2977
|
-
children: /* @__PURE__ */ c(
|
|
3047
|
+
children: /* @__PURE__ */ c(Gn, {})
|
|
2978
3048
|
}
|
|
2979
3049
|
),
|
|
2980
3050
|
/* @__PURE__ */ k(
|
|
2981
|
-
|
|
3051
|
+
Ft,
|
|
2982
3052
|
{
|
|
2983
3053
|
size: "sm",
|
|
2984
3054
|
variant: "secondary",
|
|
@@ -2992,20 +3062,20 @@ function Hs({ api: n }) {
|
|
|
2992
3062
|
}
|
|
2993
3063
|
),
|
|
2994
3064
|
/* @__PURE__ */ c(
|
|
2995
|
-
|
|
3065
|
+
Ft,
|
|
2996
3066
|
{
|
|
2997
3067
|
size: "sm",
|
|
2998
3068
|
variant: "secondary",
|
|
2999
3069
|
onClick: s,
|
|
3000
3070
|
title: "放大",
|
|
3001
|
-
children: /* @__PURE__ */ c(
|
|
3071
|
+
children: /* @__PURE__ */ c(Kn, {})
|
|
3002
3072
|
}
|
|
3003
3073
|
)
|
|
3004
3074
|
] });
|
|
3005
3075
|
}
|
|
3006
|
-
function
|
|
3076
|
+
function Us({ api: n }) {
|
|
3007
3077
|
const [i, t] = R(n.canUndo()), [e, s] = R(n.canRedo());
|
|
3008
|
-
return
|
|
3078
|
+
return Z(() => {
|
|
3009
3079
|
const o = () => {
|
|
3010
3080
|
t(n.canUndo()), s(n.canRedo());
|
|
3011
3081
|
};
|
|
@@ -3014,34 +3084,34 @@ function Ls({ api: n }) {
|
|
|
3014
3084
|
};
|
|
3015
3085
|
}, [n]), /* @__PURE__ */ k("div", { className: "history-panel flex items-center gap-2", children: [
|
|
3016
3086
|
/* @__PURE__ */ c(
|
|
3017
|
-
|
|
3087
|
+
Ft,
|
|
3018
3088
|
{
|
|
3019
3089
|
size: "sm",
|
|
3020
3090
|
variant: "secondary",
|
|
3021
3091
|
disabled: !i,
|
|
3022
3092
|
onClick: () => n.undo(),
|
|
3023
3093
|
title: "撤销",
|
|
3024
|
-
children: /* @__PURE__ */ c(
|
|
3094
|
+
children: /* @__PURE__ */ c(qn, {})
|
|
3025
3095
|
}
|
|
3026
3096
|
),
|
|
3027
3097
|
/* @__PURE__ */ c(
|
|
3028
|
-
|
|
3098
|
+
Ft,
|
|
3029
3099
|
{
|
|
3030
3100
|
size: "sm",
|
|
3031
3101
|
variant: "secondary",
|
|
3032
3102
|
disabled: !e,
|
|
3033
3103
|
onClick: () => n.redo(),
|
|
3034
3104
|
title: "重做",
|
|
3035
|
-
children: /* @__PURE__ */ c(
|
|
3105
|
+
children: /* @__PURE__ */ c(jn, {})
|
|
3036
3106
|
}
|
|
3037
3107
|
)
|
|
3038
3108
|
] });
|
|
3039
3109
|
}
|
|
3040
|
-
function
|
|
3041
|
-
const t =
|
|
3042
|
-
return
|
|
3110
|
+
function Xo({ setApi: n, theme: i }) {
|
|
3111
|
+
const t = Ue(null), [e, s] = R(null), [o, a] = R({ x: 0, y: 0, scale: 1 });
|
|
3112
|
+
return Z(() => {
|
|
3043
3113
|
if (!t.current) return;
|
|
3044
|
-
const h = new
|
|
3114
|
+
const h = new Ds(t.current, {
|
|
3045
3115
|
theme: i
|
|
3046
3116
|
});
|
|
3047
3117
|
return s(h), n?.(h), h.on("viewport:change", (l) => {
|
|
@@ -3049,11 +3119,11 @@ function Vo({ setApi: n, theme: i }) {
|
|
|
3049
3119
|
}), () => {
|
|
3050
3120
|
h.dispose();
|
|
3051
3121
|
};
|
|
3052
|
-
}, []),
|
|
3122
|
+
}, []), Z(() => {
|
|
3053
3123
|
e && i && e.setTheme(i);
|
|
3054
3124
|
}, [e, i]), /* @__PURE__ */ k("div", { className: "whiteboard relative size-full", children: [
|
|
3055
3125
|
/* @__PURE__ */ c(
|
|
3056
|
-
|
|
3126
|
+
Bs,
|
|
3057
3127
|
{
|
|
3058
3128
|
viewportX: o.x,
|
|
3059
3129
|
viewportY: o.y,
|
|
@@ -3067,15 +3137,15 @@ function Vo({ setApi: n, theme: i }) {
|
|
|
3067
3137
|
className: "whiteboard-container size-full outline-none relative"
|
|
3068
3138
|
}
|
|
3069
3139
|
),
|
|
3070
|
-
e && /* @__PURE__ */ k(
|
|
3071
|
-
/* @__PURE__ */ c("div", { className: "history-panel-wrapper absolute bottom-4 left-4 z-10", children: /* @__PURE__ */ c(
|
|
3072
|
-
/* @__PURE__ */ c("div", { className: "zoom-panel-wrapper absolute bottom-4 right-4 z-10", children: /* @__PURE__ */ c(
|
|
3140
|
+
e && /* @__PURE__ */ k(Ie, { children: [
|
|
3141
|
+
/* @__PURE__ */ c("div", { className: "history-panel-wrapper absolute bottom-4 left-4 z-10", children: /* @__PURE__ */ c(Us, { api: e }) }),
|
|
3142
|
+
/* @__PURE__ */ c("div", { className: "zoom-panel-wrapper absolute bottom-4 right-4 z-10", children: /* @__PURE__ */ c(Zs, { api: e }) })
|
|
3073
3143
|
] })
|
|
3074
3144
|
] });
|
|
3075
3145
|
}
|
|
3076
|
-
function
|
|
3146
|
+
function Yo(n) {
|
|
3077
3147
|
const [i, t] = R(null);
|
|
3078
|
-
return
|
|
3148
|
+
return Z(() => {
|
|
3079
3149
|
if (!n) return;
|
|
3080
3150
|
const s = ({
|
|
3081
3151
|
clientX: o,
|
|
@@ -3142,7 +3212,7 @@ function Oo(n) {
|
|
|
3142
3212
|
return n.on("contextmenu:show", s), () => {
|
|
3143
3213
|
n.off("contextmenu:show", s);
|
|
3144
3214
|
};
|
|
3145
|
-
}, [n]),
|
|
3215
|
+
}, [n]), Z(() => {
|
|
3146
3216
|
const s = () => {
|
|
3147
3217
|
i && t(null);
|
|
3148
3218
|
};
|
|
@@ -3156,7 +3226,7 @@ function Oo(n) {
|
|
|
3156
3226
|
}
|
|
3157
3227
|
};
|
|
3158
3228
|
}
|
|
3159
|
-
const
|
|
3229
|
+
const zs = {
|
|
3160
3230
|
mod: "⌘",
|
|
3161
3231
|
command: "⌘",
|
|
3162
3232
|
meta: "⌘",
|
|
@@ -3171,23 +3241,23 @@ const Ds = {
|
|
|
3171
3241
|
escape: "⎋",
|
|
3172
3242
|
capslock: "⇪"
|
|
3173
3243
|
};
|
|
3174
|
-
function
|
|
3244
|
+
function nt(...n) {
|
|
3175
3245
|
return n.filter(Boolean).join(" ");
|
|
3176
3246
|
}
|
|
3177
|
-
function
|
|
3247
|
+
function Ws() {
|
|
3178
3248
|
return typeof navigator < "u" && navigator.platform.toLowerCase().includes("mac");
|
|
3179
3249
|
}
|
|
3180
|
-
const
|
|
3250
|
+
const Xs = (n, i, t = !0) => {
|
|
3181
3251
|
if (i) {
|
|
3182
3252
|
const e = n.toLowerCase();
|
|
3183
|
-
return
|
|
3253
|
+
return zs[e] || (t ? n.toUpperCase() : n);
|
|
3184
3254
|
}
|
|
3185
3255
|
return t ? n.charAt(0).toUpperCase() + n.slice(1) : n;
|
|
3186
|
-
},
|
|
3256
|
+
}, ke = (n) => {
|
|
3187
3257
|
const { shortcutKeys: i, delimiter: t = "+", capitalize: e = !0 } = n;
|
|
3188
|
-
return i ? i.split(t).map((s) => s.trim()).map((s) =>
|
|
3189
|
-
},
|
|
3190
|
-
function
|
|
3258
|
+
return i ? i.split(t).map((s) => s.trim()).map((s) => Xs(s, Ws(), e)) : [];
|
|
3259
|
+
}, Qt = (n, i) => i?.schema ? i.schema.spec.marks.get(n) !== void 0 : !1;
|
|
3260
|
+
function qi(n, i) {
|
|
3191
3261
|
if (!n) return !1;
|
|
3192
3262
|
const t = Array.isArray(i) ? i : [i], e = t.some(
|
|
3193
3263
|
(s) => n.extensionManager.extensions.some((o) => o.name === s)
|
|
@@ -3196,11 +3266,11 @@ function Zi(n, i) {
|
|
|
3196
3266
|
`None of the extensions [${t.join(", ")}] were found in the editor schema. Ensure they are included in the editor configuration.`
|
|
3197
3267
|
), e;
|
|
3198
3268
|
}
|
|
3199
|
-
function
|
|
3269
|
+
function ze(n, i = [], t = !1) {
|
|
3200
3270
|
if (!n || !n.state.selection) return !1;
|
|
3201
3271
|
const { selection: e } = n.state;
|
|
3202
3272
|
if (e.empty) return !1;
|
|
3203
|
-
if (e instanceof
|
|
3273
|
+
if (e instanceof Qn) {
|
|
3204
3274
|
const s = e.node;
|
|
3205
3275
|
return s ? i.includes(s.type.name) : !1;
|
|
3206
3276
|
}
|
|
@@ -3214,12 +3284,12 @@ function Ve(n, i = [], t = !1) {
|
|
|
3214
3284
|
}
|
|
3215
3285
|
return !1;
|
|
3216
3286
|
}
|
|
3217
|
-
function
|
|
3218
|
-
const { editor: i } =
|
|
3287
|
+
function yt(n) {
|
|
3288
|
+
const { editor: i } = ts(), t = St(
|
|
3219
3289
|
() => n || i,
|
|
3220
3290
|
[n, i]
|
|
3221
3291
|
);
|
|
3222
|
-
return
|
|
3292
|
+
return es({
|
|
3223
3293
|
editor: t,
|
|
3224
3294
|
selector(s) {
|
|
3225
3295
|
return s.editor ? {
|
|
@@ -3234,7 +3304,7 @@ function mt(n) {
|
|
|
3234
3304
|
}
|
|
3235
3305
|
}) || { editor: null };
|
|
3236
3306
|
}
|
|
3237
|
-
function
|
|
3307
|
+
function Ys({
|
|
3238
3308
|
initialOpen: n = !1,
|
|
3239
3309
|
placement: i = "top",
|
|
3240
3310
|
open: t,
|
|
@@ -3242,21 +3312,21 @@ function Os({
|
|
|
3242
3312
|
delay: s = 600,
|
|
3243
3313
|
closeDelay: o = 0
|
|
3244
3314
|
} = {}) {
|
|
3245
|
-
const [a, h] = R(n), l = t ?? a, d = e ?? h, f =
|
|
3315
|
+
const [a, h] = R(n), l = t ?? a, d = e ?? h, f = ss({
|
|
3246
3316
|
placement: i,
|
|
3247
3317
|
open: l,
|
|
3248
3318
|
onOpenChange: d,
|
|
3249
|
-
whileElementsMounted:
|
|
3319
|
+
whileElementsMounted: ls,
|
|
3250
3320
|
middleware: [
|
|
3251
|
-
|
|
3252
|
-
|
|
3321
|
+
os(4),
|
|
3322
|
+
rs({
|
|
3253
3323
|
crossAxis: i.includes("-"),
|
|
3254
3324
|
fallbackAxisSideDirection: "start",
|
|
3255
3325
|
padding: 4
|
|
3256
3326
|
}),
|
|
3257
|
-
|
|
3327
|
+
as({ padding: 4 })
|
|
3258
3328
|
]
|
|
3259
|
-
}),
|
|
3329
|
+
}), m = f.context, u = hs(m, {
|
|
3260
3330
|
mouseOnly: !0,
|
|
3261
3331
|
move: !1,
|
|
3262
3332
|
restMs: s,
|
|
@@ -3264,51 +3334,51 @@ function Os({
|
|
|
3264
3334
|
delay: {
|
|
3265
3335
|
close: o
|
|
3266
3336
|
}
|
|
3267
|
-
}), y =
|
|
3337
|
+
}), y = cs(m, {
|
|
3268
3338
|
enabled: t == null
|
|
3269
|
-
}),
|
|
3270
|
-
return
|
|
3339
|
+
}), w = ds(m), v = gs(m, { role: "tooltip" }), M = us([u, y, w, v]);
|
|
3340
|
+
return St(
|
|
3271
3341
|
() => ({
|
|
3272
3342
|
open: l,
|
|
3273
3343
|
setOpen: d,
|
|
3274
|
-
...
|
|
3344
|
+
...M,
|
|
3275
3345
|
...f
|
|
3276
3346
|
}),
|
|
3277
|
-
[l, d,
|
|
3347
|
+
[l, d, M, f]
|
|
3278
3348
|
);
|
|
3279
3349
|
}
|
|
3280
|
-
const
|
|
3281
|
-
function
|
|
3282
|
-
const n =
|
|
3350
|
+
const Ve = Rn(null);
|
|
3351
|
+
function ji() {
|
|
3352
|
+
const n = Fn(Ve);
|
|
3283
3353
|
if (n == null)
|
|
3284
3354
|
throw new Error("Tooltip components must be wrapped in <TooltipProvider />");
|
|
3285
3355
|
return n;
|
|
3286
3356
|
}
|
|
3287
|
-
function
|
|
3288
|
-
const t =
|
|
3357
|
+
function Ji({ children: n, ...i }) {
|
|
3358
|
+
const t = Ys(i);
|
|
3289
3359
|
return i.useDelayGroup ? /* @__PURE__ */ c(
|
|
3290
|
-
|
|
3360
|
+
is,
|
|
3291
3361
|
{
|
|
3292
3362
|
delay: { open: i.delay ?? 0, close: i.closeDelay ?? 0 },
|
|
3293
3363
|
timeoutMs: i.timeout,
|
|
3294
|
-
children: /* @__PURE__ */ c(
|
|
3364
|
+
children: /* @__PURE__ */ c(Ve.Provider, { value: t, children: n })
|
|
3295
3365
|
}
|
|
3296
|
-
) : /* @__PURE__ */ c(
|
|
3366
|
+
) : /* @__PURE__ */ c(Ve.Provider, { value: t, children: n });
|
|
3297
3367
|
}
|
|
3298
|
-
const
|
|
3368
|
+
const Qi = $(
|
|
3299
3369
|
function({ children: i, asChild: t = !1, ...e }, s) {
|
|
3300
|
-
const o =
|
|
3370
|
+
const o = ji(), a = li(i) ? parseInt($n, 10) >= 19 ? (
|
|
3301
3371
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3302
3372
|
i.props.ref
|
|
3303
3373
|
) : (
|
|
3304
3374
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3305
3375
|
i.ref
|
|
3306
|
-
) : void 0, h =
|
|
3307
|
-
if (t &&
|
|
3376
|
+
) : void 0, h = Ni([o.refs.setReference, s, a]);
|
|
3377
|
+
if (t && li(i)) {
|
|
3308
3378
|
const l = {
|
|
3309
3379
|
"data-tooltip-state": o.open ? "open" : "closed"
|
|
3310
3380
|
};
|
|
3311
|
-
return
|
|
3381
|
+
return An(
|
|
3312
3382
|
i,
|
|
3313
3383
|
o.getReferenceProps({
|
|
3314
3384
|
ref: h,
|
|
@@ -3328,9 +3398,9 @@ const Xi = $(
|
|
|
3328
3398
|
}
|
|
3329
3399
|
);
|
|
3330
3400
|
}
|
|
3331
|
-
),
|
|
3401
|
+
), tn = $(
|
|
3332
3402
|
function({ style: i, children: t, portal: e = !0, portalProps: s = {}, ...o }, a) {
|
|
3333
|
-
const h =
|
|
3403
|
+
const h = ji(), l = Ni([h.refs.setFloating, a]);
|
|
3334
3404
|
if (!h.open) return null;
|
|
3335
3405
|
const d = /* @__PURE__ */ c(
|
|
3336
3406
|
"div",
|
|
@@ -3345,18 +3415,18 @@ const Xi = $(
|
|
|
3345
3415
|
children: t
|
|
3346
3416
|
}
|
|
3347
3417
|
);
|
|
3348
|
-
return e ? /* @__PURE__ */ c(
|
|
3418
|
+
return e ? /* @__PURE__ */ c(ns, { ...s, children: d }) : d;
|
|
3349
3419
|
}
|
|
3350
3420
|
);
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
const
|
|
3421
|
+
Ji.displayName = "Tooltip";
|
|
3422
|
+
Qi.displayName = "TooltipTrigger";
|
|
3423
|
+
tn.displayName = "TooltipContent";
|
|
3424
|
+
const Gs = ({
|
|
3355
3425
|
shortcuts: n
|
|
3356
|
-
}) => n.length === 0 ? null : /* @__PURE__ */ c("div", { children: n.map((i, t) => /* @__PURE__ */ k(
|
|
3426
|
+
}) => n.length === 0 ? null : /* @__PURE__ */ c("div", { children: n.map((i, t) => /* @__PURE__ */ k(Hn, { children: [
|
|
3357
3427
|
t > 0 && /* @__PURE__ */ c("kbd", { children: "+" }),
|
|
3358
3428
|
/* @__PURE__ */ c("kbd", { children: i })
|
|
3359
|
-
] }, t)) }),
|
|
3429
|
+
] }, t)) }), vt = $(
|
|
3360
3430
|
({
|
|
3361
3431
|
className: n,
|
|
3362
3432
|
children: i,
|
|
@@ -3367,25 +3437,25 @@ const Ps = ({
|
|
|
3367
3437
|
size: a,
|
|
3368
3438
|
...h
|
|
3369
3439
|
}, l) => {
|
|
3370
|
-
const d =
|
|
3371
|
-
() =>
|
|
3440
|
+
const d = St(
|
|
3441
|
+
() => ke({ shortcutKeys: s }),
|
|
3372
3442
|
[s]
|
|
3373
3443
|
);
|
|
3374
3444
|
return !t || !e ? /* @__PURE__ */ c(
|
|
3375
3445
|
"button",
|
|
3376
3446
|
{
|
|
3377
|
-
className:
|
|
3447
|
+
className: nt("tiptap-button", n),
|
|
3378
3448
|
ref: l,
|
|
3379
3449
|
"data-style": o,
|
|
3380
3450
|
"data-size": a,
|
|
3381
3451
|
...h,
|
|
3382
3452
|
children: i
|
|
3383
3453
|
}
|
|
3384
|
-
) : /* @__PURE__ */ k(
|
|
3454
|
+
) : /* @__PURE__ */ k(Ji, { delay: 200, children: [
|
|
3385
3455
|
/* @__PURE__ */ c(
|
|
3386
|
-
|
|
3456
|
+
Qi,
|
|
3387
3457
|
{
|
|
3388
|
-
className:
|
|
3458
|
+
className: nt("tiptap-button", n),
|
|
3389
3459
|
ref: l,
|
|
3390
3460
|
"data-style": o,
|
|
3391
3461
|
"data-size": a,
|
|
@@ -3393,27 +3463,27 @@ const Ps = ({
|
|
|
3393
3463
|
children: i
|
|
3394
3464
|
}
|
|
3395
3465
|
),
|
|
3396
|
-
/* @__PURE__ */ k(
|
|
3466
|
+
/* @__PURE__ */ k(tn, { children: [
|
|
3397
3467
|
t,
|
|
3398
|
-
/* @__PURE__ */ c(
|
|
3468
|
+
/* @__PURE__ */ c(Gs, { shortcuts: d })
|
|
3399
3469
|
] })
|
|
3400
3470
|
] });
|
|
3401
3471
|
}
|
|
3402
3472
|
);
|
|
3403
|
-
|
|
3404
|
-
const
|
|
3473
|
+
vt.displayName = "Button";
|
|
3474
|
+
const Ht = $(({ className: n, children: i, orientation: t = "vertical", ...e }, s) => /* @__PURE__ */ c(
|
|
3405
3475
|
"div",
|
|
3406
3476
|
{
|
|
3407
3477
|
ref: s,
|
|
3408
|
-
className:
|
|
3478
|
+
className: nt("tiptap-button-group", n),
|
|
3409
3479
|
"data-orientation": t,
|
|
3410
3480
|
role: "group",
|
|
3411
3481
|
...e,
|
|
3412
3482
|
children: i
|
|
3413
3483
|
}
|
|
3414
3484
|
));
|
|
3415
|
-
|
|
3416
|
-
const
|
|
3485
|
+
Ht.displayName = "ButtonGroup";
|
|
3486
|
+
const Re = $(
|
|
3417
3487
|
({
|
|
3418
3488
|
variant: n,
|
|
3419
3489
|
size: i = "default",
|
|
@@ -3436,14 +3506,14 @@ const _e = $(
|
|
|
3436
3506
|
}
|
|
3437
3507
|
)
|
|
3438
3508
|
);
|
|
3439
|
-
|
|
3440
|
-
function
|
|
3509
|
+
Re.displayName = "Badge";
|
|
3510
|
+
function Ks({
|
|
3441
3511
|
type: n,
|
|
3442
|
-
shortcutKeys: i =
|
|
3512
|
+
shortcutKeys: i = hn[n]
|
|
3443
3513
|
}) {
|
|
3444
|
-
return /* @__PURE__ */ c(
|
|
3514
|
+
return /* @__PURE__ */ c(Re, { children: ke({ shortcutKeys: i }) });
|
|
3445
3515
|
}
|
|
3446
|
-
const
|
|
3516
|
+
const At = $(
|
|
3447
3517
|
({
|
|
3448
3518
|
editor: n,
|
|
3449
3519
|
type: i,
|
|
@@ -3455,52 +3525,52 @@ const Tt = $(
|
|
|
3455
3525
|
children: h,
|
|
3456
3526
|
...l
|
|
3457
3527
|
}, d) => {
|
|
3458
|
-
const { editor: f } =
|
|
3459
|
-
isVisible:
|
|
3460
|
-
handleMark:
|
|
3528
|
+
const { editor: f } = yt(n), {
|
|
3529
|
+
isVisible: m,
|
|
3530
|
+
handleMark: u,
|
|
3461
3531
|
label: y,
|
|
3462
|
-
canToggle:
|
|
3532
|
+
canToggle: w,
|
|
3463
3533
|
isActive: v,
|
|
3464
|
-
Icon:
|
|
3534
|
+
Icon: M,
|
|
3465
3535
|
shortcutKeys: C
|
|
3466
|
-
} =
|
|
3536
|
+
} = eo({
|
|
3467
3537
|
editor: f,
|
|
3468
3538
|
type: i,
|
|
3469
3539
|
hideWhenUnavailable: e,
|
|
3470
3540
|
onToggled: s
|
|
3471
|
-
}),
|
|
3472
|
-
(
|
|
3473
|
-
a?.(
|
|
3541
|
+
}), B = J(
|
|
3542
|
+
(dt) => {
|
|
3543
|
+
a?.(dt), !dt.defaultPrevented && u();
|
|
3474
3544
|
},
|
|
3475
|
-
[
|
|
3545
|
+
[u, a]
|
|
3476
3546
|
);
|
|
3477
|
-
return
|
|
3478
|
-
|
|
3547
|
+
return m ? /* @__PURE__ */ c(
|
|
3548
|
+
vt,
|
|
3479
3549
|
{
|
|
3480
3550
|
type: "button",
|
|
3481
|
-
disabled: !
|
|
3551
|
+
disabled: !w,
|
|
3482
3552
|
variant: "ghost",
|
|
3483
3553
|
"data-active-state": v ? "on" : "off",
|
|
3484
|
-
"data-disabled": !
|
|
3554
|
+
"data-disabled": !w,
|
|
3485
3555
|
role: "button",
|
|
3486
3556
|
tabIndex: -1,
|
|
3487
3557
|
"aria-label": y,
|
|
3488
3558
|
"aria-pressed": v,
|
|
3489
3559
|
tooltip: y,
|
|
3490
|
-
onClick:
|
|
3560
|
+
onClick: B,
|
|
3491
3561
|
...l,
|
|
3492
3562
|
ref: d,
|
|
3493
|
-
children: h ?? /* @__PURE__ */ k(
|
|
3494
|
-
/* @__PURE__ */ c(
|
|
3563
|
+
children: h ?? /* @__PURE__ */ k(Ie, { children: [
|
|
3564
|
+
/* @__PURE__ */ c(M, { className: "tiptap-button-icon" }),
|
|
3495
3565
|
t && /* @__PURE__ */ c("span", { className: "tiptap-button-text", children: t }),
|
|
3496
|
-
o && /* @__PURE__ */ c(
|
|
3566
|
+
o && /* @__PURE__ */ c(Ks, { type: i, shortcutKeys: C })
|
|
3497
3567
|
] })
|
|
3498
3568
|
}
|
|
3499
3569
|
) : null;
|
|
3500
3570
|
}
|
|
3501
3571
|
);
|
|
3502
|
-
|
|
3503
|
-
const
|
|
3572
|
+
At.displayName = "MarkButton";
|
|
3573
|
+
const en = ct(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3504
3574
|
"svg",
|
|
3505
3575
|
{
|
|
3506
3576
|
width: "24",
|
|
@@ -3521,8 +3591,8 @@ const Yi = at(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
|
3521
3591
|
)
|
|
3522
3592
|
}
|
|
3523
3593
|
));
|
|
3524
|
-
|
|
3525
|
-
const
|
|
3594
|
+
en.displayName = "BoldIcon";
|
|
3595
|
+
const nn = ct(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
3526
3596
|
"svg",
|
|
3527
3597
|
{
|
|
3528
3598
|
width: "24",
|
|
@@ -3557,8 +3627,8 @@ const Gi = at(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
|
3557
3627
|
]
|
|
3558
3628
|
}
|
|
3559
3629
|
));
|
|
3560
|
-
|
|
3561
|
-
const
|
|
3630
|
+
nn.displayName = "Code2Icon";
|
|
3631
|
+
const sn = ct(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3562
3632
|
"svg",
|
|
3563
3633
|
{
|
|
3564
3634
|
width: "24",
|
|
@@ -3577,8 +3647,8 @@ const Ki = at(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
|
3577
3647
|
)
|
|
3578
3648
|
}
|
|
3579
3649
|
));
|
|
3580
|
-
|
|
3581
|
-
const
|
|
3650
|
+
sn.displayName = "ItalicIcon";
|
|
3651
|
+
const on = ct(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
3582
3652
|
"svg",
|
|
3583
3653
|
{
|
|
3584
3654
|
width: "24",
|
|
@@ -3606,8 +3676,8 @@ const qi = at(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
|
3606
3676
|
]
|
|
3607
3677
|
}
|
|
3608
3678
|
));
|
|
3609
|
-
|
|
3610
|
-
const
|
|
3679
|
+
on.displayName = "StrikeIcon";
|
|
3680
|
+
const rn = ct(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
3611
3681
|
"svg",
|
|
3612
3682
|
{
|
|
3613
3683
|
width: "24",
|
|
@@ -3648,8 +3718,8 @@ const ji = at(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
|
3648
3718
|
]
|
|
3649
3719
|
}
|
|
3650
3720
|
));
|
|
3651
|
-
|
|
3652
|
-
const
|
|
3721
|
+
rn.displayName = "SubscriptIcon";
|
|
3722
|
+
const an = ct(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
3653
3723
|
"svg",
|
|
3654
3724
|
{
|
|
3655
3725
|
width: "24",
|
|
@@ -3690,8 +3760,8 @@ const Ji = at(({ className: n, ...i }) => /* @__PURE__ */ k(
|
|
|
3690
3760
|
]
|
|
3691
3761
|
}
|
|
3692
3762
|
));
|
|
3693
|
-
|
|
3694
|
-
const
|
|
3763
|
+
an.displayName = "SuperscriptIcon";
|
|
3764
|
+
const ln = ct(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3695
3765
|
"svg",
|
|
3696
3766
|
{
|
|
3697
3767
|
width: "24",
|
|
@@ -3712,16 +3782,16 @@ const Qi = at(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
|
3712
3782
|
)
|
|
3713
3783
|
}
|
|
3714
3784
|
));
|
|
3715
|
-
|
|
3716
|
-
const
|
|
3717
|
-
bold:
|
|
3718
|
-
italic:
|
|
3719
|
-
underline:
|
|
3720
|
-
strike:
|
|
3721
|
-
code:
|
|
3722
|
-
superscript:
|
|
3723
|
-
subscript:
|
|
3724
|
-
},
|
|
3785
|
+
ln.displayName = "UnderlineIcon";
|
|
3786
|
+
const qs = {
|
|
3787
|
+
bold: en,
|
|
3788
|
+
italic: sn,
|
|
3789
|
+
underline: ln,
|
|
3790
|
+
strike: on,
|
|
3791
|
+
code: nn,
|
|
3792
|
+
superscript: an,
|
|
3793
|
+
subscript: rn
|
|
3794
|
+
}, hn = {
|
|
3725
3795
|
bold: "mod+b",
|
|
3726
3796
|
italic: "mod+i",
|
|
3727
3797
|
underline: "mod+u",
|
|
@@ -3730,54 +3800,54 @@ const Us = {
|
|
|
3730
3800
|
superscript: "mod+.",
|
|
3731
3801
|
subscript: "mod+,"
|
|
3732
3802
|
};
|
|
3733
|
-
function
|
|
3734
|
-
return !n || !n.isEditable || !
|
|
3803
|
+
function We(n, i) {
|
|
3804
|
+
return !n || !n.isEditable || !Qt(i, n) || ze(n, ["image"]) ? !1 : n.can().toggleMark(i);
|
|
3735
3805
|
}
|
|
3736
|
-
function
|
|
3806
|
+
function js(n, i) {
|
|
3737
3807
|
return !n || !n.isEditable ? !1 : n.isActive(i);
|
|
3738
3808
|
}
|
|
3739
|
-
function
|
|
3740
|
-
return !n || !n.isEditable || !
|
|
3809
|
+
function Js(n, i) {
|
|
3810
|
+
return !n || !n.isEditable || !We(n, i) ? !1 : n.chain().focus().toggleMark(i).run();
|
|
3741
3811
|
}
|
|
3742
|
-
function
|
|
3812
|
+
function Qs(n) {
|
|
3743
3813
|
const { editor: i, type: t, hideWhenUnavailable: e } = n;
|
|
3744
|
-
return !i || !i.isEditable ? !1 : e ?
|
|
3814
|
+
return !i || !i.isEditable ? !1 : e ? Qt(t, i) ? i.isActive("code") ? !0 : We(i, t) : !1 : !0;
|
|
3745
3815
|
}
|
|
3746
|
-
function
|
|
3816
|
+
function to(n) {
|
|
3747
3817
|
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
3748
3818
|
}
|
|
3749
|
-
function
|
|
3819
|
+
function eo(n) {
|
|
3750
3820
|
const {
|
|
3751
3821
|
editor: i,
|
|
3752
3822
|
type: t,
|
|
3753
3823
|
hideWhenUnavailable: e = !1,
|
|
3754
3824
|
onToggled: s
|
|
3755
|
-
} = n, { editor: o } =
|
|
3756
|
-
|
|
3825
|
+
} = n, { editor: o } = yt(i), [a, h] = R(!0), l = We(o, t), d = js(o, t);
|
|
3826
|
+
Z(() => {
|
|
3757
3827
|
if (!o) return;
|
|
3758
|
-
const
|
|
3759
|
-
h(
|
|
3828
|
+
const m = () => {
|
|
3829
|
+
h(Qs({ editor: o, type: t, hideWhenUnavailable: e }));
|
|
3760
3830
|
};
|
|
3761
|
-
return
|
|
3762
|
-
o.off("selectionUpdate",
|
|
3831
|
+
return m(), o.on("selectionUpdate", m), () => {
|
|
3832
|
+
o.off("selectionUpdate", m);
|
|
3763
3833
|
};
|
|
3764
3834
|
}, [o, t, e]);
|
|
3765
|
-
const f =
|
|
3835
|
+
const f = J(() => {
|
|
3766
3836
|
if (!o) return !1;
|
|
3767
|
-
const
|
|
3768
|
-
return
|
|
3837
|
+
const m = Js(o, t);
|
|
3838
|
+
return m && s?.(), m;
|
|
3769
3839
|
}, [o, t, s]);
|
|
3770
3840
|
return {
|
|
3771
3841
|
isVisible: a,
|
|
3772
3842
|
isActive: d,
|
|
3773
3843
|
handleMark: f,
|
|
3774
3844
|
canToggle: l,
|
|
3775
|
-
label:
|
|
3776
|
-
shortcutKeys:
|
|
3777
|
-
Icon:
|
|
3845
|
+
label: to(t),
|
|
3846
|
+
shortcutKeys: hn[t],
|
|
3847
|
+
Icon: qs[t]
|
|
3778
3848
|
};
|
|
3779
3849
|
}
|
|
3780
|
-
function
|
|
3850
|
+
function cn({
|
|
3781
3851
|
editor: n,
|
|
3782
3852
|
containerRef: i,
|
|
3783
3853
|
query: t,
|
|
@@ -3790,37 +3860,37 @@ function en({
|
|
|
3790
3860
|
const [l, d] = R(
|
|
3791
3861
|
h ? 0 : -1
|
|
3792
3862
|
);
|
|
3793
|
-
return
|
|
3794
|
-
const f = (
|
|
3863
|
+
return Z(() => {
|
|
3864
|
+
const f = (u) => {
|
|
3795
3865
|
if (!e.length) return !1;
|
|
3796
|
-
const y = () => d((v) => v === -1 ? 0 : (v + 1) % e.length),
|
|
3797
|
-
switch (
|
|
3866
|
+
const y = () => d((v) => v === -1 ? 0 : (v + 1) % e.length), w = () => d((v) => v === -1 ? e.length - 1 : (v - 1 + e.length) % e.length);
|
|
3867
|
+
switch (u.key) {
|
|
3798
3868
|
case "ArrowUp":
|
|
3799
|
-
return a === "horizontal" ? !1 : (
|
|
3869
|
+
return a === "horizontal" ? !1 : (u.preventDefault(), w(), !0);
|
|
3800
3870
|
case "ArrowDown":
|
|
3801
|
-
return a === "horizontal" ? !1 : (
|
|
3871
|
+
return a === "horizontal" ? !1 : (u.preventDefault(), y(), !0);
|
|
3802
3872
|
case "ArrowLeft":
|
|
3803
|
-
return a === "vertical" ? !1 : (
|
|
3873
|
+
return a === "vertical" ? !1 : (u.preventDefault(), w(), !0);
|
|
3804
3874
|
case "ArrowRight":
|
|
3805
|
-
return a === "vertical" ? !1 : (
|
|
3875
|
+
return a === "vertical" ? !1 : (u.preventDefault(), y(), !0);
|
|
3806
3876
|
case "Tab":
|
|
3807
|
-
return
|
|
3877
|
+
return u.preventDefault(), u.shiftKey ? w() : y(), !0;
|
|
3808
3878
|
case "Home":
|
|
3809
|
-
return
|
|
3879
|
+
return u.preventDefault(), d(0), !0;
|
|
3810
3880
|
case "End":
|
|
3811
|
-
return
|
|
3881
|
+
return u.preventDefault(), d(e.length - 1), !0;
|
|
3812
3882
|
case "Enter":
|
|
3813
|
-
return
|
|
3883
|
+
return u.isComposing ? !1 : (u.preventDefault(), l !== -1 && e[l] && s?.(e[l]), !0);
|
|
3814
3884
|
case "Escape":
|
|
3815
|
-
return
|
|
3885
|
+
return u.preventDefault(), o?.(), !0;
|
|
3816
3886
|
default:
|
|
3817
3887
|
return !1;
|
|
3818
3888
|
}
|
|
3819
3889
|
};
|
|
3820
|
-
let
|
|
3821
|
-
if (n ?
|
|
3822
|
-
return
|
|
3823
|
-
|
|
3890
|
+
let m = null;
|
|
3891
|
+
if (n ? m = n.view.dom : i?.current && (m = i.current), m)
|
|
3892
|
+
return m.addEventListener("keydown", f, !0), () => {
|
|
3893
|
+
m?.removeEventListener(
|
|
3824
3894
|
"keydown",
|
|
3825
3895
|
f,
|
|
3826
3896
|
!0
|
|
@@ -3834,21 +3904,21 @@ function en({
|
|
|
3834
3904
|
s,
|
|
3835
3905
|
o,
|
|
3836
3906
|
a
|
|
3837
|
-
]),
|
|
3907
|
+
]), Z(() => {
|
|
3838
3908
|
t && d(h ? 0 : -1);
|
|
3839
3909
|
}, [t, h]), {
|
|
3840
3910
|
selectedIndex: e.length ? l : void 0,
|
|
3841
3911
|
setSelectedIndex: d
|
|
3842
3912
|
};
|
|
3843
3913
|
}
|
|
3844
|
-
function
|
|
3914
|
+
function $e(n = "max", i = 768) {
|
|
3845
3915
|
const [t, e] = R(void 0);
|
|
3846
|
-
return
|
|
3916
|
+
return Z(() => {
|
|
3847
3917
|
const s = n === "min" ? `(min-width: ${i}px)` : `(max-width: ${i - 1}px)`, o = window.matchMedia(s), a = (h) => e(h.matches);
|
|
3848
3918
|
return e(o.matches), o.addEventListener("change", a), () => o.removeEventListener("change", a);
|
|
3849
3919
|
}, [n, i]), !!t;
|
|
3850
3920
|
}
|
|
3851
|
-
const
|
|
3921
|
+
const Xe = ct(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3852
3922
|
"svg",
|
|
3853
3923
|
{
|
|
3854
3924
|
width: "24",
|
|
@@ -3869,8 +3939,8 @@ const Pe = at(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
|
3869
3939
|
)
|
|
3870
3940
|
}
|
|
3871
3941
|
));
|
|
3872
|
-
|
|
3873
|
-
const
|
|
3942
|
+
Xe.displayName = "BanIcon";
|
|
3943
|
+
const Ye = ct(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
3874
3944
|
"svg",
|
|
3875
3945
|
{
|
|
3876
3946
|
width: "24",
|
|
@@ -3891,41 +3961,41 @@ const Ze = at(({ className: n, ...i }) => /* @__PURE__ */ c(
|
|
|
3891
3961
|
)
|
|
3892
3962
|
}
|
|
3893
3963
|
));
|
|
3894
|
-
|
|
3895
|
-
function
|
|
3964
|
+
Ye.displayName = "HighlighterIcon";
|
|
3965
|
+
function dn({
|
|
3896
3966
|
...n
|
|
3897
3967
|
}) {
|
|
3898
|
-
return /* @__PURE__ */ c(
|
|
3968
|
+
return /* @__PURE__ */ c(ie.Root, { ...n });
|
|
3899
3969
|
}
|
|
3900
|
-
function
|
|
3970
|
+
function gn({
|
|
3901
3971
|
...n
|
|
3902
3972
|
}) {
|
|
3903
|
-
return /* @__PURE__ */ c(
|
|
3973
|
+
return /* @__PURE__ */ c(ie.Trigger, { ...n });
|
|
3904
3974
|
}
|
|
3905
|
-
function
|
|
3975
|
+
function un({
|
|
3906
3976
|
className: n,
|
|
3907
3977
|
align: i = "center",
|
|
3908
3978
|
sideOffset: t = 4,
|
|
3909
3979
|
...e
|
|
3910
3980
|
}) {
|
|
3911
|
-
return /* @__PURE__ */ c(
|
|
3912
|
-
|
|
3981
|
+
return /* @__PURE__ */ c(ie.Portal, { children: /* @__PURE__ */ c(
|
|
3982
|
+
ie.Content,
|
|
3913
3983
|
{
|
|
3914
3984
|
align: i,
|
|
3915
3985
|
sideOffset: t,
|
|
3916
3986
|
side: "top",
|
|
3917
|
-
className:
|
|
3987
|
+
className: nt("tiptap-popover", n),
|
|
3918
3988
|
...e
|
|
3919
3989
|
}
|
|
3920
3990
|
) });
|
|
3921
3991
|
}
|
|
3922
|
-
const
|
|
3992
|
+
const Ge = $(
|
|
3923
3993
|
({ decorative: n, orientation: i = "vertical", className: t, ...e }, s) => {
|
|
3924
3994
|
const a = n ? { role: "none" } : { "aria-orientation": i === "vertical" ? i : void 0, role: "separator" };
|
|
3925
3995
|
return /* @__PURE__ */ c(
|
|
3926
3996
|
"div",
|
|
3927
3997
|
{
|
|
3928
|
-
className:
|
|
3998
|
+
className: nt("tiptap-separator", t),
|
|
3929
3999
|
"data-orientation": i,
|
|
3930
4000
|
...a,
|
|
3931
4001
|
...e,
|
|
@@ -3934,64 +4004,64 @@ const Ue = $(
|
|
|
3934
4004
|
);
|
|
3935
4005
|
}
|
|
3936
4006
|
);
|
|
3937
|
-
|
|
3938
|
-
const
|
|
3939
|
-
({ className: n, ...i }, t) => /* @__PURE__ */ c("div", { ref: t, className:
|
|
4007
|
+
Ge.displayName = "Separator";
|
|
4008
|
+
const Ke = $(
|
|
4009
|
+
({ className: n, ...i }, t) => /* @__PURE__ */ c("div", { ref: t, className: nt("tiptap-card", n), ...i })
|
|
3940
4010
|
);
|
|
3941
|
-
|
|
3942
|
-
const
|
|
4011
|
+
Ke.displayName = "Card";
|
|
4012
|
+
const io = $(
|
|
3943
4013
|
({ className: n, ...i }, t) => /* @__PURE__ */ c(
|
|
3944
4014
|
"div",
|
|
3945
4015
|
{
|
|
3946
4016
|
ref: t,
|
|
3947
|
-
className:
|
|
4017
|
+
className: nt("tiptap-card-header", n),
|
|
3948
4018
|
...i
|
|
3949
4019
|
}
|
|
3950
4020
|
)
|
|
3951
4021
|
);
|
|
3952
|
-
|
|
3953
|
-
const
|
|
3954
|
-
({ className: n, ...i }, t) => /* @__PURE__ */ c("div", { ref: t, className:
|
|
4022
|
+
io.displayName = "CardHeader";
|
|
4023
|
+
const qe = $(
|
|
4024
|
+
({ className: n, ...i }, t) => /* @__PURE__ */ c("div", { ref: t, className: nt("tiptap-card-body", n), ...i })
|
|
3955
4025
|
);
|
|
3956
|
-
|
|
3957
|
-
const
|
|
4026
|
+
qe.displayName = "CardBody";
|
|
4027
|
+
const je = $(({ className: n, orientation: i = "vertical", ...t }, e) => /* @__PURE__ */ c(
|
|
3958
4028
|
"div",
|
|
3959
4029
|
{
|
|
3960
4030
|
ref: e,
|
|
3961
4031
|
"data-orientation": i,
|
|
3962
|
-
className:
|
|
4032
|
+
className: nt("tiptap-card-item-group", n),
|
|
3963
4033
|
...t
|
|
3964
4034
|
}
|
|
3965
4035
|
));
|
|
3966
|
-
|
|
3967
|
-
const
|
|
4036
|
+
je.displayName = "CardItemGroup";
|
|
4037
|
+
const no = $(
|
|
3968
4038
|
({ className: n, ...i }, t) => /* @__PURE__ */ c(
|
|
3969
4039
|
"div",
|
|
3970
4040
|
{
|
|
3971
4041
|
ref: t,
|
|
3972
|
-
className:
|
|
4042
|
+
className: nt("tiptap-card-group-label", n),
|
|
3973
4043
|
...i
|
|
3974
4044
|
}
|
|
3975
4045
|
)
|
|
3976
4046
|
);
|
|
3977
|
-
|
|
3978
|
-
const
|
|
4047
|
+
no.displayName = "CardGroupLabel";
|
|
4048
|
+
const so = $(
|
|
3979
4049
|
({ className: n, ...i }, t) => /* @__PURE__ */ c(
|
|
3980
4050
|
"div",
|
|
3981
4051
|
{
|
|
3982
4052
|
ref: t,
|
|
3983
|
-
className:
|
|
4053
|
+
className: nt("tiptap-card-footer", n),
|
|
3984
4054
|
...i
|
|
3985
4055
|
}
|
|
3986
4056
|
)
|
|
3987
4057
|
);
|
|
3988
|
-
|
|
3989
|
-
function
|
|
3990
|
-
shortcutKeys: n =
|
|
4058
|
+
so.displayName = "CardFooter";
|
|
4059
|
+
function oo({
|
|
4060
|
+
shortcutKeys: n = Oe
|
|
3991
4061
|
}) {
|
|
3992
|
-
return /* @__PURE__ */ c(
|
|
4062
|
+
return /* @__PURE__ */ c(Re, { children: ke({ shortcutKeys: n }) });
|
|
3993
4063
|
}
|
|
3994
|
-
const
|
|
4064
|
+
const mn = $(
|
|
3995
4065
|
({
|
|
3996
4066
|
editor: n,
|
|
3997
4067
|
highlightColor: i,
|
|
@@ -4004,16 +4074,16 @@ const rn = $(
|
|
|
4004
4074
|
children: l,
|
|
4005
4075
|
style: d,
|
|
4006
4076
|
useColorValue: f = !1,
|
|
4007
|
-
...
|
|
4008
|
-
},
|
|
4009
|
-
const { editor: y } =
|
|
4010
|
-
isVisible:
|
|
4077
|
+
...m
|
|
4078
|
+
}, u) => {
|
|
4079
|
+
const { editor: y } = yt(n), {
|
|
4080
|
+
isVisible: w,
|
|
4011
4081
|
canColorHighlight: v,
|
|
4012
|
-
isActive:
|
|
4082
|
+
isActive: M,
|
|
4013
4083
|
handleColorHighlight: C,
|
|
4014
|
-
label:
|
|
4015
|
-
shortcutKeys:
|
|
4016
|
-
} =
|
|
4084
|
+
label: B,
|
|
4085
|
+
shortcutKeys: dt
|
|
4086
|
+
} = Qe({
|
|
4017
4087
|
editor: y,
|
|
4018
4088
|
highlightColor: i,
|
|
4019
4089
|
useColorValue: f,
|
|
@@ -4021,36 +4091,36 @@ const rn = $(
|
|
|
4021
4091
|
hideWhenUnavailable: e,
|
|
4022
4092
|
mode: s,
|
|
4023
4093
|
onApplied: o
|
|
4024
|
-
}),
|
|
4025
|
-
(
|
|
4026
|
-
h?.(
|
|
4094
|
+
}), K = J(
|
|
4095
|
+
(Ct) => {
|
|
4096
|
+
h?.(Ct), !Ct.defaultPrevented && (C(), Ct.preventDefault(), Ct.stopPropagation());
|
|
4027
4097
|
},
|
|
4028
4098
|
[C, h]
|
|
4029
|
-
),
|
|
4099
|
+
), q = St(
|
|
4030
4100
|
() => ({
|
|
4031
4101
|
...d,
|
|
4032
4102
|
"--highlight-color": i
|
|
4033
4103
|
}),
|
|
4034
4104
|
[i, d]
|
|
4035
4105
|
);
|
|
4036
|
-
return
|
|
4037
|
-
|
|
4106
|
+
return w ? /* @__PURE__ */ c(
|
|
4107
|
+
vt,
|
|
4038
4108
|
{
|
|
4039
4109
|
type: "button",
|
|
4040
4110
|
variant: "ghost",
|
|
4041
|
-
"data-active-state":
|
|
4111
|
+
"data-active-state": M ? "on" : "off",
|
|
4042
4112
|
role: "button",
|
|
4043
4113
|
tabIndex: -1,
|
|
4044
4114
|
disabled: !v,
|
|
4045
4115
|
"data-disabled": !v,
|
|
4046
|
-
"aria-label":
|
|
4047
|
-
"aria-pressed":
|
|
4048
|
-
tooltip:
|
|
4049
|
-
onClick:
|
|
4050
|
-
style:
|
|
4051
|
-
...
|
|
4052
|
-
ref:
|
|
4053
|
-
children: l ?? /* @__PURE__ */ k(
|
|
4116
|
+
"aria-label": B,
|
|
4117
|
+
"aria-pressed": M,
|
|
4118
|
+
tooltip: B,
|
|
4119
|
+
onClick: K,
|
|
4120
|
+
style: q,
|
|
4121
|
+
...m,
|
|
4122
|
+
ref: u,
|
|
4123
|
+
children: l ?? /* @__PURE__ */ k(Ie, { children: [
|
|
4054
4124
|
/* @__PURE__ */ c(
|
|
4055
4125
|
"span",
|
|
4056
4126
|
{
|
|
@@ -4059,14 +4129,14 @@ const rn = $(
|
|
|
4059
4129
|
}
|
|
4060
4130
|
),
|
|
4061
4131
|
t && /* @__PURE__ */ c("span", { className: "tiptap-button-text", children: t }),
|
|
4062
|
-
a && /* @__PURE__ */ c(
|
|
4132
|
+
a && /* @__PURE__ */ c(oo, { shortcutKeys: dt })
|
|
4063
4133
|
] })
|
|
4064
4134
|
}
|
|
4065
4135
|
) : null;
|
|
4066
4136
|
}
|
|
4067
4137
|
);
|
|
4068
|
-
|
|
4069
|
-
const
|
|
4138
|
+
mn.displayName = "ColorHighlightButton";
|
|
4139
|
+
const Oe = "mod+shift+h", fn = [
|
|
4070
4140
|
{
|
|
4071
4141
|
label: "Default background",
|
|
4072
4142
|
value: "var(--tt-bg-color)",
|
|
@@ -4128,29 +4198,29 @@ const Le = "mod+shift+h", an = [
|
|
|
4128
4198
|
border: "var(--tt-color-highlight-red-contrast)"
|
|
4129
4199
|
}
|
|
4130
4200
|
];
|
|
4131
|
-
function
|
|
4201
|
+
function pn(n) {
|
|
4132
4202
|
const i = new Map(
|
|
4133
|
-
|
|
4203
|
+
fn.map((t) => [t.value, t])
|
|
4134
4204
|
);
|
|
4135
4205
|
return n.map((t) => i.get(t)).filter((t) => !!t);
|
|
4136
4206
|
}
|
|
4137
|
-
function
|
|
4138
|
-
return i &&
|
|
4207
|
+
function ro(n, i = !1) {
|
|
4208
|
+
return i && fn.find(
|
|
4139
4209
|
(e) => e.value === n || e.colorValue === n
|
|
4140
4210
|
)?.colorValue || n;
|
|
4141
4211
|
}
|
|
4142
|
-
function
|
|
4212
|
+
function Je(n, i = "mark") {
|
|
4143
4213
|
if (!n || !n.isEditable) return !1;
|
|
4144
4214
|
if (i === "mark")
|
|
4145
|
-
return !
|
|
4146
|
-
if (!
|
|
4215
|
+
return !Qt("highlight", n) || ze(n, ["image"]) ? !1 : n.can().setMark("highlight");
|
|
4216
|
+
if (!qi(n, ["nodeBackground"])) return !1;
|
|
4147
4217
|
try {
|
|
4148
4218
|
return n.can().toggleNodeBackgroundColor("test");
|
|
4149
4219
|
} catch {
|
|
4150
4220
|
return !1;
|
|
4151
4221
|
}
|
|
4152
4222
|
}
|
|
4153
|
-
function
|
|
4223
|
+
function ao(n, i, t = "mark") {
|
|
4154
4224
|
if (!n || !n.isEditable) return !1;
|
|
4155
4225
|
if (t === "mark")
|
|
4156
4226
|
return i ? n.isActive("highlight", { color: i }) : n.isActive("highlight");
|
|
@@ -4167,20 +4237,20 @@ function to(n, i, t = "mark") {
|
|
|
4167
4237
|
return !1;
|
|
4168
4238
|
}
|
|
4169
4239
|
}
|
|
4170
|
-
function
|
|
4171
|
-
return !n || !n.isEditable || !
|
|
4240
|
+
function lo(n, i = "mark") {
|
|
4241
|
+
return !n || !n.isEditable || !Je(n, i) ? !1 : i === "mark" ? n.chain().focus().unsetMark("highlight").run() : n.chain().focus().unsetNodeBackgroundColor().run();
|
|
4172
4242
|
}
|
|
4173
|
-
function
|
|
4243
|
+
function ho(n) {
|
|
4174
4244
|
const { editor: i, hideWhenUnavailable: t, mode: e } = n;
|
|
4175
4245
|
if (!i || !i.isEditable) return !1;
|
|
4176
4246
|
if (!t)
|
|
4177
4247
|
return !0;
|
|
4178
4248
|
if (e === "mark") {
|
|
4179
|
-
if (!
|
|
4180
|
-
} else if (!
|
|
4181
|
-
return i.isActive("code") ? !0 :
|
|
4249
|
+
if (!Qt("highlight", i)) return !1;
|
|
4250
|
+
} else if (!qi(i, ["nodeBackground"])) return !1;
|
|
4251
|
+
return i.isActive("code") ? !0 : Je(i, e);
|
|
4182
4252
|
}
|
|
4183
|
-
function
|
|
4253
|
+
function Qe(n) {
|
|
4184
4254
|
const {
|
|
4185
4255
|
editor: i,
|
|
4186
4256
|
label: t,
|
|
@@ -4189,18 +4259,18 @@ function Ge(n) {
|
|
|
4189
4259
|
mode: o = "mark",
|
|
4190
4260
|
useColorValue: a = !1,
|
|
4191
4261
|
onApplied: h
|
|
4192
|
-
} = n, { editor: l } =
|
|
4193
|
-
|
|
4262
|
+
} = n, { editor: l } = yt(i), d = $e(), [f, m] = R(!0), u = Je(l, o), y = e && ro(e, a), w = ao(l, y, o);
|
|
4263
|
+
Z(() => {
|
|
4194
4264
|
if (!l) return;
|
|
4195
4265
|
const C = () => {
|
|
4196
|
-
|
|
4266
|
+
m(ho({ editor: l, hideWhenUnavailable: s, mode: o }));
|
|
4197
4267
|
};
|
|
4198
4268
|
return C(), l.on("selectionUpdate", C), () => {
|
|
4199
4269
|
l.off("selectionUpdate", C);
|
|
4200
4270
|
};
|
|
4201
4271
|
}, [l, s, o]);
|
|
4202
|
-
const v =
|
|
4203
|
-
if (!l || !
|
|
4272
|
+
const v = J(() => {
|
|
4273
|
+
if (!l || !u || !y || !t)
|
|
4204
4274
|
return !1;
|
|
4205
4275
|
if (o === "mark") {
|
|
4206
4276
|
if (l.state.storedMarks) {
|
|
@@ -4217,34 +4287,34 @@ function Ge(n) {
|
|
|
4217
4287
|
const C = l.chain().focus().toggleNodeBackgroundColor(y).run();
|
|
4218
4288
|
return C && h?.({ color: y, label: t, mode: o }), C;
|
|
4219
4289
|
}
|
|
4220
|
-
}, [
|
|
4221
|
-
const C =
|
|
4290
|
+
}, [u, y, l, t, h, o]), M = J(() => {
|
|
4291
|
+
const C = lo(l, o);
|
|
4222
4292
|
return C && h?.({ color: "", label: "Remove highlight", mode: o }), C;
|
|
4223
4293
|
}, [l, h, o]);
|
|
4224
|
-
return
|
|
4225
|
-
|
|
4294
|
+
return Ti(
|
|
4295
|
+
Oe,
|
|
4226
4296
|
(C) => {
|
|
4227
4297
|
C.preventDefault(), v();
|
|
4228
4298
|
},
|
|
4229
4299
|
{
|
|
4230
|
-
enabled: f &&
|
|
4300
|
+
enabled: f && u,
|
|
4231
4301
|
enableOnContentEditable: !d,
|
|
4232
4302
|
enableOnFormTags: !0
|
|
4233
4303
|
}
|
|
4234
4304
|
), {
|
|
4235
4305
|
isVisible: f,
|
|
4236
|
-
isActive:
|
|
4306
|
+
isActive: w,
|
|
4237
4307
|
handleColorHighlight: v,
|
|
4238
|
-
handleRemoveHighlight:
|
|
4239
|
-
canColorHighlight:
|
|
4308
|
+
handleRemoveHighlight: M,
|
|
4309
|
+
canColorHighlight: u,
|
|
4240
4310
|
label: t || "Highlight",
|
|
4241
|
-
shortcutKeys:
|
|
4242
|
-
Icon:
|
|
4311
|
+
shortcutKeys: Oe,
|
|
4312
|
+
Icon: Ye,
|
|
4243
4313
|
mode: o
|
|
4244
4314
|
};
|
|
4245
4315
|
}
|
|
4246
|
-
const
|
|
4247
|
-
|
|
4316
|
+
const yn = $(({ className: n, children: i, ...t }, e) => /* @__PURE__ */ c(
|
|
4317
|
+
vt,
|
|
4248
4318
|
{
|
|
4249
4319
|
type: "button",
|
|
4250
4320
|
className: n,
|
|
@@ -4256,13 +4326,13 @@ const hn = $(({ className: n, children: i, ...t }, e) => /* @__PURE__ */ c(
|
|
|
4256
4326
|
tooltip: "Highlight",
|
|
4257
4327
|
ref: e,
|
|
4258
4328
|
...t,
|
|
4259
|
-
children: i ?? /* @__PURE__ */ c(
|
|
4329
|
+
children: i ?? /* @__PURE__ */ c(Ye, { className: "tiptap-button-icon" })
|
|
4260
4330
|
}
|
|
4261
4331
|
));
|
|
4262
|
-
|
|
4263
|
-
function
|
|
4332
|
+
yn.displayName = "ColorHighlightPopoverButton";
|
|
4333
|
+
function co({
|
|
4264
4334
|
editor: n,
|
|
4265
|
-
colors: i =
|
|
4335
|
+
colors: i = pn([
|
|
4266
4336
|
"var(--tt-color-highlight-green)",
|
|
4267
4337
|
"var(--tt-color-highlight-blue)",
|
|
4268
4338
|
"var(--tt-color-highlight-red)",
|
|
@@ -4271,10 +4341,10 @@ function no({
|
|
|
4271
4341
|
]),
|
|
4272
4342
|
useColorValue: t = !1
|
|
4273
4343
|
}) {
|
|
4274
|
-
const { handleRemoveHighlight: e } =
|
|
4344
|
+
const { handleRemoveHighlight: e } = Qe({ editor: n }), s = $e(), o = Ue(null), a = St(
|
|
4275
4345
|
() => [...i, { label: "Remove highlight", value: "none" }],
|
|
4276
4346
|
[i]
|
|
4277
|
-
), { selectedIndex: h } =
|
|
4347
|
+
), { selectedIndex: h } = cn({
|
|
4278
4348
|
containerRef: o,
|
|
4279
4349
|
items: a,
|
|
4280
4350
|
orientation: "both",
|
|
@@ -4288,14 +4358,14 @@ function no({
|
|
|
4288
4358
|
autoSelectFirstItem: !1
|
|
4289
4359
|
});
|
|
4290
4360
|
return /* @__PURE__ */ c(
|
|
4291
|
-
|
|
4361
|
+
Ke,
|
|
4292
4362
|
{
|
|
4293
4363
|
ref: o,
|
|
4294
4364
|
tabIndex: 0,
|
|
4295
4365
|
style: s ? { boxShadow: "none", border: 0 } : {},
|
|
4296
|
-
children: /* @__PURE__ */ c(
|
|
4297
|
-
/* @__PURE__ */ c(
|
|
4298
|
-
|
|
4366
|
+
children: /* @__PURE__ */ c(qe, { style: s ? { padding: 0 } : {}, children: /* @__PURE__ */ k(je, { orientation: "horizontal", children: [
|
|
4367
|
+
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: i.map((l, d) => /* @__PURE__ */ c(
|
|
4368
|
+
mn,
|
|
4299
4369
|
{
|
|
4300
4370
|
editor: n,
|
|
4301
4371
|
highlightColor: t ? l.colorValue : l.value,
|
|
@@ -4307,9 +4377,9 @@ function no({
|
|
|
4307
4377
|
},
|
|
4308
4378
|
l.value
|
|
4309
4379
|
)) }),
|
|
4310
|
-
/* @__PURE__ */ c(
|
|
4311
|
-
/* @__PURE__ */ c(
|
|
4312
|
-
|
|
4380
|
+
/* @__PURE__ */ c(Ge, {}),
|
|
4381
|
+
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: /* @__PURE__ */ c(
|
|
4382
|
+
vt,
|
|
4313
4383
|
{
|
|
4314
4384
|
onClick: e,
|
|
4315
4385
|
"aria-label": "Remove highlight",
|
|
@@ -4319,16 +4389,16 @@ function no({
|
|
|
4319
4389
|
role: "menuitem",
|
|
4320
4390
|
variant: "ghost",
|
|
4321
4391
|
"data-highlighted": h === i.length,
|
|
4322
|
-
children: /* @__PURE__ */ c(
|
|
4392
|
+
children: /* @__PURE__ */ c(Xe, { className: "tiptap-button-icon" })
|
|
4323
4393
|
}
|
|
4324
4394
|
) })
|
|
4325
4395
|
] }) })
|
|
4326
4396
|
}
|
|
4327
4397
|
);
|
|
4328
4398
|
}
|
|
4329
|
-
function
|
|
4399
|
+
function go({
|
|
4330
4400
|
editor: n,
|
|
4331
|
-
colors: i =
|
|
4401
|
+
colors: i = pn([
|
|
4332
4402
|
"var(--tt-color-highlight-green)",
|
|
4333
4403
|
"var(--tt-color-highlight-blue)",
|
|
4334
4404
|
"var(--tt-color-highlight-red)",
|
|
@@ -4340,27 +4410,27 @@ function so({
|
|
|
4340
4410
|
onApplied: s,
|
|
4341
4411
|
...o
|
|
4342
4412
|
}) {
|
|
4343
|
-
const { editor: a } =
|
|
4413
|
+
const { editor: a } = yt(n), [h, l] = R(!1), { isVisible: d, canColorHighlight: f, isActive: m, label: u, Icon: y } = Qe({
|
|
4344
4414
|
editor: a,
|
|
4345
4415
|
hideWhenUnavailable: t,
|
|
4346
4416
|
onApplied: s
|
|
4347
4417
|
});
|
|
4348
|
-
return d ? /* @__PURE__ */ k(
|
|
4349
|
-
/* @__PURE__ */ c(
|
|
4350
|
-
|
|
4418
|
+
return d ? /* @__PURE__ */ k(dn, { open: h, onOpenChange: l, children: [
|
|
4419
|
+
/* @__PURE__ */ c(gn, { asChild: !0, children: /* @__PURE__ */ c(
|
|
4420
|
+
yn,
|
|
4351
4421
|
{
|
|
4352
4422
|
disabled: !f,
|
|
4353
|
-
"data-active-state":
|
|
4423
|
+
"data-active-state": m ? "on" : "off",
|
|
4354
4424
|
"data-disabled": !f,
|
|
4355
|
-
"aria-pressed":
|
|
4356
|
-
"aria-label":
|
|
4357
|
-
tooltip:
|
|
4425
|
+
"aria-pressed": m,
|
|
4426
|
+
"aria-label": u,
|
|
4427
|
+
tooltip: u,
|
|
4358
4428
|
...o,
|
|
4359
4429
|
children: /* @__PURE__ */ c(y, { className: "tiptap-button-icon" })
|
|
4360
4430
|
}
|
|
4361
4431
|
) }),
|
|
4362
|
-
/* @__PURE__ */ c(
|
|
4363
|
-
|
|
4432
|
+
/* @__PURE__ */ c(un, { "aria-label": "Highlight colors", children: /* @__PURE__ */ c(
|
|
4433
|
+
co,
|
|
4364
4434
|
{
|
|
4365
4435
|
editor: a,
|
|
4366
4436
|
colors: i,
|
|
@@ -4369,20 +4439,20 @@ function so({
|
|
|
4369
4439
|
) })
|
|
4370
4440
|
] }) : null;
|
|
4371
4441
|
}
|
|
4372
|
-
const
|
|
4442
|
+
const ti = ct(({ 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: [
|
|
4373
4443
|
/* @__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" }),
|
|
4374
4444
|
/* @__PURE__ */ c("circle", { cx: "13.5", cy: "6.5", r: ".5", fill: "currentColor" }),
|
|
4375
4445
|
/* @__PURE__ */ c("circle", { cx: "17.5", cy: "10.5", r: ".5", fill: "currentColor" }),
|
|
4376
4446
|
/* @__PURE__ */ c("circle", { cx: "6.5", cy: "12.5", r: ".5", fill: "currentColor" }),
|
|
4377
4447
|
/* @__PURE__ */ c("circle", { cx: "8.5", cy: "7.5", r: ".5", fill: "currentColor" })
|
|
4378
4448
|
] }));
|
|
4379
|
-
|
|
4380
|
-
function
|
|
4381
|
-
shortcutKeys: n =
|
|
4449
|
+
ti.displayName = "PaletteIcon";
|
|
4450
|
+
function uo({
|
|
4451
|
+
shortcutKeys: n = Ze
|
|
4382
4452
|
}) {
|
|
4383
|
-
return /* @__PURE__ */ c(
|
|
4453
|
+
return /* @__PURE__ */ c(Re, { children: ke({ shortcutKeys: n }) });
|
|
4384
4454
|
}
|
|
4385
|
-
const
|
|
4455
|
+
const vn = $(
|
|
4386
4456
|
({
|
|
4387
4457
|
editor: n,
|
|
4388
4458
|
textColor: i,
|
|
@@ -4395,27 +4465,27 @@ const cn = $(
|
|
|
4395
4465
|
style: l,
|
|
4396
4466
|
useColorValue: d = !1,
|
|
4397
4467
|
...f
|
|
4398
|
-
},
|
|
4399
|
-
const { editor:
|
|
4468
|
+
}, m) => {
|
|
4469
|
+
const { editor: u } = yt(n), {
|
|
4400
4470
|
isVisible: y,
|
|
4401
|
-
canTextColor:
|
|
4471
|
+
canTextColor: w,
|
|
4402
4472
|
isActive: v,
|
|
4403
|
-
handleTextColor:
|
|
4473
|
+
handleTextColor: M,
|
|
4404
4474
|
label: C,
|
|
4405
|
-
shortcutKeys:
|
|
4406
|
-
} =
|
|
4407
|
-
editor:
|
|
4475
|
+
shortcutKeys: B
|
|
4476
|
+
} = ii({
|
|
4477
|
+
editor: u,
|
|
4408
4478
|
textColor: i,
|
|
4409
4479
|
useColorValue: d,
|
|
4410
4480
|
label: t || `Toggle text color (${i})`,
|
|
4411
4481
|
hideWhenUnavailable: e,
|
|
4412
4482
|
onApplied: s
|
|
4413
|
-
}),
|
|
4414
|
-
(
|
|
4415
|
-
a?.(
|
|
4483
|
+
}), dt = J(
|
|
4484
|
+
(q) => {
|
|
4485
|
+
a?.(q), !q.defaultPrevented && (M(), q.preventDefault(), q.stopPropagation());
|
|
4416
4486
|
},
|
|
4417
|
-
[
|
|
4418
|
-
),
|
|
4487
|
+
[M, a]
|
|
4488
|
+
), K = St(
|
|
4419
4489
|
() => ({
|
|
4420
4490
|
...l,
|
|
4421
4491
|
"--text-color": i
|
|
@@ -4423,21 +4493,21 @@ const cn = $(
|
|
|
4423
4493
|
[i, l]
|
|
4424
4494
|
);
|
|
4425
4495
|
return y ? /* @__PURE__ */ k(
|
|
4426
|
-
|
|
4496
|
+
vt,
|
|
4427
4497
|
{
|
|
4428
4498
|
type: "button",
|
|
4429
4499
|
variant: "ghost",
|
|
4430
4500
|
"data-active-state": v ? "on" : "off",
|
|
4431
4501
|
role: "button",
|
|
4432
4502
|
tabIndex: -1,
|
|
4433
|
-
disabled: !
|
|
4434
|
-
"data-disabled": !
|
|
4503
|
+
disabled: !w,
|
|
4504
|
+
"data-disabled": !w,
|
|
4435
4505
|
"aria-label": C,
|
|
4436
4506
|
"aria-pressed": v,
|
|
4437
4507
|
tooltip: C,
|
|
4438
|
-
onClick:
|
|
4439
|
-
ref:
|
|
4440
|
-
style:
|
|
4508
|
+
onClick: dt,
|
|
4509
|
+
ref: m,
|
|
4510
|
+
style: K,
|
|
4441
4511
|
...f,
|
|
4442
4512
|
children: [
|
|
4443
4513
|
h || /* @__PURE__ */ c(
|
|
@@ -4447,14 +4517,14 @@ const cn = $(
|
|
|
4447
4517
|
style: { "--highlight-color": i }
|
|
4448
4518
|
}
|
|
4449
4519
|
),
|
|
4450
|
-
o && /* @__PURE__ */ c(
|
|
4520
|
+
o && /* @__PURE__ */ c(uo, { shortcutKeys: B })
|
|
4451
4521
|
]
|
|
4452
4522
|
}
|
|
4453
4523
|
) : null;
|
|
4454
4524
|
}
|
|
4455
4525
|
);
|
|
4456
|
-
|
|
4457
|
-
const
|
|
4526
|
+
vn.displayName = "TextColorButton";
|
|
4527
|
+
const Ze = "mod+shift+c", Cn = [
|
|
4458
4528
|
{
|
|
4459
4529
|
label: "Black",
|
|
4460
4530
|
value: "var(--tt-color-text-black)",
|
|
@@ -4501,29 +4571,29 @@ const De = "mod+shift+c", dn = [
|
|
|
4501
4571
|
colorValue: "#db2777"
|
|
4502
4572
|
}
|
|
4503
4573
|
];
|
|
4504
|
-
function
|
|
4505
|
-
const i = new Map(
|
|
4574
|
+
function xn(n) {
|
|
4575
|
+
const i = new Map(Cn.map((t) => [t.value, t]));
|
|
4506
4576
|
return n.map((t) => i.get(t)).filter((t) => !!t);
|
|
4507
4577
|
}
|
|
4508
|
-
function
|
|
4509
|
-
return i &&
|
|
4578
|
+
function mo(n, i = !1) {
|
|
4579
|
+
return i && Cn.find(
|
|
4510
4580
|
(e) => e.value === n || e.colorValue === n
|
|
4511
4581
|
)?.colorValue || n;
|
|
4512
4582
|
}
|
|
4513
|
-
function
|
|
4514
|
-
return !n || !n.isEditable || !
|
|
4583
|
+
function ei(n) {
|
|
4584
|
+
return !n || !n.isEditable || !Qt("textStyle", n) || ze(n, ["image"]) ? !1 : n.can().setColor("#000000");
|
|
4515
4585
|
}
|
|
4516
|
-
function
|
|
4586
|
+
function Si(n, i) {
|
|
4517
4587
|
return !n || !n.isEditable ? !1 : i ? n.isActive("textStyle", { color: i }) : !!n.getAttributes("textStyle").color;
|
|
4518
4588
|
}
|
|
4519
|
-
function
|
|
4520
|
-
return !n || !n.isEditable || !
|
|
4589
|
+
function fo(n) {
|
|
4590
|
+
return !n || !n.isEditable || !ei(n) ? !1 : n.chain().focus().unsetColor().run();
|
|
4521
4591
|
}
|
|
4522
|
-
function
|
|
4592
|
+
function po(n) {
|
|
4523
4593
|
const { editor: i, hideWhenUnavailable: t } = n;
|
|
4524
|
-
return !i || !i.isEditable ? !1 : t ?
|
|
4594
|
+
return !i || !i.isEditable ? !1 : t ? ei(i) : !0;
|
|
4525
4595
|
}
|
|
4526
|
-
function
|
|
4596
|
+
function ii({
|
|
4527
4597
|
editor: n,
|
|
4528
4598
|
textColor: i,
|
|
4529
4599
|
label: t = "Text color",
|
|
@@ -4531,56 +4601,56 @@ function je({
|
|
|
4531
4601
|
useColorValue: s = !1,
|
|
4532
4602
|
onApplied: o
|
|
4533
4603
|
} = {}) {
|
|
4534
|
-
const { editor: a } =
|
|
4535
|
-
|
|
4604
|
+
const { editor: a } = yt(n), h = $e(), [l, d] = R(!0), [f, m] = R(!1), u = ei(a);
|
|
4605
|
+
Z(() => {
|
|
4536
4606
|
if (!a) {
|
|
4537
4607
|
d(!1);
|
|
4538
4608
|
return;
|
|
4539
4609
|
}
|
|
4540
|
-
const v =
|
|
4610
|
+
const v = po({ editor: a, hideWhenUnavailable: e });
|
|
4541
4611
|
d(v);
|
|
4542
|
-
}, [a, e]),
|
|
4612
|
+
}, [a, e]), Z(() => {
|
|
4543
4613
|
if (!a) {
|
|
4544
|
-
|
|
4614
|
+
m(!1);
|
|
4545
4615
|
return;
|
|
4546
4616
|
}
|
|
4547
4617
|
const v = () => {
|
|
4548
|
-
|
|
4618
|
+
m(Si(a, i));
|
|
4549
4619
|
};
|
|
4550
4620
|
return a.on("selectionUpdate", v), a.on("transaction", v), v(), () => {
|
|
4551
4621
|
a.off("selectionUpdate", v), a.off("transaction", v);
|
|
4552
4622
|
};
|
|
4553
4623
|
}, [a, i]);
|
|
4554
|
-
const y =
|
|
4555
|
-
if (!a || !
|
|
4556
|
-
const v = i ?
|
|
4557
|
-
|
|
4558
|
-
}, [a, i, s, t,
|
|
4559
|
-
|
|
4624
|
+
const y = J(() => {
|
|
4625
|
+
if (!a || !u) return;
|
|
4626
|
+
const v = i ? mo(i, s) : "#000000";
|
|
4627
|
+
Si(a, v) ? a.chain().focus().unsetColor().run() : (a.chain().focus().setColor(v).run(), o?.({ color: v, label: t }));
|
|
4628
|
+
}, [a, i, s, t, u, o]), w = J(() => {
|
|
4629
|
+
fo(a);
|
|
4560
4630
|
}, [a]);
|
|
4561
|
-
return
|
|
4562
|
-
|
|
4631
|
+
return Ti(
|
|
4632
|
+
Ze,
|
|
4563
4633
|
(v) => {
|
|
4564
4634
|
v.preventDefault(), y();
|
|
4565
4635
|
},
|
|
4566
4636
|
{
|
|
4567
|
-
enabled: !h && l &&
|
|
4637
|
+
enabled: !h && l && u,
|
|
4568
4638
|
enableOnFormTags: ["INPUT", "TEXTAREA", "SELECT"]
|
|
4569
4639
|
},
|
|
4570
|
-
[y, h, l,
|
|
4640
|
+
[y, h, l, u]
|
|
4571
4641
|
), {
|
|
4572
4642
|
isVisible: l,
|
|
4573
|
-
canTextColor:
|
|
4643
|
+
canTextColor: u,
|
|
4574
4644
|
isActive: f,
|
|
4575
4645
|
handleTextColor: y,
|
|
4576
|
-
handleRemoveTextColor:
|
|
4646
|
+
handleRemoveTextColor: w,
|
|
4577
4647
|
label: t,
|
|
4578
|
-
shortcutKeys:
|
|
4579
|
-
Icon:
|
|
4648
|
+
shortcutKeys: Ze,
|
|
4649
|
+
Icon: ti
|
|
4580
4650
|
};
|
|
4581
4651
|
}
|
|
4582
|
-
const
|
|
4583
|
-
|
|
4652
|
+
const wn = $(({ className: n, children: i, ...t }, e) => /* @__PURE__ */ c(
|
|
4653
|
+
vt,
|
|
4584
4654
|
{
|
|
4585
4655
|
type: "button",
|
|
4586
4656
|
className: n,
|
|
@@ -4592,13 +4662,13 @@ const un = $(({ className: n, children: i, ...t }, e) => /* @__PURE__ */ c(
|
|
|
4592
4662
|
tooltip: "Text color",
|
|
4593
4663
|
ref: e,
|
|
4594
4664
|
...t,
|
|
4595
|
-
children: i ?? /* @__PURE__ */ c(
|
|
4665
|
+
children: i ?? /* @__PURE__ */ c(ti, { className: "tiptap-button-icon" })
|
|
4596
4666
|
}
|
|
4597
4667
|
));
|
|
4598
|
-
|
|
4599
|
-
function
|
|
4668
|
+
wn.displayName = "TextColorPopoverButton";
|
|
4669
|
+
function yo({
|
|
4600
4670
|
editor: n,
|
|
4601
|
-
colors: i =
|
|
4671
|
+
colors: i = xn([
|
|
4602
4672
|
"var(--tt-color-text-black)",
|
|
4603
4673
|
"var(--tt-color-text-red)",
|
|
4604
4674
|
"var(--tt-color-text-blue)",
|
|
@@ -4608,10 +4678,10 @@ function ho({
|
|
|
4608
4678
|
]),
|
|
4609
4679
|
useColorValue: t = !1
|
|
4610
4680
|
}) {
|
|
4611
|
-
const { handleRemoveTextColor: e } =
|
|
4681
|
+
const { handleRemoveTextColor: e } = ii({ editor: n }), s = $e(), o = Ue(null), a = St(
|
|
4612
4682
|
() => [...i, { label: "Remove color", value: "none" }],
|
|
4613
4683
|
[i]
|
|
4614
|
-
), { selectedIndex: h } =
|
|
4684
|
+
), { selectedIndex: h } = cn({
|
|
4615
4685
|
containerRef: o,
|
|
4616
4686
|
items: a,
|
|
4617
4687
|
orientation: "both",
|
|
@@ -4625,14 +4695,14 @@ function ho({
|
|
|
4625
4695
|
autoSelectFirstItem: !1
|
|
4626
4696
|
});
|
|
4627
4697
|
return /* @__PURE__ */ c(
|
|
4628
|
-
|
|
4698
|
+
Ke,
|
|
4629
4699
|
{
|
|
4630
4700
|
ref: o,
|
|
4631
4701
|
tabIndex: 0,
|
|
4632
4702
|
style: s ? { boxShadow: "none", border: 0 } : {},
|
|
4633
|
-
children: /* @__PURE__ */ c(
|
|
4634
|
-
/* @__PURE__ */ c(
|
|
4635
|
-
|
|
4703
|
+
children: /* @__PURE__ */ c(qe, { style: s ? { padding: 0 } : {}, children: /* @__PURE__ */ k(je, { orientation: "horizontal", children: [
|
|
4704
|
+
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: i.map((l, d) => /* @__PURE__ */ c(
|
|
4705
|
+
vn,
|
|
4636
4706
|
{
|
|
4637
4707
|
editor: n,
|
|
4638
4708
|
textColor: t ? l.colorValue : l.value,
|
|
@@ -4644,9 +4714,9 @@ function ho({
|
|
|
4644
4714
|
},
|
|
4645
4715
|
l.value
|
|
4646
4716
|
)) }),
|
|
4647
|
-
/* @__PURE__ */ c(
|
|
4648
|
-
/* @__PURE__ */ c(
|
|
4649
|
-
|
|
4717
|
+
/* @__PURE__ */ c(Ge, {}),
|
|
4718
|
+
/* @__PURE__ */ c(Ht, { orientation: "horizontal", children: /* @__PURE__ */ c(
|
|
4719
|
+
vt,
|
|
4650
4720
|
{
|
|
4651
4721
|
onClick: e,
|
|
4652
4722
|
"aria-label": "Remove text color",
|
|
@@ -4656,16 +4726,16 @@ function ho({
|
|
|
4656
4726
|
role: "menuitem",
|
|
4657
4727
|
variant: "ghost",
|
|
4658
4728
|
"data-highlighted": h === i.length,
|
|
4659
|
-
children: /* @__PURE__ */ c(
|
|
4729
|
+
children: /* @__PURE__ */ c(Xe, { className: "tiptap-button-icon" })
|
|
4660
4730
|
}
|
|
4661
4731
|
) })
|
|
4662
4732
|
] }) })
|
|
4663
4733
|
}
|
|
4664
4734
|
);
|
|
4665
4735
|
}
|
|
4666
|
-
function
|
|
4736
|
+
function vo({
|
|
4667
4737
|
editor: n,
|
|
4668
|
-
colors: i =
|
|
4738
|
+
colors: i = xn([
|
|
4669
4739
|
"var(--tt-color-text-red)",
|
|
4670
4740
|
"var(--tt-color-text-blue)",
|
|
4671
4741
|
"var(--tt-color-text-green)",
|
|
@@ -4677,27 +4747,27 @@ function co({
|
|
|
4677
4747
|
onApplied: s,
|
|
4678
4748
|
...o
|
|
4679
4749
|
}) {
|
|
4680
|
-
const { editor: a } =
|
|
4750
|
+
const { editor: a } = yt(n), [h, l] = R(!1), { isVisible: d, canTextColor: f, isActive: m, label: u, Icon: y } = ii({
|
|
4681
4751
|
editor: a,
|
|
4682
4752
|
hideWhenUnavailable: t,
|
|
4683
4753
|
onApplied: s
|
|
4684
4754
|
});
|
|
4685
|
-
return d ? /* @__PURE__ */ k(
|
|
4686
|
-
/* @__PURE__ */ c(
|
|
4687
|
-
|
|
4755
|
+
return d ? /* @__PURE__ */ k(dn, { open: h, onOpenChange: l, children: [
|
|
4756
|
+
/* @__PURE__ */ c(gn, { asChild: !0, children: /* @__PURE__ */ c(
|
|
4757
|
+
wn,
|
|
4688
4758
|
{
|
|
4689
4759
|
disabled: !f,
|
|
4690
|
-
"data-active-state":
|
|
4760
|
+
"data-active-state": m ? "on" : "off",
|
|
4691
4761
|
"data-disabled": !f,
|
|
4692
|
-
"aria-pressed":
|
|
4693
|
-
"aria-label":
|
|
4694
|
-
tooltip:
|
|
4762
|
+
"aria-pressed": m,
|
|
4763
|
+
"aria-label": u,
|
|
4764
|
+
tooltip: u,
|
|
4695
4765
|
...o,
|
|
4696
4766
|
children: /* @__PURE__ */ c(y, { className: "tiptap-button-icon" })
|
|
4697
4767
|
}
|
|
4698
4768
|
) }),
|
|
4699
|
-
/* @__PURE__ */ c(
|
|
4700
|
-
|
|
4769
|
+
/* @__PURE__ */ c(un, { "aria-label": "Text colors", children: /* @__PURE__ */ c(
|
|
4770
|
+
yo,
|
|
4701
4771
|
{
|
|
4702
4772
|
editor: a,
|
|
4703
4773
|
colors: i,
|
|
@@ -4706,7 +4776,7 @@ function co({
|
|
|
4706
4776
|
) })
|
|
4707
4777
|
] }) : null;
|
|
4708
4778
|
}
|
|
4709
|
-
const
|
|
4779
|
+
const Co = [
|
|
4710
4780
|
{ label: "宋体", value: "SimSun, STSong" },
|
|
4711
4781
|
{ label: "楷体", value: "KaiTi, STKaiti" },
|
|
4712
4782
|
{ label: "Inter", value: "Inter, sans-serif" },
|
|
@@ -4716,17 +4786,17 @@ const go = [
|
|
|
4716
4786
|
{ label: "Cursive", value: "cursive" },
|
|
4717
4787
|
{ label: "Default", value: "" }
|
|
4718
4788
|
];
|
|
4719
|
-
function
|
|
4789
|
+
function xo({
|
|
4720
4790
|
editor: n,
|
|
4721
|
-
fonts: i =
|
|
4791
|
+
fonts: i = Co
|
|
4722
4792
|
}) {
|
|
4723
4793
|
const [t, e] = R(
|
|
4724
4794
|
void 0
|
|
4725
|
-
), s =
|
|
4795
|
+
), s = J(() => n ? n.can().setFontFamily("") : !1, [n]), o = J(
|
|
4726
4796
|
(l) => n ? l ? n.isActive("textStyle", { fontFamily: l }) : !n.isActive("textStyle", { fontFamily: /.+/ }) : !1,
|
|
4727
4797
|
[n]
|
|
4728
4798
|
);
|
|
4729
|
-
|
|
4799
|
+
Z(() => {
|
|
4730
4800
|
if (!n) {
|
|
4731
4801
|
e(void 0);
|
|
4732
4802
|
return;
|
|
@@ -4739,12 +4809,12 @@ function uo({
|
|
|
4739
4809
|
n.off("selectionUpdate", l), n.off("transaction", l);
|
|
4740
4810
|
};
|
|
4741
4811
|
}, [n]);
|
|
4742
|
-
const a =
|
|
4812
|
+
const a = J(
|
|
4743
4813
|
(l) => {
|
|
4744
4814
|
n && (l ? n.chain().focus().setFontFamily(l).run() : n.chain().focus().unsetFontFamily().run());
|
|
4745
4815
|
},
|
|
4746
4816
|
[n]
|
|
4747
|
-
), h =
|
|
4817
|
+
), h = J(() => {
|
|
4748
4818
|
n && n.chain().focus().unsetFontFamily().run();
|
|
4749
4819
|
}, [n]);
|
|
4750
4820
|
return {
|
|
@@ -4756,13 +4826,13 @@ function uo({
|
|
|
4756
4826
|
isFontFamilyActive: o
|
|
4757
4827
|
};
|
|
4758
4828
|
}
|
|
4759
|
-
const
|
|
4829
|
+
const bn = $(({ editor: n, fonts: i }, t) => {
|
|
4760
4830
|
const {
|
|
4761
4831
|
fonts: e,
|
|
4762
4832
|
activeFontFamily: s,
|
|
4763
4833
|
setFontFamily: o,
|
|
4764
4834
|
canSetFontFamily: a
|
|
4765
|
-
} =
|
|
4835
|
+
} = xo({
|
|
4766
4836
|
editor: n,
|
|
4767
4837
|
fonts: i
|
|
4768
4838
|
});
|
|
@@ -4785,10 +4855,10 @@ const mn = $(({ editor: n, fonts: i }, t) => {
|
|
|
4785
4855
|
}
|
|
4786
4856
|
);
|
|
4787
4857
|
});
|
|
4788
|
-
|
|
4789
|
-
function
|
|
4858
|
+
bn.displayName = "FontFamilySelect";
|
|
4859
|
+
function Go({ api: n }) {
|
|
4790
4860
|
const [i, t] = R(null), [e, s] = R(1), [o, a] = R(1);
|
|
4791
|
-
return
|
|
4861
|
+
return Z(() => {
|
|
4792
4862
|
if (!n) return;
|
|
4793
4863
|
const h = (f) => {
|
|
4794
4864
|
t(f), s(n.getState().viewport.scale), a(f.scaleWhenCreate || 1);
|
|
@@ -4800,28 +4870,28 @@ function Po({ api: n }) {
|
|
|
4800
4870
|
return n.on("texteditor:register", h), n.on("texteditor:unregister", l), n.on("viewport:scale:change", d), () => {
|
|
4801
4871
|
n.off("texteditor:register", h), n.off("texteditor:unregister", l), n.off("viewport:scale:change", d);
|
|
4802
4872
|
};
|
|
4803
|
-
}, [n]), !n || !i ? null : /* @__PURE__ */ c(
|
|
4873
|
+
}, [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: {
|
|
4804
4874
|
transformOrigin: "bottom center",
|
|
4805
4875
|
transform: `scale(${o / e})`
|
|
4806
4876
|
}, options: {
|
|
4807
4877
|
shift: !1
|
|
4808
4878
|
}, children: [
|
|
4809
|
-
/* @__PURE__ */ c(
|
|
4810
|
-
/* @__PURE__ */ c(
|
|
4811
|
-
/* @__PURE__ */ c(
|
|
4812
|
-
/* @__PURE__ */ c(
|
|
4813
|
-
/* @__PURE__ */ c(
|
|
4814
|
-
/* @__PURE__ */ c(
|
|
4815
|
-
/* @__PURE__ */ c(
|
|
4879
|
+
/* @__PURE__ */ c(bn, { editor: i }),
|
|
4880
|
+
/* @__PURE__ */ c(At, { type: "bold", editor: i }),
|
|
4881
|
+
/* @__PURE__ */ c(At, { type: "italic", editor: i }),
|
|
4882
|
+
/* @__PURE__ */ c(At, { type: "strike", editor: i }),
|
|
4883
|
+
/* @__PURE__ */ c(At, { type: "underline", editor: i }),
|
|
4884
|
+
/* @__PURE__ */ c(go, { editor: i }),
|
|
4885
|
+
/* @__PURE__ */ c(vo, { editor: i })
|
|
4816
4886
|
] }) });
|
|
4817
4887
|
}
|
|
4818
4888
|
export {
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4889
|
+
Ds as CanvasApi,
|
|
4890
|
+
vs as DARK_THEME,
|
|
4891
|
+
Ii as DEFAULT_THEME,
|
|
4822
4892
|
b as NODE_NAMES,
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4893
|
+
Wo as THEME_PRESETS,
|
|
4894
|
+
Go as TipTapBubbleMenu,
|
|
4895
|
+
Xo as Whiteboard,
|
|
4896
|
+
Yo as useContextMenu
|
|
4827
4897
|
};
|