flow-mindmap 0.1.1-beta.1 → 0.1.1-beta.2
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 +50 -1
- package/dist/core/layout.d.ts +9 -0
- package/dist/flow-mindmap.js +69 -69
- package/dist/flow-mindmap.umd.cjs +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,48 @@ const data: MindMapNode = {
|
|
|
62
62
|
</template>
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
### 从 Markdown 渲染
|
|
66
|
+
|
|
67
|
+
```vue
|
|
68
|
+
<script setup lang="ts">
|
|
69
|
+
import { ref } from 'vue'
|
|
70
|
+
import { MindMap } from 'flow-mindmap'
|
|
71
|
+
import 'flow-mindmap/style.css'
|
|
72
|
+
|
|
73
|
+
const md = ref(`# 项目计划
|
|
74
|
+
|
|
75
|
+
## 第一阶段
|
|
76
|
+
|
|
77
|
+
调研 / 设计
|
|
78
|
+
|
|
79
|
+
## 第二阶段
|
|
80
|
+
|
|
81
|
+
实现
|
|
82
|
+
|
|
83
|
+
## 第三阶段
|
|
84
|
+
|
|
85
|
+
上线`)
|
|
86
|
+
|
|
87
|
+
// 监听变化把 markdown 同步回外部存储(可选)
|
|
88
|
+
function onMdChange(next: string) {
|
|
89
|
+
// 写入 localStorage / autosave / 远端等
|
|
90
|
+
console.log('md changed, length =', next.length)
|
|
91
|
+
}
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<template>
|
|
95
|
+
<MindMap
|
|
96
|
+
:markdown="md"
|
|
97
|
+
:theme="{ fontSize: 16, rainbowBranch: true }"
|
|
98
|
+
:line-colors="['#5eead4', '#fbbf24', '#f472b6', '#a78bfa']"
|
|
99
|
+
@markdown-change="onMdChange"
|
|
100
|
+
style="width: 100vw; height: 100vh"
|
|
101
|
+
/>
|
|
102
|
+
</template>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`markdown` prop 接受标准 markdown:`# / ## / ###` 作为节点层级;紧跟 heading 的 `[label](url)` 作为节点的 link;` ```note ... ``` ` 围栏作为节点的 note;`` 作为图片。改节点文字会自动 emit `markdownChange`,你可以把它写回输入框或远端。
|
|
106
|
+
|
|
65
107
|
## Props
|
|
66
108
|
|
|
67
109
|
| Prop | Type | Default | 说明 |
|
|
@@ -70,6 +112,8 @@ const data: MindMapNode = {
|
|
|
70
112
|
| `readonly` | `boolean` | `false` | 只读模式:禁用增删改、拖拽、编辑输入框。 |
|
|
71
113
|
| `previewMode` | `boolean` | `false` | 预览模式:隐藏画布自带工具栏,只保留节点和折叠/调整手柄。适合做截图、嵌入展示。 |
|
|
72
114
|
| `theme` | [`MindMapTheme`](#数据类型) | — | 主题色/字号/连线粗细等外观配置,见下表。 |
|
|
115
|
+
| `markdown` | `string` | — | 可选:传入 markdown 文本,内部解析为 `data`。**与 `data` 二选一**,传了 `markdown` 后 `data` 被忽略。双向同步:数据变化时通过 `markdownChange` 事件回传序列化结果。 |
|
|
116
|
+
| `lineColors` | `string[]` | — | 可选:顶层分支**连线**颜色列表(hex / rgb / 命名色)。优先级高于 `branchPaletteId` / `customPalettes`;留空走 palette 流程。 |
|
|
73
117
|
|
|
74
118
|
### `MindMapTheme` 字段
|
|
75
119
|
|
|
@@ -81,7 +125,7 @@ const data: MindMapNode = {
|
|
|
81
125
|
| `branchText` | `string` | — | 普通节点文字色 |
|
|
82
126
|
| `lineColor` | `string` | — | 连线颜色 |
|
|
83
127
|
| `bgColor` | `string` | — | 画布背景色 |
|
|
84
|
-
| `fontSize` | `number` |
|
|
128
|
+
| `fontSize` | `number` | `14` | 基础字号(px)。**节点的实际尺寸(高度/最小宽度/内边距/文本宽度)会按 `fontSize / 14` 等比缩放**——`fontSize=28` 时所有节点都会变成两倍大;`fontSize=10` 时一半。 |
|
|
85
129
|
| `lineWidthStart` | `number` | `2.2` | 父端连线粗细(px) |
|
|
86
130
|
| `lineWidthEnd` | `number` | `0.8` | 子端连线粗细(px) |
|
|
87
131
|
| `rainbowBranch` | `boolean` | `false` | 顶层分支按色板循环配色 |
|
|
@@ -93,6 +137,7 @@ const data: MindMapNode = {
|
|
|
93
137
|
| `change` | `MindMapNode` | 数据变更(增删改、导入、拖动)后触发,载荷是**新的整棵根节点**。 |
|
|
94
138
|
| `select` | `MindMapNode \| null` | 用户点击节点时触发;`null` 表示点空白处取消选中。 |
|
|
95
139
|
| `edit-note` | `nodeId: string` | 用户点击节点笔记图标 / 右键"添加/编辑笔记"时触发,由父组件决定如何展示笔记编辑界面。 |
|
|
140
|
+
| `markdownChange` | `markdown: string` | 当使用了 `markdown` prop 且内部数据变化时触发,载荷是重新序列化后的 markdown 文本。`markdown` prop 写入触发时**不会**回环 emit。 |
|
|
96
141
|
|
|
97
142
|
## Expose 方法(通过 `ref` 访问)
|
|
98
143
|
|
|
@@ -148,6 +193,8 @@ mm.value.addChild('a') // 给 id=a 的节点加一个子节点
|
|
|
148
193
|
| ---- | ---- |
|
|
149
194
|
| `exportData()` | 返回当前数据的 JSON 字符串。 |
|
|
150
195
|
| `importData(json)` | 从 JSON 字符串恢复数据,成功返回 `true`。 |
|
|
196
|
+
| `getMarkdown()` | 返回当前数据序列化后的 markdown 字符串。 |
|
|
197
|
+
| `setMarkdown(md, emitMarkdownChange?)` | 用 markdown 解析结果替换数据。`emitMarkdownChange` 默认 `true`,传 `false` 可避免回环(比如用 `markdown` prop 接收外部值后写回时)。 |
|
|
151
198
|
|
|
152
199
|
### 设置项
|
|
153
200
|
|
|
@@ -268,6 +315,8 @@ import {
|
|
|
268
315
|
removeNode, // (root, id) => 移除子树
|
|
269
316
|
addChild, // (parent, text) => 新子节点
|
|
270
317
|
addSibling, // (node, text) => 新同级节点
|
|
318
|
+
markdownToMindMap, // (md, rootText?) => MindMapNode — 与 MindMap 内部解析逻辑一致
|
|
319
|
+
mindMapToMarkdown, // (node, depth?) => string — 与 MindMap 内部序列化逻辑一致
|
|
271
320
|
} from 'flow-mindmap'
|
|
272
321
|
```
|
|
273
322
|
|
package/dist/core/layout.d.ts
CHANGED
|
@@ -54,6 +54,15 @@ import type { MindMapNode, MindMapImage } from '../types';
|
|
|
54
54
|
* roughly 2.14× larger nodes. */
|
|
55
55
|
declare function fontAt(depth: number, baseFontSize?: number): number;
|
|
56
56
|
declare function heightAt(depth: number, baseFontSize?: number): number;
|
|
57
|
+
/** Max text-label width in px. MUST match `max-width` on `.zm-text`
|
|
58
|
+
* in MindMap.vue. The layout reserves this much room for the label
|
|
59
|
+
* regardless of how long the actual text is — the DOM then truncates
|
|
60
|
+
* with `text-overflow: ellipsis`. Without this cap, a long string
|
|
61
|
+
* pushes the rendered node box past the layout's reserved width and
|
|
62
|
+
* the line anchor (computed from layout width) ends up inside the
|
|
63
|
+
* box. The 200px default is the same value `flow-mindmap` shipped
|
|
64
|
+
* with before; keeping it keeps edge anchors stable. */
|
|
65
|
+
export declare const TEXT_MAX_W = 200;
|
|
57
66
|
export type LayoutMode = 'mindmap' | 'tree' | 'org';
|
|
58
67
|
export interface LayoutOptions {
|
|
59
68
|
mode?: LayoutMode;
|
package/dist/flow-mindmap.js
CHANGED
|
@@ -226,12 +226,12 @@ function Kn(n, s, o) {
|
|
|
226
226
|
const c = d.measureText(n).width;
|
|
227
227
|
return Ft.set(i, c), c;
|
|
228
228
|
}
|
|
229
|
-
const Un = 24, Gn = 400, jn = 8, Vt = 16, Jn = 4;
|
|
230
|
-
function
|
|
229
|
+
const Un = 24, Gn = 400, jn = 8, Vt = 16, Jn = 4, Zn = 200;
|
|
230
|
+
function Qn(n, s, o) {
|
|
231
231
|
return Math.min(o, Math.max(s, n));
|
|
232
232
|
}
|
|
233
|
-
function
|
|
234
|
-
const i = Ze(s), a = ft(s, o), d = Kn(n.text || "", a, Pn[i]), c = Xn(s, o), x = Math.ceil(d + c * 2), m = qn(s, o);
|
|
233
|
+
function _n(n, s, o) {
|
|
234
|
+
const i = Ze(s), a = ft(s, o), d = Math.min(Kn(n.text || "", a, Pn[i]), Zn), c = Xn(s, o), x = Math.ceil(d + c * 2), m = qn(s, o);
|
|
235
235
|
let h = 0;
|
|
236
236
|
if (n.link && (h += Vt), n.note && (h += Vt), h > 0) {
|
|
237
237
|
const U = (n.link ? 1 : 0) + (n.note ? 1 : 0);
|
|
@@ -240,14 +240,14 @@ function Qn(n, s, o) {
|
|
|
240
240
|
const u = x + h, p = Math.round(On[i] * o / 14);
|
|
241
241
|
if (!n.image)
|
|
242
242
|
return { w: Math.max(p, u), h: m };
|
|
243
|
-
const S =
|
|
243
|
+
const S = Qn(n.image.width, Un, Gn), b = Math.max(p, u, Math.ceil(S + c * 2)), A = Math.ceil(n.image.height + jn + m);
|
|
244
244
|
return { w: b, h: A };
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function ei(n, s = {}) {
|
|
247
247
|
const o = s.mode ?? "mindmap", i = s.preservePositions === !0, a = s.baseFontSize ?? 14, d = Ut(n, 0, null, 1, "right", a);
|
|
248
|
-
return
|
|
248
|
+
return ni(d), ti(d, o, i), d.x = 0, d.y = 0, ii(d, i);
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function ti(n, s, o = !1) {
|
|
251
251
|
if (s === "mindmap") {
|
|
252
252
|
const i = n.children;
|
|
253
253
|
if (i.length !== 0) if (i.length === 1)
|
|
@@ -315,7 +315,7 @@ function Kt(n, s, o = !1) {
|
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
317
|
function Ut(n, s, o, i, a, d) {
|
|
318
|
-
const c =
|
|
318
|
+
const c = _n(n, s, d), x = {
|
|
319
319
|
id: n.id,
|
|
320
320
|
text: n.text,
|
|
321
321
|
depth: s,
|
|
@@ -347,7 +347,7 @@ function Ut(n, s, o, i, a, d) {
|
|
|
347
347
|
return Ut(u, s + 1, x, S, a, d);
|
|
348
348
|
}), x;
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function ni(n) {
|
|
351
351
|
const s = [n];
|
|
352
352
|
for (let o = 0; o < s.length; o++) {
|
|
353
353
|
const i = s[o];
|
|
@@ -365,7 +365,7 @@ function ti(n) {
|
|
|
365
365
|
i.children.length > 1 && (a += $e * (i.children.length - 1), d += $e * 2 * (i.children.length - 1)), i._subtreeH = Math.max(i.height, a), i._subtreeW = Math.max(i.width, d);
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
-
function
|
|
368
|
+
function ii(n, s = !1) {
|
|
369
369
|
const o = [n];
|
|
370
370
|
let i = 1 / 0, a = -1 / 0, d = 1 / 0, c = -1 / 0;
|
|
371
371
|
for (; o.length; ) {
|
|
@@ -469,7 +469,7 @@ const Pe = [
|
|
|
469
469
|
]
|
|
470
470
|
}
|
|
471
471
|
];
|
|
472
|
-
function
|
|
472
|
+
function oi(n, s = []) {
|
|
473
473
|
return [...Pe, ...s].find((i) => i.id === n) ?? Pe[0];
|
|
474
474
|
}
|
|
475
475
|
function we() {
|
|
@@ -502,11 +502,11 @@ function Gt(n, s) {
|
|
|
502
502
|
if (Gt(i, s)) return !0;
|
|
503
503
|
return !1;
|
|
504
504
|
}
|
|
505
|
-
function
|
|
505
|
+
function li(n, s, o) {
|
|
506
506
|
const i = B(n, s);
|
|
507
507
|
return !i || i.text === o ? !1 : (i.text = o, !0);
|
|
508
508
|
}
|
|
509
|
-
function
|
|
509
|
+
function ri(n, s, o, i) {
|
|
510
510
|
if (!ae(n, s) || s === o || B(B(n, s), o)) return !1;
|
|
511
511
|
const a = ae(n, s), d = a.children.findIndex((h) => h.id === s);
|
|
512
512
|
if (d < 0) return !1;
|
|
@@ -535,13 +535,13 @@ function jt(n) {
|
|
|
535
535
|
}
|
|
536
536
|
return o === 0 && !i ? Je : o > 0 ? `新节点 ${o + 1}` : "新节点 2";
|
|
537
537
|
}
|
|
538
|
-
function
|
|
538
|
+
function ai(n, s, o) {
|
|
539
539
|
const i = B(n, s);
|
|
540
540
|
if (!i) return null;
|
|
541
541
|
const a = { id: we(), text: o ?? jt(i), children: [] };
|
|
542
542
|
return i.children.push(a), a;
|
|
543
543
|
}
|
|
544
|
-
function
|
|
544
|
+
function ui(n, s, o) {
|
|
545
545
|
const i = ae(n, s);
|
|
546
546
|
if (!i) return null;
|
|
547
547
|
const a = i.children.findIndex((c) => c.id === s);
|
|
@@ -549,7 +549,7 @@ function ai(n, s, o) {
|
|
|
549
549
|
const d = { id: we(), text: o ?? jt(i), children: [] };
|
|
550
550
|
return i.children.splice(a + 1, 0, d), d;
|
|
551
551
|
}
|
|
552
|
-
function
|
|
552
|
+
function si(n, s, o) {
|
|
553
553
|
const i = ae(n, s);
|
|
554
554
|
if (!i) return null;
|
|
555
555
|
const a = i.children.findIndex((c) => c.id === s);
|
|
@@ -557,7 +557,7 @@ function ui(n, s, o) {
|
|
|
557
557
|
const d = { id: we(), text: o, children: [] };
|
|
558
558
|
return i.children.splice(a, 0, d), d;
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function di(n, s) {
|
|
561
561
|
const o = ae(n, s);
|
|
562
562
|
if (!o) return null;
|
|
563
563
|
const i = o.children.findIndex((c) => c.id === s);
|
|
@@ -653,7 +653,7 @@ function st(n, s = 1) {
|
|
|
653
653
|
for (const i of n.children) o += st(i, s + 1);
|
|
654
654
|
return o;
|
|
655
655
|
}
|
|
656
|
-
function
|
|
656
|
+
function ci(n) {
|
|
657
657
|
const s = n.minScale ?? 0.2, o = n.maxScale ?? 3, i = n.step ?? 1.2, a = D(1), d = D(0), c = D(0), x = D(!1), m = Ge({
|
|
658
658
|
x: 0,
|
|
659
659
|
y: 0,
|
|
@@ -729,11 +729,11 @@ function di(n) {
|
|
|
729
729
|
resetView: me
|
|
730
730
|
};
|
|
731
731
|
}
|
|
732
|
-
const
|
|
732
|
+
const fi = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform);
|
|
733
733
|
function qt(n) {
|
|
734
|
-
return
|
|
734
|
+
return fi ? n.metaKey : n.ctrlKey;
|
|
735
735
|
}
|
|
736
|
-
function
|
|
736
|
+
function vi(n) {
|
|
737
737
|
function s() {
|
|
738
738
|
const i = n.getSelectedId();
|
|
739
739
|
return i || (n.defaultTargetId ? n.defaultTargetId() : n.getRootId());
|
|
@@ -774,7 +774,7 @@ function fi(n) {
|
|
|
774
774
|
window.removeEventListener("keydown", o);
|
|
775
775
|
});
|
|
776
776
|
}
|
|
777
|
-
function
|
|
777
|
+
function hi(n = 100) {
|
|
778
778
|
const s = D([]);
|
|
779
779
|
let o = -1;
|
|
780
780
|
function i() {
|
|
@@ -806,7 +806,7 @@ function vi(n = 100) {
|
|
|
806
806
|
reset: m
|
|
807
807
|
};
|
|
808
808
|
}
|
|
809
|
-
const
|
|
809
|
+
const mi = ["disabled"], gi = ["disabled"], yi = ["disabled"], xi = ["disabled"], pi = ["disabled"], bi = ["disabled"], wi = /* @__PURE__ */ dt({
|
|
810
810
|
__name: "NodeContextMenu",
|
|
811
811
|
props: {
|
|
812
812
|
x: {},
|
|
@@ -859,7 +859,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
859
859
|
size: 13
|
|
860
860
|
}),
|
|
861
861
|
y("span", null, be(d.value ? "替换图片" : "添加图片"), 1)
|
|
862
|
-
], 8,
|
|
862
|
+
], 8, mi),
|
|
863
863
|
d.value ? (M(), C("button", {
|
|
864
864
|
key: 0,
|
|
865
865
|
class: "zm-node-menu-item",
|
|
@@ -871,7 +871,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
871
871
|
size: 13
|
|
872
872
|
}),
|
|
873
873
|
b[7] || (b[7] = y("span", null, "移除图片", -1))
|
|
874
|
-
], 8,
|
|
874
|
+
], 8, gi)) : O("", !0),
|
|
875
875
|
y("button", {
|
|
876
876
|
class: "zm-node-menu-item",
|
|
877
877
|
disabled: n.readonly,
|
|
@@ -882,7 +882,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
882
882
|
size: 13
|
|
883
883
|
}),
|
|
884
884
|
y("span", null, be(c.value ? "编辑链接" : "添加链接"), 1)
|
|
885
|
-
], 8,
|
|
885
|
+
], 8, yi),
|
|
886
886
|
c.value ? (M(), C("button", {
|
|
887
887
|
key: 1,
|
|
888
888
|
class: "zm-node-menu-item",
|
|
@@ -894,7 +894,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
894
894
|
size: 13
|
|
895
895
|
}),
|
|
896
896
|
b[8] || (b[8] = y("span", null, "移除链接", -1))
|
|
897
|
-
], 8,
|
|
897
|
+
], 8, xi)) : O("", !0),
|
|
898
898
|
y("button", {
|
|
899
899
|
class: "zm-node-menu-item",
|
|
900
900
|
disabled: n.readonly,
|
|
@@ -905,7 +905,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
905
905
|
size: 13
|
|
906
906
|
}),
|
|
907
907
|
y("span", null, be(x.value ? "编辑笔记" : "添加笔记"), 1)
|
|
908
|
-
], 8,
|
|
908
|
+
], 8, pi),
|
|
909
909
|
x.value ? (M(), C("button", {
|
|
910
910
|
key: 2,
|
|
911
911
|
class: "zm-node-menu-item",
|
|
@@ -917,16 +917,16 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
917
917
|
size: 13
|
|
918
918
|
}),
|
|
919
919
|
b[9] || (b[9] = y("span", null, "移除笔记", -1))
|
|
920
|
-
], 8,
|
|
920
|
+
], 8, bi)) : O("", !0)
|
|
921
921
|
], 36));
|
|
922
922
|
}
|
|
923
|
-
}),
|
|
923
|
+
}), ki = ["viewBox", "width", "height"], Mi = { class: "zm-edges" }, Ci = ["d", "fill"], Si = ["data-node-id", "onClick", "onDblclick", "onContextmenu", "onMouseenter", "onMouseleave"], Ei = ["src", "width", "height", "alt"], zi = {
|
|
924
924
|
key: 1,
|
|
925
925
|
class: "zm-text"
|
|
926
|
-
},
|
|
926
|
+
}, Ni = { class: "zm-text-label" }, Ii = ["href", "title"], Wi = ["title", "onClick"], $i = ["title"], Bi = ["title", "onClick"], Ri = ["onClick"], Ai = ["onMousedown"], Li = ["onClick"], Hi = {
|
|
927
927
|
key: 0,
|
|
928
928
|
class: "zm-toolbar"
|
|
929
|
-
},
|
|
929
|
+
}, Di = ["src"], Pi = ["src"], Ti = { class: "zm-tb-tip" }, We = 24, De = 400, pe = 160, Oi = /* @__PURE__ */ dt({
|
|
930
930
|
__name: "MindMap",
|
|
931
931
|
props: {
|
|
932
932
|
data: {},
|
|
@@ -1151,7 +1151,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1151
1151
|
function nn(e) {
|
|
1152
1152
|
Qe.value === e && (Qe.value = null);
|
|
1153
1153
|
}
|
|
1154
|
-
const yt = D(0), et = D(!1), fe =
|
|
1154
|
+
const yt = D(0), et = D(!1), fe = hi(100);
|
|
1155
1155
|
function K() {
|
|
1156
1156
|
fe.record({ data: u.value });
|
|
1157
1157
|
}
|
|
@@ -1236,7 +1236,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1236
1236
|
return `M ${At.x.toFixed(2)} ${At.y.toFixed(2)} L ${Dt.x.toFixed(2)} ${Dt.y.toFixed(2)} L ${Ht.x.toFixed(2)} ${Ht.y.toFixed(2)} L ${Lt.x.toFixed(2)} ${Lt.y.toFixed(2)} Z`;
|
|
1237
1237
|
}
|
|
1238
1238
|
const Te = Q(() => ee.value.root.children), an = Pe[0].colors, wt = Q(
|
|
1239
|
-
() =>
|
|
1239
|
+
() => oi(k.branchPaletteId, k.customPalettes)
|
|
1240
1240
|
), ge = Q(() => {
|
|
1241
1241
|
const e = /* @__PURE__ */ new Map();
|
|
1242
1242
|
if (!k.rainbowBranch) return e;
|
|
@@ -1299,8 +1299,8 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1299
1299
|
const r = e.replace("#", ""), v = r.length === 6 ? r : r.split("").map(($) => $ + $).join(""), f = Math.round(parseInt(v.slice(0, 2), 16) * (1 - t)), l = Math.round(parseInt(v.slice(2, 4), 16) * (1 - t)), g = Math.round(parseInt(v.slice(4, 6), 16) * (1 - t));
|
|
1300
1300
|
return `rgb(${f}, ${l}, ${g})`;
|
|
1301
1301
|
}
|
|
1302
|
-
const E =
|
|
1303
|
-
E.setOnMarqueeEnd(Cn),
|
|
1302
|
+
const E = ci({ getContainer: () => d.value });
|
|
1303
|
+
E.setOnMarqueeEnd(Cn), vi({
|
|
1304
1304
|
isEditing: () => c.value !== null,
|
|
1305
1305
|
isReadonly: () => i.readonly,
|
|
1306
1306
|
getSelectedId: () => m.value,
|
|
@@ -1328,7 +1328,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1328
1328
|
});
|
|
1329
1329
|
const ee = Q(() => {
|
|
1330
1330
|
const e = he(u.value);
|
|
1331
|
-
return Ct(e),
|
|
1331
|
+
return Ct(e), ei(e, { mode: k.layoutMode, baseFontSize: oe.value.fontSize });
|
|
1332
1332
|
}), Mt = D([]), tt = Q(() => (yt.value, Mt.value));
|
|
1333
1333
|
Ye(
|
|
1334
1334
|
ee,
|
|
@@ -1380,7 +1380,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1380
1380
|
t && (e.key === "z" || e.key === "Z") && !e.shiftKey ? (e.preventDefault(), nt()) : (t && e.shiftKey && (e.key === "z" || e.key === "Z") || t && (e.key === "y" || e.key === "Y") && !e.shiftKey) && (e.preventDefault(), it());
|
|
1381
1381
|
}
|
|
1382
1382
|
function Ce(e) {
|
|
1383
|
-
const t =
|
|
1383
|
+
const t = ai(u.value, e, Je);
|
|
1384
1384
|
t && (K(), H(), a("change", u.value), Z(() => Ae(t.id)));
|
|
1385
1385
|
}
|
|
1386
1386
|
function Fe(e) {
|
|
@@ -1388,7 +1388,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1388
1388
|
Ce(e);
|
|
1389
1389
|
return;
|
|
1390
1390
|
}
|
|
1391
|
-
const t =
|
|
1391
|
+
const t = ui(u.value, e, Je);
|
|
1392
1392
|
t && (K(), H(), a("change", u.value), Z(() => Ae(t.id)));
|
|
1393
1393
|
}
|
|
1394
1394
|
function St(e) {
|
|
@@ -1396,12 +1396,12 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1396
1396
|
Ce(e);
|
|
1397
1397
|
return;
|
|
1398
1398
|
}
|
|
1399
|
-
const t =
|
|
1399
|
+
const t = si(u.value, e, Je);
|
|
1400
1400
|
t && (K(), H(), a("change", u.value), Z(() => Ae(t.id)));
|
|
1401
1401
|
}
|
|
1402
1402
|
function Et(e) {
|
|
1403
1403
|
if (e === u.value.id) return;
|
|
1404
|
-
const t =
|
|
1404
|
+
const t = di(u.value, e);
|
|
1405
1405
|
t && (K(), m.value = t.id, a("change", u.value), H());
|
|
1406
1406
|
}
|
|
1407
1407
|
function nt() {
|
|
@@ -1445,10 +1445,10 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1445
1445
|
h.value.has(e) ? h.value.delete(e) : h.value.add(e), H();
|
|
1446
1446
|
}
|
|
1447
1447
|
function pn(e, t) {
|
|
1448
|
-
|
|
1448
|
+
li(u.value, e, t) && (K(), H(), a("change", u.value));
|
|
1449
1449
|
}
|
|
1450
1450
|
function bn(e, t, r) {
|
|
1451
|
-
return
|
|
1451
|
+
return ri(u.value, e, t, r) ? (K(), H(), a("change", u.value), !0) : !1;
|
|
1452
1452
|
}
|
|
1453
1453
|
function wn(e, t) {
|
|
1454
1454
|
e.stopPropagation(), m.value = t.id;
|
|
@@ -1668,15 +1668,15 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1668
1668
|
width: ee.value.vbW * z(E).scale.value,
|
|
1669
1669
|
height: ee.value.vbH * z(E).scale.value
|
|
1670
1670
|
}, [
|
|
1671
|
-
y("g",
|
|
1671
|
+
y("g", Mi, [
|
|
1672
1672
|
(M(!0), C(P, null, Ot(hn.value, (l) => (M(), C("path", {
|
|
1673
1673
|
key: l.key,
|
|
1674
1674
|
d: rn($t(l.from, "out", l.to.side, l.to), $t(l.to, "in"), xt(l.from.depth), pt(l.to.depth), 32, k.lineStyle, l.to._dir),
|
|
1675
1675
|
fill: un(l.from, l.to),
|
|
1676
1676
|
stroke: "none"
|
|
1677
|
-
}, null, 8,
|
|
1677
|
+
}, null, 8, Ci))), 128))
|
|
1678
1678
|
])
|
|
1679
|
-
], 8,
|
|
1679
|
+
], 8, ki))
|
|
1680
1680
|
], 4),
|
|
1681
1681
|
z(E).isMarquee.value ? (M(), C("div", {
|
|
1682
1682
|
key: 0,
|
|
@@ -1733,9 +1733,9 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1733
1733
|
height: l.image.height,
|
|
1734
1734
|
alt: l.text,
|
|
1735
1735
|
draggable: "false"
|
|
1736
|
-
}, null, 8,
|
|
1737
|
-
c.value !== l.id ? (M(), C("span",
|
|
1738
|
-
y("span",
|
|
1736
|
+
}, null, 8, Ei)) : O("", !0),
|
|
1737
|
+
c.value !== l.id ? (M(), C("span", zi, [
|
|
1738
|
+
y("span", Ni, be(l.text), 1),
|
|
1739
1739
|
l.link && !c.value ? (M(), C("a", {
|
|
1740
1740
|
key: 0,
|
|
1741
1741
|
class: "zm-node-link",
|
|
@@ -1753,7 +1753,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1753
1753
|
size: 11,
|
|
1754
1754
|
stroke: 2
|
|
1755
1755
|
})
|
|
1756
|
-
], 40,
|
|
1756
|
+
], 40, Ii)) : O("", !0),
|
|
1757
1757
|
l.note && !c.value ? (M(), C("button", {
|
|
1758
1758
|
key: 1,
|
|
1759
1759
|
class: "zm-node-note-btn",
|
|
@@ -1768,7 +1768,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1768
1768
|
size: 11,
|
|
1769
1769
|
stroke: 2
|
|
1770
1770
|
})
|
|
1771
|
-
], 40,
|
|
1771
|
+
], 40, Wi)) : O("", !0)
|
|
1772
1772
|
])) : Wn((M(), C("input", {
|
|
1773
1773
|
key: 2,
|
|
1774
1774
|
class: "zm-input",
|
|
@@ -1793,7 +1793,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1793
1793
|
key: 3,
|
|
1794
1794
|
class: "zm-order-badge",
|
|
1795
1795
|
title: `数据顺序:第 ${Wt(l.id) + 1} 个`
|
|
1796
|
-
}, be(Wt(l.id) + 1), 9,
|
|
1796
|
+
}, be(Wt(l.id) + 1), 9, $i)) : O("", !0),
|
|
1797
1797
|
It(l.id) && !l.isRoot && ot(l.id) > 0 ? (M(), C("span", {
|
|
1798
1798
|
key: 4,
|
|
1799
1799
|
class: Ie(["zm-collapse-badge", { "is-on-left": l.side === -1 }]),
|
|
@@ -1802,7 +1802,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1802
1802
|
onMousedown: t[10] || (t[10] = R(() => {
|
|
1803
1803
|
}, ["stop"])),
|
|
1804
1804
|
onClick: R((g) => Nt(l.id), ["stop"])
|
|
1805
|
-
}, be(ot(l.id)), 47,
|
|
1805
|
+
}, be(ot(l.id)), 47, Bi)) : O("", !0),
|
|
1806
1806
|
!n.readonly && !l.isRoot && Sn(l) && !It(l.id) ? (M(), C("button", {
|
|
1807
1807
|
key: 5,
|
|
1808
1808
|
class: Ie(["zm-btn zm-collapse", { "is-on-left": l.side === -1 }]),
|
|
@@ -1817,13 +1817,13 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1817
1817
|
size: 10,
|
|
1818
1818
|
stroke: 2.4
|
|
1819
1819
|
})
|
|
1820
|
-
], 46,
|
|
1820
|
+
], 46, Ri)) : O("", !0),
|
|
1821
1821
|
l.image && m.value === l.id && c.value !== l.id ? (M(), C("span", {
|
|
1822
1822
|
key: 6,
|
|
1823
1823
|
class: "zm-img-resize-handle",
|
|
1824
1824
|
title: "拖动调整图片大小",
|
|
1825
1825
|
onMousedown: R((g) => en(g, l), ["stop"])
|
|
1826
|
-
}, null, 40,
|
|
1826
|
+
}, null, 40, Ai)) : O("", !0),
|
|
1827
1827
|
l.image && m.value === l.id && c.value !== l.id ? (M(), C("button", {
|
|
1828
1828
|
key: 7,
|
|
1829
1829
|
class: "zm-img-remove-btn",
|
|
@@ -1837,10 +1837,10 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1837
1837
|
size: 9,
|
|
1838
1838
|
stroke: 2.2
|
|
1839
1839
|
})
|
|
1840
|
-
], 40,
|
|
1841
|
-
], 46,
|
|
1840
|
+
], 40, Li)) : O("", !0)
|
|
1841
|
+
], 46, Si))), 128))
|
|
1842
1842
|
], 4),
|
|
1843
|
-
W.value ? (M(), Bn(
|
|
1843
|
+
W.value ? (M(), Bn(wi, {
|
|
1844
1844
|
key: 1,
|
|
1845
1845
|
x: W.value.x,
|
|
1846
1846
|
y: W.value.y,
|
|
@@ -1858,7 +1858,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1858
1858
|
onClose: _
|
|
1859
1859
|
}, null, 8, ["x", "y", "container", "has-image", "has-link", "has-note", "readonly"])) : O("", !0)
|
|
1860
1860
|
], 544),
|
|
1861
|
-
i.previewMode ? O("", !0) : (M(), C("div",
|
|
1861
|
+
i.previewMode ? O("", !0) : (M(), C("div", Hi, [
|
|
1862
1862
|
y("button", {
|
|
1863
1863
|
class: "zm-tb-btn",
|
|
1864
1864
|
title: "放大",
|
|
@@ -1895,7 +1895,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1895
1895
|
height: "14",
|
|
1896
1896
|
alt: "添加子节点",
|
|
1897
1897
|
draggable: "false"
|
|
1898
|
-
}, null, 8,
|
|
1898
|
+
}, null, 8, Di)
|
|
1899
1899
|
])),
|
|
1900
1900
|
n.readonly ? O("", !0) : (M(), C("button", {
|
|
1901
1901
|
key: 1,
|
|
@@ -1909,7 +1909,7 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1909
1909
|
height: "14",
|
|
1910
1910
|
alt: "添加同级",
|
|
1911
1911
|
draggable: "false"
|
|
1912
|
-
}, null, 8,
|
|
1912
|
+
}, null, 8, Pi)
|
|
1913
1913
|
])),
|
|
1914
1914
|
t[23] || (t[23] = y("span", { class: "zm-tb-divider" }, null, -1)),
|
|
1915
1915
|
y("button", {
|
|
@@ -1949,22 +1949,22 @@ const hi = ["disabled"], mi = ["disabled"], gi = ["disabled"], yi = ["disabled"]
|
|
|
1949
1949
|
}, [
|
|
1950
1950
|
F(V, { name: "export" })
|
|
1951
1951
|
]),
|
|
1952
|
-
y("span",
|
|
1952
|
+
y("span", Ti, be(Math.round(z(E).scale.value * 100)) + "%", 1)
|
|
1953
1953
|
]))
|
|
1954
1954
|
], 4);
|
|
1955
1955
|
};
|
|
1956
1956
|
}
|
|
1957
|
-
}),
|
|
1957
|
+
}), Vi = {
|
|
1958
1958
|
install(n) {
|
|
1959
|
-
n.component("FlowMindMap",
|
|
1959
|
+
n.component("FlowMindMap", Oi);
|
|
1960
1960
|
}
|
|
1961
1961
|
};
|
|
1962
1962
|
export {
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1963
|
+
Oi as MindMap,
|
|
1964
|
+
ai as addChild,
|
|
1965
|
+
ui as addSibling,
|
|
1966
1966
|
he as clone,
|
|
1967
|
-
|
|
1967
|
+
Vi as default,
|
|
1968
1968
|
B as findNode,
|
|
1969
1969
|
ae as findParent,
|
|
1970
1970
|
Xt as markdownToMindMap,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(L,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(L=typeof globalThis<"u"?globalThis:L||self,e(L.FlowMind={},L.Vue))})(this,function(L,e){"use strict";const Rt=["width","height","stroke-width"],Lt={key:4,points:"6 9 12 15 18 9"},At={key:5,points:"9 6 15 12 9 18"},R=e.defineComponent({__name:"Icon",props:{name:{},size:{},stroke:{}},setup(o){return(d,l)=>(e.openBlock(),e.createElementBlock("svg",{width:o.size??16,height:o.size??16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":o.stroke??1.8,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[o.name==="add"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[l[0]||(l[0]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1)),l[1]||(l[1]=e.createElementVNode("line",{x1:"12",y1:"8",x2:"12",y2:"16"},null,-1)),l[2]||(l[2]=e.createElementVNode("line",{x1:"8",y1:"12",x2:"16",y2:"12"},null,-1))],64)):o.name==="minus"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[l[3]||(l[3]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1)),l[4]||(l[4]=e.createElementVNode("line",{x1:"8",y1:"12",x2:"16",y2:"12"},null,-1))],64)):o.name==="delete"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[l[5]||(l[5]=e.createStaticVNode('<polyline points="4 7 20 7"></polyline><path d="M9 7 V5 a1 1 0 0 1 1 -1 h4 a1 1 0 0 1 1 1 V7"></path><path d="M6 7 l1 12 a1 1 0 0 0 1 1 h8 a1 1 0 0 0 1 -1 l1 -12"></path><line x1="10" y1="11" x2="10" y2="18"></line><line x1="14" y1="11" x2="14" y2="18"></line>',5))],64)):o.name==="edit"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[l[6]||(l[6]=e.createElementVNode("path",{d:"M4 20 l4 -1 11 -11 -3 -3 -11 11 z"},null,-1)),l[7]||(l[7]=e.createElementVNode("line",{x1:"14",y1:"6",x2:"18",y2:"10"},null,-1))],64)):o.name==="collapse"?(e.openBlock(),e.createElementBlock("polyline",Lt)):o.name==="expand"?(e.openBlock(),e.createElementBlock("polyline",At)):o.name==="zoom-in"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:6},[l[8]||(l[8]=e.createElementVNode("circle",{cx:"11",cy:"11",r:"7"},null,-1)),l[9]||(l[9]=e.createElementVNode("line",{x1:"11",y1:"8",x2:"11",y2:"14"},null,-1)),l[10]||(l[10]=e.createElementVNode("line",{x1:"8",y1:"11",x2:"14",y2:"11"},null,-1)),l[11]||(l[11]=e.createElementVNode("line",{x1:"16",y1:"16",x2:"21",y2:"21"},null,-1))],64)):o.name==="zoom-out"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:7},[l[12]||(l[12]=e.createElementVNode("circle",{cx:"11",cy:"11",r:"7"},null,-1)),l[13]||(l[13]=e.createElementVNode("line",{x1:"8",y1:"11",x2:"14",y2:"11"},null,-1)),l[14]||(l[14]=e.createElementVNode("line",{x1:"16",y1:"16",x2:"21",y2:"21"},null,-1))],64)):o.name==="reset"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:8},[l[15]||(l[15]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1)),l[16]||(l[16]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"4"},null,-1)),l[17]||(l[17]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"0.8",fill:"currentColor"},null,-1))],64)):o.name==="logo"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:9},[l[18]||(l[18]=e.createStaticVNode('<circle cx="12" cy="12" r="2.2"></circle><circle cx="4" cy="5" r="1.6"></circle><circle cx="20" cy="5" r="1.6"></circle><circle cx="4" cy="19" r="1.6"></circle><circle cx="20" cy="19" r="1.6"></circle><line x1="10.5" y1="10.8" x2="5.2" y2="6.4"></line><line x1="13.5" y1="10.8" x2="18.8" y2="6.4"></line><line x1="10.5" y1="13.2" x2="5.2" y2="17.6"></line><line x1="13.5" y1="13.2" x2="18.8" y2="17.6"></line>',9))],64)):o.name==="import"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:10},[l[19]||(l[19]=e.createElementVNode("path",{d:"M12 4 V15"},null,-1)),l[20]||(l[20]=e.createElementVNode("polyline",{points:"7 10 12 15 17 10"},null,-1)),l[21]||(l[21]=e.createElementVNode("path",{d:"M4 19 H20"},null,-1))],64)):o.name==="export"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:11},[l[22]||(l[22]=e.createElementVNode("path",{d:"M12 15 V4"},null,-1)),l[23]||(l[23]=e.createElementVNode("polyline",{points:"7 9 12 4 17 9"},null,-1)),l[24]||(l[24]=e.createElementVNode("path",{d:"M4 19 H20"},null,-1))],64)):o.name==="balance"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:12},[l[25]||(l[25]=e.createStaticVNode('<line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="18" x2="21" y2="18"></line><polyline points="9 4 5 6 9 8"></polyline><polyline points="15 4 19 6 15 8"></polyline><polyline points="9 10 5 12 9 14"></polyline><polyline points="15 10 19 12 15 14"></polyline><polyline points="9 16 5 18 9 20"></polyline><polyline points="15 16 19 18 15 20"></polyline>',9))],64)):o.name==="mindmap"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:13},[l[26]||(l[26]=e.createStaticVNode('<circle cx="12" cy="12" r="2.2" fill="currentColor" stroke="none"></circle><line x1="13" y1="11" x2="19" y2="6"></line><line x1="13" y1="13" x2="19" y2="18"></line><line x1="11" y1="11" x2="5" y2="6"></line><line x1="11" y1="13" x2="5" y2="18"></line>',5))],64)):o.name==="tree"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:14},[l[27]||(l[27]=e.createStaticVNode('<circle cx="6" cy="12" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="6" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="12" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="18" r="2" fill="currentColor" stroke="none"></circle><line x1="8" y1="12" x2="16" y2="6"></line><line x1="8" y1="12" x2="16" y2="12"></line><line x1="8" y1="12" x2="16" y2="18"></line>',7))],64)):o.name==="org"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:15},[l[28]||(l[28]=e.createStaticVNode('<circle cx="12" cy="5" r="2" fill="currentColor" stroke="none"></circle><circle cx="6" cy="19" r="2" fill="currentColor" stroke="none"></circle><circle cx="12" cy="19" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="19" r="2" fill="currentColor" stroke="none"></circle><line x1="12" y1="7" x2="12" y2="13"></line><line x1="6" y1="13" x2="18" y2="13"></line><line x1="6" y1="13" x2="6" y2="17"></line><line x1="12" y1="13" x2="12" y2="17"></line><line x1="18" y1="13" x2="18" y2="17"></line>',9))],64)):o.name==="image"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:16},[l[29]||(l[29]=e.createElementVNode("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"},null,-1)),l[30]||(l[30]=e.createElementVNode("circle",{cx:"9",cy:"11",r:"1.6"},null,-1)),l[31]||(l[31]=e.createElementVNode("polyline",{points:"3 17 9 12 13 15 16 13 21 17"},null,-1))],64)):o.name==="x"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:17},[l[32]||(l[32]=e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"},null,-1)),l[33]||(l[33]=e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"},null,-1))],64)):o.name==="link"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:18},[l[34]||(l[34]=e.createElementVNode("path",{d:"M10 13 a4 4 0 0 0 5.66 0 l3 -3 a4 4 0 1 0 -5.66 -5.66 l-1 1"},null,-1)),l[35]||(l[35]=e.createElementVNode("path",{d:"M14 11 a4 4 0 0 0 -5.66 0 l-3 3 a4 4 0 1 0 5.66 5.66 l1 -1"},null,-1))],64)):o.name==="note"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:19},[l[36]||(l[36]=e.createElementVNode("path",{d:"M6 4 h9 l3 3 v13 a1 1 0 0 1 -1 1 h-11 a1 1 0 0 1 -1 -1 v-15 a1 1 0 0 1 1 -1 z"},null,-1)),l[37]||(l[37]=e.createElementVNode("line",{x1:"8",y1:"10",x2:"16",y2:"10"},null,-1)),l[38]||(l[38]=e.createElementVNode("line",{x1:"8",y1:"13",x2:"16",y2:"13"},null,-1)),l[39]||(l[39]=e.createElementVNode("line",{x1:"8",y1:"16",x2:"13",y2:"16"},null,-1))],64)):e.createCommentVNode("",!0)],8,Rt))}}),Tt="data:image/svg+xml,%3csvg%20t='1780822312364'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='7459'%20width='200'%20height='200'%3e%3cpath%20d='M329.16%20292.571h658.286V512H329.16zM329.16%200h658.286v219.429H329.16z'%20fill='%239AA1A2'%20p-id='7460'%3e%3c/path%3e%3cpath%20d='M44.927%20146.286a46.519%2046.519%200%200%201%2038.107-73.143h319.269v73.143H109.73V791.99l-48.713%205.705-24.43-651.41h8.339z'%20fill='%239AA1A2'%20p-id='7461'%3e%3c/path%3e%3cpath%20d='M363.83%20877.714H179.51c-78.775%200-142.921-66.12-142.921-147.31V112.787c0-21.943%2017.188-39.643%2038.473-39.643%2021.211%200%2033.5%2017.774%2033.5%2039.643v617.619c0%2037.522%2028.013%2076.58%2064.438%2076.58h190.903c21.211%200%2038.766%2013.97%2038.766%2035.84%200%2021.943-17.555%2034.89-38.766%2034.89z'%20fill='%239AA1A2'%20p-id='7462'%3e%3c/path%3e%3cpath%20d='M432.95%20438.857H179.51c-78.775%200-81.043-18.578-81.043-62.903l10.094-90.624c0%2020.48%2013.458%2080.677%2049.884%2080.677h210.139c21.211%200%20120.613%204.023%20120.613%2016.018%200%2011.922-35.036%2056.832-56.32%2056.832zM640.017%20749.714V640a54.857%2054.857%200%200%201%20109.714%200v109.714h109.715a54.857%2054.857%200%200%201%200%20109.715H749.73v109.714a54.857%2054.857%200%200%201-109.714%200V859.429H530.303a54.857%2054.857%200%200%201%200-109.715h109.714z'%20fill='%239AA1A2'%20p-id='7463'%3e%3c/path%3e%3c/svg%3e",Dt="data:image/svg+xml,%3csvg%20t='1780822464335'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='8457'%20width='200'%20height='200'%3e%3cpath%20d='M512%20804.571h512V1024H512V804.571zM0%200h658.286v219.429H0V0z'%20fill='%239AA1A2'%20p-id='8458'%3e%3c/path%3e%3cpath%20d='M619.813%20950.857h-184.32c-78.775%200-142.922-66.121-142.922-147.31V185.93c0-21.943%2017.189-39.643%2038.474-39.643%2021.211%200%2033.353%2017.773%2033.353%2039.643v617.618c0%2037.523%2034.743%2073.728%2071.095%2073.728h184.32c21.211%200%2038.473%2012.069%2038.473%2033.939%200%2021.943-17.189%2039.643-38.473%2039.643z'%20fill='%239AA1A2'%20p-id='8459'%3e%3c/path%3e%3cpath%20d='M676.571%20457.143V347.429a54.857%2054.857%200%200%201%20109.715%200v109.714H896a54.857%2054.857%200%200%201%200%20109.714H786.286v109.714a54.857%2054.857%200%200%201-109.715%200V566.857H566.857a54.857%2054.857%200%200%201%200-109.714h109.714z'%20fill='%239AA1A2'%20p-id='8460'%3e%3c/path%3e%3c/svg%3e",Je=[18,15,13,12],Ht=[700,600,500,400],Pt=[52,40,32,28],Ft=[120,80,60,44],Ot=[.8,.8,.8,.8],qt=Je.length-1;function Xt(o,d){return Math.round(Te(o,d)*Ot[ve(o)])}function ve(o){return Math.min(qt,Math.max(0,o))}function Te(o,d=14){return Math.round(Je[ve(o)]*d/14*10)/10}function Kt(o,d=14){return Math.round(Pt[ve(o)]*d/14)}const Ce=60,ue=14,U=24;let De=null;function Ut(){if(De)return De;const o=typeof document<"u"?document.createElement("canvas").getContext("2d"):null;return o?(De=o,o):{font:"",measureText:()=>({width:0})}}const Ze=new Map;function Yt(o,d,l){const i=`${l}|${d}|${o}`,c=Ze.get(i);if(c!==void 0)return c;const u=Ut();u.font=`${l} ${d}px "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif`;const f=u.measureText(o).width;return Ze.set(i,f),f}const jt=24,Gt=400,Jt=8,Qe=16,Zt=4;function Qt(o,d,l){return Math.min(l,Math.max(d,o))}function _t(o,d,l){const i=ve(d),c=Te(d,l),u=Yt(o.text||"",c,Ht[i]),f=Xt(d,l),p=Math.ceil(u+f*2),y=Kt(d,l);let g=0;if(o.link&&(g+=Qe),o.note&&(g+=Qe),g>0){const P=(o.link?1:0)+(o.note?1:0);g+=Zt*P}const s=p+g,k=Math.round(Ft[i]*l/14);if(!o.image)return{w:Math.max(k,s),h:y};const N=Qt(o.image.width,jt,Gt),w=Math.max(k,s,Math.ceil(N+f*2)),z=Math.ceil(o.image.height+Jt+y);return{w,h:z}}function en(o,d={}){const l=d.mode??"mindmap",i=d.preservePositions===!0,c=d.baseFontSize??14,u=et(o,0,null,1,"right",c);return nn(u),tn(u,l,i),u.x=0,u.y=0,on(u,i)}function tn(o,d,l=!1){if(d==="mindmap"){const i=o.children;if(i.length!==0)if(i.length===1)i[0]._dir="right",i[0].side=1,i[0]._dirRight=1;else{const p=i.reduce((k,N)=>k+N._subtreeH,0);let y=1,g=Math.abs(i[0]._subtreeH-(p-i[0]._subtreeH)),s=0;for(let k=0;k<i.length-1;k++){s+=i[k]._subtreeH;const N=Math.abs(s-(p-s));N<g&&(g=N,y=k+1)}for(let k=0;k<y;k++)i[k]._dir="right",i[k].side=1,i[k]._dirRight=1;for(let k=y;k<i.length;k++)i[k]._dir="left",i[k].side=-1,i[k]._dirRight=-1}const c=o.children.filter(p=>p.side===1),u=o.children.filter(p=>p.side===-1),f=(p,y)=>{const g=y==="right"?1:-1;p._dir=y,p.side=g,p._dirRight=g;for(const s of p.children)f(s,y)};for(const p of c)f(p,"right");for(const p of u)f(p,"left");if(c.length>0){const p={...o,children:c};Se(p,"right",Ce,!0,l)}if(u.length>0){const p={...o,children:u};Se(p,"left",Ce,!0,l)}}else if(d==="tree"){const i=c=>{c.side=1,c._dir="right";for(const u of c.children)i(u)};for(const c of o.children)c._dir="right";Se(o,"right",Ce,!0,l),i(o)}else{for(const i of o.children)i._dir="down";_e(o,Ce,l)}}function Se(o,d,l,i,c=!1){if(o.children.length===0)return;const u=o.children.reduce((g,s,k)=>g+s._subtreeH+(k>0?ue:0),0),f=d==="right"?1:-1,p=i?f:1;let y=o.y-p*u/2;o.children.forEach(g=>{c||(g.x=o.x+f*(o.width/2+l+g.width/2),g.y=y+p*g._subtreeH/2),g._dir=d,y+=p*(g._subtreeH+ue),Se(g,d,l,!1,c)})}function _e(o,d,l=!1){if(o.children.length===0)return;const i=o.children.reduce((u,f,p)=>u+f._subtreeW+(p>0?ue*2:0),0);let c=o.x-i/2;o.children.forEach(u=>{l||(u.x=c+u._subtreeW/2,u.y=o.y+o.height/2+d+u.height/2),u._dir="down",c+=u._subtreeW+ue*2,_e(u,d,l)})}function et(o,d,l,i,c,u){const f=_t(o,d,u),p={id:o.id,text:o.text,depth:d,x:o._x??0,y:o._y??0,width:f.w,height:f.h,fontSize:Te(d,u),isRoot:d===0,collapsed:o.collapsed,side:i,_dir:c,_dirRight:i,_subtreeH:f.h,_subtreeW:f.w,image:o.image?{...o.image}:void 0,link:o.link?{url:o.link.url}:void 0,note:o.note?{text:o.note.text}:void 0,children:[],parent:l};if(o.collapsed)return p;const y=o.children.length,g=Math.ceil(y/2);return p.children=o.children.map((s,k)=>{const N=d===0?k<g?1:-1:i;return et(s,d+1,p,N,c,u)}),p}function nn(o){const d=[o];for(let l=0;l<d.length;l++){const i=d[l];for(const c of i.children)d.push(c)}for(let l=d.length-1;l>=0;l--){const i=d[l];if(i.collapsed||i.children.length===0){i._subtreeH=i.height,i._subtreeW=i.width;continue}let c=0,u=0;for(const f of i.children)c+=f._subtreeH,u+=f._subtreeW;i.children.length>1&&(c+=ue*(i.children.length-1),u+=ue*2*(i.children.length-1)),i._subtreeH=Math.max(i.height,c),i._subtreeW=Math.max(i.width,u)}}function on(o,d=!1){const l=[o];let i=1/0,c=-1/0,u=1/0,f=-1/0;for(;l.length;){const g=l.pop(),s=g.width/2,k=g.height/2;g.x-s<i&&(i=g.x-s),g.x+s>c&&(c=g.x+s),g.y-k<u&&(u=g.y-k),g.y+k>f&&(f=g.y+k),l.push(...g.children)}if(d)return{root:o,width:c-i+U*2,height:f-u+U*2,vbX:i-U,vbY:u-U,vbW:c-i+U*2,vbH:f-u+U*2};const p=U-u,y=[o];for(;y.length;){const g=y.pop();g.y+=p,y.push(...g.children)}return u+=p,f+=p,{root:o,width:c-i+U*2,height:f+U,vbX:i-U,vbY:0,vbW:c-i+U*2,vbH:f+U}}const ke=[{id:"default",name:"默认",colors:["#f87171","#fb923c","#fbbf24","#a3e635","#34d399","#22d3ee","#818cf8","#c084fc"]},{id:"classic",name:"经典",colors:["#ef4444","#f59e0b","#10b981","#3b82f6","#6366f1","#8b5cf6","#ec4899","#14b8a6"]},{id:"vivid",name:"活力",colors:["#dc2626","#ea580c","#ca8a04","#16a34a","#0891b2","#2563eb","#7c3aed","#db2777"]},{id:"dev",name:"代码",colors:["#f472b6","#a78bfa","#60a5fa","#38bdf8","#22d3ee","#34d399","#facc15","#fb923c"]},{id:"mint",name:"薄荷",colors:["#5eead4","#67e8f9","#93c5fd","#c4b5fd","#fbcfe8","#fde68a","#a7f3d0","#bae6fd"]}];function ln(o,d=[]){return[...ke,...d].find(i=>i.id===o)??ke[0]}function oe(){return"n_"+Math.random().toString(36).slice(2,10)+Date.now().toString(36).slice(-4)}function _(o){return JSON.parse(JSON.stringify(o))}function S(o,d){if(o.id===d)return o;for(const l of o.children){const i=S(l,d);if(i)return i}return null}function Y(o,d,l=null){if(o.id===d)return l;for(const i of o.children){const c=Y(i,d,o);if(c!==null)return c}return null}function He(o,d){const l=o.children.findIndex(i=>i.id===d);if(l>=0)return o.children.splice(l,1),!0;for(const i of o.children)if(He(i,d))return!0;return!1}function rn(o,d,l){const i=S(o,d);return!i||i.text===l?!1:(i.text=l,!0)}function an(o,d,l,i){if(!Y(o,d)||d===l||S(S(o,d),l))return!1;const c=Y(o,d),u=c.children.findIndex(g=>g.id===d);if(u<0)return!1;const[f]=c.children.splice(u,1);if(i==="child"){const g=S(o,l);return g?(g.children.push(f),!0):(c.children.splice(u,0,f),!1)}const p=Y(o,l);if(!p)return c.children.splice(u,0,f),!1;let y=p.children.findIndex(g=>g.id===l);return y<0?(c.children.splice(u,0,f),!1):(i==="after"&&(y+=1),p.children.splice(y,0,f),!0)}function tt(o){const d=/^新节点(?:\s+(\d+))?$/;let l=0,i=!1;for(const c of o.children){const u=c.text.match(d);if(u)if(u[1]){const f=parseInt(u[1],10);f>l&&(l=f)}else i=!0}return l===0&&!i?Ve:l>0?`新节点 ${l+1}`:"新节点 2"}function nt(o,d,l){const i=S(o,d);if(!i)return null;const c={id:oe(),text:l??tt(i),children:[]};return i.children.push(c),c}function ot(o,d,l){const i=Y(o,d);if(!i)return null;const c=i.children.findIndex(f=>f.id===d);if(c<0)return null;const u={id:oe(),text:l??tt(i),children:[]};return i.children.splice(c+1,0,u),u}function cn(o,d,l){const i=Y(o,d);if(!i)return null;const c=i.children.findIndex(f=>f.id===d);if(c<0)return null;const u={id:oe(),text:l,children:[]};return i.children.splice(c,0,u),u}function sn(o,d){const l=Y(o,d);if(!l)return null;const i=l.children.findIndex(f=>f.id===d);if(i<0)return null;const c=l.children[i],u=_(c);return it(u),l.children.splice(i+1,0,u),u}function it(o){o.id=oe();for(const d of o.children)it(d)}const Ve="新节点";function Pe(o,d="导入的导图"){const l=o.split(/\r?\n/),i={id:oe(),text:d,children:[]},c=[i],u=[-1/0],f=[],p=/^(#{1,6})\s+(.+?)\s*#*\s*$/,y=/^!\[([^\]]*)\]\((\S+?)(?:\s+"[^"]*")?\)\s*$/,g=/^\[([^\]]+)\]\((\S+?)(?:\s+"[^"]*")?\)\s*$/,s=/^(`{3,}|~{3,})\s*(\S+)?\s*$/;let k=!1,N=[],w=null;function z(b){N.push(b)}function P(){if(w&&N.length>0){for(;N.length>0&&N[0].trim()==="";)N.shift();for(;N.length>0&&N[N.length-1].trim()==="";)N.pop();const b=N.join(`
|
|
2
|
-
`);b&&(w.note={text:b})}k=!1,N=[]}for(const b of l){if(k){const D=b.match(s);if(D&&D[1][0]==="`"){P();continue}z(b);continue}const F=b.match(p);if(F){const D=F[1].length,Q=F[2].trim();f.push({level:D,text:Q,body:""}),w=f[f.length-1];continue}const
|
|
1
|
+
(function(T,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(T=typeof globalThis<"u"?globalThis:T||self,e(T.FlowMind={},T.Vue))})(this,function(T,e){"use strict";const Rt=["width","height","stroke-width"],Tt={key:4,points:"6 9 12 15 18 9"},At={key:5,points:"9 6 15 12 9 18"},R=e.defineComponent({__name:"Icon",props:{name:{},size:{},stroke:{}},setup(o){return(d,l)=>(e.openBlock(),e.createElementBlock("svg",{width:o.size??16,height:o.size??16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":o.stroke??1.8,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[o.name==="add"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[l[0]||(l[0]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1)),l[1]||(l[1]=e.createElementVNode("line",{x1:"12",y1:"8",x2:"12",y2:"16"},null,-1)),l[2]||(l[2]=e.createElementVNode("line",{x1:"8",y1:"12",x2:"16",y2:"12"},null,-1))],64)):o.name==="minus"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[l[3]||(l[3]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1)),l[4]||(l[4]=e.createElementVNode("line",{x1:"8",y1:"12",x2:"16",y2:"12"},null,-1))],64)):o.name==="delete"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[l[5]||(l[5]=e.createStaticVNode('<polyline points="4 7 20 7"></polyline><path d="M9 7 V5 a1 1 0 0 1 1 -1 h4 a1 1 0 0 1 1 1 V7"></path><path d="M6 7 l1 12 a1 1 0 0 0 1 1 h8 a1 1 0 0 0 1 -1 l1 -12"></path><line x1="10" y1="11" x2="10" y2="18"></line><line x1="14" y1="11" x2="14" y2="18"></line>',5))],64)):o.name==="edit"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[l[6]||(l[6]=e.createElementVNode("path",{d:"M4 20 l4 -1 11 -11 -3 -3 -11 11 z"},null,-1)),l[7]||(l[7]=e.createElementVNode("line",{x1:"14",y1:"6",x2:"18",y2:"10"},null,-1))],64)):o.name==="collapse"?(e.openBlock(),e.createElementBlock("polyline",Tt)):o.name==="expand"?(e.openBlock(),e.createElementBlock("polyline",At)):o.name==="zoom-in"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:6},[l[8]||(l[8]=e.createElementVNode("circle",{cx:"11",cy:"11",r:"7"},null,-1)),l[9]||(l[9]=e.createElementVNode("line",{x1:"11",y1:"8",x2:"11",y2:"14"},null,-1)),l[10]||(l[10]=e.createElementVNode("line",{x1:"8",y1:"11",x2:"14",y2:"11"},null,-1)),l[11]||(l[11]=e.createElementVNode("line",{x1:"16",y1:"16",x2:"21",y2:"21"},null,-1))],64)):o.name==="zoom-out"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:7},[l[12]||(l[12]=e.createElementVNode("circle",{cx:"11",cy:"11",r:"7"},null,-1)),l[13]||(l[13]=e.createElementVNode("line",{x1:"8",y1:"11",x2:"14",y2:"11"},null,-1)),l[14]||(l[14]=e.createElementVNode("line",{x1:"16",y1:"16",x2:"21",y2:"21"},null,-1))],64)):o.name==="reset"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:8},[l[15]||(l[15]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1)),l[16]||(l[16]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"4"},null,-1)),l[17]||(l[17]=e.createElementVNode("circle",{cx:"12",cy:"12",r:"0.8",fill:"currentColor"},null,-1))],64)):o.name==="logo"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:9},[l[18]||(l[18]=e.createStaticVNode('<circle cx="12" cy="12" r="2.2"></circle><circle cx="4" cy="5" r="1.6"></circle><circle cx="20" cy="5" r="1.6"></circle><circle cx="4" cy="19" r="1.6"></circle><circle cx="20" cy="19" r="1.6"></circle><line x1="10.5" y1="10.8" x2="5.2" y2="6.4"></line><line x1="13.5" y1="10.8" x2="18.8" y2="6.4"></line><line x1="10.5" y1="13.2" x2="5.2" y2="17.6"></line><line x1="13.5" y1="13.2" x2="18.8" y2="17.6"></line>',9))],64)):o.name==="import"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:10},[l[19]||(l[19]=e.createElementVNode("path",{d:"M12 4 V15"},null,-1)),l[20]||(l[20]=e.createElementVNode("polyline",{points:"7 10 12 15 17 10"},null,-1)),l[21]||(l[21]=e.createElementVNode("path",{d:"M4 19 H20"},null,-1))],64)):o.name==="export"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:11},[l[22]||(l[22]=e.createElementVNode("path",{d:"M12 15 V4"},null,-1)),l[23]||(l[23]=e.createElementVNode("polyline",{points:"7 9 12 4 17 9"},null,-1)),l[24]||(l[24]=e.createElementVNode("path",{d:"M4 19 H20"},null,-1))],64)):o.name==="balance"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:12},[l[25]||(l[25]=e.createStaticVNode('<line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="18" x2="21" y2="18"></line><polyline points="9 4 5 6 9 8"></polyline><polyline points="15 4 19 6 15 8"></polyline><polyline points="9 10 5 12 9 14"></polyline><polyline points="15 10 19 12 15 14"></polyline><polyline points="9 16 5 18 9 20"></polyline><polyline points="15 16 19 18 15 20"></polyline>',9))],64)):o.name==="mindmap"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:13},[l[26]||(l[26]=e.createStaticVNode('<circle cx="12" cy="12" r="2.2" fill="currentColor" stroke="none"></circle><line x1="13" y1="11" x2="19" y2="6"></line><line x1="13" y1="13" x2="19" y2="18"></line><line x1="11" y1="11" x2="5" y2="6"></line><line x1="11" y1="13" x2="5" y2="18"></line>',5))],64)):o.name==="tree"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:14},[l[27]||(l[27]=e.createStaticVNode('<circle cx="6" cy="12" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="6" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="12" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="18" r="2" fill="currentColor" stroke="none"></circle><line x1="8" y1="12" x2="16" y2="6"></line><line x1="8" y1="12" x2="16" y2="12"></line><line x1="8" y1="12" x2="16" y2="18"></line>',7))],64)):o.name==="org"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:15},[l[28]||(l[28]=e.createStaticVNode('<circle cx="12" cy="5" r="2" fill="currentColor" stroke="none"></circle><circle cx="6" cy="19" r="2" fill="currentColor" stroke="none"></circle><circle cx="12" cy="19" r="2" fill="currentColor" stroke="none"></circle><circle cx="18" cy="19" r="2" fill="currentColor" stroke="none"></circle><line x1="12" y1="7" x2="12" y2="13"></line><line x1="6" y1="13" x2="18" y2="13"></line><line x1="6" y1="13" x2="6" y2="17"></line><line x1="12" y1="13" x2="12" y2="17"></line><line x1="18" y1="13" x2="18" y2="17"></line>',9))],64)):o.name==="image"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:16},[l[29]||(l[29]=e.createElementVNode("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"},null,-1)),l[30]||(l[30]=e.createElementVNode("circle",{cx:"9",cy:"11",r:"1.6"},null,-1)),l[31]||(l[31]=e.createElementVNode("polyline",{points:"3 17 9 12 13 15 16 13 21 17"},null,-1))],64)):o.name==="x"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:17},[l[32]||(l[32]=e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"},null,-1)),l[33]||(l[33]=e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"},null,-1))],64)):o.name==="link"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:18},[l[34]||(l[34]=e.createElementVNode("path",{d:"M10 13 a4 4 0 0 0 5.66 0 l3 -3 a4 4 0 1 0 -5.66 -5.66 l-1 1"},null,-1)),l[35]||(l[35]=e.createElementVNode("path",{d:"M14 11 a4 4 0 0 0 -5.66 0 l-3 3 a4 4 0 1 0 5.66 5.66 l1 -1"},null,-1))],64)):o.name==="note"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:19},[l[36]||(l[36]=e.createElementVNode("path",{d:"M6 4 h9 l3 3 v13 a1 1 0 0 1 -1 1 h-11 a1 1 0 0 1 -1 -1 v-15 a1 1 0 0 1 1 -1 z"},null,-1)),l[37]||(l[37]=e.createElementVNode("line",{x1:"8",y1:"10",x2:"16",y2:"10"},null,-1)),l[38]||(l[38]=e.createElementVNode("line",{x1:"8",y1:"13",x2:"16",y2:"13"},null,-1)),l[39]||(l[39]=e.createElementVNode("line",{x1:"8",y1:"16",x2:"13",y2:"16"},null,-1))],64)):e.createCommentVNode("",!0)],8,Rt))}}),Lt="data:image/svg+xml,%3csvg%20t='1780822312364'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='7459'%20width='200'%20height='200'%3e%3cpath%20d='M329.16%20292.571h658.286V512H329.16zM329.16%200h658.286v219.429H329.16z'%20fill='%239AA1A2'%20p-id='7460'%3e%3c/path%3e%3cpath%20d='M44.927%20146.286a46.519%2046.519%200%200%201%2038.107-73.143h319.269v73.143H109.73V791.99l-48.713%205.705-24.43-651.41h8.339z'%20fill='%239AA1A2'%20p-id='7461'%3e%3c/path%3e%3cpath%20d='M363.83%20877.714H179.51c-78.775%200-142.921-66.12-142.921-147.31V112.787c0-21.943%2017.188-39.643%2038.473-39.643%2021.211%200%2033.5%2017.774%2033.5%2039.643v617.619c0%2037.522%2028.013%2076.58%2064.438%2076.58h190.903c21.211%200%2038.766%2013.97%2038.766%2035.84%200%2021.943-17.555%2034.89-38.766%2034.89z'%20fill='%239AA1A2'%20p-id='7462'%3e%3c/path%3e%3cpath%20d='M432.95%20438.857H179.51c-78.775%200-81.043-18.578-81.043-62.903l10.094-90.624c0%2020.48%2013.458%2080.677%2049.884%2080.677h210.139c21.211%200%20120.613%204.023%20120.613%2016.018%200%2011.922-35.036%2056.832-56.32%2056.832zM640.017%20749.714V640a54.857%2054.857%200%200%201%20109.714%200v109.714h109.715a54.857%2054.857%200%200%201%200%20109.715H749.73v109.714a54.857%2054.857%200%200%201-109.714%200V859.429H530.303a54.857%2054.857%200%200%201%200-109.715h109.714z'%20fill='%239AA1A2'%20p-id='7463'%3e%3c/path%3e%3c/svg%3e",Dt="data:image/svg+xml,%3csvg%20t='1780822464335'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='8457'%20width='200'%20height='200'%3e%3cpath%20d='M512%20804.571h512V1024H512V804.571zM0%200h658.286v219.429H0V0z'%20fill='%239AA1A2'%20p-id='8458'%3e%3c/path%3e%3cpath%20d='M619.813%20950.857h-184.32c-78.775%200-142.922-66.121-142.922-147.31V185.93c0-21.943%2017.189-39.643%2038.474-39.643%2021.211%200%2033.353%2017.773%2033.353%2039.643v617.618c0%2037.523%2034.743%2073.728%2071.095%2073.728h184.32c21.211%200%2038.473%2012.069%2038.473%2033.939%200%2021.943-17.189%2039.643-38.473%2039.643z'%20fill='%239AA1A2'%20p-id='8459'%3e%3c/path%3e%3cpath%20d='M676.571%20457.143V347.429a54.857%2054.857%200%200%201%20109.715%200v109.714H896a54.857%2054.857%200%200%201%200%20109.714H786.286v109.714a54.857%2054.857%200%200%201-109.715%200V566.857H566.857a54.857%2054.857%200%200%201%200-109.714h109.714z'%20fill='%239AA1A2'%20p-id='8460'%3e%3c/path%3e%3c/svg%3e",Je=[18,15,13,12],Ht=[700,600,500,400],Pt=[52,40,32,28],Ft=[120,80,60,44],Ot=[.8,.8,.8,.8],Xt=Je.length-1;function qt(o,d){return Math.round(Le(o,d)*Ot[ve(o)])}function ve(o){return Math.min(Xt,Math.max(0,o))}function Le(o,d=14){return Math.round(Je[ve(o)]*d/14*10)/10}function Kt(o,d=14){return Math.round(Pt[ve(o)]*d/14)}const Ce=60,ue=14,U=24;let De=null;function Ut(){if(De)return De;const o=typeof document<"u"?document.createElement("canvas").getContext("2d"):null;return o?(De=o,o):{font:"",measureText:()=>({width:0})}}const Ze=new Map;function Yt(o,d,l){const i=`${l}|${d}|${o}`,c=Ze.get(i);if(c!==void 0)return c;const u=Ut();u.font=`${l} ${d}px "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif`;const f=u.measureText(o).width;return Ze.set(i,f),f}const jt=24,Gt=400,Jt=8,Qe=16,Zt=4,Qt=200;function _t(o,d,l){return Math.min(l,Math.max(d,o))}function en(o,d,l){const i=ve(d),c=Le(d,l),u=Math.min(Yt(o.text||"",c,Ht[i]),Qt),f=qt(d,l),p=Math.ceil(u+f*2),y=Kt(d,l);let g=0;if(o.link&&(g+=Qe),o.note&&(g+=Qe),g>0){const P=(o.link?1:0)+(o.note?1:0);g+=Zt*P}const s=p+g,k=Math.round(Ft[i]*l/14);if(!o.image)return{w:Math.max(k,s),h:y};const N=_t(o.image.width,jt,Gt),w=Math.max(k,s,Math.ceil(N+f*2)),z=Math.ceil(o.image.height+Jt+y);return{w,h:z}}function tn(o,d={}){const l=d.mode??"mindmap",i=d.preservePositions===!0,c=d.baseFontSize??14,u=et(o,0,null,1,"right",c);return on(u),nn(u,l,i),u.x=0,u.y=0,ln(u,i)}function nn(o,d,l=!1){if(d==="mindmap"){const i=o.children;if(i.length!==0)if(i.length===1)i[0]._dir="right",i[0].side=1,i[0]._dirRight=1;else{const p=i.reduce((k,N)=>k+N._subtreeH,0);let y=1,g=Math.abs(i[0]._subtreeH-(p-i[0]._subtreeH)),s=0;for(let k=0;k<i.length-1;k++){s+=i[k]._subtreeH;const N=Math.abs(s-(p-s));N<g&&(g=N,y=k+1)}for(let k=0;k<y;k++)i[k]._dir="right",i[k].side=1,i[k]._dirRight=1;for(let k=y;k<i.length;k++)i[k]._dir="left",i[k].side=-1,i[k]._dirRight=-1}const c=o.children.filter(p=>p.side===1),u=o.children.filter(p=>p.side===-1),f=(p,y)=>{const g=y==="right"?1:-1;p._dir=y,p.side=g,p._dirRight=g;for(const s of p.children)f(s,y)};for(const p of c)f(p,"right");for(const p of u)f(p,"left");if(c.length>0){const p={...o,children:c};Se(p,"right",Ce,!0,l)}if(u.length>0){const p={...o,children:u};Se(p,"left",Ce,!0,l)}}else if(d==="tree"){const i=c=>{c.side=1,c._dir="right";for(const u of c.children)i(u)};for(const c of o.children)c._dir="right";Se(o,"right",Ce,!0,l),i(o)}else{for(const i of o.children)i._dir="down";_e(o,Ce,l)}}function Se(o,d,l,i,c=!1){if(o.children.length===0)return;const u=o.children.reduce((g,s,k)=>g+s._subtreeH+(k>0?ue:0),0),f=d==="right"?1:-1,p=i?f:1;let y=o.y-p*u/2;o.children.forEach(g=>{c||(g.x=o.x+f*(o.width/2+l+g.width/2),g.y=y+p*g._subtreeH/2),g._dir=d,y+=p*(g._subtreeH+ue),Se(g,d,l,!1,c)})}function _e(o,d,l=!1){if(o.children.length===0)return;const i=o.children.reduce((u,f,p)=>u+f._subtreeW+(p>0?ue*2:0),0);let c=o.x-i/2;o.children.forEach(u=>{l||(u.x=c+u._subtreeW/2,u.y=o.y+o.height/2+d+u.height/2),u._dir="down",c+=u._subtreeW+ue*2,_e(u,d,l)})}function et(o,d,l,i,c,u){const f=en(o,d,u),p={id:o.id,text:o.text,depth:d,x:o._x??0,y:o._y??0,width:f.w,height:f.h,fontSize:Le(d,u),isRoot:d===0,collapsed:o.collapsed,side:i,_dir:c,_dirRight:i,_subtreeH:f.h,_subtreeW:f.w,image:o.image?{...o.image}:void 0,link:o.link?{url:o.link.url}:void 0,note:o.note?{text:o.note.text}:void 0,children:[],parent:l};if(o.collapsed)return p;const y=o.children.length,g=Math.ceil(y/2);return p.children=o.children.map((s,k)=>{const N=d===0?k<g?1:-1:i;return et(s,d+1,p,N,c,u)}),p}function on(o){const d=[o];for(let l=0;l<d.length;l++){const i=d[l];for(const c of i.children)d.push(c)}for(let l=d.length-1;l>=0;l--){const i=d[l];if(i.collapsed||i.children.length===0){i._subtreeH=i.height,i._subtreeW=i.width;continue}let c=0,u=0;for(const f of i.children)c+=f._subtreeH,u+=f._subtreeW;i.children.length>1&&(c+=ue*(i.children.length-1),u+=ue*2*(i.children.length-1)),i._subtreeH=Math.max(i.height,c),i._subtreeW=Math.max(i.width,u)}}function ln(o,d=!1){const l=[o];let i=1/0,c=-1/0,u=1/0,f=-1/0;for(;l.length;){const g=l.pop(),s=g.width/2,k=g.height/2;g.x-s<i&&(i=g.x-s),g.x+s>c&&(c=g.x+s),g.y-k<u&&(u=g.y-k),g.y+k>f&&(f=g.y+k),l.push(...g.children)}if(d)return{root:o,width:c-i+U*2,height:f-u+U*2,vbX:i-U,vbY:u-U,vbW:c-i+U*2,vbH:f-u+U*2};const p=U-u,y=[o];for(;y.length;){const g=y.pop();g.y+=p,y.push(...g.children)}return u+=p,f+=p,{root:o,width:c-i+U*2,height:f+U,vbX:i-U,vbY:0,vbW:c-i+U*2,vbH:f+U}}const ke=[{id:"default",name:"默认",colors:["#f87171","#fb923c","#fbbf24","#a3e635","#34d399","#22d3ee","#818cf8","#c084fc"]},{id:"classic",name:"经典",colors:["#ef4444","#f59e0b","#10b981","#3b82f6","#6366f1","#8b5cf6","#ec4899","#14b8a6"]},{id:"vivid",name:"活力",colors:["#dc2626","#ea580c","#ca8a04","#16a34a","#0891b2","#2563eb","#7c3aed","#db2777"]},{id:"dev",name:"代码",colors:["#f472b6","#a78bfa","#60a5fa","#38bdf8","#22d3ee","#34d399","#facc15","#fb923c"]},{id:"mint",name:"薄荷",colors:["#5eead4","#67e8f9","#93c5fd","#c4b5fd","#fbcfe8","#fde68a","#a7f3d0","#bae6fd"]}];function rn(o,d=[]){return[...ke,...d].find(i=>i.id===o)??ke[0]}function oe(){return"n_"+Math.random().toString(36).slice(2,10)+Date.now().toString(36).slice(-4)}function _(o){return JSON.parse(JSON.stringify(o))}function S(o,d){if(o.id===d)return o;for(const l of o.children){const i=S(l,d);if(i)return i}return null}function Y(o,d,l=null){if(o.id===d)return l;for(const i of o.children){const c=Y(i,d,o);if(c!==null)return c}return null}function He(o,d){const l=o.children.findIndex(i=>i.id===d);if(l>=0)return o.children.splice(l,1),!0;for(const i of o.children)if(He(i,d))return!0;return!1}function an(o,d,l){const i=S(o,d);return!i||i.text===l?!1:(i.text=l,!0)}function cn(o,d,l,i){if(!Y(o,d)||d===l||S(S(o,d),l))return!1;const c=Y(o,d),u=c.children.findIndex(g=>g.id===d);if(u<0)return!1;const[f]=c.children.splice(u,1);if(i==="child"){const g=S(o,l);return g?(g.children.push(f),!0):(c.children.splice(u,0,f),!1)}const p=Y(o,l);if(!p)return c.children.splice(u,0,f),!1;let y=p.children.findIndex(g=>g.id===l);return y<0?(c.children.splice(u,0,f),!1):(i==="after"&&(y+=1),p.children.splice(y,0,f),!0)}function tt(o){const d=/^新节点(?:\s+(\d+))?$/;let l=0,i=!1;for(const c of o.children){const u=c.text.match(d);if(u)if(u[1]){const f=parseInt(u[1],10);f>l&&(l=f)}else i=!0}return l===0&&!i?Ve:l>0?`新节点 ${l+1}`:"新节点 2"}function nt(o,d,l){const i=S(o,d);if(!i)return null;const c={id:oe(),text:l??tt(i),children:[]};return i.children.push(c),c}function ot(o,d,l){const i=Y(o,d);if(!i)return null;const c=i.children.findIndex(f=>f.id===d);if(c<0)return null;const u={id:oe(),text:l??tt(i),children:[]};return i.children.splice(c+1,0,u),u}function sn(o,d,l){const i=Y(o,d);if(!i)return null;const c=i.children.findIndex(f=>f.id===d);if(c<0)return null;const u={id:oe(),text:l,children:[]};return i.children.splice(c,0,u),u}function dn(o,d){const l=Y(o,d);if(!l)return null;const i=l.children.findIndex(f=>f.id===d);if(i<0)return null;const c=l.children[i],u=_(c);return it(u),l.children.splice(i+1,0,u),u}function it(o){o.id=oe();for(const d of o.children)it(d)}const Ve="新节点";function Pe(o,d="导入的导图"){const l=o.split(/\r?\n/),i={id:oe(),text:d,children:[]},c=[i],u=[-1/0],f=[],p=/^(#{1,6})\s+(.+?)\s*#*\s*$/,y=/^!\[([^\]]*)\]\((\S+?)(?:\s+"[^"]*")?\)\s*$/,g=/^\[([^\]]+)\]\((\S+?)(?:\s+"[^"]*")?\)\s*$/,s=/^(`{3,}|~{3,})\s*(\S+)?\s*$/;let k=!1,N=[],w=null;function z(b){N.push(b)}function P(){if(w&&N.length>0){for(;N.length>0&&N[0].trim()==="";)N.shift();for(;N.length>0&&N[N.length-1].trim()==="";)N.pop();const b=N.join(`
|
|
2
|
+
`);b&&(w.note={text:b})}k=!1,N=[]}for(const b of l){if(k){const D=b.match(s);if(D&&D[1][0]==="`"){P();continue}z(b);continue}const F=b.match(p);if(F){const D=F[1].length,Q=F[2].trim();f.push({level:D,text:Q,body:""}),w=f[f.length-1];continue}const L=b.match(s);if(L&&L[2]==="note"){k=!0,N=[];continue}const $=b.match(y);if($&&w){const D=$[2],Q=160,ae=120;w.image={src:D,naturalW:Q,naturalH:ae,width:Q,height:ae};continue}const Z=b.match(g);if(Z&&w){w.link={url:Z[2]},w.text=Z[1];continue}b.trim().length>0&&w&&(w.body=w.body?w.body+" "+b.trim():b.trim())}k&&P();function ie(b){for(;c.length>1;){const Z=c.length-1,D=u[Z];if(D!==void 0&&D<b.level)break;c.pop(),u.pop()}const F=c[c.length-1],L=b.text,$={id:oe(),text:L,children:[]};b.image&&($.image={...b.image}),b.link&&($.link={url:b.link.url}),b.note&&($.note={text:b.note.text}),b.body&&ee(b,f,f.indexOf(b))&&$.children.push({id:oe(),text:b.body,children:[]}),F.children.push($),c.push($),u.push(b.level)}function ee(b,F,L){for(let $=L+1;$<F.length;$++){if(F[$].level<=b.level)return!0;if(F[$].level>b.level)return!1}return!0}for(const b of f)ie(b);if(f.length>0&&f[0].level===1){const b=i.children[0];b&&(i.text=b.text,i.id=b.id,b.image&&(i.image={...b.image}),b.link&&(i.link={url:b.link.url}),b.note&&(i.note={text:b.note.text}),i.children=b.children)}return i}function ze(o,d=1){let l="#".repeat(d)+" "+(o.text||"")+`
|
|
3
3
|
`;o.link&&(l+=`[${o.text||"link"}](${o.link.url})
|
|
4
4
|
`),o.image&&(l+=`
|
|
5
|
-
`),o.note&&(l+="```note\n"+o.note.text+"\n```\n");for(const i of o.children)l+=ze(i,d+1);return l}function dn(o){const d=o.minScale??.2,l=o.maxScale??3,i=o.step??1.2,c=e.ref(1),u=e.ref(0),f=e.ref(0),p=e.ref(!1),y=e.reactive({x:0,y:0,ox:0,oy:0}),g=e.ref(!1),s=e.reactive({x:0,y:0}),k=e.reactive({x:0,y:0,width:0,height:0}),N=e.ref(0);let w=null;function z(v){w=v}function P(v){v.preventDefault();const C=o.getContainer();if(!C)return;const O=-v.deltaY*.001,X=Math.min(l,Math.max(d,c.value*(1+O))),j=C.getBoundingClientRect(),G=v.clientX-j.left,me=v.clientY-j.top,be=(G-u.value)/c.value,he=(me-f.value)/c.value;c.value=X,u.value=G-be*X,f.value=me-he*X}function ie(){c.value=Math.min(l,c.value*i)}function ee(){c.value=Math.max(d,c.value/i)}function b(v){var O;v.target.closest(".zm-node, .zm-toolbar, button, input, textarea")||(p.value=!0,y.x=v.clientX,y.y=v.clientY,y.ox=u.value,y.oy=f.value,window.addEventListener("mousemove",F),window.addEventListener("mouseup",T),(O=v.preventDefault)==null||O.call(v))}function F(v){p.value&&(u.value=y.ox+(v.clientX-y.x),f.value=y.oy+(v.clientY-y.y))}function T(){p.value=!1,window.removeEventListener("mousemove",F),window.removeEventListener("mouseup",T)}function $(v,C){g.value=!0,s.x=v,s.y=C,k.x=v,k.y=C,k.width=0,k.height=0,N.value++,window.addEventListener("mousemove",Q),window.addEventListener("mouseup",D)}function Z(v,C){if(!g.value)return;const O=Math.min(s.x,v),X=Math.min(s.y,C),j=Math.max(s.x,v),G=Math.max(s.y,C);k.x=O,k.y=X,k.width=j-O,k.height=G-X,N.value++}function D(){g.value=!1,window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",D),w&&w()}function Q(v){if(!g.value)return;const C=o.getContainer();if(!C)return;const O=C.getBoundingClientRect(),X=(v.clientX-O.left-u.value)/c.value,j=(v.clientY-O.top-f.value)/c.value;Z(X,j)}function ae(v,C,O,X=60){const j=o.getContainer();if(!j)return;const G=j.getBoundingClientRect(),me=(G.width-X*2)/v,be=(G.height-X*2)/C,he=Math.min(1,Math.max(.3,Math.min(me,be)));c.value=he,u.value=G.width/2,f.value=G.height/2-O*he}return{scale:c,offsetX:u,offsetY:f,isPanning:p,onWheel:P,zoomIn:ie,zoomOut:ee,startPan:b,startMarquee:$,updateMarquee:Z,isMarquee:g,marquee:k,marqueeVersion:N,setOnMarqueeEnd:z,resetView:ae}}const un=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform);function lt(o){return un?o.metaKey:o.ctrlKey}function fn(o){function d(){const i=o.getSelectedId();return i||(o.defaultTargetId?o.defaultTargetId():o.getRootId())}function l(i){const c=i.target;if(c&&(c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.isContentEditable)||o.isReadonly()||o.isEditing())return;const u=o.getSelectedId(),f=d();if(f){if(lt(i)&&!i.shiftKey){if(i.key==="d"||i.key==="D"){u&&u!==o.getRootId()&&(i.preventDefault(),o.onDuplicate(u));return}if(i.key==="z"||i.key==="Z"){i.preventDefault(),o.onUndo();return}if(i.key==="y"||i.key==="Y"){i.preventDefault(),o.onRedo();return}if(i.key==="Home"){i.preventDefault(),o.onSelectRoot();return}}if(lt(i)&&i.shiftKey&&(i.key==="Z"||i.key==="z")){i.preventDefault(),o.onRedo();return}i.key==="Tab"?(i.preventDefault(),o.onAddChild(f)):i.key==="Enter"?(i.preventDefault(),i.shiftKey?u&&u!==o.getRootId()&&o.onAddSiblingBefore(u):o.onAddSibling(f)):(i.key==="Delete"||i.key==="Backspace")&&u&&u!==o.getRootId()?(i.preventDefault(),o.onRemove(u)):i.key==="F2"&&u?(i.preventDefault(),o.onStartEdit(u)):i.key==="Escape"?(i.preventDefault(),o.onClearSelection()):i.key==="ArrowDown"?(i.preventDefault(),o.onNavigate(0,1)):i.key==="ArrowUp"?(i.preventDefault(),o.onNavigate(0,-1)):i.key==="ArrowRight"?(i.preventDefault(),o.onNavigate(1,0)):i.key==="ArrowLeft"&&(i.preventDefault(),o.onNavigate(-1,0))}}e.onMounted(()=>{window.addEventListener("keydown",l)}),e.onBeforeUnmount(()=>{window.removeEventListener("keydown",l)})}function mn(o=100){const d=e.ref([]);let l=-1;function i(){return l>0}function c(){return l<d.value.length-1}function u(g){const s=JSON.stringify(g);for(l<d.value.length-1&&(d.value=d.value.slice(0,l+1)),d.value.push(s),l=d.value.length-1;d.value.length>o;)d.value.shift(),l--}function f(){return i()?(l--,JSON.parse(d.value[l])):null}function p(){return c()?(l++,JSON.parse(d.value[l])):null}function y(){d.value=[],l=-1}return{canUndo:i,canRedo:c,record:u,undo:f,redo:p,reset:y}}const hn=["disabled"],gn=["disabled"],yn=["disabled"],xn=["disabled"],pn=["disabled"],kn=["disabled"],wn=e.defineComponent({__name:"NodeContextMenu",props:{x:{},y:{},container:{},hasImage:{type:Boolean,default:!1},hasLink:{type:Boolean,default:!1},hasNote:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1}},emits:["pickImage","setLink","removeLink","editNote","removeNote","removeImage","close"],setup(o,{emit:d}){const l=o,i=d,c=e.computed(()=>{let N=l.x+2,w=l.y+2;if(l.container){const z=l.container.getBoundingClientRect(),P=180,ie=u.value?f.value?184:160:136;N+P>z.right&&(N=Math.max(z.left+4,l.x-P-2)),w+ie>z.bottom&&(w=Math.max(z.top+4,l.y-ie-2)),N<z.left+2&&(N=z.left+2),w<z.top+2&&(w=z.top+2)}return{left:N,top:w}}),u=e.computed(()=>l.hasImage),f=e.computed(()=>l.hasLink),p=e.computed(()=>l.hasNote);function y(N){const w=N.target;w&&w.closest(".zm-node-menu")||i("close")}function g(N){N.key==="Escape"&&i("close")}function s(){i("close")}window.addEventListener("mousedown",y,!0),window.addEventListener("keydown",g,!0),window.addEventListener("wheel",s,!0),window.addEventListener("scroll",s,!0),e.onBeforeUnmount(()=>{window.removeEventListener("mousedown",y,!0),window.removeEventListener("keydown",g,!0),window.removeEventListener("wheel",s,!0),window.removeEventListener("scroll",s,!0)});function k(N){l.readonly||(N(),i("close"))}return(N,w)=>(e.openBlock(),e.createElementBlock("div",{class:"zm-node-menu",style:e.normalizeStyle({left:c.value.left+"px",top:c.value.top+"px"}),onContextmenu:w[6]||(w[6]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("button",{class:"zm-node-menu-item",disabled:o.readonly,onClick:w[0]||(w[0]=e.withModifiers(z=>k(()=>i("pickImage")),["stop"]))},[e.createVNode(R,{name:"image",size:13}),e.createElementVNode("span",null,e.toDisplayString(u.value?"替换图片":"添加图片"),1)],8,hn),u.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"zm-node-menu-item",disabled:o.readonly,onClick:w[1]||(w[1]=e.withModifiers(z=>k(()=>i("removeImage")),["stop"]))},[e.createVNode(R,{name:"x",size:13}),w[7]||(w[7]=e.createElementVNode("span",null,"移除图片",-1))],8,gn)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"zm-node-menu-item",disabled:o.readonly,onClick:w[2]||(w[2]=e.withModifiers(z=>k(()=>i("setLink")),["stop"]))},[e.createVNode(R,{name:"link",size:13}),e.createElementVNode("span",null,e.toDisplayString(f.value?"编辑链接":"添加链接"),1)],8,yn),f.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zm-node-menu-item",disabled:o.readonly,onClick:w[3]||(w[3]=e.withModifiers(z=>k(()=>i("removeLink")),["stop"]))},[e.createVNode(R,{name:"x",size:13}),w[8]||(w[8]=e.createElementVNode("span",null,"移除链接",-1))],8,xn)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"zm-node-menu-item",disabled:o.readonly,onClick:w[4]||(w[4]=e.withModifiers(z=>k(()=>i("editNote")),["stop"]))},[e.createVNode(R,{name:"note",size:13}),e.createElementVNode("span",null,e.toDisplayString(p.value?"编辑笔记":"添加笔记"),1)],8,pn),p.value?(e.openBlock(),e.createElementBlock("button",{key:2,class:"zm-node-menu-item",disabled:o.readonly,onClick:w[5]||(w[5]=e.withModifiers(z=>k(()=>i("removeNote")),["stop"]))},[e.createVNode(R,{name:"x",size:13}),w[9]||(w[9]=e.createElementVNode("span",null,"移除笔记",-1))],8,kn)):e.createCommentVNode("",!0)],36))}}),bn=["viewBox","width","height"],En={class:"zm-edges"},Nn=["d","fill"],Mn=["data-node-id","onClick","onDblclick","onContextmenu","onMouseenter","onMouseleave"],Bn=["src","width","height","alt"],vn={key:1,class:"zm-text"},Cn={class:"zm-text-label"},Sn=["href","title"],Vn=["title","onClick"],zn=["title"],In=["title","onClick"],Wn=["onClick"],$n=["onMousedown"],Rn=["onClick"],Ln={key:0,class:"zm-toolbar"},An=["src"],Tn=["src"],Dn={class:"zm-tb-tip"},fe=24,we=400,re=160,rt=e.defineComponent({__name:"MindMap",props:{data:{},readonly:{type:Boolean,default:!1},theme:{},previewMode:{type:Boolean,default:!1},markdown:{},lineColors:{}},emits:["change","select","edit-note","markdownChange"],setup(o,{expose:d,emit:l}){const i=o,c=l,u=e.ref(null),f=e.ref(null),p=e.ref(""),y=e.ref(null),g=e.ref(new Set),s=e.ref(_(i.data)),k=e.ref(i.markdown!==void 0);let N=!1;e.watch(()=>i.markdown,t=>{if(t===void 0){k.value=!1;return}k.value=!0;const n=Pe(t||"");N=!0,s.value=_(n),y.value=null,g.value=new Set,W(),e.nextTick(()=>{N=!1,te()})}),e.watch(s,()=>{k.value&&!N&&c("markdownChange",ze(s.value))},{deep:!0});const w=e.computed(()=>E.showOrderBadge===!0),z=e.ref(new Map),P=z.value;function ie(t,n){const a={};n.bg&&(a.bg=n.bg),n.textColor&&(a.textColor=n.textColor),n.borderColor&&(a.borderColor=n.borderColor),n.fontWeight&&(a.fontWeight=n.fontWeight),Object.keys(a).length===0?P.delete(t):P.set(t,a),z.value=new Map(P)}function ee(t){return P.get(t)??{}}function b(t,n){const a=S(s.value,t);a&&(a.image={src:n.src,naturalW:n.naturalW,naturalH:n.naturalH,width:T(n.width,fe,we),height:T(n.height,fe,we)},H(),W(),c("change",s.value))}function F(t){const n=S(s.value,t);!n||!n.image||(delete n.image,H(),W(),c("change",s.value))}function T(t,n,a){return Math.min(a,Math.max(n,t))}function $(t,n){const a=new FileReader;a.onload=()=>{if(typeof a.result!="string")return;const h=a.result,m=new window.Image;m.onload=()=>{const r=m.naturalWidth||re,x=m.naturalHeight||re,V=T(r,fe,re),A=T(Math.round(x*V/r),fe,we);n({src:h,naturalW:r,naturalH:x,width:V,height:A})},m.onerror=()=>{n({src:h,naturalW:re,naturalH:re,width:re,height:re})},m.src=h},a.readAsDataURL(t)}function Z(t){const n=document.createElement("input");n.type="file",n.accept="image/*",n.style.display="none",n.onchange=()=>{var h;const a=(h=n.files)==null?void 0:h[0];a&&($(a,m=>b(t,m)),document.body.removeChild(n))},document.body.appendChild(n),n.click()}function D(t,n){const a=n.trim(),h=S(s.value,t);h&&(a?h.link={url:a}:delete h.link,H(),W(),c("change",s.value))}function Q(t){D(t,"")}function ae(t,n){const a=S(s.value,t);a&&(n?a.note={text:n}:delete a.note,H(),W(),c("change",s.value))}function v(t){ae(t,"")}const C=e.ref(null);function O(t,n){i.readonly||(t.preventDefault(),t.stopPropagation(),y.value=n.id,c("select",S(s.value,n.id)),C.value={nodeId:n.id,x:t.clientX,y:t.clientY})}function X(){C.value=null}function j(){var n;const t=(n=C.value)==null?void 0:n.nodeId;t&&Z(t)}function G(){var h,m,r;const t=(h=C.value)==null?void 0:h.nodeId;if(!t)return;const n=((r=(m=S(s.value,t))==null?void 0:m.link)==null?void 0:r.url)??"",a=window.prompt("输入链接 URL(留空取消)",n);a!==null&&D(t,a)}function me(){var n;const t=(n=C.value)==null?void 0:n.nodeId;t&&Q(t)}function be(){var n;const t=(n=C.value)==null?void 0:n.nodeId;t&&at(t)}function he(){var n;const t=(n=C.value)==null?void 0:n.nodeId;t&&v(t)}function Pn(){var n;const t=(n=C.value)==null?void 0:n.nodeId;t&&F(t)}function at(t){i.readonly||c("edit-note",t)}function Fn(t,n=60){const a=t.replace(/\s+/g," ").trim();return a.length<=n?a||"点击编辑笔记":a.slice(0,n)+"…"}function ct(t){var m;if(i.readonly||f.value)return;const n=t.target;if(n&&(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable))return;const a=y.value;if(!a)return;const h=(m=t.clipboardData)==null?void 0:m.items;if(h)for(let r=0;r<h.length;r++){const x=h[r];if(x.kind==="file"&&x.type.startsWith("image/")){const V=x.getAsFile();if(!V)continue;t.preventDefault();const A=S(s.value,a);if(A!=null&&A.image&&!window.confirm("该节点已有图片,要用剪贴板里的图片替换吗?"))return;$(V,q=>b(a,q));return}}}e.onMounted(()=>{window.addEventListener("paste",ct)}),e.onBeforeUnmount(()=>{window.removeEventListener("paste",ct)});const Ee=e.ref(null),On=e.computed(()=>{var t;return((t=Ee.value)==null?void 0:t.nodeId)??null});function qn(t,n){if(!n.image)return;t.preventDefault(),t.stopPropagation();const a=n.image.naturalW||n.image.width,h=n.image.naturalH||n.image.height,m=h>0?h/a:1;Ee.value={nodeId:n.id,startX:t.clientX,startY:t.clientY,startW:n.image.width,startH:n.image.height,naturalW:a,naturalH:h,ratio:m,pendingW:n.image.width,pendingH:n.image.height},window.addEventListener("mousemove",st),window.addEventListener("mouseup",dt)}function st(t){var A,q;const n=Ee.value;if(!n)return;const a=M.scale.value||1,h=t.clientX-n.startX,m=T(n.startW+h/a,fe,we),r=T(m*n.ratio,fe,we);n.pendingW=m,n.pendingH=r;const x=(A=u.value)==null?void 0:A.querySelector(`[data-node-id="${n.nodeId}"] .zm-node-img`);x&&(x.style.width=`${m}px`,x.style.height=`${r}px`);const V=(q=u.value)==null?void 0:q.querySelector(`[data-node-id="${n.nodeId}"]`);V&&(V.style.minWidth=`${Math.max(80,Math.ceil(m+28))}px`,V.style.height=`${Math.ceil(r+8+30)}px`)}function dt(){const t=Ee.value;if(window.removeEventListener("mousemove",st),window.removeEventListener("mouseup",dt),Ee.value=null,!t)return;const n=S(s.value,t.nodeId);!n||!n.image||(b(t.nodeId,{src:n.image.src,naturalW:n.image.naturalW,naturalH:n.image.naturalH,width:t.pendingW,height:t.pendingH}),y.value=t.nodeId,c("select",n),Oe=!0)}const Fe=e.ref(null);let Oe=!1;function Xn(t){Fe.value=t}function Kn(t){Fe.value===t&&(Fe.value=null)}const ut=e.ref(0),qe=e.ref(!1),le=mn(100);function H(){le.record({data:s.value})}function W(){g.value=new Set(g.value),ut.value++}const J=e.computed(()=>{var t,n,a,h,m,r,x,V,A,q;return{rootBg:((t=i.theme)==null?void 0:t.rootBg)??"#1f2937",rootText:((n=i.theme)==null?void 0:n.rootText)??"#ffffff",branchBg:((a=i.theme)==null?void 0:a.branchBg)??"#ffffff",branchText:((h=i.theme)==null?void 0:h.branchText)??"#1f2937",lineColor:((m=i.theme)==null?void 0:m.lineColor)??"#94a3b8",bgColor:((r=i.theme)==null?void 0:r.bgColor)??"#f8fafc",fontSize:((x=i.theme)==null?void 0:x.fontSize)??14,lineWidthStart:((V=i.theme)==null?void 0:V.lineWidthStart)??2.2,lineWidthEnd:((A=i.theme)==null?void 0:A.lineWidthEnd)??.8,rainbowBranch:((q=i.theme)==null?void 0:q.rainbowBranch)??!1}}),E=e.reactive({autoBalanceOnChange:!0,lineWidthStart:12,lineWidthEnd:3.6,rainbowBranch:!0,branchPaletteId:"default",customPalettes:[],lineStyle:"curve",layoutMode:"mindmap",taperedEdge:!0,showOrderBadge:!1});function ft(t){return E.taperedEdge?Un(t):ht(t)}function mt(t){return E.taperedEdge?E.lineWidthEnd:ht(t)}function Un(t){return t<=0?E.lineWidthStart:t===1?Math.max(1.5,E.lineWidthStart*.67):t===2?Math.max(.8,E.lineWidthStart*.42):E.lineWidthEnd}function ht(t){if(t<=0)return E.lineWidthStart;if(t>=3)return E.lineWidthEnd;const n=t/3;return E.lineWidthStart+(E.lineWidthEnd-E.lineWidthStart)*n}function Yn(t,n,a,h){const m=1-t,r=m*m*m*n.x+3*m*m*t*a.x1+3*m*t*t*a.x2+t*t*t*h.x,x=m*m*m*n.y+3*m*m*t*a.y1+3*m*t*t*a.y2+t*t*t*h.y;return{x:r,y:x}}function jn(t,n,a,h,m=32,r="curve",x="right"){if(r==="curve"){let de;if(x==="right"||x==="left"){const I=Math.abs(n.x-t.x)*.45,ne=x==="right"?1:-1;de={x1:t.x+ne*I,y1:t.y,x2:n.x-ne*I,y2:n.y}}else{const I=Math.abs(n.y-t.y)*.45;de={x1:t.x,y1:t.y+I,x2:n.x,y2:n.y-I}}const po=B=>{const I=1-B,ne=-3*I*I*t.x+3*(I*I-2*I*B)*de.x1+3*(2*I*B-B*B)*de.x2+3*B*B*n.x,pe=-3*I*I*t.y+3*(I*I-2*I*B)*de.y1+3*(2*I*B-B*B)*de.y2+3*B*B*n.y;return{dx:ne,dy:pe}},Be=[],Ge=[];for(let B=0;B<=m;B++){const I=B/m,ne=B===0?t:B===m?n:Yn(I,t,de,n),pe=po(I);let Le=Math.hypot(pe.dx,pe.dy);Le<1e-6&&(Le=1);const Wt=-pe.dy/Le,$t=pe.dx/Le,Ae=(a+(h-a)*I)/2;Be.push({x:ne.x+Wt*Ae,y:ne.y+$t*Ae}),Ge.push({x:ne.x-Wt*Ae,y:ne.y-$t*Ae})}let Re=`M ${Be[0].x.toFixed(2)} ${Be[0].y.toFixed(2)}`;for(let B=1;B<=m;B++)Re+=` L ${Be[B].x.toFixed(2)} ${Be[B].y.toFixed(2)}`;for(let B=m;B>=0;B--)Re+=` L ${Ge[B].x.toFixed(2)} ${Ge[B].y.toFixed(2)}`;return Re+=" Z",Re}const V=n.x-t.x,A=n.y-t.y;let q=Math.hypot(V,A);q<1e-6&&(q=1);const se=-A/q,ye=V/q,xe=a/2,Me=h/2,St={x:t.x+se*xe,y:t.y+ye*xe},Vt={x:t.x-se*xe,y:t.y-ye*xe},zt={x:n.x-se*Me,y:n.y-ye*Me},It={x:n.x+se*Me,y:n.y+ye*Me};return`M ${St.x.toFixed(2)} ${St.y.toFixed(2)} L ${It.x.toFixed(2)} ${It.y.toFixed(2)} L ${zt.x.toFixed(2)} ${zt.y.toFixed(2)} L ${Vt.x.toFixed(2)} ${Vt.y.toFixed(2)} Z`}const Ie=e.computed(()=>K.value.root.children),Gn=ke[0].colors,gt=e.computed(()=>ln(E.branchPaletteId,E.customPalettes)),ce=e.computed(()=>{const t=new Map;if(!E.rainbowBranch)return t;const n=i.lineColors,a=n&&n.length>0?n:gt.value.colors.length>0?gt.value.colors:Gn;for(let m=0;m<Ie.value.length;m++){const r=Ie.value[m];t.set(r.id,a[m%a.length])}const h=(m,r)=>{t.set(m.id,r);for(const x of m.children)h(x,r)};for(let m=0;m<Ie.value.length;m++){const r=Ie.value[m];h(r,a[m%a.length])}return t});function Jn(t,n){return E.rainbowBranch?ce.value.get(n.id)??J.value.lineColor:J.value.lineColor}function Zn(t){const n=ee(t.id);if(n.bg)return n.bg;if(t.isRoot)return J.value.rootBg;if(E.rainbowBranch){const a=ce.value.get(t.id);if(a)return to(a,.18)}return J.value.branchBg}function Qn(t){const n=ee(t.id);if(n.textColor)return n.textColor;if(t.isRoot)return J.value.rootText;if(E.rainbowBranch){const a=ce.value.get(t.id);if(a)return yt(a,.55)}return J.value.branchText}function _n(t){const n=ee(t.id);if(n.borderColor)return n.borderColor;if(t.isRoot)return J.value.rootBg;if(E.rainbowBranch){const a=ce.value.get(t.id);if(a)return yt(a,.3)}return J.value.lineColor}function eo(t){return ee(t.id).fontWeight??(t.isRoot?600:400)}function to(t,n){const a=t.replace("#",""),h=a.length===6?a:a.split("").map(V=>V+V).join(""),m=parseInt(h.slice(0,2),16),r=parseInt(h.slice(2,4),16),x=parseInt(h.slice(4,6),16);return`rgba(${m}, ${r}, ${x}, ${n})`}function yt(t,n){const a=t.replace("#",""),h=a.length===6?a:a.split("").map(V=>V+V).join(""),m=Math.round(parseInt(h.slice(0,2),16)*(1-n)),r=Math.round(parseInt(h.slice(2,4),16)*(1-n)),x=Math.round(parseInt(h.slice(4,6),16)*(1-n));return`rgb(${m}, ${r}, ${x})`}const M=dn({getContainer:()=>u.value});M.setOnMarqueeEnd(mo),fn({isEditing:()=>f.value!==null,isReadonly:()=>i.readonly,getSelectedId:()=>y.value,getRootId:()=>s.value.id,defaultTargetId:()=>s.value.id,onAddChild:ge,onAddSibling:$e,onAddSiblingBefore:kt,onRemove:bt,onStartEdit:Ne,onClearSelection:()=>{y.value=null,c("select",null)},onDuplicate:wt,onUndo:Ke,onRedo:Ue,onNavigate:ro,onSelectRoot:()=>{y.value=s.value.id;const t=S(s.value,s.value.id);t&&c("select",t)}});const K=e.computed(()=>{const t=_(s.value);return pt(t),en(t,{mode:E.layoutMode,baseFontSize:J.value.fontSize})}),xt=e.ref([]),Xe=e.computed(()=>(ut.value,xt.value));e.watch(K,t=>{const n=[],a=h=>{n.push(h);for(const m of h.children)a(m)};a(t.root),xt.value=n},{immediate:!0});const no=e.computed(()=>{const t=[];for(const n of Xe.value)for(const a of n.children)t.push({from:n,to:a,key:`${n.id}->${a.id}`});return t}),oo=e.computed(()=>`${K.value.vbX} ${K.value.vbY} ${K.value.vbW} ${K.value.vbH}`);function pt(t){if(g.value.has(t.id)){t.children=[],t.collapsed=!0;return}t.collapsed=!1;for(const n of t.children)pt(n)}function Ne(t){const n=S(s.value,t);n&&(f.value=t,p.value=n.text,e.nextTick(()=>{const a=document.querySelector(".zm-input");a==null||a.focus(),a==null||a.select()}))}function We(t={}){if(!f.value)return;const n=S(s.value,f.value);n&&n.text!==(p.value.trim()||" ")&&(n.text=p.value.trim()||" ",H(),c("change",s.value));const a=f.value;f.value=null,t.addChild?e.nextTick(()=>ge(a)):t.addSibling==="after"?e.nextTick(()=>$e(a)):t.addSibling==="before"&&e.nextTick(()=>kt(a))}function io(){f.value=null}function lo(t){const n=t.metaKey||t.ctrlKey;n&&(t.key==="z"||t.key==="Z")&&!t.shiftKey?(t.preventDefault(),Ke()):(n&&t.shiftKey&&(t.key==="z"||t.key==="Z")||n&&(t.key==="y"||t.key==="Y")&&!t.shiftKey)&&(t.preventDefault(),Ue())}function ge(t){const n=nt(s.value,t,Ve);n&&(H(),W(),c("change",s.value),e.nextTick(()=>Ne(n.id)))}function $e(t){if(t===s.value.id){ge(t);return}const n=ot(s.value,t,Ve);n&&(H(),W(),c("change",s.value),e.nextTick(()=>Ne(n.id)))}function kt(t){if(t===s.value.id){ge(t);return}const n=cn(s.value,t,Ve);n&&(H(),W(),c("change",s.value),e.nextTick(()=>Ne(n.id)))}function wt(t){if(t===s.value.id)return;const n=sn(s.value,t);n&&(H(),y.value=n.id,c("change",s.value),W())}function Ke(){const t=le.undo();t&&(s.value=t.data,y.value=null,c("select",null),W(),c("change",s.value))}function Ue(){const t=le.redo();t&&(s.value=t.data,y.value=null,c("select",null),W(),c("change",s.value))}function ro(t,n){const a=y.value??s.value.id,h=S(s.value,a);if(!h)return;let m=null;if(n===1){const r=Y(s.value,h.id);if(r){const x=r.children.findIndex(V=>V.id===h.id);x>=0&&x<r.children.length-1&&(m=r.children[x+1].id)}}else if(n===-1){const r=Y(s.value,h.id);if(r){const x=r.children.findIndex(V=>V.id===h.id);x>0&&(m=r.children[x-1].id)}}else if(t===1){const r=Y(s.value,h.id);r&&(m=r.id)}else t===-1&&h.children.length>0&&(m=h.children[0].id);if(m){y.value=m;const r=S(s.value,m);r&&c("select",r)}}function bt(t){t!==s.value.id&&He(s.value,t)&&(H(),y.value===t&&(y.value=null),W(),c("change",s.value))}function Et(t){g.value.has(t)?g.value.delete(t):g.value.add(t),W()}function ao(t,n){rn(s.value,t,n)&&(H(),W(),c("change",s.value))}function co(t,n,a){return an(s.value,t,n,a)?(H(),W(),c("change",s.value),!0):!1}function so(t,n){t.stopPropagation(),y.value=n.id;const a=S(s.value,n.id);c("select",a)}function uo(t){const n=t.target;if(!n||n.closest(".zm-node, .zm-toolbar, button, input, textarea"))return;if(t.button===2){M.startPan(t);return}if(t.button!==0)return;const a=u.value.getBoundingClientRect(),h=(t.clientX-a.left-M.offsetX.value)/M.scale.value,m=(t.clientY-a.top-M.offsetY.value)/M.scale.value;M.startMarquee(h,m)}function fo(t){if(Oe){Oe=!1;return}const n=t.target;if(!n||n.closest(".zm-node"))return;const a=M.marquee;a.width>=4||a.height>=4||y.value!==null&&(y.value=null,c("select",null))}function mo(){const t=M.marquee;if(t.width<4&&t.height<4)return;const n=t.x,a=t.y,h=t.x+t.width,m=t.y+t.height,r=[];for(const x of Xe.value){const V=x.width/2,A=x.height/2,q=x.x-V,se=x.x+V,ye=x.y-A,xe=x.y+A;q<=h&&se>=n&&ye<=m&&xe>=a&&r.push(x.id)}if(r.length>0){y.value=r[0];const x=S(s.value,r[0]);x&&c("select",x)}}function Nt(t){return g.value.has(t)}function ho(t){const n=S(s.value,t.id);return!!n&&n.children.length>0}function Ye(t){const n=S(s.value,t);return n?n.children.length:0}function Mt(t){if(!S(s.value,t))return 0;const h=[s.value];for(;h.length;){const m=h.pop(),r=m.children.findIndex(x=>x.id===t);if(r>=0)return r;for(const x of m.children)h.push(x)}return 0}function Bt(t,n,a,h){if(((h==null?void 0:h._dir)??t._dir)==="down")return n==="out"?{x:t.x,y:t.y+t.height/2}:{x:t.x,y:t.y-t.height/2};let r;return n==="in"?r=-t.side:a!==void 0?r=a:r=t.side,{x:t.x+r*(t.width/2),y:t.y}}function te(){const t=K.value;M.resetView(t.width,t.height,t.root.y)}function go(){qe.value=!0,H(),W(),e.nextTick(()=>te())}function je(t){E.layoutMode!==t&&(E.layoutMode=t,W(),e.nextTick(()=>te()))}function vt(){return JSON.stringify(s.value,null,2)}function Ct(t){try{const n=JSON.parse(t);return!n.id||!Array.isArray(n.children)?!1:(le.reset(),s.value=_(n),y.value=null,g.value=new Set,W(),e.nextTick(()=>te()),c("change",s.value),!0)}catch{return!1}}function yo(){const t=document.createElement("input");t.type="file",t.accept="application/json",t.onchange=()=>{var h;const n=(h=t.files)==null?void 0:h[0];if(!n)return;const a=new FileReader;a.onload=()=>{typeof a.result=="string"&&(Ct(a.result)||alert("导入失败:JSON 格式无效"))},a.readAsText(n)},t.click()}function xo(){const t=new Blob([vt()],{type:"application/json"}),n=URL.createObjectURL(t),a=document.createElement("a");a.href=n,a.download=`${s.value.text||"mindmap"}.json`,a.click(),URL.revokeObjectURL(n)}return d({addChild:t=>ge(t),addSibling:t=>$e(t),removeNode:t=>bt(t),duplicateNode:t=>wt(t),setNodeText:(t,n)=>ao(t,n),moveNode:(t,n,a)=>co(t,n,a),lineWidthForDepth:ft,endWidthForDepth:mt,getData:()=>s.value,setData:t=>{le.reset(),s.value=_(t),y.value=null,g.value=new Set,W(),H(),e.nextTick(()=>te())},resetView:()=>te(),exportData:vt,importData:Ct,getMarkdown:()=>ze(s.value),setMarkdown:(t,n=!0)=>{const a=Pe(t||"");n&&(k.value=!0),N=!n,le.reset(),s.value=_(a),y.value=null,g.value=new Set,W(),H(),e.nextTick(()=>{N=!1,te()}),c("change",s.value)},setBalanced:t=>{qe.value=t},isBalanced:()=>qe.value,balance:()=>go(),applyNodeStyle:(t,n)=>ie(t,n),getNodeStyle:t=>ee(t),applyNodeLink:(t,n)=>D(t,n),removeNodeLink:t=>Q(t),applyNodeNote:(t,n)=>ae(t,n),removeNodeNote:t=>v(t),undo:()=>Ke(),redo:()=>Ue(),canUndo:()=>le.canUndo(),canRedo:()=>le.canRedo(),applySettings:t=>{t.autoBalanceOnChange!==void 0&&(E.autoBalanceOnChange=t.autoBalanceOnChange),t.lineWidthStart!==void 0&&(E.lineWidthStart=Math.max(.5,Math.min(20,t.lineWidthStart))),t.lineWidthEnd!==void 0&&(E.lineWidthEnd=Math.max(.3,Math.min(10,t.lineWidthEnd))),t.rainbowBranch!==void 0&&(E.rainbowBranch=t.rainbowBranch),t.branchPaletteId!==void 0&&(E.branchPaletteId=t.branchPaletteId),t.customPalettes!==void 0&&(E.customPalettes=t.customPalettes),t.lineStyle!==void 0&&(E.lineStyle=t.lineStyle),t.taperedEdge!==void 0&&(E.taperedEdge=t.taperedEdge),t.showOrderBadge!==void 0&&(E.showOrderBadge=t.showOrderBadge)},getSettings:()=>({autoBalanceOnChange:E.autoBalanceOnChange,lineWidthStart:E.lineWidthStart,lineWidthEnd:E.lineWidthEnd,rainbowBranch:E.rainbowBranch,branchPaletteId:E.branchPaletteId,customPalettes:E.customPalettes,lineStyle:E.lineStyle,layoutMode:E.layoutMode,taperedEdge:E.taperedEdge,showOrderBadge:E.showOrderBadge}),setBranchPalette:t=>{if(!t)return;[...ke,...E.customPalettes].find(a=>a.id===t)&&(E.branchPaletteId=t)},getBranchPalette:()=>E.branchPaletteId,getBranchPalettes:()=>[...ke,...E.customPalettes]}),e.watch(()=>i.data,t=>{s.value=_(t),W()},{deep:!1}),e.onMounted(()=>{H(),e.nextTick(()=>te())}),(t,n)=>{var a,h,m;return e.openBlock(),e.createElementBlock("div",{class:"zm-mindmap",style:e.normalizeStyle({background:J.value.bgColor,fontSize:J.value.fontSize+"px"})},[e.createElementVNode("div",{ref_key:"wrapperRef",ref:u,class:"zm-canvas",onMousedown:uo,onContextmenu:n[13]||(n[13]=e.withModifiers(()=>{},["prevent"])),onWheel:n[14]||(n[14]=(...r)=>e.unref(M).onWheel&&e.unref(M).onWheel(...r)),onClick:fo},[e.createElementVNode("div",{class:"zm-svg-layer",style:e.normalizeStyle({left:K.value.vbX*e.unref(M).scale.value+e.unref(M).offsetX.value+"px",top:K.value.vbY*e.unref(M).scale.value+e.unref(M).offsetY.value+"px",width:K.value.vbW*e.unref(M).scale.value+"px",height:K.value.vbH*e.unref(M).scale.value+"px"})},[(e.openBlock(),e.createElementBlock("svg",{class:"zm-svg",viewBox:oo.value,preserveAspectRatio:"xMinYMin meet",width:K.value.vbW*e.unref(M).scale.value,height:K.value.vbH*e.unref(M).scale.value},[e.createElementVNode("g",En,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(no.value,r=>(e.openBlock(),e.createElementBlock("path",{key:r.key,d:jn(Bt(r.from,"out",r.to.side,r.to),Bt(r.to,"in"),ft(r.from.depth),mt(r.to.depth),32,E.lineStyle,r.to._dir),fill:Jn(r.from,r.to),stroke:"none"},null,8,Nn))),128))])],8,bn))],4),e.unref(M).isMarquee.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"zm-marquee",style:e.normalizeStyle({left:e.unref(M).marquee.x*e.unref(M).scale.value+e.unref(M).offsetX.value+"px",top:e.unref(M).marquee.y*e.unref(M).scale.value+e.unref(M).offsetY.value+"px",width:e.unref(M).marquee.width*e.unref(M).scale.value+"px",height:e.unref(M).marquee.height*e.unref(M).scale.value+"px"})},null,4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"zm-world",style:e.normalizeStyle({transform:`translate(${e.unref(M).offsetX.value}px, ${e.unref(M).offsetY.value}px) scale(${e.unref(M).scale.value})`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Xe.value,r=>(e.openBlock(),e.createElementBlock("div",{key:r.id,class:e.normalizeClass(["zm-node",{"is-root":r.isRoot,"is-selected":y.value===r.id,"is-editing":f.value===r.id,"has-image":!!r.image,"is-resizing":On.value===r.id}]),"data-node-id":r.id,style:e.normalizeStyle({left:r.x+"px",top:r.y+"px",minWidth:r.width+"px",height:r.height+"px",fontSize:r.fontSize+"px",background:Zn(r),color:Qn(r),borderColor:_n(r),fontWeight:eo(r),transform:"translate(-50%, -50%)"}),onClick:x=>so(x,r),onDblclick:x=>{x.stopPropagation(),o.readonly||Ne(r.id)},onContextmenu:x=>O(x,r),onMouseenter:x=>Xn(r.id),onMouseleave:x=>Kn(r.id)},[r.image?(e.openBlock(),e.createElementBlock("img",{key:0,class:"zm-node-img",src:r.image.src,width:r.image.width,height:r.image.height,alt:r.text,draggable:"false"},null,8,Bn)):e.createCommentVNode("",!0),f.value!==r.id?(e.openBlock(),e.createElementBlock("span",vn,[e.createElementVNode("span",Cn,e.toDisplayString(r.text),1),r.link&&!f.value?(e.openBlock(),e.createElementBlock("a",{key:0,class:"zm-node-link",href:r.link.url,target:"_blank",rel:"noopener noreferrer",title:`打开链接:${r.link.url}`,onClick:n[0]||(n[0]=e.withModifiers(()=>{},["stop"])),onMousedown:n[1]||(n[1]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(R,{name:"link",size:11,stroke:2})],40,Sn)):e.createCommentVNode("",!0),r.note&&!f.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zm-node-note-btn",type:"button",title:Fn(r.note.text),onClick:e.withModifiers(x=>at(r.id),["stop"]),onMousedown:n[2]||(n[2]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(R,{name:"note",size:11,stroke:2})],40,Vn)):e.createCommentVNode("",!0)])):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,class:"zm-input","onUpdate:modelValue":n[3]||(n[3]=x=>p.value=x),autofocus:"",onBlur:n[4]||(n[4]=x=>We()),onKeydown:[n[5]||(n[5]=e.withKeys(e.withModifiers(x=>We({addSibling:"after"}),["exact"]),["enter"])),n[6]||(n[6]=e.withKeys(e.withModifiers(x=>We({addSibling:"before"}),["shift","prevent","exact"]),["enter"])),n[7]||(n[7]=e.withKeys(e.withModifiers(x=>We({addChild:!0}),["prevent"]),["tab"])),e.withKeys(io,["esc"]),lo],onMousedown:n[8]||(n[8]=e.withModifiers(()=>{},["stop"])),onClick:n[9]||(n[9]=e.withModifiers(()=>{},["stop"]))},null,544)),[[e.vModelText,p.value]]),w.value?(e.openBlock(),e.createElementBlock("span",{key:3,class:"zm-order-badge",title:`数据顺序:第 ${Mt(r.id)+1} 个`},e.toDisplayString(Mt(r.id)+1),9,zn)):e.createCommentVNode("",!0),Nt(r.id)&&!r.isRoot&&Ye(r.id)>0?(e.openBlock(),e.createElementBlock("span",{key:4,class:e.normalizeClass(["zm-collapse-badge",{"is-on-left":r.side===-1}]),style:e.normalizeStyle({background:ce.value.get(r.id)??"#64748b"}),title:`展开 ${Ye(r.id)} 个子节点`,onMousedown:n[10]||(n[10]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(x=>Et(r.id),["stop"])},e.toDisplayString(Ye(r.id)),47,In)):e.createCommentVNode("",!0),!o.readonly&&!r.isRoot&&ho(r)&&!Nt(r.id)?(e.openBlock(),e.createElementBlock("button",{key:5,class:e.normalizeClass(["zm-btn zm-collapse",{"is-on-left":r.side===-1}]),style:e.normalizeStyle({color:ce.value.get(r.id)??"#64748b",borderColor:ce.value.get(r.id)??"#64748b"}),title:"折叠",onMousedown:n[11]||(n[11]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(x=>Et(r.id),["stop"])},[e.createVNode(R,{name:"minus",size:10,stroke:2.4})],46,Wn)):e.createCommentVNode("",!0),r.image&&y.value===r.id&&f.value!==r.id?(e.openBlock(),e.createElementBlock("span",{key:6,class:"zm-img-resize-handle",title:"拖动调整图片大小",onMousedown:e.withModifiers(x=>qn(x,r),["stop"])},null,40,$n)):e.createCommentVNode("",!0),r.image&&y.value===r.id&&f.value!==r.id?(e.openBlock(),e.createElementBlock("button",{key:7,class:"zm-img-remove-btn",title:"移除图片",onMousedown:n[12]||(n[12]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(x=>F(r.id),["stop"])},[e.createVNode(R,{name:"x",size:9,stroke:2.2})],40,Rn)):e.createCommentVNode("",!0)],46,Mn))),128))],4),C.value?(e.openBlock(),e.createBlock(wn,{key:1,x:C.value.x,y:C.value.y,container:u.value,"has-image":!!((a=e.unref(S)(s.value,C.value.nodeId))!=null&&a.image),"has-link":!!((h=e.unref(S)(s.value,C.value.nodeId))!=null&&h.link),"has-note":!!((m=e.unref(S)(s.value,C.value.nodeId))!=null&&m.note),readonly:i.readonly,onPickImage:j,onRemoveImage:Pn,onSetLink:G,onRemoveLink:me,onEditNote:be,onRemoveNote:he,onClose:X},null,8,["x","y","container","has-image","has-link","has-note","readonly"])):e.createCommentVNode("",!0)],544),i.previewMode?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ln,[e.createElementVNode("button",{class:"zm-tb-btn",title:"放大",onClick:n[15]||(n[15]=(...r)=>e.unref(M).zoomIn&&e.unref(M).zoomIn(...r))},[e.createVNode(R,{name:"zoom-in"})]),e.createElementVNode("button",{class:"zm-tb-btn",title:"缩小",onClick:n[16]||(n[16]=(...r)=>e.unref(M).zoomOut&&e.unref(M).zoomOut(...r))},[e.createVNode(R,{name:"zoom-out"})]),e.createElementVNode("button",{class:"zm-tb-btn",title:"重置视图",onClick:te},[e.createVNode(R,{name:"reset"})]),n[22]||(n[22]=e.createElementVNode("span",{class:"zm-tb-divider"},null,-1)),o.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"zm-tb-btn",title:"添加子节点 (Tab)",onClick:n[17]||(n[17]=r=>y.value&&ge(y.value))},[e.createElementVNode("img",{src:e.unref(Dt),width:"14",height:"14",alt:"添加子节点",draggable:"false"},null,8,An)])),o.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"zm-tb-btn",title:"添加同级 (Enter)",onClick:n[18]||(n[18]=r=>y.value&&$e(y.value))},[e.createElementVNode("img",{src:e.unref(Tt),width:"14",height:"14",alt:"添加同级",draggable:"false"},null,8,Tn)])),n[23]||(n[23]=e.createElementVNode("span",{class:"zm-tb-divider"},null,-1)),e.createElementVNode("button",{class:e.normalizeClass(["zm-tb-btn",{active:E.layoutMode==="mindmap"}]),title:"思维导图布局 (中心辐射)",onClick:n[19]||(n[19]=r=>je("mindmap"))},[e.createVNode(R,{name:"mindmap"})],2),e.createElementVNode("button",{class:e.normalizeClass(["zm-tb-btn",{active:E.layoutMode==="tree"}]),title:"树形布局 (向右展开)",onClick:n[20]||(n[20]=r=>je("tree"))},[e.createVNode(R,{name:"tree"})],2),e.createElementVNode("button",{class:e.normalizeClass(["zm-tb-btn",{active:E.layoutMode==="org"}]),title:"组织结构布局 (向下展开)",onClick:n[21]||(n[21]=r=>je("org"))},[e.createVNode(R,{name:"org"})],2),n[24]||(n[24]=e.createElementVNode("span",{class:"zm-tb-divider"},null,-1)),o.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:2,class:"zm-tb-btn",title:"导入 JSON",onClick:yo},[e.createVNode(R,{name:"import"})])),e.createElementVNode("button",{class:"zm-tb-btn",title:"导出 JSON",onClick:xo},[e.createVNode(R,{name:"export"})]),e.createElementVNode("span",Dn,e.toDisplayString(Math.round(e.unref(M).scale.value*100))+"%",1)]))],4)}}}),Hn={install(o){o.component("FlowMindMap",rt)}};L.MindMap=rt,L.addChild=nt,L.addSibling=ot,L.clone=_,L.default=Hn,L.findNode=S,L.findParent=Y,L.markdownToMindMap=Pe,L.mindMapToMarkdown=ze,L.removeNode=He,L.uid=oe,Object.defineProperties(L,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
5
|
+
`),o.note&&(l+="```note\n"+o.note.text+"\n```\n");for(const i of o.children)l+=ze(i,d+1);return l}function un(o){const d=o.minScale??.2,l=o.maxScale??3,i=o.step??1.2,c=e.ref(1),u=e.ref(0),f=e.ref(0),p=e.ref(!1),y=e.reactive({x:0,y:0,ox:0,oy:0}),g=e.ref(!1),s=e.reactive({x:0,y:0}),k=e.reactive({x:0,y:0,width:0,height:0}),N=e.ref(0);let w=null;function z(v){w=v}function P(v){v.preventDefault();const C=o.getContainer();if(!C)return;const O=-v.deltaY*.001,q=Math.min(l,Math.max(d,c.value*(1+O))),j=C.getBoundingClientRect(),G=v.clientX-j.left,me=v.clientY-j.top,be=(G-u.value)/c.value,he=(me-f.value)/c.value;c.value=q,u.value=G-be*q,f.value=me-he*q}function ie(){c.value=Math.min(l,c.value*i)}function ee(){c.value=Math.max(d,c.value/i)}function b(v){var O;v.target.closest(".zm-node, .zm-toolbar, button, input, textarea")||(p.value=!0,y.x=v.clientX,y.y=v.clientY,y.ox=u.value,y.oy=f.value,window.addEventListener("mousemove",F),window.addEventListener("mouseup",L),(O=v.preventDefault)==null||O.call(v))}function F(v){p.value&&(u.value=y.ox+(v.clientX-y.x),f.value=y.oy+(v.clientY-y.y))}function L(){p.value=!1,window.removeEventListener("mousemove",F),window.removeEventListener("mouseup",L)}function $(v,C){g.value=!0,s.x=v,s.y=C,k.x=v,k.y=C,k.width=0,k.height=0,N.value++,window.addEventListener("mousemove",Q),window.addEventListener("mouseup",D)}function Z(v,C){if(!g.value)return;const O=Math.min(s.x,v),q=Math.min(s.y,C),j=Math.max(s.x,v),G=Math.max(s.y,C);k.x=O,k.y=q,k.width=j-O,k.height=G-q,N.value++}function D(){g.value=!1,window.removeEventListener("mousemove",Q),window.removeEventListener("mouseup",D),w&&w()}function Q(v){if(!g.value)return;const C=o.getContainer();if(!C)return;const O=C.getBoundingClientRect(),q=(v.clientX-O.left-u.value)/c.value,j=(v.clientY-O.top-f.value)/c.value;Z(q,j)}function ae(v,C,O,q=60){const j=o.getContainer();if(!j)return;const G=j.getBoundingClientRect(),me=(G.width-q*2)/v,be=(G.height-q*2)/C,he=Math.min(1,Math.max(.3,Math.min(me,be)));c.value=he,u.value=G.width/2,f.value=G.height/2-O*he}return{scale:c,offsetX:u,offsetY:f,isPanning:p,onWheel:P,zoomIn:ie,zoomOut:ee,startPan:b,startMarquee:$,updateMarquee:Z,isMarquee:g,marquee:k,marqueeVersion:N,setOnMarqueeEnd:z,resetView:ae}}const fn=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform);function lt(o){return fn?o.metaKey:o.ctrlKey}function mn(o){function d(){const i=o.getSelectedId();return i||(o.defaultTargetId?o.defaultTargetId():o.getRootId())}function l(i){const c=i.target;if(c&&(c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.isContentEditable)||o.isReadonly()||o.isEditing())return;const u=o.getSelectedId(),f=d();if(f){if(lt(i)&&!i.shiftKey){if(i.key==="d"||i.key==="D"){u&&u!==o.getRootId()&&(i.preventDefault(),o.onDuplicate(u));return}if(i.key==="z"||i.key==="Z"){i.preventDefault(),o.onUndo();return}if(i.key==="y"||i.key==="Y"){i.preventDefault(),o.onRedo();return}if(i.key==="Home"){i.preventDefault(),o.onSelectRoot();return}}if(lt(i)&&i.shiftKey&&(i.key==="Z"||i.key==="z")){i.preventDefault(),o.onRedo();return}i.key==="Tab"?(i.preventDefault(),o.onAddChild(f)):i.key==="Enter"?(i.preventDefault(),i.shiftKey?u&&u!==o.getRootId()&&o.onAddSiblingBefore(u):o.onAddSibling(f)):(i.key==="Delete"||i.key==="Backspace")&&u&&u!==o.getRootId()?(i.preventDefault(),o.onRemove(u)):i.key==="F2"&&u?(i.preventDefault(),o.onStartEdit(u)):i.key==="Escape"?(i.preventDefault(),o.onClearSelection()):i.key==="ArrowDown"?(i.preventDefault(),o.onNavigate(0,1)):i.key==="ArrowUp"?(i.preventDefault(),o.onNavigate(0,-1)):i.key==="ArrowRight"?(i.preventDefault(),o.onNavigate(1,0)):i.key==="ArrowLeft"&&(i.preventDefault(),o.onNavigate(-1,0))}}e.onMounted(()=>{window.addEventListener("keydown",l)}),e.onBeforeUnmount(()=>{window.removeEventListener("keydown",l)})}function hn(o=100){const d=e.ref([]);let l=-1;function i(){return l>0}function c(){return l<d.value.length-1}function u(g){const s=JSON.stringify(g);for(l<d.value.length-1&&(d.value=d.value.slice(0,l+1)),d.value.push(s),l=d.value.length-1;d.value.length>o;)d.value.shift(),l--}function f(){return i()?(l--,JSON.parse(d.value[l])):null}function p(){return c()?(l++,JSON.parse(d.value[l])):null}function y(){d.value=[],l=-1}return{canUndo:i,canRedo:c,record:u,undo:f,redo:p,reset:y}}const gn=["disabled"],yn=["disabled"],xn=["disabled"],pn=["disabled"],kn=["disabled"],wn=["disabled"],bn=e.defineComponent({__name:"NodeContextMenu",props:{x:{},y:{},container:{},hasImage:{type:Boolean,default:!1},hasLink:{type:Boolean,default:!1},hasNote:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1}},emits:["pickImage","setLink","removeLink","editNote","removeNote","removeImage","close"],setup(o,{emit:d}){const l=o,i=d,c=e.computed(()=>{let N=l.x+2,w=l.y+2;if(l.container){const z=l.container.getBoundingClientRect(),P=180,ie=u.value?f.value?184:160:136;N+P>z.right&&(N=Math.max(z.left+4,l.x-P-2)),w+ie>z.bottom&&(w=Math.max(z.top+4,l.y-ie-2)),N<z.left+2&&(N=z.left+2),w<z.top+2&&(w=z.top+2)}return{left:N,top:w}}),u=e.computed(()=>l.hasImage),f=e.computed(()=>l.hasLink),p=e.computed(()=>l.hasNote);function y(N){const w=N.target;w&&w.closest(".zm-node-menu")||i("close")}function g(N){N.key==="Escape"&&i("close")}function s(){i("close")}window.addEventListener("mousedown",y,!0),window.addEventListener("keydown",g,!0),window.addEventListener("wheel",s,!0),window.addEventListener("scroll",s,!0),e.onBeforeUnmount(()=>{window.removeEventListener("mousedown",y,!0),window.removeEventListener("keydown",g,!0),window.removeEventListener("wheel",s,!0),window.removeEventListener("scroll",s,!0)});function k(N){l.readonly||(N(),i("close"))}return(N,w)=>(e.openBlock(),e.createElementBlock("div",{class:"zm-node-menu",style:e.normalizeStyle({left:c.value.left+"px",top:c.value.top+"px"}),onContextmenu:w[6]||(w[6]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("button",{class:"zm-node-menu-item",disabled:o.readonly,onClick:w[0]||(w[0]=e.withModifiers(z=>k(()=>i("pickImage")),["stop"]))},[e.createVNode(R,{name:"image",size:13}),e.createElementVNode("span",null,e.toDisplayString(u.value?"替换图片":"添加图片"),1)],8,gn),u.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"zm-node-menu-item",disabled:o.readonly,onClick:w[1]||(w[1]=e.withModifiers(z=>k(()=>i("removeImage")),["stop"]))},[e.createVNode(R,{name:"x",size:13}),w[7]||(w[7]=e.createElementVNode("span",null,"移除图片",-1))],8,yn)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"zm-node-menu-item",disabled:o.readonly,onClick:w[2]||(w[2]=e.withModifiers(z=>k(()=>i("setLink")),["stop"]))},[e.createVNode(R,{name:"link",size:13}),e.createElementVNode("span",null,e.toDisplayString(f.value?"编辑链接":"添加链接"),1)],8,xn),f.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zm-node-menu-item",disabled:o.readonly,onClick:w[3]||(w[3]=e.withModifiers(z=>k(()=>i("removeLink")),["stop"]))},[e.createVNode(R,{name:"x",size:13}),w[8]||(w[8]=e.createElementVNode("span",null,"移除链接",-1))],8,pn)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"zm-node-menu-item",disabled:o.readonly,onClick:w[4]||(w[4]=e.withModifiers(z=>k(()=>i("editNote")),["stop"]))},[e.createVNode(R,{name:"note",size:13}),e.createElementVNode("span",null,e.toDisplayString(p.value?"编辑笔记":"添加笔记"),1)],8,kn),p.value?(e.openBlock(),e.createElementBlock("button",{key:2,class:"zm-node-menu-item",disabled:o.readonly,onClick:w[5]||(w[5]=e.withModifiers(z=>k(()=>i("removeNote")),["stop"]))},[e.createVNode(R,{name:"x",size:13}),w[9]||(w[9]=e.createElementVNode("span",null,"移除笔记",-1))],8,wn)):e.createCommentVNode("",!0)],36))}}),En=["viewBox","width","height"],Nn={class:"zm-edges"},Mn=["d","fill"],Bn=["data-node-id","onClick","onDblclick","onContextmenu","onMouseenter","onMouseleave"],vn=["src","width","height","alt"],Cn={key:1,class:"zm-text"},Sn={class:"zm-text-label"},Vn=["href","title"],zn=["title","onClick"],In=["title"],Wn=["title","onClick"],$n=["onClick"],Rn=["onMousedown"],Tn=["onClick"],An={key:0,class:"zm-toolbar"},Ln=["src"],Dn=["src"],Hn={class:"zm-tb-tip"},fe=24,we=400,re=160,rt=e.defineComponent({__name:"MindMap",props:{data:{},readonly:{type:Boolean,default:!1},theme:{},previewMode:{type:Boolean,default:!1},markdown:{},lineColors:{}},emits:["change","select","edit-note","markdownChange"],setup(o,{expose:d,emit:l}){const i=o,c=l,u=e.ref(null),f=e.ref(null),p=e.ref(""),y=e.ref(null),g=e.ref(new Set),s=e.ref(_(i.data)),k=e.ref(i.markdown!==void 0);let N=!1;e.watch(()=>i.markdown,t=>{if(t===void 0){k.value=!1;return}k.value=!0;const n=Pe(t||"");N=!0,s.value=_(n),y.value=null,g.value=new Set,W(),e.nextTick(()=>{N=!1,te()})}),e.watch(s,()=>{k.value&&!N&&c("markdownChange",ze(s.value))},{deep:!0});const w=e.computed(()=>E.showOrderBadge===!0),z=e.ref(new Map),P=z.value;function ie(t,n){const a={};n.bg&&(a.bg=n.bg),n.textColor&&(a.textColor=n.textColor),n.borderColor&&(a.borderColor=n.borderColor),n.fontWeight&&(a.fontWeight=n.fontWeight),Object.keys(a).length===0?P.delete(t):P.set(t,a),z.value=new Map(P)}function ee(t){return P.get(t)??{}}function b(t,n){const a=S(s.value,t);a&&(a.image={src:n.src,naturalW:n.naturalW,naturalH:n.naturalH,width:L(n.width,fe,we),height:L(n.height,fe,we)},H(),W(),c("change",s.value))}function F(t){const n=S(s.value,t);!n||!n.image||(delete n.image,H(),W(),c("change",s.value))}function L(t,n,a){return Math.min(a,Math.max(n,t))}function $(t,n){const a=new FileReader;a.onload=()=>{if(typeof a.result!="string")return;const h=a.result,m=new window.Image;m.onload=()=>{const r=m.naturalWidth||re,x=m.naturalHeight||re,V=L(r,fe,re),A=L(Math.round(x*V/r),fe,we);n({src:h,naturalW:r,naturalH:x,width:V,height:A})},m.onerror=()=>{n({src:h,naturalW:re,naturalH:re,width:re,height:re})},m.src=h},a.readAsDataURL(t)}function Z(t){const n=document.createElement("input");n.type="file",n.accept="image/*",n.style.display="none",n.onchange=()=>{var h;const a=(h=n.files)==null?void 0:h[0];a&&($(a,m=>b(t,m)),document.body.removeChild(n))},document.body.appendChild(n),n.click()}function D(t,n){const a=n.trim(),h=S(s.value,t);h&&(a?h.link={url:a}:delete h.link,H(),W(),c("change",s.value))}function Q(t){D(t,"")}function ae(t,n){const a=S(s.value,t);a&&(n?a.note={text:n}:delete a.note,H(),W(),c("change",s.value))}function v(t){ae(t,"")}const C=e.ref(null);function O(t,n){i.readonly||(t.preventDefault(),t.stopPropagation(),y.value=n.id,c("select",S(s.value,n.id)),C.value={nodeId:n.id,x:t.clientX,y:t.clientY})}function q(){C.value=null}function j(){var n;const t=(n=C.value)==null?void 0:n.nodeId;t&&Z(t)}function G(){var h,m,r;const t=(h=C.value)==null?void 0:h.nodeId;if(!t)return;const n=((r=(m=S(s.value,t))==null?void 0:m.link)==null?void 0:r.url)??"",a=window.prompt("输入链接 URL(留空取消)",n);a!==null&&D(t,a)}function me(){var n;const t=(n=C.value)==null?void 0:n.nodeId;t&&Q(t)}function be(){var n;const t=(n=C.value)==null?void 0:n.nodeId;t&&at(t)}function he(){var n;const t=(n=C.value)==null?void 0:n.nodeId;t&&v(t)}function Fn(){var n;const t=(n=C.value)==null?void 0:n.nodeId;t&&F(t)}function at(t){i.readonly||c("edit-note",t)}function On(t,n=60){const a=t.replace(/\s+/g," ").trim();return a.length<=n?a||"点击编辑笔记":a.slice(0,n)+"…"}function ct(t){var m;if(i.readonly||f.value)return;const n=t.target;if(n&&(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable))return;const a=y.value;if(!a)return;const h=(m=t.clipboardData)==null?void 0:m.items;if(h)for(let r=0;r<h.length;r++){const x=h[r];if(x.kind==="file"&&x.type.startsWith("image/")){const V=x.getAsFile();if(!V)continue;t.preventDefault();const A=S(s.value,a);if(A!=null&&A.image&&!window.confirm("该节点已有图片,要用剪贴板里的图片替换吗?"))return;$(V,X=>b(a,X));return}}}e.onMounted(()=>{window.addEventListener("paste",ct)}),e.onBeforeUnmount(()=>{window.removeEventListener("paste",ct)});const Ee=e.ref(null),Xn=e.computed(()=>{var t;return((t=Ee.value)==null?void 0:t.nodeId)??null});function qn(t,n){if(!n.image)return;t.preventDefault(),t.stopPropagation();const a=n.image.naturalW||n.image.width,h=n.image.naturalH||n.image.height,m=h>0?h/a:1;Ee.value={nodeId:n.id,startX:t.clientX,startY:t.clientY,startW:n.image.width,startH:n.image.height,naturalW:a,naturalH:h,ratio:m,pendingW:n.image.width,pendingH:n.image.height},window.addEventListener("mousemove",st),window.addEventListener("mouseup",dt)}function st(t){var A,X;const n=Ee.value;if(!n)return;const a=M.scale.value||1,h=t.clientX-n.startX,m=L(n.startW+h/a,fe,we),r=L(m*n.ratio,fe,we);n.pendingW=m,n.pendingH=r;const x=(A=u.value)==null?void 0:A.querySelector(`[data-node-id="${n.nodeId}"] .zm-node-img`);x&&(x.style.width=`${m}px`,x.style.height=`${r}px`);const V=(X=u.value)==null?void 0:X.querySelector(`[data-node-id="${n.nodeId}"]`);V&&(V.style.minWidth=`${Math.max(80,Math.ceil(m+28))}px`,V.style.height=`${Math.ceil(r+8+30)}px`)}function dt(){const t=Ee.value;if(window.removeEventListener("mousemove",st),window.removeEventListener("mouseup",dt),Ee.value=null,!t)return;const n=S(s.value,t.nodeId);!n||!n.image||(b(t.nodeId,{src:n.image.src,naturalW:n.image.naturalW,naturalH:n.image.naturalH,width:t.pendingW,height:t.pendingH}),y.value=t.nodeId,c("select",n),Oe=!0)}const Fe=e.ref(null);let Oe=!1;function Kn(t){Fe.value=t}function Un(t){Fe.value===t&&(Fe.value=null)}const ut=e.ref(0),Xe=e.ref(!1),le=hn(100);function H(){le.record({data:s.value})}function W(){g.value=new Set(g.value),ut.value++}const J=e.computed(()=>{var t,n,a,h,m,r,x,V,A,X;return{rootBg:((t=i.theme)==null?void 0:t.rootBg)??"#1f2937",rootText:((n=i.theme)==null?void 0:n.rootText)??"#ffffff",branchBg:((a=i.theme)==null?void 0:a.branchBg)??"#ffffff",branchText:((h=i.theme)==null?void 0:h.branchText)??"#1f2937",lineColor:((m=i.theme)==null?void 0:m.lineColor)??"#94a3b8",bgColor:((r=i.theme)==null?void 0:r.bgColor)??"#f8fafc",fontSize:((x=i.theme)==null?void 0:x.fontSize)??14,lineWidthStart:((V=i.theme)==null?void 0:V.lineWidthStart)??2.2,lineWidthEnd:((A=i.theme)==null?void 0:A.lineWidthEnd)??.8,rainbowBranch:((X=i.theme)==null?void 0:X.rainbowBranch)??!1}}),E=e.reactive({autoBalanceOnChange:!0,lineWidthStart:12,lineWidthEnd:3.6,rainbowBranch:!0,branchPaletteId:"default",customPalettes:[],lineStyle:"curve",layoutMode:"mindmap",taperedEdge:!0,showOrderBadge:!1});function ft(t){return E.taperedEdge?Yn(t):ht(t)}function mt(t){return E.taperedEdge?E.lineWidthEnd:ht(t)}function Yn(t){return t<=0?E.lineWidthStart:t===1?Math.max(1.5,E.lineWidthStart*.67):t===2?Math.max(.8,E.lineWidthStart*.42):E.lineWidthEnd}function ht(t){if(t<=0)return E.lineWidthStart;if(t>=3)return E.lineWidthEnd;const n=t/3;return E.lineWidthStart+(E.lineWidthEnd-E.lineWidthStart)*n}function jn(t,n,a,h){const m=1-t,r=m*m*m*n.x+3*m*m*t*a.x1+3*m*t*t*a.x2+t*t*t*h.x,x=m*m*m*n.y+3*m*m*t*a.y1+3*m*t*t*a.y2+t*t*t*h.y;return{x:r,y:x}}function Gn(t,n,a,h,m=32,r="curve",x="right"){if(r==="curve"){let de;if(x==="right"||x==="left"){const I=Math.abs(n.x-t.x)*.45,ne=x==="right"?1:-1;de={x1:t.x+ne*I,y1:t.y,x2:n.x-ne*I,y2:n.y}}else{const I=Math.abs(n.y-t.y)*.45;de={x1:t.x,y1:t.y+I,x2:n.x,y2:n.y-I}}const ko=B=>{const I=1-B,ne=-3*I*I*t.x+3*(I*I-2*I*B)*de.x1+3*(2*I*B-B*B)*de.x2+3*B*B*n.x,pe=-3*I*I*t.y+3*(I*I-2*I*B)*de.y1+3*(2*I*B-B*B)*de.y2+3*B*B*n.y;return{dx:ne,dy:pe}},Be=[],Ge=[];for(let B=0;B<=m;B++){const I=B/m,ne=B===0?t:B===m?n:jn(I,t,de,n),pe=ko(I);let Te=Math.hypot(pe.dx,pe.dy);Te<1e-6&&(Te=1);const Wt=-pe.dy/Te,$t=pe.dx/Te,Ae=(a+(h-a)*I)/2;Be.push({x:ne.x+Wt*Ae,y:ne.y+$t*Ae}),Ge.push({x:ne.x-Wt*Ae,y:ne.y-$t*Ae})}let Re=`M ${Be[0].x.toFixed(2)} ${Be[0].y.toFixed(2)}`;for(let B=1;B<=m;B++)Re+=` L ${Be[B].x.toFixed(2)} ${Be[B].y.toFixed(2)}`;for(let B=m;B>=0;B--)Re+=` L ${Ge[B].x.toFixed(2)} ${Ge[B].y.toFixed(2)}`;return Re+=" Z",Re}const V=n.x-t.x,A=n.y-t.y;let X=Math.hypot(V,A);X<1e-6&&(X=1);const se=-A/X,ye=V/X,xe=a/2,Me=h/2,St={x:t.x+se*xe,y:t.y+ye*xe},Vt={x:t.x-se*xe,y:t.y-ye*xe},zt={x:n.x-se*Me,y:n.y-ye*Me},It={x:n.x+se*Me,y:n.y+ye*Me};return`M ${St.x.toFixed(2)} ${St.y.toFixed(2)} L ${It.x.toFixed(2)} ${It.y.toFixed(2)} L ${zt.x.toFixed(2)} ${zt.y.toFixed(2)} L ${Vt.x.toFixed(2)} ${Vt.y.toFixed(2)} Z`}const Ie=e.computed(()=>K.value.root.children),Jn=ke[0].colors,gt=e.computed(()=>rn(E.branchPaletteId,E.customPalettes)),ce=e.computed(()=>{const t=new Map;if(!E.rainbowBranch)return t;const n=i.lineColors,a=n&&n.length>0?n:gt.value.colors.length>0?gt.value.colors:Jn;for(let m=0;m<Ie.value.length;m++){const r=Ie.value[m];t.set(r.id,a[m%a.length])}const h=(m,r)=>{t.set(m.id,r);for(const x of m.children)h(x,r)};for(let m=0;m<Ie.value.length;m++){const r=Ie.value[m];h(r,a[m%a.length])}return t});function Zn(t,n){return E.rainbowBranch?ce.value.get(n.id)??J.value.lineColor:J.value.lineColor}function Qn(t){const n=ee(t.id);if(n.bg)return n.bg;if(t.isRoot)return J.value.rootBg;if(E.rainbowBranch){const a=ce.value.get(t.id);if(a)return no(a,.18)}return J.value.branchBg}function _n(t){const n=ee(t.id);if(n.textColor)return n.textColor;if(t.isRoot)return J.value.rootText;if(E.rainbowBranch){const a=ce.value.get(t.id);if(a)return yt(a,.55)}return J.value.branchText}function eo(t){const n=ee(t.id);if(n.borderColor)return n.borderColor;if(t.isRoot)return J.value.rootBg;if(E.rainbowBranch){const a=ce.value.get(t.id);if(a)return yt(a,.3)}return J.value.lineColor}function to(t){return ee(t.id).fontWeight??(t.isRoot?600:400)}function no(t,n){const a=t.replace("#",""),h=a.length===6?a:a.split("").map(V=>V+V).join(""),m=parseInt(h.slice(0,2),16),r=parseInt(h.slice(2,4),16),x=parseInt(h.slice(4,6),16);return`rgba(${m}, ${r}, ${x}, ${n})`}function yt(t,n){const a=t.replace("#",""),h=a.length===6?a:a.split("").map(V=>V+V).join(""),m=Math.round(parseInt(h.slice(0,2),16)*(1-n)),r=Math.round(parseInt(h.slice(2,4),16)*(1-n)),x=Math.round(parseInt(h.slice(4,6),16)*(1-n));return`rgb(${m}, ${r}, ${x})`}const M=un({getContainer:()=>u.value});M.setOnMarqueeEnd(ho),mn({isEditing:()=>f.value!==null,isReadonly:()=>i.readonly,getSelectedId:()=>y.value,getRootId:()=>s.value.id,defaultTargetId:()=>s.value.id,onAddChild:ge,onAddSibling:$e,onAddSiblingBefore:kt,onRemove:bt,onStartEdit:Ne,onClearSelection:()=>{y.value=null,c("select",null)},onDuplicate:wt,onUndo:Ke,onRedo:Ue,onNavigate:ao,onSelectRoot:()=>{y.value=s.value.id;const t=S(s.value,s.value.id);t&&c("select",t)}});const K=e.computed(()=>{const t=_(s.value);return pt(t),tn(t,{mode:E.layoutMode,baseFontSize:J.value.fontSize})}),xt=e.ref([]),qe=e.computed(()=>(ut.value,xt.value));e.watch(K,t=>{const n=[],a=h=>{n.push(h);for(const m of h.children)a(m)};a(t.root),xt.value=n},{immediate:!0});const oo=e.computed(()=>{const t=[];for(const n of qe.value)for(const a of n.children)t.push({from:n,to:a,key:`${n.id}->${a.id}`});return t}),io=e.computed(()=>`${K.value.vbX} ${K.value.vbY} ${K.value.vbW} ${K.value.vbH}`);function pt(t){if(g.value.has(t.id)){t.children=[],t.collapsed=!0;return}t.collapsed=!1;for(const n of t.children)pt(n)}function Ne(t){const n=S(s.value,t);n&&(f.value=t,p.value=n.text,e.nextTick(()=>{const a=document.querySelector(".zm-input");a==null||a.focus(),a==null||a.select()}))}function We(t={}){if(!f.value)return;const n=S(s.value,f.value);n&&n.text!==(p.value.trim()||" ")&&(n.text=p.value.trim()||" ",H(),c("change",s.value));const a=f.value;f.value=null,t.addChild?e.nextTick(()=>ge(a)):t.addSibling==="after"?e.nextTick(()=>$e(a)):t.addSibling==="before"&&e.nextTick(()=>kt(a))}function lo(){f.value=null}function ro(t){const n=t.metaKey||t.ctrlKey;n&&(t.key==="z"||t.key==="Z")&&!t.shiftKey?(t.preventDefault(),Ke()):(n&&t.shiftKey&&(t.key==="z"||t.key==="Z")||n&&(t.key==="y"||t.key==="Y")&&!t.shiftKey)&&(t.preventDefault(),Ue())}function ge(t){const n=nt(s.value,t,Ve);n&&(H(),W(),c("change",s.value),e.nextTick(()=>Ne(n.id)))}function $e(t){if(t===s.value.id){ge(t);return}const n=ot(s.value,t,Ve);n&&(H(),W(),c("change",s.value),e.nextTick(()=>Ne(n.id)))}function kt(t){if(t===s.value.id){ge(t);return}const n=sn(s.value,t,Ve);n&&(H(),W(),c("change",s.value),e.nextTick(()=>Ne(n.id)))}function wt(t){if(t===s.value.id)return;const n=dn(s.value,t);n&&(H(),y.value=n.id,c("change",s.value),W())}function Ke(){const t=le.undo();t&&(s.value=t.data,y.value=null,c("select",null),W(),c("change",s.value))}function Ue(){const t=le.redo();t&&(s.value=t.data,y.value=null,c("select",null),W(),c("change",s.value))}function ao(t,n){const a=y.value??s.value.id,h=S(s.value,a);if(!h)return;let m=null;if(n===1){const r=Y(s.value,h.id);if(r){const x=r.children.findIndex(V=>V.id===h.id);x>=0&&x<r.children.length-1&&(m=r.children[x+1].id)}}else if(n===-1){const r=Y(s.value,h.id);if(r){const x=r.children.findIndex(V=>V.id===h.id);x>0&&(m=r.children[x-1].id)}}else if(t===1){const r=Y(s.value,h.id);r&&(m=r.id)}else t===-1&&h.children.length>0&&(m=h.children[0].id);if(m){y.value=m;const r=S(s.value,m);r&&c("select",r)}}function bt(t){t!==s.value.id&&He(s.value,t)&&(H(),y.value===t&&(y.value=null),W(),c("change",s.value))}function Et(t){g.value.has(t)?g.value.delete(t):g.value.add(t),W()}function co(t,n){an(s.value,t,n)&&(H(),W(),c("change",s.value))}function so(t,n,a){return cn(s.value,t,n,a)?(H(),W(),c("change",s.value),!0):!1}function uo(t,n){t.stopPropagation(),y.value=n.id;const a=S(s.value,n.id);c("select",a)}function fo(t){const n=t.target;if(!n||n.closest(".zm-node, .zm-toolbar, button, input, textarea"))return;if(t.button===2){M.startPan(t);return}if(t.button!==0)return;const a=u.value.getBoundingClientRect(),h=(t.clientX-a.left-M.offsetX.value)/M.scale.value,m=(t.clientY-a.top-M.offsetY.value)/M.scale.value;M.startMarquee(h,m)}function mo(t){if(Oe){Oe=!1;return}const n=t.target;if(!n||n.closest(".zm-node"))return;const a=M.marquee;a.width>=4||a.height>=4||y.value!==null&&(y.value=null,c("select",null))}function ho(){const t=M.marquee;if(t.width<4&&t.height<4)return;const n=t.x,a=t.y,h=t.x+t.width,m=t.y+t.height,r=[];for(const x of qe.value){const V=x.width/2,A=x.height/2,X=x.x-V,se=x.x+V,ye=x.y-A,xe=x.y+A;X<=h&&se>=n&&ye<=m&&xe>=a&&r.push(x.id)}if(r.length>0){y.value=r[0];const x=S(s.value,r[0]);x&&c("select",x)}}function Nt(t){return g.value.has(t)}function go(t){const n=S(s.value,t.id);return!!n&&n.children.length>0}function Ye(t){const n=S(s.value,t);return n?n.children.length:0}function Mt(t){if(!S(s.value,t))return 0;const h=[s.value];for(;h.length;){const m=h.pop(),r=m.children.findIndex(x=>x.id===t);if(r>=0)return r;for(const x of m.children)h.push(x)}return 0}function Bt(t,n,a,h){if(((h==null?void 0:h._dir)??t._dir)==="down")return n==="out"?{x:t.x,y:t.y+t.height/2}:{x:t.x,y:t.y-t.height/2};let r;return n==="in"?r=-t.side:a!==void 0?r=a:r=t.side,{x:t.x+r*(t.width/2),y:t.y}}function te(){const t=K.value;M.resetView(t.width,t.height,t.root.y)}function yo(){Xe.value=!0,H(),W(),e.nextTick(()=>te())}function je(t){E.layoutMode!==t&&(E.layoutMode=t,W(),e.nextTick(()=>te()))}function vt(){return JSON.stringify(s.value,null,2)}function Ct(t){try{const n=JSON.parse(t);return!n.id||!Array.isArray(n.children)?!1:(le.reset(),s.value=_(n),y.value=null,g.value=new Set,W(),e.nextTick(()=>te()),c("change",s.value),!0)}catch{return!1}}function xo(){const t=document.createElement("input");t.type="file",t.accept="application/json",t.onchange=()=>{var h;const n=(h=t.files)==null?void 0:h[0];if(!n)return;const a=new FileReader;a.onload=()=>{typeof a.result=="string"&&(Ct(a.result)||alert("导入失败:JSON 格式无效"))},a.readAsText(n)},t.click()}function po(){const t=new Blob([vt()],{type:"application/json"}),n=URL.createObjectURL(t),a=document.createElement("a");a.href=n,a.download=`${s.value.text||"mindmap"}.json`,a.click(),URL.revokeObjectURL(n)}return d({addChild:t=>ge(t),addSibling:t=>$e(t),removeNode:t=>bt(t),duplicateNode:t=>wt(t),setNodeText:(t,n)=>co(t,n),moveNode:(t,n,a)=>so(t,n,a),lineWidthForDepth:ft,endWidthForDepth:mt,getData:()=>s.value,setData:t=>{le.reset(),s.value=_(t),y.value=null,g.value=new Set,W(),H(),e.nextTick(()=>te())},resetView:()=>te(),exportData:vt,importData:Ct,getMarkdown:()=>ze(s.value),setMarkdown:(t,n=!0)=>{const a=Pe(t||"");n&&(k.value=!0),N=!n,le.reset(),s.value=_(a),y.value=null,g.value=new Set,W(),H(),e.nextTick(()=>{N=!1,te()}),c("change",s.value)},setBalanced:t=>{Xe.value=t},isBalanced:()=>Xe.value,balance:()=>yo(),applyNodeStyle:(t,n)=>ie(t,n),getNodeStyle:t=>ee(t),applyNodeLink:(t,n)=>D(t,n),removeNodeLink:t=>Q(t),applyNodeNote:(t,n)=>ae(t,n),removeNodeNote:t=>v(t),undo:()=>Ke(),redo:()=>Ue(),canUndo:()=>le.canUndo(),canRedo:()=>le.canRedo(),applySettings:t=>{t.autoBalanceOnChange!==void 0&&(E.autoBalanceOnChange=t.autoBalanceOnChange),t.lineWidthStart!==void 0&&(E.lineWidthStart=Math.max(.5,Math.min(20,t.lineWidthStart))),t.lineWidthEnd!==void 0&&(E.lineWidthEnd=Math.max(.3,Math.min(10,t.lineWidthEnd))),t.rainbowBranch!==void 0&&(E.rainbowBranch=t.rainbowBranch),t.branchPaletteId!==void 0&&(E.branchPaletteId=t.branchPaletteId),t.customPalettes!==void 0&&(E.customPalettes=t.customPalettes),t.lineStyle!==void 0&&(E.lineStyle=t.lineStyle),t.taperedEdge!==void 0&&(E.taperedEdge=t.taperedEdge),t.showOrderBadge!==void 0&&(E.showOrderBadge=t.showOrderBadge)},getSettings:()=>({autoBalanceOnChange:E.autoBalanceOnChange,lineWidthStart:E.lineWidthStart,lineWidthEnd:E.lineWidthEnd,rainbowBranch:E.rainbowBranch,branchPaletteId:E.branchPaletteId,customPalettes:E.customPalettes,lineStyle:E.lineStyle,layoutMode:E.layoutMode,taperedEdge:E.taperedEdge,showOrderBadge:E.showOrderBadge}),setBranchPalette:t=>{if(!t)return;[...ke,...E.customPalettes].find(a=>a.id===t)&&(E.branchPaletteId=t)},getBranchPalette:()=>E.branchPaletteId,getBranchPalettes:()=>[...ke,...E.customPalettes]}),e.watch(()=>i.data,t=>{s.value=_(t),W()},{deep:!1}),e.onMounted(()=>{H(),e.nextTick(()=>te())}),(t,n)=>{var a,h,m;return e.openBlock(),e.createElementBlock("div",{class:"zm-mindmap",style:e.normalizeStyle({background:J.value.bgColor,fontSize:J.value.fontSize+"px"})},[e.createElementVNode("div",{ref_key:"wrapperRef",ref:u,class:"zm-canvas",onMousedown:fo,onContextmenu:n[13]||(n[13]=e.withModifiers(()=>{},["prevent"])),onWheel:n[14]||(n[14]=(...r)=>e.unref(M).onWheel&&e.unref(M).onWheel(...r)),onClick:mo},[e.createElementVNode("div",{class:"zm-svg-layer",style:e.normalizeStyle({left:K.value.vbX*e.unref(M).scale.value+e.unref(M).offsetX.value+"px",top:K.value.vbY*e.unref(M).scale.value+e.unref(M).offsetY.value+"px",width:K.value.vbW*e.unref(M).scale.value+"px",height:K.value.vbH*e.unref(M).scale.value+"px"})},[(e.openBlock(),e.createElementBlock("svg",{class:"zm-svg",viewBox:io.value,preserveAspectRatio:"xMinYMin meet",width:K.value.vbW*e.unref(M).scale.value,height:K.value.vbH*e.unref(M).scale.value},[e.createElementVNode("g",Nn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(oo.value,r=>(e.openBlock(),e.createElementBlock("path",{key:r.key,d:Gn(Bt(r.from,"out",r.to.side,r.to),Bt(r.to,"in"),ft(r.from.depth),mt(r.to.depth),32,E.lineStyle,r.to._dir),fill:Zn(r.from,r.to),stroke:"none"},null,8,Mn))),128))])],8,En))],4),e.unref(M).isMarquee.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"zm-marquee",style:e.normalizeStyle({left:e.unref(M).marquee.x*e.unref(M).scale.value+e.unref(M).offsetX.value+"px",top:e.unref(M).marquee.y*e.unref(M).scale.value+e.unref(M).offsetY.value+"px",width:e.unref(M).marquee.width*e.unref(M).scale.value+"px",height:e.unref(M).marquee.height*e.unref(M).scale.value+"px"})},null,4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"zm-world",style:e.normalizeStyle({transform:`translate(${e.unref(M).offsetX.value}px, ${e.unref(M).offsetY.value}px) scale(${e.unref(M).scale.value})`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(qe.value,r=>(e.openBlock(),e.createElementBlock("div",{key:r.id,class:e.normalizeClass(["zm-node",{"is-root":r.isRoot,"is-selected":y.value===r.id,"is-editing":f.value===r.id,"has-image":!!r.image,"is-resizing":Xn.value===r.id}]),"data-node-id":r.id,style:e.normalizeStyle({left:r.x+"px",top:r.y+"px",minWidth:r.width+"px",height:r.height+"px",fontSize:r.fontSize+"px",background:Qn(r),color:_n(r),borderColor:eo(r),fontWeight:to(r),transform:"translate(-50%, -50%)"}),onClick:x=>uo(x,r),onDblclick:x=>{x.stopPropagation(),o.readonly||Ne(r.id)},onContextmenu:x=>O(x,r),onMouseenter:x=>Kn(r.id),onMouseleave:x=>Un(r.id)},[r.image?(e.openBlock(),e.createElementBlock("img",{key:0,class:"zm-node-img",src:r.image.src,width:r.image.width,height:r.image.height,alt:r.text,draggable:"false"},null,8,vn)):e.createCommentVNode("",!0),f.value!==r.id?(e.openBlock(),e.createElementBlock("span",Cn,[e.createElementVNode("span",Sn,e.toDisplayString(r.text),1),r.link&&!f.value?(e.openBlock(),e.createElementBlock("a",{key:0,class:"zm-node-link",href:r.link.url,target:"_blank",rel:"noopener noreferrer",title:`打开链接:${r.link.url}`,onClick:n[0]||(n[0]=e.withModifiers(()=>{},["stop"])),onMousedown:n[1]||(n[1]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(R,{name:"link",size:11,stroke:2})],40,Vn)):e.createCommentVNode("",!0),r.note&&!f.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"zm-node-note-btn",type:"button",title:On(r.note.text),onClick:e.withModifiers(x=>at(r.id),["stop"]),onMousedown:n[2]||(n[2]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(R,{name:"note",size:11,stroke:2})],40,zn)):e.createCommentVNode("",!0)])):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,class:"zm-input","onUpdate:modelValue":n[3]||(n[3]=x=>p.value=x),autofocus:"",onBlur:n[4]||(n[4]=x=>We()),onKeydown:[n[5]||(n[5]=e.withKeys(e.withModifiers(x=>We({addSibling:"after"}),["exact"]),["enter"])),n[6]||(n[6]=e.withKeys(e.withModifiers(x=>We({addSibling:"before"}),["shift","prevent","exact"]),["enter"])),n[7]||(n[7]=e.withKeys(e.withModifiers(x=>We({addChild:!0}),["prevent"]),["tab"])),e.withKeys(lo,["esc"]),ro],onMousedown:n[8]||(n[8]=e.withModifiers(()=>{},["stop"])),onClick:n[9]||(n[9]=e.withModifiers(()=>{},["stop"]))},null,544)),[[e.vModelText,p.value]]),w.value?(e.openBlock(),e.createElementBlock("span",{key:3,class:"zm-order-badge",title:`数据顺序:第 ${Mt(r.id)+1} 个`},e.toDisplayString(Mt(r.id)+1),9,In)):e.createCommentVNode("",!0),Nt(r.id)&&!r.isRoot&&Ye(r.id)>0?(e.openBlock(),e.createElementBlock("span",{key:4,class:e.normalizeClass(["zm-collapse-badge",{"is-on-left":r.side===-1}]),style:e.normalizeStyle({background:ce.value.get(r.id)??"#64748b"}),title:`展开 ${Ye(r.id)} 个子节点`,onMousedown:n[10]||(n[10]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(x=>Et(r.id),["stop"])},e.toDisplayString(Ye(r.id)),47,Wn)):e.createCommentVNode("",!0),!o.readonly&&!r.isRoot&&go(r)&&!Nt(r.id)?(e.openBlock(),e.createElementBlock("button",{key:5,class:e.normalizeClass(["zm-btn zm-collapse",{"is-on-left":r.side===-1}]),style:e.normalizeStyle({color:ce.value.get(r.id)??"#64748b",borderColor:ce.value.get(r.id)??"#64748b"}),title:"折叠",onMousedown:n[11]||(n[11]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(x=>Et(r.id),["stop"])},[e.createVNode(R,{name:"minus",size:10,stroke:2.4})],46,$n)):e.createCommentVNode("",!0),r.image&&y.value===r.id&&f.value!==r.id?(e.openBlock(),e.createElementBlock("span",{key:6,class:"zm-img-resize-handle",title:"拖动调整图片大小",onMousedown:e.withModifiers(x=>qn(x,r),["stop"])},null,40,Rn)):e.createCommentVNode("",!0),r.image&&y.value===r.id&&f.value!==r.id?(e.openBlock(),e.createElementBlock("button",{key:7,class:"zm-img-remove-btn",title:"移除图片",onMousedown:n[12]||(n[12]=e.withModifiers(()=>{},["stop"])),onClick:e.withModifiers(x=>F(r.id),["stop"])},[e.createVNode(R,{name:"x",size:9,stroke:2.2})],40,Tn)):e.createCommentVNode("",!0)],46,Bn))),128))],4),C.value?(e.openBlock(),e.createBlock(bn,{key:1,x:C.value.x,y:C.value.y,container:u.value,"has-image":!!((a=e.unref(S)(s.value,C.value.nodeId))!=null&&a.image),"has-link":!!((h=e.unref(S)(s.value,C.value.nodeId))!=null&&h.link),"has-note":!!((m=e.unref(S)(s.value,C.value.nodeId))!=null&&m.note),readonly:i.readonly,onPickImage:j,onRemoveImage:Fn,onSetLink:G,onRemoveLink:me,onEditNote:be,onRemoveNote:he,onClose:q},null,8,["x","y","container","has-image","has-link","has-note","readonly"])):e.createCommentVNode("",!0)],544),i.previewMode?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",An,[e.createElementVNode("button",{class:"zm-tb-btn",title:"放大",onClick:n[15]||(n[15]=(...r)=>e.unref(M).zoomIn&&e.unref(M).zoomIn(...r))},[e.createVNode(R,{name:"zoom-in"})]),e.createElementVNode("button",{class:"zm-tb-btn",title:"缩小",onClick:n[16]||(n[16]=(...r)=>e.unref(M).zoomOut&&e.unref(M).zoomOut(...r))},[e.createVNode(R,{name:"zoom-out"})]),e.createElementVNode("button",{class:"zm-tb-btn",title:"重置视图",onClick:te},[e.createVNode(R,{name:"reset"})]),n[22]||(n[22]=e.createElementVNode("span",{class:"zm-tb-divider"},null,-1)),o.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"zm-tb-btn",title:"添加子节点 (Tab)",onClick:n[17]||(n[17]=r=>y.value&&ge(y.value))},[e.createElementVNode("img",{src:e.unref(Dt),width:"14",height:"14",alt:"添加子节点",draggable:"false"},null,8,Ln)])),o.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"zm-tb-btn",title:"添加同级 (Enter)",onClick:n[18]||(n[18]=r=>y.value&&$e(y.value))},[e.createElementVNode("img",{src:e.unref(Lt),width:"14",height:"14",alt:"添加同级",draggable:"false"},null,8,Dn)])),n[23]||(n[23]=e.createElementVNode("span",{class:"zm-tb-divider"},null,-1)),e.createElementVNode("button",{class:e.normalizeClass(["zm-tb-btn",{active:E.layoutMode==="mindmap"}]),title:"思维导图布局 (中心辐射)",onClick:n[19]||(n[19]=r=>je("mindmap"))},[e.createVNode(R,{name:"mindmap"})],2),e.createElementVNode("button",{class:e.normalizeClass(["zm-tb-btn",{active:E.layoutMode==="tree"}]),title:"树形布局 (向右展开)",onClick:n[20]||(n[20]=r=>je("tree"))},[e.createVNode(R,{name:"tree"})],2),e.createElementVNode("button",{class:e.normalizeClass(["zm-tb-btn",{active:E.layoutMode==="org"}]),title:"组织结构布局 (向下展开)",onClick:n[21]||(n[21]=r=>je("org"))},[e.createVNode(R,{name:"org"})],2),n[24]||(n[24]=e.createElementVNode("span",{class:"zm-tb-divider"},null,-1)),o.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:2,class:"zm-tb-btn",title:"导入 JSON",onClick:xo},[e.createVNode(R,{name:"import"})])),e.createElementVNode("button",{class:"zm-tb-btn",title:"导出 JSON",onClick:po},[e.createVNode(R,{name:"export"})]),e.createElementVNode("span",Hn,e.toDisplayString(Math.round(e.unref(M).scale.value*100))+"%",1)]))],4)}}}),Pn={install(o){o.component("FlowMindMap",rt)}};T.MindMap=rt,T.addChild=nt,T.addSibling=ot,T.clone=_,T.default=Pn,T.findNode=S,T.findParent=Y,T.markdownToMindMap=Pe,T.mindMapToMarkdown=ze,T.removeNode=He,T.uid=oe,Object.defineProperties(T,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|