flow-mindmap 0.1.1-beta.0 → 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/components/MindMap.vue.d.ts +22 -0
- package/dist/core/layout.d.ts +19 -2
- package/dist/entry.d.ts +4 -4
- package/dist/flow-mindmap.js +1120 -995
- package/dist/flow-mindmap.umd.cjs +5 -1
- package/dist/types.d.ts +8 -0
- package/package.json +1 -1
package/dist/flow-mindmap.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as dt, openBlock as M, createElementBlock as C, Fragment as P, createElementVNode as y, createStaticVNode as Ne, createCommentVNode as O, ref as D, reactive as Ge, onMounted as ut, onBeforeUnmount as ct, computed as Q, withModifiers as R, normalizeStyle as ve, createVNode as F, toDisplayString as be, watch as Ye, nextTick as Z, unref as z, renderList as Ot, normalizeClass as Ie, withDirectives as Wn, withKeys as Ke, vModelText as $n, createBlock as Bn } from "vue";
|
|
2
|
+
const Rn = ["width", "height", "stroke-width"], An = {
|
|
3
3
|
key: 4,
|
|
4
4
|
points: "6 9 12 15 18 9"
|
|
5
|
-
},
|
|
5
|
+
}, Ln = {
|
|
6
6
|
key: 5,
|
|
7
7
|
points: "9 6 15 12 9 18"
|
|
8
|
-
},
|
|
8
|
+
}, V = /* @__PURE__ */ dt({
|
|
9
9
|
__name: "Icon",
|
|
10
10
|
props: {
|
|
11
11
|
name: {},
|
|
@@ -13,7 +13,7 @@ const In = ["width", "height", "stroke-width"], Wn = {
|
|
|
13
13
|
stroke: {}
|
|
14
14
|
},
|
|
15
15
|
setup(n) {
|
|
16
|
-
return (
|
|
16
|
+
return (s, o) => (M(), C("svg", {
|
|
17
17
|
width: n.size ?? 16,
|
|
18
18
|
height: n.size ?? 16,
|
|
19
19
|
viewBox: "0 0 24 24",
|
|
@@ -24,189 +24,192 @@ const In = ["width", "height", "stroke-width"], Wn = {
|
|
|
24
24
|
"stroke-linejoin": "round",
|
|
25
25
|
"aria-hidden": "true"
|
|
26
26
|
}, [
|
|
27
|
-
n.name === "add" ? (
|
|
28
|
-
|
|
27
|
+
n.name === "add" ? (M(), C(P, { key: 0 }, [
|
|
28
|
+
o[0] || (o[0] = y("circle", {
|
|
29
29
|
cx: "12",
|
|
30
30
|
cy: "12",
|
|
31
31
|
r: "9"
|
|
32
32
|
}, null, -1)),
|
|
33
|
-
|
|
33
|
+
o[1] || (o[1] = y("line", {
|
|
34
34
|
x1: "12",
|
|
35
35
|
y1: "8",
|
|
36
36
|
x2: "12",
|
|
37
37
|
y2: "16"
|
|
38
38
|
}, null, -1)),
|
|
39
|
-
|
|
39
|
+
o[2] || (o[2] = y("line", {
|
|
40
40
|
x1: "8",
|
|
41
41
|
y1: "12",
|
|
42
42
|
x2: "16",
|
|
43
43
|
y2: "12"
|
|
44
44
|
}, null, -1))
|
|
45
|
-
], 64)) : n.name === "minus" ? (
|
|
46
|
-
|
|
45
|
+
], 64)) : n.name === "minus" ? (M(), C(P, { key: 1 }, [
|
|
46
|
+
o[3] || (o[3] = y("circle", {
|
|
47
47
|
cx: "12",
|
|
48
48
|
cy: "12",
|
|
49
49
|
r: "9"
|
|
50
50
|
}, null, -1)),
|
|
51
|
-
|
|
51
|
+
o[4] || (o[4] = y("line", {
|
|
52
52
|
x1: "8",
|
|
53
53
|
y1: "12",
|
|
54
54
|
x2: "16",
|
|
55
55
|
y2: "12"
|
|
56
56
|
}, null, -1))
|
|
57
|
-
], 64)) : n.name === "delete" ? (
|
|
58
|
-
|
|
59
|
-
], 64)) : n.name === "edit" ? (
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
], 64)) : n.name === "delete" ? (M(), C(P, { key: 2 }, [
|
|
58
|
+
o[5] || (o[5] = Ne('<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))
|
|
59
|
+
], 64)) : n.name === "edit" ? (M(), C(P, { key: 3 }, [
|
|
60
|
+
o[6] || (o[6] = y("path", { d: "M4 20 l4 -1 11 -11 -3 -3 -11 11 z" }, null, -1)),
|
|
61
|
+
o[7] || (o[7] = y("line", {
|
|
62
62
|
x1: "14",
|
|
63
63
|
y1: "6",
|
|
64
64
|
x2: "18",
|
|
65
65
|
y2: "10"
|
|
66
66
|
}, null, -1))
|
|
67
|
-
], 64)) : n.name === "collapse" ? (
|
|
68
|
-
|
|
67
|
+
], 64)) : n.name === "collapse" ? (M(), C("polyline", An)) : n.name === "expand" ? (M(), C("polyline", Ln)) : n.name === "zoom-in" ? (M(), C(P, { key: 6 }, [
|
|
68
|
+
o[8] || (o[8] = y("circle", {
|
|
69
69
|
cx: "11",
|
|
70
70
|
cy: "11",
|
|
71
71
|
r: "7"
|
|
72
72
|
}, null, -1)),
|
|
73
|
-
|
|
73
|
+
o[9] || (o[9] = y("line", {
|
|
74
74
|
x1: "11",
|
|
75
75
|
y1: "8",
|
|
76
76
|
x2: "11",
|
|
77
77
|
y2: "14"
|
|
78
78
|
}, null, -1)),
|
|
79
|
-
|
|
79
|
+
o[10] || (o[10] = y("line", {
|
|
80
80
|
x1: "8",
|
|
81
81
|
y1: "11",
|
|
82
82
|
x2: "14",
|
|
83
83
|
y2: "11"
|
|
84
84
|
}, null, -1)),
|
|
85
|
-
|
|
85
|
+
o[11] || (o[11] = y("line", {
|
|
86
86
|
x1: "16",
|
|
87
87
|
y1: "16",
|
|
88
88
|
x2: "21",
|
|
89
89
|
y2: "21"
|
|
90
90
|
}, null, -1))
|
|
91
|
-
], 64)) : n.name === "zoom-out" ? (
|
|
92
|
-
|
|
91
|
+
], 64)) : n.name === "zoom-out" ? (M(), C(P, { key: 7 }, [
|
|
92
|
+
o[12] || (o[12] = y("circle", {
|
|
93
93
|
cx: "11",
|
|
94
94
|
cy: "11",
|
|
95
95
|
r: "7"
|
|
96
96
|
}, null, -1)),
|
|
97
|
-
|
|
97
|
+
o[13] || (o[13] = y("line", {
|
|
98
98
|
x1: "8",
|
|
99
99
|
y1: "11",
|
|
100
100
|
x2: "14",
|
|
101
101
|
y2: "11"
|
|
102
102
|
}, null, -1)),
|
|
103
|
-
|
|
103
|
+
o[14] || (o[14] = y("line", {
|
|
104
104
|
x1: "16",
|
|
105
105
|
y1: "16",
|
|
106
106
|
x2: "21",
|
|
107
107
|
y2: "21"
|
|
108
108
|
}, null, -1))
|
|
109
|
-
], 64)) : n.name === "reset" ? (
|
|
110
|
-
|
|
109
|
+
], 64)) : n.name === "reset" ? (M(), C(P, { key: 8 }, [
|
|
110
|
+
o[15] || (o[15] = y("circle", {
|
|
111
111
|
cx: "12",
|
|
112
112
|
cy: "12",
|
|
113
113
|
r: "9"
|
|
114
114
|
}, null, -1)),
|
|
115
|
-
|
|
115
|
+
o[16] || (o[16] = y("circle", {
|
|
116
116
|
cx: "12",
|
|
117
117
|
cy: "12",
|
|
118
118
|
r: "4"
|
|
119
119
|
}, null, -1)),
|
|
120
|
-
|
|
120
|
+
o[17] || (o[17] = y("circle", {
|
|
121
121
|
cx: "12",
|
|
122
122
|
cy: "12",
|
|
123
123
|
r: "0.8",
|
|
124
124
|
fill: "currentColor"
|
|
125
125
|
}, null, -1))
|
|
126
|
-
], 64)) : n.name === "logo" ? (
|
|
127
|
-
|
|
128
|
-
], 64)) : n.name === "import" ? (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
], 64)) : n.name === "export" ? (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
], 64)) : n.name === "balance" ? (
|
|
137
|
-
|
|
138
|
-
], 64)) : n.name === "mindmap" ? (
|
|
139
|
-
|
|
140
|
-
], 64)) : n.name === "tree" ? (
|
|
141
|
-
|
|
142
|
-
], 64)) : n.name === "org" ? (
|
|
143
|
-
|
|
144
|
-
], 64)) : n.name === "image" ? (
|
|
145
|
-
|
|
126
|
+
], 64)) : n.name === "logo" ? (M(), C(P, { key: 9 }, [
|
|
127
|
+
o[18] || (o[18] = Ne('<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))
|
|
128
|
+
], 64)) : n.name === "import" ? (M(), C(P, { key: 10 }, [
|
|
129
|
+
o[19] || (o[19] = y("path", { d: "M12 4 V15" }, null, -1)),
|
|
130
|
+
o[20] || (o[20] = y("polyline", { points: "7 10 12 15 17 10" }, null, -1)),
|
|
131
|
+
o[21] || (o[21] = y("path", { d: "M4 19 H20" }, null, -1))
|
|
132
|
+
], 64)) : n.name === "export" ? (M(), C(P, { key: 11 }, [
|
|
133
|
+
o[22] || (o[22] = y("path", { d: "M12 15 V4" }, null, -1)),
|
|
134
|
+
o[23] || (o[23] = y("polyline", { points: "7 9 12 4 17 9" }, null, -1)),
|
|
135
|
+
o[24] || (o[24] = y("path", { d: "M4 19 H20" }, null, -1))
|
|
136
|
+
], 64)) : n.name === "balance" ? (M(), C(P, { key: 12 }, [
|
|
137
|
+
o[25] || (o[25] = Ne('<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))
|
|
138
|
+
], 64)) : n.name === "mindmap" ? (M(), C(P, { key: 13 }, [
|
|
139
|
+
o[26] || (o[26] = Ne('<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))
|
|
140
|
+
], 64)) : n.name === "tree" ? (M(), C(P, { key: 14 }, [
|
|
141
|
+
o[27] || (o[27] = Ne('<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))
|
|
142
|
+
], 64)) : n.name === "org" ? (M(), C(P, { key: 15 }, [
|
|
143
|
+
o[28] || (o[28] = Ne('<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))
|
|
144
|
+
], 64)) : n.name === "image" ? (M(), C(P, { key: 16 }, [
|
|
145
|
+
o[29] || (o[29] = y("rect", {
|
|
146
146
|
x: "3",
|
|
147
147
|
y: "5",
|
|
148
148
|
width: "18",
|
|
149
149
|
height: "14",
|
|
150
150
|
rx: "2"
|
|
151
151
|
}, null, -1)),
|
|
152
|
-
|
|
152
|
+
o[30] || (o[30] = y("circle", {
|
|
153
153
|
cx: "9",
|
|
154
154
|
cy: "11",
|
|
155
155
|
r: "1.6"
|
|
156
156
|
}, null, -1)),
|
|
157
|
-
|
|
158
|
-
], 64)) : n.name === "x" ? (
|
|
159
|
-
|
|
157
|
+
o[31] || (o[31] = y("polyline", { points: "3 17 9 12 13 15 16 13 21 17" }, null, -1))
|
|
158
|
+
], 64)) : n.name === "x" ? (M(), C(P, { key: 17 }, [
|
|
159
|
+
o[32] || (o[32] = y("line", {
|
|
160
160
|
x1: "6",
|
|
161
161
|
y1: "6",
|
|
162
162
|
x2: "18",
|
|
163
163
|
y2: "18"
|
|
164
164
|
}, null, -1)),
|
|
165
|
-
|
|
165
|
+
o[33] || (o[33] = y("line", {
|
|
166
166
|
x1: "18",
|
|
167
167
|
y1: "6",
|
|
168
168
|
x2: "6",
|
|
169
169
|
y2: "18"
|
|
170
170
|
}, null, -1))
|
|
171
|
-
], 64)) : n.name === "link" ? (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
], 64)) : n.name === "note" ? (
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
], 64)) : n.name === "link" ? (M(), C(P, { key: 18 }, [
|
|
172
|
+
o[34] || (o[34] = y("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)),
|
|
173
|
+
o[35] || (o[35] = y("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))
|
|
174
|
+
], 64)) : n.name === "note" ? (M(), C(P, { key: 19 }, [
|
|
175
|
+
o[36] || (o[36] = y("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)),
|
|
176
|
+
o[37] || (o[37] = y("line", {
|
|
177
177
|
x1: "8",
|
|
178
178
|
y1: "10",
|
|
179
179
|
x2: "16",
|
|
180
180
|
y2: "10"
|
|
181
181
|
}, null, -1)),
|
|
182
|
-
|
|
182
|
+
o[38] || (o[38] = y("line", {
|
|
183
183
|
x1: "8",
|
|
184
184
|
y1: "13",
|
|
185
185
|
x2: "16",
|
|
186
186
|
y2: "13"
|
|
187
187
|
}, null, -1)),
|
|
188
|
-
|
|
188
|
+
o[39] || (o[39] = y("line", {
|
|
189
189
|
x1: "8",
|
|
190
190
|
y1: "16",
|
|
191
191
|
x2: "13",
|
|
192
192
|
y2: "16"
|
|
193
193
|
}, null, -1))
|
|
194
|
-
], 64)) :
|
|
195
|
-
], 8,
|
|
194
|
+
], 64)) : O("", !0)
|
|
195
|
+
], 8, Rn));
|
|
196
196
|
}
|
|
197
|
-
}),
|
|
198
|
-
function
|
|
199
|
-
return Math.round(
|
|
197
|
+
}), Hn = "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", Dn = "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", Yt = [18, 15, 13, 12], Pn = [700, 600, 500, 400], Tn = [52, 40, 32, 28], On = [120, 80, 60, 44], Fn = [0.8, 0.8, 0.8, 0.8], Vn = Yt.length - 1;
|
|
198
|
+
function Xn(n, s) {
|
|
199
|
+
return Math.round(ft(n, s) * Fn[Ze(n)]);
|
|
200
200
|
}
|
|
201
|
-
function
|
|
202
|
-
return Math.min(
|
|
201
|
+
function Ze(n) {
|
|
202
|
+
return Math.min(Vn, Math.max(0, n));
|
|
203
203
|
}
|
|
204
|
-
function
|
|
205
|
-
return
|
|
204
|
+
function ft(n, s = 14) {
|
|
205
|
+
return Math.round(Yt[Ze(n)] * s / 14 * 10) / 10;
|
|
206
206
|
}
|
|
207
|
-
|
|
207
|
+
function qn(n, s = 14) {
|
|
208
|
+
return Math.round(Tn[Ze(n)] * s / 14);
|
|
209
|
+
}
|
|
210
|
+
const Ue = 60, $e = 14, te = 24;
|
|
208
211
|
let at = null;
|
|
209
|
-
function
|
|
212
|
+
function Yn() {
|
|
210
213
|
if (at) return at;
|
|
211
214
|
const n = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null;
|
|
212
215
|
return n ? (at = n, n) : {
|
|
@@ -214,187 +217,187 @@ function Tn() {
|
|
|
214
217
|
measureText: () => ({ width: 0 })
|
|
215
218
|
};
|
|
216
219
|
}
|
|
217
|
-
const
|
|
218
|
-
function
|
|
219
|
-
const
|
|
220
|
+
const Ft = /* @__PURE__ */ new Map();
|
|
221
|
+
function Kn(n, s, o) {
|
|
222
|
+
const i = `${o}|${s}|${n}`, a = Ft.get(i);
|
|
220
223
|
if (a !== void 0) return a;
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
return
|
|
224
|
+
const d = Yn();
|
|
225
|
+
d.font = `${o} ${s}px "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif`;
|
|
226
|
+
const c = d.measureText(n).width;
|
|
227
|
+
return Ft.set(i, c), c;
|
|
225
228
|
}
|
|
226
|
-
const
|
|
227
|
-
function
|
|
228
|
-
return Math.min(
|
|
229
|
+
const Un = 24, Gn = 400, jn = 8, Vt = 16, Jn = 4, Zn = 200;
|
|
230
|
+
function Qn(n, s, o) {
|
|
231
|
+
return Math.min(o, Math.max(s, n));
|
|
229
232
|
}
|
|
230
|
-
function
|
|
231
|
-
const i =
|
|
232
|
-
let
|
|
233
|
-
if (n.link && (
|
|
234
|
-
const
|
|
235
|
-
|
|
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
|
+
let h = 0;
|
|
236
|
+
if (n.link && (h += Vt), n.note && (h += Vt), h > 0) {
|
|
237
|
+
const U = (n.link ? 1 : 0) + (n.note ? 1 : 0);
|
|
238
|
+
h += Jn * U;
|
|
236
239
|
}
|
|
237
|
-
const
|
|
240
|
+
const u = x + h, p = Math.round(On[i] * o / 14);
|
|
238
241
|
if (!n.image)
|
|
239
|
-
return { w: Math.max(
|
|
240
|
-
const
|
|
241
|
-
return { w:
|
|
242
|
+
return { w: Math.max(p, u), h: m };
|
|
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
|
+
return { w: b, h: A };
|
|
242
245
|
}
|
|
243
|
-
function
|
|
244
|
-
const
|
|
245
|
-
return
|
|
246
|
+
function ei(n, s = {}) {
|
|
247
|
+
const o = s.mode ?? "mindmap", i = s.preservePositions === !0, a = s.baseFontSize ?? 14, d = Ut(n, 0, null, 1, "right", a);
|
|
248
|
+
return ni(d), ti(d, o, i), d.x = 0, d.y = 0, ii(d, i);
|
|
246
249
|
}
|
|
247
|
-
function
|
|
248
|
-
if (
|
|
249
|
-
const
|
|
250
|
-
if (
|
|
251
|
-
|
|
250
|
+
function ti(n, s, o = !1) {
|
|
251
|
+
if (s === "mindmap") {
|
|
252
|
+
const i = n.children;
|
|
253
|
+
if (i.length !== 0) if (i.length === 1)
|
|
254
|
+
i[0]._dir = "right", i[0].side = 1, i[0]._dirRight = 1;
|
|
252
255
|
else {
|
|
253
|
-
const x =
|
|
254
|
-
let m = 1,
|
|
255
|
-
for (let
|
|
256
|
-
u +=
|
|
257
|
-
const
|
|
258
|
-
|
|
256
|
+
const x = i.reduce((p, S) => p + S._subtreeH, 0);
|
|
257
|
+
let m = 1, h = Math.abs(i[0]._subtreeH - (x - i[0]._subtreeH)), u = 0;
|
|
258
|
+
for (let p = 0; p < i.length - 1; p++) {
|
|
259
|
+
u += i[p]._subtreeH;
|
|
260
|
+
const S = Math.abs(u - (x - u));
|
|
261
|
+
S < h && (h = S, m = p + 1);
|
|
259
262
|
}
|
|
260
|
-
for (let
|
|
261
|
-
|
|
262
|
-
for (let
|
|
263
|
-
|
|
264
|
-
}
|
|
265
|
-
const a = n.children.filter((x) => x.side === 1),
|
|
266
|
-
const
|
|
267
|
-
x._dir = m, x.side =
|
|
268
|
-
for (const u of x.children)
|
|
263
|
+
for (let p = 0; p < m; p++)
|
|
264
|
+
i[p]._dir = "right", i[p].side = 1, i[p]._dirRight = 1;
|
|
265
|
+
for (let p = m; p < i.length; p++)
|
|
266
|
+
i[p]._dir = "left", i[p].side = -1, i[p]._dirRight = -1;
|
|
267
|
+
}
|
|
268
|
+
const a = n.children.filter((x) => x.side === 1), d = n.children.filter((x) => x.side === -1), c = (x, m) => {
|
|
269
|
+
const h = m === "right" ? 1 : -1;
|
|
270
|
+
x._dir = m, x.side = h, x._dirRight = h;
|
|
271
|
+
for (const u of x.children) c(u, m);
|
|
269
272
|
};
|
|
270
|
-
for (const x of a)
|
|
271
|
-
for (const x of
|
|
273
|
+
for (const x of a) c(x, "right");
|
|
274
|
+
for (const x of d) c(x, "left");
|
|
272
275
|
if (a.length > 0) {
|
|
273
276
|
const x = { ...n, children: a };
|
|
274
|
-
|
|
277
|
+
je(x, "right", Ue, !0, o);
|
|
275
278
|
}
|
|
276
|
-
if (
|
|
277
|
-
const x = { ...n, children:
|
|
278
|
-
|
|
279
|
+
if (d.length > 0) {
|
|
280
|
+
const x = { ...n, children: d };
|
|
281
|
+
je(x, "left", Ue, !0, o);
|
|
279
282
|
}
|
|
280
|
-
} else if (
|
|
281
|
-
const
|
|
283
|
+
} else if (s === "tree") {
|
|
284
|
+
const i = (a) => {
|
|
282
285
|
a.side = 1, a._dir = "right";
|
|
283
|
-
for (const
|
|
286
|
+
for (const d of a.children) i(d);
|
|
284
287
|
};
|
|
285
288
|
for (const a of n.children) a._dir = "right";
|
|
286
|
-
|
|
289
|
+
je(n, "right", Ue, !0, o), i(n);
|
|
287
290
|
} else {
|
|
288
|
-
for (const
|
|
289
|
-
|
|
291
|
+
for (const i of n.children) i._dir = "down";
|
|
292
|
+
Kt(n, Ue, o);
|
|
290
293
|
}
|
|
291
294
|
}
|
|
292
|
-
function
|
|
295
|
+
function je(n, s, o, i, a = !1) {
|
|
293
296
|
if (n.children.length === 0) return;
|
|
294
|
-
const
|
|
295
|
-
(
|
|
297
|
+
const d = n.children.reduce(
|
|
298
|
+
(h, u, p) => h + u._subtreeH + (p > 0 ? $e : 0),
|
|
296
299
|
0
|
|
297
|
-
),
|
|
298
|
-
let m = n.y - x *
|
|
299
|
-
n.children.forEach((
|
|
300
|
-
a || (
|
|
300
|
+
), c = s === "right" ? 1 : -1, x = i ? c : 1;
|
|
301
|
+
let m = n.y - x * d / 2;
|
|
302
|
+
n.children.forEach((h) => {
|
|
303
|
+
a || (h.x = n.x + c * (n.width / 2 + o + h.width / 2), h.y = m + x * h._subtreeH / 2), h._dir = s, m += x * (h._subtreeH + $e), je(h, s, o, !1, a);
|
|
301
304
|
});
|
|
302
305
|
}
|
|
303
|
-
function
|
|
306
|
+
function Kt(n, s, o = !1) {
|
|
304
307
|
if (n.children.length === 0) return;
|
|
305
|
-
const
|
|
306
|
-
(
|
|
308
|
+
const i = n.children.reduce(
|
|
309
|
+
(d, c, x) => d + c._subtreeW + (x > 0 ? $e * 2 : 0),
|
|
307
310
|
0
|
|
308
311
|
);
|
|
309
|
-
let a = n.x -
|
|
310
|
-
n.children.forEach((
|
|
311
|
-
|
|
312
|
+
let a = n.x - i / 2;
|
|
313
|
+
n.children.forEach((d) => {
|
|
314
|
+
o || (d.x = a + d._subtreeW / 2, d.y = n.y + n.height / 2 + s + d.height / 2), d._dir = "down", a += d._subtreeW + $e * 2, Kt(d, s, o);
|
|
312
315
|
});
|
|
313
316
|
}
|
|
314
|
-
function
|
|
315
|
-
const
|
|
317
|
+
function Ut(n, s, o, i, a, d) {
|
|
318
|
+
const c = _n(n, s, d), x = {
|
|
316
319
|
id: n.id,
|
|
317
320
|
text: n.text,
|
|
318
|
-
depth:
|
|
321
|
+
depth: s,
|
|
319
322
|
// Honor a user-set position from the data tree (drag commit).
|
|
320
323
|
// The next applyDoLayout pass will overwrite these unless
|
|
321
324
|
// preservePositions is true.
|
|
322
325
|
x: n._x ?? 0,
|
|
323
326
|
y: n._y ?? 0,
|
|
324
|
-
width:
|
|
325
|
-
height:
|
|
326
|
-
fontSize:
|
|
327
|
-
isRoot:
|
|
327
|
+
width: c.w,
|
|
328
|
+
height: c.h,
|
|
329
|
+
fontSize: ft(s, d),
|
|
330
|
+
isRoot: s === 0,
|
|
328
331
|
collapsed: n.collapsed,
|
|
329
|
-
side:
|
|
332
|
+
side: i,
|
|
330
333
|
_dir: a,
|
|
331
|
-
_dirRight:
|
|
332
|
-
_subtreeH:
|
|
333
|
-
_subtreeW:
|
|
334
|
+
_dirRight: i,
|
|
335
|
+
_subtreeH: c.h,
|
|
336
|
+
_subtreeW: c.w,
|
|
334
337
|
image: n.image ? { ...n.image } : void 0,
|
|
335
338
|
link: n.link ? { url: n.link.url } : void 0,
|
|
336
339
|
note: n.note ? { text: n.note.text } : void 0,
|
|
337
340
|
children: [],
|
|
338
|
-
parent:
|
|
341
|
+
parent: o
|
|
339
342
|
};
|
|
340
|
-
if (n.collapsed) return
|
|
341
|
-
const
|
|
342
|
-
return
|
|
343
|
-
const
|
|
344
|
-
return
|
|
345
|
-
}),
|
|
343
|
+
if (n.collapsed) return x;
|
|
344
|
+
const m = n.children.length, h = Math.ceil(m / 2);
|
|
345
|
+
return x.children = n.children.map((u, p) => {
|
|
346
|
+
const S = s === 0 ? p < h ? 1 : -1 : i;
|
|
347
|
+
return Ut(u, s + 1, x, S, a, d);
|
|
348
|
+
}), x;
|
|
346
349
|
}
|
|
347
|
-
function
|
|
348
|
-
const
|
|
349
|
-
for (let
|
|
350
|
-
const
|
|
351
|
-
for (const a of
|
|
350
|
+
function ni(n) {
|
|
351
|
+
const s = [n];
|
|
352
|
+
for (let o = 0; o < s.length; o++) {
|
|
353
|
+
const i = s[o];
|
|
354
|
+
for (const a of i.children) s.push(a);
|
|
352
355
|
}
|
|
353
|
-
for (let
|
|
354
|
-
const
|
|
355
|
-
if (
|
|
356
|
-
|
|
356
|
+
for (let o = s.length - 1; o >= 0; o--) {
|
|
357
|
+
const i = s[o];
|
|
358
|
+
if (i.collapsed || i.children.length === 0) {
|
|
359
|
+
i._subtreeH = i.height, i._subtreeW = i.width;
|
|
357
360
|
continue;
|
|
358
361
|
}
|
|
359
|
-
let a = 0,
|
|
360
|
-
for (const
|
|
361
|
-
a +=
|
|
362
|
-
|
|
362
|
+
let a = 0, d = 0;
|
|
363
|
+
for (const c of i.children)
|
|
364
|
+
a += c._subtreeH, d += c._subtreeW;
|
|
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);
|
|
363
366
|
}
|
|
364
367
|
}
|
|
365
|
-
function
|
|
366
|
-
const
|
|
367
|
-
let
|
|
368
|
-
for (;
|
|
369
|
-
const
|
|
370
|
-
|
|
368
|
+
function ii(n, s = !1) {
|
|
369
|
+
const o = [n];
|
|
370
|
+
let i = 1 / 0, a = -1 / 0, d = 1 / 0, c = -1 / 0;
|
|
371
|
+
for (; o.length; ) {
|
|
372
|
+
const h = o.pop(), u = h.width / 2, p = h.height / 2;
|
|
373
|
+
h.x - u < i && (i = h.x - u), h.x + u > a && (a = h.x + u), h.y - p < d && (d = h.y - p), h.y + p > c && (c = h.y + p), o.push(...h.children);
|
|
371
374
|
}
|
|
372
|
-
if (
|
|
375
|
+
if (s)
|
|
373
376
|
return {
|
|
374
377
|
root: n,
|
|
375
|
-
width: a -
|
|
376
|
-
height:
|
|
377
|
-
vbX:
|
|
378
|
-
vbY:
|
|
379
|
-
vbW: a -
|
|
380
|
-
vbH:
|
|
378
|
+
width: a - i + te * 2,
|
|
379
|
+
height: c - d + te * 2,
|
|
380
|
+
vbX: i - te,
|
|
381
|
+
vbY: d - te,
|
|
382
|
+
vbW: a - i + te * 2,
|
|
383
|
+
vbH: c - d + te * 2
|
|
381
384
|
};
|
|
382
|
-
const x =
|
|
385
|
+
const x = te - d, m = [n];
|
|
383
386
|
for (; m.length; ) {
|
|
384
|
-
const
|
|
385
|
-
|
|
387
|
+
const h = m.pop();
|
|
388
|
+
h.y += x, m.push(...h.children);
|
|
386
389
|
}
|
|
387
|
-
return
|
|
390
|
+
return d += x, c += x, {
|
|
388
391
|
root: n,
|
|
389
|
-
width: a -
|
|
390
|
-
height:
|
|
391
|
-
vbX:
|
|
392
|
+
width: a - i + te * 2,
|
|
393
|
+
height: c + te,
|
|
394
|
+
vbX: i - te,
|
|
392
395
|
vbY: 0,
|
|
393
|
-
vbW: a -
|
|
394
|
-
vbH:
|
|
396
|
+
vbW: a - i + te * 2,
|
|
397
|
+
vbH: c + te
|
|
395
398
|
};
|
|
396
399
|
}
|
|
397
|
-
const
|
|
400
|
+
const Pe = [
|
|
398
401
|
{
|
|
399
402
|
id: "default",
|
|
400
403
|
name: "默认",
|
|
@@ -466,261 +469,344 @@ const Le = [
|
|
|
466
469
|
]
|
|
467
470
|
}
|
|
468
471
|
];
|
|
469
|
-
function
|
|
470
|
-
return [...
|
|
472
|
+
function oi(n, s = []) {
|
|
473
|
+
return [...Pe, ...s].find((i) => i.id === n) ?? Pe[0];
|
|
471
474
|
}
|
|
472
|
-
function
|
|
475
|
+
function we() {
|
|
473
476
|
return "n_" + Math.random().toString(36).slice(2, 10) + Date.now().toString(36).slice(-4);
|
|
474
477
|
}
|
|
475
|
-
function
|
|
478
|
+
function he(n) {
|
|
476
479
|
return JSON.parse(JSON.stringify(n));
|
|
477
480
|
}
|
|
478
|
-
function
|
|
479
|
-
if (n.id ===
|
|
480
|
-
for (const
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
481
|
+
function B(n, s) {
|
|
482
|
+
if (n.id === s) return n;
|
|
483
|
+
for (const o of n.children) {
|
|
484
|
+
const i = B(o, s);
|
|
485
|
+
if (i) return i;
|
|
483
486
|
}
|
|
484
487
|
return null;
|
|
485
488
|
}
|
|
486
|
-
function
|
|
487
|
-
if (n.id ===
|
|
488
|
-
for (const
|
|
489
|
-
const a =
|
|
489
|
+
function ae(n, s, o = null) {
|
|
490
|
+
if (n.id === s) return o;
|
|
491
|
+
for (const i of n.children) {
|
|
492
|
+
const a = ae(i, s, n);
|
|
490
493
|
if (a !== null) return a;
|
|
491
494
|
}
|
|
492
495
|
return null;
|
|
493
496
|
}
|
|
494
|
-
function
|
|
495
|
-
const
|
|
496
|
-
if (
|
|
497
|
-
return n.children.splice(
|
|
498
|
-
for (const
|
|
499
|
-
if (
|
|
497
|
+
function Gt(n, s) {
|
|
498
|
+
const o = n.children.findIndex((i) => i.id === s);
|
|
499
|
+
if (o >= 0)
|
|
500
|
+
return n.children.splice(o, 1), !0;
|
|
501
|
+
for (const i of n.children)
|
|
502
|
+
if (Gt(i, s)) return !0;
|
|
500
503
|
return !1;
|
|
501
504
|
}
|
|
502
|
-
function
|
|
503
|
-
const
|
|
504
|
-
return !
|
|
505
|
+
function li(n, s, o) {
|
|
506
|
+
const i = B(n, s);
|
|
507
|
+
return !i || i.text === o ? !1 : (i.text = o, !0);
|
|
505
508
|
}
|
|
506
|
-
function
|
|
507
|
-
if (!
|
|
508
|
-
const a =
|
|
509
|
-
if (
|
|
510
|
-
const [
|
|
511
|
-
if (
|
|
512
|
-
const
|
|
513
|
-
return
|
|
509
|
+
function ri(n, s, o, i) {
|
|
510
|
+
if (!ae(n, s) || s === o || B(B(n, s), o)) return !1;
|
|
511
|
+
const a = ae(n, s), d = a.children.findIndex((h) => h.id === s);
|
|
512
|
+
if (d < 0) return !1;
|
|
513
|
+
const [c] = a.children.splice(d, 1);
|
|
514
|
+
if (i === "child") {
|
|
515
|
+
const h = B(n, o);
|
|
516
|
+
return h ? (h.children.push(c), !0) : (a.children.splice(d, 0, c), !1);
|
|
514
517
|
}
|
|
515
|
-
const x =
|
|
518
|
+
const x = ae(n, o);
|
|
516
519
|
if (!x)
|
|
517
|
-
return a.children.splice(
|
|
518
|
-
let m = x.children.findIndex((
|
|
519
|
-
return m < 0 ? (a.children.splice(
|
|
520
|
+
return a.children.splice(d, 0, c), !1;
|
|
521
|
+
let m = x.children.findIndex((h) => h.id === o);
|
|
522
|
+
return m < 0 ? (a.children.splice(d, 0, c), !1) : (i === "after" && (m += 1), x.children.splice(m, 0, c), !0);
|
|
520
523
|
}
|
|
521
|
-
function
|
|
522
|
-
const
|
|
523
|
-
let
|
|
524
|
+
function jt(n) {
|
|
525
|
+
const s = /^新节点(?:\s+(\d+))?$/;
|
|
526
|
+
let o = 0, i = !1;
|
|
524
527
|
for (const a of n.children) {
|
|
525
|
-
const
|
|
526
|
-
if (
|
|
527
|
-
if (
|
|
528
|
-
const
|
|
529
|
-
|
|
528
|
+
const d = a.text.match(s);
|
|
529
|
+
if (d)
|
|
530
|
+
if (d[1]) {
|
|
531
|
+
const c = parseInt(d[1], 10);
|
|
532
|
+
c > o && (o = c);
|
|
530
533
|
} else
|
|
531
|
-
|
|
534
|
+
i = !0;
|
|
532
535
|
}
|
|
533
|
-
return
|
|
536
|
+
return o === 0 && !i ? Je : o > 0 ? `新节点 ${o + 1}` : "新节点 2";
|
|
534
537
|
}
|
|
535
|
-
function
|
|
536
|
-
const
|
|
537
|
-
if (!
|
|
538
|
-
const a = { id:
|
|
539
|
-
return
|
|
538
|
+
function ai(n, s, o) {
|
|
539
|
+
const i = B(n, s);
|
|
540
|
+
if (!i) return null;
|
|
541
|
+
const a = { id: we(), text: o ?? jt(i), children: [] };
|
|
542
|
+
return i.children.push(a), a;
|
|
540
543
|
}
|
|
541
|
-
function
|
|
542
|
-
const
|
|
543
|
-
if (!
|
|
544
|
-
const a =
|
|
544
|
+
function ui(n, s, o) {
|
|
545
|
+
const i = ae(n, s);
|
|
546
|
+
if (!i) return null;
|
|
547
|
+
const a = i.children.findIndex((c) => c.id === s);
|
|
545
548
|
if (a < 0) return null;
|
|
546
|
-
const
|
|
547
|
-
return
|
|
549
|
+
const d = { id: we(), text: o ?? jt(i), children: [] };
|
|
550
|
+
return i.children.splice(a + 1, 0, d), d;
|
|
548
551
|
}
|
|
549
|
-
function
|
|
550
|
-
const
|
|
551
|
-
if (!
|
|
552
|
-
const a =
|
|
552
|
+
function si(n, s, o) {
|
|
553
|
+
const i = ae(n, s);
|
|
554
|
+
if (!i) return null;
|
|
555
|
+
const a = i.children.findIndex((c) => c.id === s);
|
|
553
556
|
if (a < 0) return null;
|
|
554
|
-
const
|
|
555
|
-
return
|
|
557
|
+
const d = { id: we(), text: o, children: [] };
|
|
558
|
+
return i.children.splice(a, 0, d), d;
|
|
556
559
|
}
|
|
557
|
-
function
|
|
558
|
-
const
|
|
559
|
-
if (!
|
|
560
|
-
const
|
|
561
|
-
if (
|
|
562
|
-
const a =
|
|
563
|
-
return
|
|
560
|
+
function di(n, s) {
|
|
561
|
+
const o = ae(n, s);
|
|
562
|
+
if (!o) return null;
|
|
563
|
+
const i = o.children.findIndex((c) => c.id === s);
|
|
564
|
+
if (i < 0) return null;
|
|
565
|
+
const a = o.children[i], d = he(a);
|
|
566
|
+
return Jt(d), o.children.splice(i + 1, 0, d), d;
|
|
567
|
+
}
|
|
568
|
+
function Jt(n) {
|
|
569
|
+
n.id = we();
|
|
570
|
+
for (const s of n.children) Jt(s);
|
|
571
|
+
}
|
|
572
|
+
const Je = "新节点";
|
|
573
|
+
function Xt(n, s = "导入的导图") {
|
|
574
|
+
const o = n.split(/\r?\n/), i = { id: we(), text: s, children: [] }, a = [i], d = [-1 / 0], c = [], x = /^(#{1,6})\s+(.+?)\s*#*\s*$/, m = /^!\[([^\]]*)\]\((\S+?)(?:\s+"[^"]*")?\)\s*$/, h = /^\[([^\]]+)\]\((\S+?)(?:\s+"[^"]*")?\)\s*$/, u = /^(`{3,}|~{3,})\s*(\S+)?\s*$/;
|
|
575
|
+
let p = !1, S = [], b = null;
|
|
576
|
+
function A(w) {
|
|
577
|
+
S.push(w);
|
|
578
|
+
}
|
|
579
|
+
function U() {
|
|
580
|
+
if (b && S.length > 0) {
|
|
581
|
+
for (; S.length > 0 && S[0].trim() === ""; ) S.shift();
|
|
582
|
+
for (; S.length > 0 && S[S.length - 1].trim() === ""; ) S.pop();
|
|
583
|
+
const w = S.join(`
|
|
584
|
+
`);
|
|
585
|
+
w && (b.note = { text: w });
|
|
586
|
+
}
|
|
587
|
+
p = !1, S = [];
|
|
588
|
+
}
|
|
589
|
+
for (const w of o) {
|
|
590
|
+
if (p) {
|
|
591
|
+
const Y = w.match(u);
|
|
592
|
+
if (Y && Y[1][0] === "`") {
|
|
593
|
+
U();
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
A(w);
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
const G = w.match(x);
|
|
600
|
+
if (G) {
|
|
601
|
+
const Y = G[1].length, re = G[2].trim();
|
|
602
|
+
c.push({ level: Y, text: re, body: "" }), b = c[c.length - 1];
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
const q = w.match(u);
|
|
606
|
+
if (q && q[2] === "note") {
|
|
607
|
+
p = !0, S = [];
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
const T = w.match(m);
|
|
611
|
+
if (T && b) {
|
|
612
|
+
const Y = T[2], re = 160, me = 120;
|
|
613
|
+
b.image = { src: Y, naturalW: re, naturalH: me, width: re, height: me };
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
const le = w.match(h);
|
|
617
|
+
if (le && b) {
|
|
618
|
+
b.link = { url: le[2] }, b.text = le[1];
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
w.trim().length > 0 && b && (b.body = b.body ? b.body + " " + w.trim() : w.trim());
|
|
622
|
+
}
|
|
623
|
+
p && U();
|
|
624
|
+
function ce(w) {
|
|
625
|
+
for (; a.length > 1; ) {
|
|
626
|
+
const le = a.length - 1, Y = d[le];
|
|
627
|
+
if (Y !== void 0 && Y < w.level) break;
|
|
628
|
+
a.pop(), d.pop();
|
|
629
|
+
}
|
|
630
|
+
const G = a[a.length - 1], q = w.text, T = { id: we(), text: q, children: [] };
|
|
631
|
+
w.image && (T.image = { ...w.image }), w.link && (T.link = { url: w.link.url }), w.note && (T.note = { text: w.note.text }), w.body && ue(w, c, c.indexOf(w)) && T.children.push({ id: we(), text: w.body, children: [] }), G.children.push(T), a.push(T), d.push(w.level);
|
|
632
|
+
}
|
|
633
|
+
function ue(w, G, q) {
|
|
634
|
+
for (let T = q + 1; T < G.length; T++) {
|
|
635
|
+
if (G[T].level <= w.level) return !0;
|
|
636
|
+
if (G[T].level > w.level) return !1;
|
|
637
|
+
}
|
|
638
|
+
return !0;
|
|
639
|
+
}
|
|
640
|
+
for (const w of c) ce(w);
|
|
641
|
+
if (c.length > 0 && c[0].level === 1) {
|
|
642
|
+
const w = i.children[0];
|
|
643
|
+
w && (i.text = w.text, i.id = w.id, w.image && (i.image = { ...w.image }), w.link && (i.link = { url: w.link.url }), w.note && (i.note = { text: w.note.text }), i.children = w.children);
|
|
644
|
+
}
|
|
645
|
+
return i;
|
|
564
646
|
}
|
|
565
|
-
function
|
|
566
|
-
|
|
567
|
-
|
|
647
|
+
function st(n, s = 1) {
|
|
648
|
+
let o = "#".repeat(s) + " " + (n.text || "") + `
|
|
649
|
+
`;
|
|
650
|
+
n.link && (o += `[${n.text || "link"}](${n.link.url})
|
|
651
|
+
`), n.image && (o += `
|
|
652
|
+
`), n.note && (o += "```note\n" + n.note.text + "\n```\n");
|
|
653
|
+
for (const i of n.children) o += st(i, s + 1);
|
|
654
|
+
return o;
|
|
568
655
|
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
const d = n.minScale ?? 0.2, i = n.maxScale ?? 3, l = n.step ?? 1.2, a = A(1), s = A(0), f = A(0), x = A(!1), m = Ue({
|
|
656
|
+
function ci(n) {
|
|
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({
|
|
572
658
|
x: 0,
|
|
573
659
|
y: 0,
|
|
574
660
|
ox: 0,
|
|
575
661
|
oy: 0
|
|
576
|
-
}),
|
|
577
|
-
let
|
|
578
|
-
function
|
|
579
|
-
|
|
662
|
+
}), h = D(!1), u = Ge({ x: 0, y: 0 }), p = Ge({ x: 0, y: 0, width: 0, height: 0 }), S = D(0);
|
|
663
|
+
let b = null;
|
|
664
|
+
function A(I) {
|
|
665
|
+
b = I;
|
|
580
666
|
}
|
|
581
|
-
function
|
|
582
|
-
|
|
583
|
-
const
|
|
584
|
-
if (!
|
|
585
|
-
const
|
|
586
|
-
a.value =
|
|
667
|
+
function U(I) {
|
|
668
|
+
I.preventDefault();
|
|
669
|
+
const W = n.getContainer();
|
|
670
|
+
if (!W) return;
|
|
671
|
+
const j = -I.deltaY * 1e-3, _ = Math.min(o, Math.max(s, a.value * (1 + j))), ne = W.getBoundingClientRect(), ie = I.clientX - ne.left, ke = I.clientY - ne.top, Be = (ie - d.value) / a.value, Me = (ke - c.value) / a.value;
|
|
672
|
+
a.value = _, d.value = ie - Be * _, c.value = ke - Me * _;
|
|
587
673
|
}
|
|
588
|
-
function
|
|
589
|
-
a.value = Math.min(
|
|
674
|
+
function ce() {
|
|
675
|
+
a.value = Math.min(o, a.value * i);
|
|
590
676
|
}
|
|
591
|
-
function
|
|
592
|
-
a.value = Math.max(
|
|
677
|
+
function ue() {
|
|
678
|
+
a.value = Math.max(s, a.value / i);
|
|
593
679
|
}
|
|
594
|
-
function
|
|
595
|
-
var
|
|
596
|
-
|
|
680
|
+
function w(I) {
|
|
681
|
+
var j;
|
|
682
|
+
I.target.closest(".zm-node, .zm-toolbar, button, input, textarea") || (x.value = !0, m.x = I.clientX, m.y = I.clientY, m.ox = d.value, m.oy = c.value, window.addEventListener("mousemove", G), window.addEventListener("mouseup", q), (j = I.preventDefault) == null || j.call(I));
|
|
597
683
|
}
|
|
598
|
-
function
|
|
599
|
-
x.value && (
|
|
684
|
+
function G(I) {
|
|
685
|
+
x.value && (d.value = m.ox + (I.clientX - m.x), c.value = m.oy + (I.clientY - m.y));
|
|
600
686
|
}
|
|
601
|
-
function
|
|
602
|
-
x.value = !1, window.removeEventListener("mousemove",
|
|
687
|
+
function q() {
|
|
688
|
+
x.value = !1, window.removeEventListener("mousemove", G), window.removeEventListener("mouseup", q);
|
|
603
689
|
}
|
|
604
|
-
function
|
|
605
|
-
|
|
690
|
+
function T(I, W) {
|
|
691
|
+
h.value = !0, u.x = I, u.y = W, p.x = I, p.y = W, p.width = 0, p.height = 0, S.value++, window.addEventListener("mousemove", re), window.addEventListener("mouseup", Y);
|
|
606
692
|
}
|
|
607
|
-
function
|
|
608
|
-
if (!
|
|
609
|
-
const
|
|
610
|
-
|
|
693
|
+
function le(I, W) {
|
|
694
|
+
if (!h.value) return;
|
|
695
|
+
const j = Math.min(u.x, I), _ = Math.min(u.y, W), ne = Math.max(u.x, I), ie = Math.max(u.y, W);
|
|
696
|
+
p.x = j, p.y = _, p.width = ne - j, p.height = ie - _, S.value++;
|
|
611
697
|
}
|
|
612
|
-
function
|
|
613
|
-
|
|
698
|
+
function Y() {
|
|
699
|
+
h.value = !1, window.removeEventListener("mousemove", re), window.removeEventListener("mouseup", Y), b && b();
|
|
614
700
|
}
|
|
615
|
-
function
|
|
616
|
-
if (!
|
|
617
|
-
const
|
|
618
|
-
if (!
|
|
619
|
-
const
|
|
620
|
-
|
|
701
|
+
function re(I) {
|
|
702
|
+
if (!h.value) return;
|
|
703
|
+
const W = n.getContainer();
|
|
704
|
+
if (!W) return;
|
|
705
|
+
const j = W.getBoundingClientRect(), _ = (I.clientX - j.left - d.value) / a.value, ne = (I.clientY - j.top - c.value) / a.value;
|
|
706
|
+
le(_, ne);
|
|
621
707
|
}
|
|
622
|
-
function
|
|
623
|
-
const
|
|
624
|
-
if (!
|
|
625
|
-
const
|
|
626
|
-
a.value =
|
|
708
|
+
function me(I, W, j, _ = 60) {
|
|
709
|
+
const ne = n.getContainer();
|
|
710
|
+
if (!ne) return;
|
|
711
|
+
const ie = ne.getBoundingClientRect(), ke = (ie.width - _ * 2) / I, Be = (ie.height - _ * 2) / W, Me = Math.min(1, Math.max(0.3, Math.min(ke, Be)));
|
|
712
|
+
a.value = Me, d.value = ie.width / 2, c.value = ie.height / 2 - j * Me;
|
|
627
713
|
}
|
|
628
714
|
return {
|
|
629
715
|
scale: a,
|
|
630
|
-
offsetX:
|
|
631
|
-
offsetY:
|
|
716
|
+
offsetX: d,
|
|
717
|
+
offsetY: c,
|
|
632
718
|
isPanning: x,
|
|
633
|
-
onWheel:
|
|
634
|
-
zoomIn:
|
|
635
|
-
zoomOut:
|
|
636
|
-
startPan:
|
|
637
|
-
startMarquee:
|
|
638
|
-
updateMarquee:
|
|
639
|
-
isMarquee:
|
|
640
|
-
marquee:
|
|
641
|
-
marqueeVersion:
|
|
642
|
-
setOnMarqueeEnd:
|
|
643
|
-
resetView:
|
|
719
|
+
onWheel: U,
|
|
720
|
+
zoomIn: ce,
|
|
721
|
+
zoomOut: ue,
|
|
722
|
+
startPan: w,
|
|
723
|
+
startMarquee: T,
|
|
724
|
+
updateMarquee: le,
|
|
725
|
+
isMarquee: h,
|
|
726
|
+
marquee: p,
|
|
727
|
+
marqueeVersion: S,
|
|
728
|
+
setOnMarqueeEnd: A,
|
|
729
|
+
resetView: me
|
|
644
730
|
};
|
|
645
731
|
}
|
|
646
|
-
const
|
|
647
|
-
function
|
|
648
|
-
return
|
|
732
|
+
const fi = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform);
|
|
733
|
+
function qt(n) {
|
|
734
|
+
return fi ? n.metaKey : n.ctrlKey;
|
|
649
735
|
}
|
|
650
|
-
function
|
|
651
|
-
function
|
|
652
|
-
const
|
|
653
|
-
return
|
|
736
|
+
function vi(n) {
|
|
737
|
+
function s() {
|
|
738
|
+
const i = n.getSelectedId();
|
|
739
|
+
return i || (n.defaultTargetId ? n.defaultTargetId() : n.getRootId());
|
|
654
740
|
}
|
|
655
|
-
function i
|
|
656
|
-
const a =
|
|
741
|
+
function o(i) {
|
|
742
|
+
const a = i.target;
|
|
657
743
|
if (a && (a.tagName === "INPUT" || a.tagName === "TEXTAREA" || a.isContentEditable) || n.isReadonly() || n.isEditing()) return;
|
|
658
|
-
const
|
|
659
|
-
if (
|
|
660
|
-
if (
|
|
661
|
-
if (
|
|
662
|
-
|
|
744
|
+
const d = n.getSelectedId(), c = s();
|
|
745
|
+
if (c) {
|
|
746
|
+
if (qt(i) && !i.shiftKey) {
|
|
747
|
+
if (i.key === "d" || i.key === "D") {
|
|
748
|
+
d && d !== n.getRootId() && (i.preventDefault(), n.onDuplicate(d));
|
|
663
749
|
return;
|
|
664
750
|
}
|
|
665
|
-
if (
|
|
666
|
-
|
|
751
|
+
if (i.key === "z" || i.key === "Z") {
|
|
752
|
+
i.preventDefault(), n.onUndo();
|
|
667
753
|
return;
|
|
668
754
|
}
|
|
669
|
-
if (
|
|
670
|
-
|
|
755
|
+
if (i.key === "y" || i.key === "Y") {
|
|
756
|
+
i.preventDefault(), n.onRedo();
|
|
671
757
|
return;
|
|
672
758
|
}
|
|
673
|
-
if (
|
|
674
|
-
|
|
759
|
+
if (i.key === "Home") {
|
|
760
|
+
i.preventDefault(), n.onSelectRoot();
|
|
675
761
|
return;
|
|
676
762
|
}
|
|
677
763
|
}
|
|
678
|
-
if (
|
|
679
|
-
|
|
764
|
+
if (qt(i) && i.shiftKey && (i.key === "Z" || i.key === "z")) {
|
|
765
|
+
i.preventDefault(), n.onRedo();
|
|
680
766
|
return;
|
|
681
767
|
}
|
|
682
|
-
|
|
768
|
+
i.key === "Tab" ? (i.preventDefault(), n.onAddChild(c)) : i.key === "Enter" ? (i.preventDefault(), i.shiftKey ? d && d !== n.getRootId() && n.onAddSiblingBefore(d) : n.onAddSibling(c)) : (i.key === "Delete" || i.key === "Backspace") && d && d !== n.getRootId() ? (i.preventDefault(), n.onRemove(d)) : i.key === "F2" && d ? (i.preventDefault(), n.onStartEdit(d)) : i.key === "Escape" ? (i.preventDefault(), n.onClearSelection()) : i.key === "ArrowDown" ? (i.preventDefault(), n.onNavigate(0, 1)) : i.key === "ArrowUp" ? (i.preventDefault(), n.onNavigate(0, -1)) : i.key === "ArrowRight" ? (i.preventDefault(), n.onNavigate(1, 0)) : i.key === "ArrowLeft" && (i.preventDefault(), n.onNavigate(-1, 0));
|
|
683
769
|
}
|
|
684
770
|
}
|
|
685
771
|
ut(() => {
|
|
686
|
-
window.addEventListener("keydown",
|
|
687
|
-
}),
|
|
688
|
-
window.removeEventListener("keydown",
|
|
772
|
+
window.addEventListener("keydown", o);
|
|
773
|
+
}), ct(() => {
|
|
774
|
+
window.removeEventListener("keydown", o);
|
|
689
775
|
});
|
|
690
776
|
}
|
|
691
|
-
function
|
|
692
|
-
const
|
|
693
|
-
let
|
|
694
|
-
function
|
|
695
|
-
return
|
|
777
|
+
function hi(n = 100) {
|
|
778
|
+
const s = D([]);
|
|
779
|
+
let o = -1;
|
|
780
|
+
function i() {
|
|
781
|
+
return o > 0;
|
|
696
782
|
}
|
|
697
783
|
function a() {
|
|
698
|
-
return
|
|
784
|
+
return o < s.value.length - 1;
|
|
699
785
|
}
|
|
700
|
-
function
|
|
701
|
-
const u = JSON.stringify(
|
|
702
|
-
for (
|
|
703
|
-
|
|
786
|
+
function d(h) {
|
|
787
|
+
const u = JSON.stringify(h);
|
|
788
|
+
for (o < s.value.length - 1 && (s.value = s.value.slice(0, o + 1)), s.value.push(u), o = s.value.length - 1; s.value.length > n; )
|
|
789
|
+
s.value.shift(), o--;
|
|
704
790
|
}
|
|
705
|
-
function
|
|
706
|
-
return
|
|
791
|
+
function c() {
|
|
792
|
+
return i() ? (o--, JSON.parse(s.value[o])) : null;
|
|
707
793
|
}
|
|
708
794
|
function x() {
|
|
709
|
-
return a() ? (
|
|
795
|
+
return a() ? (o++, JSON.parse(s.value[o])) : null;
|
|
710
796
|
}
|
|
711
797
|
function m() {
|
|
712
|
-
|
|
798
|
+
s.value = [], o = -1;
|
|
713
799
|
}
|
|
714
800
|
return {
|
|
715
|
-
canUndo:
|
|
801
|
+
canUndo: i,
|
|
716
802
|
canRedo: a,
|
|
717
|
-
record:
|
|
718
|
-
undo:
|
|
803
|
+
record: d,
|
|
804
|
+
undo: c,
|
|
719
805
|
redo: x,
|
|
720
806
|
reset: m
|
|
721
807
|
};
|
|
722
808
|
}
|
|
723
|
-
const
|
|
809
|
+
const mi = ["disabled"], gi = ["disabled"], yi = ["disabled"], xi = ["disabled"], pi = ["disabled"], bi = ["disabled"], wi = /* @__PURE__ */ dt({
|
|
724
810
|
__name: "NodeContextMenu",
|
|
725
811
|
props: {
|
|
726
812
|
x: {},
|
|
@@ -732,300 +818,324 @@ const si = ["disabled"], di = ["disabled"], ci = ["disabled"], fi = ["disabled"]
|
|
|
732
818
|
readonly: { type: Boolean, default: !1 }
|
|
733
819
|
},
|
|
734
820
|
emits: ["pickImage", "setLink", "removeLink", "editNote", "removeNote", "removeImage", "close"],
|
|
735
|
-
setup(n, { emit:
|
|
736
|
-
const
|
|
737
|
-
let
|
|
738
|
-
if (
|
|
739
|
-
const
|
|
740
|
-
|
|
821
|
+
setup(n, { emit: s }) {
|
|
822
|
+
const o = n, i = s, a = Q(() => {
|
|
823
|
+
let S = o.x + 2, b = o.y + 2;
|
|
824
|
+
if (o.container) {
|
|
825
|
+
const A = o.container.getBoundingClientRect(), U = 180, ce = d.value ? c.value ? 184 : 160 : 136;
|
|
826
|
+
S + U > A.right && (S = Math.max(A.left + 4, o.x - U - 2)), b + ce > A.bottom && (b = Math.max(A.top + 4, o.y - ce - 2)), S < A.left + 2 && (S = A.left + 2), b < A.top + 2 && (b = A.top + 2);
|
|
741
827
|
}
|
|
742
|
-
return { left:
|
|
743
|
-
}),
|
|
744
|
-
function m(
|
|
745
|
-
const
|
|
746
|
-
|
|
828
|
+
return { left: S, top: b };
|
|
829
|
+
}), d = Q(() => o.hasImage), c = Q(() => o.hasLink), x = Q(() => o.hasNote);
|
|
830
|
+
function m(S) {
|
|
831
|
+
const b = S.target;
|
|
832
|
+
b && b.closest(".zm-node-menu") || i("close");
|
|
747
833
|
}
|
|
748
|
-
function
|
|
749
|
-
|
|
834
|
+
function h(S) {
|
|
835
|
+
S.key === "Escape" && i("close");
|
|
750
836
|
}
|
|
751
837
|
function u() {
|
|
752
|
-
|
|
838
|
+
i("close");
|
|
753
839
|
}
|
|
754
|
-
window.addEventListener("mousedown", m, !0), window.addEventListener("keydown",
|
|
755
|
-
window.removeEventListener("mousedown", m, !0), window.removeEventListener("keydown",
|
|
840
|
+
window.addEventListener("mousedown", m, !0), window.addEventListener("keydown", h, !0), window.addEventListener("wheel", u, !0), window.addEventListener("scroll", u, !0), ct(() => {
|
|
841
|
+
window.removeEventListener("mousedown", m, !0), window.removeEventListener("keydown", h, !0), window.removeEventListener("wheel", u, !0), window.removeEventListener("scroll", u, !0);
|
|
756
842
|
});
|
|
757
|
-
function
|
|
758
|
-
|
|
843
|
+
function p(S) {
|
|
844
|
+
o.readonly || (S(), i("close"));
|
|
759
845
|
}
|
|
760
|
-
return (
|
|
846
|
+
return (S, b) => (M(), C("div", {
|
|
761
847
|
class: "zm-node-menu",
|
|
762
|
-
style:
|
|
763
|
-
onContextmenu:
|
|
848
|
+
style: ve({ left: a.value.left + "px", top: a.value.top + "px" }),
|
|
849
|
+
onContextmenu: b[6] || (b[6] = R(() => {
|
|
764
850
|
}, ["prevent"]))
|
|
765
851
|
}, [
|
|
766
|
-
|
|
852
|
+
y("button", {
|
|
767
853
|
class: "zm-node-menu-item",
|
|
768
854
|
disabled: n.readonly,
|
|
769
|
-
onClick:
|
|
855
|
+
onClick: b[0] || (b[0] = R((A) => p(() => i("pickImage")), ["stop"]))
|
|
770
856
|
}, [
|
|
771
|
-
|
|
857
|
+
F(V, {
|
|
772
858
|
name: "image",
|
|
773
859
|
size: 13
|
|
774
860
|
}),
|
|
775
|
-
|
|
776
|
-
], 8,
|
|
777
|
-
|
|
861
|
+
y("span", null, be(d.value ? "替换图片" : "添加图片"), 1)
|
|
862
|
+
], 8, mi),
|
|
863
|
+
d.value ? (M(), C("button", {
|
|
778
864
|
key: 0,
|
|
779
865
|
class: "zm-node-menu-item",
|
|
780
866
|
disabled: n.readonly,
|
|
781
|
-
onClick:
|
|
867
|
+
onClick: b[1] || (b[1] = R((A) => p(() => i("removeImage")), ["stop"]))
|
|
782
868
|
}, [
|
|
783
|
-
|
|
869
|
+
F(V, {
|
|
784
870
|
name: "x",
|
|
785
871
|
size: 13
|
|
786
872
|
}),
|
|
787
|
-
|
|
788
|
-
], 8,
|
|
789
|
-
|
|
873
|
+
b[7] || (b[7] = y("span", null, "移除图片", -1))
|
|
874
|
+
], 8, gi)) : O("", !0),
|
|
875
|
+
y("button", {
|
|
790
876
|
class: "zm-node-menu-item",
|
|
791
877
|
disabled: n.readonly,
|
|
792
|
-
onClick:
|
|
878
|
+
onClick: b[2] || (b[2] = R((A) => p(() => i("setLink")), ["stop"]))
|
|
793
879
|
}, [
|
|
794
|
-
|
|
880
|
+
F(V, {
|
|
795
881
|
name: "link",
|
|
796
882
|
size: 13
|
|
797
883
|
}),
|
|
798
|
-
|
|
799
|
-
], 8,
|
|
800
|
-
|
|
884
|
+
y("span", null, be(c.value ? "编辑链接" : "添加链接"), 1)
|
|
885
|
+
], 8, yi),
|
|
886
|
+
c.value ? (M(), C("button", {
|
|
801
887
|
key: 1,
|
|
802
888
|
class: "zm-node-menu-item",
|
|
803
889
|
disabled: n.readonly,
|
|
804
|
-
onClick:
|
|
890
|
+
onClick: b[3] || (b[3] = R((A) => p(() => i("removeLink")), ["stop"]))
|
|
805
891
|
}, [
|
|
806
|
-
|
|
892
|
+
F(V, {
|
|
807
893
|
name: "x",
|
|
808
894
|
size: 13
|
|
809
895
|
}),
|
|
810
|
-
|
|
811
|
-
], 8,
|
|
812
|
-
|
|
896
|
+
b[8] || (b[8] = y("span", null, "移除链接", -1))
|
|
897
|
+
], 8, xi)) : O("", !0),
|
|
898
|
+
y("button", {
|
|
813
899
|
class: "zm-node-menu-item",
|
|
814
900
|
disabled: n.readonly,
|
|
815
|
-
onClick:
|
|
901
|
+
onClick: b[4] || (b[4] = R((A) => p(() => i("editNote")), ["stop"]))
|
|
816
902
|
}, [
|
|
817
|
-
|
|
903
|
+
F(V, {
|
|
818
904
|
name: "note",
|
|
819
905
|
size: 13
|
|
820
906
|
}),
|
|
821
|
-
|
|
822
|
-
], 8,
|
|
823
|
-
x.value ? (
|
|
907
|
+
y("span", null, be(x.value ? "编辑笔记" : "添加笔记"), 1)
|
|
908
|
+
], 8, pi),
|
|
909
|
+
x.value ? (M(), C("button", {
|
|
824
910
|
key: 2,
|
|
825
911
|
class: "zm-node-menu-item",
|
|
826
912
|
disabled: n.readonly,
|
|
827
|
-
onClick:
|
|
913
|
+
onClick: b[5] || (b[5] = R((A) => p(() => i("removeNote")), ["stop"]))
|
|
828
914
|
}, [
|
|
829
|
-
|
|
915
|
+
F(V, {
|
|
830
916
|
name: "x",
|
|
831
917
|
size: 13
|
|
832
918
|
}),
|
|
833
|
-
|
|
834
|
-
], 8,
|
|
919
|
+
b[9] || (b[9] = y("span", null, "移除笔记", -1))
|
|
920
|
+
], 8, bi)) : O("", !0)
|
|
835
921
|
], 36));
|
|
836
922
|
}
|
|
837
|
-
}),
|
|
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 = {
|
|
838
924
|
key: 1,
|
|
839
925
|
class: "zm-text"
|
|
840
|
-
},
|
|
926
|
+
}, Ni = { class: "zm-text-label" }, Ii = ["href", "title"], Wi = ["title", "onClick"], $i = ["title"], Bi = ["title", "onClick"], Ri = ["onClick"], Ai = ["onMousedown"], Li = ["onClick"], Hi = {
|
|
841
927
|
key: 0,
|
|
842
928
|
class: "zm-toolbar"
|
|
843
|
-
},
|
|
929
|
+
}, Di = ["src"], Pi = ["src"], Ti = { class: "zm-tb-tip" }, We = 24, De = 400, pe = 160, Oi = /* @__PURE__ */ dt({
|
|
844
930
|
__name: "MindMap",
|
|
845
931
|
props: {
|
|
846
932
|
data: {},
|
|
847
933
|
readonly: { type: Boolean, default: !1 },
|
|
848
934
|
theme: {},
|
|
849
|
-
previewMode: { type: Boolean, default: !1 }
|
|
935
|
+
previewMode: { type: Boolean, default: !1 },
|
|
936
|
+
markdown: {},
|
|
937
|
+
lineColors: {}
|
|
850
938
|
},
|
|
851
|
-
emits: ["change", "select", "edit-note"],
|
|
852
|
-
setup(n, { expose:
|
|
853
|
-
const
|
|
854
|
-
|
|
939
|
+
emits: ["change", "select", "edit-note", "markdownChange"],
|
|
940
|
+
setup(n, { expose: s, emit: o }) {
|
|
941
|
+
const i = n, a = o, d = D(null), c = D(null), x = D(""), m = D(null), h = D(/* @__PURE__ */ new Set()), u = D(he(i.data)), p = D(i.markdown !== void 0);
|
|
942
|
+
let S = !1;
|
|
943
|
+
Ye(
|
|
944
|
+
() => i.markdown,
|
|
945
|
+
(e) => {
|
|
946
|
+
if (e === void 0) {
|
|
947
|
+
p.value = !1;
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
p.value = !0;
|
|
951
|
+
const t = Xt(e || "");
|
|
952
|
+
S = !0, u.value = he(t), m.value = null, h.value = /* @__PURE__ */ new Set(), H(), Z(() => {
|
|
953
|
+
S = !1, se();
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
), Ye(
|
|
957
|
+
u,
|
|
958
|
+
() => {
|
|
959
|
+
p.value && !S && a("markdownChange", st(u.value));
|
|
960
|
+
},
|
|
961
|
+
{ deep: !0 }
|
|
962
|
+
);
|
|
963
|
+
const b = Q(() => k.showOrderBadge === !0), A = D(/* @__PURE__ */ new Map()), U = A.value;
|
|
964
|
+
function ce(e, t) {
|
|
855
965
|
const r = {};
|
|
856
|
-
t.bg && (r.bg = t.bg), t.textColor && (r.textColor = t.textColor), t.borderColor && (r.borderColor = t.borderColor), t.fontWeight && (r.fontWeight = t.fontWeight), Object.keys(r).length === 0 ?
|
|
966
|
+
t.bg && (r.bg = t.bg), t.textColor && (r.textColor = t.textColor), t.borderColor && (r.borderColor = t.borderColor), t.fontWeight && (r.fontWeight = t.fontWeight), Object.keys(r).length === 0 ? U.delete(e) : U.set(e, r), A.value = new Map(U);
|
|
857
967
|
}
|
|
858
|
-
function
|
|
859
|
-
return
|
|
968
|
+
function ue(e) {
|
|
969
|
+
return U.get(e) ?? {};
|
|
860
970
|
}
|
|
861
|
-
function
|
|
862
|
-
const r =
|
|
971
|
+
function w(e, t) {
|
|
972
|
+
const r = B(u.value, e);
|
|
863
973
|
r && (r.image = {
|
|
864
974
|
src: t.src,
|
|
865
975
|
naturalW: t.naturalW,
|
|
866
976
|
naturalH: t.naturalH,
|
|
867
|
-
width:
|
|
868
|
-
height:
|
|
869
|
-
},
|
|
977
|
+
width: q(t.width, We, De),
|
|
978
|
+
height: q(t.height, We, De)
|
|
979
|
+
}, K(), H(), a("change", u.value));
|
|
870
980
|
}
|
|
871
|
-
function
|
|
872
|
-
const t =
|
|
873
|
-
!t || !t.image || (delete t.image,
|
|
981
|
+
function G(e) {
|
|
982
|
+
const t = B(u.value, e);
|
|
983
|
+
!t || !t.image || (delete t.image, K(), H(), a("change", u.value));
|
|
874
984
|
}
|
|
875
|
-
function
|
|
985
|
+
function q(e, t, r) {
|
|
876
986
|
return Math.min(r, Math.max(t, e));
|
|
877
987
|
}
|
|
878
|
-
function
|
|
988
|
+
function T(e, t) {
|
|
879
989
|
const r = new FileReader();
|
|
880
990
|
r.onload = () => {
|
|
881
991
|
if (typeof r.result != "string") return;
|
|
882
|
-
const
|
|
883
|
-
|
|
884
|
-
const
|
|
885
|
-
t({ src:
|
|
886
|
-
},
|
|
887
|
-
t({ src:
|
|
888
|
-
},
|
|
992
|
+
const v = r.result, f = new window.Image();
|
|
993
|
+
f.onload = () => {
|
|
994
|
+
const l = f.naturalWidth || pe, g = f.naturalHeight || pe, $ = q(l, We, pe), X = q(Math.round(g * $ / l), We, De);
|
|
995
|
+
t({ src: v, naturalW: l, naturalH: g, width: $, height: X });
|
|
996
|
+
}, f.onerror = () => {
|
|
997
|
+
t({ src: v, naturalW: pe, naturalH: pe, width: pe, height: pe });
|
|
998
|
+
}, f.src = v;
|
|
889
999
|
}, r.readAsDataURL(e);
|
|
890
1000
|
}
|
|
891
|
-
function
|
|
1001
|
+
function le(e) {
|
|
892
1002
|
const t = document.createElement("input");
|
|
893
1003
|
t.type = "file", t.accept = "image/*", t.style.display = "none", t.onchange = () => {
|
|
894
|
-
var
|
|
895
|
-
const r = (
|
|
896
|
-
r && (
|
|
1004
|
+
var v;
|
|
1005
|
+
const r = (v = t.files) == null ? void 0 : v[0];
|
|
1006
|
+
r && (T(r, (f) => w(e, f)), document.body.removeChild(t));
|
|
897
1007
|
}, document.body.appendChild(t), t.click();
|
|
898
1008
|
}
|
|
899
|
-
function
|
|
900
|
-
const r = t.trim(),
|
|
901
|
-
|
|
1009
|
+
function Y(e, t) {
|
|
1010
|
+
const r = t.trim(), v = B(u.value, e);
|
|
1011
|
+
v && (r ? v.link = { url: r } : delete v.link, K(), H(), a("change", u.value));
|
|
902
1012
|
}
|
|
903
|
-
function
|
|
904
|
-
|
|
1013
|
+
function re(e) {
|
|
1014
|
+
Y(e, "");
|
|
905
1015
|
}
|
|
906
|
-
function
|
|
907
|
-
const r =
|
|
908
|
-
r && (t ? r.note = { text: t } : delete r.note,
|
|
1016
|
+
function me(e, t) {
|
|
1017
|
+
const r = B(u.value, e);
|
|
1018
|
+
r && (t ? r.note = { text: t } : delete r.note, K(), H(), a("change", u.value));
|
|
909
1019
|
}
|
|
910
|
-
function
|
|
911
|
-
|
|
1020
|
+
function I(e) {
|
|
1021
|
+
me(e, "");
|
|
912
1022
|
}
|
|
913
|
-
const
|
|
914
|
-
function
|
|
915
|
-
|
|
1023
|
+
const W = D(null);
|
|
1024
|
+
function j(e, t) {
|
|
1025
|
+
i.readonly || (e.preventDefault(), e.stopPropagation(), m.value = t.id, a("select", B(u.value, t.id)), W.value = { nodeId: t.id, x: e.clientX, y: e.clientY });
|
|
916
1026
|
}
|
|
917
|
-
function
|
|
918
|
-
|
|
1027
|
+
function _() {
|
|
1028
|
+
W.value = null;
|
|
919
1029
|
}
|
|
920
|
-
function
|
|
1030
|
+
function ne() {
|
|
921
1031
|
var t;
|
|
922
|
-
const e = (t =
|
|
923
|
-
e &&
|
|
1032
|
+
const e = (t = W.value) == null ? void 0 : t.nodeId;
|
|
1033
|
+
e && le(e);
|
|
924
1034
|
}
|
|
925
|
-
function
|
|
926
|
-
var
|
|
927
|
-
const e = (
|
|
1035
|
+
function ie() {
|
|
1036
|
+
var v, f, l;
|
|
1037
|
+
const e = (v = W.value) == null ? void 0 : v.nodeId;
|
|
928
1038
|
if (!e) return;
|
|
929
|
-
const t = ((
|
|
930
|
-
r !== null &&
|
|
1039
|
+
const t = ((l = (f = B(u.value, e)) == null ? void 0 : f.link) == null ? void 0 : l.url) ?? "", r = window.prompt("输入链接 URL(留空取消)", t);
|
|
1040
|
+
r !== null && Y(e, r);
|
|
931
1041
|
}
|
|
932
|
-
function
|
|
1042
|
+
function ke() {
|
|
933
1043
|
var t;
|
|
934
|
-
const e = (t =
|
|
935
|
-
e &&
|
|
1044
|
+
const e = (t = W.value) == null ? void 0 : t.nodeId;
|
|
1045
|
+
e && re(e);
|
|
936
1046
|
}
|
|
937
|
-
function
|
|
1047
|
+
function Be() {
|
|
938
1048
|
var t;
|
|
939
|
-
const e = (t =
|
|
940
|
-
e &&
|
|
1049
|
+
const e = (t = W.value) == null ? void 0 : t.nodeId;
|
|
1050
|
+
e && vt(e);
|
|
941
1051
|
}
|
|
942
|
-
function
|
|
1052
|
+
function Me() {
|
|
943
1053
|
var t;
|
|
944
|
-
const e = (t =
|
|
945
|
-
e &&
|
|
1054
|
+
const e = (t = W.value) == null ? void 0 : t.nodeId;
|
|
1055
|
+
e && I(e);
|
|
946
1056
|
}
|
|
947
|
-
function
|
|
1057
|
+
function Zt() {
|
|
948
1058
|
var t;
|
|
949
|
-
const e = (t =
|
|
950
|
-
e &&
|
|
1059
|
+
const e = (t = W.value) == null ? void 0 : t.nodeId;
|
|
1060
|
+
e && G(e);
|
|
951
1061
|
}
|
|
952
|
-
function
|
|
953
|
-
|
|
1062
|
+
function vt(e) {
|
|
1063
|
+
i.readonly || a("edit-note", e);
|
|
954
1064
|
}
|
|
955
|
-
function
|
|
1065
|
+
function Qt(e, t = 60) {
|
|
956
1066
|
const r = e.replace(/\s+/g, " ").trim();
|
|
957
1067
|
return r.length <= t ? r || "点击编辑笔记" : r.slice(0, t) + "…";
|
|
958
1068
|
}
|
|
959
|
-
function
|
|
960
|
-
var
|
|
961
|
-
if (
|
|
1069
|
+
function ht(e) {
|
|
1070
|
+
var f;
|
|
1071
|
+
if (i.readonly || c.value) return;
|
|
962
1072
|
const t = e.target;
|
|
963
1073
|
if (t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable))
|
|
964
1074
|
return;
|
|
965
1075
|
const r = m.value;
|
|
966
1076
|
if (!r) return;
|
|
967
|
-
const
|
|
968
|
-
if (
|
|
969
|
-
for (let
|
|
970
|
-
const
|
|
971
|
-
if (
|
|
972
|
-
const
|
|
973
|
-
if (
|
|
1077
|
+
const v = (f = e.clipboardData) == null ? void 0 : f.items;
|
|
1078
|
+
if (v)
|
|
1079
|
+
for (let l = 0; l < v.length; l++) {
|
|
1080
|
+
const g = v[l];
|
|
1081
|
+
if (g.kind === "file" && g.type.startsWith("image/")) {
|
|
1082
|
+
const $ = g.getAsFile();
|
|
1083
|
+
if (!$) continue;
|
|
974
1084
|
e.preventDefault();
|
|
975
|
-
const
|
|
976
|
-
if (
|
|
1085
|
+
const X = B(u.value, r);
|
|
1086
|
+
if (X != null && X.image && !window.confirm("该节点已有图片,要用剪贴板里的图片替换吗?"))
|
|
977
1087
|
return;
|
|
978
|
-
|
|
1088
|
+
T($, (J) => w(r, J));
|
|
979
1089
|
return;
|
|
980
1090
|
}
|
|
981
1091
|
}
|
|
982
1092
|
}
|
|
983
1093
|
ut(() => {
|
|
984
|
-
window.addEventListener("paste",
|
|
985
|
-
}),
|
|
986
|
-
window.removeEventListener("paste",
|
|
1094
|
+
window.addEventListener("paste", ht);
|
|
1095
|
+
}), ct(() => {
|
|
1096
|
+
window.removeEventListener("paste", ht);
|
|
987
1097
|
});
|
|
988
|
-
const
|
|
1098
|
+
const Re = D(null), _t = Q(() => {
|
|
989
1099
|
var e;
|
|
990
|
-
return ((e =
|
|
1100
|
+
return ((e = Re.value) == null ? void 0 : e.nodeId) ?? null;
|
|
991
1101
|
});
|
|
992
|
-
function
|
|
1102
|
+
function en(e, t) {
|
|
993
1103
|
if (!t.image) return;
|
|
994
1104
|
e.preventDefault(), e.stopPropagation();
|
|
995
|
-
const r = t.image.naturalW || t.image.width,
|
|
996
|
-
|
|
1105
|
+
const r = t.image.naturalW || t.image.width, v = t.image.naturalH || t.image.height, f = v > 0 ? v / r : 1;
|
|
1106
|
+
Re.value = {
|
|
997
1107
|
nodeId: t.id,
|
|
998
1108
|
startX: e.clientX,
|
|
999
1109
|
startY: e.clientY,
|
|
1000
1110
|
startW: t.image.width,
|
|
1001
1111
|
startH: t.image.height,
|
|
1002
1112
|
naturalW: r,
|
|
1003
|
-
naturalH:
|
|
1004
|
-
ratio:
|
|
1113
|
+
naturalH: v,
|
|
1114
|
+
ratio: f,
|
|
1005
1115
|
pendingW: t.image.width,
|
|
1006
1116
|
pendingH: t.image.height
|
|
1007
|
-
}, window.addEventListener("mousemove",
|
|
1117
|
+
}, window.addEventListener("mousemove", mt), window.addEventListener("mouseup", gt);
|
|
1008
1118
|
}
|
|
1009
|
-
function
|
|
1010
|
-
var
|
|
1011
|
-
const t =
|
|
1119
|
+
function mt(e) {
|
|
1120
|
+
var X, J;
|
|
1121
|
+
const t = Re.value;
|
|
1012
1122
|
if (!t) return;
|
|
1013
|
-
const r =
|
|
1014
|
-
t.pendingW =
|
|
1015
|
-
const
|
|
1123
|
+
const r = E.scale.value || 1, v = e.clientX - t.startX, f = q(t.startW + v / r, We, De), l = q(f * t.ratio, We, De);
|
|
1124
|
+
t.pendingW = f, t.pendingH = l;
|
|
1125
|
+
const g = (X = d.value) == null ? void 0 : X.querySelector(
|
|
1016
1126
|
`[data-node-id="${t.nodeId}"] .zm-node-img`
|
|
1017
1127
|
);
|
|
1018
|
-
|
|
1019
|
-
const
|
|
1128
|
+
g && (g.style.width = `${f}px`, g.style.height = `${l}px`);
|
|
1129
|
+
const $ = (J = d.value) == null ? void 0 : J.querySelector(
|
|
1020
1130
|
`[data-node-id="${t.nodeId}"]`
|
|
1021
1131
|
);
|
|
1022
|
-
|
|
1132
|
+
$ && ($.style.minWidth = `${Math.max(80, Math.ceil(f + 28))}px`, $.style.height = `${Math.ceil(l + 8 + 30)}px`);
|
|
1023
1133
|
}
|
|
1024
|
-
function
|
|
1025
|
-
const e =
|
|
1026
|
-
if (window.removeEventListener("mousemove",
|
|
1027
|
-
const t =
|
|
1028
|
-
!t || !t.image || (
|
|
1134
|
+
function gt() {
|
|
1135
|
+
const e = Re.value;
|
|
1136
|
+
if (window.removeEventListener("mousemove", mt), window.removeEventListener("mouseup", gt), Re.value = null, !e) return;
|
|
1137
|
+
const t = B(u.value, e.nodeId);
|
|
1138
|
+
!t || !t.image || (w(e.nodeId, {
|
|
1029
1139
|
src: t.image.src,
|
|
1030
1140
|
naturalW: t.image.naturalW,
|
|
1031
1141
|
naturalH: t.image.naturalH,
|
|
@@ -1033,36 +1143,36 @@ const si = ["disabled"], di = ["disabled"], ci = ["disabled"], fi = ["disabled"]
|
|
|
1033
1143
|
height: e.pendingH
|
|
1034
1144
|
}), m.value = e.nodeId, a("select", t), _e = !0);
|
|
1035
1145
|
}
|
|
1036
|
-
const Qe =
|
|
1146
|
+
const Qe = D(null);
|
|
1037
1147
|
let _e = !1;
|
|
1038
|
-
function
|
|
1148
|
+
function tn(e) {
|
|
1039
1149
|
Qe.value = e;
|
|
1040
1150
|
}
|
|
1041
|
-
function
|
|
1151
|
+
function nn(e) {
|
|
1042
1152
|
Qe.value === e && (Qe.value = null);
|
|
1043
1153
|
}
|
|
1044
|
-
const
|
|
1045
|
-
function
|
|
1046
|
-
|
|
1154
|
+
const yt = D(0), et = D(!1), fe = hi(100);
|
|
1155
|
+
function K() {
|
|
1156
|
+
fe.record({ data: u.value });
|
|
1047
1157
|
}
|
|
1048
|
-
function
|
|
1049
|
-
|
|
1158
|
+
function H() {
|
|
1159
|
+
h.value = new Set(h.value), yt.value++;
|
|
1050
1160
|
}
|
|
1051
|
-
const
|
|
1052
|
-
var e, t, r,
|
|
1161
|
+
const oe = Q(() => {
|
|
1162
|
+
var e, t, r, v, f, l, g, $, X, J;
|
|
1053
1163
|
return {
|
|
1054
|
-
rootBg: ((e =
|
|
1055
|
-
rootText: ((t =
|
|
1056
|
-
branchBg: ((r =
|
|
1057
|
-
branchText: ((
|
|
1058
|
-
lineColor: ((
|
|
1059
|
-
bgColor: ((
|
|
1060
|
-
fontSize: ((
|
|
1061
|
-
lineWidthStart: ((
|
|
1062
|
-
lineWidthEnd: ((
|
|
1063
|
-
rainbowBranch: ((
|
|
1164
|
+
rootBg: ((e = i.theme) == null ? void 0 : e.rootBg) ?? "#1f2937",
|
|
1165
|
+
rootText: ((t = i.theme) == null ? void 0 : t.rootText) ?? "#ffffff",
|
|
1166
|
+
branchBg: ((r = i.theme) == null ? void 0 : r.branchBg) ?? "#ffffff",
|
|
1167
|
+
branchText: ((v = i.theme) == null ? void 0 : v.branchText) ?? "#1f2937",
|
|
1168
|
+
lineColor: ((f = i.theme) == null ? void 0 : f.lineColor) ?? "#94a3b8",
|
|
1169
|
+
bgColor: ((l = i.theme) == null ? void 0 : l.bgColor) ?? "#f8fafc",
|
|
1170
|
+
fontSize: ((g = i.theme) == null ? void 0 : g.fontSize) ?? 14,
|
|
1171
|
+
lineWidthStart: (($ = i.theme) == null ? void 0 : $.lineWidthStart) ?? 2.2,
|
|
1172
|
+
lineWidthEnd: ((X = i.theme) == null ? void 0 : X.lineWidthEnd) ?? 0.8,
|
|
1173
|
+
rainbowBranch: ((J = i.theme) == null ? void 0 : J.rainbowBranch) ?? !1
|
|
1064
1174
|
};
|
|
1065
|
-
}),
|
|
1175
|
+
}), k = Ge({
|
|
1066
1176
|
autoBalanceOnChange: !0,
|
|
1067
1177
|
lineWidthStart: 12,
|
|
1068
1178
|
lineWidthEnd: 3.6,
|
|
@@ -1074,393 +1184,406 @@ const si = ["disabled"], di = ["disabled"], ci = ["disabled"], fi = ["disabled"]
|
|
|
1074
1184
|
taperedEdge: !0,
|
|
1075
1185
|
showOrderBadge: !1
|
|
1076
1186
|
});
|
|
1077
|
-
function
|
|
1078
|
-
return
|
|
1187
|
+
function xt(e) {
|
|
1188
|
+
return k.taperedEdge ? on(e) : bt(e);
|
|
1079
1189
|
}
|
|
1080
|
-
function
|
|
1081
|
-
return
|
|
1190
|
+
function pt(e) {
|
|
1191
|
+
return k.taperedEdge ? k.lineWidthEnd : bt(e);
|
|
1082
1192
|
}
|
|
1083
|
-
function
|
|
1084
|
-
return e <= 0 ?
|
|
1193
|
+
function on(e) {
|
|
1194
|
+
return e <= 0 ? k.lineWidthStart : e === 1 ? Math.max(1.5, k.lineWidthStart * 0.67) : e === 2 ? Math.max(0.8, k.lineWidthStart * 0.42) : k.lineWidthEnd;
|
|
1085
1195
|
}
|
|
1086
|
-
function
|
|
1087
|
-
if (e <= 0) return
|
|
1088
|
-
if (e >= 3) return
|
|
1196
|
+
function bt(e) {
|
|
1197
|
+
if (e <= 0) return k.lineWidthStart;
|
|
1198
|
+
if (e >= 3) return k.lineWidthEnd;
|
|
1089
1199
|
const t = e / 3;
|
|
1090
|
-
return
|
|
1091
|
-
}
|
|
1092
|
-
function
|
|
1093
|
-
const
|
|
1094
|
-
return { x:
|
|
1095
|
-
}
|
|
1096
|
-
function
|
|
1097
|
-
if (
|
|
1098
|
-
let
|
|
1099
|
-
if (
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1200
|
+
return k.lineWidthStart + (k.lineWidthEnd - k.lineWidthStart) * t;
|
|
1201
|
+
}
|
|
1202
|
+
function ln(e, t, r, v) {
|
|
1203
|
+
const f = 1 - e, l = f * f * f * t.x + 3 * f * f * e * r.x1 + 3 * f * e * e * r.x2 + e * e * e * v.x, g = f * f * f * t.y + 3 * f * f * e * r.y1 + 3 * f * e * e * r.y2 + e * e * e * v.y;
|
|
1204
|
+
return { x: l, y: g };
|
|
1205
|
+
}
|
|
1206
|
+
function rn(e, t, r, v, f = 32, l = "curve", g = "right") {
|
|
1207
|
+
if (l === "curve") {
|
|
1208
|
+
let xe;
|
|
1209
|
+
if (g === "right" || g === "left") {
|
|
1210
|
+
const L = Math.abs(t.x - e.x) * 0.45, de = g === "right" ? 1 : -1;
|
|
1211
|
+
xe = { x1: e.x + de * L, y1: e.y, x2: t.x - de * L, y2: t.y };
|
|
1102
1212
|
} else {
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1213
|
+
const L = Math.abs(t.y - e.y) * 0.45;
|
|
1214
|
+
xe = { x1: e.x, y1: e.y + L, x2: t.x, y2: t.y - L };
|
|
1105
1215
|
}
|
|
1106
|
-
const
|
|
1107
|
-
const
|
|
1108
|
-
return { dx:
|
|
1109
|
-
},
|
|
1110
|
-
for (let
|
|
1111
|
-
const
|
|
1112
|
-
let
|
|
1113
|
-
|
|
1114
|
-
const
|
|
1115
|
-
|
|
1216
|
+
const In = (N) => {
|
|
1217
|
+
const L = 1 - N, de = -3 * L * L * e.x + 3 * (L * L - 2 * L * N) * xe.x1 + 3 * (2 * L * N - N * N) * xe.x2 + 3 * N * N * t.x, ze = -3 * L * L * e.y + 3 * (L * L - 2 * L * N) * xe.y1 + 3 * (2 * L * N - N * N) * xe.y2 + 3 * N * N * t.y;
|
|
1218
|
+
return { dx: de, dy: ze };
|
|
1219
|
+
}, He = [], rt = [];
|
|
1220
|
+
for (let N = 0; N <= f; N++) {
|
|
1221
|
+
const L = N / f, de = N === 0 ? e : N === f ? t : ln(L, e, xe, t), ze = In(L);
|
|
1222
|
+
let Xe = Math.hypot(ze.dx, ze.dy);
|
|
1223
|
+
Xe < 1e-6 && (Xe = 1);
|
|
1224
|
+
const Pt = -ze.dy / Xe, Tt = ze.dx / Xe, qe = (r + (v - r) * L) / 2;
|
|
1225
|
+
He.push({ x: de.x + Pt * qe, y: de.y + Tt * qe }), rt.push({ x: de.x - Pt * qe, y: de.y - Tt * qe });
|
|
1116
1226
|
}
|
|
1117
|
-
let
|
|
1118
|
-
for (let
|
|
1119
|
-
for (let
|
|
1120
|
-
return
|
|
1227
|
+
let Ve = `M ${He[0].x.toFixed(2)} ${He[0].y.toFixed(2)}`;
|
|
1228
|
+
for (let N = 1; N <= f; N++) Ve += ` L ${He[N].x.toFixed(2)} ${He[N].y.toFixed(2)}`;
|
|
1229
|
+
for (let N = f; N >= 0; N--) Ve += ` L ${rt[N].x.toFixed(2)} ${rt[N].y.toFixed(2)}`;
|
|
1230
|
+
return Ve += " Z", Ve;
|
|
1121
1231
|
}
|
|
1122
|
-
const
|
|
1123
|
-
let
|
|
1124
|
-
|
|
1125
|
-
const
|
|
1126
|
-
return `M ${
|
|
1127
|
-
}
|
|
1128
|
-
const
|
|
1129
|
-
() =>
|
|
1130
|
-
),
|
|
1232
|
+
const $ = t.x - e.x, X = t.y - e.y;
|
|
1233
|
+
let J = Math.hypot($, X);
|
|
1234
|
+
J < 1e-6 && (J = 1);
|
|
1235
|
+
const ye = -X / J, Se = $ / J, Ee = r / 2, Le = v / 2, At = { x: e.x + ye * Ee, y: e.y + Se * Ee }, Lt = { x: e.x - ye * Ee, y: e.y - Se * Ee }, Ht = { x: t.x - ye * Le, y: t.y - Se * Le }, Dt = { x: t.x + ye * Le, y: t.y + Se * Le };
|
|
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
|
+
}
|
|
1238
|
+
const Te = Q(() => ee.value.root.children), an = Pe[0].colors, wt = Q(
|
|
1239
|
+
() => oi(k.branchPaletteId, k.customPalettes)
|
|
1240
|
+
), ge = Q(() => {
|
|
1131
1241
|
const e = /* @__PURE__ */ new Map();
|
|
1132
|
-
if (!
|
|
1133
|
-
const t =
|
|
1134
|
-
for (let
|
|
1135
|
-
const
|
|
1136
|
-
e.set(
|
|
1242
|
+
if (!k.rainbowBranch) return e;
|
|
1243
|
+
const t = i.lineColors, r = t && t.length > 0 ? t : wt.value.colors.length > 0 ? wt.value.colors : an;
|
|
1244
|
+
for (let f = 0; f < Te.value.length; f++) {
|
|
1245
|
+
const l = Te.value[f];
|
|
1246
|
+
e.set(l.id, r[f % r.length]);
|
|
1137
1247
|
}
|
|
1138
|
-
const
|
|
1139
|
-
e.set(
|
|
1140
|
-
for (const
|
|
1248
|
+
const v = (f, l) => {
|
|
1249
|
+
e.set(f.id, l);
|
|
1250
|
+
for (const g of f.children) v(g, l);
|
|
1141
1251
|
};
|
|
1142
|
-
for (let
|
|
1143
|
-
const
|
|
1144
|
-
|
|
1252
|
+
for (let f = 0; f < Te.value.length; f++) {
|
|
1253
|
+
const l = Te.value[f];
|
|
1254
|
+
v(l, r[f % r.length]);
|
|
1145
1255
|
}
|
|
1146
1256
|
return e;
|
|
1147
1257
|
});
|
|
1148
|
-
function
|
|
1149
|
-
return
|
|
1258
|
+
function un(e, t) {
|
|
1259
|
+
return k.rainbowBranch ? ge.value.get(t.id) ?? oe.value.lineColor : oe.value.lineColor;
|
|
1150
1260
|
}
|
|
1151
|
-
function
|
|
1152
|
-
const t =
|
|
1261
|
+
function sn(e) {
|
|
1262
|
+
const t = ue(e.id);
|
|
1153
1263
|
if (t.bg) return t.bg;
|
|
1154
|
-
if (e.isRoot) return
|
|
1155
|
-
if (
|
|
1156
|
-
const r =
|
|
1157
|
-
if (r) return
|
|
1264
|
+
if (e.isRoot) return oe.value.rootBg;
|
|
1265
|
+
if (k.rainbowBranch) {
|
|
1266
|
+
const r = ge.value.get(e.id);
|
|
1267
|
+
if (r) return vn(r, 0.18);
|
|
1158
1268
|
}
|
|
1159
|
-
return
|
|
1269
|
+
return oe.value.branchBg;
|
|
1160
1270
|
}
|
|
1161
|
-
function
|
|
1162
|
-
const t =
|
|
1271
|
+
function dn(e) {
|
|
1272
|
+
const t = ue(e.id);
|
|
1163
1273
|
if (t.textColor) return t.textColor;
|
|
1164
|
-
if (e.isRoot) return
|
|
1165
|
-
if (
|
|
1166
|
-
const r =
|
|
1167
|
-
if (r) return
|
|
1274
|
+
if (e.isRoot) return oe.value.rootText;
|
|
1275
|
+
if (k.rainbowBranch) {
|
|
1276
|
+
const r = ge.value.get(e.id);
|
|
1277
|
+
if (r) return kt(r, 0.55);
|
|
1168
1278
|
}
|
|
1169
|
-
return
|
|
1279
|
+
return oe.value.branchText;
|
|
1170
1280
|
}
|
|
1171
|
-
function
|
|
1172
|
-
const t =
|
|
1281
|
+
function cn(e) {
|
|
1282
|
+
const t = ue(e.id);
|
|
1173
1283
|
if (t.borderColor) return t.borderColor;
|
|
1174
|
-
if (e.isRoot) return
|
|
1175
|
-
if (
|
|
1176
|
-
const r =
|
|
1177
|
-
if (r) return
|
|
1284
|
+
if (e.isRoot) return oe.value.rootBg;
|
|
1285
|
+
if (k.rainbowBranch) {
|
|
1286
|
+
const r = ge.value.get(e.id);
|
|
1287
|
+
if (r) return kt(r, 0.3);
|
|
1178
1288
|
}
|
|
1179
|
-
return
|
|
1289
|
+
return oe.value.lineColor;
|
|
1180
1290
|
}
|
|
1181
|
-
function
|
|
1182
|
-
return
|
|
1291
|
+
function fn(e) {
|
|
1292
|
+
return ue(e.id).fontWeight ?? (e.isRoot ? 600 : 400);
|
|
1183
1293
|
}
|
|
1184
|
-
function
|
|
1185
|
-
const r = e.replace("#", ""),
|
|
1186
|
-
return `rgba(${
|
|
1294
|
+
function vn(e, t) {
|
|
1295
|
+
const r = e.replace("#", ""), v = r.length === 6 ? r : r.split("").map(($) => $ + $).join(""), f = parseInt(v.slice(0, 2), 16), l = parseInt(v.slice(2, 4), 16), g = parseInt(v.slice(4, 6), 16);
|
|
1296
|
+
return `rgba(${f}, ${l}, ${g}, ${t})`;
|
|
1187
1297
|
}
|
|
1188
|
-
function
|
|
1189
|
-
const r = e.replace("#", ""),
|
|
1190
|
-
return `rgb(${
|
|
1298
|
+
function kt(e, t) {
|
|
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
|
+
return `rgb(${f}, ${l}, ${g})`;
|
|
1191
1301
|
}
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
isEditing: () =>
|
|
1195
|
-
isReadonly: () =>
|
|
1302
|
+
const E = ci({ getContainer: () => d.value });
|
|
1303
|
+
E.setOnMarqueeEnd(Cn), vi({
|
|
1304
|
+
isEditing: () => c.value !== null,
|
|
1305
|
+
isReadonly: () => i.readonly,
|
|
1196
1306
|
getSelectedId: () => m.value,
|
|
1197
1307
|
getRootId: () => u.value.id,
|
|
1198
1308
|
// If nothing is selected, default Tab/Enter to the root so the user
|
|
1199
1309
|
// can build a tree from scratch without first clicking somewhere.
|
|
1200
1310
|
defaultTargetId: () => u.value.id,
|
|
1201
|
-
onAddChild:
|
|
1202
|
-
onAddSibling:
|
|
1203
|
-
onAddSiblingBefore:
|
|
1204
|
-
onRemove:
|
|
1205
|
-
onStartEdit:
|
|
1311
|
+
onAddChild: Ce,
|
|
1312
|
+
onAddSibling: Fe,
|
|
1313
|
+
onAddSiblingBefore: St,
|
|
1314
|
+
onRemove: zt,
|
|
1315
|
+
onStartEdit: Ae,
|
|
1206
1316
|
onClearSelection: () => {
|
|
1207
1317
|
m.value = null, a("select", null);
|
|
1208
1318
|
},
|
|
1209
|
-
onDuplicate:
|
|
1319
|
+
onDuplicate: Et,
|
|
1210
1320
|
onUndo: nt,
|
|
1211
1321
|
onRedo: it,
|
|
1212
|
-
onNavigate:
|
|
1322
|
+
onNavigate: xn,
|
|
1213
1323
|
onSelectRoot: () => {
|
|
1214
1324
|
m.value = u.value.id;
|
|
1215
|
-
const e =
|
|
1325
|
+
const e = B(u.value, u.value.id);
|
|
1216
1326
|
e && a("select", e);
|
|
1217
1327
|
}
|
|
1218
1328
|
});
|
|
1219
|
-
const
|
|
1220
|
-
const e =
|
|
1221
|
-
return
|
|
1222
|
-
}),
|
|
1223
|
-
|
|
1224
|
-
|
|
1329
|
+
const ee = Q(() => {
|
|
1330
|
+
const e = he(u.value);
|
|
1331
|
+
return Ct(e), ei(e, { mode: k.layoutMode, baseFontSize: oe.value.fontSize });
|
|
1332
|
+
}), Mt = D([]), tt = Q(() => (yt.value, Mt.value));
|
|
1333
|
+
Ye(
|
|
1334
|
+
ee,
|
|
1225
1335
|
(e) => {
|
|
1226
|
-
const t = [], r = (
|
|
1227
|
-
t.push(
|
|
1228
|
-
for (const
|
|
1336
|
+
const t = [], r = (v) => {
|
|
1337
|
+
t.push(v);
|
|
1338
|
+
for (const f of v.children) r(f);
|
|
1229
1339
|
};
|
|
1230
|
-
r(e.root),
|
|
1340
|
+
r(e.root), Mt.value = t;
|
|
1231
1341
|
},
|
|
1232
1342
|
{ immediate: !0 }
|
|
1233
1343
|
);
|
|
1234
|
-
const
|
|
1344
|
+
const hn = Q(() => {
|
|
1235
1345
|
const e = [];
|
|
1236
1346
|
for (const t of tt.value)
|
|
1237
1347
|
for (const r of t.children)
|
|
1238
1348
|
e.push({ from: t, to: r, key: `${t.id}->${r.id}` });
|
|
1239
1349
|
return e;
|
|
1240
|
-
}),
|
|
1241
|
-
() => `${
|
|
1350
|
+
}), mn = Q(
|
|
1351
|
+
() => `${ee.value.vbX} ${ee.value.vbY} ${ee.value.vbW} ${ee.value.vbH}`
|
|
1242
1352
|
);
|
|
1243
|
-
function
|
|
1244
|
-
if (
|
|
1353
|
+
function Ct(e) {
|
|
1354
|
+
if (h.value.has(e.id)) {
|
|
1245
1355
|
e.children = [], e.collapsed = !0;
|
|
1246
1356
|
return;
|
|
1247
1357
|
}
|
|
1248
1358
|
e.collapsed = !1;
|
|
1249
|
-
for (const t of e.children)
|
|
1359
|
+
for (const t of e.children) Ct(t);
|
|
1250
1360
|
}
|
|
1251
|
-
function
|
|
1252
|
-
const t =
|
|
1253
|
-
t && (
|
|
1361
|
+
function Ae(e) {
|
|
1362
|
+
const t = B(u.value, e);
|
|
1363
|
+
t && (c.value = e, x.value = t.text, Z(() => {
|
|
1254
1364
|
const r = document.querySelector(".zm-input");
|
|
1255
1365
|
r == null || r.focus(), r == null || r.select();
|
|
1256
1366
|
}));
|
|
1257
1367
|
}
|
|
1258
1368
|
function Oe(e = {}) {
|
|
1259
|
-
if (!
|
|
1260
|
-
const t =
|
|
1261
|
-
t && t.text !== (x.value.trim() || " ") && (t.text = x.value.trim() || " ",
|
|
1262
|
-
const r =
|
|
1263
|
-
|
|
1369
|
+
if (!c.value) return;
|
|
1370
|
+
const t = B(u.value, c.value);
|
|
1371
|
+
t && t.text !== (x.value.trim() || " ") && (t.text = x.value.trim() || " ", K(), a("change", u.value));
|
|
1372
|
+
const r = c.value;
|
|
1373
|
+
c.value = null, e.addChild ? Z(() => Ce(r)) : e.addSibling === "after" ? Z(() => Fe(r)) : e.addSibling === "before" && Z(() => St(r));
|
|
1264
1374
|
}
|
|
1265
|
-
function
|
|
1266
|
-
|
|
1375
|
+
function gn() {
|
|
1376
|
+
c.value = null;
|
|
1267
1377
|
}
|
|
1268
|
-
function
|
|
1378
|
+
function yn(e) {
|
|
1269
1379
|
const t = e.metaKey || e.ctrlKey;
|
|
1270
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());
|
|
1271
1381
|
}
|
|
1272
|
-
function
|
|
1273
|
-
const t =
|
|
1274
|
-
t && (
|
|
1382
|
+
function Ce(e) {
|
|
1383
|
+
const t = ai(u.value, e, Je);
|
|
1384
|
+
t && (K(), H(), a("change", u.value), Z(() => Ae(t.id)));
|
|
1275
1385
|
}
|
|
1276
|
-
function
|
|
1386
|
+
function Fe(e) {
|
|
1277
1387
|
if (e === u.value.id) {
|
|
1278
|
-
|
|
1388
|
+
Ce(e);
|
|
1279
1389
|
return;
|
|
1280
1390
|
}
|
|
1281
|
-
const t =
|
|
1282
|
-
t && (
|
|
1391
|
+
const t = ui(u.value, e, Je);
|
|
1392
|
+
t && (K(), H(), a("change", u.value), Z(() => Ae(t.id)));
|
|
1283
1393
|
}
|
|
1284
|
-
function
|
|
1394
|
+
function St(e) {
|
|
1285
1395
|
if (e === u.value.id) {
|
|
1286
|
-
|
|
1396
|
+
Ce(e);
|
|
1287
1397
|
return;
|
|
1288
1398
|
}
|
|
1289
|
-
const t =
|
|
1290
|
-
t && (
|
|
1399
|
+
const t = si(u.value, e, Je);
|
|
1400
|
+
t && (K(), H(), a("change", u.value), Z(() => Ae(t.id)));
|
|
1291
1401
|
}
|
|
1292
|
-
function
|
|
1402
|
+
function Et(e) {
|
|
1293
1403
|
if (e === u.value.id) return;
|
|
1294
|
-
const t =
|
|
1295
|
-
t && (
|
|
1404
|
+
const t = di(u.value, e);
|
|
1405
|
+
t && (K(), m.value = t.id, a("change", u.value), H());
|
|
1296
1406
|
}
|
|
1297
1407
|
function nt() {
|
|
1298
|
-
const e =
|
|
1299
|
-
e && (u.value = e.data, m.value = null, a("select", null),
|
|
1408
|
+
const e = fe.undo();
|
|
1409
|
+
e && (u.value = e.data, m.value = null, a("select", null), H(), a("change", u.value));
|
|
1300
1410
|
}
|
|
1301
1411
|
function it() {
|
|
1302
|
-
const e =
|
|
1303
|
-
e && (u.value = e.data, m.value = null, a("select", null),
|
|
1412
|
+
const e = fe.redo();
|
|
1413
|
+
e && (u.value = e.data, m.value = null, a("select", null), H(), a("change", u.value));
|
|
1304
1414
|
}
|
|
1305
|
-
function
|
|
1306
|
-
const r = m.value ?? u.value.id,
|
|
1307
|
-
if (!
|
|
1308
|
-
let
|
|
1415
|
+
function xn(e, t) {
|
|
1416
|
+
const r = m.value ?? u.value.id, v = B(u.value, r);
|
|
1417
|
+
if (!v) return;
|
|
1418
|
+
let f = null;
|
|
1309
1419
|
if (t === 1) {
|
|
1310
|
-
const
|
|
1311
|
-
if (
|
|
1312
|
-
const
|
|
1313
|
-
|
|
1420
|
+
const l = ae(u.value, v.id);
|
|
1421
|
+
if (l) {
|
|
1422
|
+
const g = l.children.findIndex(($) => $.id === v.id);
|
|
1423
|
+
g >= 0 && g < l.children.length - 1 && (f = l.children[g + 1].id);
|
|
1314
1424
|
}
|
|
1315
1425
|
} else if (t === -1) {
|
|
1316
|
-
const
|
|
1317
|
-
if (
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1426
|
+
const l = ae(u.value, v.id);
|
|
1427
|
+
if (l) {
|
|
1428
|
+
const g = l.children.findIndex(($) => $.id === v.id);
|
|
1429
|
+
g > 0 && (f = l.children[g - 1].id);
|
|
1320
1430
|
}
|
|
1321
1431
|
} else if (e === 1) {
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1324
|
-
} else e === -1 &&
|
|
1325
|
-
if (
|
|
1326
|
-
m.value =
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1432
|
+
const l = ae(u.value, v.id);
|
|
1433
|
+
l && (f = l.id);
|
|
1434
|
+
} else e === -1 && v.children.length > 0 && (f = v.children[0].id);
|
|
1435
|
+
if (f) {
|
|
1436
|
+
m.value = f;
|
|
1437
|
+
const l = B(u.value, f);
|
|
1438
|
+
l && a("select", l);
|
|
1329
1439
|
}
|
|
1330
1440
|
}
|
|
1331
|
-
function
|
|
1332
|
-
e !== u.value.id &&
|
|
1441
|
+
function zt(e) {
|
|
1442
|
+
e !== u.value.id && Gt(u.value, e) && (K(), m.value === e && (m.value = null), H(), a("change", u.value));
|
|
1333
1443
|
}
|
|
1334
|
-
function
|
|
1335
|
-
|
|
1444
|
+
function Nt(e) {
|
|
1445
|
+
h.value.has(e) ? h.value.delete(e) : h.value.add(e), H();
|
|
1336
1446
|
}
|
|
1337
|
-
function
|
|
1338
|
-
|
|
1447
|
+
function pn(e, t) {
|
|
1448
|
+
li(u.value, e, t) && (K(), H(), a("change", u.value));
|
|
1339
1449
|
}
|
|
1340
|
-
function
|
|
1341
|
-
return
|
|
1450
|
+
function bn(e, t, r) {
|
|
1451
|
+
return ri(u.value, e, t, r) ? (K(), H(), a("change", u.value), !0) : !1;
|
|
1342
1452
|
}
|
|
1343
|
-
function
|
|
1453
|
+
function wn(e, t) {
|
|
1344
1454
|
e.stopPropagation(), m.value = t.id;
|
|
1345
|
-
const r =
|
|
1455
|
+
const r = B(u.value, t.id);
|
|
1346
1456
|
a("select", r);
|
|
1347
1457
|
}
|
|
1348
|
-
function
|
|
1458
|
+
function kn(e) {
|
|
1349
1459
|
const t = e.target;
|
|
1350
1460
|
if (!t || t.closest(".zm-node, .zm-toolbar, button, input, textarea")) return;
|
|
1351
1461
|
if (e.button === 2) {
|
|
1352
|
-
|
|
1462
|
+
E.startPan(e);
|
|
1353
1463
|
return;
|
|
1354
1464
|
}
|
|
1355
1465
|
if (e.button !== 0) return;
|
|
1356
|
-
const r =
|
|
1357
|
-
|
|
1466
|
+
const r = d.value.getBoundingClientRect(), v = (e.clientX - r.left - E.offsetX.value) / E.scale.value, f = (e.clientY - r.top - E.offsetY.value) / E.scale.value;
|
|
1467
|
+
E.startMarquee(v, f);
|
|
1358
1468
|
}
|
|
1359
|
-
function
|
|
1469
|
+
function Mn(e) {
|
|
1360
1470
|
if (_e) {
|
|
1361
1471
|
_e = !1;
|
|
1362
1472
|
return;
|
|
1363
1473
|
}
|
|
1364
1474
|
const t = e.target;
|
|
1365
1475
|
if (!t || t.closest(".zm-node")) return;
|
|
1366
|
-
const r =
|
|
1476
|
+
const r = E.marquee;
|
|
1367
1477
|
r.width >= 4 || r.height >= 4 || m.value !== null && (m.value = null, a("select", null));
|
|
1368
1478
|
}
|
|
1369
|
-
function
|
|
1370
|
-
const e =
|
|
1479
|
+
function Cn() {
|
|
1480
|
+
const e = E.marquee;
|
|
1371
1481
|
if (e.width < 4 && e.height < 4)
|
|
1372
1482
|
return;
|
|
1373
|
-
const t = e.x, r = e.y,
|
|
1374
|
-
for (const
|
|
1375
|
-
const
|
|
1376
|
-
|
|
1483
|
+
const t = e.x, r = e.y, v = e.x + e.width, f = e.y + e.height, l = [];
|
|
1484
|
+
for (const g of tt.value) {
|
|
1485
|
+
const $ = g.width / 2, X = g.height / 2, J = g.x - $, ye = g.x + $, Se = g.y - X, Ee = g.y + X;
|
|
1486
|
+
J <= v && ye >= t && Se <= f && Ee >= r && l.push(g.id);
|
|
1377
1487
|
}
|
|
1378
|
-
if (
|
|
1379
|
-
m.value =
|
|
1380
|
-
const
|
|
1381
|
-
|
|
1488
|
+
if (l.length > 0) {
|
|
1489
|
+
m.value = l[0];
|
|
1490
|
+
const g = B(u.value, l[0]);
|
|
1491
|
+
g && a("select", g);
|
|
1382
1492
|
}
|
|
1383
1493
|
}
|
|
1384
|
-
function
|
|
1385
|
-
return
|
|
1494
|
+
function It(e) {
|
|
1495
|
+
return h.value.has(e);
|
|
1386
1496
|
}
|
|
1387
|
-
function
|
|
1388
|
-
const t =
|
|
1497
|
+
function Sn(e) {
|
|
1498
|
+
const t = B(u.value, e.id);
|
|
1389
1499
|
return !!t && t.children.length > 0;
|
|
1390
1500
|
}
|
|
1391
|
-
function
|
|
1392
|
-
const t =
|
|
1501
|
+
function ot(e) {
|
|
1502
|
+
const t = B(u.value, e);
|
|
1393
1503
|
return t ? t.children.length : 0;
|
|
1394
1504
|
}
|
|
1395
|
-
function
|
|
1396
|
-
if (!
|
|
1397
|
-
const
|
|
1398
|
-
for (;
|
|
1399
|
-
const
|
|
1400
|
-
if (
|
|
1401
|
-
for (const
|
|
1505
|
+
function Wt(e) {
|
|
1506
|
+
if (!B(u.value, e)) return 0;
|
|
1507
|
+
const v = [u.value];
|
|
1508
|
+
for (; v.length; ) {
|
|
1509
|
+
const f = v.pop(), l = f.children.findIndex((g) => g.id === e);
|
|
1510
|
+
if (l >= 0) return l;
|
|
1511
|
+
for (const g of f.children) v.push(g);
|
|
1402
1512
|
}
|
|
1403
1513
|
return 0;
|
|
1404
1514
|
}
|
|
1405
|
-
function
|
|
1406
|
-
if (((
|
|
1515
|
+
function $t(e, t, r, v) {
|
|
1516
|
+
if (((v == null ? void 0 : v._dir) ?? e._dir) === "down")
|
|
1407
1517
|
return t === "out" ? { x: e.x, y: e.y + e.height / 2 } : { x: e.x, y: e.y - e.height / 2 };
|
|
1408
|
-
let
|
|
1409
|
-
return t === "in" ?
|
|
1518
|
+
let l;
|
|
1519
|
+
return t === "in" ? l = -e.side : r !== void 0 ? l = r : l = e.side, { x: e.x + l * (e.width / 2), y: e.y };
|
|
1410
1520
|
}
|
|
1411
1521
|
function se() {
|
|
1412
|
-
const e =
|
|
1413
|
-
|
|
1522
|
+
const e = ee.value;
|
|
1523
|
+
E.resetView(e.width, e.height, e.root.y);
|
|
1414
1524
|
}
|
|
1415
|
-
function
|
|
1416
|
-
et.value = !0,
|
|
1525
|
+
function En() {
|
|
1526
|
+
et.value = !0, K(), H(), Z(() => se());
|
|
1417
1527
|
}
|
|
1418
|
-
function
|
|
1419
|
-
|
|
1528
|
+
function lt(e) {
|
|
1529
|
+
k.layoutMode !== e && (k.layoutMode = e, H(), Z(() => se()));
|
|
1420
1530
|
}
|
|
1421
|
-
function
|
|
1531
|
+
function Bt() {
|
|
1422
1532
|
return JSON.stringify(u.value, null, 2);
|
|
1423
1533
|
}
|
|
1424
|
-
function
|
|
1534
|
+
function Rt(e) {
|
|
1425
1535
|
try {
|
|
1426
1536
|
const t = JSON.parse(e);
|
|
1427
|
-
return !t.id || !Array.isArray(t.children) ? !1 : (
|
|
1537
|
+
return !t.id || !Array.isArray(t.children) ? !1 : (fe.reset(), u.value = he(t), m.value = null, h.value = /* @__PURE__ */ new Set(), H(), Z(() => se()), a("change", u.value), !0);
|
|
1428
1538
|
} catch {
|
|
1429
1539
|
return !1;
|
|
1430
1540
|
}
|
|
1431
1541
|
}
|
|
1432
|
-
function
|
|
1542
|
+
function zn() {
|
|
1433
1543
|
const e = document.createElement("input");
|
|
1434
1544
|
e.type = "file", e.accept = "application/json", e.onchange = () => {
|
|
1435
|
-
var
|
|
1436
|
-
const t = (
|
|
1545
|
+
var v;
|
|
1546
|
+
const t = (v = e.files) == null ? void 0 : v[0];
|
|
1437
1547
|
if (!t) return;
|
|
1438
1548
|
const r = new FileReader();
|
|
1439
1549
|
r.onload = () => {
|
|
1440
|
-
typeof r.result == "string" && (
|
|
1550
|
+
typeof r.result == "string" && (Rt(r.result) || alert("导入失败:JSON 格式无效"));
|
|
1441
1551
|
}, r.readAsText(t);
|
|
1442
1552
|
}, e.click();
|
|
1443
1553
|
}
|
|
1444
|
-
function
|
|
1445
|
-
const e = new Blob([
|
|
1554
|
+
function Nn() {
|
|
1555
|
+
const e = new Blob([Bt()], { type: "application/json" }), t = URL.createObjectURL(e), r = document.createElement("a");
|
|
1446
1556
|
r.href = t, r.download = `${u.value.text || "mindmap"}.json`, r.click(), URL.revokeObjectURL(t);
|
|
1447
1557
|
}
|
|
1448
|
-
return
|
|
1449
|
-
addChild: (e) =>
|
|
1450
|
-
addSibling: (e) =>
|
|
1451
|
-
removeNode: (e) =>
|
|
1452
|
-
duplicateNode: (e) =>
|
|
1453
|
-
setNodeText: (e, t) =>
|
|
1454
|
-
moveNode: (e, t, r) =>
|
|
1455
|
-
lineWidthForDepth:
|
|
1456
|
-
endWidthForDepth:
|
|
1558
|
+
return s({
|
|
1559
|
+
addChild: (e) => Ce(e),
|
|
1560
|
+
addSibling: (e) => Fe(e),
|
|
1561
|
+
removeNode: (e) => zt(e),
|
|
1562
|
+
duplicateNode: (e) => Et(e),
|
|
1563
|
+
setNodeText: (e, t) => pn(e, t),
|
|
1564
|
+
moveNode: (e, t, r) => bn(e, t, r),
|
|
1565
|
+
lineWidthForDepth: xt,
|
|
1566
|
+
endWidthForDepth: pt,
|
|
1457
1567
|
getData: () => u.value,
|
|
1458
1568
|
setData: (e) => {
|
|
1459
|
-
|
|
1569
|
+
fe.reset(), u.value = he(e), m.value = null, h.value = /* @__PURE__ */ new Set(), H(), K(), Z(() => se());
|
|
1460
1570
|
},
|
|
1461
1571
|
resetView: () => se(),
|
|
1462
|
-
exportData:
|
|
1463
|
-
importData:
|
|
1572
|
+
exportData: Bt,
|
|
1573
|
+
importData: Rt,
|
|
1574
|
+
/** Serialize the current data tree as markdown. Always available
|
|
1575
|
+
* — the same serializer is used to emit `markdownChange`. */
|
|
1576
|
+
getMarkdown: () => st(u.value),
|
|
1577
|
+
/** Replace the data tree with the result of parsing `md`. The
|
|
1578
|
+
* flag `emitMarkdownChange` (default true) controls whether the
|
|
1579
|
+
* change is also echoed via `markdownChange` (use false when
|
|
1580
|
+
* the host just set the same value back from the prop). */
|
|
1581
|
+
setMarkdown: (e, t = !0) => {
|
|
1582
|
+
const r = Xt(e || "");
|
|
1583
|
+
t && (p.value = !0), S = !t, fe.reset(), u.value = he(r), m.value = null, h.value = /* @__PURE__ */ new Set(), H(), K(), Z(() => {
|
|
1584
|
+
S = !1, se();
|
|
1585
|
+
}), a("change", u.value);
|
|
1586
|
+
},
|
|
1464
1587
|
// Make balanced the active layout (sticky). Subsequent data changes
|
|
1465
1588
|
// and additions stay in balanced mode. Pass `false` to revert to the
|
|
1466
1589
|
// default compact layout.
|
|
@@ -1471,379 +1594,381 @@ const si = ["disabled"], di = ["disabled"], ci = ["disabled"], fi = ["disabled"]
|
|
|
1471
1594
|
// Re-balance now: clear all manual drag offsets, re-run the balanced
|
|
1472
1595
|
// layout, and re-center the view. This is the action tied to the
|
|
1473
1596
|
// "balance" toolbar button.
|
|
1474
|
-
balance: () =>
|
|
1475
|
-
applyNodeStyle: (e, t) =>
|
|
1476
|
-
getNodeStyle: (e) =>
|
|
1477
|
-
applyNodeLink: (e, t) =>
|
|
1478
|
-
removeNodeLink: (e) =>
|
|
1479
|
-
applyNodeNote: (e, t) =>
|
|
1480
|
-
removeNodeNote: (e) =>
|
|
1597
|
+
balance: () => En(),
|
|
1598
|
+
applyNodeStyle: (e, t) => ce(e, t),
|
|
1599
|
+
getNodeStyle: (e) => ue(e),
|
|
1600
|
+
applyNodeLink: (e, t) => Y(e, t),
|
|
1601
|
+
removeNodeLink: (e) => re(e),
|
|
1602
|
+
applyNodeNote: (e, t) => me(e, t),
|
|
1603
|
+
removeNodeNote: (e) => I(e),
|
|
1481
1604
|
undo: () => nt(),
|
|
1482
1605
|
redo: () => it(),
|
|
1483
|
-
canUndo: () =>
|
|
1484
|
-
canRedo: () =>
|
|
1606
|
+
canUndo: () => fe.canUndo(),
|
|
1607
|
+
canRedo: () => fe.canRedo(),
|
|
1485
1608
|
// Settings panel / external mutation hooks
|
|
1486
1609
|
applySettings: (e) => {
|
|
1487
|
-
e.autoBalanceOnChange !== void 0 && (
|
|
1610
|
+
e.autoBalanceOnChange !== void 0 && (k.autoBalanceOnChange = e.autoBalanceOnChange), e.lineWidthStart !== void 0 && (k.lineWidthStart = Math.max(0.5, Math.min(20, e.lineWidthStart))), e.lineWidthEnd !== void 0 && (k.lineWidthEnd = Math.max(0.3, Math.min(10, e.lineWidthEnd))), e.rainbowBranch !== void 0 && (k.rainbowBranch = e.rainbowBranch), e.branchPaletteId !== void 0 && (k.branchPaletteId = e.branchPaletteId), e.customPalettes !== void 0 && (k.customPalettes = e.customPalettes), e.lineStyle !== void 0 && (k.lineStyle = e.lineStyle), e.taperedEdge !== void 0 && (k.taperedEdge = e.taperedEdge), e.showOrderBadge !== void 0 && (k.showOrderBadge = e.showOrderBadge);
|
|
1488
1611
|
},
|
|
1489
1612
|
getSettings: () => ({
|
|
1490
|
-
autoBalanceOnChange:
|
|
1491
|
-
lineWidthStart:
|
|
1492
|
-
lineWidthEnd:
|
|
1493
|
-
rainbowBranch:
|
|
1494
|
-
branchPaletteId:
|
|
1495
|
-
customPalettes:
|
|
1496
|
-
lineStyle:
|
|
1497
|
-
layoutMode:
|
|
1498
|
-
taperedEdge:
|
|
1499
|
-
showOrderBadge:
|
|
1613
|
+
autoBalanceOnChange: k.autoBalanceOnChange,
|
|
1614
|
+
lineWidthStart: k.lineWidthStart,
|
|
1615
|
+
lineWidthEnd: k.lineWidthEnd,
|
|
1616
|
+
rainbowBranch: k.rainbowBranch,
|
|
1617
|
+
branchPaletteId: k.branchPaletteId,
|
|
1618
|
+
customPalettes: k.customPalettes,
|
|
1619
|
+
lineStyle: k.lineStyle,
|
|
1620
|
+
layoutMode: k.layoutMode,
|
|
1621
|
+
taperedEdge: k.taperedEdge,
|
|
1622
|
+
showOrderBadge: k.showOrderBadge
|
|
1500
1623
|
}),
|
|
1501
1624
|
setBranchPalette: (e) => {
|
|
1502
1625
|
if (!e) return;
|
|
1503
|
-
[...
|
|
1626
|
+
[...Pe, ...k.customPalettes].find((r) => r.id === e) && (k.branchPaletteId = e);
|
|
1504
1627
|
},
|
|
1505
|
-
getBranchPalette: () =>
|
|
1506
|
-
getBranchPalettes: () => [...
|
|
1507
|
-
}),
|
|
1508
|
-
() =>
|
|
1628
|
+
getBranchPalette: () => k.branchPaletteId,
|
|
1629
|
+
getBranchPalettes: () => [...Pe, ...k.customPalettes]
|
|
1630
|
+
}), Ye(
|
|
1631
|
+
() => i.data,
|
|
1509
1632
|
(e) => {
|
|
1510
|
-
u.value =
|
|
1633
|
+
u.value = he(e), H();
|
|
1511
1634
|
},
|
|
1512
1635
|
{ deep: !1 }
|
|
1513
1636
|
), ut(() => {
|
|
1514
|
-
|
|
1637
|
+
K(), Z(() => se());
|
|
1515
1638
|
}), (e, t) => {
|
|
1516
|
-
var r,
|
|
1517
|
-
return
|
|
1639
|
+
var r, v, f;
|
|
1640
|
+
return M(), C("div", {
|
|
1518
1641
|
class: "zm-mindmap",
|
|
1519
|
-
style:
|
|
1642
|
+
style: ve({ background: oe.value.bgColor, fontSize: oe.value.fontSize + "px" })
|
|
1520
1643
|
}, [
|
|
1521
|
-
|
|
1644
|
+
y("div", {
|
|
1522
1645
|
ref_key: "wrapperRef",
|
|
1523
|
-
ref:
|
|
1646
|
+
ref: d,
|
|
1524
1647
|
class: "zm-canvas",
|
|
1525
|
-
onMousedown:
|
|
1526
|
-
onContextmenu: t[13] || (t[13] =
|
|
1648
|
+
onMousedown: kn,
|
|
1649
|
+
onContextmenu: t[13] || (t[13] = R(() => {
|
|
1527
1650
|
}, ["prevent"])),
|
|
1528
1651
|
onWheel: t[14] || (t[14] = //@ts-ignore
|
|
1529
|
-
(...
|
|
1530
|
-
onClick:
|
|
1652
|
+
(...l) => z(E).onWheel && z(E).onWheel(...l)),
|
|
1653
|
+
onClick: Mn
|
|
1531
1654
|
}, [
|
|
1532
|
-
|
|
1655
|
+
y("div", {
|
|
1533
1656
|
class: "zm-svg-layer",
|
|
1534
|
-
style:
|
|
1535
|
-
left:
|
|
1536
|
-
top:
|
|
1537
|
-
width:
|
|
1538
|
-
height:
|
|
1657
|
+
style: ve({
|
|
1658
|
+
left: ee.value.vbX * z(E).scale.value + z(E).offsetX.value + "px",
|
|
1659
|
+
top: ee.value.vbY * z(E).scale.value + z(E).offsetY.value + "px",
|
|
1660
|
+
width: ee.value.vbW * z(E).scale.value + "px",
|
|
1661
|
+
height: ee.value.vbH * z(E).scale.value + "px"
|
|
1539
1662
|
})
|
|
1540
1663
|
}, [
|
|
1541
|
-
(
|
|
1664
|
+
(M(), C("svg", {
|
|
1542
1665
|
class: "zm-svg",
|
|
1543
|
-
viewBox:
|
|
1666
|
+
viewBox: mn.value,
|
|
1544
1667
|
preserveAspectRatio: "xMinYMin meet",
|
|
1545
|
-
width:
|
|
1546
|
-
height:
|
|
1668
|
+
width: ee.value.vbW * z(E).scale.value,
|
|
1669
|
+
height: ee.value.vbH * z(E).scale.value
|
|
1547
1670
|
}, [
|
|
1548
|
-
|
|
1549
|
-
(
|
|
1550
|
-
key:
|
|
1551
|
-
d:
|
|
1552
|
-
fill:
|
|
1671
|
+
y("g", Mi, [
|
|
1672
|
+
(M(!0), C(P, null, Ot(hn.value, (l) => (M(), C("path", {
|
|
1673
|
+
key: l.key,
|
|
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
|
+
fill: un(l.from, l.to),
|
|
1553
1676
|
stroke: "none"
|
|
1554
|
-
}, null, 8,
|
|
1677
|
+
}, null, 8, Ci))), 128))
|
|
1555
1678
|
])
|
|
1556
|
-
], 8,
|
|
1679
|
+
], 8, ki))
|
|
1557
1680
|
], 4),
|
|
1558
|
-
|
|
1681
|
+
z(E).isMarquee.value ? (M(), C("div", {
|
|
1559
1682
|
key: 0,
|
|
1560
1683
|
class: "zm-marquee",
|
|
1561
|
-
style:
|
|
1562
|
-
left:
|
|
1563
|
-
top:
|
|
1564
|
-
width:
|
|
1565
|
-
height:
|
|
1684
|
+
style: ve({
|
|
1685
|
+
left: z(E).marquee.x * z(E).scale.value + z(E).offsetX.value + "px",
|
|
1686
|
+
top: z(E).marquee.y * z(E).scale.value + z(E).offsetY.value + "px",
|
|
1687
|
+
width: z(E).marquee.width * z(E).scale.value + "px",
|
|
1688
|
+
height: z(E).marquee.height * z(E).scale.value + "px"
|
|
1566
1689
|
})
|
|
1567
|
-
}, null, 4)) :
|
|
1568
|
-
|
|
1690
|
+
}, null, 4)) : O("", !0),
|
|
1691
|
+
y("div", {
|
|
1569
1692
|
class: "zm-world",
|
|
1570
|
-
style:
|
|
1571
|
-
transform: `translate(${
|
|
1693
|
+
style: ve({
|
|
1694
|
+
transform: `translate(${z(E).offsetX.value}px, ${z(E).offsetY.value}px) scale(${z(E).scale.value})`
|
|
1572
1695
|
})
|
|
1573
1696
|
}, [
|
|
1574
|
-
(
|
|
1575
|
-
key:
|
|
1576
|
-
class:
|
|
1577
|
-
"is-root":
|
|
1578
|
-
"is-selected": m.value ===
|
|
1579
|
-
"is-editing":
|
|
1580
|
-
"has-image": !!
|
|
1581
|
-
"is-resizing":
|
|
1697
|
+
(M(!0), C(P, null, Ot(tt.value, (l) => (M(), C("div", {
|
|
1698
|
+
key: l.id,
|
|
1699
|
+
class: Ie(["zm-node", {
|
|
1700
|
+
"is-root": l.isRoot,
|
|
1701
|
+
"is-selected": m.value === l.id,
|
|
1702
|
+
"is-editing": c.value === l.id,
|
|
1703
|
+
"has-image": !!l.image,
|
|
1704
|
+
"is-resizing": _t.value === l.id
|
|
1582
1705
|
}]),
|
|
1583
|
-
"data-node-id":
|
|
1584
|
-
style:
|
|
1585
|
-
left:
|
|
1586
|
-
top:
|
|
1587
|
-
minWidth:
|
|
1588
|
-
height:
|
|
1589
|
-
fontSize:
|
|
1590
|
-
background:
|
|
1591
|
-
color:
|
|
1592
|
-
borderColor:
|
|
1593
|
-
fontWeight:
|
|
1706
|
+
"data-node-id": l.id,
|
|
1707
|
+
style: ve({
|
|
1708
|
+
left: l.x + "px",
|
|
1709
|
+
top: l.y + "px",
|
|
1710
|
+
minWidth: l.width + "px",
|
|
1711
|
+
height: l.height + "px",
|
|
1712
|
+
fontSize: l.fontSize + "px",
|
|
1713
|
+
background: sn(l),
|
|
1714
|
+
color: dn(l),
|
|
1715
|
+
borderColor: cn(l),
|
|
1716
|
+
fontWeight: fn(l),
|
|
1594
1717
|
// Center the box on (x, y) with translate(-50%, -50%)
|
|
1595
1718
|
transform: "translate(-50%, -50%)"
|
|
1596
1719
|
}),
|
|
1597
|
-
onClick: (
|
|
1598
|
-
onDblclick: (
|
|
1599
|
-
|
|
1720
|
+
onClick: (g) => wn(g, l),
|
|
1721
|
+
onDblclick: (g) => {
|
|
1722
|
+
g.stopPropagation(), n.readonly || Ae(l.id);
|
|
1600
1723
|
},
|
|
1601
|
-
onContextmenu: (
|
|
1602
|
-
onMouseenter: (
|
|
1603
|
-
onMouseleave: (
|
|
1724
|
+
onContextmenu: (g) => j(g, l),
|
|
1725
|
+
onMouseenter: (g) => tn(l.id),
|
|
1726
|
+
onMouseleave: (g) => nn(l.id)
|
|
1604
1727
|
}, [
|
|
1605
|
-
|
|
1728
|
+
l.image ? (M(), C("img", {
|
|
1606
1729
|
key: 0,
|
|
1607
1730
|
class: "zm-node-img",
|
|
1608
|
-
src:
|
|
1609
|
-
width:
|
|
1610
|
-
height:
|
|
1611
|
-
alt:
|
|
1731
|
+
src: l.image.src,
|
|
1732
|
+
width: l.image.width,
|
|
1733
|
+
height: l.image.height,
|
|
1734
|
+
alt: l.text,
|
|
1612
1735
|
draggable: "false"
|
|
1613
|
-
}, null, 8,
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1736
|
+
}, null, 8, Ei)) : O("", !0),
|
|
1737
|
+
c.value !== l.id ? (M(), C("span", zi, [
|
|
1738
|
+
y("span", Ni, be(l.text), 1),
|
|
1739
|
+
l.link && !c.value ? (M(), C("a", {
|
|
1617
1740
|
key: 0,
|
|
1618
1741
|
class: "zm-node-link",
|
|
1619
|
-
href:
|
|
1742
|
+
href: l.link.url,
|
|
1620
1743
|
target: "_blank",
|
|
1621
1744
|
rel: "noopener noreferrer",
|
|
1622
|
-
title: `打开链接:${
|
|
1623
|
-
onClick: t[0] || (t[0] =
|
|
1745
|
+
title: `打开链接:${l.link.url}`,
|
|
1746
|
+
onClick: t[0] || (t[0] = R(() => {
|
|
1624
1747
|
}, ["stop"])),
|
|
1625
|
-
onMousedown: t[1] || (t[1] =
|
|
1748
|
+
onMousedown: t[1] || (t[1] = R(() => {
|
|
1626
1749
|
}, ["stop"]))
|
|
1627
1750
|
}, [
|
|
1628
|
-
|
|
1751
|
+
F(V, {
|
|
1629
1752
|
name: "link",
|
|
1630
1753
|
size: 11,
|
|
1631
1754
|
stroke: 2
|
|
1632
1755
|
})
|
|
1633
|
-
], 40,
|
|
1634
|
-
|
|
1756
|
+
], 40, Ii)) : O("", !0),
|
|
1757
|
+
l.note && !c.value ? (M(), C("button", {
|
|
1635
1758
|
key: 1,
|
|
1636
1759
|
class: "zm-node-note-btn",
|
|
1637
1760
|
type: "button",
|
|
1638
|
-
title:
|
|
1639
|
-
onClick:
|
|
1640
|
-
onMousedown: t[2] || (t[2] =
|
|
1761
|
+
title: Qt(l.note.text),
|
|
1762
|
+
onClick: R((g) => vt(l.id), ["stop"]),
|
|
1763
|
+
onMousedown: t[2] || (t[2] = R(() => {
|
|
1641
1764
|
}, ["stop"]))
|
|
1642
1765
|
}, [
|
|
1643
|
-
|
|
1766
|
+
F(V, {
|
|
1644
1767
|
name: "note",
|
|
1645
1768
|
size: 11,
|
|
1646
1769
|
stroke: 2
|
|
1647
1770
|
})
|
|
1648
|
-
], 40,
|
|
1649
|
-
])) :
|
|
1771
|
+
], 40, Wi)) : O("", !0)
|
|
1772
|
+
])) : Wn((M(), C("input", {
|
|
1650
1773
|
key: 2,
|
|
1651
1774
|
class: "zm-input",
|
|
1652
|
-
"onUpdate:modelValue": t[3] || (t[3] = (
|
|
1775
|
+
"onUpdate:modelValue": t[3] || (t[3] = (g) => x.value = g),
|
|
1653
1776
|
autofocus: "",
|
|
1654
|
-
onBlur: t[4] || (t[4] = (
|
|
1777
|
+
onBlur: t[4] || (t[4] = (g) => Oe()),
|
|
1655
1778
|
onKeydown: [
|
|
1656
|
-
t[5] || (t[5] =
|
|
1657
|
-
t[6] || (t[6] =
|
|
1658
|
-
t[7] || (t[7] =
|
|
1659
|
-
|
|
1660
|
-
|
|
1779
|
+
t[5] || (t[5] = Ke(R((g) => Oe({ addSibling: "after" }), ["exact"]), ["enter"])),
|
|
1780
|
+
t[6] || (t[6] = Ke(R((g) => Oe({ addSibling: "before" }), ["shift", "prevent", "exact"]), ["enter"])),
|
|
1781
|
+
t[7] || (t[7] = Ke(R((g) => Oe({ addChild: !0 }), ["prevent"]), ["tab"])),
|
|
1782
|
+
Ke(gn, ["esc"]),
|
|
1783
|
+
yn
|
|
1661
1784
|
],
|
|
1662
|
-
onMousedown: t[8] || (t[8] =
|
|
1785
|
+
onMousedown: t[8] || (t[8] = R(() => {
|
|
1663
1786
|
}, ["stop"])),
|
|
1664
|
-
onClick: t[9] || (t[9] =
|
|
1787
|
+
onClick: t[9] || (t[9] = R(() => {
|
|
1665
1788
|
}, ["stop"]))
|
|
1666
1789
|
}, null, 544)), [
|
|
1667
|
-
[
|
|
1790
|
+
[$n, x.value]
|
|
1668
1791
|
]),
|
|
1669
|
-
b.value ? (
|
|
1792
|
+
b.value ? (M(), C("span", {
|
|
1670
1793
|
key: 3,
|
|
1671
1794
|
class: "zm-order-badge",
|
|
1672
|
-
title: `数据顺序:第 ${
|
|
1673
|
-
},
|
|
1674
|
-
|
|
1795
|
+
title: `数据顺序:第 ${Wt(l.id) + 1} 个`
|
|
1796
|
+
}, be(Wt(l.id) + 1), 9, $i)) : O("", !0),
|
|
1797
|
+
It(l.id) && !l.isRoot && ot(l.id) > 0 ? (M(), C("span", {
|
|
1675
1798
|
key: 4,
|
|
1676
|
-
class:
|
|
1677
|
-
style:
|
|
1678
|
-
title: `展开 ${
|
|
1679
|
-
onMousedown: t[10] || (t[10] =
|
|
1799
|
+
class: Ie(["zm-collapse-badge", { "is-on-left": l.side === -1 }]),
|
|
1800
|
+
style: ve({ background: ge.value.get(l.id) ?? "#64748b" }),
|
|
1801
|
+
title: `展开 ${ot(l.id)} 个子节点`,
|
|
1802
|
+
onMousedown: t[10] || (t[10] = R(() => {
|
|
1680
1803
|
}, ["stop"])),
|
|
1681
|
-
onClick:
|
|
1682
|
-
},
|
|
1683
|
-
!n.readonly && !
|
|
1804
|
+
onClick: R((g) => Nt(l.id), ["stop"])
|
|
1805
|
+
}, be(ot(l.id)), 47, Bi)) : O("", !0),
|
|
1806
|
+
!n.readonly && !l.isRoot && Sn(l) && !It(l.id) ? (M(), C("button", {
|
|
1684
1807
|
key: 5,
|
|
1685
|
-
class:
|
|
1686
|
-
style:
|
|
1808
|
+
class: Ie(["zm-btn zm-collapse", { "is-on-left": l.side === -1 }]),
|
|
1809
|
+
style: ve({ color: ge.value.get(l.id) ?? "#64748b", borderColor: ge.value.get(l.id) ?? "#64748b" }),
|
|
1687
1810
|
title: "折叠",
|
|
1688
|
-
onMousedown: t[11] || (t[11] =
|
|
1811
|
+
onMousedown: t[11] || (t[11] = R(() => {
|
|
1689
1812
|
}, ["stop"])),
|
|
1690
|
-
onClick:
|
|
1813
|
+
onClick: R((g) => Nt(l.id), ["stop"])
|
|
1691
1814
|
}, [
|
|
1692
|
-
|
|
1815
|
+
F(V, {
|
|
1693
1816
|
name: "minus",
|
|
1694
1817
|
size: 10,
|
|
1695
1818
|
stroke: 2.4
|
|
1696
1819
|
})
|
|
1697
|
-
], 46,
|
|
1698
|
-
|
|
1820
|
+
], 46, Ri)) : O("", !0),
|
|
1821
|
+
l.image && m.value === l.id && c.value !== l.id ? (M(), C("span", {
|
|
1699
1822
|
key: 6,
|
|
1700
1823
|
class: "zm-img-resize-handle",
|
|
1701
1824
|
title: "拖动调整图片大小",
|
|
1702
|
-
onMousedown:
|
|
1703
|
-
}, null, 40,
|
|
1704
|
-
|
|
1825
|
+
onMousedown: R((g) => en(g, l), ["stop"])
|
|
1826
|
+
}, null, 40, Ai)) : O("", !0),
|
|
1827
|
+
l.image && m.value === l.id && c.value !== l.id ? (M(), C("button", {
|
|
1705
1828
|
key: 7,
|
|
1706
1829
|
class: "zm-img-remove-btn",
|
|
1707
1830
|
title: "移除图片",
|
|
1708
|
-
onMousedown: t[12] || (t[12] =
|
|
1831
|
+
onMousedown: t[12] || (t[12] = R(() => {
|
|
1709
1832
|
}, ["stop"])),
|
|
1710
|
-
onClick:
|
|
1833
|
+
onClick: R((g) => G(l.id), ["stop"])
|
|
1711
1834
|
}, [
|
|
1712
|
-
|
|
1835
|
+
F(V, {
|
|
1713
1836
|
name: "x",
|
|
1714
1837
|
size: 9,
|
|
1715
1838
|
stroke: 2.2
|
|
1716
1839
|
})
|
|
1717
|
-
], 40,
|
|
1718
|
-
], 46,
|
|
1840
|
+
], 40, Li)) : O("", !0)
|
|
1841
|
+
], 46, Si))), 128))
|
|
1719
1842
|
], 4),
|
|
1720
|
-
|
|
1843
|
+
W.value ? (M(), Bn(wi, {
|
|
1721
1844
|
key: 1,
|
|
1722
|
-
x:
|
|
1723
|
-
y:
|
|
1724
|
-
container:
|
|
1725
|
-
"has-image": !!((r =
|
|
1726
|
-
"has-link": !!((
|
|
1727
|
-
"has-note": !!((
|
|
1728
|
-
readonly:
|
|
1729
|
-
onPickImage:
|
|
1730
|
-
onRemoveImage:
|
|
1731
|
-
onSetLink:
|
|
1732
|
-
onRemoveLink:
|
|
1733
|
-
onEditNote:
|
|
1734
|
-
onRemoveNote:
|
|
1735
|
-
onClose:
|
|
1736
|
-
}, null, 8, ["x", "y", "container", "has-image", "has-link", "has-note", "readonly"])) :
|
|
1845
|
+
x: W.value.x,
|
|
1846
|
+
y: W.value.y,
|
|
1847
|
+
container: d.value,
|
|
1848
|
+
"has-image": !!((r = z(B)(u.value, W.value.nodeId)) != null && r.image),
|
|
1849
|
+
"has-link": !!((v = z(B)(u.value, W.value.nodeId)) != null && v.link),
|
|
1850
|
+
"has-note": !!((f = z(B)(u.value, W.value.nodeId)) != null && f.note),
|
|
1851
|
+
readonly: i.readonly,
|
|
1852
|
+
onPickImage: ne,
|
|
1853
|
+
onRemoveImage: Zt,
|
|
1854
|
+
onSetLink: ie,
|
|
1855
|
+
onRemoveLink: ke,
|
|
1856
|
+
onEditNote: Be,
|
|
1857
|
+
onRemoveNote: Me,
|
|
1858
|
+
onClose: _
|
|
1859
|
+
}, null, 8, ["x", "y", "container", "has-image", "has-link", "has-note", "readonly"])) : O("", !0)
|
|
1737
1860
|
], 544),
|
|
1738
|
-
|
|
1739
|
-
|
|
1861
|
+
i.previewMode ? O("", !0) : (M(), C("div", Hi, [
|
|
1862
|
+
y("button", {
|
|
1740
1863
|
class: "zm-tb-btn",
|
|
1741
1864
|
title: "放大",
|
|
1742
1865
|
onClick: t[15] || (t[15] = //@ts-ignore
|
|
1743
|
-
(...
|
|
1866
|
+
(...l) => z(E).zoomIn && z(E).zoomIn(...l))
|
|
1744
1867
|
}, [
|
|
1745
|
-
|
|
1868
|
+
F(V, { name: "zoom-in" })
|
|
1746
1869
|
]),
|
|
1747
|
-
|
|
1870
|
+
y("button", {
|
|
1748
1871
|
class: "zm-tb-btn",
|
|
1749
1872
|
title: "缩小",
|
|
1750
1873
|
onClick: t[16] || (t[16] = //@ts-ignore
|
|
1751
|
-
(...
|
|
1874
|
+
(...l) => z(E).zoomOut && z(E).zoomOut(...l))
|
|
1752
1875
|
}, [
|
|
1753
|
-
|
|
1876
|
+
F(V, { name: "zoom-out" })
|
|
1754
1877
|
]),
|
|
1755
|
-
|
|
1878
|
+
y("button", {
|
|
1756
1879
|
class: "zm-tb-btn",
|
|
1757
1880
|
title: "重置视图",
|
|
1758
1881
|
onClick: se
|
|
1759
1882
|
}, [
|
|
1760
|
-
|
|
1883
|
+
F(V, { name: "reset" })
|
|
1761
1884
|
]),
|
|
1762
|
-
t[22] || (t[22] =
|
|
1763
|
-
n.readonly ?
|
|
1885
|
+
t[22] || (t[22] = y("span", { class: "zm-tb-divider" }, null, -1)),
|
|
1886
|
+
n.readonly ? O("", !0) : (M(), C("button", {
|
|
1764
1887
|
key: 0,
|
|
1765
1888
|
class: "zm-tb-btn",
|
|
1766
1889
|
title: "添加子节点 (Tab)",
|
|
1767
|
-
onClick: t[17] || (t[17] = (
|
|
1890
|
+
onClick: t[17] || (t[17] = (l) => m.value && Ce(m.value))
|
|
1768
1891
|
}, [
|
|
1769
|
-
|
|
1770
|
-
src:
|
|
1892
|
+
y("img", {
|
|
1893
|
+
src: z(Dn),
|
|
1771
1894
|
width: "14",
|
|
1772
1895
|
height: "14",
|
|
1773
1896
|
alt: "添加子节点",
|
|
1774
1897
|
draggable: "false"
|
|
1775
|
-
}, null, 8,
|
|
1898
|
+
}, null, 8, Di)
|
|
1776
1899
|
])),
|
|
1777
|
-
n.readonly ?
|
|
1900
|
+
n.readonly ? O("", !0) : (M(), C("button", {
|
|
1778
1901
|
key: 1,
|
|
1779
1902
|
class: "zm-tb-btn",
|
|
1780
1903
|
title: "添加同级 (Enter)",
|
|
1781
|
-
onClick: t[18] || (t[18] = (
|
|
1904
|
+
onClick: t[18] || (t[18] = (l) => m.value && Fe(m.value))
|
|
1782
1905
|
}, [
|
|
1783
|
-
|
|
1784
|
-
src:
|
|
1906
|
+
y("img", {
|
|
1907
|
+
src: z(Hn),
|
|
1785
1908
|
width: "14",
|
|
1786
1909
|
height: "14",
|
|
1787
1910
|
alt: "添加同级",
|
|
1788
1911
|
draggable: "false"
|
|
1789
|
-
}, null, 8,
|
|
1912
|
+
}, null, 8, Pi)
|
|
1790
1913
|
])),
|
|
1791
|
-
t[23] || (t[23] =
|
|
1792
|
-
|
|
1793
|
-
class:
|
|
1914
|
+
t[23] || (t[23] = y("span", { class: "zm-tb-divider" }, null, -1)),
|
|
1915
|
+
y("button", {
|
|
1916
|
+
class: Ie(["zm-tb-btn", { active: k.layoutMode === "mindmap" }]),
|
|
1794
1917
|
title: "思维导图布局 (中心辐射)",
|
|
1795
|
-
onClick: t[19] || (t[19] = (
|
|
1918
|
+
onClick: t[19] || (t[19] = (l) => lt("mindmap"))
|
|
1796
1919
|
}, [
|
|
1797
|
-
|
|
1920
|
+
F(V, { name: "mindmap" })
|
|
1798
1921
|
], 2),
|
|
1799
|
-
|
|
1800
|
-
class:
|
|
1922
|
+
y("button", {
|
|
1923
|
+
class: Ie(["zm-tb-btn", { active: k.layoutMode === "tree" }]),
|
|
1801
1924
|
title: "树形布局 (向右展开)",
|
|
1802
|
-
onClick: t[20] || (t[20] = (
|
|
1925
|
+
onClick: t[20] || (t[20] = (l) => lt("tree"))
|
|
1803
1926
|
}, [
|
|
1804
|
-
|
|
1927
|
+
F(V, { name: "tree" })
|
|
1805
1928
|
], 2),
|
|
1806
|
-
|
|
1807
|
-
class:
|
|
1929
|
+
y("button", {
|
|
1930
|
+
class: Ie(["zm-tb-btn", { active: k.layoutMode === "org" }]),
|
|
1808
1931
|
title: "组织结构布局 (向下展开)",
|
|
1809
|
-
onClick: t[21] || (t[21] = (
|
|
1932
|
+
onClick: t[21] || (t[21] = (l) => lt("org"))
|
|
1810
1933
|
}, [
|
|
1811
|
-
|
|
1934
|
+
F(V, { name: "org" })
|
|
1812
1935
|
], 2),
|
|
1813
|
-
t[24] || (t[24] =
|
|
1814
|
-
n.readonly ?
|
|
1936
|
+
t[24] || (t[24] = y("span", { class: "zm-tb-divider" }, null, -1)),
|
|
1937
|
+
n.readonly ? O("", !0) : (M(), C("button", {
|
|
1815
1938
|
key: 2,
|
|
1816
1939
|
class: "zm-tb-btn",
|
|
1817
1940
|
title: "导入 JSON",
|
|
1818
|
-
onClick:
|
|
1941
|
+
onClick: zn
|
|
1819
1942
|
}, [
|
|
1820
|
-
|
|
1943
|
+
F(V, { name: "import" })
|
|
1821
1944
|
])),
|
|
1822
|
-
|
|
1945
|
+
y("button", {
|
|
1823
1946
|
class: "zm-tb-btn",
|
|
1824
1947
|
title: "导出 JSON",
|
|
1825
|
-
onClick:
|
|
1948
|
+
onClick: Nn
|
|
1826
1949
|
}, [
|
|
1827
|
-
|
|
1950
|
+
F(V, { name: "export" })
|
|
1828
1951
|
]),
|
|
1829
|
-
|
|
1952
|
+
y("span", Ti, be(Math.round(z(E).scale.value * 100)) + "%", 1)
|
|
1830
1953
|
]))
|
|
1831
1954
|
], 4);
|
|
1832
1955
|
};
|
|
1833
1956
|
}
|
|
1834
|
-
}),
|
|
1957
|
+
}), Vi = {
|
|
1835
1958
|
install(n) {
|
|
1836
|
-
n.component("FlowMindMap",
|
|
1959
|
+
n.component("FlowMindMap", Oi);
|
|
1837
1960
|
}
|
|
1838
1961
|
};
|
|
1839
1962
|
export {
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1963
|
+
Oi as MindMap,
|
|
1964
|
+
ai as addChild,
|
|
1965
|
+
ui as addSibling,
|
|
1966
|
+
he as clone,
|
|
1967
|
+
Vi as default,
|
|
1968
|
+
B as findNode,
|
|
1969
|
+
ae as findParent,
|
|
1970
|
+
Xt as markdownToMindMap,
|
|
1971
|
+
st as mindMapToMarkdown,
|
|
1972
|
+
Gt as removeNode,
|
|
1973
|
+
we as uid
|
|
1849
1974
|
};
|