@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.
- package/README.md +534 -0
- package/README.zh-CN.md +534 -0
- package/dist/MindMap.d.ts +3 -0
- package/dist/components/MindMapContextMenu.d.ts +20 -0
- package/dist/components/MindMapControls.d.ts +16 -0
- package/dist/components/MindMapNode.d.ts +32 -0
- package/dist/components/icons.d.ts +8 -0
- package/dist/esm/MindMap2.js +713 -0
- package/dist/esm/components/MindMapContextMenu.js +123 -0
- package/dist/esm/components/MindMapControls.js +114 -0
- package/dist/esm/components/MindMapNode.js +588 -0
- package/dist/esm/components/icons.js +45 -0
- package/dist/esm/hooks/useDrag.js +346 -0
- package/dist/esm/hooks/useNewNodeAnimation.js +20 -0
- package/dist/esm/hooks/useNodeEdit.js +57 -0
- package/dist/esm/hooks/usePanZoom.js +85 -0
- package/dist/esm/hooks/useTheme.js +16 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/logo.svg +9 -0
- package/dist/esm/plugins/cross-link.js +65 -0
- package/dist/esm/plugins/dotted-line.js +23 -0
- package/dist/esm/plugins/folding.js +20 -0
- package/dist/esm/plugins/front-matter.js +19 -0
- package/dist/esm/plugins/index.js +19 -0
- package/dist/esm/plugins/latex.js +132 -0
- package/dist/esm/plugins/multi-line.js +39 -0
- package/dist/esm/plugins/runner.js +128 -0
- package/dist/esm/plugins/tags.js +55 -0
- package/dist/esm/style.css +2 -0
- package/dist/esm/utils/export.js +50 -0
- package/dist/esm/utils/i18n.js +61 -0
- package/dist/esm/utils/inline-markdown.js +189 -0
- package/dist/esm/utils/layout.js +208 -0
- package/dist/esm/utils/markdown.js +288 -0
- package/dist/esm/utils/theme.js +119 -0
- package/dist/esm/utils/tree-ops.js +136 -0
- package/dist/hooks/useDrag.d.ts +40 -0
- package/dist/hooks/useNewNodeAnimation.d.ts +2 -0
- package/dist/hooks/useNodeEdit.d.ts +17 -0
- package/dist/hooks/usePanZoom.d.ts +26 -0
- package/dist/hooks/useTheme.d.ts +3 -0
- package/dist/index.d.ts +16 -0
- package/dist/logo.svg +9 -0
- package/dist/mindmap.umd.cjs +24 -0
- package/dist/plugins/cross-link.d.ts +2 -0
- package/dist/plugins/dotted-line.d.ts +2 -0
- package/dist/plugins/folding.d.ts +2 -0
- package/dist/plugins/front-matter.d.ts +2 -0
- package/dist/plugins/index.d.ts +11 -0
- package/dist/plugins/latex.d.ts +20 -0
- package/dist/plugins/multi-line.d.ts +2 -0
- package/dist/plugins/runner.d.ts +30 -0
- package/dist/plugins/tags.d.ts +2 -0
- package/dist/plugins/types.d.ts +78 -0
- package/dist/style.css +2 -0
- package/dist/types.d.ts +105 -0
- package/dist/utils/export.d.ts +18 -0
- package/dist/utils/i18n.d.ts +22 -0
- package/dist/utils/inline-markdown.d.ts +66 -0
- package/dist/utils/layout.d.ts +14 -0
- package/dist/utils/markdown.d.ts +20 -0
- package/dist/utils/theme.d.ts +62 -0
- package/dist/utils/tree-ops.d.ts +36 -0
- package/package.json +65 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { getDescendantIds as e, moveChildToSide as t, swapSiblingsMulti as n } from "../utils/tree-ops.js";
|
|
2
|
+
import { useCallback as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
|
|
3
|
+
//#region src/components/MindMap/hooks/useDrag.ts
|
|
4
|
+
function c({ svgRef: c, zoom: l, pan: u, setPan: d, setZoom: f, nodeMap: p, nodes: m, updateData: h, direction: g, splitIndices: _, setSplitIndices: v, mapData: y, contentCenter: b }) {
|
|
5
|
+
let [x, S] = s(!1), [C, w] = s(null), [T, E] = s(null), D = o({
|
|
6
|
+
x: 0,
|
|
7
|
+
y: 0,
|
|
8
|
+
panX: 0,
|
|
9
|
+
panY: 0
|
|
10
|
+
}), O = o({
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0
|
|
13
|
+
}), k = o(!1), A = o(0), j = o({
|
|
14
|
+
type: "none",
|
|
15
|
+
startPan: {
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 0
|
|
18
|
+
},
|
|
19
|
+
startZoom: 1,
|
|
20
|
+
startTouches: [],
|
|
21
|
+
pinchDistance: 0,
|
|
22
|
+
contentCenter: {
|
|
23
|
+
x: 0,
|
|
24
|
+
y: 0
|
|
25
|
+
},
|
|
26
|
+
touchNodeId: null
|
|
27
|
+
}), M = a(() => {
|
|
28
|
+
if (!C) return /* @__PURE__ */ new Set();
|
|
29
|
+
let t = new Set([C]);
|
|
30
|
+
for (let n of e(C, m)) t.add(n);
|
|
31
|
+
return t;
|
|
32
|
+
}, [C, m]), N = r((e, t) => {
|
|
33
|
+
let n = c.current.getBoundingClientRect();
|
|
34
|
+
return {
|
|
35
|
+
x: (e - n.left - u.x) / l,
|
|
36
|
+
y: (t - n.top - u.y) / l
|
|
37
|
+
};
|
|
38
|
+
}, [
|
|
39
|
+
c,
|
|
40
|
+
u,
|
|
41
|
+
l
|
|
42
|
+
]), P = r((e, r, i) => {
|
|
43
|
+
let a = N(e, r), o = {
|
|
44
|
+
x: a.x + O.current.x,
|
|
45
|
+
y: a.y + O.current.y
|
|
46
|
+
};
|
|
47
|
+
E(o);
|
|
48
|
+
let s = Date.now();
|
|
49
|
+
if (s - A.current > 500) {
|
|
50
|
+
let e = p[i];
|
|
51
|
+
if (e && e.parentId) {
|
|
52
|
+
if (e.depth === 1 && g === "both") {
|
|
53
|
+
let n = e.side, r = n === "right" && o.x < 0, a = n === "left" && o.x > 0;
|
|
54
|
+
if (r || a) {
|
|
55
|
+
let n = r ? "left" : "right", a = e.parentId, o = y.find((e) => e.id === a);
|
|
56
|
+
if (o) {
|
|
57
|
+
let e = t(o, i, n, _[a] ?? Math.ceil((o.children?.length ?? 0) / 2));
|
|
58
|
+
if (e) {
|
|
59
|
+
A.current = s, v((t) => ({
|
|
60
|
+
...t,
|
|
61
|
+
[a]: e.newSplitIndex
|
|
62
|
+
})), h((t) => t.map((t) => t.id === a ? e.data : t));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let r = m.filter((t) => t.parentId === e.parentId && t.id !== i && t.side === e.side);
|
|
69
|
+
for (let t of r) {
|
|
70
|
+
let r = Math.max(e.height, t.height) * .6;
|
|
71
|
+
if (Math.abs(o.y - t.y) < r) {
|
|
72
|
+
A.current = s, h((e) => n(e, i, t.id));
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}, [
|
|
79
|
+
N,
|
|
80
|
+
p,
|
|
81
|
+
m,
|
|
82
|
+
h,
|
|
83
|
+
g,
|
|
84
|
+
_,
|
|
85
|
+
v,
|
|
86
|
+
y
|
|
87
|
+
]), F = r((e) => {
|
|
88
|
+
e.button === 0 && (k.current = !1, S(!0), D.current = {
|
|
89
|
+
x: e.clientX,
|
|
90
|
+
y: e.clientY,
|
|
91
|
+
panX: u.x,
|
|
92
|
+
panY: u.y
|
|
93
|
+
});
|
|
94
|
+
}, [u]), I = r((e) => {
|
|
95
|
+
x ? (k.current = !0, d({
|
|
96
|
+
x: D.current.panX + (e.clientX - D.current.x),
|
|
97
|
+
y: D.current.panY + (e.clientY - D.current.y)
|
|
98
|
+
})) : C && (k.current = !0, P(e.clientX, e.clientY, C));
|
|
99
|
+
}, [
|
|
100
|
+
x,
|
|
101
|
+
C,
|
|
102
|
+
d,
|
|
103
|
+
P
|
|
104
|
+
]), L = r(() => {
|
|
105
|
+
S(!1), w(null), E(null);
|
|
106
|
+
}, []), R = r((e, t) => {
|
|
107
|
+
if (e.stopPropagation(), e.button !== 0) return;
|
|
108
|
+
k.current = !1;
|
|
109
|
+
let n = p[t];
|
|
110
|
+
if (!n) return;
|
|
111
|
+
w(t), E({
|
|
112
|
+
x: n.x,
|
|
113
|
+
y: n.y
|
|
114
|
+
});
|
|
115
|
+
let r = N(e.clientX, e.clientY);
|
|
116
|
+
O.current = {
|
|
117
|
+
x: n.x - r.x,
|
|
118
|
+
y: n.y - r.y
|
|
119
|
+
};
|
|
120
|
+
}, [p, N]), z = o(u), B = o(l), V = o(p), H = o(b), U = o(C);
|
|
121
|
+
i(() => {
|
|
122
|
+
z.current = u, B.current = l, V.current = p, H.current = b, U.current = C;
|
|
123
|
+
});
|
|
124
|
+
let W = r((e) => {
|
|
125
|
+
let t = e;
|
|
126
|
+
for (; t && t !== c.current;) {
|
|
127
|
+
if (t.classList?.contains("mindmap-node-g")) {
|
|
128
|
+
let e = t.getAttribute("transform");
|
|
129
|
+
if (e) for (let t of m) {
|
|
130
|
+
let n = t.x, r = t.y;
|
|
131
|
+
if (e.includes(`translate(${n}`) && e.includes(`${r})`)) return t.id;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
t = t.parentElement;
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}, [c, m]);
|
|
138
|
+
return i(() => {
|
|
139
|
+
let e = c.current;
|
|
140
|
+
if (!e) return;
|
|
141
|
+
let r = e;
|
|
142
|
+
function i(e, t) {
|
|
143
|
+
return Math.hypot(t.clientX - e.clientX, t.clientY - e.clientY);
|
|
144
|
+
}
|
|
145
|
+
function a(e) {
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
let t = e.touches;
|
|
148
|
+
if (t.length === 2) {
|
|
149
|
+
let e = i(t[0], t[1]);
|
|
150
|
+
j.current = {
|
|
151
|
+
type: "pinch",
|
|
152
|
+
startPan: { ...z.current },
|
|
153
|
+
startZoom: B.current,
|
|
154
|
+
startTouches: [{
|
|
155
|
+
id: t[0].identifier,
|
|
156
|
+
x: t[0].clientX,
|
|
157
|
+
y: t[0].clientY
|
|
158
|
+
}, {
|
|
159
|
+
id: t[1].identifier,
|
|
160
|
+
x: t[1].clientX,
|
|
161
|
+
y: t[1].clientY
|
|
162
|
+
}],
|
|
163
|
+
pinchDistance: e,
|
|
164
|
+
contentCenter: { ...H.current },
|
|
165
|
+
touchNodeId: null
|
|
166
|
+
}, U.current && (w(null), E(null)), S(!1);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (t.length === 1) {
|
|
170
|
+
let n = t[0], i = W(e.target);
|
|
171
|
+
if (i) {
|
|
172
|
+
let t = e.target;
|
|
173
|
+
for (; t && t !== r;) {
|
|
174
|
+
if (t.classList?.contains("mindmap-add-btn")) return;
|
|
175
|
+
t = t.parentElement;
|
|
176
|
+
}
|
|
177
|
+
k.current = !1;
|
|
178
|
+
let a = V.current[i];
|
|
179
|
+
if (a) {
|
|
180
|
+
w(i), E({
|
|
181
|
+
x: a.x,
|
|
182
|
+
y: a.y
|
|
183
|
+
});
|
|
184
|
+
let e = r.getBoundingClientRect(), t = (n.clientX - e.left - z.current.x) / B.current, o = (n.clientY - e.top - z.current.y) / B.current;
|
|
185
|
+
O.current = {
|
|
186
|
+
x: a.x - t,
|
|
187
|
+
y: a.y - o
|
|
188
|
+
}, j.current = {
|
|
189
|
+
type: "node-drag",
|
|
190
|
+
startPan: { ...z.current },
|
|
191
|
+
startZoom: B.current,
|
|
192
|
+
startTouches: [{
|
|
193
|
+
id: n.identifier,
|
|
194
|
+
x: n.clientX,
|
|
195
|
+
y: n.clientY
|
|
196
|
+
}],
|
|
197
|
+
pinchDistance: 0,
|
|
198
|
+
contentCenter: { ...H.current },
|
|
199
|
+
touchNodeId: i
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
} else k.current = !1, S(!0), D.current = {
|
|
203
|
+
x: n.clientX,
|
|
204
|
+
y: n.clientY,
|
|
205
|
+
panX: z.current.x,
|
|
206
|
+
panY: z.current.y
|
|
207
|
+
}, j.current = {
|
|
208
|
+
type: "canvas-pan",
|
|
209
|
+
startPan: { ...z.current },
|
|
210
|
+
startZoom: B.current,
|
|
211
|
+
startTouches: [{
|
|
212
|
+
id: n.identifier,
|
|
213
|
+
x: n.clientX,
|
|
214
|
+
y: n.clientY
|
|
215
|
+
}],
|
|
216
|
+
pinchDistance: 0,
|
|
217
|
+
contentCenter: { ...H.current },
|
|
218
|
+
touchNodeId: null
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function o(e) {
|
|
223
|
+
e.preventDefault();
|
|
224
|
+
let a = j.current, o = e.touches;
|
|
225
|
+
if (a.type === "pinch" && o.length >= 2) {
|
|
226
|
+
let e = i(o[0], o[1]) / a.pinchDistance, t = Math.min(Math.max(a.startZoom * e, .1), 5), n = r.clientWidth / 2, s = r.clientHeight / 2, c = a.contentCenter;
|
|
227
|
+
f(t), d({
|
|
228
|
+
x: n - c.x * t,
|
|
229
|
+
y: s - c.y * t
|
|
230
|
+
});
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (a.type === "canvas-pan" && o.length === 1) {
|
|
234
|
+
k.current = !0;
|
|
235
|
+
let e = o[0];
|
|
236
|
+
d({
|
|
237
|
+
x: D.current.panX + (e.clientX - D.current.x),
|
|
238
|
+
y: D.current.panY + (e.clientY - D.current.y)
|
|
239
|
+
});
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (a.type === "node-drag" && o.length === 1 && a.touchNodeId) {
|
|
243
|
+
k.current = !0;
|
|
244
|
+
let e = o[0], i = r.getBoundingClientRect(), s = (e.clientX - i.left - z.current.x) / B.current, c = (e.clientY - i.top - z.current.y) / B.current, l = {
|
|
245
|
+
x: s + O.current.x,
|
|
246
|
+
y: c + O.current.y
|
|
247
|
+
};
|
|
248
|
+
E(l);
|
|
249
|
+
let u = Date.now();
|
|
250
|
+
if (u - A.current > 500) {
|
|
251
|
+
let e = V.current[a.touchNodeId];
|
|
252
|
+
if (e && e.parentId) {
|
|
253
|
+
if (e.depth === 1 && g === "both") {
|
|
254
|
+
let n = e.side, r = n === "right" && l.x < 0, i = n === "left" && l.x > 0;
|
|
255
|
+
if (r || i) {
|
|
256
|
+
let n = r ? "left" : "right", i = e.parentId, o = y.find((e) => e.id === i);
|
|
257
|
+
if (o) {
|
|
258
|
+
let e = _[i] ?? Math.ceil((o.children?.length ?? 0) / 2), r = t(o, a.touchNodeId, n, e);
|
|
259
|
+
if (r) {
|
|
260
|
+
A.current = u, v((e) => ({
|
|
261
|
+
...e,
|
|
262
|
+
[i]: r.newSplitIndex
|
|
263
|
+
})), h((e) => e.map((e) => e.id === i ? r.data : e));
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
let r = m.filter((t) => t.parentId === e.parentId && t.id !== a.touchNodeId && t.side === e.side);
|
|
270
|
+
for (let t of r) {
|
|
271
|
+
let r = Math.max(e.height, t.height) * .6;
|
|
272
|
+
if (Math.abs(l.y - t.y) < r) {
|
|
273
|
+
A.current = u, h((e) => n(e, a.touchNodeId, t.id));
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function s(e) {
|
|
283
|
+
e.preventDefault();
|
|
284
|
+
let t = j.current, n = e.touches;
|
|
285
|
+
if (t.type === "pinch" && n.length === 1) {
|
|
286
|
+
let e = n[0];
|
|
287
|
+
D.current = {
|
|
288
|
+
x: e.clientX,
|
|
289
|
+
y: e.clientY,
|
|
290
|
+
panX: z.current.x,
|
|
291
|
+
panY: z.current.y
|
|
292
|
+
}, S(!0), j.current = {
|
|
293
|
+
...t,
|
|
294
|
+
type: "canvas-pan",
|
|
295
|
+
startTouches: [{
|
|
296
|
+
id: e.identifier,
|
|
297
|
+
x: e.clientX,
|
|
298
|
+
y: e.clientY
|
|
299
|
+
}]
|
|
300
|
+
};
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
n.length === 0 && (S(!1), w(null), E(null), j.current = {
|
|
304
|
+
type: "none",
|
|
305
|
+
startPan: {
|
|
306
|
+
x: 0,
|
|
307
|
+
y: 0
|
|
308
|
+
},
|
|
309
|
+
startZoom: 1,
|
|
310
|
+
startTouches: [],
|
|
311
|
+
pinchDistance: 0,
|
|
312
|
+
contentCenter: {
|
|
313
|
+
x: 0,
|
|
314
|
+
y: 0
|
|
315
|
+
},
|
|
316
|
+
touchNodeId: null
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
return r.addEventListener("touchstart", a, { passive: !1 }), r.addEventListener("touchmove", o, { passive: !1 }), r.addEventListener("touchend", s, { passive: !1 }), r.addEventListener("touchcancel", s, { passive: !1 }), () => {
|
|
320
|
+
r.removeEventListener("touchstart", a), r.removeEventListener("touchmove", o), r.removeEventListener("touchend", s), r.removeEventListener("touchcancel", s);
|
|
321
|
+
};
|
|
322
|
+
}, [
|
|
323
|
+
c,
|
|
324
|
+
d,
|
|
325
|
+
f,
|
|
326
|
+
W,
|
|
327
|
+
g,
|
|
328
|
+
y,
|
|
329
|
+
_,
|
|
330
|
+
v,
|
|
331
|
+
h,
|
|
332
|
+
m
|
|
333
|
+
]), {
|
|
334
|
+
draggingCanvas: x,
|
|
335
|
+
floatingNodeId: C,
|
|
336
|
+
floatingPos: T,
|
|
337
|
+
floatingSubtreeIds: M,
|
|
338
|
+
didDragRef: k,
|
|
339
|
+
handleCanvasMouseDown: F,
|
|
340
|
+
handleMouseMove: I,
|
|
341
|
+
handleMouseUp: L,
|
|
342
|
+
handleNodeMouseDown: R
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
export { c as useDrag };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useEffect as e, useRef as t, useState as n } from "react";
|
|
2
|
+
//#region src/components/MindMap/hooks/useNewNodeAnimation.ts
|
|
3
|
+
function r(r) {
|
|
4
|
+
let [i, a] = n(/* @__PURE__ */ new Set()), o = t(/* @__PURE__ */ new Set());
|
|
5
|
+
return e(() => {
|
|
6
|
+
let e = new Set(r.map((e) => e.id));
|
|
7
|
+
if (o.current.size > 0) {
|
|
8
|
+
let t = /* @__PURE__ */ new Set();
|
|
9
|
+
for (let n of e) o.current.has(n) || t.add(n);
|
|
10
|
+
if (t.size > 0) {
|
|
11
|
+
a(t);
|
|
12
|
+
let n = setTimeout(() => a(/* @__PURE__ */ new Set()), 350);
|
|
13
|
+
return o.current = e, () => clearTimeout(n);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
o.current = e;
|
|
17
|
+
}, [r]), i;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { r as useNewNodeAnimation };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { updateNodeFieldsMulti as e } from "../utils/tree-ops.js";
|
|
2
|
+
import { useCallback as t, useEffect as n, useState as r } from "react";
|
|
3
|
+
//#region src/components/MindMap/hooks/useNodeEdit.ts
|
|
4
|
+
function i(e) {
|
|
5
|
+
let t = e.match(/^\[([ x\-])\]\s+(.*)/);
|
|
6
|
+
if (!t) return { text: e };
|
|
7
|
+
let n = t[1], r = t[2];
|
|
8
|
+
return n === " " ? {
|
|
9
|
+
taskStatus: "todo",
|
|
10
|
+
text: r
|
|
11
|
+
} : n === "x" ? {
|
|
12
|
+
taskStatus: "done",
|
|
13
|
+
text: r
|
|
14
|
+
} : n === "-" ? {
|
|
15
|
+
taskStatus: "doing",
|
|
16
|
+
text: r
|
|
17
|
+
} : { text: e };
|
|
18
|
+
}
|
|
19
|
+
function a({ nodeMap: a, updateData: o, onTextChange: s }) {
|
|
20
|
+
let [c, l] = r(null), [u, d] = r(""), [f, p] = r(null);
|
|
21
|
+
return n(() => {
|
|
22
|
+
f && a[f] && (l(f), d(""), p(null));
|
|
23
|
+
}, [f, a]), {
|
|
24
|
+
editingId: c,
|
|
25
|
+
editText: u,
|
|
26
|
+
setEditText: d,
|
|
27
|
+
pendingEditId: f,
|
|
28
|
+
setPendingEditId: p,
|
|
29
|
+
handleNodeDoubleClick: t((e, t, n) => {
|
|
30
|
+
e.stopPropagation(), l(t), d(n);
|
|
31
|
+
}, []),
|
|
32
|
+
commitEdit: t(() => {
|
|
33
|
+
if (c) {
|
|
34
|
+
let t = u.trim();
|
|
35
|
+
if (t) {
|
|
36
|
+
let n = a[c]?.text ?? "", { taskStatus: r, text: l } = i(t);
|
|
37
|
+
o((t) => e(t, c, {
|
|
38
|
+
text: l,
|
|
39
|
+
taskStatus: r
|
|
40
|
+
})), l !== n && s?.(c, n, l);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
l(null);
|
|
44
|
+
}, [
|
|
45
|
+
c,
|
|
46
|
+
u,
|
|
47
|
+
o,
|
|
48
|
+
a,
|
|
49
|
+
s
|
|
50
|
+
]),
|
|
51
|
+
cancelEdit: t(() => {
|
|
52
|
+
l(null);
|
|
53
|
+
}, [])
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { a as useNodeEdit };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useCallback as e, useEffect as t, useMemo as n, useRef as r, useState as i } from "react";
|
|
2
|
+
//#region src/components/MindMap/hooks/usePanZoom.ts
|
|
3
|
+
function a(a, o) {
|
|
4
|
+
let [s, c] = i({
|
|
5
|
+
x: 0,
|
|
6
|
+
y: 0
|
|
7
|
+
}), [l, u] = i(1), d = r(0), f = r(l), p = r(s);
|
|
8
|
+
f.current = l, p.current = s;
|
|
9
|
+
let m = n(() => {
|
|
10
|
+
if (o.length === 0) return {
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0
|
|
13
|
+
};
|
|
14
|
+
let e = Infinity, t = -Infinity, n = Infinity, r = -Infinity;
|
|
15
|
+
for (let i of o) e = Math.min(e, i.x - i.width / 2), t = Math.max(t, i.x + i.width / 2), n = Math.min(n, i.y - i.height / 2), r = Math.max(r, i.y + i.height / 2);
|
|
16
|
+
return {
|
|
17
|
+
x: (e + t) / 2,
|
|
18
|
+
y: (n + r) / 2
|
|
19
|
+
};
|
|
20
|
+
}, [o]), h = e((e, t, n) => {
|
|
21
|
+
cancelAnimationFrame(d.current);
|
|
22
|
+
let r = f.current, i = p.current.x, a = p.current.y, o = performance.now(), s = (l) => {
|
|
23
|
+
let f = l - o, p = Math.min(f / 200, 1), m = 1 - (1 - p) ** 3;
|
|
24
|
+
u(r + (e - r) * m), c({
|
|
25
|
+
x: i + (t - i) * m,
|
|
26
|
+
y: a + (n - a) * m
|
|
27
|
+
}), p < 1 && (d.current = requestAnimationFrame(s));
|
|
28
|
+
};
|
|
29
|
+
d.current = requestAnimationFrame(s);
|
|
30
|
+
}, []), g = e(() => {
|
|
31
|
+
let e = a.current;
|
|
32
|
+
if (!e || o.length === 0) return;
|
|
33
|
+
let t = e.clientWidth, n = e.clientHeight, r = Infinity, i = -Infinity, s = Infinity, c = -Infinity;
|
|
34
|
+
for (let e of o) r = Math.min(r, e.x - e.width / 2), i = Math.max(i, e.x + e.width / 2), s = Math.min(s, e.y - e.height / 2), c = Math.max(c, e.y + e.height / 2);
|
|
35
|
+
let l = i - r, u = c - s, d = Math.min((t - 120) / l, (n - 120) / u, 1.5), f = (r + i) / 2, p = (s + c) / 2;
|
|
36
|
+
return {
|
|
37
|
+
zoom: d,
|
|
38
|
+
panX: t / 2 - f * d,
|
|
39
|
+
panY: n / 2 - p * d
|
|
40
|
+
};
|
|
41
|
+
}, [a, o]);
|
|
42
|
+
return t(() => {
|
|
43
|
+
let e = a.current;
|
|
44
|
+
if (!e) return;
|
|
45
|
+
let t = (t) => {
|
|
46
|
+
t.preventDefault();
|
|
47
|
+
let n = e.getBoundingClientRect(), r = t.clientX - n.left, i = t.clientY - n.top, a = t.deltaY > 0 ? .9 : 1.1, o = Math.min(Math.max(f.current * a, .1), 5);
|
|
48
|
+
c({
|
|
49
|
+
x: r - (r - p.current.x) * (o / f.current),
|
|
50
|
+
y: i - (i - p.current.y) * (o / f.current)
|
|
51
|
+
}), u(o);
|
|
52
|
+
};
|
|
53
|
+
return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
|
|
54
|
+
}, [a]), {
|
|
55
|
+
pan: s,
|
|
56
|
+
setPan: c,
|
|
57
|
+
zoom: l,
|
|
58
|
+
setZoom: u,
|
|
59
|
+
animateTo: h,
|
|
60
|
+
autoFit: g,
|
|
61
|
+
zoomIn: e(() => {
|
|
62
|
+
let e = Math.min(f.current * 1.2, 5), t = a.current, n = t.clientWidth / 2, r = t.clientHeight / 2;
|
|
63
|
+
h(e, n - (n - p.current.x) * (e / f.current), r - (r - p.current.y) * (e / f.current));
|
|
64
|
+
}, [a, h]),
|
|
65
|
+
zoomOut: e(() => {
|
|
66
|
+
let e = Math.max(f.current * .8, .1), t = a.current, n = t.clientWidth / 2, r = t.clientHeight / 2;
|
|
67
|
+
h(e, n - (n - p.current.x) * (e / f.current), r - (r - p.current.y) * (e / f.current));
|
|
68
|
+
}, [a, h]),
|
|
69
|
+
contentCenter: m,
|
|
70
|
+
panToNode: e((e) => {
|
|
71
|
+
let t = a.current;
|
|
72
|
+
if (!t) return;
|
|
73
|
+
let n = o.find((t) => t.id === e);
|
|
74
|
+
if (!n) return;
|
|
75
|
+
let r = t.clientWidth, i = t.clientHeight, s = n.x * f.current + p.current.x, c = n.y * f.current + p.current.y;
|
|
76
|
+
s > 100 && s < r - 100 && c > 100 && c < i - 100 || h(f.current, r / 2 - n.x * f.current, i / 2 - n.y * f.current);
|
|
77
|
+
}, [
|
|
78
|
+
a,
|
|
79
|
+
o,
|
|
80
|
+
h
|
|
81
|
+
])
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { a as usePanZoom };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getTheme as e } from "../utils/theme.js";
|
|
2
|
+
import { useMemo as t, useSyncExternalStore as n } from "react";
|
|
3
|
+
//#region src/components/MindMap/hooks/useTheme.ts
|
|
4
|
+
var r = typeof window < "u" ? window.matchMedia("(prefers-color-scheme: dark)") : null;
|
|
5
|
+
function i(e) {
|
|
6
|
+
return r?.addEventListener("change", e), () => r?.removeEventListener("change", e);
|
|
7
|
+
}
|
|
8
|
+
function a() {
|
|
9
|
+
return r?.matches ?? !1;
|
|
10
|
+
}
|
|
11
|
+
function o(r = "auto") {
|
|
12
|
+
let o = n(i, a, () => !1), s = r === "auto" ? o ? "dark" : "light" : r;
|
|
13
|
+
return t(() => e(s), [s]);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { o as useTheme };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { parseInlineMarkdown as e, stripInlineMarkdown as t } from "./utils/inline-markdown.js";
|
|
2
|
+
import { buildExportSVG as n, buildExportSVGForPNG as r, exportToPNG as i } from "./utils/export.js";
|
|
3
|
+
import { parseMarkdownList as a, parseMarkdownMultiRoot as o, parseMarkdownWithFrontMatter as s, toMarkdownList as c, toMarkdownMultiRoot as l } from "./utils/markdown.js";
|
|
4
|
+
import { detectLocale as u, resolveMessages as d } from "./utils/i18n.js";
|
|
5
|
+
import { latexPlugin as f } from "./plugins/latex.js";
|
|
6
|
+
import { MindMap as p } from "./MindMap2.js";
|
|
7
|
+
import { frontMatterPlugin as m } from "./plugins/front-matter.js";
|
|
8
|
+
import { dottedLinePlugin as h } from "./plugins/dotted-line.js";
|
|
9
|
+
import { foldingPlugin as g } from "./plugins/folding.js";
|
|
10
|
+
import { multiLinePlugin as _ } from "./plugins/multi-line.js";
|
|
11
|
+
import { tagsPlugin as v } from "./plugins/tags.js";
|
|
12
|
+
import { crossLinkPlugin as y } from "./plugins/cross-link.js";
|
|
13
|
+
import { allPlugins as b } from "./plugins/index.js";
|
|
14
|
+
export { p as MindMap, b as allPlugins, n as buildExportSVG, r as buildExportSVGForPNG, y as crossLinkPlugin, u as detectLocale, h as dottedLinePlugin, i as exportToPNG, g as foldingPlugin, m as frontMatterPlugin, f as latexPlugin, _ as multiLinePlugin, e as parseInlineMarkdown, a as parseMarkdownList, o as parseMarkdownMultiRoot, s as parseMarkdownWithFrontMatter, d as resolveMessages, t as stripInlineMarkdown, v as tagsPlugin, c as toMarkdownList, l as toMarkdownMultiRoot };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="192px" height="192px" viewBox="0 0 192 192" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
+
<title>192x192@1x</title>
|
|
4
|
+
<g id="192x192" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
5
|
+
<g id="open-mindmap" transform="translate(27, 34)" fill="#FF6B6B">
|
|
6
|
+
<path d="M65.2942453,0.192083517 C59.8455194,1.55726816 56.0732557,5.16121182 54.5364241,10.4696141 C52.70243,16.8043764 55.6897191,23.6276034 61.685779,26.7992536 C63.6786478,27.8534745 64.4640698,27.9981715 68.203216,28 C72.0828879,28.0022158 72.664682,27.8853798 74.8553607,26.6671389 C84.6626198,21.2131409 84.2960895,6.40731353 74.2314984,1.46290056 C71.8349541,0.28555238 67.4240594,-0.341318119 65.2942453,0.192083517 M66.6757112,8.41163667 C65.2714183,8.9725578 63.4030866,11.3751699 63.0901196,13.0223193 C62.4389317,16.4479447 65.4121182,20 68.9305166,20 C73.5641418,20 76.2676535,15.7120696 74.4060861,11.3146261 C73.2746248,8.64134723 69.5776458,7.25284486 66.6757112,8.41163667 M26.9077072,14.3521949 C22.6763866,15.428857 18.6913715,18.6921892 16.9676837,22.4922536 C16.2247148,24.129858 16.0031749,25.5048062 16,28.4986303 C15.9946195,33.1761949 16.9424678,35.5035573 20.1669528,38.728062 C23.1446822,41.7063551 26.2156204,42.8131656 30.6297563,42.4984349 C32.4871786,42.3659648 34.6872671,42.1160988 35.5184918,41.9425173 C36.9400389,41.6465152 37.1885958,41.799541 39.6993805,44.5174618 C42.7000743,47.7670902 44.8141586,51.7407361 45.4868832,55.3973674 C45.7358903,56.7508463 45.9394188,61.1611867 45.9394188,65.1978702 L45.9394188,72.5380836 L56.0118258,82.7844167 C69.0714182,96.0702533 67.1149334,95.8400294 77.5363107,85.3173362 C81.7379125,81.0750958 86.2254447,76.3865681 87.5087547,74.8992488 L89.8421274,72.1941181 L90.0672695,62.9970395 L90.2924116,53.799504 L91.9526094,50.3941091 C93.000871,48.2435257 94.5710119,46.0079787 96.2136487,44.3283493 C98.6429319,41.8443067 98.9203069,41.6876266 100.407596,41.9548507 C101.283398,42.1124445 103.549679,42.3559154 105.444024,42.4966077 C108.535676,42.7254612 109.170126,42.6235963 111.640835,41.4985141 C120.764944,37.3448916 122.890285,25.0562351 115.670429,18.2052474 C112.571122,15.2644114 109.955872,14.1653664 106.017686,14.1484651 C101.716572,14.1301933 97.6009742,16.1053681 95.0095887,19.4308241 C91.9719716,23.329556 91.2299032,27.5160676 92.6302871,32.848674 L93.3926182,35.7502258 L90.041153,39.3186959 C83.8781133,45.8823605 81.9644054,51.3136343 81.9585518,62.2602317 L81.9553998,68.9248477 L77.6434784,73.6069802 C75.2722818,76.1819247 73.0510299,78.2891127 72.7074631,78.2891127 C72.1864842,78.2891127 72.0622058,74.9663974 71.9568393,58.2267458 L71.8307597,38.1639222 L70.7392709,36.9858519 C69.2506313,35.3788527 66.6097145,35.3523587 65.0562341,36.9287528 L63.9507864,38.0497238 L63.9507864,58.1696467 C63.9507864,74.1195024 63.8323617,78.2891127 63.3793758,78.2891127 C63.0650774,78.2891127 60.8555329,76.28516 58.4694769,73.8353769 L54.1305385,69.3816411 L53.9171038,61.616153 C53.7468964,55.4097008 53.5145497,53.2545495 52.7603237,50.8815077 C51.3968632,46.5903903 48.8554592,42.4861015 45.3454939,38.9066683 L42.275006,35.7758062 L43.0630034,33.3936285 C44.9024143,27.8307983 43.5596668,21.9884105 39.5724003,18.2052474 C35.8913271,14.7121481 31.1552379,13.2714217 26.9077072,14.3521949 M27.235249,23.6088612 C21.7500564,26.3640569 23.6694642,35 29.7671564,35 C33.6469267,35 35.9981786,32.7733704 36,29.0976786 C36.001819,25.7316654 33.9099466,23.427279 30.4966042,23.0348995 C29.411761,22.9103989 28.2031438,23.1229939 27.235249,23.6088612 M103.103845,23.7565027 C100.88837,24.9235968 99.7892725,27.0996711 100.033466,29.8358433 C100.197626,31.6746976 100.503208,32.2870535 101.873784,33.5206982 C103.241176,34.7516631 103.871895,35 105.629906,35 C108.463368,35 110.501041,33.7199037 111.475541,31.3276513 C112.365915,29.1421973 112.120812,27.1398695 110.753874,25.4332234 C108.774407,22.9614673 105.835901,22.3173994 103.103845,23.7565027 M11.3176117,51.4490768 C6.67273908,52.3691606 2.55622295,55.8705277 0.905221,60.3055025 C-3.25973528,71.4939189 7.67518117,82.5448412 18.842431,78.4330903 C20.1992038,77.9336034 21.6232547,77.4196909 22.0067392,77.2912128 C22.6216601,77.0851969 37.1940734,87.8210097 51.0802511,98.7109962 L54.9482872,101.744432 L55.1725472,111.557908 L55.3968072,121.370932 L56.8616733,122.685466 L58.3265395,124 L68.6007861,124 L78.8754811,124 L80.2551285,122.832878 L81.6352244,121.665755 L81.6352244,112.019527 L81.6352244,102.373299 L84.8869941,99.6950936 C86.6752431,98.2218777 93.9919491,92.5300712 101.145842,87.0460837 C110.655362,79.7561896 114.394225,77.1338834 115.049961,77.293016 C115.543333,77.4129289 117.158005,77.9511846 118.638121,78.4889896 C125.471322,80.9724492 132.927069,77.708654 136.064915,70.8605443 C136.795554,69.2669647 137.015329,67.9285382 137,65.170541 C136.97541,60.9925224 135.846037,58.2534589 132.953532,55.3584184 C126.117191,48.5166199 114.810003,50.5718192 110.475057,59.4440229 C109.336714,61.7742104 109.225929,62.427871 109.290516,66.4237663 L109.361831,70.8325947 L101.665677,76.6691081 C88.1522193,86.9171548 74.7011059,97.4266657 74.1225152,98.1889693 C73.7197443,98.7191106 73.5618653,101.317975 73.5618653,107.406486 L73.5618653,115.885592 L68.4038858,115.885592 L63.2459063,115.885592 L63.2459063,107.345628 C63.2459063,99.1248311 63.2082307,98.7632891 62.2367364,97.674606 C61.3612255,96.6936642 49.3826031,87.3566852 32.3926673,74.4119503 L27.3629645,70.5801464 L27.7002515,68.7769446 C28.238924,65.8931741 27.9254085,61.9495718 26.9875533,59.818638 C25.889128,57.3234575 23.2634921,54.3869434 20.8984464,53.0088464 C19.4030809,52.1374491 14.5047945,50.8224642 13.4897938,51.0199148 C13.3503041,51.0469628 12.3725306,51.2399054 11.3176117,51.4490768 M10.2857859,59.7135188 C8.1500563,60.7305963 7.00185926,62.7045033 7,65.3625611 C6.99816582,67.2918398 7.19853475,67.7283039 8.79040584,69.2675318 C10.4159795,70.8388921 10.8079455,71 13,71 C15.1920545,71 15.5840205,70.8388921 17.2095942,69.2675318 C18.8014653,67.7283039 19.0018342,67.2918398 19,65.3625611 C18.9981407,62.6696932 17.8300915,60.7006954 15.639422,59.6956675 C13.6057236,58.7629373 12.2728547,58.7674002 10.2857859,59.7135188 M120.527041,59.6974997 C117.432794,61.2687562 116.166924,64.6438655 117.568696,67.5851537 C119.606327,71.8619653 125.604018,72.1945016 128.101556,68.1695572 C129.309374,66.2236371 129.299474,64.1903254 128.071405,62.0144981 C126.449581,59.1408823 123.441735,58.21722 120.527041,59.6974997" id="形状"></path>
|
|
7
|
+
</g>
|
|
8
|
+
</g>
|
|
9
|
+
</svg>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region src/components/MindMap/plugins/cross-link.ts
|
|
2
|
+
var e = /\{#([\w-]+)\}/, t = /(-?\.?)>\s*\{#([\w-]+)\}(?:\s+"([^"]*)")?/g, n = {
|
|
3
|
+
name: "cross-link",
|
|
4
|
+
transformNodeData(n) {
|
|
5
|
+
let r = n.text, i, a = [], o = new RegExp(t.source, "g"), s;
|
|
6
|
+
for (; (s = o.exec(r)) !== null;) {
|
|
7
|
+
let e = s[1] === "-.";
|
|
8
|
+
a.push({
|
|
9
|
+
targetAnchorId: s[2],
|
|
10
|
+
label: s[3] || void 0,
|
|
11
|
+
dotted: e
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
r = r.replace(new RegExp(t.source, "g"), "").trim();
|
|
15
|
+
let c = r.match(e);
|
|
16
|
+
return c && (i = c[1], r = r.replace(e, "").trim()), i || a.length > 0 ? {
|
|
17
|
+
...n,
|
|
18
|
+
text: r,
|
|
19
|
+
...i ? { anchorId: i } : {},
|
|
20
|
+
...a.length > 0 ? { crossLinks: a } : {}
|
|
21
|
+
} : n;
|
|
22
|
+
},
|
|
23
|
+
serializeNodeText(e, t) {
|
|
24
|
+
let n = t;
|
|
25
|
+
if (e.anchorId && (n += ` {#${e.anchorId}}`), e.crossLinks) for (let t of e.crossLinks) {
|
|
26
|
+
let e = t.dotted ? "-.>" : "->";
|
|
27
|
+
n += ` ${e} {#${t.targetAnchorId}}`, t.label && (n += ` "${t.label}"`);
|
|
28
|
+
}
|
|
29
|
+
return n;
|
|
30
|
+
},
|
|
31
|
+
generateExtraEdges(e, t) {
|
|
32
|
+
let n = [], i = /* @__PURE__ */ new Map();
|
|
33
|
+
for (let t of e) t.anchorId && i.set(t.anchorId, t);
|
|
34
|
+
function a(t) {
|
|
35
|
+
if (t.crossLinks) {
|
|
36
|
+
let a = e.find((e) => e.id === t.id);
|
|
37
|
+
if (a) for (let e of t.crossLinks) {
|
|
38
|
+
let t = i.get(e.targetAnchorId);
|
|
39
|
+
if (t) {
|
|
40
|
+
let i = r(a, t);
|
|
41
|
+
n.push({
|
|
42
|
+
key: `xlink-${a.id}-${t.id}`,
|
|
43
|
+
path: i,
|
|
44
|
+
color: a.color,
|
|
45
|
+
fromId: a.id,
|
|
46
|
+
toId: t.id,
|
|
47
|
+
strokeDasharray: "6 4",
|
|
48
|
+
isCrossLink: !0,
|
|
49
|
+
label: e.label
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (t.children) for (let e of t.children) a(e);
|
|
55
|
+
}
|
|
56
|
+
for (let e of t) a(e);
|
|
57
|
+
return n;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
function r(e, t) {
|
|
61
|
+
let n = e.x, r = e.y, i = t.x, a = t.y, o = i - n, s = a - r, c = Math.sqrt(o * o + s * s), l = (n + i) / 2, u = (r + a) / 2, d = Math.min(c * .3, 60), f = -s / c, p = o / c;
|
|
62
|
+
return `M ${n},${r} Q ${l + f * d},${u + p * d} ${i},${a}`;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { n as crossLinkPlugin };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/components/MindMap/plugins/dotted-line.ts
|
|
2
|
+
var e = {
|
|
3
|
+
name: "dotted-line",
|
|
4
|
+
parseLine(e) {
|
|
5
|
+
let t = e.match(/^(\s*)-\.\s+(.+)/);
|
|
6
|
+
return t ? {
|
|
7
|
+
indent: t[1].replace(/\t/g, " ").length,
|
|
8
|
+
text: t[2].trim(),
|
|
9
|
+
dottedLine: !0
|
|
10
|
+
} : null;
|
|
11
|
+
},
|
|
12
|
+
serializeListMarker(e, t) {
|
|
13
|
+
return e.dottedLine ? "-. " : t;
|
|
14
|
+
},
|
|
15
|
+
transformEdge(e, t, n) {
|
|
16
|
+
return n.dottedLine ? {
|
|
17
|
+
...e,
|
|
18
|
+
strokeDasharray: "6 4"
|
|
19
|
+
} : e;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { e as dottedLinePlugin };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/components/MindMap/plugins/folding.ts
|
|
2
|
+
var e = {
|
|
3
|
+
name: "folding",
|
|
4
|
+
parseLine(e) {
|
|
5
|
+
let t = e.match(/^(\s*)\+\s+(.+)/);
|
|
6
|
+
return t ? {
|
|
7
|
+
indent: t[1].replace(/\t/g, " ").length,
|
|
8
|
+
text: t[2].trim(),
|
|
9
|
+
collapsed: !0
|
|
10
|
+
} : null;
|
|
11
|
+
},
|
|
12
|
+
serializeListMarker(e, t) {
|
|
13
|
+
return e.collapsed ? "+ " : t;
|
|
14
|
+
},
|
|
15
|
+
filterChildren(e, t, n) {
|
|
16
|
+
return !n.readonly || !e.collapsed || n.foldOverrides[e.id] ? t : [];
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { e as foldingPlugin };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/components/MindMap/plugins/front-matter.ts
|
|
2
|
+
var e = {
|
|
3
|
+
name: "front-matter",
|
|
4
|
+
preParseMarkdown(e, t) {
|
|
5
|
+
let n = e.match(/^---\n([\s\S]*?)\n---\n?/);
|
|
6
|
+
if (!n) return e;
|
|
7
|
+
let r = n[1];
|
|
8
|
+
for (let e of r.split("\n")) {
|
|
9
|
+
let n = e.match(/^(\w[\w-]*)\s*:\s*(.+)/);
|
|
10
|
+
n && (t.frontMatter[n[1].trim()] = n[2].trim());
|
|
11
|
+
}
|
|
12
|
+
return e.slice(n[0].length);
|
|
13
|
+
},
|
|
14
|
+
serializePreamble(e) {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { e as frontMatterPlugin };
|