@xiangfa/mindmap 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +74 -6
- package/README.zh-CN.md +74 -6
- package/dist/components/MindMapAIInput.d.ts +13 -0
- package/dist/components/icons.d.ts +4 -0
- package/dist/esm/MindMap2.js +289 -275
- package/dist/esm/components/MindMapAIInput.js +209 -0
- package/dist/esm/components/icons.js +78 -1
- package/dist/esm/hooks/useNodeEdit.js +1 -1
- package/dist/esm/hooks/usePanZoom.js +3 -1
- package/dist/esm/plugins/tags.js +8 -8
- package/dist/esm/style.css +1 -1
- package/dist/esm/utils/i18n.js +6 -0
- package/dist/esm/utils/markdown.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/mindmap.umd.cjs +76 -14
- package/dist/plugins/tags.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/utils/i18n.d.ts +3 -0
- package/package.json +2 -1
- package/dist/esm/logo.svg +0 -9
- package/dist/logo.svg +0 -9
package/dist/esm/MindMap2.js
CHANGED
|
@@ -12,16 +12,17 @@ import { useNewNodeAnimation as pe } from "./hooks/useNewNodeAnimation.js";
|
|
|
12
12
|
import { MindMapNode as me } from "./components/MindMapNode.js";
|
|
13
13
|
import { MindMapControls as he } from "./components/MindMapControls.js";
|
|
14
14
|
import { MindMapContextMenu as ge } from "./components/MindMapContextMenu.js";
|
|
15
|
+
import { MindMapAIInput as _e } from "./components/MindMapAIInput.js";
|
|
15
16
|
/* empty css */
|
|
16
|
-
import { forwardRef as l, useCallback as u, useEffect as d, useImperativeHandle as
|
|
17
|
-
import { Fragment as
|
|
17
|
+
import { forwardRef as l, useCallback as u, useEffect as d, useImperativeHandle as ve, useMemo as f, useRef as p, useState as m } from "react";
|
|
18
|
+
import { Fragment as ye, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
18
19
|
//#region src/components/MindMap/MindMap.tsx
|
|
19
|
-
function
|
|
20
|
+
function be(e, t) {
|
|
20
21
|
let n = URL.createObjectURL(e), r = document.createElement("a");
|
|
21
22
|
r.href = n, r.download = t, document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(n);
|
|
22
23
|
}
|
|
23
|
-
var _ = l(function({ data: l, markdown: _, defaultDirection:
|
|
24
|
-
let
|
|
24
|
+
var _ = l(function({ data: l, markdown: _, defaultDirection: xe = "both", theme: Se = "auto", locale: Ce, messages: we, readonly: v = !1, toolbar: y = !0, ai: Te, onDataChange: Ee, onEvent: De, plugins: Oe }, ke) {
|
|
25
|
+
let Ae = p(null), b = p(null), x = Oe && Oe.length > 0 ? Oe : void 0, S = f(() => {
|
|
25
26
|
if (l || _ === void 0) return null;
|
|
26
27
|
if (x) {
|
|
27
28
|
let e = s(_, x), t = e.frontMatter.direction, n = e.frontMatter.theme;
|
|
@@ -36,307 +37,307 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
36
37
|
direction: void 0,
|
|
37
38
|
theme: void 0
|
|
38
39
|
};
|
|
39
|
-
}, []), [
|
|
40
|
+
}, []), [C, w] = m(() => l ? oe(l) : S ? S.roots : [{
|
|
40
41
|
id: "md-0",
|
|
41
42
|
text: "Root"
|
|
42
|
-
}]), [
|
|
43
|
+
}]), [T, je] = m(() => S?.direction ?? xe), [E, D] = m({}), [O, k] = m(null), [A, Me] = m(null), [j, Ne] = m({}), M = p(null), [Pe, Fe] = m("view"), [Ie, Le] = m(!1), [N, P] = m(""), [Re, ze] = m(null), [Be, Ve] = m({}), [He, Ue] = m(null), [We, Ge] = m(() => S?.theme);
|
|
43
44
|
d(() => {
|
|
44
|
-
l &&
|
|
45
|
+
l && w(oe(l));
|
|
45
46
|
}, [l]), d(() => {
|
|
46
47
|
if (_ !== void 0) if (x) {
|
|
47
48
|
let { roots: e, frontMatter: t } = s(_, x);
|
|
48
|
-
if (
|
|
49
|
+
if (w(e), t.direction) {
|
|
49
50
|
let e = t.direction;
|
|
50
|
-
(e === "left" || e === "right" || e === "both") &&
|
|
51
|
+
(e === "left" || e === "right" || e === "both") && je(e);
|
|
51
52
|
}
|
|
52
53
|
if (t.theme) {
|
|
53
54
|
let e = t.theme;
|
|
54
|
-
(e === "light" || e === "dark" || e === "auto") &&
|
|
55
|
+
(e === "light" || e === "dark" || e === "auto") && Ge(e);
|
|
55
56
|
}
|
|
56
|
-
} else
|
|
57
|
+
} else w(o(_));
|
|
57
58
|
}, [_, x]);
|
|
58
|
-
let
|
|
59
|
-
|
|
59
|
+
let F = u((e) => {
|
|
60
|
+
w((t) => {
|
|
60
61
|
let n = e(t);
|
|
61
|
-
return
|
|
62
|
+
return Ee?.(n), n;
|
|
62
63
|
});
|
|
63
|
-
}, [
|
|
64
|
-
|
|
65
|
-
let
|
|
66
|
-
|
|
67
|
-
}, []),
|
|
68
|
-
|
|
69
|
-
w,
|
|
70
|
-
Me,
|
|
64
|
+
}, [Ee]), Ke = p(De);
|
|
65
|
+
Ke.current = De;
|
|
66
|
+
let I = u((e) => {
|
|
67
|
+
Ke.current?.(e);
|
|
68
|
+
}, []), L = le(We ?? Se), R = f(() => te(Ce ?? ee(), we), [Ce, we]), qe = f(() => y === !1 ? { zoom: !1 } : y === !0 || y === void 0 ? { zoom: !0 } : { zoom: y.zoom ?? !0 }, [y]), { nodes: z, edges: B } = f(() => n(C, T, j, E, x, v, Be), [
|
|
69
|
+
C,
|
|
71
70
|
T,
|
|
71
|
+
j,
|
|
72
|
+
E,
|
|
72
73
|
x,
|
|
73
74
|
v,
|
|
74
|
-
|
|
75
|
+
Be
|
|
75
76
|
]);
|
|
76
77
|
d(() => {
|
|
77
78
|
let e = {}, t = !1;
|
|
78
|
-
for (let n of
|
|
79
|
+
for (let n of z) n.depth === 1 && !j[n.id] && (e[n.id] = n.color, t = !0);
|
|
79
80
|
t && Ne((t) => ({
|
|
80
81
|
...t,
|
|
81
82
|
...e
|
|
82
83
|
}));
|
|
83
|
-
}, [
|
|
84
|
-
let
|
|
84
|
+
}, [z, j]);
|
|
85
|
+
let V = f(() => {
|
|
85
86
|
let e = {};
|
|
86
|
-
for (let t of
|
|
87
|
+
for (let t of z) e[t.id] = t;
|
|
87
88
|
return e;
|
|
88
|
-
}, [
|
|
89
|
-
if (!
|
|
89
|
+
}, [z]), Je = f(() => {
|
|
90
|
+
if (!He) return {};
|
|
90
91
|
let e = {}, t = [];
|
|
91
|
-
for (let e of
|
|
92
|
+
for (let e of z) e.parentId === He && t.push({
|
|
92
93
|
id: e.id,
|
|
93
94
|
depth: 1
|
|
94
95
|
});
|
|
95
96
|
for (; t.length > 0;) {
|
|
96
97
|
let { id: n, depth: r } = t.shift();
|
|
97
98
|
e[n] = r * 100;
|
|
98
|
-
for (let e of
|
|
99
|
+
for (let e of z) e.parentId === n && t.push({
|
|
99
100
|
id: e.id,
|
|
100
101
|
depth: r + 1
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
104
|
return e;
|
|
104
|
-
}, [
|
|
105
|
+
}, [He, z]), { pan: H, setPan: Ye, zoom: U, setZoom: Xe, animateTo: Ze, autoFit: Qe, zoomIn: $e, zoomOut: et, contentCenter: tt, panToNode: nt } = ue(b, z), { draggingCanvas: rt, floatingNodeId: W, floatingPos: G, floatingSubtreeIds: K, didDragRef: it, handleCanvasMouseDown: at, handleMouseMove: ot, handleMouseUp: st, handleNodeMouseDown: ct } = de({
|
|
105
106
|
svgRef: b,
|
|
106
|
-
zoom:
|
|
107
|
-
pan:
|
|
108
|
-
setPan:
|
|
109
|
-
setZoom:
|
|
110
|
-
nodeMap:
|
|
111
|
-
nodes:
|
|
112
|
-
updateData:
|
|
113
|
-
direction:
|
|
114
|
-
splitIndices:
|
|
115
|
-
setSplitIndices:
|
|
116
|
-
mapData:
|
|
117
|
-
contentCenter:
|
|
118
|
-
}), { editingId:
|
|
119
|
-
nodeMap:
|
|
120
|
-
updateData:
|
|
107
|
+
zoom: U,
|
|
108
|
+
pan: H,
|
|
109
|
+
setPan: Ye,
|
|
110
|
+
setZoom: Xe,
|
|
111
|
+
nodeMap: V,
|
|
112
|
+
nodes: z,
|
|
113
|
+
updateData: F,
|
|
114
|
+
direction: T,
|
|
115
|
+
splitIndices: E,
|
|
116
|
+
setSplitIndices: D,
|
|
117
|
+
mapData: C,
|
|
118
|
+
contentCenter: tt
|
|
119
|
+
}), { editingId: lt, editText: ut, setEditText: q, pendingEditId: J, setPendingEditId: Y, handleNodeDoubleClick: dt, commitEdit: ft, cancelEdit: pt } = fe({
|
|
120
|
+
nodeMap: V,
|
|
121
|
+
updateData: F,
|
|
121
122
|
onTextChange: (e, t, n) => {
|
|
122
|
-
|
|
123
|
+
I({
|
|
123
124
|
type: "nodeTextChange",
|
|
124
125
|
nodeId: e,
|
|
125
126
|
oldText: t,
|
|
126
127
|
newText: n
|
|
127
128
|
});
|
|
128
129
|
}
|
|
129
|
-
}),
|
|
130
|
+
}), mt = pe(z), [X, ht] = m(!1);
|
|
130
131
|
d(() => {
|
|
131
|
-
if (
|
|
132
|
-
let e =
|
|
133
|
-
e ? X ? (
|
|
132
|
+
if (W || J) return;
|
|
133
|
+
let e = Qe();
|
|
134
|
+
e ? X ? (Xe(e.zoom), Ye({
|
|
134
135
|
x: e.panX,
|
|
135
136
|
y: e.panY
|
|
136
|
-
})) : (
|
|
137
|
+
})) : (Xe(e.zoom * .92), Ye({
|
|
137
138
|
x: e.panX,
|
|
138
139
|
y: e.panY
|
|
139
140
|
}), requestAnimationFrame(() => {
|
|
140
|
-
|
|
141
|
-
})) : X || requestAnimationFrame(() =>
|
|
141
|
+
ht(!0), Ze(e.zoom, e.panX, e.panY);
|
|
142
|
+
})) : X || requestAnimationFrame(() => ht(!0));
|
|
142
143
|
}, [
|
|
143
|
-
F,
|
|
144
|
-
Ze,
|
|
145
|
-
U,
|
|
146
|
-
J,
|
|
147
|
-
V,
|
|
148
144
|
z,
|
|
145
|
+
Qe,
|
|
146
|
+
W,
|
|
147
|
+
J,
|
|
148
|
+
Xe,
|
|
149
|
+
Ye,
|
|
149
150
|
X,
|
|
150
|
-
|
|
151
|
+
Ze
|
|
151
152
|
]), d(() => {
|
|
152
|
-
J &&
|
|
153
|
+
J && V[J] && nt(J);
|
|
153
154
|
}, [
|
|
154
155
|
J,
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
V,
|
|
157
|
+
nt
|
|
157
158
|
]);
|
|
158
|
-
let
|
|
159
|
-
|
|
160
|
-
}, [
|
|
161
|
-
e.stopPropagation(),
|
|
159
|
+
let gt = u((e) => {
|
|
160
|
+
Me(null), at(e);
|
|
161
|
+
}, [at]), _t = u((e, t) => {
|
|
162
|
+
e.stopPropagation(), it.current || (k(t), I({
|
|
162
163
|
type: "nodeSelect",
|
|
163
164
|
nodeId: t
|
|
164
165
|
}));
|
|
165
|
-
}, [
|
|
166
|
-
|
|
166
|
+
}, [it, I]), vt = u(() => {
|
|
167
|
+
it.current || (k(null), I({
|
|
167
168
|
type: "nodeSelect",
|
|
168
169
|
nodeId: null
|
|
169
170
|
}));
|
|
170
|
-
}, [
|
|
171
|
+
}, [it, I]), yt = u((e) => {
|
|
171
172
|
e.preventDefault(), e.stopPropagation();
|
|
172
|
-
let t =
|
|
173
|
+
let t = Ae.current;
|
|
173
174
|
if (!t) return;
|
|
174
175
|
let n = t.getBoundingClientRect();
|
|
175
|
-
|
|
176
|
+
Me({
|
|
176
177
|
x: e.clientX - n.left,
|
|
177
178
|
y: e.clientY - n.top
|
|
178
179
|
});
|
|
179
180
|
}, []), Z = u(() => {
|
|
180
|
-
|
|
181
|
-
}, []),
|
|
181
|
+
Me(null);
|
|
182
|
+
}, []), bt = u((e) => {
|
|
182
183
|
if (!e) {
|
|
183
|
-
|
|
184
|
+
ze(null);
|
|
184
185
|
return;
|
|
185
186
|
}
|
|
186
|
-
let t =
|
|
187
|
+
let t = V[e];
|
|
187
188
|
if (!t || !t.remark) {
|
|
188
|
-
|
|
189
|
+
ze(null);
|
|
189
190
|
return;
|
|
190
191
|
}
|
|
191
192
|
let n = b.current;
|
|
192
193
|
if (!n) return;
|
|
193
|
-
let r = n.getBoundingClientRect(), i = (t.x + t.width / 2) *
|
|
194
|
-
|
|
194
|
+
let r = n.getBoundingClientRect(), i = (t.x + t.width / 2) * U + H.x, a = (t.y - t.height / 2) * U + H.y;
|
|
195
|
+
ze({
|
|
195
196
|
nodeId: e,
|
|
196
197
|
text: t.remark,
|
|
197
198
|
x: Math.min(i, r.width - 300),
|
|
198
199
|
y: a - 8
|
|
199
200
|
});
|
|
200
201
|
}, [
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
]),
|
|
202
|
+
V,
|
|
203
|
+
U,
|
|
204
|
+
H
|
|
205
|
+
]), xt = u((e, t, n) => {
|
|
205
206
|
if (e.stopPropagation(), v) return;
|
|
206
207
|
let r = ae(), i = {
|
|
207
208
|
id: r,
|
|
208
|
-
text:
|
|
209
|
+
text: R.newNode
|
|
209
210
|
};
|
|
210
|
-
|
|
211
|
+
C.some((e) => e.id === t) && n && T === "both" ? F((e) => e.map((e) => {
|
|
211
212
|
if (e.id !== t) return e;
|
|
212
|
-
let r = e.children || [], a =
|
|
213
|
+
let r = e.children || [], a = E[t] ?? Math.ceil(r.length / 2), o = a, s = r.length - a, c = n;
|
|
213
214
|
n === "right" && o >= 3 * Math.max(s, 1) ? c = "left" : n === "left" && s >= 3 * Math.max(o, 1) && (c = "right");
|
|
214
215
|
let ee = re(e, i, c, a);
|
|
215
|
-
return
|
|
216
|
+
return D((e) => ({
|
|
216
217
|
...e,
|
|
217
218
|
[t]: ee.newSplitIndex
|
|
218
219
|
})), ee.data;
|
|
219
|
-
})) :
|
|
220
|
+
})) : F((e) => ne(e, t, i)), I({
|
|
220
221
|
type: "nodeAdd",
|
|
221
222
|
node: i,
|
|
222
223
|
parentId: t
|
|
223
224
|
}), Y(r), q("");
|
|
224
225
|
}, [
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
w,
|
|
226
|
+
F,
|
|
227
|
+
C,
|
|
228
228
|
T,
|
|
229
|
+
E,
|
|
229
230
|
Y,
|
|
230
231
|
q,
|
|
231
|
-
|
|
232
|
+
R,
|
|
232
233
|
v,
|
|
233
|
-
|
|
234
|
-
]),
|
|
234
|
+
I
|
|
235
|
+
]), St = u(() => {
|
|
235
236
|
if (v) return;
|
|
236
237
|
let e = ae(), t = {
|
|
237
238
|
id: e,
|
|
238
|
-
text:
|
|
239
|
+
text: R.newNode
|
|
239
240
|
};
|
|
240
|
-
|
|
241
|
+
F((e) => [...e, t]), I({
|
|
241
242
|
type: "nodeAdd",
|
|
242
243
|
node: t,
|
|
243
244
|
parentId: null
|
|
244
245
|
}), Y(e), q(""), Z();
|
|
245
246
|
}, [
|
|
246
|
-
|
|
247
|
+
F,
|
|
247
248
|
Z,
|
|
248
249
|
Y,
|
|
249
250
|
q,
|
|
250
|
-
|
|
251
|
+
R,
|
|
251
252
|
v,
|
|
252
|
-
|
|
253
|
-
]),
|
|
254
|
-
let e = r(
|
|
255
|
-
|
|
253
|
+
I
|
|
254
|
+
]), Ct = u(() => {
|
|
255
|
+
let e = r(z, B, {}, L, x);
|
|
256
|
+
be(new Blob([e], { type: "image/svg+xml;charset=utf-8" }), "mindmap.svg"), Z();
|
|
256
257
|
}, [
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
z,
|
|
259
|
+
B,
|
|
260
|
+
L,
|
|
260
261
|
Z,
|
|
261
262
|
x
|
|
262
|
-
]),
|
|
263
|
-
|
|
263
|
+
]), wt = u(async () => {
|
|
264
|
+
be(await a(i(z, B, { pngSafe: !0 }, L, x)), "mindmap.png"), Z();
|
|
264
265
|
}, [
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
z,
|
|
267
|
+
B,
|
|
268
|
+
L,
|
|
268
269
|
Z,
|
|
269
270
|
x
|
|
270
|
-
]),
|
|
271
|
-
let e = c(
|
|
272
|
-
|
|
271
|
+
]), Tt = u(() => {
|
|
272
|
+
let e = c(C, x);
|
|
273
|
+
be(new Blob([e], { type: "text/markdown;charset=utf-8" }), "mindmap.md"), Z();
|
|
273
274
|
}, [
|
|
274
|
-
|
|
275
|
+
C,
|
|
275
276
|
Z,
|
|
276
277
|
x
|
|
277
278
|
]), Q = u(() => {
|
|
278
|
-
let e =
|
|
279
|
-
e &&
|
|
280
|
-
}, [
|
|
281
|
-
|
|
279
|
+
let e = Qe();
|
|
280
|
+
e && Ze(e.zoom, e.panX, e.panY);
|
|
281
|
+
}, [Qe, Ze]), $ = u((e) => {
|
|
282
|
+
je(e), D({}), I({
|
|
282
283
|
type: "directionChange",
|
|
283
284
|
direction: e
|
|
284
285
|
});
|
|
285
|
-
}, [
|
|
286
|
-
|
|
287
|
-
if (e === "view") return
|
|
286
|
+
}, [I]), Et = u(() => {
|
|
287
|
+
Fe((e) => {
|
|
288
|
+
if (e === "view") return P(c(C, x)), I({
|
|
288
289
|
type: "modeChange",
|
|
289
290
|
mode: "text"
|
|
290
291
|
}), "text";
|
|
291
292
|
{
|
|
292
|
-
let e = x ? s(
|
|
293
|
-
return
|
|
293
|
+
let e = x ? s(N, x).roots : o(N);
|
|
294
|
+
return F(() => e), D({}), I({
|
|
294
295
|
type: "modeChange",
|
|
295
296
|
mode: "view"
|
|
296
297
|
}), "view";
|
|
297
298
|
}
|
|
298
299
|
});
|
|
299
300
|
}, [
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
301
|
+
C,
|
|
302
|
+
N,
|
|
303
|
+
F,
|
|
303
304
|
x,
|
|
304
|
-
|
|
305
|
-
]),
|
|
306
|
-
let e =
|
|
305
|
+
I
|
|
306
|
+
]), Dt = u(() => {
|
|
307
|
+
let e = Ae.current;
|
|
307
308
|
e && (document.fullscreenElement ? document.exitFullscreen() : e.requestFullscreen());
|
|
308
309
|
}, []);
|
|
309
310
|
d(() => {
|
|
310
311
|
let e = () => {
|
|
311
312
|
let e = !!document.fullscreenElement;
|
|
312
|
-
|
|
313
|
+
Le(e), I({
|
|
313
314
|
type: "fullscreenChange",
|
|
314
315
|
fullscreen: e
|
|
315
316
|
});
|
|
316
317
|
};
|
|
317
318
|
return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
|
|
318
|
-
}, [
|
|
319
|
-
let
|
|
319
|
+
}, [I]);
|
|
320
|
+
let Ot = p(U);
|
|
320
321
|
d(() => {
|
|
321
|
-
|
|
322
|
+
U !== Ot.current && (Ot.current = U, I({
|
|
322
323
|
type: "zoomChange",
|
|
323
|
-
zoom:
|
|
324
|
+
zoom: U
|
|
324
325
|
}));
|
|
325
|
-
}, [
|
|
326
|
-
let
|
|
327
|
-
if (e.key === "Escape" &&
|
|
326
|
+
}, [U, I]);
|
|
327
|
+
let kt = u((e) => {
|
|
328
|
+
if (e.key === "Escape" && A) {
|
|
328
329
|
e.preventDefault(), Z();
|
|
329
330
|
return;
|
|
330
331
|
}
|
|
331
|
-
if (
|
|
332
|
+
if (lt) return;
|
|
332
333
|
let t = e.metaKey || e.ctrlKey;
|
|
333
334
|
if (e.shiftKey && !t) {
|
|
334
335
|
if (e.code === "Equal") {
|
|
335
|
-
e.preventDefault(),
|
|
336
|
+
e.preventDefault(), $e();
|
|
336
337
|
return;
|
|
337
338
|
}
|
|
338
339
|
if (e.code === "Minus") {
|
|
339
|
-
e.preventDefault(),
|
|
340
|
+
e.preventDefault(), et();
|
|
340
341
|
return;
|
|
341
342
|
}
|
|
342
343
|
if (e.code === "Digit0") {
|
|
@@ -356,93 +357,93 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
356
357
|
return;
|
|
357
358
|
}
|
|
358
359
|
}
|
|
359
|
-
if (e.key === "Enter" && !t &&
|
|
360
|
+
if (e.key === "Enter" && !t && O && !v) {
|
|
360
361
|
e.preventDefault();
|
|
361
362
|
let t = ae(), n = {
|
|
362
363
|
id: t,
|
|
363
|
-
text:
|
|
364
|
+
text: R.newNode
|
|
364
365
|
};
|
|
365
|
-
|
|
366
|
-
if (e.id !==
|
|
367
|
-
let t = e.children || [], r = re(e, n, "right",
|
|
368
|
-
return
|
|
366
|
+
C.some((e) => e.id === O) && T === "both" ? F((e) => e.map((e) => {
|
|
367
|
+
if (e.id !== O) return e;
|
|
368
|
+
let t = e.children || [], r = re(e, n, "right", E[O] ?? Math.ceil(t.length / 2));
|
|
369
|
+
return D((e) => ({
|
|
369
370
|
...e,
|
|
370
|
-
[
|
|
371
|
+
[O]: r.newSplitIndex
|
|
371
372
|
})), r.data;
|
|
372
|
-
})) :
|
|
373
|
+
})) : F((e) => ne(e, O, n)), Y(t), q(""), I({
|
|
373
374
|
type: "nodeAdd",
|
|
374
375
|
node: n,
|
|
375
|
-
parentId:
|
|
376
|
+
parentId: O
|
|
376
377
|
});
|
|
377
378
|
return;
|
|
378
379
|
}
|
|
379
|
-
if ((e.key === "Delete" || e.key === "Backspace") &&
|
|
380
|
-
if (e.preventDefault(),
|
|
381
|
-
|
|
380
|
+
if ((e.key === "Delete" || e.key === "Backspace") && O && !v) {
|
|
381
|
+
if (e.preventDefault(), C.some((e) => e.id === O) && C.length <= 1) return;
|
|
382
|
+
I({
|
|
382
383
|
type: "nodeDelete",
|
|
383
|
-
nodeId:
|
|
384
|
-
}),
|
|
384
|
+
nodeId: O
|
|
385
|
+
}), F((e) => ce(e, O)), k(null);
|
|
385
386
|
return;
|
|
386
387
|
}
|
|
387
|
-
if (t && e.key === "c" &&
|
|
388
|
-
e.preventDefault(),
|
|
388
|
+
if (t && e.key === "c" && O) {
|
|
389
|
+
e.preventDefault(), M.current = ie(C, O);
|
|
389
390
|
return;
|
|
390
391
|
}
|
|
391
|
-
if (t && e.key === "x" &&
|
|
392
|
-
if (e.preventDefault(),
|
|
393
|
-
|
|
392
|
+
if (t && e.key === "x" && O && !v) {
|
|
393
|
+
if (e.preventDefault(), M.current = ie(C, O), C.some((e) => e.id === O) && C.length <= 1) return;
|
|
394
|
+
I({
|
|
394
395
|
type: "nodeDelete",
|
|
395
|
-
nodeId:
|
|
396
|
-
}),
|
|
396
|
+
nodeId: O
|
|
397
|
+
}), F((e) => ce(e, O)), k(null);
|
|
397
398
|
return;
|
|
398
399
|
}
|
|
399
|
-
if (t && e.key === "v" &&
|
|
400
|
+
if (t && e.key === "v" && O && M.current && !v) {
|
|
400
401
|
e.preventDefault();
|
|
401
|
-
let t = se(
|
|
402
|
-
|
|
402
|
+
let t = se(M.current);
|
|
403
|
+
F((e) => ne(e, O, t)), I({
|
|
403
404
|
type: "nodeAdd",
|
|
404
405
|
node: t,
|
|
405
|
-
parentId:
|
|
406
|
+
parentId: O
|
|
406
407
|
});
|
|
407
408
|
return;
|
|
408
409
|
}
|
|
409
410
|
}, [
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
w,
|
|
411
|
+
lt,
|
|
412
|
+
O,
|
|
413
|
+
C,
|
|
414
414
|
T,
|
|
415
|
-
|
|
416
|
-
|
|
415
|
+
E,
|
|
416
|
+
F,
|
|
417
|
+
A,
|
|
417
418
|
Z,
|
|
418
419
|
Y,
|
|
419
420
|
q,
|
|
420
|
-
|
|
421
|
-
Qe,
|
|
421
|
+
R,
|
|
422
422
|
$e,
|
|
423
|
+
et,
|
|
423
424
|
Q,
|
|
424
425
|
$,
|
|
425
426
|
v,
|
|
426
|
-
|
|
427
|
+
I
|
|
427
428
|
]);
|
|
428
|
-
|
|
429
|
+
ve(ke, () => ({
|
|
429
430
|
exportToSVG() {
|
|
430
|
-
return r(
|
|
431
|
+
return r(z, B, {}, L, x);
|
|
431
432
|
},
|
|
432
433
|
async exportToPNG() {
|
|
433
|
-
return a(i(
|
|
434
|
+
return a(i(z, B, {}, L, x));
|
|
434
435
|
},
|
|
435
436
|
exportToOutline() {
|
|
436
|
-
return c(
|
|
437
|
+
return c(C, x);
|
|
437
438
|
},
|
|
438
439
|
getData() {
|
|
439
|
-
return
|
|
440
|
+
return C;
|
|
440
441
|
},
|
|
441
442
|
setData(e) {
|
|
442
|
-
|
|
443
|
+
w(oe(e)), D({});
|
|
443
444
|
},
|
|
444
445
|
setMarkdown(e) {
|
|
445
|
-
|
|
446
|
+
w(x ? s(e, x).roots : o(e)), D({});
|
|
446
447
|
},
|
|
447
448
|
fitView() {
|
|
448
449
|
Q();
|
|
@@ -451,19 +452,23 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
451
452
|
$(e);
|
|
452
453
|
}
|
|
453
454
|
}), [
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
455
|
+
z,
|
|
456
|
+
B,
|
|
457
|
+
C,
|
|
457
458
|
x,
|
|
458
459
|
Q,
|
|
459
460
|
$,
|
|
460
|
-
|
|
461
|
+
L
|
|
461
462
|
]), d(() => {
|
|
462
|
-
if (!
|
|
463
|
+
if (!A) return;
|
|
463
464
|
let e = () => Z();
|
|
464
465
|
return window.addEventListener("click", e), () => window.removeEventListener("click", e);
|
|
465
|
-
}, [
|
|
466
|
-
let
|
|
466
|
+
}, [A, Z]);
|
|
467
|
+
let At = u((e) => {
|
|
468
|
+
w(x ? s(e, x).roots : o(e)), D({});
|
|
469
|
+
}, [x]), jt = u(() => {
|
|
470
|
+
setTimeout(() => Q(), 100);
|
|
471
|
+
}, [Q]), Mt = u(() => {}, []), Nt = u((e) => {
|
|
467
472
|
if (e.key !== "Tab") return;
|
|
468
473
|
e.preventDefault();
|
|
469
474
|
let t = e.currentTarget, { selectionStart: n, selectionEnd: r, value: i } = t;
|
|
@@ -473,7 +478,7 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
473
478
|
let a = i.slice(e, r), o = a.match(/^ {1,2}/);
|
|
474
479
|
if (!o) return;
|
|
475
480
|
let s = o[0].length;
|
|
476
|
-
|
|
481
|
+
P(i.slice(0, e) + a.slice(s) + i.slice(r)), requestAnimationFrame(() => {
|
|
477
482
|
t.selectionStart = t.selectionEnd = Math.max(e, n - s);
|
|
478
483
|
});
|
|
479
484
|
} else {
|
|
@@ -481,60 +486,60 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
481
486
|
let n = e.match(/^ {1,2}/), r = n ? n[0].length : 0;
|
|
482
487
|
return o += r, t === 0 && (s = r), e.slice(r);
|
|
483
488
|
}).join("\n");
|
|
484
|
-
|
|
489
|
+
P(i.slice(0, e) + c + i.slice(r)), requestAnimationFrame(() => {
|
|
485
490
|
t.selectionStart = n - s, t.selectionEnd = r - o;
|
|
486
491
|
});
|
|
487
492
|
}
|
|
488
|
-
} else if (n === r)
|
|
493
|
+
} else if (n === r) P(i.slice(0, n) + " " + i.slice(r)), requestAnimationFrame(() => {
|
|
489
494
|
t.selectionStart = t.selectionEnd = n + 2;
|
|
490
495
|
});
|
|
491
496
|
else {
|
|
492
497
|
let e = i.lastIndexOf("\n", n - 1) + 1, a = i.slice(e, r).split("\n"), o = a.map((e) => " " + e).join("\n");
|
|
493
|
-
|
|
498
|
+
P(i.slice(0, e) + o + i.slice(r)), requestAnimationFrame(() => {
|
|
494
499
|
t.selectionStart = n + 2, t.selectionEnd = r + a.length * 2;
|
|
495
500
|
});
|
|
496
501
|
}
|
|
497
502
|
}, []);
|
|
498
503
|
return /* @__PURE__ */ g("div", {
|
|
499
|
-
ref:
|
|
504
|
+
ref: Ae,
|
|
500
505
|
className: "mindmap-container",
|
|
501
506
|
children: [
|
|
502
|
-
|
|
507
|
+
Pe === "text" && /* @__PURE__ */ h("textarea", {
|
|
503
508
|
className: "mindmap-text-editor",
|
|
504
|
-
value:
|
|
505
|
-
onChange: (e) =>
|
|
506
|
-
onKeyDown:
|
|
509
|
+
value: N,
|
|
510
|
+
onChange: (e) => P(e.target.value),
|
|
511
|
+
onKeyDown: Nt,
|
|
507
512
|
readOnly: v,
|
|
508
513
|
style: {
|
|
509
|
-
background:
|
|
510
|
-
color:
|
|
514
|
+
background: L.canvas.bgColor,
|
|
515
|
+
color: L.node.textColor,
|
|
511
516
|
opacity: v ? .7 : 1
|
|
512
517
|
}
|
|
513
518
|
}),
|
|
514
519
|
/* @__PURE__ */ h("svg", {
|
|
515
520
|
ref: b,
|
|
516
|
-
className: `mindmap-svg ${
|
|
521
|
+
className: `mindmap-svg ${rt ? "dragging-canvas" : ""} ${W ? "dragging-node" : ""}`,
|
|
517
522
|
style: {
|
|
518
|
-
background:
|
|
519
|
-
display:
|
|
523
|
+
background: L.canvas.bgColor,
|
|
524
|
+
display: Pe === "text" ? "none" : "block"
|
|
520
525
|
},
|
|
521
526
|
tabIndex: 0,
|
|
522
|
-
onMouseDown:
|
|
523
|
-
onMouseMove:
|
|
524
|
-
onMouseUp:
|
|
525
|
-
onMouseLeave:
|
|
526
|
-
onClick:
|
|
527
|
-
onKeyDown:
|
|
528
|
-
onContextMenu:
|
|
527
|
+
onMouseDown: gt,
|
|
528
|
+
onMouseMove: ot,
|
|
529
|
+
onMouseUp: st,
|
|
530
|
+
onMouseLeave: st,
|
|
531
|
+
onClick: vt,
|
|
532
|
+
onKeyDown: kt,
|
|
533
|
+
onContextMenu: yt,
|
|
529
534
|
children: /* @__PURE__ */ g("g", {
|
|
530
535
|
className: "mindmap-canvas",
|
|
531
|
-
transform: `translate(${
|
|
536
|
+
transform: `translate(${H.x}, ${H.y}) scale(${U})`,
|
|
532
537
|
opacity: X ? 1 : 0,
|
|
533
538
|
style: { transition: X ? "opacity 0.4s ease-out" : "none" },
|
|
534
539
|
children: [
|
|
535
540
|
/* @__PURE__ */ g("g", {
|
|
536
541
|
className: "mindmap-edges",
|
|
537
|
-
children: [
|
|
542
|
+
children: [B.some((e) => e.isCrossLink) && /* @__PURE__ */ h("defs", { children: /* @__PURE__ */ h("marker", {
|
|
538
543
|
id: "mindmap-arrowhead",
|
|
539
544
|
markerWidth: "8",
|
|
540
545
|
markerHeight: "6",
|
|
@@ -547,12 +552,12 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
547
552
|
stroke: "currentColor",
|
|
548
553
|
strokeWidth: 1.5
|
|
549
554
|
})
|
|
550
|
-
}) }),
|
|
551
|
-
let t =
|
|
555
|
+
}) }), B.map((e) => {
|
|
556
|
+
let t = Je[e.toId], n = t !== void 0;
|
|
552
557
|
return /* @__PURE__ */ g("g", { children: [/* @__PURE__ */ h("path", {
|
|
553
558
|
d: e.path,
|
|
554
559
|
stroke: e.color,
|
|
555
|
-
strokeWidth:
|
|
560
|
+
strokeWidth: L.connection.strokeWidth,
|
|
556
561
|
strokeLinecap: "round",
|
|
557
562
|
strokeDasharray: n ? void 0 : e.strokeDasharray,
|
|
558
563
|
markerEnd: e.isCrossLink ? "url(#mindmap-arrowhead)" : void 0,
|
|
@@ -561,11 +566,11 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
561
566
|
className: [
|
|
562
567
|
"mindmap-edge",
|
|
563
568
|
e.isCrossLink ? "mindmap-edge-cross-link" : "",
|
|
564
|
-
n ? "mindmap-edge-expanding" :
|
|
569
|
+
n ? "mindmap-edge-expanding" : rt || K.has(e.fromId) || K.has(e.toId) ? "" : "mindmap-edge-animated"
|
|
565
570
|
].filter(Boolean).join(" "),
|
|
566
571
|
style: n ? { animationDelay: `${t}ms` } : void 0
|
|
567
572
|
}), e.label && (() => {
|
|
568
|
-
let t =
|
|
573
|
+
let t = V[e.fromId], n = V[e.toId];
|
|
569
574
|
return !t || !n ? null : /* @__PURE__ */ h("text", {
|
|
570
575
|
className: "mindmap-edge-label",
|
|
571
576
|
x: (t.x + n.x) / 2,
|
|
@@ -574,7 +579,7 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
574
579
|
fontSize: 11,
|
|
575
580
|
fill: e.color,
|
|
576
581
|
opacity: .8,
|
|
577
|
-
fontFamily:
|
|
582
|
+
fontFamily: L.node.fontFamily,
|
|
578
583
|
style: { pointerEvents: "none" },
|
|
579
584
|
children: e.label
|
|
580
585
|
});
|
|
@@ -583,48 +588,48 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
583
588
|
}),
|
|
584
589
|
/* @__PURE__ */ h("g", {
|
|
585
590
|
className: "mindmap-nodes",
|
|
586
|
-
children:
|
|
587
|
-
let t =
|
|
591
|
+
children: z.map((e) => {
|
|
592
|
+
let t = K.has(e.id), n = t || rt ? "" : "mindmap-node-animated";
|
|
588
593
|
return /* @__PURE__ */ h(me, {
|
|
589
594
|
node: e,
|
|
590
|
-
isEditing:
|
|
595
|
+
isEditing: lt === e.id,
|
|
591
596
|
isPendingEdit: J === e.id,
|
|
592
|
-
isSelected:
|
|
593
|
-
isNew:
|
|
597
|
+
isSelected: O === e.id,
|
|
598
|
+
isNew: mt.has(e.id),
|
|
594
599
|
isGhost: t,
|
|
595
600
|
animClass: n,
|
|
596
|
-
editText:
|
|
597
|
-
theme:
|
|
598
|
-
direction:
|
|
599
|
-
onMouseDown:
|
|
600
|
-
onClick:
|
|
601
|
-
onDoubleClick: v ? () => {} :
|
|
601
|
+
editText: ut,
|
|
602
|
+
theme: L,
|
|
603
|
+
direction: T,
|
|
604
|
+
onMouseDown: ct,
|
|
605
|
+
onClick: _t,
|
|
606
|
+
onDoubleClick: v ? () => {} : dt,
|
|
602
607
|
onEditChange: q,
|
|
603
|
-
onEditCommit:
|
|
604
|
-
onEditCancel:
|
|
605
|
-
onAddChild:
|
|
606
|
-
onRemarkHover:
|
|
608
|
+
onEditCommit: ft,
|
|
609
|
+
onEditCancel: pt,
|
|
610
|
+
onAddChild: xt,
|
|
611
|
+
onRemarkHover: bt,
|
|
607
612
|
onFoldToggle: x ? (e) => {
|
|
608
|
-
|
|
613
|
+
Be[e] || (Ue(e), setTimeout(() => Ue(null), 800)), Ve((t) => ({
|
|
609
614
|
...t,
|
|
610
615
|
[e]: !t[e]
|
|
611
616
|
}));
|
|
612
617
|
} : void 0,
|
|
613
|
-
expandDelay:
|
|
618
|
+
expandDelay: Je[e.id],
|
|
614
619
|
readonly: v,
|
|
615
620
|
plugins: x
|
|
616
621
|
}, e.id);
|
|
617
622
|
})
|
|
618
623
|
}),
|
|
619
|
-
|
|
620
|
-
let e =
|
|
624
|
+
W && G && (() => {
|
|
625
|
+
let e = V[W];
|
|
621
626
|
if (!e) return null;
|
|
622
|
-
let n =
|
|
623
|
-
return /* @__PURE__ */ g(
|
|
627
|
+
let n = G.x - e.x, r = G.y - e.y, i = e.parentId ? V[e.parentId] : null;
|
|
628
|
+
return /* @__PURE__ */ g(ye, { children: [i && /* @__PURE__ */ h("path", {
|
|
624
629
|
className: "mindmap-floating-edge",
|
|
625
|
-
d: t(i.x, i.y, i.width,
|
|
630
|
+
d: t(i.x, i.y, i.width, G.x, G.y, e.width, e.side),
|
|
626
631
|
stroke: e.color,
|
|
627
|
-
strokeWidth:
|
|
632
|
+
strokeWidth: L.connection.strokeWidth,
|
|
628
633
|
strokeLinecap: "round",
|
|
629
634
|
fill: "none",
|
|
630
635
|
style: { pointerEvents: "none" }
|
|
@@ -632,14 +637,14 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
632
637
|
className: "mindmap-floating",
|
|
633
638
|
transform: `translate(${n}, ${r})`,
|
|
634
639
|
style: { pointerEvents: "none" },
|
|
635
|
-
children: [
|
|
640
|
+
children: [B.filter((e) => K.has(e.fromId) && K.has(e.toId)).map((e) => /* @__PURE__ */ h("path", {
|
|
636
641
|
className: "mindmap-floating-edge",
|
|
637
642
|
d: e.path,
|
|
638
643
|
stroke: e.color,
|
|
639
|
-
strokeWidth:
|
|
644
|
+
strokeWidth: L.connection.strokeWidth,
|
|
640
645
|
strokeLinecap: "round",
|
|
641
646
|
fill: "none"
|
|
642
|
-
}, `fl-${e.key}`)),
|
|
647
|
+
}, `fl-${e.key}`)), z.filter((e) => K.has(e.id)).map((e) => /* @__PURE__ */ h(me, {
|
|
643
648
|
node: e,
|
|
644
649
|
isEditing: !1,
|
|
645
650
|
isPendingEdit: !1,
|
|
@@ -647,8 +652,8 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
647
652
|
isNew: !1,
|
|
648
653
|
animClass: "",
|
|
649
654
|
editText: "",
|
|
650
|
-
theme:
|
|
651
|
-
direction:
|
|
655
|
+
theme: L,
|
|
656
|
+
direction: T,
|
|
652
657
|
onMouseDown: () => {},
|
|
653
658
|
onClick: () => {},
|
|
654
659
|
onDoubleClick: () => {},
|
|
@@ -660,7 +665,7 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
660
665
|
}, `fl-${e.id}`))]
|
|
661
666
|
})] });
|
|
662
667
|
})(),
|
|
663
|
-
x && e(x,
|
|
668
|
+
x && e(x, z, B, L).map((e, t) => /* @__PURE__ */ h("g", {
|
|
664
669
|
className: "mindmap-plugin-overlay",
|
|
665
670
|
children: e
|
|
666
671
|
}, `plugin-overlay-${t}`))
|
|
@@ -668,43 +673,52 @@ var _ = l(function({ data: l, markdown: _, defaultDirection: be = "both", theme:
|
|
|
668
673
|
})
|
|
669
674
|
}),
|
|
670
675
|
/* @__PURE__ */ h(he, {
|
|
671
|
-
zoom:
|
|
672
|
-
theme:
|
|
673
|
-
messages:
|
|
674
|
-
showZoom:
|
|
675
|
-
mode:
|
|
676
|
-
isFullscreen:
|
|
677
|
-
onZoomIn:
|
|
678
|
-
onZoomOut:
|
|
676
|
+
zoom: U,
|
|
677
|
+
theme: L,
|
|
678
|
+
messages: R,
|
|
679
|
+
showZoom: qe.zoom,
|
|
680
|
+
mode: Pe,
|
|
681
|
+
isFullscreen: Ie,
|
|
682
|
+
onZoomIn: $e,
|
|
683
|
+
onZoomOut: et,
|
|
679
684
|
onAutoFit: Q,
|
|
680
|
-
onModeToggle:
|
|
681
|
-
onFullscreenToggle:
|
|
685
|
+
onModeToggle: Et,
|
|
686
|
+
onFullscreenToggle: Dt
|
|
687
|
+
}),
|
|
688
|
+
Te && /* @__PURE__ */ h(_e, {
|
|
689
|
+
config: Te,
|
|
690
|
+
theme: L,
|
|
691
|
+
messages: R,
|
|
692
|
+
currentMarkdown: c(C, x),
|
|
693
|
+
onMarkdownStream: At,
|
|
694
|
+
onComplete: jt,
|
|
695
|
+
onError: Mt
|
|
682
696
|
}),
|
|
683
|
-
|
|
684
|
-
position:
|
|
685
|
-
theme:
|
|
686
|
-
messages:
|
|
687
|
-
direction:
|
|
697
|
+
A && /* @__PURE__ */ h(ge, {
|
|
698
|
+
position: A,
|
|
699
|
+
theme: L,
|
|
700
|
+
messages: R,
|
|
701
|
+
direction: T,
|
|
688
702
|
readonly: v,
|
|
689
|
-
onNewRootNode:
|
|
690
|
-
onExportSVG:
|
|
691
|
-
onExportPNG:
|
|
692
|
-
onExportMarkdown:
|
|
703
|
+
onNewRootNode: St,
|
|
704
|
+
onExportSVG: Ct,
|
|
705
|
+
onExportPNG: wt,
|
|
706
|
+
onExportMarkdown: Tt,
|
|
693
707
|
onDirectionChange: $,
|
|
694
708
|
onClose: Z
|
|
695
709
|
}),
|
|
696
|
-
|
|
710
|
+
Re && /* @__PURE__ */ h("div", {
|
|
697
711
|
className: "mindmap-remark-tooltip",
|
|
698
712
|
style: {
|
|
699
|
-
left:
|
|
700
|
-
top:
|
|
713
|
+
left: Re.x,
|
|
714
|
+
top: Re.y,
|
|
701
715
|
transform: "translateY(-100%)",
|
|
702
|
-
background:
|
|
703
|
-
color:
|
|
704
|
-
borderColor:
|
|
705
|
-
border: `1px solid ${
|
|
716
|
+
background: L.contextMenu.bgColor,
|
|
717
|
+
color: L.contextMenu.textColor,
|
|
718
|
+
borderColor: L.contextMenu.borderColor,
|
|
719
|
+
border: `1px solid ${L.contextMenu.borderColor}`
|
|
706
720
|
},
|
|
707
|
-
children:
|
|
721
|
+
children: Re.text
|
|
708
722
|
})
|
|
709
723
|
]
|
|
710
724
|
});
|