@billtaofbj/mindmap 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/AutoMove-B6piuV1l.mjs +21 -0
- package/dist/Base-B8xfItDp.mjs +289 -0
- package/dist/Drag-BNJqZaaB.mjs +458 -0
- package/dist/Export-C11gtER2.mjs +307 -0
- package/dist/Formula-rim6V3Ro.mjs +29081 -0
- package/dist/KeyboardNavigation-BznWjRqo.mjs +106 -0
- package/dist/MindMapNode-CKCds6wa.mjs +1865 -0
- package/dist/MiniMap-BtFFvLbR.mjs +98 -0
- package/dist/NodeImgAdjust-CU_ka96q.mjs +138 -0
- package/dist/OuterFrame-D-P0EKq5.mjs +325 -0
- package/dist/Painter-D3byksYq.mjs +42 -0
- package/dist/RainbowLines-CGp8BmNt.mjs +52 -0
- package/dist/Scrollbar-5bObtsl_.mjs +117 -0
- package/dist/Search-1GRF2dmm.mjs +124 -0
- package/dist/Select-CY_n5-r2.mjs +99 -0
- package/dist/Watermark-B-zBgHXG.mjs +88 -0
- package/dist/api-D2rfJWe_.mjs +16 -0
- package/dist/btns-Cf5zZK5X.mjs +9 -0
- package/dist/index.cjs.js +1515 -0
- package/dist/index.es.js +2745 -0
- package/dist/mindmap.css +2 -0
- package/dist/simple-mind-map-DFGmd5vc.mjs +3188 -0
- package/dist/utils-DjW7eJ1w.mjs +4295 -0
- package/package.json +26 -0
|
@@ -0,0 +1,3188 @@
|
|
|
1
|
+
import { $ as e, C as t, Ct as n, D as r, Dt as i, Et as a, F as o, I as s, It as c, J as l, K as u, L as d, M as f, Mt as p, N as m, Nt as h, O as g, Ot as _, P as v, Pt as y, R as ee, S as b, St as x, U as S, V as C, W as te, Y as w, Z as ne, _ as T, b as E, ct as D, d as O, dt as k, ft as A, g as j, gt as M, ht as re, i as ie, jt as ae, k as N, kt as oe, l as se, lt as P, m as ce, mt as le, o as ue, p as de, pt as F, q as fe, r as I, s as pe, st as me, t as L, tt as R, u as he, ut as z, v as B, w as V, wt as H, y as ge, yt as _e, z as U } from "./utils-DjW7eJ1w.mjs";
|
|
2
|
+
import { i as ve, n as ye, r as be } from "./MindMapNode-CKCds6wa.mjs";
|
|
3
|
+
import { t as W } from "./Base-B8xfItDp.mjs";
|
|
4
|
+
//#region ../../node_modules/.pnpm/simple-mind-map@0.14.0-fix.2/node_modules/simple-mind-map/src/core/view/View.js
|
|
5
|
+
var xe = class {
|
|
6
|
+
constructor(e = {}) {
|
|
7
|
+
this.opt = e, this.mindMap = this.opt.mindMap, this.scale = 1, this.sx = 0, this.sy = 0, this.x = 0, this.y = 0, this.firstDrag = !0, this.setTransformData(this.mindMap.opt.viewData), this.bind();
|
|
8
|
+
}
|
|
9
|
+
bind() {
|
|
10
|
+
this.mindMap.keyCommand.addShortcut("Control+=", () => {
|
|
11
|
+
this.enlarge();
|
|
12
|
+
}), this.mindMap.keyCommand.addShortcut("Control+-", () => {
|
|
13
|
+
this.narrow();
|
|
14
|
+
}), this.mindMap.keyCommand.addShortcut("Control+i", () => {
|
|
15
|
+
this.fit();
|
|
16
|
+
}), this.mindMap.event.on("mousedown", (e) => {
|
|
17
|
+
let { isDisableDrag: t, mousedownEventPreventDefault: n } = this.mindMap.opt;
|
|
18
|
+
t || (n && e.preventDefault(), this.sx = this.x, this.sy = this.y);
|
|
19
|
+
}), this.mindMap.event.on("drag", (e, t) => {
|
|
20
|
+
e.ctrlKey || e.metaKey || this.mindMap.opt.isDisableDrag || (this.firstDrag && (this.firstDrag = !1, this.mindMap.renderer.activeNodeList.length > 0 && this.mindMap.execCommand("CLEAR_ACTIVE_NODE")), this.x = this.sx + t.mousemoveOffset.x, this.y = this.sy + t.mousemoveOffset.y, this.transform());
|
|
21
|
+
}), this.mindMap.event.on("mouseup", () => {
|
|
22
|
+
this.firstDrag = !0;
|
|
23
|
+
}), this.mindMap.event.on("mousewheel", (e, t, n, r) => {
|
|
24
|
+
let { customHandleMousewheel: a, mousewheelAction: o, mouseScaleCenterUseMousePosition: s, mousewheelMoveStep: c, mousewheelZoomActionReverse: l, disableMouseWheelZoom: u, translateRatio: d } = this.mindMap.opt;
|
|
25
|
+
if (a && typeof a == "function") return a(e);
|
|
26
|
+
if (o === i.MOUSE_WHEEL_ACTION.ZOOM || e.ctrlKey || e.metaKey) {
|
|
27
|
+
if (u) return;
|
|
28
|
+
let { x: n, y: a } = this.mindMap.toPos(e.clientX, e.clientY), o = s ? n : void 0, c = s ? a : void 0;
|
|
29
|
+
switch (r && (t.includes(i.DIR.LEFT) || t.includes(i.DIR.RIGHT)) && (t = t.filter((e) => ![i.DIR.LEFT, i.DIR.RIGHT].includes(e))), !0) {
|
|
30
|
+
case t.includes(i.DIR.UP || i.DIR.LEFT):
|
|
31
|
+
l ? this.enlarge(o, c, r) : this.narrow(o, c, r);
|
|
32
|
+
break;
|
|
33
|
+
case t.includes(i.DIR.DOWN || i.DIR.RIGHT):
|
|
34
|
+
l ? this.narrow(o, c, r) : this.enlarge(o, c, r);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
let n = 0, a = 0;
|
|
39
|
+
r ? (n = Math.abs(e.wheelDeltaX), a = Math.abs(e.wheelDeltaY)) : n = a = c;
|
|
40
|
+
let o = 0, s = 0;
|
|
41
|
+
t.includes(i.DIR.DOWN) && (s = -a), t.includes(i.DIR.UP) && (s = a), t.includes(i.DIR.LEFT) && (o = n), t.includes(i.DIR.RIGHT) && (o = -n), this.translateXY(o * d, s * d);
|
|
42
|
+
}
|
|
43
|
+
}), this.mindMap.on("resize", () => {
|
|
44
|
+
this.checkNeedMindMapInCanvas() && this.transform();
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
getTransformData() {
|
|
48
|
+
return {
|
|
49
|
+
transform: this.mindMap.draw.transform(),
|
|
50
|
+
state: {
|
|
51
|
+
scale: this.scale,
|
|
52
|
+
x: this.x,
|
|
53
|
+
y: this.y,
|
|
54
|
+
sx: this.sx,
|
|
55
|
+
sy: this.sy
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
setTransformData(e) {
|
|
60
|
+
e && (Object.keys(e.state).forEach((t) => {
|
|
61
|
+
this[t] = e.state[t];
|
|
62
|
+
}), this.mindMap.draw.transform({ ...e.transform }), this.mindMap.emit("view_data_change", this.getTransformData()), this.emitEvent("scale"), this.emitEvent("translate"));
|
|
63
|
+
}
|
|
64
|
+
translateXY(e, t) {
|
|
65
|
+
e === 0 && t === 0 || (this.x += e, this.y += t, this.transform(), this.emitEvent("translate"));
|
|
66
|
+
}
|
|
67
|
+
translateX(e) {
|
|
68
|
+
e !== 0 && (this.x += e, this.transform(), this.emitEvent("translate"));
|
|
69
|
+
}
|
|
70
|
+
translateXTo(e) {
|
|
71
|
+
this.x = e, this.transform(), this.emitEvent("translate");
|
|
72
|
+
}
|
|
73
|
+
translateY(e) {
|
|
74
|
+
e !== 0 && (this.y += e, this.transform(), this.emitEvent("translate"));
|
|
75
|
+
}
|
|
76
|
+
translateYTo(e) {
|
|
77
|
+
this.y = e, this.transform(), this.emitEvent("translate");
|
|
78
|
+
}
|
|
79
|
+
transform() {
|
|
80
|
+
try {
|
|
81
|
+
this.limitMindMapInCanvas();
|
|
82
|
+
} catch {}
|
|
83
|
+
this.mindMap.draw.transform({
|
|
84
|
+
origin: [0, 0],
|
|
85
|
+
scale: this.scale,
|
|
86
|
+
translate: [this.x, this.y]
|
|
87
|
+
}), this.mindMap.emit("view_data_change", this.getTransformData());
|
|
88
|
+
}
|
|
89
|
+
reset() {
|
|
90
|
+
let e = this.scale !== 1, t = this.x !== 0 || this.y !== 0;
|
|
91
|
+
this.scale = 1, this.x = 0, this.y = 0, this.transform(), e && this.emitEvent("scale"), t && this.emitEvent("translate");
|
|
92
|
+
}
|
|
93
|
+
narrow(e, t, n) {
|
|
94
|
+
let { scaleRatio: r, minZoomRatio: i } = this.mindMap.opt;
|
|
95
|
+
r /= n ? 5 : 1;
|
|
96
|
+
let a = Math.max(this.scale - r, i / 100);
|
|
97
|
+
this.scaleInCenter(a, e, t), this.transform(), this.emitEvent("scale");
|
|
98
|
+
}
|
|
99
|
+
enlarge(e, t, n) {
|
|
100
|
+
let { scaleRatio: r, maxZoomRatio: i } = this.mindMap.opt;
|
|
101
|
+
r /= n ? 5 : 1;
|
|
102
|
+
let a = 0;
|
|
103
|
+
a = i === -1 ? this.scale + r : Math.min(this.scale + r, i / 100), this.scaleInCenter(a, e, t), this.transform(), this.emitEvent("scale");
|
|
104
|
+
}
|
|
105
|
+
scaleInCenter(e, t, n) {
|
|
106
|
+
(t === void 0 || n === void 0) && (t = this.mindMap.width / 2, n = this.mindMap.height / 2);
|
|
107
|
+
let r = 1 - e / this.scale, i = (t - this.x) * r, a = (n - this.y) * r;
|
|
108
|
+
this.x += i, this.y += a, this.scale = e;
|
|
109
|
+
}
|
|
110
|
+
setScale(e, t, n) {
|
|
111
|
+
t !== void 0 && n !== void 0 ? this.scaleInCenter(e, t, n) : this.scale = e, this.transform(), this.emitEvent("scale");
|
|
112
|
+
}
|
|
113
|
+
fit(e = () => {}, t = !1, n) {
|
|
114
|
+
n = n === void 0 ? this.mindMap.opt.fitPadding : n;
|
|
115
|
+
let r = this.mindMap.draw, i = r.transform(), a = e() || r.rbox(), o = a.width / i.scaleX, s = a.height / i.scaleY, c = o / s, { width: l, height: u } = this.mindMap.elRect;
|
|
116
|
+
l -= n * 2, u -= n * 2;
|
|
117
|
+
let d = l / u, f = 0, p = "";
|
|
118
|
+
if (o <= l && s <= u && !t) f = 1, p = 1;
|
|
119
|
+
else {
|
|
120
|
+
let e = 0;
|
|
121
|
+
c > d ? (e = l, l / c, p = 2) : (e = u * c, p = 3), f = e / o;
|
|
122
|
+
}
|
|
123
|
+
this.setScale(f);
|
|
124
|
+
let m = e() || r.rbox();
|
|
125
|
+
m.x -= this.mindMap.elRect.left, m.y -= this.mindMap.elRect.top;
|
|
126
|
+
let h = 0, g = 0;
|
|
127
|
+
p === 1 ? (h = -m.x + n + (l - m.width) / 2, g = -m.y + n + (u - m.height) / 2) : p === 2 ? (h = -m.x + n, g = -m.y + n + (u - m.height) / 2) : p === 3 && (h = -m.x + n + (l - m.width) / 2, g = -m.y + n), this.translateXY(h, g);
|
|
128
|
+
}
|
|
129
|
+
checkNeedMindMapInCanvas() {
|
|
130
|
+
if (this.mindMap.demonstrate && this.mindMap.demonstrate.isInDemonstrate) return !1;
|
|
131
|
+
let { isLimitMindMapInCanvasWhenHasScrollbar: e, isLimitMindMapInCanvas: t } = this.mindMap.opt;
|
|
132
|
+
return this.mindMap.scrollbar ? e : t;
|
|
133
|
+
}
|
|
134
|
+
limitMindMapInCanvas() {
|
|
135
|
+
if (!this.checkNeedMindMapInCanvas()) return;
|
|
136
|
+
let { scale: e, left: t, top: n, right: r, bottom: i } = this.getPositionLimit(), a = (this.mindMap.width - this.mindMap.initWidth) / 2 * e, o = (this.mindMap.height - this.mindMap.initHeight) / 2 * e, s = this.scale / e;
|
|
137
|
+
t *= s, r *= s, n *= s, i *= s;
|
|
138
|
+
let c = this.mindMap.width / 2, l = this.mindMap.height / 2, u = this.scale - 1;
|
|
139
|
+
t -= u * c - a, r -= u * c - a, n -= u * l - o, i -= u * l - o, this.x > t && (this.x = t), this.x < r && (this.x = r), this.y > n && (this.y = n), this.y < i && (this.y = i);
|
|
140
|
+
}
|
|
141
|
+
getPositionLimit() {
|
|
142
|
+
let { scaleX: e, scaleY: t } = this.mindMap.draw.transform(), n = this.mindMap.draw.rbox(), r = this.mindMap.renderer.root.group.rbox(), i = this.mindMap.renderer.layout.getRootCenterOffset(r.width, r.height);
|
|
143
|
+
return {
|
|
144
|
+
scale: e,
|
|
145
|
+
left: r.x - n.x - i.x * e,
|
|
146
|
+
right: r.x - n.x2 - i.x * e,
|
|
147
|
+
top: r.y - n.y - i.y * t,
|
|
148
|
+
bottom: r.y - n.y2 - i.y * t
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
emitEvent(e) {
|
|
152
|
+
switch (e) {
|
|
153
|
+
case "scale": this.mindMap.emit("scale", this.scale);
|
|
154
|
+
case "translate": this.mindMap.emit("translate", this.x, this.y);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}, Se = /* @__PURE__ */ c((/* @__PURE__ */ y(((e, t) => {
|
|
158
|
+
var n = Object.prototype.hasOwnProperty, r = "~";
|
|
159
|
+
function i() {}
|
|
160
|
+
Object.create && (i.prototype = Object.create(null), new i().__proto__ || (r = !1));
|
|
161
|
+
function a(e, t, n) {
|
|
162
|
+
this.fn = e, this.context = t, this.once = n || !1;
|
|
163
|
+
}
|
|
164
|
+
function o(e, t, n, i, o) {
|
|
165
|
+
if (typeof n != "function") throw TypeError("The listener must be a function");
|
|
166
|
+
var s = new a(n, i || e, o), c = r ? r + t : t;
|
|
167
|
+
return e._events[c] ? e._events[c].fn ? e._events[c] = [e._events[c], s] : e._events[c].push(s) : (e._events[c] = s, e._eventsCount++), e;
|
|
168
|
+
}
|
|
169
|
+
function s(e, t) {
|
|
170
|
+
--e._eventsCount === 0 ? e._events = new i() : delete e._events[t];
|
|
171
|
+
}
|
|
172
|
+
function c() {
|
|
173
|
+
this._events = new i(), this._eventsCount = 0;
|
|
174
|
+
}
|
|
175
|
+
c.prototype.eventNames = function() {
|
|
176
|
+
var e = [], t, i;
|
|
177
|
+
if (this._eventsCount === 0) return e;
|
|
178
|
+
for (i in t = this._events) n.call(t, i) && e.push(r ? i.slice(1) : i);
|
|
179
|
+
return Object.getOwnPropertySymbols ? e.concat(Object.getOwnPropertySymbols(t)) : e;
|
|
180
|
+
}, c.prototype.listeners = function(e) {
|
|
181
|
+
var t = r ? r + e : e, n = this._events[t];
|
|
182
|
+
if (!n) return [];
|
|
183
|
+
if (n.fn) return [n.fn];
|
|
184
|
+
for (var i = 0, a = n.length, o = Array(a); i < a; i++) o[i] = n[i].fn;
|
|
185
|
+
return o;
|
|
186
|
+
}, c.prototype.listenerCount = function(e) {
|
|
187
|
+
var t = r ? r + e : e, n = this._events[t];
|
|
188
|
+
return n ? n.fn ? 1 : n.length : 0;
|
|
189
|
+
}, c.prototype.emit = function(e, t, n, i, a, o) {
|
|
190
|
+
var s = r ? r + e : e;
|
|
191
|
+
if (!this._events[s]) return !1;
|
|
192
|
+
var c = this._events[s], l = arguments.length, u, d;
|
|
193
|
+
if (c.fn) {
|
|
194
|
+
switch (c.once && this.removeListener(e, c.fn, void 0, !0), l) {
|
|
195
|
+
case 1: return c.fn.call(c.context), !0;
|
|
196
|
+
case 2: return c.fn.call(c.context, t), !0;
|
|
197
|
+
case 3: return c.fn.call(c.context, t, n), !0;
|
|
198
|
+
case 4: return c.fn.call(c.context, t, n, i), !0;
|
|
199
|
+
case 5: return c.fn.call(c.context, t, n, i, a), !0;
|
|
200
|
+
case 6: return c.fn.call(c.context, t, n, i, a, o), !0;
|
|
201
|
+
}
|
|
202
|
+
for (d = 1, u = Array(l - 1); d < l; d++) u[d - 1] = arguments[d];
|
|
203
|
+
c.fn.apply(c.context, u);
|
|
204
|
+
} else {
|
|
205
|
+
var f = c.length, p;
|
|
206
|
+
for (d = 0; d < f; d++) switch (c[d].once && this.removeListener(e, c[d].fn, void 0, !0), l) {
|
|
207
|
+
case 1:
|
|
208
|
+
c[d].fn.call(c[d].context);
|
|
209
|
+
break;
|
|
210
|
+
case 2:
|
|
211
|
+
c[d].fn.call(c[d].context, t);
|
|
212
|
+
break;
|
|
213
|
+
case 3:
|
|
214
|
+
c[d].fn.call(c[d].context, t, n);
|
|
215
|
+
break;
|
|
216
|
+
case 4:
|
|
217
|
+
c[d].fn.call(c[d].context, t, n, i);
|
|
218
|
+
break;
|
|
219
|
+
default:
|
|
220
|
+
if (!u) for (p = 1, u = Array(l - 1); p < l; p++) u[p - 1] = arguments[p];
|
|
221
|
+
c[d].fn.apply(c[d].context, u);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return !0;
|
|
225
|
+
}, c.prototype.on = function(e, t, n) {
|
|
226
|
+
return o(this, e, t, n, !1);
|
|
227
|
+
}, c.prototype.once = function(e, t, n) {
|
|
228
|
+
return o(this, e, t, n, !0);
|
|
229
|
+
}, c.prototype.removeListener = function(e, t, n, i) {
|
|
230
|
+
var a = r ? r + e : e;
|
|
231
|
+
if (!this._events[a]) return this;
|
|
232
|
+
if (!t) return s(this, a), this;
|
|
233
|
+
var o = this._events[a];
|
|
234
|
+
if (o.fn) o.fn === t && (!i || o.once) && (!n || o.context === n) && s(this, a);
|
|
235
|
+
else {
|
|
236
|
+
for (var c = 0, l = [], u = o.length; c < u; c++) (o[c].fn !== t || i && !o[c].once || n && o[c].context !== n) && l.push(o[c]);
|
|
237
|
+
l.length ? this._events[a] = l.length === 1 ? l[0] : l : s(this, a);
|
|
238
|
+
}
|
|
239
|
+
return this;
|
|
240
|
+
}, c.prototype.removeAllListeners = function(e) {
|
|
241
|
+
var t;
|
|
242
|
+
return e ? (t = r ? r + e : e, this._events[t] && s(this, t)) : (this._events = new i(), this._eventsCount = 0), this;
|
|
243
|
+
}, c.prototype.off = c.prototype.removeListener, c.prototype.addListener = c.prototype.on, c.prefixed = r, c.EventEmitter = c, t !== void 0 && (t.exports = c);
|
|
244
|
+
})))()), Ce = class extends Se.default {
|
|
245
|
+
constructor(e = {}) {
|
|
246
|
+
super(), this.opt = e, this.mindMap = e.mindMap, this.isLeftMousedown = !1, this.isRightMousedown = !1, this.isMiddleMousedown = !1, this.mousedownPos = {
|
|
247
|
+
x: 0,
|
|
248
|
+
y: 0
|
|
249
|
+
}, this.mousemovePos = {
|
|
250
|
+
x: 0,
|
|
251
|
+
y: 0
|
|
252
|
+
}, this.mousemoveOffset = {
|
|
253
|
+
x: 0,
|
|
254
|
+
y: 0
|
|
255
|
+
}, this.bindFn(), this.bind();
|
|
256
|
+
}
|
|
257
|
+
bindFn() {
|
|
258
|
+
this.onBodyMousedown = this.onBodyMousedown.bind(this), this.onBodyClick = this.onBodyClick.bind(this), this.onDrawClick = this.onDrawClick.bind(this), this.onMousedown = this.onMousedown.bind(this), this.onMousemove = this.onMousemove.bind(this), this.onMouseup = this.onMouseup.bind(this), this.onNodeMouseup = this.onNodeMouseup.bind(this), this.onMousewheel = this.onMousewheel.bind(this), this.onContextmenu = this.onContextmenu.bind(this), this.onSvgMousedown = this.onSvgMousedown.bind(this), this.onKeyup = this.onKeyup.bind(this), this.onMouseenter = this.onMouseenter.bind(this), this.onMouseleave = this.onMouseleave.bind(this);
|
|
259
|
+
}
|
|
260
|
+
bind() {
|
|
261
|
+
document.body.addEventListener("mousedown", this.onBodyMousedown), document.body.addEventListener("click", this.onBodyClick), this.mindMap.svg.on("click", this.onDrawClick), this.mindMap.el.addEventListener("mousedown", this.onMousedown), this.mindMap.svg.on("mousedown", this.onSvgMousedown), window.addEventListener("mousemove", this.onMousemove), window.addEventListener("mouseup", this.onMouseup), this.on("node_mouseup", this.onNodeMouseup), this.mindMap.el.addEventListener("wheel", this.onMousewheel), this.mindMap.svg.on("contextmenu", this.onContextmenu), this.mindMap.svg.on("mouseenter", this.onMouseenter), this.mindMap.svg.on("mouseleave", this.onMouseleave), window.addEventListener("keyup", this.onKeyup);
|
|
262
|
+
}
|
|
263
|
+
unbind() {
|
|
264
|
+
document.body.removeEventListener("mousedown", this.onBodyMousedown), document.body.removeEventListener("click", this.onBodyClick), this.mindMap.svg.off("click", this.onDrawClick), this.mindMap.el.removeEventListener("mousedown", this.onMousedown), window.removeEventListener("mousemove", this.onMousemove), window.removeEventListener("mouseup", this.onMouseup), this.off("node_mouseup", this.onNodeMouseup), this.mindMap.el.removeEventListener("wheel", this.onMousewheel), this.mindMap.svg.off("contextmenu", this.onContextmenu), this.mindMap.svg.off("mouseenter", this.onMouseenter), this.mindMap.svg.off("mouseleave", this.onMouseleave), window.removeEventListener("keyup", this.onKeyup);
|
|
265
|
+
}
|
|
266
|
+
onDrawClick(e) {
|
|
267
|
+
this.emit("draw_click", e);
|
|
268
|
+
}
|
|
269
|
+
onBodyMousedown(e) {
|
|
270
|
+
this.emit("body_mousedown", e);
|
|
271
|
+
}
|
|
272
|
+
onBodyClick(e) {
|
|
273
|
+
this.emit("body_click", e);
|
|
274
|
+
}
|
|
275
|
+
onSvgMousedown(e) {
|
|
276
|
+
this.emit("svg_mousedown", e);
|
|
277
|
+
}
|
|
278
|
+
onMousedown(e) {
|
|
279
|
+
e.which === 1 ? this.isLeftMousedown = !0 : e.which === 3 ? this.isRightMousedown = !0 : e.which === 2 && (this.isMiddleMousedown = !0), this.mousedownPos.x = e.clientX, this.mousedownPos.y = e.clientY, this.emit("mousedown", e, this);
|
|
280
|
+
}
|
|
281
|
+
onMousemove(e) {
|
|
282
|
+
let { useLeftKeySelectionRightKeyDrag: t } = this.mindMap.opt;
|
|
283
|
+
this.mousemovePos.x = e.clientX, this.mousemovePos.y = e.clientY, this.mousemoveOffset.x = e.clientX - this.mousedownPos.x, this.mousemoveOffset.y = e.clientY - this.mousedownPos.y, this.emit("mousemove", e, this), (this.isMiddleMousedown || (t ? this.isRightMousedown : this.isLeftMousedown)) && (e.preventDefault(), this.emit("drag", e, this));
|
|
284
|
+
}
|
|
285
|
+
onMouseup(e) {
|
|
286
|
+
this.onNodeMouseup(), this.emit("mouseup", e, this);
|
|
287
|
+
}
|
|
288
|
+
onNodeMouseup() {
|
|
289
|
+
this.isLeftMousedown = !1, this.isRightMousedown = !1, this.isMiddleMousedown = !1;
|
|
290
|
+
}
|
|
291
|
+
onMousewheel(e) {
|
|
292
|
+
e.stopPropagation(), e.preventDefault();
|
|
293
|
+
let t = [];
|
|
294
|
+
e.deltaY < 0 && t.push(i.DIR.UP), e.deltaY > 0 && t.push(i.DIR.DOWN), e.deltaX < 0 && t.push(i.DIR.LEFT), e.deltaX > 0 && t.push(i.DIR.RIGHT);
|
|
295
|
+
let n = !1, { customCheckIsTouchPad: r } = this.mindMap.opt;
|
|
296
|
+
n = typeof r == "function" ? r(e) : Math.abs(e.deltaY) <= 10, this.emit("mousewheel", e, t, this, n);
|
|
297
|
+
}
|
|
298
|
+
onContextmenu(e) {
|
|
299
|
+
e.preventDefault(), !e.ctrlKey && this.emit("contextmenu", e);
|
|
300
|
+
}
|
|
301
|
+
onKeyup(e) {
|
|
302
|
+
this.emit("keyup", e);
|
|
303
|
+
}
|
|
304
|
+
onMouseenter(e) {
|
|
305
|
+
this.emit("svg_mouseenter", e);
|
|
306
|
+
}
|
|
307
|
+
onMouseleave(e) {
|
|
308
|
+
this.emit("svg_mouseleave", e);
|
|
309
|
+
}
|
|
310
|
+
}, G = /* @__PURE__ */ c(a()), we = class extends W {
|
|
311
|
+
constructor(e = {}, t) {
|
|
312
|
+
super(e), this.isUseLeft = t === i.LAYOUT.LOGICAL_STRUCTURE_LEFT;
|
|
313
|
+
}
|
|
314
|
+
doLayout(e) {
|
|
315
|
+
I([
|
|
316
|
+
() => {
|
|
317
|
+
this.computedBaseValue();
|
|
318
|
+
},
|
|
319
|
+
() => {
|
|
320
|
+
this.computedTopValue();
|
|
321
|
+
},
|
|
322
|
+
() => {
|
|
323
|
+
this.adjustTopValue();
|
|
324
|
+
},
|
|
325
|
+
() => {
|
|
326
|
+
e(this.root);
|
|
327
|
+
}
|
|
328
|
+
]);
|
|
329
|
+
}
|
|
330
|
+
computedBaseValue() {
|
|
331
|
+
let e = 0;
|
|
332
|
+
F(this.renderer.renderTree, null, (t, n, r, i, a, o) => {
|
|
333
|
+
let s = this.createNode(t, n, r, i, a, o);
|
|
334
|
+
if (s.sortIndex = e, e++, r ? this.setNodeCenter(s) : this.isUseLeft ? s.left = n._node.left - s.width - this.getMarginX(i) : s.left = n._node.left + n._node.width + this.getMarginX(i), !t.data.expand) return !0;
|
|
335
|
+
}, (e, t, n, r) => {
|
|
336
|
+
let i = e.data.expand === !1 ? 0 : e._node.children.length;
|
|
337
|
+
e._node.childrenAreaHeight = i ? e._node.children.reduce((e, t) => e + t.height, 0) + (i + 1) * this.getMarginY(r + 1) : 0;
|
|
338
|
+
let a = e._node.checkHasGeneralization() ? e._node._generalizationNodeHeight + this.getMarginY(r + 1) : 0;
|
|
339
|
+
e._node.childrenAreaHeight2 = Math.max(e._node.childrenAreaHeight, a);
|
|
340
|
+
}, !0, 0);
|
|
341
|
+
}
|
|
342
|
+
computedTopValue() {
|
|
343
|
+
F(this.root, null, (e, t, n, r) => {
|
|
344
|
+
if (e.getData("expand") && e.children && e.children.length) {
|
|
345
|
+
let t = this.getMarginY(r + 1), n = e.top + e.height / 2 - e.childrenAreaHeight / 2 + t;
|
|
346
|
+
e.children.forEach((e) => {
|
|
347
|
+
e.top = n, n += e.height + t;
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}, null, !0);
|
|
351
|
+
}
|
|
352
|
+
adjustTopValue() {
|
|
353
|
+
F(this.root, null, (e, t, n, r) => {
|
|
354
|
+
if (!e.getData("expand")) return;
|
|
355
|
+
let i = e.childrenAreaHeight2 - this.getMarginY(r + 1) * 2 - e.height;
|
|
356
|
+
i > 0 && this.updateBrothers(e, i / 2);
|
|
357
|
+
}, null, !0);
|
|
358
|
+
}
|
|
359
|
+
updateBrothers(e, t) {
|
|
360
|
+
if (e.parent) {
|
|
361
|
+
let n = e.parent.children, r = N(e, n);
|
|
362
|
+
n.forEach((n, i) => {
|
|
363
|
+
if (n.uid === e.uid || n.hasCustomPosition()) return;
|
|
364
|
+
let a = 0;
|
|
365
|
+
i < r ? a = -t : i > r && (a = t), n.top += a, n.children && n.children.length && this.updateChildren(n.children, "top", a);
|
|
366
|
+
}), this.updateBrothers(e.parent, t);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
renderLine(e, t, n, r) {
|
|
370
|
+
r === "curve" ? this.renderLineCurve(e, t, n) : r === "direct" ? this.renderLineDirect(e, t, n) : this.renderLineStraight(e, t, n);
|
|
371
|
+
}
|
|
372
|
+
renderLineStraight(e, t, n) {
|
|
373
|
+
if (e.children.length <= 0) return [];
|
|
374
|
+
let { left: r, top: i, width: a, height: o, expandBtnSize: s } = e, { alwaysShowExpandBtn: c, notShowExpandBtn: l } = this.mindMap.opt;
|
|
375
|
+
(!c || l) && (s = 0);
|
|
376
|
+
let u = (this.getMarginX(e.layerIndex + 1) - s) * .6;
|
|
377
|
+
this.isUseLeft && (u *= -1);
|
|
378
|
+
let d = this.mindMap.themeConfig.nodeUseLineStyle;
|
|
379
|
+
e.children.forEach((c, l) => {
|
|
380
|
+
let f;
|
|
381
|
+
f = this.isUseLeft ? e.layerIndex === 0 ? r : r - s : e.layerIndex === 0 ? r + a : r + a + s;
|
|
382
|
+
let p = i + o / 2, m = this.isUseLeft ? c.left + c.width : c.left, h = c.top + c.height / 2, g = d ? c.width * (this.isUseLeft ? -1 : 1) : 0;
|
|
383
|
+
p = d && !e.isRoot ? p + o / 2 : p, h = d ? h + c.height / 2 : h;
|
|
384
|
+
let _ = this.createFoldLine([
|
|
385
|
+
[f, p],
|
|
386
|
+
[f + u, p],
|
|
387
|
+
[f + u, h],
|
|
388
|
+
[m + g, h]
|
|
389
|
+
]);
|
|
390
|
+
this.setLineStyle(n, t[l], _, c);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
renderLineDirect(e, t, n) {
|
|
394
|
+
if (e.children.length <= 0) return [];
|
|
395
|
+
let { left: r, top: i, width: a, height: o, expandBtnSize: s } = e, { alwaysShowExpandBtn: c, notShowExpandBtn: l } = this.mindMap.opt;
|
|
396
|
+
(!c || l) && (s = 0);
|
|
397
|
+
let { nodeUseLineStyle: u } = this.mindMap.themeConfig;
|
|
398
|
+
e.children.forEach((c, l) => {
|
|
399
|
+
e.layerIndex === 0 && (s = 0);
|
|
400
|
+
let d = this.isUseLeft ? r - s : r + a + s, f = i + o / 2, p = this.isUseLeft ? c.left + c.width : c.left, m = c.top + c.height / 2;
|
|
401
|
+
f = u && !e.isRoot ? f + o / 2 : f, m = u ? m + c.height / 2 : m;
|
|
402
|
+
let h = u ? ` L ${this.isUseLeft ? c.left : c.left + c.width},${m}` : "", g = `M ${d},${f} L ${p},${m}` + h;
|
|
403
|
+
this.setLineStyle(n, t[l], g, c);
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
renderLineCurve(e, t, n) {
|
|
407
|
+
if (e.children.length <= 0) return [];
|
|
408
|
+
let { left: r, top: i, width: a, height: o, expandBtnSize: s } = e, { alwaysShowExpandBtn: c, notShowExpandBtn: l } = this.mindMap.opt;
|
|
409
|
+
(!c || l) && (s = 0);
|
|
410
|
+
let { nodeUseLineStyle: u, rootLineStartPositionKeepSameInCurve: d, rootLineKeepSameInCurve: f } = this.mindMap.themeConfig;
|
|
411
|
+
e.children.forEach((c, l) => {
|
|
412
|
+
e.layerIndex === 0 && (s = 0);
|
|
413
|
+
let p;
|
|
414
|
+
p = this.isUseLeft ? e.layerIndex === 0 && !d ? r + a / 2 : r - s : e.layerIndex === 0 && !d ? r + a / 2 : r + a + s;
|
|
415
|
+
let m = i + o / 2, h = this.isUseLeft ? c.left + c.width : c.left, g = c.top + c.height / 2, _ = "";
|
|
416
|
+
m = u && !e.isRoot ? m + o / 2 : m, g = u ? g + c.height / 2 : g;
|
|
417
|
+
let v;
|
|
418
|
+
v = this.isUseLeft ? u ? ` L ${c.left},${g}` : "" : u ? ` L ${c.left + c.width},${g}` : "", _ = e.isRoot && !f ? this.quadraticCurvePath(p, m, h, g) + v : this.cubicBezierPath(p, m, h, g) + v, this.setLineStyle(n, t[l], _, c);
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
renderExpandBtn(e, t) {
|
|
422
|
+
let { width: n, height: r, expandBtnSize: i, layerIndex: a } = e;
|
|
423
|
+
a === 0 && (i = 0);
|
|
424
|
+
let { translateX: o, translateY: s } = t.transform(), c = this.mindMap.themeConfig.nodeUseLineStyle ? r / 2 : 0, l = this.isUseLeft ? 0 - i : n, u = r / 2 + c;
|
|
425
|
+
l === o && u === s || t.translate(l - o, u - s);
|
|
426
|
+
}
|
|
427
|
+
renderGeneralization(e) {
|
|
428
|
+
e.forEach((e) => {
|
|
429
|
+
let { left: t, top: n, bottom: r, right: i, generalizationLineMargin: a, generalizationNodeMargin: o } = this.getNodeGeneralizationRenderBoundaries(e, "h"), s = this.isUseLeft ? t - a : i + a, c = s, l = n, u = s, d = r, f = `M ${c},${l} Q ${c + (this.isUseLeft ? -20 : 20)},${l + (d - l) / 2} ${u},${d}`;
|
|
430
|
+
e.generalizationLine.plot(f), e.generalizationNode.left = s + (this.isUseLeft ? -o : o) - (this.isUseLeft ? e.generalizationNode.width : 0), e.generalizationNode.top = n + (r - n - e.generalizationNode.height) / 2;
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
renderExpandBtnRect(e, t, n, r) {
|
|
434
|
+
this.isUseLeft ? e.size(t, r).x(-t).y(0) : e.size(t, r).x(n).y(0);
|
|
435
|
+
}
|
|
436
|
+
}, Te = class extends W {
|
|
437
|
+
constructor(e = {}) {
|
|
438
|
+
super(e);
|
|
439
|
+
}
|
|
440
|
+
doLayout(e) {
|
|
441
|
+
I([
|
|
442
|
+
() => {
|
|
443
|
+
this.computedBaseValue();
|
|
444
|
+
},
|
|
445
|
+
() => {
|
|
446
|
+
this.computedTopValue();
|
|
447
|
+
},
|
|
448
|
+
() => {
|
|
449
|
+
this.adjustTopValue();
|
|
450
|
+
},
|
|
451
|
+
() => {
|
|
452
|
+
e(this.root);
|
|
453
|
+
}
|
|
454
|
+
]);
|
|
455
|
+
}
|
|
456
|
+
computedBaseValue() {
|
|
457
|
+
F(this.renderer.renderTree, null, (e, t, n, r, a, o) => {
|
|
458
|
+
let s = this.createNode(e, t, n, r, a, o);
|
|
459
|
+
if (n ? this.setNodeCenter(s) : (t._node.dir ? s.dir = t._node.dir : s.dir = s.getData("dir") || (a % 2 == 0 ? i.LAYOUT_GROW_DIR.RIGHT : i.LAYOUT_GROW_DIR.LEFT), s.left = s.dir === i.LAYOUT_GROW_DIR.RIGHT ? t._node.left + t._node.width + this.getMarginX(r) : t._node.left - this.getMarginX(r) - s.width), !e.data.expand) return !0;
|
|
460
|
+
}, (e, t, n, r) => {
|
|
461
|
+
if (!e.data.expand) {
|
|
462
|
+
e._node.leftChildrenAreaHeight = 0, e._node.rightChildrenAreaHeight = 0;
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
let a = 0, o = 0, s = 0, c = 0;
|
|
466
|
+
e._node.children.forEach((e) => {
|
|
467
|
+
e.dir === i.LAYOUT_GROW_DIR.LEFT ? (a++, s += e.height) : (o++, c += e.height);
|
|
468
|
+
}), e._node.leftChildrenAreaHeight = s + (a + 1) * this.getMarginY(r + 1), e._node.rightChildrenAreaHeight = c + (o + 1) * this.getMarginY(r + 1);
|
|
469
|
+
let l = e._node.checkHasGeneralization() ? e._node._generalizationNodeHeight + this.getMarginY(r + 1) : 0;
|
|
470
|
+
e._node.leftChildrenAreaHeight2 = Math.max(e._node.leftChildrenAreaHeight, l), e._node.rightChildrenAreaHeight2 = Math.max(e._node.rightChildrenAreaHeight, l);
|
|
471
|
+
}, !0, 0);
|
|
472
|
+
}
|
|
473
|
+
computedTopValue() {
|
|
474
|
+
F(this.root, null, (e, t, n, r) => {
|
|
475
|
+
if (e.getData("expand") && e.children && e.children.length) {
|
|
476
|
+
let t = this.getMarginY(r + 1), n = e.top + e.height / 2 + t, a = n - e.leftChildrenAreaHeight / 2, o = n - e.rightChildrenAreaHeight / 2;
|
|
477
|
+
e.children.forEach((e) => {
|
|
478
|
+
e.dir === i.LAYOUT_GROW_DIR.LEFT ? (e.top = a, a += e.height + t) : (e.top = o, o += e.height + t);
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
}, null, !0);
|
|
482
|
+
}
|
|
483
|
+
adjustTopValue() {
|
|
484
|
+
F(this.root, null, (e, t, n, r) => {
|
|
485
|
+
if (!e.getData("expand")) return;
|
|
486
|
+
let i = this.getMarginY(r + 1) * 2 + e.height, a = e.leftChildrenAreaHeight2 - i, o = e.rightChildrenAreaHeight2 - i;
|
|
487
|
+
(a > 0 || o > 0) && this.updateBrothers(e, a / 2, o / 2);
|
|
488
|
+
}, null, !0);
|
|
489
|
+
}
|
|
490
|
+
updateBrothers(e, t, n) {
|
|
491
|
+
if (e.parent) {
|
|
492
|
+
let r = e.parent.children.filter((t) => t.dir === e.dir), a = N(e, r);
|
|
493
|
+
r.forEach((e, r) => {
|
|
494
|
+
if (e.hasCustomPosition()) return;
|
|
495
|
+
let o = 0, s = e.dir === i.LAYOUT_GROW_DIR.LEFT ? t : n;
|
|
496
|
+
r < a ? o = -s : r > a && (o = s), e.top += o, e.children && e.children.length && this.updateChildren(e.children, "top", o);
|
|
497
|
+
}), this.updateBrothers(e.parent, t, n);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
renderLine(e, t, n, r) {
|
|
501
|
+
r === "curve" ? this.renderLineCurve(e, t, n) : r === "direct" ? this.renderLineDirect(e, t, n) : this.renderLineStraight(e, t, n);
|
|
502
|
+
}
|
|
503
|
+
renderLineStraight(e, t, n) {
|
|
504
|
+
if (e.children.length <= 0) return [];
|
|
505
|
+
let { left: r, top: a, width: o, height: s, expandBtnSize: c } = e, { alwaysShowExpandBtn: l, notShowExpandBtn: u } = this.mindMap.opt;
|
|
506
|
+
(!l || u) && (c = 0);
|
|
507
|
+
let d = (this.getMarginX(e.layerIndex + 1) - c) * .6, f = this.mindMap.themeConfig.nodeUseLineStyle;
|
|
508
|
+
e.children.forEach((l, u) => {
|
|
509
|
+
let p = 0, m = 0, h = f ? l.width : 0;
|
|
510
|
+
l.dir === i.LAYOUT_GROW_DIR.LEFT ? (m = -d, p = e.layerIndex === 0 ? r : r - c, h = -h) : (m = d, p = e.layerIndex === 0 ? r + o : r + o + c);
|
|
511
|
+
let g = a + s / 2, _ = l.dir === i.LAYOUT_GROW_DIR.LEFT ? l.left + l.width : l.left, v = l.top + l.height / 2;
|
|
512
|
+
g = f && !e.isRoot ? g + s / 2 : g, v = f ? v + l.height / 2 : v;
|
|
513
|
+
let y = this.createFoldLine([
|
|
514
|
+
[p, g],
|
|
515
|
+
[p + m, g],
|
|
516
|
+
[p + m, v],
|
|
517
|
+
[_ + h, v]
|
|
518
|
+
]);
|
|
519
|
+
this.setLineStyle(n, t[u], y, l);
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
renderLineDirect(e, t, n) {
|
|
523
|
+
if (e.children.length <= 0) return [];
|
|
524
|
+
let { left: r, top: a, width: o, height: s, expandBtnSize: c } = e, { alwaysShowExpandBtn: l, notShowExpandBtn: u } = this.mindMap.opt;
|
|
525
|
+
(!l || u) && (c = 0);
|
|
526
|
+
let { nodeUseLineStyle: d } = this.mindMap.themeConfig;
|
|
527
|
+
e.children.forEach((l, u) => {
|
|
528
|
+
e.layerIndex === 0 && (c = 0);
|
|
529
|
+
let f = l.dir === i.LAYOUT_GROW_DIR.LEFT ? r - c : r + o + c, p = a + s / 2, m = l.dir === i.LAYOUT_GROW_DIR.LEFT ? l.left + l.width : l.left, h = l.top + l.height / 2;
|
|
530
|
+
p = d && !e.isRoot ? p + s / 2 : p, h = d ? h + l.height / 2 : h;
|
|
531
|
+
let g = "";
|
|
532
|
+
d && (g = l.dir === i.LAYOUT_GROW_DIR.LEFT ? ` L ${l.left},${h}` : ` L ${l.left + l.width},${h}`);
|
|
533
|
+
let _ = `M ${f},${p} L ${m},${h}` + g;
|
|
534
|
+
this.setLineStyle(n, t[u], _, l);
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
renderLineCurve(e, t, n) {
|
|
538
|
+
if (e.children.length <= 0) return [];
|
|
539
|
+
let { left: r, top: a, width: o, height: s, expandBtnSize: c } = e, { alwaysShowExpandBtn: l, notShowExpandBtn: u } = this.mindMap.opt;
|
|
540
|
+
(!l || u) && (c = 0);
|
|
541
|
+
let { nodeUseLineStyle: d, rootLineKeepSameInCurve: f, rootLineStartPositionKeepSameInCurve: p } = this.mindMap.themeConfig;
|
|
542
|
+
e.children.forEach((l, u) => {
|
|
543
|
+
e.layerIndex === 0 && (c = 0);
|
|
544
|
+
let m = e.layerIndex === 0 && !p ? r + o / 2 : l.dir === i.LAYOUT_GROW_DIR.LEFT ? r - c : r + o + c, h = a + s / 2, g = l.dir === i.LAYOUT_GROW_DIR.LEFT ? l.left + l.width : l.left, _ = l.top + l.height / 2, v = "";
|
|
545
|
+
h = d && !e.isRoot ? h + s / 2 : h, _ = d ? _ + l.height / 2 : _;
|
|
546
|
+
let y = "";
|
|
547
|
+
d && (y = l.dir === i.LAYOUT_GROW_DIR.LEFT ? ` L ${l.left},${_}` : ` L ${l.left + l.width},${_}`), v = e.isRoot && !f ? this.quadraticCurvePath(m, h, g, _) + y : this.cubicBezierPath(m, h, g, _) + y, this.setLineStyle(n, t[u], v, l);
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
renderExpandBtn(e, t) {
|
|
551
|
+
let { width: n, height: r, expandBtnSize: a } = e, { translateX: o, translateY: s } = t.transform(), c = this.mindMap.themeConfig.nodeUseLineStyle ? r / 2 : 0, l = e.dir === i.LAYOUT_GROW_DIR.LEFT ? 0 - a : n, u = r / 2 + c;
|
|
552
|
+
if (l === o && u === s) return;
|
|
553
|
+
let d = l - o, f = u - s;
|
|
554
|
+
t.translate(d, f);
|
|
555
|
+
}
|
|
556
|
+
renderGeneralization(e) {
|
|
557
|
+
e.forEach((e) => {
|
|
558
|
+
let t = e.node.dir === i.LAYOUT_GROW_DIR.LEFT, { top: n, bottom: r, left: a, right: o, generalizationLineMargin: s, generalizationNodeMargin: c } = this.getNodeGeneralizationRenderBoundaries(e, "h"), l = t ? a - s : o + s, u = l, d = n, f = l, p = r, m = `M ${u},${d} Q ${u + (t ? -20 : 20)},${d + (p - d) / 2} ${f},${p}`;
|
|
559
|
+
e.generalizationLine.plot(m), e.generalizationNode.left = l + (t ? -c : c) - (t ? e.generalizationNode.width : 0), e.generalizationNode.top = n + (r - n - e.generalizationNode.height) / 2;
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
renderExpandBtnRect(e, t, n, r, a) {
|
|
563
|
+
a.dir === i.LAYOUT_GROW_DIR.LEFT ? e.size(t, r).x(-t).y(0) : e.size(t, r).x(n).y(0);
|
|
564
|
+
}
|
|
565
|
+
}, Ee = class extends W {
|
|
566
|
+
constructor(e = {}) {
|
|
567
|
+
super(e);
|
|
568
|
+
}
|
|
569
|
+
doLayout(e) {
|
|
570
|
+
I([
|
|
571
|
+
() => {
|
|
572
|
+
this.computedBaseValue();
|
|
573
|
+
},
|
|
574
|
+
() => {
|
|
575
|
+
this.computedLeftTopValue();
|
|
576
|
+
},
|
|
577
|
+
() => {
|
|
578
|
+
this.adjustLeftTopValue();
|
|
579
|
+
},
|
|
580
|
+
() => {
|
|
581
|
+
e(this.root);
|
|
582
|
+
}
|
|
583
|
+
]);
|
|
584
|
+
}
|
|
585
|
+
computedBaseValue() {
|
|
586
|
+
F(this.renderer.renderTree, null, (e, t, n, r, i, a) => {
|
|
587
|
+
let o = this.createNode(e, t, n, r, i, a);
|
|
588
|
+
if (n ? this.setNodeCenter(o) : t._node.isRoot && (o.top = t._node.top + t._node.height + this.getMarginX(r)), !e.data.expand) return !0;
|
|
589
|
+
}, (e, t, n, r) => {
|
|
590
|
+
if (n) {
|
|
591
|
+
let t = e.data.expand === !1 ? 0 : e._node.children.length;
|
|
592
|
+
e._node.childrenAreaWidth = t ? e._node.children.reduce((e, t) => e + t.width, 0) + (t + 1) * this.getMarginX(r + 1) : 0;
|
|
593
|
+
}
|
|
594
|
+
}, !0, 0);
|
|
595
|
+
}
|
|
596
|
+
computedLeftTopValue() {
|
|
597
|
+
F(this.root, null, (e, t, n, r) => {
|
|
598
|
+
if (e.getData("expand") && e.children && e.children.length) {
|
|
599
|
+
let t = this.getMarginX(r + 1), i = this.getMarginY(r + 1);
|
|
600
|
+
if (n) {
|
|
601
|
+
let n = e.left + e.width / 2 - e.childrenAreaWidth / 2 + t;
|
|
602
|
+
e.children.forEach((e) => {
|
|
603
|
+
e.left = n, n += e.width + t;
|
|
604
|
+
});
|
|
605
|
+
} else {
|
|
606
|
+
let t = e.top + this.getNodeHeightWithGeneralization(e) + i + (this.getNodeActChildrenLength(e) > 0 ? e.expandBtnSize : 0);
|
|
607
|
+
e.children.forEach((n) => {
|
|
608
|
+
n.left = e.left + e.width * .5, n.top = t, t += this.getNodeHeightWithGeneralization(n) + i + (this.getNodeActChildrenLength(n) > 0 ? n.expandBtnSize : 0);
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}, null, !0);
|
|
613
|
+
}
|
|
614
|
+
adjustLeftTopValue() {
|
|
615
|
+
F(this.root, null, (e, t, n, r) => {
|
|
616
|
+
if (!e.getData("expand")) return;
|
|
617
|
+
if (t && t.isRoot) {
|
|
618
|
+
let t = this.getNodeAreaWidth(e, !0) - e.width;
|
|
619
|
+
t > 0 && this.updateBrothersLeft(e, t);
|
|
620
|
+
}
|
|
621
|
+
let i = e.children.length;
|
|
622
|
+
if (t && !t.isRoot && i > 0) {
|
|
623
|
+
let t = this.getMarginY(r + 1), n = e.children.reduce((e, t) => e + this.getNodeHeightWithGeneralization(t) + (this.getNodeActChildrenLength(t) > 0 ? t.expandBtnSize : 0), 0) + i * t;
|
|
624
|
+
this.updateBrothersTop(e, n);
|
|
625
|
+
}
|
|
626
|
+
}, (e, t, n) => {
|
|
627
|
+
if (n) {
|
|
628
|
+
let { right: t, left: n } = this.getNodeBoundaries(e, "h"), r = t - n, i = e.left - n - (r - e.width) / 2;
|
|
629
|
+
this.updateChildren(e.children, "left", i);
|
|
630
|
+
}
|
|
631
|
+
}, !0);
|
|
632
|
+
}
|
|
633
|
+
updateBrothersLeft(e, t) {
|
|
634
|
+
if (e.parent) {
|
|
635
|
+
let n = e.parent.children, r = N(e, n);
|
|
636
|
+
n.forEach((e, n) => {
|
|
637
|
+
e.hasCustomPosition() || n <= r || (e.left += t, e.children && e.children.length && this.updateChildren(e.children, "left", t));
|
|
638
|
+
}), this.updateBrothersLeft(e.parent, t);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
updateBrothersTop(e, t) {
|
|
642
|
+
if (e.parent && !e.parent.isRoot) {
|
|
643
|
+
let n = e.parent.children, r = N(e, n);
|
|
644
|
+
n.forEach((e, n) => {
|
|
645
|
+
if (e.hasCustomPosition()) return;
|
|
646
|
+
let i = 0;
|
|
647
|
+
n > r && (i = t), e.top += i, e.children && e.children.length && this.updateChildren(e.children, "top", i);
|
|
648
|
+
}), this.updateBrothersTop(e.parent, t);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
renderLine(e, t, n) {
|
|
652
|
+
if (e.children.length <= 0) return [];
|
|
653
|
+
let { left: r, top: i, width: a, height: o, expandBtnSize: s } = e, { alwaysShowExpandBtn: c, notShowExpandBtn: l } = this.mindMap.opt;
|
|
654
|
+
(!c || l) && (s = 0);
|
|
655
|
+
let u = e.children.length, d = this.getMarginX(e.layerIndex + 1);
|
|
656
|
+
if (e.isRoot) {
|
|
657
|
+
let s = r + a / 2, c = i + o, l = d * .7, f = Infinity, p = -Infinity;
|
|
658
|
+
e.children.forEach((e, r) => {
|
|
659
|
+
let i = e.left + e.width / 2, a = e.top;
|
|
660
|
+
i < f && (f = i), i > p && (p = i);
|
|
661
|
+
let o = this.mindMap.themeConfig.nodeUseLineStyle ? ` L ${e.left},${a} L ${e.left + e.width},${a}` : "", s = `M ${i},${c + l} L ${i},${c + l > a ? a + e.height : a}` + o;
|
|
662
|
+
this.setLineStyle(n, t[r], s, e);
|
|
663
|
+
}), f = Math.min(f, s), p = Math.max(p, s);
|
|
664
|
+
let m = this.lineDraw.path();
|
|
665
|
+
if (e.style.line(m), m.plot(this.transformPath(`M ${s},${c} L ${s},${c + l}`)), e._lines.push(m), n && n(m, e), u > 0) {
|
|
666
|
+
let t = this.lineDraw.path();
|
|
667
|
+
e.style.line(t), t.plot(this.transformPath(`M ${f},${c + l} L ${p},${c + l}`)), e._lines.push(t), n && n(t, e);
|
|
668
|
+
}
|
|
669
|
+
} else {
|
|
670
|
+
let r = i + o, a = -Infinity, c = e.left + e.width * .3;
|
|
671
|
+
if (e.children.forEach((o, s) => {
|
|
672
|
+
let l = o.top + o.height / 2;
|
|
673
|
+
l > a && (a = l);
|
|
674
|
+
let u = "", d = o.left, f = o.left + o.width < c, p = !1;
|
|
675
|
+
f ? d = o.left + o.width : o.left < c && o.left + o.width > c && (p = !0, l = o.top, a = l), l > i && l < r ? u = `M ${f ? e.left : e.left + e.width},${l} L ${d},${l}` : l < r ? (p && (l = o.top + o.height, d = c), u = `M ${c},${i} L ${c},${l} L ${d},${l}`) : (p && (d = c), u = `M ${c},${l} L ${d},${l}`);
|
|
676
|
+
let m = this.mindMap.themeConfig.nodeUseLineStyle ? ` L ${d},${l - o.height / 2} L ${d},${l + o.height / 2}` : "";
|
|
677
|
+
u += m, this.setLineStyle(n, t[s], u, o);
|
|
678
|
+
}), u > 0) {
|
|
679
|
+
let t = this.lineDraw.path();
|
|
680
|
+
s = u > 0 ? s : 0, e.style.line(t), a < r + s ? t.hide() : (t.plot(this.transformPath(`M ${c},${r + s} L ${c},${a}`)), t.show()), e._lines.push(t), n && n(t, e);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
renderExpandBtn(e, t) {
|
|
685
|
+
let { width: n, height: r, expandBtnSize: i, isRoot: a } = e;
|
|
686
|
+
if (!a) {
|
|
687
|
+
let { translateX: e, translateY: a } = t.transform();
|
|
688
|
+
t.translate(n * .3 - i / 2 - e, r + i / 2 - a);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
renderGeneralization(e) {
|
|
692
|
+
e.forEach((e) => {
|
|
693
|
+
let { top: t, bottom: n, right: r, generalizationLineMargin: i, generalizationNodeMargin: a } = this.getNodeGeneralizationRenderBoundaries(e, "h"), o = r + i, s = t, c = r + i, l = n, u = `M ${o},${s} Q ${o + 20},${s + (l - s) / 2} ${c},${l}`;
|
|
694
|
+
e.generalizationLine.plot(this.transformPath(u)), e.generalizationNode.left = r + a, e.generalizationNode.top = t + (n - t - e.generalizationNode.height) / 2;
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
renderExpandBtnRect(e, t, n, r, i) {
|
|
698
|
+
e.size(n, t).x(0).y(r);
|
|
699
|
+
}
|
|
700
|
+
}, De = class extends W {
|
|
701
|
+
constructor(e = {}) {
|
|
702
|
+
super(e);
|
|
703
|
+
}
|
|
704
|
+
doLayout(e) {
|
|
705
|
+
I([
|
|
706
|
+
() => {
|
|
707
|
+
this.computedBaseValue();
|
|
708
|
+
},
|
|
709
|
+
() => {
|
|
710
|
+
this.computedLeftValue();
|
|
711
|
+
},
|
|
712
|
+
() => {
|
|
713
|
+
this.adjustLeftValue();
|
|
714
|
+
},
|
|
715
|
+
() => {
|
|
716
|
+
e(this.root);
|
|
717
|
+
}
|
|
718
|
+
]);
|
|
719
|
+
}
|
|
720
|
+
computedBaseValue() {
|
|
721
|
+
F(this.renderer.renderTree, null, (e, t, n, r, i, a) => {
|
|
722
|
+
let o = this.createNode(e, t, n, r, i, a);
|
|
723
|
+
if (n ? this.setNodeCenter(o) : o.top = t._node.top + t._node.height + this.getMarginX(r), !e.data.expand) return !0;
|
|
724
|
+
}, (e, t, n, r) => {
|
|
725
|
+
let i = e.data.expand === !1 ? 0 : e._node.children.length;
|
|
726
|
+
e._node.childrenAreaWidth = i ? e._node.children.reduce((e, t) => e + t.width, 0) + (i + 1) * this.getMarginY(r + 1) : 0;
|
|
727
|
+
let a = e._node.checkHasGeneralization() ? e._node._generalizationNodeWidth + this.getMarginY(r + 1) : 0;
|
|
728
|
+
e._node.childrenAreaWidth2 = Math.max(e._node.childrenAreaWidth, a);
|
|
729
|
+
}, !0, 0);
|
|
730
|
+
}
|
|
731
|
+
computedLeftValue() {
|
|
732
|
+
F(this.root, null, (e, t, n, r) => {
|
|
733
|
+
if (e.getData("expand") && e.children && e.children.length) {
|
|
734
|
+
let t = this.getMarginY(r + 1), n = e.left + e.width / 2 - e.childrenAreaWidth / 2 + t;
|
|
735
|
+
e.children.forEach((e) => {
|
|
736
|
+
e.left = n, n += e.width + t;
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
}, null, !0);
|
|
740
|
+
}
|
|
741
|
+
adjustLeftValue() {
|
|
742
|
+
F(this.root, null, (e, t, n, r) => {
|
|
743
|
+
if (!e.getData("expand")) return;
|
|
744
|
+
let i = e.childrenAreaWidth2 - this.getMarginY(r + 1) * 2 - e.width;
|
|
745
|
+
i > 0 && this.updateBrothers(e, i / 2);
|
|
746
|
+
}, null, !0);
|
|
747
|
+
}
|
|
748
|
+
updateBrothers(e, t) {
|
|
749
|
+
if (e.parent) {
|
|
750
|
+
let n = e.parent.children, r = N(e, n);
|
|
751
|
+
n.forEach((e, n) => {
|
|
752
|
+
if (e.hasCustomPosition()) return;
|
|
753
|
+
let i = 0;
|
|
754
|
+
n < r ? i = -t : n > r && (i = t), e.left += i, e.children && e.children.length && this.updateChildren(e.children, "left", i);
|
|
755
|
+
}), this.updateBrothers(e.parent, t);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
renderLine(e, t, n, r) {
|
|
759
|
+
r === "curve" ? this.renderLineCurve(e, t, n) : r === "direct" ? this.renderLineDirect(e, t, n) : this.renderLineStraight(e, t, n);
|
|
760
|
+
}
|
|
761
|
+
renderLineCurve(e, t, n) {
|
|
762
|
+
if (e.children.length <= 0) return [];
|
|
763
|
+
let { left: r, top: i, width: a, height: o, expandBtnSize: s } = e, { alwaysShowExpandBtn: c, notShowExpandBtn: l } = this.mindMap.opt;
|
|
764
|
+
(!c || l) && (s = 0);
|
|
765
|
+
let { nodeUseLineStyle: u, rootLineStartPositionKeepSameInCurve: d, rootLineKeepSameInCurve: f } = this.mindMap.themeConfig;
|
|
766
|
+
e.children.forEach((c, l) => {
|
|
767
|
+
e.layerIndex === 0 && (s = 0);
|
|
768
|
+
let p = r + a / 2, m = e.layerIndex === 0 && !d ? i + o / 2 : i + o + s, h = c.left + c.width / 2, g = c.top, _ = "", v = u ? ` L ${c.left},${g} L ${c.left + c.width},${g}` : "";
|
|
769
|
+
_ = e.isRoot && !f ? this.quadraticCurvePath(p, m, h, g, !0) + v : this.cubicBezierPath(p, m, h, g, !0) + v, this.setLineStyle(n, t[l], _, c);
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
renderLineDirect(e, t, n) {
|
|
773
|
+
if (e.children.length <= 0) return [];
|
|
774
|
+
let { left: r, top: i, width: a, height: o } = e, { nodeUseLineStyle: s } = this.mindMap.themeConfig, c = r + a / 2, l = i + o;
|
|
775
|
+
e.children.forEach((e, r) => {
|
|
776
|
+
let i = e.left + e.width / 2, a = e.top, o = s ? ` L ${e.left},${a} L ${e.left + e.width},${a}` : "", u = `M ${c},${l} L ${i},${a}` + o;
|
|
777
|
+
this.setLineStyle(n, t[r], u, e);
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
renderLineStraight(e, t, n) {
|
|
781
|
+
if (e.children.length <= 0) return [];
|
|
782
|
+
let { left: r, top: i, width: a, height: o, expandBtnSize: s, isRoot: c } = e, { alwaysShowExpandBtn: l, notShowExpandBtn: u } = this.mindMap.opt;
|
|
783
|
+
(!l || u) && (s = 0);
|
|
784
|
+
let d = r + a / 2, f = i + o, p = this.getMarginX(e.layerIndex + 1) * .7, m = Infinity, h = -Infinity, g = e.children.length;
|
|
785
|
+
e.children.forEach((e, r) => {
|
|
786
|
+
let i = e.left + e.width / 2, a = f + p > e.top ? e.top + e.height : e.top;
|
|
787
|
+
i < m && (m = i), i > h && (h = i);
|
|
788
|
+
let o = this.mindMap.themeConfig.nodeUseLineStyle ? ` L ${e.left},${a} L ${e.left + e.width},${a}` : "", s = `M ${i},${f + p} L ${i},${a}` + o;
|
|
789
|
+
this.setLineStyle(n, t[r], s, e);
|
|
790
|
+
}), m = Math.min(d, m), h = Math.max(d, h);
|
|
791
|
+
let _ = this.lineDraw.path();
|
|
792
|
+
if (e.style.line(_), s = g > 0 && !c ? s : 0, _.plot(this.transformPath(`M ${d},${f + s} L ${d},${f + p}`)), e._lines.push(_), n && n(_, e), g > 0) {
|
|
793
|
+
let t = this.lineDraw.path();
|
|
794
|
+
e.style.line(t), t.plot(this.transformPath(`M ${m},${f + p} L ${h},${f + p}`)), e._lines.push(t), n && n(t, e);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
renderExpandBtn(e, t) {
|
|
798
|
+
let { width: n, height: r, expandBtnSize: i } = e, { translateX: a, translateY: o } = t.transform();
|
|
799
|
+
t.translate(n / 2 - i / 2 - a, r + i / 2 - o);
|
|
800
|
+
}
|
|
801
|
+
renderGeneralization(e) {
|
|
802
|
+
e.forEach((e) => {
|
|
803
|
+
let { bottom: t, left: n, right: r, generalizationLineMargin: i, generalizationNodeMargin: a } = this.getNodeGeneralizationRenderBoundaries(e, "v"), o = n, s = t + i, c = r, l = t + i, u = `M ${o},${s} Q ${o + (c - o) / 2},${s + 20} ${c},${l}`;
|
|
804
|
+
e.generalizationLine.plot(this.transformPath(u)), e.generalizationNode.top = t + a, e.generalizationNode.left = n + (r - n - e.generalizationNode.width) / 2;
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
renderExpandBtnRect(e, t, n, r, i) {
|
|
808
|
+
e.size(n, t).x(0).y(r);
|
|
809
|
+
}
|
|
810
|
+
}, Oe = class extends W {
|
|
811
|
+
constructor(e = {}, t) {
|
|
812
|
+
super(e), this.layout = t;
|
|
813
|
+
}
|
|
814
|
+
doLayout(e) {
|
|
815
|
+
I([
|
|
816
|
+
() => {
|
|
817
|
+
this.computedBaseValue();
|
|
818
|
+
},
|
|
819
|
+
() => {
|
|
820
|
+
this.computedLeftTopValue();
|
|
821
|
+
},
|
|
822
|
+
() => {
|
|
823
|
+
this.adjustLeftTopValue();
|
|
824
|
+
},
|
|
825
|
+
() => {
|
|
826
|
+
e(this.root);
|
|
827
|
+
}
|
|
828
|
+
]);
|
|
829
|
+
}
|
|
830
|
+
computedBaseValue() {
|
|
831
|
+
F(this.renderer.renderTree, null, (e, t, n, r, a, o) => {
|
|
832
|
+
let s = this.createNode(e, t, n, r, a, o);
|
|
833
|
+
if (n ? this.setNodeCenter(s) : (this.layout === i.LAYOUT.TIMELINE2 ? t._node.dir ? s.dir = t._node.dir : s.dir = a % 2 == 0 ? i.LAYOUT_GROW_DIR.BOTTOM : i.LAYOUT_GROW_DIR.TOP : s.dir = "", t._node.isRoot && (s.top = t._node.top + (e._node.height > t._node.height ? -(e._node.height - t._node.height) / 2 : (t._node.height - e._node.height) / 2))), !e.data.expand) return !0;
|
|
834
|
+
}, null, !0, 0);
|
|
835
|
+
}
|
|
836
|
+
computedLeftTopValue() {
|
|
837
|
+
F(this.root, null, (e, t, n, r, i) => {
|
|
838
|
+
if (e.getData("expand") && e.children && e.children.length) {
|
|
839
|
+
let t = this.getMarginX(r + 1), i = this.getMarginY(r + 1);
|
|
840
|
+
if (n) {
|
|
841
|
+
let n = e.left + e.width + t;
|
|
842
|
+
e.children.forEach((e) => {
|
|
843
|
+
e.left = n, n += e.width + t;
|
|
844
|
+
});
|
|
845
|
+
} else {
|
|
846
|
+
let t = e.top + e.height + i + (this.getNodeActChildrenLength(e) > 0 ? e.expandBtnSize : 0);
|
|
847
|
+
e.children.forEach((n) => {
|
|
848
|
+
n.left = e.left + e.width * .5, n.top = t, t += n.height + i + (this.getNodeActChildrenLength(n) > 0 ? n.expandBtnSize : 0);
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}, null, !0);
|
|
853
|
+
}
|
|
854
|
+
adjustLeftTopValue() {
|
|
855
|
+
F(this.root, null, (e, t, n, r) => {
|
|
856
|
+
if (!e.getData("expand")) return;
|
|
857
|
+
e.isRoot && this.updateBrothersLeft(e);
|
|
858
|
+
let i = e.children.length;
|
|
859
|
+
if (t && !t.isRoot && i > 0) {
|
|
860
|
+
let t = this.getMarginY(r + 1), n = e.children.reduce((e, t) => e + t.height + (this.getNodeActChildrenLength(t) > 0 ? t.expandBtnSize : 0), 0) + i * t;
|
|
861
|
+
this.updateBrothersTop(e, n);
|
|
862
|
+
}
|
|
863
|
+
}, (e, t, n, r) => {
|
|
864
|
+
t && t.isRoot && e.dir === i.LAYOUT_GROW_DIR.TOP && e.children.forEach((t) => {
|
|
865
|
+
let n = this.getNodeAreaHeight(t), r = t.top;
|
|
866
|
+
t.top = e.top - (t.top - e.top) - n + e.height, this.updateChildren(t.children, "top", t.top - r);
|
|
867
|
+
});
|
|
868
|
+
}, !0);
|
|
869
|
+
}
|
|
870
|
+
getNodeAreaHeight(e) {
|
|
871
|
+
let t = 0, n = (e) => {
|
|
872
|
+
t += e.height + (this.getNodeActChildrenLength(e) > 0 ? e.expandBtnSize : 0) + this.getMarginY(e.layerIndex), e.children.length && e.children.forEach((e) => {
|
|
873
|
+
n(e);
|
|
874
|
+
});
|
|
875
|
+
};
|
|
876
|
+
return n(e), t;
|
|
877
|
+
}
|
|
878
|
+
updateBrothersLeft(e) {
|
|
879
|
+
let t = e.children, n = 0;
|
|
880
|
+
t.forEach((e) => {
|
|
881
|
+
e.left += n, e.children && e.children.length && this.updateChildren(e.children, "left", n);
|
|
882
|
+
let { left: t, right: r } = this.getNodeBoundaries(e, "h"), i = r - t - e.width;
|
|
883
|
+
i > 0 && (n += i);
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
updateBrothersTop(e, t) {
|
|
887
|
+
if (e.parent && !e.parent.isRoot) {
|
|
888
|
+
let n = e.parent.children, r = N(e, n);
|
|
889
|
+
n.forEach((e, n) => {
|
|
890
|
+
if (e.hasCustomPosition()) return;
|
|
891
|
+
let i = 0;
|
|
892
|
+
n > r && (i = t), e.top += i, e.children && e.children.length && this.updateChildren(e.children, "top", i);
|
|
893
|
+
}), this.updateBrothersTop(e.parent, t);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
renderLine(e, t, n) {
|
|
897
|
+
if (e.children.length <= 0) return [];
|
|
898
|
+
let { left: r, top: a, width: o, height: s, expandBtnSize: c } = e, { alwaysShowExpandBtn: l, notShowExpandBtn: u } = this.mindMap.opt;
|
|
899
|
+
(!l || u) && (c = 0);
|
|
900
|
+
let d = e.children.length;
|
|
901
|
+
if (e.isRoot) {
|
|
902
|
+
let r = e;
|
|
903
|
+
e.children.forEach((i, a) => {
|
|
904
|
+
let o = r.left + r.width, s = i.left, c = e.top + e.height / 2, l = `M ${o},${c} L ${s},${c}`;
|
|
905
|
+
this.setLineStyle(n, t[a], l, i), r = i;
|
|
906
|
+
});
|
|
907
|
+
} else {
|
|
908
|
+
let r = -Infinity, o = Infinity, l = e.left + e.width * .3;
|
|
909
|
+
if (e.children.forEach((e, i) => {
|
|
910
|
+
let a = e.top + e.height / 2;
|
|
911
|
+
a > r && (r = a), a < o && (o = a);
|
|
912
|
+
let s = `M ${l},${a} L ${e.left},${a}`;
|
|
913
|
+
this.setLineStyle(n, t[i], s, e);
|
|
914
|
+
}), d > 0) {
|
|
915
|
+
let t = this.lineDraw.path();
|
|
916
|
+
c = d > 0 ? c : 0, e.parent && e.parent.isRoot && e.dir === i.LAYOUT_GROW_DIR.TOP ? t.plot(this.transformPath(`M ${l},${a} L ${l},${o}`)) : t.plot(this.transformPath(`M ${l},${a + s + c} L ${l},${r}`)), e.style.line(t), e._lines.push(t), n && n(t, e);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
renderExpandBtn(e, t) {
|
|
921
|
+
let { width: n, height: r, expandBtnSize: a, isRoot: o } = e;
|
|
922
|
+
if (!o) {
|
|
923
|
+
let { translateX: o, translateY: s } = t.transform();
|
|
924
|
+
e.parent && e.parent.isRoot && e.dir === i.LAYOUT_GROW_DIR.TOP ? t.translate(n * .3 - a / 2 - o, -a / 2 - s) : t.translate(n * .3 - a / 2 - o, r + a / 2 - s);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
renderGeneralization(e) {
|
|
928
|
+
e.forEach((e) => {
|
|
929
|
+
let { top: t, bottom: n, right: r, generalizationLineMargin: i, generalizationNodeMargin: a } = this.getNodeGeneralizationRenderBoundaries(e, "h"), o = r + i, s = t, c = r + i, l = n, u = `M ${o},${s} Q ${o + 20},${s + (l - s) / 2} ${c},${l}`;
|
|
930
|
+
e.generalizationLine.plot(this.transformPath(u)), e.generalizationNode.left = r + a, e.generalizationNode.top = t + (n - t - e.generalizationNode.height) / 2;
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
renderExpandBtnRect(e, t, n, r, a) {
|
|
934
|
+
if (this.layout === i.LAYOUT.TIMELINE) e.size(n, t).x(0).y(r);
|
|
935
|
+
else {
|
|
936
|
+
let o = "";
|
|
937
|
+
o = a.dir === i.LAYOUT_GROW_DIR.TOP && a.layerIndex === 1 ? i.LAYOUT_GROW_DIR.TOP : i.LAYOUT_GROW_DIR.BOTTOM, o === i.LAYOUT_GROW_DIR.TOP ? e.size(n, t).x(0).y(-t) : e.size(n, t).x(0).y(r);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}, K = class extends W {
|
|
941
|
+
constructor(e = {}, t) {
|
|
942
|
+
super(e), this.layout = t;
|
|
943
|
+
}
|
|
944
|
+
doLayout(e) {
|
|
945
|
+
I([
|
|
946
|
+
() => {
|
|
947
|
+
this.computedBaseValue();
|
|
948
|
+
},
|
|
949
|
+
() => {
|
|
950
|
+
this.computedTopValue();
|
|
951
|
+
},
|
|
952
|
+
() => {
|
|
953
|
+
this.adjustLeftTopValue();
|
|
954
|
+
},
|
|
955
|
+
() => {
|
|
956
|
+
e(this.root);
|
|
957
|
+
}
|
|
958
|
+
]);
|
|
959
|
+
}
|
|
960
|
+
computedBaseValue() {
|
|
961
|
+
F(this.renderer.renderTree, null, (e, t, n, r, a, o) => {
|
|
962
|
+
let s = this.createNode(e, t, n, r, a, o);
|
|
963
|
+
if (n ? this.setNodeCenter(s) : (t._node.dir ? s.dir = t._node.dir : this.layout === i.LAYOUT.VERTICAL_TIMELINE2 ? s.dir = i.LAYOUT_GROW_DIR.LEFT : this.layout === i.LAYOUT.VERTICAL_TIMELINE3 ? s.dir = i.LAYOUT_GROW_DIR.RIGHT : s.dir = a % 2 == 0 ? i.LAYOUT_GROW_DIR.RIGHT : i.LAYOUT_GROW_DIR.LEFT, t._node.isRoot ? s.left = t._node.left + (e._node.width > t._node.width ? -(e._node.width - t._node.width) / 2 : (t._node.width - e._node.width) / 2) : s.left = s.dir === i.LAYOUT_GROW_DIR.RIGHT ? t._node.left + t._node.width + this.getMarginX(r) : t._node.left - this.getMarginX(r) - s.width), !e.data.expand) return !0;
|
|
964
|
+
}, (e, t, n, r) => {
|
|
965
|
+
if (n) return;
|
|
966
|
+
let i = e.data.expand === !1 ? 0 : e._node.children.length;
|
|
967
|
+
e._node.childrenAreaHeight = i ? e._node.children.reduce((e, t) => e + t.height, 0) + (i + 1) * this.getMarginY(r + 1) : 0;
|
|
968
|
+
}, !0, 0);
|
|
969
|
+
}
|
|
970
|
+
computedTopValue() {
|
|
971
|
+
F(this.root, null, (e, t, n, r, i) => {
|
|
972
|
+
if (e.getData("expand") && e.children && e.children.length) {
|
|
973
|
+
let t = this.getMarginY(r + 1);
|
|
974
|
+
if (n) {
|
|
975
|
+
let n = e.top + e.height + t;
|
|
976
|
+
e.children.forEach((e) => {
|
|
977
|
+
e.top = n, n += e.height + t;
|
|
978
|
+
});
|
|
979
|
+
} else {
|
|
980
|
+
let t = this.getMarginY(r + 1), n = e.top + e.height / 2 + t - e.childrenAreaHeight / 2;
|
|
981
|
+
e.children.forEach((e) => {
|
|
982
|
+
e.top = n, n += e.height + t;
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}, null, !0);
|
|
987
|
+
}
|
|
988
|
+
adjustLeftTopValue() {
|
|
989
|
+
F(this.root, null, (e, t, n, r) => {
|
|
990
|
+
if (!e.getData("expand") || n) return;
|
|
991
|
+
let i = this.getMarginY(r + 1) * 2 + e.height, a = e.childrenAreaHeight - i;
|
|
992
|
+
a > 0 && this.updateBrothers(e, a / 2);
|
|
993
|
+
}, null, !0);
|
|
994
|
+
}
|
|
995
|
+
updateBrothers(e, t) {
|
|
996
|
+
if (e.parent) {
|
|
997
|
+
let n = e.parent.children, r = N(e, n);
|
|
998
|
+
n.forEach((n, i) => {
|
|
999
|
+
if (n.hasCustomPosition() || !e.parent.isRoot && n.uid === e.uid) return;
|
|
1000
|
+
let a = 0;
|
|
1001
|
+
e.parent.isRoot ? a = i < r ? 0 : i > r ? t * 2 : t : i < r ? a = -t : i > r && (a = t), n.top += a, n.children && n.children.length && this.updateChildren(n.children, "top", a);
|
|
1002
|
+
}), this.updateBrothers(e.parent, t);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
updateBrothersTop(e, t) {
|
|
1006
|
+
if (e.parent && !e.parent.isRoot) {
|
|
1007
|
+
let n = e.parent.children, r = N(e, n);
|
|
1008
|
+
n.forEach((e, n) => {
|
|
1009
|
+
if (e.hasCustomPosition()) return;
|
|
1010
|
+
let i = 0;
|
|
1011
|
+
n > r && (i = t), e.top += i, e.children && e.children.length && this.updateChildren(e.children, "top", i);
|
|
1012
|
+
}), this.updateBrothersTop(e.parent, t);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
renderLine(e, t, n, r) {
|
|
1016
|
+
r === "curve" ? this.renderLineCurve(e, t, n) : r === "direct" ? this.renderLineDirect(e, t, n) : this.renderLineStraight(e, t, n);
|
|
1017
|
+
}
|
|
1018
|
+
renderLineStraight(e, t, n) {
|
|
1019
|
+
if (e.children.length <= 0) return [];
|
|
1020
|
+
let { expandBtnSize: r } = e, { alwaysShowExpandBtn: a, notShowExpandBtn: o } = this.mindMap.opt;
|
|
1021
|
+
if ((!a || o) && (r = 0), e.isRoot) {
|
|
1022
|
+
let r = e;
|
|
1023
|
+
e.children.forEach((i, a) => {
|
|
1024
|
+
let o = r.top + r.height, s = i.top, c = e.left + e.width / 2, l = `M ${c},${o} L ${c},${s}`;
|
|
1025
|
+
this.setLineStyle(n, t[a], l, i), r = i;
|
|
1026
|
+
});
|
|
1027
|
+
} else if (e.dir === i.LAYOUT_GROW_DIR.RIGHT) {
|
|
1028
|
+
let i = e.left + e.width, a = e.top + e.height / 2, o = (this.getMarginX(e.layerIndex + 1) - r) * .6;
|
|
1029
|
+
e.children.forEach((e, r) => {
|
|
1030
|
+
let s = e.left, c = e.top + e.height / 2, l = this.createFoldLine([
|
|
1031
|
+
[i, a],
|
|
1032
|
+
[i + o, a],
|
|
1033
|
+
[i + o, c],
|
|
1034
|
+
[s, c]
|
|
1035
|
+
]);
|
|
1036
|
+
this.setLineStyle(n, t[r], l, e);
|
|
1037
|
+
});
|
|
1038
|
+
} else {
|
|
1039
|
+
let i = e.left, a = e.top + e.height / 2, o = (this.getMarginX(e.layerIndex + 1) - r) * .6;
|
|
1040
|
+
e.children.forEach((e, r) => {
|
|
1041
|
+
let s = e.left + e.width, c = e.top + e.height / 2, l = this.createFoldLine([
|
|
1042
|
+
[i, a],
|
|
1043
|
+
[i - o, a],
|
|
1044
|
+
[i - o, c],
|
|
1045
|
+
[s, c]
|
|
1046
|
+
]);
|
|
1047
|
+
this.setLineStyle(n, t[r], l, e);
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
renderLineDirect(e, t, n) {
|
|
1052
|
+
if (e.children.length <= 0) return [];
|
|
1053
|
+
let { left: r, top: a, width: o, height: s, expandBtnSize: c } = e, { alwaysShowExpandBtn: l, notShowExpandBtn: u } = this.mindMap.opt;
|
|
1054
|
+
(!l || u) && (c = 0), e.children.forEach((l, u) => {
|
|
1055
|
+
if (e.isRoot) {
|
|
1056
|
+
let r = e;
|
|
1057
|
+
e.children.forEach((i, a) => {
|
|
1058
|
+
let o = r.top + r.height, s = i.top, c = e.left + e.width / 2, l = `M ${c},${o} L ${c},${s}`;
|
|
1059
|
+
this.setLineStyle(n, t[a], l, i), r = i;
|
|
1060
|
+
});
|
|
1061
|
+
} else {
|
|
1062
|
+
let e = `M ${l.dir === i.LAYOUT_GROW_DIR.LEFT ? r - c : r + o + c},${a + s / 2} L ${l.dir === i.LAYOUT_GROW_DIR.LEFT ? l.left + l.width : l.left},${l.top + l.height / 2}`;
|
|
1063
|
+
this.setLineStyle(n, t[u], e, l);
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
renderLineCurve(e, t, n) {
|
|
1068
|
+
if (e.children.length <= 0) return [];
|
|
1069
|
+
let { left: r, top: a, width: o, height: s, expandBtnSize: c } = e, { alwaysShowExpandBtn: l, notShowExpandBtn: u } = this.mindMap.opt;
|
|
1070
|
+
(!l || u) && (c = 0), e.children.forEach((l, u) => {
|
|
1071
|
+
if (e.isRoot) {
|
|
1072
|
+
let r = e;
|
|
1073
|
+
e.children.forEach((i, a) => {
|
|
1074
|
+
let o = r.top + r.height, s = i.top, c = e.left + e.width / 2, l = `M ${c},${o} L ${c},${s}`;
|
|
1075
|
+
this.setLineStyle(n, t[a], l, i), r = i;
|
|
1076
|
+
});
|
|
1077
|
+
} else {
|
|
1078
|
+
let e = l.dir === i.LAYOUT_GROW_DIR.LEFT ? r - c : r + o + c, d = a + s / 2, f = l.dir === i.LAYOUT_GROW_DIR.LEFT ? l.left + l.width : l.left, p = l.top + l.height / 2, m = this.cubicBezierPath(e, d, f, p);
|
|
1079
|
+
this.setLineStyle(n, t[u], m, l);
|
|
1080
|
+
}
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
renderExpandBtn(e, t) {
|
|
1084
|
+
let { width: n, height: r, expandBtnSize: a, isRoot: o } = e;
|
|
1085
|
+
if (!o) {
|
|
1086
|
+
let { translateX: o, translateY: s } = t.transform();
|
|
1087
|
+
e.dir === i.LAYOUT_GROW_DIR.RIGHT ? t.translate(n - o, r / 2 - s) : t.translate(-a - o, r / 2 - s);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
renderGeneralization(e) {
|
|
1091
|
+
e.forEach((e) => {
|
|
1092
|
+
let t = e.node.dir === i.LAYOUT_GROW_DIR.LEFT, { top: n, bottom: r, left: a, right: o, generalizationLineMargin: s, generalizationNodeMargin: c } = this.getNodeGeneralizationRenderBoundaries(e, "h"), l = t ? a - s : o + s, u = l, d = n, f = l, p = r, m = `M ${u},${d} Q ${u + (t ? -20 : 20)},${d + (p - d) / 2} ${f},${p}`;
|
|
1093
|
+
e.generalizationLine.plot(this.transformPath(m)), e.generalizationNode.left = l + (t ? -c : c) - (t ? e.generalizationNode.width : 0), e.generalizationNode.top = n + (r - n - e.generalizationNode.height) / 2;
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
renderExpandBtnRect(e, t, n, r, a) {
|
|
1097
|
+
a.dir === i.LAYOUT_GROW_DIR.LEFT ? e.size(t, r).x(-t).y(0) : e.size(t, r).x(n).y(0);
|
|
1098
|
+
}
|
|
1099
|
+
}, q = {
|
|
1100
|
+
top: {
|
|
1101
|
+
renderExpandBtn({ node: e, btn: t, expandBtnSize: n, translateX: r, translateY: i, width: a, height: o }) {
|
|
1102
|
+
e.parent && e.parent.isRoot ? t.translate(a * .3 - n / 2 - r, -n / 2 - i) : t.translate(a * .3 - n / 2 - r, o + n / 2 - i);
|
|
1103
|
+
},
|
|
1104
|
+
renderLine({ node: e, line: t, top: n, x: r, lineLength: i, height: a, expandBtnSize: o, maxy: s, ctx: c }) {
|
|
1105
|
+
e.parent && e.parent.isRoot ? t.plot(c.transformPath(`M ${r},${n} L ${r + i},${n - Math.tan(E(c.mindMap.opt.fishboneDeg)) * i}`)) : t.plot(c.transformPath(`M ${r},${n + a + o} L ${r},${s}`));
|
|
1106
|
+
},
|
|
1107
|
+
computedLeftTopValue({ layerIndex: e, node: t, ctx: n }) {
|
|
1108
|
+
if (e >= 1 && t.children) {
|
|
1109
|
+
let r = n.getMarginY(e + 1), i = t.left + t.width * n.childIndent, a = t.top + t.height + (n.getNodeActChildrenLength(t) > 0 ? t.expandBtnSize : 0) + r;
|
|
1110
|
+
t.children.forEach((e) => {
|
|
1111
|
+
e.left = i, e.top += a, a += e.height + (n.getNodeActChildrenLength(e) > 0 ? e.expandBtnSize : 0) + r;
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
},
|
|
1115
|
+
adjustLeftTopValueBefore({ node: e, parent: t, ctx: n, layerIndex: r }) {
|
|
1116
|
+
let i = e.children.length, a = n.getMarginY(r + 1);
|
|
1117
|
+
if (t && !t.isRoot && i > 0) {
|
|
1118
|
+
let t = e.children.reduce((e, t) => e + t.height + (n.getNodeActChildrenLength(t) > 0 ? t.expandBtnSize : 0) + a, 0);
|
|
1119
|
+
n.updateBrothersTop(e, t);
|
|
1120
|
+
}
|
|
1121
|
+
},
|
|
1122
|
+
adjustLeftTopValueAfter({ parent: e, node: t, ctx: n }) {
|
|
1123
|
+
if (e && e.isRoot) {
|
|
1124
|
+
let e = n.getMarginY(t.layerIndex + 1), r = t.expandBtnSize + e;
|
|
1125
|
+
t.children.forEach((e) => {
|
|
1126
|
+
let i = n.getNodeAreaHeight(e), a = e.top, o = e.left;
|
|
1127
|
+
e.top = t.top - (e.top - t.top) - i + t.height, e.left = t.left + t.width * n.indent + (i + r) / Math.tan(E(n.mindMap.opt.fishboneDeg)), r += i, n.updateChildrenPro(e.children, {
|
|
1128
|
+
top: e.top - a,
|
|
1129
|
+
left: e.left - o
|
|
1130
|
+
});
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
},
|
|
1135
|
+
bottom: {
|
|
1136
|
+
renderExpandBtn({ node: e, btn: t, expandBtnSize: n, translateX: r, translateY: i, width: a, height: o }) {
|
|
1137
|
+
e.parent && e.parent.isRoot ? t.translate(a * .3 - n / 2 - r, o + n / 2 - i) : t.translate(a * .3 - n / 2 - r, -n / 2 - i);
|
|
1138
|
+
},
|
|
1139
|
+
renderLine({ node: e, line: t, top: n, x: r, lineLength: i, height: a, miny: o, ctx: s }) {
|
|
1140
|
+
e.parent && e.parent.isRoot ? t.plot(s.transformPath(`M ${r},${n + a} L ${r + i},${n + a + Math.tan(E(s.mindMap.opt.fishboneDeg)) * i}`)) : t.plot(s.transformPath(`M ${r},${n} L ${r},${o}`));
|
|
1141
|
+
},
|
|
1142
|
+
computedLeftTopValue({ layerIndex: e, node: t, ctx: n }) {
|
|
1143
|
+
let r = n.getMarginY(e + 1);
|
|
1144
|
+
if (e === 1 && t.children) {
|
|
1145
|
+
let e = t.left + t.width * n.childIndent, i = t.top + t.height + (n.getNodeActChildrenLength(t) > 0 ? t.expandBtnSize : 0) + r;
|
|
1146
|
+
t.children.forEach((t) => {
|
|
1147
|
+
t.left = e, t.top = i + (n.getNodeActChildrenLength(t) > 0 ? t.expandBtnSize : 0), i += t.height + (n.getNodeActChildrenLength(t) > 0 ? t.expandBtnSize : 0) + r;
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
if (e > 1 && t.children) {
|
|
1151
|
+
let e = t.left + t.width * n.childIndent, i = t.top - (n.getNodeActChildrenLength(t) > 0 ? t.expandBtnSize : 0) - r;
|
|
1152
|
+
t.children.forEach((t) => {
|
|
1153
|
+
t.left = e, t.top = i - t.height, i -= t.height + (n.getNodeActChildrenLength(t) > 0 ? t.expandBtnSize : 0) + r;
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
adjustLeftTopValueBefore({ node: e, ctx: t, layerIndex: n }) {
|
|
1158
|
+
let r = t.getMarginY(n + 1), i = e.children.length;
|
|
1159
|
+
if (n > 2 && i > 0) {
|
|
1160
|
+
let n = e.children.reduce((e, n) => e + n.height + (t.getNodeActChildrenLength(n) > 0 ? n.expandBtnSize : 0) + r, 0);
|
|
1161
|
+
t.updateBrothersTop(e, -n);
|
|
1162
|
+
}
|
|
1163
|
+
},
|
|
1164
|
+
adjustLeftTopValueAfter({ parent: e, node: t, ctx: n }) {
|
|
1165
|
+
if (e && e.isRoot) {
|
|
1166
|
+
let e = n.getMarginY(t.layerIndex + 1), r = 0, i = t.expandBtnSize;
|
|
1167
|
+
t.children.forEach((a) => {
|
|
1168
|
+
let o = n.getNodeActChildrenLength(a) > 0, s = n.getNodeAreaHeight(a), c = o ? s - a.height - (o ? a.expandBtnSize : 0) : 0;
|
|
1169
|
+
c -= o ? e : 0;
|
|
1170
|
+
let l = r + c, u = a.left;
|
|
1171
|
+
a.top += l, a.left = t.left + t.width * n.indent + (s + i) / Math.tan(E(n.mindMap.opt.fishboneDeg)), r += c, i += s, n.updateChildrenPro(a.children, {
|
|
1172
|
+
top: l,
|
|
1173
|
+
left: a.left - u
|
|
1174
|
+
});
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
}, J = class extends W {
|
|
1180
|
+
constructor(e = {}, t) {
|
|
1181
|
+
super(e), this.layout = t, this.indent = .3, this.childIndent = .5, this.fishTail = null, this.maxx = 0, this.headRatio = 1, this.tailRatio = .6, this.paddingXRatio = .3, this.fishHeadPathStr = "M4,181 C4,181, 0,177, 4,173 Q 96.09523809523809,0, 288.2857142857143,0 L 288.2857142857143,354 Q 48.047619047619044,354, 8,218.18367346938777 C8,218.18367346938777, 6,214.18367346938777, 8,214.18367346938777 L 41.183673469387756,214.18367346938777 Z", this.fishTailPathStr = "M 606.9342905223708 0 Q 713.1342905223709 -177 819.3342905223708 -177 L 766.2342905223709 0 L 819.3342905223708 177 Q 713.1342905223709 177 606.9342905223708 0 z", this.bindEvent(), this.extendShape(), this.beforeChange = this.beforeChange.bind(this);
|
|
1182
|
+
}
|
|
1183
|
+
nodeIsRemoveAllLines(e) {
|
|
1184
|
+
return e.isRoot || e.layerIndex === 1;
|
|
1185
|
+
}
|
|
1186
|
+
isFishbone2() {
|
|
1187
|
+
return this.layout === i.LAYOUT.FISHBONE2;
|
|
1188
|
+
}
|
|
1189
|
+
bindEvent() {
|
|
1190
|
+
this.isFishbone2() && (this.onCheckUpdateFishTail = this.onCheckUpdateFishTail.bind(this), this.mindMap.on("afterExecCommand", this.onCheckUpdateFishTail));
|
|
1191
|
+
}
|
|
1192
|
+
unBindEvent() {
|
|
1193
|
+
this.mindMap.off("afterExecCommand", this.onCheckUpdateFishTail);
|
|
1194
|
+
}
|
|
1195
|
+
extendShape() {
|
|
1196
|
+
this.isFishbone2() && this.mindMap.addShape({
|
|
1197
|
+
name: "fishHead",
|
|
1198
|
+
createShape: (e) => {
|
|
1199
|
+
let t = H(`<path d="${this.fishHeadPathStr}"></path>`), { width: n, height: r } = e.shapeInstance.getNodeSize();
|
|
1200
|
+
return t.size(n, r), t;
|
|
1201
|
+
},
|
|
1202
|
+
getPadding: ({ width: e, height: t, paddingX: n, paddingY: r }) => {
|
|
1203
|
+
e += n * 2, t += r * 2;
|
|
1204
|
+
let i = this.paddingXRatio * e, a = 0;
|
|
1205
|
+
return e += i * 2, a = (e / this.headRatio - t) / 2, {
|
|
1206
|
+
paddingX: i,
|
|
1207
|
+
paddingY: a
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
doLayout(e) {
|
|
1213
|
+
I([
|
|
1214
|
+
() => {
|
|
1215
|
+
this.computedBaseValue(), this.addFishTail();
|
|
1216
|
+
},
|
|
1217
|
+
() => {
|
|
1218
|
+
this.computedLeftTopValue();
|
|
1219
|
+
},
|
|
1220
|
+
() => {
|
|
1221
|
+
this.adjustLeftTopValue(), this.updateFishTailPosition();
|
|
1222
|
+
},
|
|
1223
|
+
() => {
|
|
1224
|
+
e(this.root);
|
|
1225
|
+
}
|
|
1226
|
+
]);
|
|
1227
|
+
}
|
|
1228
|
+
addFishTail() {
|
|
1229
|
+
if (!this.isFishbone2()) return;
|
|
1230
|
+
let e = this.mindMap.lineDraw.findOne(".smm-layout-fishbone-tail");
|
|
1231
|
+
e ? this.fishTail = e : (this.fishTail = H(`<path d="${this.fishTailPathStr}"></path>`), this.fishTail.addClass("smm-layout-fishbone-tail"));
|
|
1232
|
+
let t = this.root.height, n = t * this.tailRatio;
|
|
1233
|
+
this.fishTail.size(n, t), this.styleFishTail(), this.mindMap.lineDraw.add(this.fishTail);
|
|
1234
|
+
}
|
|
1235
|
+
onCheckUpdateFishTail(e, t, n) {
|
|
1236
|
+
if (e === "SET_NODE_DATA") {
|
|
1237
|
+
let e = !1;
|
|
1238
|
+
Object.keys(n).forEach((t) => {
|
|
1239
|
+
ve.includes(t) && (e = !0);
|
|
1240
|
+
}), e && this.styleFishTail();
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
styleFishTail() {
|
|
1244
|
+
this.root.style.shape(this.fishTail);
|
|
1245
|
+
}
|
|
1246
|
+
removeFishTail() {
|
|
1247
|
+
let e = this.mindMap.lineDraw.findOne(".smm-layout-fishbone-tail");
|
|
1248
|
+
e && e.remove();
|
|
1249
|
+
}
|
|
1250
|
+
updateFishTailPosition() {
|
|
1251
|
+
this.isFishbone2() && this.fishTail.x(this.maxx).cy(this.root.top + this.root.height / 2);
|
|
1252
|
+
}
|
|
1253
|
+
computedBaseValue() {
|
|
1254
|
+
F(this.renderer.renderTree, null, (e, t, n, r, a, o) => {
|
|
1255
|
+
n && this.isFishbone2() && (e.data.shape = "fishHead");
|
|
1256
|
+
let s = this.createNode(e, t, n, r, a, o);
|
|
1257
|
+
if (n) this.setNodeCenter(s);
|
|
1258
|
+
else if (t._node.dir ? s.dir = t._node.dir : s.dir = a % 2 == 0 ? i.LAYOUT_GROW_DIR.TOP : i.LAYOUT_GROW_DIR.BOTTOM, t._node.isRoot) {
|
|
1259
|
+
let e = this.getMarginY(r), n = this.isFishbone2() ? t._node.height / 4 : 0;
|
|
1260
|
+
this.checkIsTop(s) ? s.top = t._node.top - s.height - e + n : s.top = t._node.top + t._node.height + e - n;
|
|
1261
|
+
}
|
|
1262
|
+
if (!e.data.expand) return !0;
|
|
1263
|
+
}, null, !0, 0);
|
|
1264
|
+
}
|
|
1265
|
+
computedLeftTopValue() {
|
|
1266
|
+
F(this.root, null, (e, t, n, r) => {
|
|
1267
|
+
if (e.isRoot) {
|
|
1268
|
+
let t = this.getMarginX(r + 1), n = this.isFishbone2() ? 2 : 1, i = e.left + e.width + e.height / n + t, a = e.left + e.width + e.height / n + t;
|
|
1269
|
+
e.children.forEach((e) => {
|
|
1270
|
+
this.checkIsTop(e) ? (e.left = i, i += e.width + t) : (e.left = a + 20, a += e.width + t);
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
let i = {
|
|
1274
|
+
layerIndex: r,
|
|
1275
|
+
node: e,
|
|
1276
|
+
ctx: this
|
|
1277
|
+
};
|
|
1278
|
+
this.checkIsTop(e) ? q.top.computedLeftTopValue(i) : q.bottom.computedLeftTopValue(i);
|
|
1279
|
+
}, null, !0);
|
|
1280
|
+
}
|
|
1281
|
+
adjustLeftTopValue() {
|
|
1282
|
+
F(this.root, null, (e, t, n, r) => {
|
|
1283
|
+
if (!e.getData("expand")) return;
|
|
1284
|
+
let i = {
|
|
1285
|
+
node: e,
|
|
1286
|
+
parent: t,
|
|
1287
|
+
layerIndex: r,
|
|
1288
|
+
ctx: this
|
|
1289
|
+
};
|
|
1290
|
+
this.checkIsTop(e) ? q.top.adjustLeftTopValueBefore(i) : q.bottom.adjustLeftTopValueBefore(i);
|
|
1291
|
+
}, (e, t) => {
|
|
1292
|
+
let n = {
|
|
1293
|
+
parent: t,
|
|
1294
|
+
node: e,
|
|
1295
|
+
ctx: this
|
|
1296
|
+
};
|
|
1297
|
+
if (this.checkIsTop(e) ? q.top.adjustLeftTopValueAfter(n) : q.bottom.adjustLeftTopValueAfter(n), e.isRoot) {
|
|
1298
|
+
let t = 0, n = 0, r = -Infinity;
|
|
1299
|
+
e.children.forEach((e) => {
|
|
1300
|
+
if (this.checkIsTop(e)) {
|
|
1301
|
+
e.left += t, this.updateChildren(e.children, "left", t);
|
|
1302
|
+
let { left: n, right: i } = this.getNodeBoundaries(e, "h");
|
|
1303
|
+
i > r && (r = i), t += i - n;
|
|
1304
|
+
} else {
|
|
1305
|
+
e.left += n, this.updateChildren(e.children, "left", n);
|
|
1306
|
+
let { left: t, right: i } = this.getNodeBoundaries(e, "h");
|
|
1307
|
+
i > r && (r = i), n += i - t;
|
|
1308
|
+
}
|
|
1309
|
+
}), this.maxx = r;
|
|
1310
|
+
}
|
|
1311
|
+
}, !0);
|
|
1312
|
+
}
|
|
1313
|
+
getNodeAreaHeight(e) {
|
|
1314
|
+
let t = 0, n = (e) => {
|
|
1315
|
+
let r = this.getMarginY(e.layerIndex);
|
|
1316
|
+
t += e.height + (this.getNodeActChildrenLength(e) > 0 ? e.expandBtnSize : 0) + r, e.children.length && e.children.forEach((e) => {
|
|
1317
|
+
n(e);
|
|
1318
|
+
});
|
|
1319
|
+
};
|
|
1320
|
+
return n(e), t;
|
|
1321
|
+
}
|
|
1322
|
+
updateBrothersLeft(e) {
|
|
1323
|
+
let t = e.children, n = 0;
|
|
1324
|
+
t.forEach((e) => {
|
|
1325
|
+
e.left += n, e.children && e.children.length && this.updateChildren(e.children, "left", n);
|
|
1326
|
+
let { left: t, right: r } = this.getNodeBoundaries(e, "h"), i = r - t - e.width;
|
|
1327
|
+
i > 0 && (n += i);
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1330
|
+
updateBrothersTop(e, t) {
|
|
1331
|
+
if (e.parent && !e.parent.isRoot) {
|
|
1332
|
+
let n = e.parent.children, r = N(e, n);
|
|
1333
|
+
n.forEach((e, n) => {
|
|
1334
|
+
if (e.hasCustomPosition()) return;
|
|
1335
|
+
let i = 0;
|
|
1336
|
+
n > r && (i = t), e.top += i, e.children && e.children.length && this.updateChildren(e.children, "top", i);
|
|
1337
|
+
}), this.checkIsTop(e) ? this.updateBrothersTop(e.parent, t) : this.updateBrothersTop(e.parent, e.layerIndex === 3 ? 0 : t);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
checkIsTop(e) {
|
|
1341
|
+
return e.dir === i.LAYOUT_GROW_DIR.TOP;
|
|
1342
|
+
}
|
|
1343
|
+
renderLine(e, t, n) {
|
|
1344
|
+
if (e.layerIndex !== 1 && e.children.length <= 0) return [];
|
|
1345
|
+
let { top: r, height: i, expandBtnSize: a } = e, { alwaysShowExpandBtn: o, notShowExpandBtn: s } = this.mindMap.opt;
|
|
1346
|
+
(!o || s) && (a = 0);
|
|
1347
|
+
let c = e.children.length;
|
|
1348
|
+
if (e.isRoot) {
|
|
1349
|
+
let t = -Infinity;
|
|
1350
|
+
e.children.forEach((r) => {
|
|
1351
|
+
r.left > t && (t = r.left);
|
|
1352
|
+
let i = this.getMarginY(r.layerIndex), a = r.left, o = e.height / 2 + i - (this.isFishbone2() ? e.height / 4 : 0), s = o / Math.tan(E(this.mindMap.opt.fishboneDeg)), c = this.lineDraw.path();
|
|
1353
|
+
this.checkIsTop(r) ? c.plot(this.transformPath(`M ${a - s},${r.top + r.height + o} L ${r.left},${r.top + r.height}`)) : c.plot(this.transformPath(`M ${a - s},${r.top - o} L ${a},${r.top}`)), e.style.line(c), e._lines.push(c), n && n(c, e);
|
|
1354
|
+
});
|
|
1355
|
+
let r = e.top + e.height / 2, i = e.height / 2 + this.getMarginY(e.layerIndex + 1), a = this.lineDraw.path(), o = this.isFishbone2() ? this.maxx : t - i / Math.tan(E(this.mindMap.opt.fishboneDeg));
|
|
1356
|
+
a.plot(this.transformPath(`M ${e.left + e.width},${r} L ${o},${r}`)), e.style.line(a), e._lines.push(a), n && n(a, e);
|
|
1357
|
+
} else {
|
|
1358
|
+
let o = -Infinity, s = Infinity, l = -Infinity, u = e.left + e.width * this.indent;
|
|
1359
|
+
if (e.children.forEach((r, i) => {
|
|
1360
|
+
r.left > l && (l = r.left);
|
|
1361
|
+
let a = r.top + r.height / 2;
|
|
1362
|
+
if (a > o && (o = a), a < s && (s = a), e.layerIndex > 1) {
|
|
1363
|
+
let e = `M ${u},${a} L ${r.left},${a}`;
|
|
1364
|
+
this.setLineStyle(n, t[i], e, r);
|
|
1365
|
+
}
|
|
1366
|
+
}), c >= 0) {
|
|
1367
|
+
let t = this.lineDraw.path();
|
|
1368
|
+
a = c > 0 ? a : 0;
|
|
1369
|
+
let d = l - e.left - e.width * this.indent;
|
|
1370
|
+
d = Math.max(d, 0);
|
|
1371
|
+
let f = {
|
|
1372
|
+
node: e,
|
|
1373
|
+
line: t,
|
|
1374
|
+
top: r,
|
|
1375
|
+
x: u,
|
|
1376
|
+
lineLength: d,
|
|
1377
|
+
height: i,
|
|
1378
|
+
expandBtnSize: a,
|
|
1379
|
+
maxy: o,
|
|
1380
|
+
miny: s,
|
|
1381
|
+
ctx: this
|
|
1382
|
+
};
|
|
1383
|
+
this.checkIsTop(e) ? q.top.renderLine(f) : q.bottom.renderLine(f), e.style.line(t), e._lines.push(t), n && n(t, e);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
renderExpandBtn(e, t) {
|
|
1388
|
+
let { width: n, height: r, expandBtnSize: i, isRoot: a } = e;
|
|
1389
|
+
if (!a) {
|
|
1390
|
+
let { translateX: a, translateY: o } = t.transform(), s = {
|
|
1391
|
+
node: e,
|
|
1392
|
+
btn: t,
|
|
1393
|
+
expandBtnSize: i,
|
|
1394
|
+
translateX: a,
|
|
1395
|
+
translateY: o,
|
|
1396
|
+
width: n,
|
|
1397
|
+
height: r
|
|
1398
|
+
};
|
|
1399
|
+
this.checkIsTop(e) ? q.top.renderExpandBtn(s) : q.bottom.renderExpandBtn(s);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
renderGeneralization(e) {
|
|
1403
|
+
e.forEach((e) => {
|
|
1404
|
+
let { top: t, bottom: n, right: r, generalizationLineMargin: i, generalizationNodeMargin: a } = this.getNodeGeneralizationRenderBoundaries(e, "h"), o = r + i, s = t, c = r + i, l = n, u = `M ${o},${s} Q ${o + 20},${s + (l - s) / 2} ${c},${l}`;
|
|
1405
|
+
e.generalizationLine.plot(this.transformPath(u)), e.generalizationNode.left = r + a, e.generalizationNode.top = t + (n - t - e.generalizationNode.height) / 2;
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
renderExpandBtnRect(e, t, n, r, a) {
|
|
1409
|
+
let o = "";
|
|
1410
|
+
o = a.dir === i.LAYOUT_GROW_DIR.TOP ? a.layerIndex === 1 ? i.LAYOUT_GROW_DIR.TOP : i.LAYOUT_GROW_DIR.BOTTOM : a.layerIndex === 1 ? i.LAYOUT_GROW_DIR.BOTTOM : i.LAYOUT_GROW_DIR.TOP, o === i.LAYOUT_GROW_DIR.TOP ? e.size(n, t).x(0).y(-t) : e.size(n, t).x(0).y(r);
|
|
1411
|
+
}
|
|
1412
|
+
beforeChange() {
|
|
1413
|
+
this.isFishbone2() && (this.root.nodeData.data.shape = i.SHAPE.RECTANGLE, this.removeFishTail(), this.unBindEvent(), this.mindMap.removeShape("fishHead"));
|
|
1414
|
+
}
|
|
1415
|
+
}, ke = "smm-node-edit-wrap", Ae = class {
|
|
1416
|
+
constructor(e) {
|
|
1417
|
+
this.renderer = e, this.mindMap = e.mindMap, this.currentNode = null, this.textEditNode = null, this.showTextEdit = !1, this.cacheEditingText = "", this.hasBodyMousedown = !1, this.textNodePaddingX = 5, this.textNodePaddingY = 3, this.isNeedUpdateTextEditNode = !1, this.mindMap.addEditNodeClass(ke), this.bindEvent();
|
|
1418
|
+
}
|
|
1419
|
+
bindEvent() {
|
|
1420
|
+
this.show = this.show.bind(this), this.onScale = this.onScale.bind(this), this.onKeydown = this.onKeydown.bind(this), this.mindMap.on("node_dblclick", (e, t, n) => {
|
|
1421
|
+
this.show({
|
|
1422
|
+
node: e,
|
|
1423
|
+
e: t,
|
|
1424
|
+
isInserting: n
|
|
1425
|
+
});
|
|
1426
|
+
}), this.mindMap.on("draw_click", () => {
|
|
1427
|
+
this.hideEditTextBox();
|
|
1428
|
+
}), this.mindMap.on("body_mousedown", () => {
|
|
1429
|
+
this.hasBodyMousedown = !0;
|
|
1430
|
+
}), this.mindMap.on("body_click", () => {
|
|
1431
|
+
this.hasBodyMousedown && (this.hasBodyMousedown = !1, this.mindMap.opt.isEndNodeTextEditOnClickOuter && this.hideEditTextBox());
|
|
1432
|
+
}), this.mindMap.on("svg_mousedown", () => {
|
|
1433
|
+
this.hideEditTextBox();
|
|
1434
|
+
}), this.mindMap.on("expand_btn_click", () => {
|
|
1435
|
+
this.hideEditTextBox();
|
|
1436
|
+
}), this.mindMap.on("before_node_active", () => {
|
|
1437
|
+
this.hideEditTextBox();
|
|
1438
|
+
}), this.mindMap.on("mousewheel", () => {
|
|
1439
|
+
this.mindMap.opt.mousewheelAction === i.MOUSE_WHEEL_ACTION.MOVE && this.hideEditTextBox();
|
|
1440
|
+
}), this.mindMap.keyCommand.addShortcut("F2", () => {
|
|
1441
|
+
this.renderer.activeNodeList.length <= 0 || this.show({ node: this.renderer.activeNodeList[0] });
|
|
1442
|
+
}), this.mindMap.on("scale", this.onScale), this.mindMap.opt.enableAutoEnterTextEditWhenKeydown && window.addEventListener("keydown", this.onKeydown), this.mindMap.on("beforeDestroy", () => {
|
|
1443
|
+
this.unBindEvent();
|
|
1444
|
+
}), this.mindMap.on("after_update_config", (e, t) => {
|
|
1445
|
+
e.openRealtimeRenderOnNodeTextEdit !== t.openRealtimeRenderOnNodeTextEdit && (this.mindMap.richText ? this.mindMap.richText.onOpenRealtimeRenderOnNodeTextEditConfigUpdate(e.openRealtimeRenderOnNodeTextEdit) : this.onOpenRealtimeRenderOnNodeTextEditConfigUpdate(e.openRealtimeRenderOnNodeTextEdit)), e.enableAutoEnterTextEditWhenKeydown !== t.enableAutoEnterTextEditWhenKeydown && window[e.enableAutoEnterTextEditWhenKeydown ? "addEventListener" : "removeEventListener"]("keydown", this.onKeydown);
|
|
1446
|
+
}), this.mindMap.on("afterExecCommand", () => {
|
|
1447
|
+
this.isShowTextEdit() && (this.isNeedUpdateTextEditNode = !0);
|
|
1448
|
+
}), this.mindMap.on("node_tree_render_end", () => {
|
|
1449
|
+
this.isShowTextEdit() && this.isNeedUpdateTextEditNode && (this.isNeedUpdateTextEditNode = !1, this.updateTextEditNode());
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
unBindEvent() {
|
|
1453
|
+
window.removeEventListener("keydown", this.onKeydown);
|
|
1454
|
+
}
|
|
1455
|
+
onKeydown(e) {
|
|
1456
|
+
if (e.target !== document.body) return;
|
|
1457
|
+
let t = this.mindMap.renderer.activeNodeList;
|
|
1458
|
+
if (t.length <= 0 || t.length > 1) return;
|
|
1459
|
+
let n = t[0];
|
|
1460
|
+
n && this.checkIsAutoEnterTextEditKey(e) && (e.preventDefault(), this.show({
|
|
1461
|
+
node: n,
|
|
1462
|
+
e,
|
|
1463
|
+
isInserting: !1,
|
|
1464
|
+
isFromKeyDown: !0
|
|
1465
|
+
}));
|
|
1466
|
+
}
|
|
1467
|
+
checkIsAutoEnterTextEditKey(e) {
|
|
1468
|
+
let t = e.keyCode;
|
|
1469
|
+
return (t === 229 || t >= 65 && t <= 90 || t >= 48 && t <= 57) && !this.mindMap.keyCommand.hasCombinationKey(e);
|
|
1470
|
+
}
|
|
1471
|
+
registerTmpShortcut() {
|
|
1472
|
+
this.mindMap.keyCommand.addShortcut("Enter", () => {
|
|
1473
|
+
this.hideEditTextBox();
|
|
1474
|
+
}), this.mindMap.keyCommand.addShortcut("Tab", () => {
|
|
1475
|
+
this.hideEditTextBox();
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
isShowTextEdit() {
|
|
1479
|
+
return this.mindMap.richText ? this.mindMap.richText.showTextEdit : this.showTextEdit;
|
|
1480
|
+
}
|
|
1481
|
+
setIsShowTextEdit(e) {
|
|
1482
|
+
this.showTextEdit = e, e ? this.mindMap.keyCommand.stopCheckInSvg() : this.mindMap.keyCommand.recoveryCheckInSvg();
|
|
1483
|
+
}
|
|
1484
|
+
async show({ node: e, isInserting: t = !1, isFromKeyDown: n = !1, isFromScale: r = !1 }) {
|
|
1485
|
+
if (e.isUseCustomNodeContent()) return;
|
|
1486
|
+
this.getCurrentEditNode() && this.hideEditTextBox();
|
|
1487
|
+
let { beforeTextEdit: i, openRealtimeRenderOnNodeTextEdit: a } = this.mindMap.opt;
|
|
1488
|
+
if (typeof i == "function") {
|
|
1489
|
+
let n = !1;
|
|
1490
|
+
try {
|
|
1491
|
+
n = await i(e, t);
|
|
1492
|
+
} catch (e) {
|
|
1493
|
+
n = !1, this.mindMap.opt.errorHandler(_.BEFORE_TEXT_EDIT_ERROR, e);
|
|
1494
|
+
}
|
|
1495
|
+
if (!n) return;
|
|
1496
|
+
}
|
|
1497
|
+
let { offsetLeft: o, offsetTop: s } = he(this.mindMap, e);
|
|
1498
|
+
this.mindMap.view.translateXY(o, s);
|
|
1499
|
+
let c = e._textData.node;
|
|
1500
|
+
a && c.show();
|
|
1501
|
+
let l = c.node.getBoundingClientRect();
|
|
1502
|
+
a && c.hide();
|
|
1503
|
+
let u = {
|
|
1504
|
+
node: e,
|
|
1505
|
+
rect: l,
|
|
1506
|
+
isInserting: t,
|
|
1507
|
+
isFromKeyDown: n,
|
|
1508
|
+
isFromScale: r
|
|
1509
|
+
};
|
|
1510
|
+
if (this.mindMap.richText) {
|
|
1511
|
+
this.mindMap.richText.showEditText(u);
|
|
1512
|
+
return;
|
|
1513
|
+
}
|
|
1514
|
+
this.currentNode = e, this.showEditTextBox(u);
|
|
1515
|
+
}
|
|
1516
|
+
onOpenRealtimeRenderOnNodeTextEditConfigUpdate(e) {
|
|
1517
|
+
this.textEditNode && (this.textEditNode.style.background = e ? "transparent" : this.currentNode ? this.getBackground(this.currentNode) : "", this.textEditNode.style.boxShadow = e ? "none" : "0 0 20px rgba(0,0,0,.5)");
|
|
1518
|
+
}
|
|
1519
|
+
onScale() {
|
|
1520
|
+
let e = this.getCurrentEditNode();
|
|
1521
|
+
e && (this.mindMap.richText ? (this.mindMap.richText.cacheEditingText = this.mindMap.richText.getEditText(), this.mindMap.richText.showTextEdit = !1) : (this.cacheEditingText = this.getEditText(), this.setIsShowTextEdit(!1)), this.show({
|
|
1522
|
+
node: e,
|
|
1523
|
+
isFromScale: !0
|
|
1524
|
+
}));
|
|
1525
|
+
}
|
|
1526
|
+
showEditTextBox({ node: e, rect: t, isInserting: n, isFromKeyDown: r, isFromScale: i }) {
|
|
1527
|
+
if (this.showTextEdit) return;
|
|
1528
|
+
let { nodeTextEditZIndex: a, textAutoWrapWidth: s, selectTextOnEnterEditText: c, openRealtimeRenderOnNodeTextEdit: l, autoEmptyTextWhenKeydownEnterEdit: u } = this.mindMap.opt;
|
|
1529
|
+
i || this.mindMap.emit("before_show_text_edit"), this.registerTmpShortcut(), this.textEditNode || (this.textEditNode = document.createElement("div"), this.textEditNode.classList.add(ke), this.textEditNode.style.cssText = `
|
|
1530
|
+
position: fixed;
|
|
1531
|
+
box-sizing: border-box;
|
|
1532
|
+
${l ? "" : "box-shadow: 0 0 20px rgba(0,0,0,.5);"}
|
|
1533
|
+
padding: ${this.textNodePaddingY}px ${this.textNodePaddingX}px;
|
|
1534
|
+
margin-left: -${this.textNodePaddingX}px;
|
|
1535
|
+
margin-top: -${this.textNodePaddingY}px;
|
|
1536
|
+
outline: none;
|
|
1537
|
+
word-break: break-all;
|
|
1538
|
+
line-break: anywhere;
|
|
1539
|
+
`, this.textEditNode.setAttribute("contenteditable", !0), this.textEditNode.addEventListener("keyup", (e) => {
|
|
1540
|
+
e.stopPropagation();
|
|
1541
|
+
}), this.textEditNode.addEventListener("click", (e) => {
|
|
1542
|
+
e.stopPropagation();
|
|
1543
|
+
}), this.textEditNode.addEventListener("mousedown", (e) => {
|
|
1544
|
+
e.stopPropagation();
|
|
1545
|
+
}), this.textEditNode.addEventListener("keydown", (e) => {
|
|
1546
|
+
this.checkIsAutoEnterTextEditKey(e) && e.stopPropagation();
|
|
1547
|
+
}), this.textEditNode.addEventListener("paste", (e) => {
|
|
1548
|
+
let { isSmm: t, data: n } = O(e.clipboardData.getData("text"));
|
|
1549
|
+
t && n[0] && n[0].data ? U(e, o(n[0].data.text)) : U(e), this.emitTextChangeEvent();
|
|
1550
|
+
}), this.textEditNode.addEventListener("input", () => {
|
|
1551
|
+
this.emitTextChangeEvent();
|
|
1552
|
+
}), (this.mindMap.opt.customInnerElsAppendTo || document.body).appendChild(this.textEditNode));
|
|
1553
|
+
let d = this.mindMap.view.scale, f = e.style.merge("fontSize"), p = (this.cacheEditingText || e.getData("text")).split(/\n/gim).map((e) => C(e)), m = e._textData.node.attr("data-ismultiLine") === "true";
|
|
1554
|
+
e.style.domText(this.textEditNode, d), l || (this.textEditNode.style.background = this.getBackground(e)), this.textEditNode.style.zIndex = a, r && u ? this.textEditNode.innerHTML = "" : this.textEditNode.innerHTML = p.join("<br>"), this.textEditNode.style.minWidth = t.width + this.textNodePaddingX * 2 + "px", this.textEditNode.style.minHeight = t.height + "px", this.textEditNode.style.left = Math.floor(t.left) + "px", this.textEditNode.style.top = Math.floor(t.top) + "px", this.textEditNode.style.display = "block", this.textEditNode.style.maxWidth = s * d + "px", m ? (this.textEditNode.style.lineHeight = h, this.textEditNode.style.transform = `translateY(${(h - 1) * f / 2 * d}px)`) : this.textEditNode.style.lineHeight = "normal", this.setIsShowTextEdit(!0), n || c && !r ? me(this.textEditNode) : b(this.textEditNode), this.cacheEditingText = "";
|
|
1555
|
+
}
|
|
1556
|
+
emitTextChangeEvent() {
|
|
1557
|
+
this.mindMap.emit("node_text_edit_change", {
|
|
1558
|
+
node: this.currentNode,
|
|
1559
|
+
text: this.getEditText(),
|
|
1560
|
+
richText: !1
|
|
1561
|
+
});
|
|
1562
|
+
}
|
|
1563
|
+
updateTextEditNode() {
|
|
1564
|
+
if (this.mindMap.richText) {
|
|
1565
|
+
this.mindMap.richText.updateTextEditNode();
|
|
1566
|
+
return;
|
|
1567
|
+
}
|
|
1568
|
+
if (!this.showTextEdit || !this.currentNode) return;
|
|
1569
|
+
let e = this.currentNode._textData.node.node.getBoundingClientRect();
|
|
1570
|
+
this.textEditNode.style.minWidth = e.width + this.textNodePaddingX * 2 + "px", this.textEditNode.style.minHeight = e.height + this.textNodePaddingY * 2 + "px", this.textEditNode.style.left = Math.floor(e.left) + "px", this.textEditNode.style.top = Math.floor(e.top) + "px";
|
|
1571
|
+
}
|
|
1572
|
+
getBackground(e) {
|
|
1573
|
+
if (e.style.merge("gradientStyle")) return `linear-gradient(to right, ${e.style.merge("startColor")}, ${e.style.merge("endColor")})`;
|
|
1574
|
+
{
|
|
1575
|
+
let t = e.style.merge("fillColor"), n = e.style.merge("color");
|
|
1576
|
+
return t === "transparent" ? fe(n) ? d(this.mindMap.themeConfig) : "#fff" : t;
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
removeTextEditEl() {
|
|
1580
|
+
if (this.mindMap.richText) {
|
|
1581
|
+
this.mindMap.richText.removeTextEditEl();
|
|
1582
|
+
return;
|
|
1583
|
+
}
|
|
1584
|
+
this.textEditNode && (this.mindMap.opt.customInnerElsAppendTo || document.body).removeChild(this.textEditNode);
|
|
1585
|
+
}
|
|
1586
|
+
getEditText() {
|
|
1587
|
+
return v(this.textEditNode.innerHTML);
|
|
1588
|
+
}
|
|
1589
|
+
hideEditTextBox() {
|
|
1590
|
+
if (this.mindMap.richText) return this.mindMap.richText.hideEditText();
|
|
1591
|
+
if (!this.showTextEdit) return;
|
|
1592
|
+
let e = this.currentNode, t = this.getEditText();
|
|
1593
|
+
this.currentNode = null, this.textEditNode.style.display = "none", this.textEditNode.innerHTML = "", this.textEditNode.style.fontFamily = "inherit", this.textEditNode.style.fontSize = "inherit", this.textEditNode.style.fontWeight = "normal", this.textEditNode.style.transform = "translateY(0)", this.setIsShowTextEdit(!1), this.mindMap.execCommand("SET_NODE_TEXT", e, t), this.mindMap.render(), this.mindMap.emit("hide_text_edit", this.textEditNode, this.renderer.activeNodeList, e);
|
|
1594
|
+
}
|
|
1595
|
+
getCurrentEditNode() {
|
|
1596
|
+
return this.mindMap.richText ? this.mindMap.richText.node : this.currentNode;
|
|
1597
|
+
}
|
|
1598
|
+
}, je = {
|
|
1599
|
+
[i.LAYOUT.LOGICAL_STRUCTURE]: we,
|
|
1600
|
+
[i.LAYOUT.LOGICAL_STRUCTURE_LEFT]: we,
|
|
1601
|
+
[i.LAYOUT.MIND_MAP]: Te,
|
|
1602
|
+
[i.LAYOUT.CATALOG_ORGANIZATION]: Ee,
|
|
1603
|
+
[i.LAYOUT.ORGANIZATION_STRUCTURE]: De,
|
|
1604
|
+
[i.LAYOUT.TIMELINE]: Oe,
|
|
1605
|
+
[i.LAYOUT.TIMELINE2]: Oe,
|
|
1606
|
+
[i.LAYOUT.VERTICAL_TIMELINE]: K,
|
|
1607
|
+
[i.LAYOUT.VERTICAL_TIMELINE2]: K,
|
|
1608
|
+
[i.LAYOUT.VERTICAL_TIMELINE3]: K,
|
|
1609
|
+
[i.LAYOUT.FISHBONE]: J,
|
|
1610
|
+
[i.LAYOUT.FISHBONE2]: J
|
|
1611
|
+
}, Me = class {
|
|
1612
|
+
constructor(e = {}) {
|
|
1613
|
+
this.opt = e, this.mindMap = e.mindMap, this.themeConfig = this.mindMap.themeConfig, this.renderTree = this.mindMap.opt.data ? (0, G.default)({}, this.mindMap.opt.data) : null, this.reRender = !1, this.isRendering = !1, this.hasWaitRendering = !1, this.nodeCache = {}, this.lastNodeCache = {}, this.renderSourceList = [], this.renderCallbackList = [], this.activeNodeList = [], this.emitNodeActiveEventTimer = null, this.renderTimer = null, this.root = null, this.textEdit = new Ae(this), this.beingCopyData = null, this.highlightBoxNode = null, this.highlightBoxNodeStyle = null, this.lastActiveNodeList = [], this.setLayout(), this.bindEvent(), this.registerCommands(), this.registerShortcutKeys();
|
|
1614
|
+
}
|
|
1615
|
+
setLayout() {
|
|
1616
|
+
this.layout && this.layout.beforeChange && this.layout.beforeChange();
|
|
1617
|
+
let { layout: e } = this.mindMap.opt, t = je[e] || this.mindMap[e];
|
|
1618
|
+
t || (t = je[i.LAYOUT.LOGICAL_STRUCTURE], this.mindMap.opt.layout = i.LAYOUT.LOGICAL_STRUCTURE), this.layout = new t(this, e);
|
|
1619
|
+
}
|
|
1620
|
+
setData(e) {
|
|
1621
|
+
this.renderTree = e || null;
|
|
1622
|
+
}
|
|
1623
|
+
bindEvent() {
|
|
1624
|
+
let { openPerformance: e, performanceConfig: t, openRealtimeRenderOnNodeTextEdit: n } = this.mindMap.opt;
|
|
1625
|
+
this.mindMap.on("draw_click", (e) => {
|
|
1626
|
+
this.clearActiveNodeListOnDrawClick(e, "click");
|
|
1627
|
+
}), this.mindMap.on("contextmenu", (e) => {
|
|
1628
|
+
this.clearActiveNodeListOnDrawClick(e, "contextmenu");
|
|
1629
|
+
}), this.mindMap.svg.on("dblclick", () => {
|
|
1630
|
+
this.mindMap.opt.enableDblclickBackToRootNode && this.setRootNodeCenter();
|
|
1631
|
+
});
|
|
1632
|
+
let r = k(() => {
|
|
1633
|
+
this.renderTree && this.root && (this.mindMap.emit("node_tree_render_start"), this.root.render(() => {
|
|
1634
|
+
this.mindMap.emit("node_tree_render_end");
|
|
1635
|
+
}, !1, !0));
|
|
1636
|
+
}, t.time);
|
|
1637
|
+
e && this.mindMap.on("view_data_change", r), this.onNodeTextEditChange = ge(this.onNodeTextEditChange, 100, this), n && this.mindMap.on("node_text_edit_change", this.onNodeTextEditChange), this.mindMap.on("after_update_config", (e, t) => {
|
|
1638
|
+
e.openPerformance !== t.openPerformance && (this.mindMap[e.openPerformance ? "on" : "off"]("view_data_change", r), this.forceLoadNode()), e.openRealtimeRenderOnNodeTextEdit !== t.openRealtimeRenderOnNodeTextEdit && this.mindMap[e.openRealtimeRenderOnNodeTextEdit ? "on" : "off"]("node_text_edit_change", this.onNodeTextEditChange);
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
onNodeTextEditChange({ node: e, text: t }) {
|
|
1642
|
+
e._textData = e.createTextNode(t);
|
|
1643
|
+
let { width: n, height: r } = e.getNodeRect();
|
|
1644
|
+
e.width = n, e.height = r, e.layout(), this.mindMap.render(() => {
|
|
1645
|
+
this.textEdit.updateTextEditNode();
|
|
1646
|
+
});
|
|
1647
|
+
}
|
|
1648
|
+
forceLoadNode(e) {
|
|
1649
|
+
e ||= this.root, e && (this.mindMap.emit("node_tree_render_start"), e.render(() => {
|
|
1650
|
+
this.mindMap.emit("node_tree_render_end");
|
|
1651
|
+
}, !0));
|
|
1652
|
+
}
|
|
1653
|
+
registerCommands() {
|
|
1654
|
+
this.selectAll = this.selectAll.bind(this), this.mindMap.command.add("SELECT_ALL", this.selectAll), this.back = this.back.bind(this), this.mindMap.command.add("BACK", this.back), this.forward = this.forward.bind(this), this.mindMap.command.add("FORWARD", this.forward), this.insertNode = this.insertNode.bind(this), this.mindMap.command.add("INSERT_NODE", this.insertNode), this.insertMultiNode = this.insertMultiNode.bind(this), this.mindMap.command.add("INSERT_MULTI_NODE", this.insertMultiNode), this.insertChildNode = this.insertChildNode.bind(this), this.mindMap.command.add("INSERT_CHILD_NODE", this.insertChildNode), this.insertMultiChildNode = this.insertMultiChildNode.bind(this), this.mindMap.command.add("INSERT_MULTI_CHILD_NODE", this.insertMultiChildNode), this.insertParentNode = this.insertParentNode.bind(this), this.mindMap.command.add("INSERT_PARENT_NODE", this.insertParentNode), this.upNode = this.upNode.bind(this), this.mindMap.command.add("UP_NODE", this.upNode), this.downNode = this.downNode.bind(this), this.mindMap.command.add("DOWN_NODE", this.downNode), this.moveUpOneLevel = this.moveUpOneLevel.bind(this), this.mindMap.command.add("MOVE_UP_ONE_LEVEL", this.moveUpOneLevel), this.insertAfter = this.insertAfter.bind(this), this.mindMap.command.add("INSERT_AFTER", this.insertAfter), this.insertBefore = this.insertBefore.bind(this), this.mindMap.command.add("INSERT_BEFORE", this.insertBefore), this.moveNodeTo = this.moveNodeTo.bind(this), this.mindMap.command.add("MOVE_NODE_TO", this.moveNodeTo), this.removeNode = this.removeNode.bind(this), this.mindMap.command.add("REMOVE_NODE", this.removeNode), this.removeCurrentNode = this.removeCurrentNode.bind(this), this.mindMap.command.add("REMOVE_CURRENT_NODE", this.removeCurrentNode), this.pasteNode = this.pasteNode.bind(this), this.mindMap.command.add("PASTE_NODE", this.pasteNode), this.cutNode = this.cutNode.bind(this), this.mindMap.command.add("CUT_NODE", this.cutNode), this.setNodeStyle = this.setNodeStyle.bind(this), this.mindMap.command.add("SET_NODE_STYLE", this.setNodeStyle), this.setNodeStyles = this.setNodeStyles.bind(this), this.mindMap.command.add("SET_NODE_STYLES", this.setNodeStyles), this.setNodeActive = this.setNodeActive.bind(this), this.mindMap.command.add("SET_NODE_ACTIVE", this.setNodeActive), this.clearActiveNode = this.clearActiveNode.bind(this), this.mindMap.command.add("CLEAR_ACTIVE_NODE", this.clearActiveNode), this.setNodeExpand = this.setNodeExpand.bind(this), this.mindMap.command.add("SET_NODE_EXPAND", this.setNodeExpand), this.expandAllNode = this.expandAllNode.bind(this), this.mindMap.command.add("EXPAND_ALL", this.expandAllNode), this.unexpandAllNode = this.unexpandAllNode.bind(this), this.mindMap.command.add("UNEXPAND_ALL", this.unexpandAllNode), this.expandToLevel = this.expandToLevel.bind(this), this.mindMap.command.add("UNEXPAND_TO_LEVEL", this.expandToLevel), this.setNodeData = this.setNodeData.bind(this), this.mindMap.command.add("SET_NODE_DATA", this.setNodeData), this.setNodeText = this.setNodeText.bind(this), this.mindMap.command.add("SET_NODE_TEXT", this.setNodeText), this.setNodeImage = this.setNodeImage.bind(this), this.mindMap.command.add("SET_NODE_IMAGE", this.setNodeImage), this.setNodeIcon = this.setNodeIcon.bind(this), this.mindMap.command.add("SET_NODE_ICON", this.setNodeIcon), this.setNodeHyperlink = this.setNodeHyperlink.bind(this), this.mindMap.command.add("SET_NODE_HYPERLINK", this.setNodeHyperlink), this.setNodeNote = this.setNodeNote.bind(this), this.mindMap.command.add("SET_NODE_NOTE", this.setNodeNote), this.setNodeAttachment = this.setNodeAttachment.bind(this), this.mindMap.command.add("SET_NODE_ATTACHMENT", this.setNodeAttachment), this.setNodeTag = this.setNodeTag.bind(this), this.mindMap.command.add("SET_NODE_TAG", this.setNodeTag), this.insertFormula = this.insertFormula.bind(this), this.mindMap.command.add("INSERT_FORMULA", this.insertFormula), this.addGeneralization = this.addGeneralization.bind(this), this.mindMap.command.add("ADD_GENERALIZATION", this.addGeneralization), this.removeGeneralization = this.removeGeneralization.bind(this), this.mindMap.command.add("REMOVE_GENERALIZATION", this.removeGeneralization), this.setNodeCustomPosition = this.setNodeCustomPosition.bind(this), this.mindMap.command.add("SET_NODE_CUSTOM_POSITION", this.setNodeCustomPosition), this.resetLayout = this.resetLayout.bind(this), this.mindMap.command.add("RESET_LAYOUT", this.resetLayout), this.setNodeShape = this.setNodeShape.bind(this), this.mindMap.command.add("SET_NODE_SHAPE", this.setNodeShape), this.goTargetNode = this.goTargetNode.bind(this), this.mindMap.command.add("GO_TARGET_NODE", this.goTargetNode), this.removeCustomStyles = this.removeCustomStyles.bind(this), this.mindMap.command.add("REMOVE_CUSTOM_STYLES", this.removeCustomStyles), this.removeAllNodeCustomStyles = this.removeAllNodeCustomStyles.bind(this), this.mindMap.command.add("REMOVE_ALL_NODE_CUSTOM_STYLES", this.removeAllNodeCustomStyles);
|
|
1655
|
+
}
|
|
1656
|
+
registerShortcutKeys() {
|
|
1657
|
+
this.mindMap.keyCommand.addShortcut("Tab", () => {
|
|
1658
|
+
this.mindMap.execCommand("INSERT_CHILD_NODE");
|
|
1659
|
+
}), this.mindMap.keyCommand.addShortcut("Insert", () => {
|
|
1660
|
+
this.mindMap.execCommand("INSERT_CHILD_NODE");
|
|
1661
|
+
}), this.mindMap.keyCommand.addShortcut("Enter", () => {
|
|
1662
|
+
this.mindMap.execCommand("INSERT_NODE");
|
|
1663
|
+
}), this.mindMap.keyCommand.addShortcut("Shift+Tab", () => {
|
|
1664
|
+
this.mindMap.execCommand("INSERT_PARENT_NODE");
|
|
1665
|
+
}), this.mindMap.keyCommand.addShortcut("Control+g", () => {
|
|
1666
|
+
this.mindMap.execCommand("ADD_GENERALIZATION");
|
|
1667
|
+
}), this.toggleActiveExpand = this.toggleActiveExpand.bind(this), this.mindMap.keyCommand.addShortcut("/", this.toggleActiveExpand), this.mindMap.keyCommand.addShortcut("Del|Backspace", () => {
|
|
1668
|
+
this.mindMap.execCommand("REMOVE_NODE");
|
|
1669
|
+
}), this.mindMap.keyCommand.addShortcut("Shift+Backspace", () => {
|
|
1670
|
+
this.mindMap.execCommand("REMOVE_CURRENT_NODE");
|
|
1671
|
+
}), this.mindMap.on("before_show_text_edit", () => {
|
|
1672
|
+
this.startTextEdit();
|
|
1673
|
+
}), this.mindMap.on("hide_text_edit", () => {
|
|
1674
|
+
this.endTextEdit();
|
|
1675
|
+
}), this.mindMap.keyCommand.addShortcut("Control+a", () => {
|
|
1676
|
+
this.mindMap.execCommand("SELECT_ALL");
|
|
1677
|
+
}), this.mindMap.keyCommand.addShortcut("Control+l", () => {
|
|
1678
|
+
this.mindMap.execCommand("RESET_LAYOUT");
|
|
1679
|
+
}), this.mindMap.keyCommand.addShortcut("Control+Up", () => {
|
|
1680
|
+
this.mindMap.execCommand("UP_NODE");
|
|
1681
|
+
}), this.mindMap.keyCommand.addShortcut("Control+Down", () => {
|
|
1682
|
+
this.mindMap.execCommand("DOWN_NODE");
|
|
1683
|
+
}), this.mindMap.keyCommand.addShortcut("Control+c", () => {
|
|
1684
|
+
this.copy();
|
|
1685
|
+
}), this.mindMap.keyCommand.addShortcut("Control+x", () => {
|
|
1686
|
+
this.cut();
|
|
1687
|
+
}), this.mindMap.keyCommand.addShortcut("Control+v", () => {
|
|
1688
|
+
this.paste();
|
|
1689
|
+
}), this.mindMap.keyCommand.addShortcut("Control+Enter", () => {
|
|
1690
|
+
this.setRootNodeCenter();
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
emitNodeActiveEvent(e = null, t = [...this.activeNodeList]) {
|
|
1694
|
+
se(this.lastActiveNodeList, t) || (this.lastActiveNodeList = [...t], clearTimeout(this.emitNodeActiveEventTimer), this.emitNodeActiveEventTimer = setTimeout(() => {
|
|
1695
|
+
this.mindMap.emit("node_active", e, t);
|
|
1696
|
+
}, 0));
|
|
1697
|
+
}
|
|
1698
|
+
clearActiveNodeListOnDrawClick(e, t) {
|
|
1699
|
+
if (this.activeNodeList.length <= 0) return;
|
|
1700
|
+
let n = !0, { useLeftKeySelectionRightKeyDrag: r } = this.mindMap.opt;
|
|
1701
|
+
if (t === "contextmenu" ? !r : r) {
|
|
1702
|
+
let t = this.mindMap.event.mousedownPos;
|
|
1703
|
+
n = Math.abs(e.clientX - t.x) <= 5 && Math.abs(e.clientY - t.y) <= 5;
|
|
1704
|
+
}
|
|
1705
|
+
n && this.mindMap.execCommand("CLEAR_ACTIVE_NODE");
|
|
1706
|
+
}
|
|
1707
|
+
startTextEdit() {
|
|
1708
|
+
this.mindMap.keyCommand.save();
|
|
1709
|
+
}
|
|
1710
|
+
endTextEdit() {
|
|
1711
|
+
this.mindMap.keyCommand.restore();
|
|
1712
|
+
}
|
|
1713
|
+
clearCache() {
|
|
1714
|
+
this.layout.lru.clear(), this.nodeCache = {}, this.lastNodeCache = {};
|
|
1715
|
+
}
|
|
1716
|
+
addRenderParams(e, t) {
|
|
1717
|
+
e && this.renderCallbackList.findIndex((t) => t === e) === -1 && this.renderCallbackList.push(e), t && this.renderSourceList.findIndex((e) => e === t) === -1 && this.renderSourceList.push(t);
|
|
1718
|
+
}
|
|
1719
|
+
checkHasRenderSource(e) {
|
|
1720
|
+
e = Array.isArray(e) ? e : [e];
|
|
1721
|
+
for (let t = 0; t < this.renderSourceList.length; t++) if (e.includes(this.renderSourceList[t])) return !0;
|
|
1722
|
+
return !1;
|
|
1723
|
+
}
|
|
1724
|
+
onRenderEnd() {
|
|
1725
|
+
this.renderCallbackList.forEach((e) => {
|
|
1726
|
+
e();
|
|
1727
|
+
}), this.isRendering = !1, this.reRender = !1, this.renderCallbackList = [], this.renderSourceList = [], this.mindMap.emit("node_tree_render_end");
|
|
1728
|
+
}
|
|
1729
|
+
render(e, t) {
|
|
1730
|
+
this.addRenderParams(e, t), clearTimeout(this.renderTimer), this.renderTimer = setTimeout(() => {
|
|
1731
|
+
this._render();
|
|
1732
|
+
}, 0);
|
|
1733
|
+
}
|
|
1734
|
+
_render() {
|
|
1735
|
+
if (this.checkHasRenderSource(i.CHANGE_THEME) && this.resetUnExpandNodeStyle(), this.isRendering) {
|
|
1736
|
+
this.hasWaitRendering = !0;
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
if (this.isRendering = !0, this.lastNodeCache = this.nodeCache, this.nodeCache = {}, this.reRender && this.clearActiveNodeList(), !this.renderTree) {
|
|
1740
|
+
this.onRenderEnd();
|
|
1741
|
+
return;
|
|
1742
|
+
}
|
|
1743
|
+
this.mindMap.emit("node_tree_render_start"), this.root = null, this.layout.doLayout((e) => {
|
|
1744
|
+
Object.keys(this.lastNodeCache).forEach((e) => {
|
|
1745
|
+
this.nodeCache[e] || (this.removeNodeFromActiveList(this.lastNodeCache[e]), this.emitNodeActiveEvent(), this.lastNodeCache[e].destroy());
|
|
1746
|
+
}), this.root = e, this.root.render(() => {
|
|
1747
|
+
if (this.isRendering = !1, this.hasWaitRendering) {
|
|
1748
|
+
this.hasWaitRendering = !1, this.render();
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
this.onRenderEnd();
|
|
1752
|
+
});
|
|
1753
|
+
}), this.emitNodeActiveEvent();
|
|
1754
|
+
}
|
|
1755
|
+
renderByCustomNodeContentNode(e) {
|
|
1756
|
+
e.getSize(), e.customNodeContentRealtimeLayout(), this.mindMap.render();
|
|
1757
|
+
}
|
|
1758
|
+
resetUnExpandNodeStyle() {
|
|
1759
|
+
this.renderTree && F(this.renderTree, null, (e) => {
|
|
1760
|
+
if (!e.data.expand) return F(e, null, (e) => {
|
|
1761
|
+
e.data.needUpdate = !0;
|
|
1762
|
+
}), !0;
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
clearActiveNode() {
|
|
1766
|
+
this.activeNodeList.length <= 0 || (this.clearActiveNodeList(), this.emitNodeActiveEvent(null, []));
|
|
1767
|
+
}
|
|
1768
|
+
clearActiveNodeList() {
|
|
1769
|
+
this.activeNodeList.forEach((e) => {
|
|
1770
|
+
this.mindMap.execCommand("SET_NODE_ACTIVE", e, !1);
|
|
1771
|
+
}), this.activeNodeList = [];
|
|
1772
|
+
}
|
|
1773
|
+
addNodeToActiveList(e, t = !1) {
|
|
1774
|
+
this.mindMap.opt.onlyOneEnableActiveNodeOnCooperate && e.userList.length > 0 || this.findActiveNodeIndex(e) === -1 && (t || this.mindMap.emit("before_node_active", e, this.activeNodeList), this.mindMap.execCommand("SET_NODE_ACTIVE", e, !0), this.activeNodeList.push(e));
|
|
1775
|
+
}
|
|
1776
|
+
removeNodeFromActiveList(e) {
|
|
1777
|
+
let t = this.findActiveNodeIndex(e);
|
|
1778
|
+
t !== -1 && (this.mindMap.execCommand("SET_NODE_ACTIVE", e, !1), this.activeNodeList.splice(t, 1));
|
|
1779
|
+
}
|
|
1780
|
+
activeMultiNode(e = []) {
|
|
1781
|
+
e.forEach((e) => {
|
|
1782
|
+
this.mindMap.emit("before_node_active", e, this.activeNodeList), this.addNodeToActiveList(e, !0), this.emitNodeActiveEvent(e);
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
cancelActiveMultiNode(e = []) {
|
|
1786
|
+
e.forEach((e) => {
|
|
1787
|
+
this.removeNodeFromActiveList(e), this.emitNodeActiveEvent(null);
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
findActiveNodeIndex(e) {
|
|
1791
|
+
return N(e, this.activeNodeList);
|
|
1792
|
+
}
|
|
1793
|
+
selectAll() {
|
|
1794
|
+
this.mindMap.opt.readonly || (F(this.root, null, (e) => {
|
|
1795
|
+
e.getData("isActive") || this.addNodeToActiveList(e), e._generalizationList && e._generalizationList.length > 0 && e._generalizationList.forEach((e) => {
|
|
1796
|
+
let t = e.generalizationNode;
|
|
1797
|
+
t.getData("isActive") || this.addNodeToActiveList(t);
|
|
1798
|
+
});
|
|
1799
|
+
}, null, !0, 0, 0), this.emitNodeActiveEvent());
|
|
1800
|
+
}
|
|
1801
|
+
back(e) {
|
|
1802
|
+
this.backForward("back", e);
|
|
1803
|
+
}
|
|
1804
|
+
forward(e) {
|
|
1805
|
+
this.backForward("forward", e);
|
|
1806
|
+
}
|
|
1807
|
+
backForward(e, t) {
|
|
1808
|
+
this.mindMap.execCommand("CLEAR_ACTIVE_NODE");
|
|
1809
|
+
let n = this.mindMap.command[e](t);
|
|
1810
|
+
n && (this.renderTree = n, this.mindMap.render()), this.mindMap.emit("data_change", n);
|
|
1811
|
+
}
|
|
1812
|
+
getNewNodeBehavior(e = !1, t = !1) {
|
|
1813
|
+
let { createNewNodeBehavior: n } = this.mindMap.opt, r = !1, a = !1;
|
|
1814
|
+
switch (n) {
|
|
1815
|
+
case i.CREATE_NEW_NODE_BEHAVIOR.DEFAULT:
|
|
1816
|
+
r = t || !e, a = t ? !1 : e;
|
|
1817
|
+
break;
|
|
1818
|
+
case i.CREATE_NEW_NODE_BEHAVIOR.NOT_ACTIVE:
|
|
1819
|
+
r = !1, a = !1;
|
|
1820
|
+
break;
|
|
1821
|
+
case i.CREATE_NEW_NODE_BEHAVIOR.ACTIVE_ONLY:
|
|
1822
|
+
r = !0, a = !1;
|
|
1823
|
+
break;
|
|
1824
|
+
default: break;
|
|
1825
|
+
}
|
|
1826
|
+
return {
|
|
1827
|
+
focusNewNode: r,
|
|
1828
|
+
inserting: a
|
|
1829
|
+
};
|
|
1830
|
+
}
|
|
1831
|
+
insertNode(e = !0, n = [], r = null, i = []) {
|
|
1832
|
+
if (n = t(n), this.activeNodeList.length <= 0 && n.length <= 0) return;
|
|
1833
|
+
this.textEdit.hideEditTextBox();
|
|
1834
|
+
let { defaultInsertSecondLevelNodeText: a, defaultInsertBelowSecondLevelNodeText: o } = this.mindMap.opt, s = n.length > 0 ? n : this.activeNodeList, c = s.length > 1, l = this.hasRichTextPlugin(), { focusNewNode: u, inserting: d } = this.getNewNodeBehavior(e, c), f = {
|
|
1835
|
+
expand: !0,
|
|
1836
|
+
richText: l,
|
|
1837
|
+
isActive: u
|
|
1838
|
+
};
|
|
1839
|
+
l && (f.resetRichText = !0), i = L(i, f);
|
|
1840
|
+
let p = r && r.richText, m = !1;
|
|
1841
|
+
s.forEach((e) => {
|
|
1842
|
+
if (e.isGeneralization || e.isRoot) return;
|
|
1843
|
+
i = P(i);
|
|
1844
|
+
let t = e.parent, n = e.layerIndex === 1 ? a : o, s = g(e);
|
|
1845
|
+
p && f.resetRichText && delete f.resetRichText;
|
|
1846
|
+
let c = {
|
|
1847
|
+
inserting: d,
|
|
1848
|
+
data: {
|
|
1849
|
+
text: n,
|
|
1850
|
+
...f,
|
|
1851
|
+
uid: T(),
|
|
1852
|
+
...r || {}
|
|
1853
|
+
},
|
|
1854
|
+
children: [...B(i, m)]
|
|
1855
|
+
};
|
|
1856
|
+
m = !0, t.nodeData.children.splice(s + 1, 0, c);
|
|
1857
|
+
}), u && this.clearActiveNodeList(), this.mindMap.render();
|
|
1858
|
+
}
|
|
1859
|
+
insertMultiNode(e, n) {
|
|
1860
|
+
if (!n || n.length <= 0 || (e = t(e), this.activeNodeList.length <= 0 && e.length <= 0)) return;
|
|
1861
|
+
this.textEdit.hideEditTextBox();
|
|
1862
|
+
let r = e.length > 0 ? e : this.activeNodeList, i = this.hasRichTextPlugin(), { focusNewNode: a } = this.getNewNodeBehavior(!1, !0), o = {
|
|
1863
|
+
expand: !0,
|
|
1864
|
+
richText: i,
|
|
1865
|
+
isActive: a
|
|
1866
|
+
};
|
|
1867
|
+
i && (o.resetRichText = !0), n = L(n, o);
|
|
1868
|
+
let s = !1;
|
|
1869
|
+
r.forEach((e) => {
|
|
1870
|
+
if (e.isGeneralization || e.isRoot) return;
|
|
1871
|
+
n = P(n);
|
|
1872
|
+
let t = e.parent, r = g(e), i = B(n, s);
|
|
1873
|
+
s = !0, t.nodeData.children.splice(r + 1, 0, ...i);
|
|
1874
|
+
}), a && this.clearActiveNodeList(), this.mindMap.render();
|
|
1875
|
+
}
|
|
1876
|
+
insertChildNode(e = !0, n = [], r = null, i = []) {
|
|
1877
|
+
if (n = t(n), this.activeNodeList.length <= 0 && n.length <= 0) return;
|
|
1878
|
+
this.textEdit.hideEditTextBox();
|
|
1879
|
+
let { defaultInsertSecondLevelNodeText: a, defaultInsertBelowSecondLevelNodeText: o } = this.mindMap.opt, s = n.length > 0 ? n : this.activeNodeList, c = s.length > 1, l = this.hasRichTextPlugin(), { focusNewNode: u, inserting: d } = this.getNewNodeBehavior(e, c), f = {
|
|
1880
|
+
expand: !0,
|
|
1881
|
+
richText: l,
|
|
1882
|
+
isActive: u
|
|
1883
|
+
};
|
|
1884
|
+
l && (f.resetRichText = !0), i = L(i, f);
|
|
1885
|
+
let p = r && r.richText, m = !1;
|
|
1886
|
+
s.forEach((e) => {
|
|
1887
|
+
if (e.isGeneralization) return;
|
|
1888
|
+
i = P(i), e.nodeData.children || (e.nodeData.children = []);
|
|
1889
|
+
let t = e.isRoot ? a : o;
|
|
1890
|
+
p && f.resetRichText && delete f.resetRichText;
|
|
1891
|
+
let n = {
|
|
1892
|
+
inserting: d,
|
|
1893
|
+
data: {
|
|
1894
|
+
text: t,
|
|
1895
|
+
uid: T(),
|
|
1896
|
+
...f,
|
|
1897
|
+
...r || {}
|
|
1898
|
+
},
|
|
1899
|
+
children: [...B(i, m)]
|
|
1900
|
+
};
|
|
1901
|
+
m = !0, e.nodeData.children.push(n), e.setData({ expand: !0 });
|
|
1902
|
+
}), u && this.clearActiveNodeList(), this.mindMap.render();
|
|
1903
|
+
}
|
|
1904
|
+
insertMultiChildNode(e, n) {
|
|
1905
|
+
if (!n || n.length <= 0 || (e = t(e), this.activeNodeList.length <= 0 && e.length <= 0)) return;
|
|
1906
|
+
this.textEdit.hideEditTextBox();
|
|
1907
|
+
let r = e.length > 0 ? e : this.activeNodeList, i = this.hasRichTextPlugin(), { focusNewNode: a } = this.getNewNodeBehavior(!1, !0), o = {
|
|
1908
|
+
expand: !0,
|
|
1909
|
+
richText: i,
|
|
1910
|
+
isActive: a
|
|
1911
|
+
};
|
|
1912
|
+
i && (o.resetRichText = !0), n = L(n, o);
|
|
1913
|
+
let s = !1;
|
|
1914
|
+
r.forEach((e) => {
|
|
1915
|
+
e.isGeneralization || (n = P(n), e.nodeData.children || (e.nodeData.children = []), n = B(n, s), s = !0, e.nodeData.children.push(...n), e.setData({ expand: !0 }));
|
|
1916
|
+
}), a && this.clearActiveNodeList(), this.mindMap.render();
|
|
1917
|
+
}
|
|
1918
|
+
insertParentNode(e = !0, n, r) {
|
|
1919
|
+
if (n = t(n), this.activeNodeList.length <= 0 && n.length <= 0) return;
|
|
1920
|
+
this.textEdit.hideEditTextBox();
|
|
1921
|
+
let { defaultInsertSecondLevelNodeText: i, defaultInsertBelowSecondLevelNodeText: a } = this.mindMap.opt, o = n.length > 0 ? n : this.activeNodeList, s = o.length > 1, c = this.hasRichTextPlugin(), { focusNewNode: l, inserting: u } = this.getNewNodeBehavior(e, s), d = {
|
|
1922
|
+
expand: !0,
|
|
1923
|
+
richText: c,
|
|
1924
|
+
isActive: l
|
|
1925
|
+
};
|
|
1926
|
+
c && (d.resetRichText = !0);
|
|
1927
|
+
let f = r && r.richText;
|
|
1928
|
+
o.forEach((e) => {
|
|
1929
|
+
if (e.isGeneralization || e.isRoot) return;
|
|
1930
|
+
let t = e.layerIndex === 1 ? i : a;
|
|
1931
|
+
f && d.resetRichText && delete d.resetRichText;
|
|
1932
|
+
let n = {
|
|
1933
|
+
inserting: u,
|
|
1934
|
+
data: {
|
|
1935
|
+
text: t,
|
|
1936
|
+
uid: T(),
|
|
1937
|
+
...d,
|
|
1938
|
+
...r || {}
|
|
1939
|
+
},
|
|
1940
|
+
children: [e.nodeData]
|
|
1941
|
+
}, o = e.parent, s = g(e);
|
|
1942
|
+
o.nodeData.children.splice(s, 1, n);
|
|
1943
|
+
}), l && this.clearActiveNodeList(), this.mindMap.render();
|
|
1944
|
+
}
|
|
1945
|
+
upNode(e) {
|
|
1946
|
+
if (this.activeNodeList.length <= 0 && !e) return;
|
|
1947
|
+
let t = (e ? [e] : this.activeNodeList)[0];
|
|
1948
|
+
if (t.isRoot) return;
|
|
1949
|
+
let n = t.parent, r = n.children, i = N(t, r);
|
|
1950
|
+
if (i === -1 || i === 0) return;
|
|
1951
|
+
let a = i - 1;
|
|
1952
|
+
r.splice(i, 1), r.splice(a, 0, t), n.nodeData.children.splice(i, 1), n.nodeData.children.splice(a, 0, t.nodeData), this.mindMap.render();
|
|
1953
|
+
}
|
|
1954
|
+
downNode(e) {
|
|
1955
|
+
if (this.activeNodeList.length <= 0 && !e) return;
|
|
1956
|
+
let t = (e ? [e] : this.activeNodeList)[0];
|
|
1957
|
+
if (t.isRoot) return;
|
|
1958
|
+
let n = t.parent, r = n.children, i = N(t, r);
|
|
1959
|
+
if (i === -1 || i === r.length - 1) return;
|
|
1960
|
+
let a = i + 1;
|
|
1961
|
+
r.splice(i, 1), r.splice(a, 0, t), n.nodeData.children.splice(i, 1), n.nodeData.children.splice(a, 0, t.nodeData), this.mindMap.render();
|
|
1962
|
+
}
|
|
1963
|
+
moveUpOneLevel(e) {
|
|
1964
|
+
if (e ||= this.activeNodeList[0], !e || e.isRoot || e.layerIndex <= 1) return;
|
|
1965
|
+
let t = e.parent, n = t.parent, r = N(e, t.children), i = N(t, n.children);
|
|
1966
|
+
t.nodeData.children.splice(r, 1), n.nodeData.children.splice(i + 1, 0, e.nodeData), this.mindMap.render();
|
|
1967
|
+
}
|
|
1968
|
+
_handleRemoveCustomStyles(e) {
|
|
1969
|
+
let t = !1;
|
|
1970
|
+
return Object.keys(e).forEach((n) => {
|
|
1971
|
+
pe(n) && (t = !0, delete e[n]);
|
|
1972
|
+
}), this.hasRichTextPlugin() && (t = !0, e.resetRichText = !0), t;
|
|
1973
|
+
}
|
|
1974
|
+
removeCustomStyles(e) {
|
|
1975
|
+
e ||= this.activeNodeList[0], e && this._handleRemoveCustomStyles(e.getData()) && this.reRenderNodeCheckChange(e);
|
|
1976
|
+
}
|
|
1977
|
+
removeAllNodeCustomStyles(e) {
|
|
1978
|
+
e = t(e);
|
|
1979
|
+
let n = !1;
|
|
1980
|
+
if (e.length > 0) e.forEach((e) => {
|
|
1981
|
+
this._handleRemoveCustomStyles(e.getData()) && (n = !0);
|
|
1982
|
+
});
|
|
1983
|
+
else {
|
|
1984
|
+
if (!this.renderTree) return;
|
|
1985
|
+
F(this.renderTree, null, (e) => {
|
|
1986
|
+
this._handleRemoveCustomStyles(e.data) && (n = !0);
|
|
1987
|
+
let t = V(e.data);
|
|
1988
|
+
t.length > 0 && t.forEach((e) => {
|
|
1989
|
+
this._handleRemoveCustomStyles(e) && (n = !0);
|
|
1990
|
+
});
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
n && this.mindMap.reRender();
|
|
1994
|
+
}
|
|
1995
|
+
copy() {
|
|
1996
|
+
this.beingCopyData = this.copyNode(), this.beingCopyData && (this.mindMap.opt.disabledClipboard || D(j(this.beingCopyData)));
|
|
1997
|
+
}
|
|
1998
|
+
cut() {
|
|
1999
|
+
this.mindMap.execCommand("CUT_NODE", (e) => {
|
|
2000
|
+
this.beingCopyData = e, this.mindMap.opt.disabledClipboard || D(j(e));
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
handlePaste(e) {
|
|
2004
|
+
let { disabledClipboard: t } = this.mindMap.opt;
|
|
2005
|
+
if (t) return;
|
|
2006
|
+
let n = e.clipboardData || e.originalEvent.clipboardData, r = n.items;
|
|
2007
|
+
Array.from(r).forEach((e) => {
|
|
2008
|
+
e.type.indexOf("image") > -1 && e.getAsFile(), e.type.indexOf("text") > -1 && n.getData("text");
|
|
2009
|
+
}), this.paste();
|
|
2010
|
+
}
|
|
2011
|
+
async paste() {
|
|
2012
|
+
let { errorHandler: e, handleIsSplitByWrapOnPasteCreateNewNode: t, handleNodePasteImg: n, disabledClipboard: i, onlyPasteTextWhenHasImgAndText: a } = this.mindMap.opt;
|
|
2013
|
+
if (!i && ue()) try {
|
|
2014
|
+
let i = await r(), o = i.text || "", s = i.img || null;
|
|
2015
|
+
if (o) {
|
|
2016
|
+
let n = null, r = !0;
|
|
2017
|
+
if (this.mindMap.opt.customHandleClipboardText) try {
|
|
2018
|
+
let e = await this.mindMap.opt.customHandleClipboardText(o);
|
|
2019
|
+
if (!u(e)) {
|
|
2020
|
+
r = !1;
|
|
2021
|
+
let t = O(e);
|
|
2022
|
+
t.isSmm ? n = t.data : o = t.data;
|
|
2023
|
+
}
|
|
2024
|
+
} catch (t) {
|
|
2025
|
+
e(_.CUSTOM_HANDLE_CLIPBOARD_TEXT_ERROR, t);
|
|
2026
|
+
}
|
|
2027
|
+
if (r) {
|
|
2028
|
+
let e = O(o);
|
|
2029
|
+
e.isSmm ? n = e.data : o = e.data;
|
|
2030
|
+
}
|
|
2031
|
+
if (n) this.mindMap.execCommand("INSERT_MULTI_CHILD_NODE", [], Array.isArray(n) ? n : [n]);
|
|
2032
|
+
else {
|
|
2033
|
+
this.hasRichTextPlugin() && (o = C(o));
|
|
2034
|
+
let e = o.split(/* @__PURE__ */ RegExp("\r?\n|(?<!\n)\r", "g")).filter((e) => !!e);
|
|
2035
|
+
e.length > 1 && t ? t().then(() => {
|
|
2036
|
+
this.mindMap.execCommand("INSERT_MULTI_CHILD_NODE", [], e.map((e) => ({
|
|
2037
|
+
data: { text: e },
|
|
2038
|
+
children: []
|
|
2039
|
+
})));
|
|
2040
|
+
}).catch(() => {
|
|
2041
|
+
this.mindMap.execCommand("INSERT_CHILD_NODE", !1, [], { text: o });
|
|
2042
|
+
}) : this.mindMap.execCommand("INSERT_CHILD_NODE", !1, [], { text: o });
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
if (s && (!o || !a)) try {
|
|
2046
|
+
let e = null;
|
|
2047
|
+
e = n && typeof n == "function" ? await n(s) : await l(s), this.activeNodeList.length > 0 && this.activeNodeList.forEach((t) => {
|
|
2048
|
+
this.mindMap.execCommand("SET_NODE_IMAGE", t, {
|
|
2049
|
+
url: e.url,
|
|
2050
|
+
title: "",
|
|
2051
|
+
width: e.size.width,
|
|
2052
|
+
height: e.size.height
|
|
2053
|
+
});
|
|
2054
|
+
});
|
|
2055
|
+
} catch (t) {
|
|
2056
|
+
e(_.LOAD_CLIPBOARD_IMAGE_ERROR, t);
|
|
2057
|
+
}
|
|
2058
|
+
} catch (t) {
|
|
2059
|
+
e(_.READ_CLIPBOARD_ERROR, t);
|
|
2060
|
+
}
|
|
2061
|
+
else this.beingCopyData && this.mindMap.execCommand("PASTE_NODE", this.beingCopyData);
|
|
2062
|
+
}
|
|
2063
|
+
insertBefore(e, t) {
|
|
2064
|
+
this.insertTo(e, t, "before");
|
|
2065
|
+
}
|
|
2066
|
+
insertAfter(e, t) {
|
|
2067
|
+
this.insertTo(e, t, "after");
|
|
2068
|
+
}
|
|
2069
|
+
insertTo(e, n, r = "before") {
|
|
2070
|
+
let i = t(e);
|
|
2071
|
+
i = i.filter((e) => !e.isRoot), r === "after" && i.reverse(), i.forEach((e) => {
|
|
2072
|
+
let t = e.parent, i = t.children, a = N(e, i);
|
|
2073
|
+
if (a === -1) return;
|
|
2074
|
+
i.splice(a, 1), t.nodeData.children.splice(a, 1);
|
|
2075
|
+
let o = n.parent, s = o.children, c = N(n, s);
|
|
2076
|
+
c !== -1 && (r === "after" && c++, s.splice(c, 0, e), o.nodeData.children.splice(c, 0, e.nodeData));
|
|
2077
|
+
}), this.mindMap.render();
|
|
2078
|
+
}
|
|
2079
|
+
removeNode(e = []) {
|
|
2080
|
+
if (e = t(e), this.activeNodeList.length <= 0 && e.length <= 0) return;
|
|
2081
|
+
let n = null, r = e.length > 0, i = r ? e : this.activeNodeList, a = i.find((e) => e.isRoot);
|
|
2082
|
+
if (a) this.clearActiveNodeList(), a.children = [], a.nodeData.children = [];
|
|
2083
|
+
else {
|
|
2084
|
+
n = this.getNextActiveNode(i);
|
|
2085
|
+
for (let e = 0; e < i.length; e++) {
|
|
2086
|
+
let t = i[e], n = this.textEdit.getCurrentEditNode();
|
|
2087
|
+
n && n.getData("uid") === t.getData("uid") && this.textEdit.hideEditTextBox(), r && i.splice(e, 1), t.isGeneralization ? (this.deleteNodeGeneralization(t), this.removeNodeFromActiveList(t), e--) : (this.removeNodeFromActiveList(t), R(t), e--);
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
this.activeNodeList = [], n && this.addNodeToActiveList(n), this.emitNodeActiveEvent(), this.mindMap.render();
|
|
2091
|
+
}
|
|
2092
|
+
deleteNodeGeneralization(e) {
|
|
2093
|
+
let t = e.generalizationBelongNode, n = t.getGeneralizationNodeIndex(e), r = t.getData("generalization");
|
|
2094
|
+
Array.isArray(r) ? r.splice(n, 1) : r = null, this.mindMap.execCommand("SET_NODE_DATA", t, { generalization: r }), this.closeHighlightNode();
|
|
2095
|
+
}
|
|
2096
|
+
removeCurrentNode(e = []) {
|
|
2097
|
+
if (e = t(e), this.activeNodeList.length <= 0 && e.length <= 0) return;
|
|
2098
|
+
let n = e.length > 0 ? e : this.activeNodeList;
|
|
2099
|
+
n = n.filter((e) => !e.isRoot);
|
|
2100
|
+
let r = this.getNextActiveNode(n);
|
|
2101
|
+
for (let e = 0; e < n.length; e++) {
|
|
2102
|
+
let t = n[e];
|
|
2103
|
+
if (t.isGeneralization) this.deleteNodeGeneralization(t);
|
|
2104
|
+
else {
|
|
2105
|
+
let e = t.parent, n = g(t);
|
|
2106
|
+
e.nodeData.children.splice(n, 1, ...t.nodeData.children || []);
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
this.activeNodeList = [], r && this.addNodeToActiveList(r), this.emitNodeActiveEvent(), this.mindMap.render();
|
|
2110
|
+
}
|
|
2111
|
+
getNextActiveNode(e) {
|
|
2112
|
+
if (e.length !== 1 || this.findActiveNodeIndex(e[0]) === -1) return null;
|
|
2113
|
+
let t = null;
|
|
2114
|
+
if (this.activeNodeList.length === 1 && !this.activeNodeList[0].isGeneralization && this.mindMap.opt.deleteNodeActive) {
|
|
2115
|
+
let e = this.activeNodeList[0], n = e.parent.children, r = N(e, n);
|
|
2116
|
+
t = r < n.length - 1 ? n[r + 1] : r > 0 ? n[r - 1] : e.parent;
|
|
2117
|
+
}
|
|
2118
|
+
return t;
|
|
2119
|
+
}
|
|
2120
|
+
copyNode() {
|
|
2121
|
+
if (this.activeNodeList.length <= 0) return null;
|
|
2122
|
+
let e = s(this.activeNodeList);
|
|
2123
|
+
return e = z(e), e.map((e) => de({}, e, !0));
|
|
2124
|
+
}
|
|
2125
|
+
cutNode(e) {
|
|
2126
|
+
if (this.activeNodeList.length <= 0) return;
|
|
2127
|
+
let t = s(this.activeNodeList).filter((e) => !e.isRoot);
|
|
2128
|
+
t = z(t);
|
|
2129
|
+
let n = t.map((e) => de({}, e, !0));
|
|
2130
|
+
t.forEach((e) => {
|
|
2131
|
+
R(e);
|
|
2132
|
+
}), this.clearActiveNodeList(), this.mindMap.render(), e && typeof e == "function" && e(n);
|
|
2133
|
+
}
|
|
2134
|
+
moveNodeTo(e, n) {
|
|
2135
|
+
let r = t(e);
|
|
2136
|
+
r = r.filter((e) => !e.isRoot), r.forEach((e) => {
|
|
2137
|
+
this.removeNodeFromActiveList(e), R(e), n.setData({ expand: !0 }), n.nodeData.children.push(e.nodeData);
|
|
2138
|
+
}), this.emitNodeActiveEvent(), this.mindMap.render();
|
|
2139
|
+
}
|
|
2140
|
+
pasteNode(e) {
|
|
2141
|
+
e = t(e), this.mindMap.execCommand("INSERT_MULTI_CHILD_NODE", [], e);
|
|
2142
|
+
}
|
|
2143
|
+
setNodeStyle(e, t, n) {
|
|
2144
|
+
let r = { [t]: n };
|
|
2145
|
+
this.setNodeDataRender(e, r), M.includes(t) && (e.parent || e).renderLine(!0);
|
|
2146
|
+
}
|
|
2147
|
+
setNodeStyles(e, t) {
|
|
2148
|
+
let n = { ...t };
|
|
2149
|
+
this.setNodeDataRender(e, n);
|
|
2150
|
+
let r = Object.keys(t), i = !1;
|
|
2151
|
+
r.forEach((e) => {
|
|
2152
|
+
M.includes(e) && (i = !0);
|
|
2153
|
+
}), i && (e.parent || e).renderLine(!0);
|
|
2154
|
+
}
|
|
2155
|
+
setNodeActive(e, t) {
|
|
2156
|
+
this.mindMap.execCommand("SET_NODE_DATA", e, { isActive: t }), e.updateNodeByActive(t);
|
|
2157
|
+
}
|
|
2158
|
+
setNodeExpand(e, t) {
|
|
2159
|
+
this.mindMap.execCommand("SET_NODE_DATA", e, { expand: t }), this.mindMap.render();
|
|
2160
|
+
}
|
|
2161
|
+
expandAllNode(e = "") {
|
|
2162
|
+
if (!this.renderTree) return;
|
|
2163
|
+
let t = (n, r) => {
|
|
2164
|
+
!r && n.data.uid === e && (r = !0), r && !n.data.expand && (n.data.expand = !0), n.children && n.children.length > 0 && n.children.forEach((e) => {
|
|
2165
|
+
t(e, r);
|
|
2166
|
+
});
|
|
2167
|
+
};
|
|
2168
|
+
t(this.renderTree, !e), this.mindMap.render();
|
|
2169
|
+
}
|
|
2170
|
+
unexpandAllNode(e = !0, t = "") {
|
|
2171
|
+
if (!this.renderTree) return;
|
|
2172
|
+
let n = (e, r, i) => {
|
|
2173
|
+
!i && e.data.uid === t && (i = !0), i && !r && e.children && e.children.length > 0 && (e.data.expand = !1), e.children && e.children.length > 0 && e.children.forEach((e) => {
|
|
2174
|
+
n(e, !1, i);
|
|
2175
|
+
});
|
|
2176
|
+
};
|
|
2177
|
+
n(this.renderTree, !0, !t), this.mindMap.render(() => {
|
|
2178
|
+
e && this.setRootNodeCenter();
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
expandToLevel(e) {
|
|
2182
|
+
this.renderTree && (F(this.renderTree, null, (t, n, r, i) => {
|
|
2183
|
+
i < e ? t.data.expand = !0 : !r && t.children && t.children.length > 0 && (t.data.expand = !1);
|
|
2184
|
+
}, null, !0, 0, 0), this.mindMap.render());
|
|
2185
|
+
}
|
|
2186
|
+
toggleActiveExpand() {
|
|
2187
|
+
this.activeNodeList.forEach((e) => {
|
|
2188
|
+
e.nodeData.children.length <= 0 || e.isRoot || this.toggleNodeExpand(e);
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
toggleNodeExpand(e) {
|
|
2192
|
+
this.mindMap.execCommand("SET_NODE_EXPAND", e, !e.getData("expand"));
|
|
2193
|
+
}
|
|
2194
|
+
setNodeText(e, t, n, r) {
|
|
2195
|
+
n = n === void 0 ? e.getData("richText") : n, this.setNodeDataRender(e, {
|
|
2196
|
+
text: t,
|
|
2197
|
+
richText: n,
|
|
2198
|
+
resetRichText: r
|
|
2199
|
+
});
|
|
2200
|
+
}
|
|
2201
|
+
setNodeImage(e, t) {
|
|
2202
|
+
let { url: n, title: r, width: i, height: a, custom: o = !1 } = t || {
|
|
2203
|
+
url: "",
|
|
2204
|
+
title: "",
|
|
2205
|
+
width: 0,
|
|
2206
|
+
height: 0,
|
|
2207
|
+
custom: !1
|
|
2208
|
+
};
|
|
2209
|
+
this.setNodeDataRender(e, {
|
|
2210
|
+
image: n,
|
|
2211
|
+
imageTitle: r || "",
|
|
2212
|
+
imageSize: {
|
|
2213
|
+
width: i,
|
|
2214
|
+
height: a,
|
|
2215
|
+
custom: o
|
|
2216
|
+
}
|
|
2217
|
+
});
|
|
2218
|
+
}
|
|
2219
|
+
setNodeIcon(e, t) {
|
|
2220
|
+
this.setNodeDataRender(e, { icon: t });
|
|
2221
|
+
}
|
|
2222
|
+
setNodeHyperlink(e, t, n = "") {
|
|
2223
|
+
this.setNodeDataRender(e, {
|
|
2224
|
+
hyperlink: t,
|
|
2225
|
+
hyperlinkTitle: n
|
|
2226
|
+
});
|
|
2227
|
+
}
|
|
2228
|
+
setNodeNote(e, t) {
|
|
2229
|
+
this.setNodeDataRender(e, { note: t });
|
|
2230
|
+
}
|
|
2231
|
+
setNodeAttachment(e, t, n = "") {
|
|
2232
|
+
this.setNodeDataRender(e, {
|
|
2233
|
+
attachmentUrl: t,
|
|
2234
|
+
attachmentName: n
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
setNodeTag(e, t) {
|
|
2238
|
+
this.setNodeDataRender(e, { tag: t });
|
|
2239
|
+
}
|
|
2240
|
+
insertFormula(e, n = []) {
|
|
2241
|
+
!this.hasRichTextPlugin() || !this.mindMap.formula || (n = t(n), (n.length > 0 ? n : this.activeNodeList).forEach((t) => {
|
|
2242
|
+
this.mindMap.formula.insertFormulaToNode(t, e);
|
|
2243
|
+
}));
|
|
2244
|
+
}
|
|
2245
|
+
addGeneralization(t, n = !0) {
|
|
2246
|
+
if (this.activeNodeList.length <= 0) return;
|
|
2247
|
+
let r = e(this.activeNodeList.filter((e) => !e.isRoot && !e.isGeneralization && !e.checkHasSelfGeneralization()));
|
|
2248
|
+
if (r.length <= 0) return;
|
|
2249
|
+
let i = this.hasRichTextPlugin(), { focusNewNode: a, inserting: o } = this.getNewNodeBehavior(n, r.length > 1), s = !1, c = t && t.richText;
|
|
2250
|
+
r.forEach((e) => {
|
|
2251
|
+
let n = {
|
|
2252
|
+
inserting: o,
|
|
2253
|
+
...t || { text: this.mindMap.opt.defaultGeneralizationText },
|
|
2254
|
+
range: e.range || null,
|
|
2255
|
+
uid: T(),
|
|
2256
|
+
richText: i,
|
|
2257
|
+
isActive: a
|
|
2258
|
+
};
|
|
2259
|
+
i && !c && (n.resetRichText = i);
|
|
2260
|
+
let r = e.node.getData("generalization");
|
|
2261
|
+
if (r = r ? Array.isArray(r) ? r : [r] : [], e.range) {
|
|
2262
|
+
if (r.find((t) => t.range && t.range[0] === e.range[0] && t.range[1] === e.range[1])) return;
|
|
2263
|
+
r.push(n);
|
|
2264
|
+
} else r.push(n);
|
|
2265
|
+
s = !0, this.mindMap.execCommand("SET_NODE_DATA", e.node, { generalization: r }), e.node.setData({ expand: !0 });
|
|
2266
|
+
}), s && (a && this.clearActiveNodeList(), this.mindMap.render(() => {
|
|
2267
|
+
this.mindMap.render();
|
|
2268
|
+
}));
|
|
2269
|
+
}
|
|
2270
|
+
removeGeneralization() {
|
|
2271
|
+
this.activeNodeList.length <= 0 || (this.activeNodeList.forEach((e) => {
|
|
2272
|
+
e.checkHasGeneralization() && this.mindMap.execCommand("SET_NODE_DATA", e, { generalization: null });
|
|
2273
|
+
}), this.mindMap.render(), this.closeHighlightNode());
|
|
2274
|
+
}
|
|
2275
|
+
setNodeCustomPosition(e, t = void 0, n = void 0) {
|
|
2276
|
+
[e].forEach((e) => {
|
|
2277
|
+
this.mindMap.execCommand("SET_NODE_DATA", e, {
|
|
2278
|
+
customLeft: t,
|
|
2279
|
+
customTop: n
|
|
2280
|
+
});
|
|
2281
|
+
});
|
|
2282
|
+
}
|
|
2283
|
+
resetLayout() {
|
|
2284
|
+
F(this.root, null, (e) => {
|
|
2285
|
+
e.customLeft = void 0, e.customTop = void 0, this.mindMap.execCommand("SET_NODE_DATA", e, {
|
|
2286
|
+
customLeft: void 0,
|
|
2287
|
+
customTop: void 0
|
|
2288
|
+
}), this.mindMap.render();
|
|
2289
|
+
}, null, !0, 0, 0);
|
|
2290
|
+
}
|
|
2291
|
+
setNodeShape(e, t) {
|
|
2292
|
+
!t || !ye.includes(t) || [e].forEach((e) => {
|
|
2293
|
+
this.setNodeStyle(e, "shape", t);
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
goTargetNode(e, t = () => {}) {
|
|
2297
|
+
let n = typeof e == "string" ? e : e.getData("uid");
|
|
2298
|
+
n && this.expandToNodeUid(n, () => {
|
|
2299
|
+
let e = this.findNodeByUid(n);
|
|
2300
|
+
e && (e.active(), this.moveNodeToCenter(e), t(e));
|
|
2301
|
+
});
|
|
2302
|
+
}
|
|
2303
|
+
setNodeData(e, t) {
|
|
2304
|
+
Object.keys(t).forEach((n) => {
|
|
2305
|
+
e.nodeData.data[n] = t[n];
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
2308
|
+
setNodeDataRender(e, t, n = !1) {
|
|
2309
|
+
if (this.mindMap.execCommand("SET_NODE_DATA", e, t), S(t)) {
|
|
2310
|
+
this.mindMap.emit("node_tree_render_end");
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
2313
|
+
this.reRenderNodeCheckChange(e, n);
|
|
2314
|
+
}
|
|
2315
|
+
reRenderNodeCheckChange(e, t) {
|
|
2316
|
+
e.reRender() ? t || this.mindMap.render() : this.mindMap.emit("node_tree_render_end");
|
|
2317
|
+
}
|
|
2318
|
+
moveNodeToCenter(e, t) {
|
|
2319
|
+
let { resetScaleOnMoveNodeToCenter: n } = this.mindMap.opt;
|
|
2320
|
+
t !== void 0 && (n = t);
|
|
2321
|
+
let { transform: r, state: i } = this.mindMap.view.getTransformData(), { left: a, top: o, width: s, height: c } = e;
|
|
2322
|
+
n || (a *= r.scaleX, o *= r.scaleY, s *= r.scaleX, c *= r.scaleY);
|
|
2323
|
+
let l = this.mindMap.width / 2, u = this.mindMap.height / 2, d = a + s / 2, f = o + c / 2, p = l - i.x, m = u - i.y, h = p - d, g = m - f;
|
|
2324
|
+
this.mindMap.view.translateX(h), this.mindMap.view.translateY(g), n && this.mindMap.view.setScale(1);
|
|
2325
|
+
}
|
|
2326
|
+
setRootNodeCenter() {
|
|
2327
|
+
this.moveNodeToCenter(this.root);
|
|
2328
|
+
}
|
|
2329
|
+
expandToNodeUid(e, t = () => {}) {
|
|
2330
|
+
if (!this.renderTree) {
|
|
2331
|
+
t();
|
|
2332
|
+
return;
|
|
2333
|
+
}
|
|
2334
|
+
let n = [], r = !1, i = {};
|
|
2335
|
+
ie(this.renderTree, (t, a) => {
|
|
2336
|
+
if (t.data.uid === e) return n = a ? [...i[a.data.uid], a] : [], "stop";
|
|
2337
|
+
if (V(t.data).forEach((o) => {
|
|
2338
|
+
o.uid === e && (n = a ? [
|
|
2339
|
+
...i[a.data.uid],
|
|
2340
|
+
a,
|
|
2341
|
+
t
|
|
2342
|
+
] : [], r = !0);
|
|
2343
|
+
}), r) return "stop";
|
|
2344
|
+
i[t.data.uid] = a ? [...i[a.data.uid], a] : [];
|
|
2345
|
+
});
|
|
2346
|
+
let a = !1;
|
|
2347
|
+
if (n.forEach((e) => {
|
|
2348
|
+
e.data.expand || (a = !0, e.data.expand = !0);
|
|
2349
|
+
}), r) {
|
|
2350
|
+
let e = n[n.length - 1];
|
|
2351
|
+
e && F(e, null, (e) => {
|
|
2352
|
+
e.data.expand || (a = !0, e.data.expand = !0);
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
a ? this.mindMap.render(t) : t();
|
|
2356
|
+
}
|
|
2357
|
+
findNodeByUid(e) {
|
|
2358
|
+
if (!this.root) return;
|
|
2359
|
+
let t = null;
|
|
2360
|
+
return F(this.root, null, (n) => {
|
|
2361
|
+
if (n.getData("uid") === e) return t = n, !0;
|
|
2362
|
+
let r = !1;
|
|
2363
|
+
if ((n._generalizationList || []).forEach((n) => {
|
|
2364
|
+
n.generalizationNode.getData("uid") === e && (t = n.generalizationNode, r = !0);
|
|
2365
|
+
}), r) return !0;
|
|
2366
|
+
}), t;
|
|
2367
|
+
}
|
|
2368
|
+
highlightNode(e, t, n) {
|
|
2369
|
+
if (this.isRendering) return;
|
|
2370
|
+
n = {
|
|
2371
|
+
stroke: "rgb(94, 200, 248)",
|
|
2372
|
+
fill: "transparent",
|
|
2373
|
+
...n || {}
|
|
2374
|
+
}, this.highlightBoxNode ? this.highlightBoxNodeStyle && (this.highlightBoxNodeStyle.stroke !== n.stroke || this.highlightBoxNodeStyle.fill !== n.fill) && this.highlightBoxNode.stroke({ color: n.stroke || "transparent" }).fill({ color: n.fill || "transparent" }) : this.highlightBoxNode = new x().stroke({ color: n.stroke || "transparent" }).fill({ color: n.fill || "transparent" }), this.highlightBoxNodeStyle = { ...n };
|
|
2375
|
+
let r = Infinity, i = Infinity, a = -Infinity, o = -Infinity;
|
|
2376
|
+
t ? e.children.slice(t[0], t[1] + 1).forEach((e) => {
|
|
2377
|
+
e.left < r && (r = e.left), e.top < i && (i = e.top);
|
|
2378
|
+
let t = e.left + e.width, n = e.top + e.height;
|
|
2379
|
+
t > a && (a = t), n > o && (o = n);
|
|
2380
|
+
}) : (r = e.left, i = e.top, a = e.left + e.width, o = e.top + e.height), this.highlightBoxNode.plot([
|
|
2381
|
+
[r, i],
|
|
2382
|
+
[a, i],
|
|
2383
|
+
[a, o],
|
|
2384
|
+
[r, o]
|
|
2385
|
+
]), this.mindMap.otherDraw.add(this.highlightBoxNode);
|
|
2386
|
+
}
|
|
2387
|
+
closeHighlightNode() {
|
|
2388
|
+
this.highlightBoxNode && this.highlightBoxNode.remove();
|
|
2389
|
+
}
|
|
2390
|
+
hasRichTextPlugin() {
|
|
2391
|
+
return !!this.mindMap.richText;
|
|
2392
|
+
}
|
|
2393
|
+
}, Y = { default: re }, X = {
|
|
2394
|
+
Backspace: 8,
|
|
2395
|
+
Tab: 9,
|
|
2396
|
+
Enter: 13,
|
|
2397
|
+
Shift: 16,
|
|
2398
|
+
Control: 17,
|
|
2399
|
+
Alt: 18,
|
|
2400
|
+
CapsLock: 20,
|
|
2401
|
+
Esc: 27,
|
|
2402
|
+
Spacebar: 32,
|
|
2403
|
+
PageUp: 33,
|
|
2404
|
+
PageDown: 34,
|
|
2405
|
+
End: 35,
|
|
2406
|
+
Home: 36,
|
|
2407
|
+
Insert: 45,
|
|
2408
|
+
Left: 37,
|
|
2409
|
+
Up: 38,
|
|
2410
|
+
Right: 39,
|
|
2411
|
+
Down: 40,
|
|
2412
|
+
Del: 46,
|
|
2413
|
+
NumLock: 144,
|
|
2414
|
+
Cmd: 91,
|
|
2415
|
+
CmdFF: 224,
|
|
2416
|
+
F1: 112,
|
|
2417
|
+
F2: 113,
|
|
2418
|
+
F3: 114,
|
|
2419
|
+
F4: 115,
|
|
2420
|
+
F5: 116,
|
|
2421
|
+
F6: 117,
|
|
2422
|
+
F7: 118,
|
|
2423
|
+
F8: 119,
|
|
2424
|
+
F9: 120,
|
|
2425
|
+
F10: 121,
|
|
2426
|
+
F11: 122,
|
|
2427
|
+
F12: 123,
|
|
2428
|
+
"`": 192,
|
|
2429
|
+
"=": 187,
|
|
2430
|
+
"-": 189,
|
|
2431
|
+
"/": 191,
|
|
2432
|
+
".": 190
|
|
2433
|
+
};
|
|
2434
|
+
for (let e = 0; e <= 9; e++) X[e] = e + 48;
|
|
2435
|
+
"abcdefghijklmnopqrstuvwxyz".split("").forEach((e, t) => {
|
|
2436
|
+
X[e] = t + 65;
|
|
2437
|
+
});
|
|
2438
|
+
var Z = X, Ne = class {
|
|
2439
|
+
constructor(e) {
|
|
2440
|
+
this.opt = e, this.mindMap = e.mindMap, this.shortcutMap = {}, this.shortcutMapCache = {}, this.isPause = !1, this.isInSvg = !1, this.isStopCheckInSvg = !1, this.defaultEnableCheck = this.defaultEnableCheck.bind(this), this.bindEvent();
|
|
2441
|
+
}
|
|
2442
|
+
extendKeyMap(e, t) {
|
|
2443
|
+
Z[e] = t;
|
|
2444
|
+
}
|
|
2445
|
+
removeKeyMap(e) {
|
|
2446
|
+
Z[e] !== void 0 && delete Z[e];
|
|
2447
|
+
}
|
|
2448
|
+
pause() {
|
|
2449
|
+
this.isPause = !0;
|
|
2450
|
+
}
|
|
2451
|
+
recovery() {
|
|
2452
|
+
this.isPause = !1;
|
|
2453
|
+
}
|
|
2454
|
+
save() {
|
|
2455
|
+
Object.keys(this.shortcutMapCache).length > 0 || (this.shortcutMapCache = this.shortcutMap, this.shortcutMap = {});
|
|
2456
|
+
}
|
|
2457
|
+
restore() {
|
|
2458
|
+
Object.keys(this.shortcutMapCache).length <= 0 || (this.shortcutMap = this.shortcutMapCache, this.shortcutMapCache = {});
|
|
2459
|
+
}
|
|
2460
|
+
stopCheckInSvg() {
|
|
2461
|
+
let { enableShortcutOnlyWhenMouseInSvg: e } = this.mindMap.opt;
|
|
2462
|
+
e && (this.isStopCheckInSvg = !0);
|
|
2463
|
+
}
|
|
2464
|
+
recoveryCheckInSvg() {
|
|
2465
|
+
let { enableShortcutOnlyWhenMouseInSvg: e } = this.mindMap.opt;
|
|
2466
|
+
e && (this.isStopCheckInSvg = !0);
|
|
2467
|
+
}
|
|
2468
|
+
bindEvent() {
|
|
2469
|
+
this.onKeydown = this.onKeydown.bind(this), this.mindMap.on("svg_mouseenter", () => {
|
|
2470
|
+
this.isInSvg = !0;
|
|
2471
|
+
}), this.mindMap.on("svg_mouseleave", () => {
|
|
2472
|
+
this.isInSvg = !1;
|
|
2473
|
+
}), window.addEventListener("keydown", this.onKeydown), this.mindMap.on("beforeDestroy", () => {
|
|
2474
|
+
this.unBindEvent();
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
unBindEvent() {
|
|
2478
|
+
window.removeEventListener("keydown", this.onKeydown);
|
|
2479
|
+
}
|
|
2480
|
+
defaultEnableCheck(e) {
|
|
2481
|
+
let t = e.target;
|
|
2482
|
+
if (t === document.body) return !0;
|
|
2483
|
+
for (let e = 0; e < this.mindMap.editNodeClassList.length; e++) {
|
|
2484
|
+
let n = this.mindMap.editNodeClassList[e];
|
|
2485
|
+
if (t.classList.contains(n)) return !0;
|
|
2486
|
+
}
|
|
2487
|
+
return !1;
|
|
2488
|
+
}
|
|
2489
|
+
onKeydown(e) {
|
|
2490
|
+
let { enableShortcutOnlyWhenMouseInSvg: t, beforeShortcutRun: n, customCheckEnableShortcut: r } = this.mindMap.opt;
|
|
2491
|
+
(typeof r == "function" ? r : this.defaultEnableCheck)(e) && (this.isPause || t && !this.isStopCheckInSvg && !this.isInSvg || Object.keys(this.shortcutMap).forEach((t) => {
|
|
2492
|
+
if (this.checkKey(e, t)) {
|
|
2493
|
+
if (this.checkKey(e, "Control+v") || (e.stopPropagation(), e.preventDefault()), typeof n == "function" && n(t, [...this.mindMap.renderer.activeNodeList])) return;
|
|
2494
|
+
this.shortcutMap[t].forEach((e) => {
|
|
2495
|
+
e();
|
|
2496
|
+
});
|
|
2497
|
+
}
|
|
2498
|
+
}));
|
|
2499
|
+
}
|
|
2500
|
+
checkKey(e, t) {
|
|
2501
|
+
let n = this.getOriginEventCodeArr(e), r = this.getKeyCodeArr(t);
|
|
2502
|
+
if (n.length !== r.length) return !1;
|
|
2503
|
+
for (let e = 0; e < n.length; e++) {
|
|
2504
|
+
let t = r.findIndex((t) => t === n[e]);
|
|
2505
|
+
if (t === -1) return !1;
|
|
2506
|
+
r.splice(t, 1);
|
|
2507
|
+
}
|
|
2508
|
+
return !0;
|
|
2509
|
+
}
|
|
2510
|
+
getOriginEventCodeArr(e) {
|
|
2511
|
+
let t = [];
|
|
2512
|
+
return (e.ctrlKey || e.metaKey) && t.push(Z.Control), e.altKey && t.push(Z.Alt), e.shiftKey && t.push(Z.Shift), t.includes(e.keyCode) || t.push(e.keyCode), t;
|
|
2513
|
+
}
|
|
2514
|
+
hasCombinationKey(e) {
|
|
2515
|
+
return e.ctrlKey || e.metaKey || e.altKey || e.shiftKey;
|
|
2516
|
+
}
|
|
2517
|
+
getKeyCodeArr(e) {
|
|
2518
|
+
let t = e.split(/\s*\+\s*/), n = [];
|
|
2519
|
+
return t.forEach((e) => {
|
|
2520
|
+
n.push(Z[e]);
|
|
2521
|
+
}), n;
|
|
2522
|
+
}
|
|
2523
|
+
addShortcut(e, t) {
|
|
2524
|
+
e.split(/\s*\|\s*/).forEach((e) => {
|
|
2525
|
+
this.shortcutMap[e] ? this.shortcutMap[e].push(t) : this.shortcutMap[e] = [t];
|
|
2526
|
+
});
|
|
2527
|
+
}
|
|
2528
|
+
removeShortcut(e, t) {
|
|
2529
|
+
e.split(/\s*\|\s*/).forEach((e) => {
|
|
2530
|
+
if (this.shortcutMap[e]) if (t) {
|
|
2531
|
+
let n = this.shortcutMap[e].findIndex((e) => e === t);
|
|
2532
|
+
n !== -1 && this.shortcutMap[e].splice(n, 1);
|
|
2533
|
+
} else this.shortcutMap[e] = [], delete this.shortcutMap[e];
|
|
2534
|
+
});
|
|
2535
|
+
}
|
|
2536
|
+
getShortcutFn(e) {
|
|
2537
|
+
let t = [];
|
|
2538
|
+
return e.split(/\s*\|\s*/).forEach((e) => {
|
|
2539
|
+
t = this.shortcutMap[e] || [];
|
|
2540
|
+
}), t;
|
|
2541
|
+
}
|
|
2542
|
+
}, Pe = {
|
|
2543
|
+
name: "simple-mind-map",
|
|
2544
|
+
version: "0.14.0-fix.2",
|
|
2545
|
+
description: "一个简单的web在线思维导图",
|
|
2546
|
+
authors: [{
|
|
2547
|
+
name: "街角小林",
|
|
2548
|
+
email: "1013335014@qq.com"
|
|
2549
|
+
}, {
|
|
2550
|
+
name: "理想青年实验室",
|
|
2551
|
+
url: "http://lxqnsys.com/"
|
|
2552
|
+
}],
|
|
2553
|
+
types: "./types/index.d.ts",
|
|
2554
|
+
typings: "./types/index.d.ts",
|
|
2555
|
+
license: "MIT",
|
|
2556
|
+
repository: {
|
|
2557
|
+
type: "git",
|
|
2558
|
+
url: "https://github.com/wanglin2/mind-map"
|
|
2559
|
+
},
|
|
2560
|
+
scripts: {
|
|
2561
|
+
lint: "eslint src/",
|
|
2562
|
+
format: "prettier --write .",
|
|
2563
|
+
types: "npx -p typescript tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types --target es2017 --skipLibCheck & node ./bin/createPluginsTypeFiles.js",
|
|
2564
|
+
wsServe: "node ./bin/wsServer.mjs"
|
|
2565
|
+
},
|
|
2566
|
+
module: "index.js",
|
|
2567
|
+
main: "./dist/simpleMindMap.umd.min.js",
|
|
2568
|
+
dependencies: {
|
|
2569
|
+
"@svgdotjs/svg.js": "3.2.0",
|
|
2570
|
+
deepmerge: "^1.5.2",
|
|
2571
|
+
eventemitter3: "^4.0.7",
|
|
2572
|
+
jszip: "^3.10.1",
|
|
2573
|
+
katex: "^0.16.8",
|
|
2574
|
+
"mdast-util-from-markdown": "^1.3.0",
|
|
2575
|
+
"pdf-lib": "^1.17.1",
|
|
2576
|
+
quill: "^2.0.3",
|
|
2577
|
+
tern: "^0.24.3",
|
|
2578
|
+
uuid: "^9.0.0",
|
|
2579
|
+
ws: "^7.5.9",
|
|
2580
|
+
"xml-js": "^1.6.11",
|
|
2581
|
+
"y-webrtc": "^10.2.5",
|
|
2582
|
+
yjs: "^13.6.8"
|
|
2583
|
+
},
|
|
2584
|
+
keywords: [
|
|
2585
|
+
"javascript",
|
|
2586
|
+
"svg",
|
|
2587
|
+
"mind-map",
|
|
2588
|
+
"mindMap",
|
|
2589
|
+
"MindMap"
|
|
2590
|
+
],
|
|
2591
|
+
devDependencies: {
|
|
2592
|
+
eslint: "^8.25.0",
|
|
2593
|
+
prettier: "^2.7.1"
|
|
2594
|
+
}
|
|
2595
|
+
}, Fe = class {
|
|
2596
|
+
constructor(e = {}) {
|
|
2597
|
+
this.opt = e, this.mindMap = e.mindMap, this.commands = {}, this.history = [], this.activeHistoryIndex = 0, this.registerShortcutKeys(), this.originAddHistory = this.addHistory.bind(this), this.addHistory = k(this.addHistory, this.mindMap.opt.addHistoryTime, this), this.isPause = !1;
|
|
2598
|
+
}
|
|
2599
|
+
pause() {
|
|
2600
|
+
this.isPause = !0;
|
|
2601
|
+
}
|
|
2602
|
+
recovery() {
|
|
2603
|
+
this.isPause = !1;
|
|
2604
|
+
}
|
|
2605
|
+
clearHistory() {
|
|
2606
|
+
this.history = [], this.activeHistoryIndex = 0, this.mindMap.emit("back_forward", 0, 0);
|
|
2607
|
+
}
|
|
2608
|
+
registerShortcutKeys() {
|
|
2609
|
+
this.mindMap.keyCommand.addShortcut("Control+z", () => {
|
|
2610
|
+
this.mindMap.execCommand("BACK");
|
|
2611
|
+
}), this.mindMap.keyCommand.addShortcut("Control+y", () => {
|
|
2612
|
+
this.mindMap.execCommand("FORWARD");
|
|
2613
|
+
});
|
|
2614
|
+
}
|
|
2615
|
+
exec(e, ...t) {
|
|
2616
|
+
if (this.commands[e]) {
|
|
2617
|
+
if (this.commands[e].forEach((e) => {
|
|
2618
|
+
e(...t);
|
|
2619
|
+
}), this.mindMap.emit("afterExecCommand", e, ...t), [
|
|
2620
|
+
"BACK",
|
|
2621
|
+
"FORWARD",
|
|
2622
|
+
"SET_NODE_ACTIVE",
|
|
2623
|
+
"CLEAR_ACTIVE_NODE"
|
|
2624
|
+
].includes(e)) return;
|
|
2625
|
+
this.addHistory();
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
add(e, t) {
|
|
2629
|
+
this.commands[e] ? this.commands[e].push(t) : this.commands[e] = [t];
|
|
2630
|
+
}
|
|
2631
|
+
remove(e, t) {
|
|
2632
|
+
if (this.commands[e]) if (!t) this.commands[e] = [], delete this.commands[e];
|
|
2633
|
+
else {
|
|
2634
|
+
let n = this.commands[e].find((e) => e === t);
|
|
2635
|
+
n !== -1 && this.commands[e].splice(n, 1);
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
addHistory() {
|
|
2639
|
+
if (this.mindMap.opt.readonly || this.isPause) return;
|
|
2640
|
+
this.mindMap.emit("beforeAddHistory");
|
|
2641
|
+
let e = this.history.length > 0 ? this.history[this.activeHistoryIndex] : null, t = this.getCopyData(), n = JSON.stringify(t);
|
|
2642
|
+
e && e === n || (this.emitDataUpdatesEvent(e, n), this.history = this.history.slice(0, this.activeHistoryIndex + 1), this.history.push(n), this.history.length > this.mindMap.opt.maxHistoryCount && this.history.shift(), this.activeHistoryIndex = this.history.length - 1, this.mindMap.emit("data_change", t), this.mindMap.emit("back_forward", this.activeHistoryIndex, this.history.length));
|
|
2643
|
+
}
|
|
2644
|
+
back(e = 1) {
|
|
2645
|
+
if (!this.mindMap.opt.readonly && this.activeHistoryIndex - e >= 0) {
|
|
2646
|
+
let t = this.history[this.activeHistoryIndex];
|
|
2647
|
+
this.activeHistoryIndex -= e, this.mindMap.emit("back_forward", this.activeHistoryIndex, this.history.length);
|
|
2648
|
+
let n = this.history[this.activeHistoryIndex], r = JSON.parse(n);
|
|
2649
|
+
return this.emitDataUpdatesEvent(t, n), r;
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
forward(e = 1) {
|
|
2653
|
+
if (this.mindMap.opt.readonly) return;
|
|
2654
|
+
let t = this.history.length;
|
|
2655
|
+
if (this.activeHistoryIndex + e <= t - 1) {
|
|
2656
|
+
let t = this.history[this.activeHistoryIndex];
|
|
2657
|
+
this.activeHistoryIndex += e, this.mindMap.emit("back_forward", this.activeHistoryIndex, this.history.length);
|
|
2658
|
+
let n = this.history[this.activeHistoryIndex], r = JSON.parse(n);
|
|
2659
|
+
return this.emitDataUpdatesEvent(t, n), r;
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
getCopyData() {
|
|
2663
|
+
if (!this.mindMap.renderer.renderTree) return null;
|
|
2664
|
+
let e = ce({}, this.mindMap.renderer.renderTree, !0);
|
|
2665
|
+
return e.smmVersion = Pe.version, e;
|
|
2666
|
+
}
|
|
2667
|
+
removeDataUid(e) {
|
|
2668
|
+
e = P(e);
|
|
2669
|
+
let t = (e) => {
|
|
2670
|
+
delete e.data.uid, e.children && e.children.length > 0 && e.children.forEach((e) => {
|
|
2671
|
+
t(e);
|
|
2672
|
+
});
|
|
2673
|
+
};
|
|
2674
|
+
return t(e), e;
|
|
2675
|
+
}
|
|
2676
|
+
emitDataUpdatesEvent(e, t) {
|
|
2677
|
+
try {
|
|
2678
|
+
let n = "data_change_detail";
|
|
2679
|
+
if (this.mindMap.event.listenerCount(n) > 0 && e && t) {
|
|
2680
|
+
let r = JSON.parse(e), i = JSON.parse(t), a = P(A(r)), o = P(A(i)), s = [], c = (e, t) => (e.children && e.children.length > 0 && e.children.forEach((n, r) => {
|
|
2681
|
+
e.children[r] = typeof n == "string" ? t[n] : t[n.data.uid], c(e.children[r], t);
|
|
2682
|
+
}), e);
|
|
2683
|
+
Object.keys(o).forEach((e) => {
|
|
2684
|
+
a[e] ? te(a[e], o[e]) || s.push({
|
|
2685
|
+
action: "update",
|
|
2686
|
+
oldData: c(a[e], a),
|
|
2687
|
+
data: c(o[e], o)
|
|
2688
|
+
}) : s.push({
|
|
2689
|
+
action: "create",
|
|
2690
|
+
data: c(o[e], o)
|
|
2691
|
+
});
|
|
2692
|
+
}), Object.keys(a).forEach((e) => {
|
|
2693
|
+
o[e] || s.push({
|
|
2694
|
+
action: "delete",
|
|
2695
|
+
data: c(a[e], a)
|
|
2696
|
+
});
|
|
2697
|
+
}), this.mindMap.emit(n, s);
|
|
2698
|
+
}
|
|
2699
|
+
} catch (e) {
|
|
2700
|
+
this.mindMap.opt.errorHandler(_.DATA_CHANGE_DETAIL_EVENT_ERROR, e);
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
}, Ie = class {
|
|
2704
|
+
constructor() {
|
|
2705
|
+
this.has = {}, this.queue = [], this.nextTick = ne(this.flush, this);
|
|
2706
|
+
}
|
|
2707
|
+
push(e, t) {
|
|
2708
|
+
if (this.has[e]) {
|
|
2709
|
+
this.replaceTask(e, t);
|
|
2710
|
+
return;
|
|
2711
|
+
}
|
|
2712
|
+
this.has[e] = !0, this.queue.push({
|
|
2713
|
+
name: e,
|
|
2714
|
+
fn: t
|
|
2715
|
+
}), this.nextTick();
|
|
2716
|
+
}
|
|
2717
|
+
replaceTask(e, t) {
|
|
2718
|
+
let n = this.queue.findIndex((t) => t.name === e);
|
|
2719
|
+
n !== -1 && (this.queue[n] = {
|
|
2720
|
+
name: e,
|
|
2721
|
+
fn: t
|
|
2722
|
+
});
|
|
2723
|
+
}
|
|
2724
|
+
flush() {
|
|
2725
|
+
let e = this.queue.slice(0);
|
|
2726
|
+
this.queue = [], e.forEach(({ name: e, fn: t }) => {
|
|
2727
|
+
this.has[e] = !1, t();
|
|
2728
|
+
});
|
|
2729
|
+
}
|
|
2730
|
+
}, Le = {
|
|
2731
|
+
el: null,
|
|
2732
|
+
data: null,
|
|
2733
|
+
viewData: null,
|
|
2734
|
+
readonly: !1,
|
|
2735
|
+
layout: i.LAYOUT.LOGICAL_STRUCTURE,
|
|
2736
|
+
fishboneDeg: 45,
|
|
2737
|
+
theme: "default",
|
|
2738
|
+
themeConfig: {},
|
|
2739
|
+
scaleRatio: .2,
|
|
2740
|
+
translateRatio: 1,
|
|
2741
|
+
minZoomRatio: 20,
|
|
2742
|
+
maxZoomRatio: 400,
|
|
2743
|
+
customCheckIsTouchPad: null,
|
|
2744
|
+
mouseScaleCenterUseMousePosition: !0,
|
|
2745
|
+
maxTag: 5,
|
|
2746
|
+
expandBtnSize: 20,
|
|
2747
|
+
imgTextMargin: 5,
|
|
2748
|
+
textContentMargin: 2,
|
|
2749
|
+
customNoteContentShow: null,
|
|
2750
|
+
textAutoWrapWidth: 500,
|
|
2751
|
+
customHandleMousewheel: null,
|
|
2752
|
+
mousewheelAction: i.MOUSE_WHEEL_ACTION.MOVE,
|
|
2753
|
+
mousewheelMoveStep: 100,
|
|
2754
|
+
mousewheelZoomActionReverse: !0,
|
|
2755
|
+
defaultInsertSecondLevelNodeText: "二级节点",
|
|
2756
|
+
defaultInsertBelowSecondLevelNodeText: "分支主题",
|
|
2757
|
+
expandBtnStyle: {
|
|
2758
|
+
color: "#808080",
|
|
2759
|
+
fill: "#fff",
|
|
2760
|
+
fontSize: 13,
|
|
2761
|
+
strokeColor: "#333333"
|
|
2762
|
+
},
|
|
2763
|
+
expandBtnIcon: {
|
|
2764
|
+
open: "",
|
|
2765
|
+
close: ""
|
|
2766
|
+
},
|
|
2767
|
+
expandBtnNumHandler: null,
|
|
2768
|
+
isShowExpandNum: !0,
|
|
2769
|
+
enableShortcutOnlyWhenMouseInSvg: !0,
|
|
2770
|
+
customCheckEnableShortcut: null,
|
|
2771
|
+
initRootNodePosition: null,
|
|
2772
|
+
nodeTextEditZIndex: 3e3,
|
|
2773
|
+
nodeNoteTooltipZIndex: 3e3,
|
|
2774
|
+
isEndNodeTextEditOnClickOuter: !0,
|
|
2775
|
+
maxHistoryCount: 500,
|
|
2776
|
+
alwaysShowExpandBtn: !1,
|
|
2777
|
+
notShowExpandBtn: !1,
|
|
2778
|
+
iconList: [],
|
|
2779
|
+
maxNodeCacheCount: 1e3,
|
|
2780
|
+
fitPadding: 50,
|
|
2781
|
+
enableCtrlKeyNodeSelection: !0,
|
|
2782
|
+
useLeftKeySelectionRightKeyDrag: !1,
|
|
2783
|
+
beforeTextEdit: null,
|
|
2784
|
+
isUseCustomNodeContent: !1,
|
|
2785
|
+
customCreateNodeContent: null,
|
|
2786
|
+
customInnerElsAppendTo: null,
|
|
2787
|
+
enableAutoEnterTextEditWhenKeydown: !1,
|
|
2788
|
+
autoEmptyTextWhenKeydownEnterEdit: !1,
|
|
2789
|
+
customHandleClipboardText: null,
|
|
2790
|
+
disableMouseWheelZoom: !1,
|
|
2791
|
+
errorHandler: (e, t) => {
|
|
2792
|
+
console.error(e, t);
|
|
2793
|
+
},
|
|
2794
|
+
enableDblclickBackToRootNode: !1,
|
|
2795
|
+
hoverRectColor: "rgb(94, 200, 248)",
|
|
2796
|
+
hoverRectPadding: 2,
|
|
2797
|
+
selectTextOnEnterEditText: !1,
|
|
2798
|
+
deleteNodeActive: !0,
|
|
2799
|
+
fit: !1,
|
|
2800
|
+
tagsColorMap: {},
|
|
2801
|
+
cooperateStyle: {
|
|
2802
|
+
avatarSize: 22,
|
|
2803
|
+
fontSize: 12
|
|
2804
|
+
},
|
|
2805
|
+
onlyOneEnableActiveNodeOnCooperate: !1,
|
|
2806
|
+
defaultGeneralizationText: "概要",
|
|
2807
|
+
handleIsSplitByWrapOnPasteCreateNewNode: null,
|
|
2808
|
+
addHistoryTime: 100,
|
|
2809
|
+
isDisableDrag: !1,
|
|
2810
|
+
createNewNodeBehavior: i.CREATE_NEW_NODE_BEHAVIOR.DEFAULT,
|
|
2811
|
+
defaultNodeImage: "",
|
|
2812
|
+
isLimitMindMapInCanvas: !1,
|
|
2813
|
+
handleNodePasteImg: null,
|
|
2814
|
+
customCreateNodePath: null,
|
|
2815
|
+
customCreateNodePolygon: null,
|
|
2816
|
+
customTransformNodeLinePath: null,
|
|
2817
|
+
beforeShortcutRun: null,
|
|
2818
|
+
resetScaleOnMoveNodeToCenter: !1,
|
|
2819
|
+
createNodePrefixContent: null,
|
|
2820
|
+
createNodePostfixContent: null,
|
|
2821
|
+
disabledClipboard: !1,
|
|
2822
|
+
customHyperlinkJump: null,
|
|
2823
|
+
openPerformance: !1,
|
|
2824
|
+
performanceConfig: {
|
|
2825
|
+
time: 250,
|
|
2826
|
+
padding: 100,
|
|
2827
|
+
removeNodeWhenOutCanvas: !0
|
|
2828
|
+
},
|
|
2829
|
+
emptyTextMeasureHeightText: "abc123我和你",
|
|
2830
|
+
openRealtimeRenderOnNodeTextEdit: !1,
|
|
2831
|
+
mousedownEventPreventDefault: !1,
|
|
2832
|
+
onlyPasteTextWhenHasImgAndText: !0,
|
|
2833
|
+
enableDragModifyNodeWidth: !0,
|
|
2834
|
+
minNodeTextModifyWidth: 20,
|
|
2835
|
+
maxNodeTextModifyWidth: -1,
|
|
2836
|
+
customHandleLine: null,
|
|
2837
|
+
addHistoryOnInit: !0,
|
|
2838
|
+
noteIcon: {
|
|
2839
|
+
icon: "",
|
|
2840
|
+
style: {}
|
|
2841
|
+
},
|
|
2842
|
+
hyperlinkIcon: {
|
|
2843
|
+
icon: "",
|
|
2844
|
+
style: {}
|
|
2845
|
+
},
|
|
2846
|
+
attachmentIcon: {
|
|
2847
|
+
icon: "",
|
|
2848
|
+
style: {}
|
|
2849
|
+
},
|
|
2850
|
+
isShowCreateChildBtnIcon: !0,
|
|
2851
|
+
quickCreateChildBtnIcon: {
|
|
2852
|
+
icon: "",
|
|
2853
|
+
style: {}
|
|
2854
|
+
},
|
|
2855
|
+
customQuickCreateChildBtnClick: null,
|
|
2856
|
+
addCustomContentToNode: null,
|
|
2857
|
+
enableInheritAncestorLineStyle: !0,
|
|
2858
|
+
selectTranslateStep: 3,
|
|
2859
|
+
selectTranslateLimit: 20,
|
|
2860
|
+
enableFreeDrag: !1,
|
|
2861
|
+
autoMoveWhenMouseInEdgeOnDrag: !0,
|
|
2862
|
+
dragMultiNodeRectConfig: {
|
|
2863
|
+
width: 40,
|
|
2864
|
+
height: 20,
|
|
2865
|
+
fill: "rgb(94, 200, 248)"
|
|
2866
|
+
},
|
|
2867
|
+
dragPlaceholderRectFill: "rgb(94, 200, 248)",
|
|
2868
|
+
dragPlaceholderLineConfig: {
|
|
2869
|
+
color: "rgb(94, 200, 248)",
|
|
2870
|
+
width: 2
|
|
2871
|
+
},
|
|
2872
|
+
dragOpacityConfig: {
|
|
2873
|
+
cloneNodeOpacity: .5,
|
|
2874
|
+
beingDragNodeOpacity: .3
|
|
2875
|
+
},
|
|
2876
|
+
handleDragCloneNode: null,
|
|
2877
|
+
beforeDragEnd: null,
|
|
2878
|
+
beforeDragStart: null,
|
|
2879
|
+
watermarkConfig: {
|
|
2880
|
+
onlyExport: !1,
|
|
2881
|
+
text: "",
|
|
2882
|
+
lineSpacing: 100,
|
|
2883
|
+
textSpacing: 100,
|
|
2884
|
+
angle: 30,
|
|
2885
|
+
textStyle: {
|
|
2886
|
+
color: "#999",
|
|
2887
|
+
opacity: .5,
|
|
2888
|
+
fontSize: 14
|
|
2889
|
+
},
|
|
2890
|
+
belowNode: !1
|
|
2891
|
+
},
|
|
2892
|
+
exportPaddingX: 10,
|
|
2893
|
+
exportPaddingY: 10,
|
|
2894
|
+
resetCss: "\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n ",
|
|
2895
|
+
minExportImgCanvasScale: 2,
|
|
2896
|
+
addContentToHeader: null,
|
|
2897
|
+
addContentToFooter: null,
|
|
2898
|
+
handleBeingExportSvg: null,
|
|
2899
|
+
maxCanvasSize: 16384,
|
|
2900
|
+
defaultAssociativeLineText: "关联",
|
|
2901
|
+
associativeLineIsAlwaysAboveNode: !0,
|
|
2902
|
+
associativeLineInitPointsPosition: {
|
|
2903
|
+
from: "",
|
|
2904
|
+
to: ""
|
|
2905
|
+
},
|
|
2906
|
+
enableAdjustAssociativeLinePoints: !0,
|
|
2907
|
+
beforeAssociativeLineConnection: null,
|
|
2908
|
+
disableTouchZoom: !1,
|
|
2909
|
+
minTouchZoomScale: 20,
|
|
2910
|
+
maxTouchZoomScale: -1,
|
|
2911
|
+
isLimitMindMapInCanvasWhenHasScrollbar: !0,
|
|
2912
|
+
isOnlySearchCurrentRenderNodes: !1,
|
|
2913
|
+
beforeCooperateUpdate: null,
|
|
2914
|
+
rainbowLinesConfig: {
|
|
2915
|
+
open: !1,
|
|
2916
|
+
colorsList: []
|
|
2917
|
+
},
|
|
2918
|
+
demonstrateConfig: null,
|
|
2919
|
+
enableEditFormulaInRichTextEdit: !0,
|
|
2920
|
+
katexFontPath: "https://unpkg.com/katex@0.16.11/dist/",
|
|
2921
|
+
getKatexOutputType: null,
|
|
2922
|
+
transformRichTextOnEnterEdit: null,
|
|
2923
|
+
beforeHideRichTextEdit: null,
|
|
2924
|
+
outerFramePaddingX: 10,
|
|
2925
|
+
outerFramePaddingY: 10,
|
|
2926
|
+
defaultOuterFrameText: "外框",
|
|
2927
|
+
onlyPainterNodeCustomStyles: !1,
|
|
2928
|
+
beforeDeleteNodeImg: null,
|
|
2929
|
+
imgResizeBtnSize: 25,
|
|
2930
|
+
minImgResizeWidth: 50,
|
|
2931
|
+
minImgResizeHeight: 50,
|
|
2932
|
+
maxImgResizeWidthInheritTheme: !1,
|
|
2933
|
+
maxImgResizeWidth: Infinity,
|
|
2934
|
+
maxImgResizeHeight: Infinity,
|
|
2935
|
+
customDeleteBtnInnerHTML: "",
|
|
2936
|
+
customResizeBtnInnerHTML: ""
|
|
2937
|
+
}, Q = class e {
|
|
2938
|
+
constructor(t = {}) {
|
|
2939
|
+
if (e.instanceCount++, this.opt = this.handleOpt((0, G.default)(Le, t)), this.opt.data = this.handleData(this.opt.data), this.el = this.opt.el, !this.el) throw Error("缺少容器元素el");
|
|
2940
|
+
this.getElRectInfo(), this.initWidth = this.width, this.initHeight = this.height, this.cssEl = null, this.cssTextMap = {}, this.nodeInnerPrefixList = [], this.nodeInnerPostfixList = [], this.editNodeClassList = [], this.extendShapeList = [], this.initContainer(), this.initTheme(), this.initCache(), e.pluginList.filter((e) => e.preload).forEach((e) => {
|
|
2941
|
+
this.initPlugin(e);
|
|
2942
|
+
}), this.event = new Ce({ mindMap: this }), this.keyCommand = new Ne({ mindMap: this }), this.command = new Fe({ mindMap: this }), this.renderer = new Me({ mindMap: this }), this.view = new xe({ mindMap: this }), this.batchExecution = new Ie(), e.pluginList.filter((e) => !e.preload).forEach((e) => {
|
|
2943
|
+
this.initPlugin(e);
|
|
2944
|
+
}), this.addCss(), this.render(this.opt.fit ? () => this.view.fit() : () => {}), this.opt.addHistoryOnInit && this.opt.data && this.command.addHistory();
|
|
2945
|
+
}
|
|
2946
|
+
handleOpt(e) {
|
|
2947
|
+
return ae.includes(e.layout) || (e.layout = i.LAYOUT.LOGICAL_STRUCTURE), e.theme = e.theme && Y[e.theme] ? e.theme : "default", e;
|
|
2948
|
+
}
|
|
2949
|
+
handleData(e) {
|
|
2950
|
+
return u(e) || Object.keys(e).length <= 0 ? null : (e = P(e || {}), e.data && !e.data.expand && (e.data.expand = !0), B([e], !1, null, !0), e);
|
|
2951
|
+
}
|
|
2952
|
+
initContainer() {
|
|
2953
|
+
let { associativeLineIsAlwaysAboveNode: e } = this.opt;
|
|
2954
|
+
this.el.classList.add("smm-mind-map-container");
|
|
2955
|
+
let t = () => {
|
|
2956
|
+
this.associativeLineDraw = this.draw.group(), this.associativeLineDraw.addClass("smm-associative-line-container");
|
|
2957
|
+
};
|
|
2958
|
+
this.svg = H().addTo(this.el).size(this.width, this.height), this.draw = this.svg.group(), this.draw.addClass("smm-container"), this.lineDraw = this.draw.group(), this.lineDraw.addClass("smm-line-container"), e || t(), this.nodeDraw = this.draw.group(), this.nodeDraw.addClass("smm-node-container"), e && t(), this.otherDraw = this.draw.group(), this.otherDraw.addClass("smm-other-container");
|
|
2959
|
+
}
|
|
2960
|
+
clearDraw() {
|
|
2961
|
+
this.lineDraw.clear(), this.associativeLineDraw.clear(), this.nodeDraw.clear(), this.otherDraw.clear();
|
|
2962
|
+
}
|
|
2963
|
+
appendCss(e, t) {
|
|
2964
|
+
this.cssTextMap[e] = t, this.removeCss(), this.addCss();
|
|
2965
|
+
}
|
|
2966
|
+
removeAppendCss(e) {
|
|
2967
|
+
this.cssTextMap[e] && (delete this.cssTextMap[e], this.removeCss(), this.addCss());
|
|
2968
|
+
}
|
|
2969
|
+
joinCss() {
|
|
2970
|
+
return oe + Object.keys(this.cssTextMap).map((e) => this.cssTextMap[e]).join("\n");
|
|
2971
|
+
}
|
|
2972
|
+
addCss() {
|
|
2973
|
+
this.cssEl = document.createElement("style"), this.cssEl.type = "text/css", this.cssEl.innerHTML = this.joinCss(), document.head.appendChild(this.cssEl);
|
|
2974
|
+
}
|
|
2975
|
+
removeCss() {
|
|
2976
|
+
this.cssEl && document.head.removeChild(this.cssEl);
|
|
2977
|
+
}
|
|
2978
|
+
checkEditNodeClassIndex(e) {
|
|
2979
|
+
return this.editNodeClassList.findIndex((t) => t === e);
|
|
2980
|
+
}
|
|
2981
|
+
addEditNodeClass(e) {
|
|
2982
|
+
this.checkEditNodeClassIndex(e) === -1 && this.editNodeClassList.push(e);
|
|
2983
|
+
}
|
|
2984
|
+
deleteEditNodeClass(e) {
|
|
2985
|
+
let t = this.checkEditNodeClassIndex(e);
|
|
2986
|
+
t !== -1 && this.editNodeClassList.splice(t, 1);
|
|
2987
|
+
}
|
|
2988
|
+
render(e, t = "") {
|
|
2989
|
+
this.initTheme(), this.renderer.render(e, t);
|
|
2990
|
+
}
|
|
2991
|
+
reRender(e, t = "") {
|
|
2992
|
+
this.renderer.reRender = !0, this.renderer.clearCache(), this.clearDraw(), this.render(e, t);
|
|
2993
|
+
}
|
|
2994
|
+
getElRectInfo() {
|
|
2995
|
+
if (this.elRect = this.el.getBoundingClientRect(), this.width = this.elRect.width, this.height = this.elRect.height, this.width <= 0 || this.height <= 0) throw Error("容器元素el的宽高不能为0");
|
|
2996
|
+
}
|
|
2997
|
+
resize() {
|
|
2998
|
+
let e = this.width, t = this.height;
|
|
2999
|
+
this.getElRectInfo(), this.svg.size(this.width, this.height), (e !== this.width || t !== this.height) && (this.demonstrate && this.demonstrate.isInDemonstrate || this.render()), this.emit("resize");
|
|
3000
|
+
}
|
|
3001
|
+
on(e, t) {
|
|
3002
|
+
this.event.on(e, t);
|
|
3003
|
+
}
|
|
3004
|
+
emit(e, ...t) {
|
|
3005
|
+
this.event.emit(e, ...t);
|
|
3006
|
+
}
|
|
3007
|
+
off(e, t) {
|
|
3008
|
+
this.event.off(e, t);
|
|
3009
|
+
}
|
|
3010
|
+
initCache() {
|
|
3011
|
+
this.commonCaches = {
|
|
3012
|
+
measureCustomNodeContentSizeEl: null,
|
|
3013
|
+
measureRichtextNodeTextSizeEl: null
|
|
3014
|
+
};
|
|
3015
|
+
}
|
|
3016
|
+
initTheme() {
|
|
3017
|
+
this.themeConfig = w(Y[this.opt.theme] || Y.default, this.opt.themeConfig), be.setBackgroundStyle(this.el, this.themeConfig);
|
|
3018
|
+
}
|
|
3019
|
+
setTheme(e, t = !1) {
|
|
3020
|
+
this.execCommand("CLEAR_ACTIVE_NODE"), this.opt.theme = e, t || this.render(null, i.CHANGE_THEME), this.emit("view_theme_change", e);
|
|
3021
|
+
}
|
|
3022
|
+
getTheme() {
|
|
3023
|
+
return this.opt.theme;
|
|
3024
|
+
}
|
|
3025
|
+
setThemeConfig(e, t = !1) {
|
|
3026
|
+
let n = m(this.themeConfig, e);
|
|
3027
|
+
if (this.opt.themeConfig = e, !t) {
|
|
3028
|
+
let e = le(n);
|
|
3029
|
+
this.render(null, e ? "" : i.CHANGE_THEME);
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
getCustomThemeConfig() {
|
|
3033
|
+
return this.opt.themeConfig;
|
|
3034
|
+
}
|
|
3035
|
+
getThemeConfig(e) {
|
|
3036
|
+
return e === void 0 ? this.themeConfig : this.themeConfig[e];
|
|
3037
|
+
}
|
|
3038
|
+
getConfig(e) {
|
|
3039
|
+
return e === void 0 ? this.opt : this.opt[e];
|
|
3040
|
+
}
|
|
3041
|
+
updateConfig(e = {}) {
|
|
3042
|
+
this.emit("before_update_config", this.opt);
|
|
3043
|
+
let t = { ...this.opt };
|
|
3044
|
+
this.opt = this.handleOpt(G.default.all([
|
|
3045
|
+
Le,
|
|
3046
|
+
this.opt,
|
|
3047
|
+
e
|
|
3048
|
+
])), this.emit("after_update_config", this.opt, t);
|
|
3049
|
+
}
|
|
3050
|
+
getLayout() {
|
|
3051
|
+
return this.opt.layout;
|
|
3052
|
+
}
|
|
3053
|
+
setLayout(e, t = !1) {
|
|
3054
|
+
ae.includes(e) || (e = i.LAYOUT.LOGICAL_STRUCTURE), this.opt.layout = e, this.view.reset(), this.renderer.setLayout(), t || this.render(null, i.CHANGE_LAYOUT), this.emit("layout_change", e);
|
|
3055
|
+
}
|
|
3056
|
+
execCommand(...e) {
|
|
3057
|
+
this.command.exec(...e);
|
|
3058
|
+
}
|
|
3059
|
+
updateData(e) {
|
|
3060
|
+
e = this.handleData(e), this.emit("before_update_data", e), this.renderer.setData(e), this.render(), this.command.addHistory(), this.emit("update_data", e);
|
|
3061
|
+
}
|
|
3062
|
+
setData(e) {
|
|
3063
|
+
e = this.handleData(e), this.emit("before_set_data", e), this.opt.data = e, this.execCommand("CLEAR_ACTIVE_NODE"), this.command.clearHistory(), this.command.addHistory(), this.renderer.setData(e), this.reRender(), this.emit("set_data", e);
|
|
3064
|
+
}
|
|
3065
|
+
setFullData(e) {
|
|
3066
|
+
e.root && this.setData(e.root), e.layout && this.setLayout(e.layout), e.theme && (e.theme.template && this.setTheme(e.theme.template), e.theme.config && this.setThemeConfig(e.theme.config)), e.view && this.view.setTransformData(e.view);
|
|
3067
|
+
}
|
|
3068
|
+
getData(e) {
|
|
3069
|
+
let t = this.command.getCopyData(), n = {};
|
|
3070
|
+
return n = e ? {
|
|
3071
|
+
layout: this.getLayout(),
|
|
3072
|
+
root: t,
|
|
3073
|
+
theme: {
|
|
3074
|
+
template: this.getTheme(),
|
|
3075
|
+
config: this.getCustomThemeConfig()
|
|
3076
|
+
},
|
|
3077
|
+
view: this.view.getTransformData()
|
|
3078
|
+
} : t, P(n);
|
|
3079
|
+
}
|
|
3080
|
+
async export(...e) {
|
|
3081
|
+
try {
|
|
3082
|
+
if (!this.doExport) throw Error("请注册Export插件!");
|
|
3083
|
+
return await this.doExport.export(...e);
|
|
3084
|
+
} catch (e) {
|
|
3085
|
+
this.opt.errorHandler(_.EXPORT_ERROR, e);
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
toPos(e, t) {
|
|
3089
|
+
return {
|
|
3090
|
+
x: e - this.elRect.left,
|
|
3091
|
+
y: t - this.elRect.top
|
|
3092
|
+
};
|
|
3093
|
+
}
|
|
3094
|
+
setMode(e) {
|
|
3095
|
+
if (![i.MODE.READONLY, i.MODE.EDIT].includes(e)) return;
|
|
3096
|
+
let t = e === i.MODE.READONLY;
|
|
3097
|
+
t !== this.opt.readonly && (t && (this.renderer.textEdit.isShowTextEdit() && (this.renderer.textEdit.hideEditTextBox(), this.command.originAddHistory()), this.execCommand("CLEAR_ACTIVE_NODE")), this.opt.readonly = t, !t && this.command.history.length <= 0 && this.command.originAddHistory(), this.emit("mode_change", e));
|
|
3098
|
+
}
|
|
3099
|
+
getSvgData({ paddingX: e = 0, paddingY: t = 0, ignoreWatermark: n = !1, addContentToHeader: r, addContentToFooter: i, node: a } = {}) {
|
|
3100
|
+
let { watermarkConfig: o, openPerformance: s } = this.opt;
|
|
3101
|
+
s && this.renderer.forceLoadNode(a);
|
|
3102
|
+
let { cssTextList: c, header: l, headerHeight: u, footer: d, footerHeight: p } = ee({
|
|
3103
|
+
addContentToHeader: r,
|
|
3104
|
+
addContentToFooter: i
|
|
3105
|
+
}), m = this.svg, h = this.draw, g = m.width(), _ = m.height(), v = h.transform(), y = this.elRect;
|
|
3106
|
+
h.scale(1 / v.scaleX, 1 / v.scaleY);
|
|
3107
|
+
let b = h.rbox(), x = null;
|
|
3108
|
+
a && (x = f(a, b.x, b.y, e, t)), b.width += e * 2, b.height += t * 2 + 0 + u + p, h.translate(e, t), m.size(b.width, b.height), h.translate(-b.x + y.left, -b.y + y.top);
|
|
3109
|
+
let S = m.clone(), C = this.watermark && this.watermark.hasWatermark();
|
|
3110
|
+
if (!n && C) {
|
|
3111
|
+
this.watermark.isInExport = !0;
|
|
3112
|
+
let { onlyExport: e } = o;
|
|
3113
|
+
b.width > g || b.height > _ ? (this.width = b.width, this.height = b.height, this.watermark.onResize(), S = m.clone(), this.width = g, this.height = _, this.watermark.onResize()) : e && (this.watermark.onResize(), S = m.clone()), e && this.watermark.clear(), this.watermark.isInExport = !1;
|
|
3114
|
+
}
|
|
3115
|
+
[this.joinCss(), ...c].forEach((e) => {
|
|
3116
|
+
S.add(H(`<style>${e}</style>`));
|
|
3117
|
+
}), l && u > 0 && (S.findOne(".smm-container").translate(0, u), l.width(b.width), l.y(t), S.add(l, 0)), d && p > 0 && (d.width(b.width), d.y(b.height - t - p), S.add(d));
|
|
3118
|
+
let te = m.find("defs"), w = S.find("defs");
|
|
3119
|
+
return te.forEach((e, t) => {
|
|
3120
|
+
let n = w[t];
|
|
3121
|
+
if (!n) return;
|
|
3122
|
+
let r = e.children(), i = n.children();
|
|
3123
|
+
for (let e = 0; e < r.length; e++) {
|
|
3124
|
+
let t = r[e], n = i[e];
|
|
3125
|
+
t && n && n.attr("id", t.attr("id"));
|
|
3126
|
+
}
|
|
3127
|
+
}), m.size(g, _), h.transform(v), {
|
|
3128
|
+
svg: S,
|
|
3129
|
+
svgHTML: S.svg(),
|
|
3130
|
+
clipData: x,
|
|
3131
|
+
rect: {
|
|
3132
|
+
...b,
|
|
3133
|
+
ratio: b.width / b.height
|
|
3134
|
+
},
|
|
3135
|
+
origWidth: g,
|
|
3136
|
+
origHeight: _,
|
|
3137
|
+
scaleX: v.scaleX,
|
|
3138
|
+
scaleY: v.scaleY
|
|
3139
|
+
};
|
|
3140
|
+
}
|
|
3141
|
+
addShape(e) {
|
|
3142
|
+
e && (this.extendShapeList.find((t) => t.name === e.name) || this.extendShapeList.push(e));
|
|
3143
|
+
}
|
|
3144
|
+
removeShape(e) {
|
|
3145
|
+
let t = this.extendShapeList.findIndex((t) => t.name === e);
|
|
3146
|
+
t !== -1 && this.extendShapeList.splice(t, 1);
|
|
3147
|
+
}
|
|
3148
|
+
getSvgObjects() {
|
|
3149
|
+
return {
|
|
3150
|
+
SVG: H,
|
|
3151
|
+
G: _e,
|
|
3152
|
+
Rect: n
|
|
3153
|
+
};
|
|
3154
|
+
}
|
|
3155
|
+
addPlugin(t, n) {
|
|
3156
|
+
e.hasPlugin(t) === -1 && e.usePlugin(t, n), this.initPlugin(t);
|
|
3157
|
+
}
|
|
3158
|
+
removePlugin(t) {
|
|
3159
|
+
let n = e.hasPlugin(t);
|
|
3160
|
+
n !== -1 && (e.pluginList.splice(n, 1), this[t.instanceName] && (this[t.instanceName].beforePluginRemove && this[t.instanceName].beforePluginRemove(), delete this[t.instanceName]));
|
|
3161
|
+
}
|
|
3162
|
+
initPlugin(e) {
|
|
3163
|
+
this[e.instanceName] || (this[e.instanceName] = new e({
|
|
3164
|
+
mindMap: this,
|
|
3165
|
+
pluginOpt: e.pluginOpt
|
|
3166
|
+
}));
|
|
3167
|
+
}
|
|
3168
|
+
destroy() {
|
|
3169
|
+
this.emit("beforeDestroy"), this.renderer.textEdit.hideEditTextBox(), this.renderer.textEdit.removeTextEditEl(), [...e.pluginList].forEach((e) => {
|
|
3170
|
+
this[e.instanceName] && this[e.instanceName].beforePluginDestroy && this[e.instanceName].beforePluginDestroy(), this[e.instanceName] = null;
|
|
3171
|
+
}), this.event.unbind(), this.svg.remove(), be.removeBackgroundStyle(this.el), this.el.classList.remove("smm-mind-map-container"), this.el.innerHTML = "", this.el = null, this.removeCss(), e.instanceCount--;
|
|
3172
|
+
}
|
|
3173
|
+
}, $ = [];
|
|
3174
|
+
Q.extendNodeDataNoStylePropList = (e = []) => {
|
|
3175
|
+
$.push(...e), p.push(...e);
|
|
3176
|
+
}, Q.resetNodeDataNoStylePropList = () => {
|
|
3177
|
+
$.forEach((e) => {
|
|
3178
|
+
let t = p.findIndex((t) => t === e);
|
|
3179
|
+
t !== -1 && p.splice(t, 1);
|
|
3180
|
+
}), $ = [];
|
|
3181
|
+
}, Q.pluginList = [], Q.usePlugin = (e, t = {}) => Q.hasPlugin(e) === -1 ? (e.pluginOpt = t, Q.pluginList.push(e), Q) : Q, Q.hasPlugin = (e) => Q.pluginList.findIndex((t) => t === e), Q.instanceCount = 0, Q.defineTheme = (e, t = {}) => {
|
|
3182
|
+
if (Y[e]) return /* @__PURE__ */ Error("该主题名称已存在");
|
|
3183
|
+
Y[e] = w(re, t);
|
|
3184
|
+
}, Q.removeTheme = (e) => {
|
|
3185
|
+
Y[e] && (Y[e] = null);
|
|
3186
|
+
};
|
|
3187
|
+
//#endregion
|
|
3188
|
+
export { Q as default };
|