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