@umbraci/jsmind 0.10.18 → 1.0.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +7 -7
  2. package/dist/jsmind.draggable-node.js +7 -472
  3. package/dist/jsmind.draggable-node.js.map +1 -1
  4. package/dist/jsmind.history.js +7 -980
  5. package/dist/jsmind.history.js.map +1 -1
  6. package/dist/jsmind.js +7 -2624
  7. package/dist/jsmind.js.map +1 -1
  8. package/dist/jsmind.multi-select.js +7 -671
  9. package/dist/jsmind.multi-select.js.map +1 -1
  10. package/dist/jsmind.multiline-text.js +7 -156
  11. package/dist/jsmind.multiline-text.js.map +1 -1
  12. package/dist/jsmind.screenshot.js +7 -156
  13. package/dist/jsmind.screenshot.js.map +1 -1
  14. package/es/jsmind.draggable-node.js +7 -443
  15. package/es/jsmind.draggable-node.js.map +1 -1
  16. package/es/jsmind.history.js +7 -944
  17. package/es/jsmind.history.js.map +1 -1
  18. package/es/jsmind.js +7 -2570
  19. package/es/jsmind.js.map +1 -1
  20. package/es/jsmind.multi-select.js +7 -621
  21. package/es/jsmind.multi-select.js.map +1 -1
  22. package/es/jsmind.multiline-text.js +7 -136
  23. package/es/jsmind.multiline-text.js.map +1 -1
  24. package/es/jsmind.screenshot.js +7 -136
  25. package/es/jsmind.screenshot.js.map +1 -1
  26. package/lib/jsmind.draggable-node.js +7 -450
  27. package/lib/jsmind.draggable-node.js.map +1 -1
  28. package/lib/jsmind.history.js +7 -946
  29. package/lib/jsmind.history.js.map +1 -1
  30. package/lib/jsmind.js +7 -2571
  31. package/lib/jsmind.js.map +1 -1
  32. package/lib/jsmind.multi-select.js +7 -623
  33. package/lib/jsmind.multi-select.js.map +1 -1
  34. package/lib/jsmind.multiline-text.js +7 -141
  35. package/lib/jsmind.multiline-text.js.map +1 -1
  36. package/lib/jsmind.screenshot.js +7 -145
  37. package/lib/jsmind.screenshot.js.map +1 -1
  38. package/package.json +26 -25
  39. package/types/generated/jsmind.d.ts +21 -24
  40. package/types/generated/jsmind.mind.d.ts +7 -0
  41. package/types/generated/{jsmind.enhanced-plugin.d.ts → jsmind.plugin-system.d.ts} +10 -10
  42. package/types/generated/jsmind.plugin.d.ts +93 -13
  43. package/types/generated/jsmind.view_provider.d.ts +1 -1
  44. package/types/generated/plugins/history/history-diff.d.ts +10 -0
  45. package/types/generated/plugins/history/jsmind.history.d.ts +2 -2
  46. package/types/generated/plugins/jsmind.draggable-node.d.ts +13 -3
  47. package/types/generated/plugins/jsmind.multi-select.d.ts +3 -3
  48. package/types/generated/plugins/jsmind.multiline-text.d.ts +67 -21
  49. package/types/generated/plugins/jsmind.screenshot.d.ts +12 -3
  50. package/types/tsconfig.declaration.json +6 -1
  51. package/dist/jsmind.copy-paste.js +0 -283
  52. package/dist/jsmind.copy-paste.js.map +0 -1
  53. package/es/jsmind.copy-paste.js +0 -260
  54. package/es/jsmind.copy-paste.js.map +0 -1
  55. package/types/generated/plugins/jsmind.multiline-text-v2.d.ts +0 -58
package/dist/jsmind.js CHANGED
@@ -1,2626 +1,9 @@
1
1
  /**
2
- * @license BSD-3-Clause
3
- * @copyright 2014-2025 hizzgdev@163.com
4
- *
5
- * Project Home:
6
- * https://github.com/hizzgdev/jsmind/
7
- */
8
- !(function (e, t) {
9
- 'object' == typeof exports && 'undefined' != typeof module
10
- ? (module.exports = t())
11
- : 'function' == typeof define && define.amd
12
- ? define(t)
13
- : ((e = 'undefined' != typeof globalThis ? globalThis : e || self).jsMind = t());
14
- })(this, function () {
15
- 'use strict';
16
- const e = '0.9.0';
17
- 'function' != typeof String.prototype.startsWith &&
18
- (String.prototype.startsWith = function (e) {
19
- return this.slice(0, e.length) === e;
20
- });
21
- const t = {
22
- left: -1,
23
- center: 0,
24
- right: 1,
25
- of: function (e) {
26
- return e && -1 !== e && 0 !== e && 1 !== e
27
- ? '-1' === e || '0' === e || '1' === e
28
- ? parseInt(e)
29
- : 'left' === e.toLowerCase()
30
- ? this.left
31
- : 'right' === e.toLowerCase()
32
- ? this.right
33
- : 'center' === e.toLowerCase()
34
- ? this.center
35
- : void 0
36
- : e;
37
- },
38
- },
39
- i = { show: 1, resize: 2, edit: 3, select: 4, reset: 5, history_change: 6 },
40
- n = { debug: 1, info: 2, warn: 3, error: 4, disable: 9 };
41
- var o = function () {};
42
- let s =
43
- 'undefined' == typeof console
44
- ? { level: o, log: o, debug: o, info: o, warn: o, error: o }
45
- : {
46
- level: function (e) {
47
- s.debug = e > n.debug ? o : console.debug;
48
- s.info = e > n.info ? o : console.info;
49
- s.warn = e > n.warn ? o : console.warn;
50
- s.error = e > n.error ? o : console.error;
51
- },
52
- log: console.log,
53
- debug: console.debug,
54
- info: console.info,
55
- warn: console.warn,
56
- error: console.error,
57
- };
58
- const r = new (class {
59
- constructor(e) {
60
- (this.w = e),
61
- (this.d = e.document),
62
- (this.g = function (e) {
63
- return this.d.getElementById(e);
64
- }),
65
- (this.c = function (e) {
66
- return this.d.createElement(e);
67
- }),
68
- (this.t = function (e, t) {
69
- e.hasChildNodes()
70
- ? (e.firstChild.nodeValue = t)
71
- : e.appendChild(this.d.createTextNode(t));
72
- }),
73
- (this.h = function (e, t) {
74
- t instanceof HTMLElement
75
- ? ((e.innerHTML = ''), e.appendChild(t))
76
- : (e.innerHTML = t);
77
- }),
78
- (this.i = function (e) {
79
- return (
80
- !!e &&
81
- 'object' == typeof e &&
82
- 1 === e.nodeType &&
83
- 'object' == typeof e.style &&
84
- 'object' == typeof e.ownerDocument
85
- );
86
- }),
87
- (this.on = function (e, t, i) {
88
- e.addEventListener
89
- ? e.addEventListener(t, i, !1)
90
- : e.attachEvent('on' + t, i);
91
- });
92
- }
93
- })(window),
94
- a = {
95
- file: {
96
- read: function (e, t) {
97
- var i = new FileReader();
98
- (i.onload = function () {
99
- 'function' == typeof t && t(this.result, e.name);
100
- }),
101
- i.readAsText(e);
102
- },
103
- save: function (e, t, i) {
104
- var n;
105
- if ('function' == typeof r.w.Blob) n = new Blob([e], { type: t });
106
- else {
107
- var o = new (r.w.BlobBuilder ||
108
- r.w.MozBlobBuilder ||
109
- r.w.WebKitBlobBuilder ||
110
- r.w.MSBlobBuilder)();
111
- o.append(e), (n = o.getBlob(t));
112
- }
113
- if (navigator.msSaveBlob) navigator.msSaveBlob(n, i);
114
- else {
115
- var s = (r.w.URL || r.w.webkitURL).createObjectURL(n),
116
- a = r.c('a');
117
- if ('download' in a) {
118
- (a.style.visibility = 'hidden'),
119
- (a.href = s),
120
- (a.download = i),
121
- r.d.body.appendChild(a);
122
- var d = r.d.createEvent('MouseEvents');
123
- d.initEvent('click', !0, !0),
124
- a.dispatchEvent(d),
125
- r.d.body.removeChild(a);
126
- } else location.href = s;
127
- }
128
- },
129
- },
130
- json: {
131
- json2string: function (e) {
132
- return JSON.stringify(e);
133
- },
134
- string2json: function (e) {
135
- return JSON.parse(e);
136
- },
137
- merge: function (e, t) {
138
- for (var i in t)
139
- i in e
140
- ? 'object' != typeof e[i] ||
141
- '[object object]' !=
142
- Object.prototype.toString.call(e[i]).toLowerCase() ||
143
- e[i].length
144
- ? (e[i] = t[i])
145
- : a.json.merge(e[i], t[i])
146
- : (e[i] = t[i]);
147
- return e;
148
- },
149
- },
150
- uuid: {
151
- newid: function () {
152
- return (
153
- new Date().getTime().toString(16) + Math.random().toString(16).substring(2)
154
- ).substring(2, 18);
155
- },
156
- },
157
- text: {
158
- is_empty: function (e) {
159
- return !e || 0 == e.replace(/\s*/, '').length;
160
- },
161
- },
162
- },
163
- d = {
164
- container: '',
165
- editable: !1,
166
- theme: null,
167
- mode: 'full',
168
- support_html: !0,
169
- log_level: 'info',
170
- view: {
171
- engine: 'canvas',
172
- enable_device_pixel_ratio: !1,
173
- hmargin: 100,
174
- vmargin: 50,
175
- line_width: 2,
176
- line_color: '#555',
177
- line_style: 'curved',
178
- draggable: !1,
179
- hide_scrollbars_when_draggable: !1,
180
- node_overflow: 'hidden',
181
- zoom: { min: 0.5, max: 2.1, step: 0.1, mask_key: 4096 },
182
- custom_node_render: null,
183
- expander_style: 'char',
184
- },
185
- layout: { hspace: 30, vspace: 20, pspace: 13, cousin_space: 0 },
186
- default_event_handle: {
187
- enable_mousedown_handle: !0,
188
- enable_click_handle: !0,
189
- enable_dblclick_handle: !0,
190
- enable_mousewheel_handle: !0,
191
- },
192
- shortcut: {
193
- enable: !0,
194
- handles: {},
195
- mapping: {
196
- addchild: [45, 4109],
197
- addbrother: 13,
198
- editnode: 113,
199
- delnode: 46,
200
- toggle: 32,
201
- left: 37,
202
- up: 38,
203
- right: 39,
204
- down: 40,
205
- },
206
- },
207
- fieldNames: {
208
- id: 'id',
209
- topic: 'topic',
210
- children: 'children',
211
- parentid: 'parentid',
212
- isroot: 'isroot',
213
- direction: 'direction',
214
- expanded: 'expanded',
215
- },
216
- plugin: {},
217
- };
218
- class l {
219
- constructor(e, t, i, n, o, r, a, d) {
220
- e
221
- ? 'number' == typeof t
222
- ? (void 0 === d && (d = !0),
223
- (this.id = e),
224
- (this.index = t),
225
- (this.topic = i),
226
- (this.data = n || {}),
227
- (this.isroot = o),
228
- (this.parent = r),
229
- (this.direction = a),
230
- (this.expanded = !!d),
231
- (this.children = []),
232
- (this._data = {}))
233
- : s.error('invalid node index')
234
- : s.error('invalid node id');
235
- }
236
- get_location() {
237
- var e = this._data.view;
238
- return { x: e.abs_x, y: e.abs_y };
239
- }
240
- get_size() {
241
- var e = this._data.view;
242
- return { w: e.width, h: e.height };
243
- }
244
- static compare(e, t) {
245
- var i = e.index,
246
- n = t.index;
247
- return i >= 0 && n >= 0
248
- ? i - n
249
- : -1 == i && -1 == n
250
- ? 0
251
- : -1 == i
252
- ? 1
253
- : -1 == n
254
- ? -1
255
- : 0;
256
- }
257
- static inherited(e, t) {
258
- if (e && t) {
259
- if (e.id === t.id) return !0;
260
- if (e.isroot) return !0;
261
- for (var i = e.id, n = t; !n.isroot; ) if ((n = n.parent).id === i) return !0;
262
- }
263
- return !1;
264
- }
265
- static is_node(e) {
266
- return !!e && e instanceof l;
267
- }
268
- toObject(e, t = !1) {
269
- var i = e || {},
270
- n = i.id || 'id',
271
- o = i.topic || 'topic',
272
- s = i.children || 'children',
273
- r = i.direction || 'direction',
274
- a = i.expanded || 'expanded',
275
- d = {};
276
- if (
277
- ((d[n] = this.id),
278
- (d[o] = this.topic),
279
- (d[a] = this.expanded),
280
- this.parent &&
281
- this.parent.isroot &&
282
- (d[r] = -1 === this.direction ? 'left' : 'right'),
283
- null != this.data)
284
- )
285
- for (var l in this.data) d[l] = this.data[l];
286
- return (
287
- t && this.children.length > 0 && (d[s] = this.children.map(t => t.toObject(e, !0))),
288
- d
289
- );
290
- }
291
- }
292
- class h {
293
- constructor() {
294
- (this.name = null),
295
- (this.author = null),
296
- (this.version = null),
297
- (this.root = null),
298
- (this.selected = null),
299
- (this.nodes = {});
300
- }
301
- get_node(e) {
302
- return e in this.nodes
303
- ? this.nodes[e]
304
- : (s.warn('the node[id=' + e + '] can not be found'), null);
305
- }
306
- set_root(e, t, i) {
307
- return null == this.root
308
- ? ((this.root = new l(e, 0, t, i, !0)), this._put_node(this.root), this.root)
309
- : (s.error('root node is already exist'), null);
310
- }
311
- add_node(e, i, n, o, r, a, d) {
312
- if (!l.is_node(e)) return s.error('the parent_node ' + e + ' is not a node.'), null;
313
- var h = new l(i, d || -1, n, o, !1, e, e.direction, a);
314
- return (
315
- e.isroot && (h.direction = r || t.right),
316
- this._put_node(h)
317
- ? (e.children.push(h), this._update_index(e))
318
- : (s.error("fail, the node id '" + h.id + "' has been already exist."),
319
- (h = null)),
320
- h
321
- );
322
- }
323
- insert_node_before(e, t, i, n, o) {
324
- if (!l.is_node(e)) return s.error('the node_before ' + e + ' is not a node.'), null;
325
- var r = e.index - 0.5;
326
- return this.add_node(e.parent, t, i, n, o, !0, r);
327
- }
328
- get_node_before(e) {
329
- if (!l.is_node(e)) {
330
- var t = this.get_node(e);
331
- return t
332
- ? this.get_node_before(t)
333
- : (s.error('the node[id=' + e + '] can not be found.'), null);
334
- }
335
- if (e.isroot) return null;
336
- var i = e.index - 2;
337
- return i >= 0 ? e.parent.children[i] : null;
338
- }
339
- insert_node_after(e, t, i, n, o) {
340
- if (!l.is_node(e)) return s.error('the node_after ' + e + ' is not a node.'), null;
341
- var r = e.index + 0.5;
342
- return this.add_node(e.parent, t, i, n, o, !0, r);
343
- }
344
- get_node_after(e) {
345
- if (!l.is_node(e)) {
346
- var t = this.get_node(e);
347
- return t
348
- ? this.get_node_after(t)
349
- : (s.error('the node[id=' + e + '] can not be found.'), null);
350
- }
351
- if (e.isroot) return null;
352
- var i = e.index;
353
- return e.parent.children.length > i ? e.parent.children[i] : null;
354
- }
355
- move_node(e, t, i, n) {
356
- return l.is_node(e)
357
- ? (i || (i = e.parent.id), this._move_node(e, t, i, n))
358
- : (s.error('the parameter node ' + e + ' is not a node.'), null);
359
- }
360
- _flow_node_direction(e, t) {
361
- void 0 === t ? (t = e.direction) : (e.direction = t);
362
- for (var i = e.children.length; i--; ) this._flow_node_direction(e.children[i], t);
363
- }
364
- _move_node_internal(e, t) {
365
- if (e && t)
366
- if ('_last_' == t) (e.index = -1), this._update_index(e.parent);
367
- else if ('_first_' == t) (e.index = 0), this._update_index(e.parent);
368
- else {
369
- var i = t ? this.get_node(t) : null;
370
- null != i &&
371
- null != i.parent &&
372
- i.parent.id == e.parent.id &&
373
- ((e.index = i.index - 0.5), this._update_index(e.parent));
374
- }
375
- return e;
376
- }
377
- _move_node(e, i, n, o) {
378
- if (e && n) {
379
- var r = this.get_node(n);
380
- if (l.inherited(e, r)) return s.error('can not move a node to its children'), null;
381
- if (e.parent.id != n) {
382
- for (var a = e.parent.children, d = a.length; d--; )
383
- if (a[d].id == e.id) {
384
- a.splice(d, 1);
385
- break;
386
- }
387
- let t = e.parent;
388
- (e.parent = r), r.children.push(e), this._update_index(t);
389
- }
390
- e.parent.isroot
391
- ? o == t.left
392
- ? (e.direction = o)
393
- : (e.direction = t.right)
394
- : (e.direction = e.parent.direction),
395
- this._move_node_internal(e, i),
396
- this._flow_node_direction(e);
397
- }
398
- return e;
399
- }
400
- remove_node(e) {
401
- if (!l.is_node(e)) return s.error('the parameter node ' + e + ' is not a node.'), !1;
402
- if (e.isroot) return s.error('fail, can not remove root node'), !1;
403
- null != this.selected && this.selected.id == e.id && (this.selected = null);
404
- for (var t = e.children, i = t.length; i--; ) this.remove_node(t[i]);
405
- t.length = 0;
406
- for (var n = e.parent, o = n.children, r = o.length; r--; )
407
- if (o[r].id == e.id) {
408
- o.splice(r, 1);
409
- break;
410
- }
411
- for (var a in (delete this.nodes[e.id], e)) delete e[a];
412
- return (e = null), this._update_index(n), !0;
413
- }
414
- _put_node(e) {
415
- return e.id in this.nodes
416
- ? (s.warn("the node_id '" + e.id + "' has been already exist."), !1)
417
- : ((this.nodes[e.id] = e), !0);
418
- }
419
- _update_index(e) {
420
- if (e instanceof l) {
421
- e.children.sort(l.compare);
422
- for (var t = 0; t < e.children.length; t++) e.children[t].index = t + 1;
423
- }
424
- }
425
- }
426
- const _ = { name: 'jsMind', author: 'UmbraCi', version: e },
427
- u = {
428
- node_tree: {
429
- example: {
430
- meta: _,
431
- format: 'node_tree',
432
- data: { id: 'root', topic: 'jsMind node_tree example' },
433
- },
434
- get_mind: function (e, t) {
435
- var i = u.node_tree,
436
- n = new h();
437
- return (
438
- (n.name = e.meta.name),
439
- (n.author = e.meta.author),
440
- (n.version = e.meta.version),
441
- i._parse(n, e.data, t),
442
- n
443
- );
444
- },
445
- get_data: function (e, t) {
446
- var i = u.node_tree,
447
- n = {};
448
- return (
449
- (n.meta = { name: e.name, author: e.author, version: e.version }),
450
- (n.format = 'node_tree'),
451
- (n.data = i._build_node(e.root, t)),
452
- n
453
- );
454
- },
455
- _parse: function (e, t, i) {
456
- var n = u.node_tree,
457
- o = i || {},
458
- s = o.id || 'id',
459
- r = o.topic || 'topic',
460
- a = o.children || 'children',
461
- d = n._extract_data(t, i);
462
- if ((e.set_root(t[s], t[r], d), a in t))
463
- for (var l = t[a], h = 0; h < l.length; h++)
464
- n._extract_subnode(e, e.root, l[h], i);
465
- },
466
- _extract_data: function (e, t) {
467
- var i = t || {},
468
- n = i.id || 'id',
469
- o = i.topic || 'topic',
470
- s = i.children || 'children',
471
- r = i.direction || 'direction',
472
- a = i.expanded || 'expanded',
473
- d = {};
474
- for (var l in e)
475
- l != n && l != o && l != s && l != r && l != a && (d[l] = e[l]);
476
- return d;
477
- },
478
- _extract_subnode: function (e, i, n, o) {
479
- var s = u.node_tree,
480
- r = o || {},
481
- a = r.id || 'id',
482
- d = r.topic || 'topic',
483
- l = r.children || 'children',
484
- h = r.direction || 'direction',
485
- _ = r.expanded || 'expanded',
486
- c = s._extract_data(n, o),
487
- p = null;
488
- i.isroot && (p = 'left' == n[h] ? t.left : t.right);
489
- var v = e.add_node(i, n[a], n[d], c, p, n[_]);
490
- if (n[l])
491
- for (var g = n[l], f = 0; f < g.length; f++)
492
- s._extract_subnode(e, v, g[f], o);
493
- },
494
- _build_node: function (e, i) {
495
- var n = u.node_tree;
496
- if (e instanceof l) {
497
- var o = i || {},
498
- s = o.id || 'id',
499
- r = o.topic || 'topic',
500
- a = o.children || 'children',
501
- d = o.direction || 'direction',
502
- h = o.expanded || 'expanded',
503
- _ = {};
504
- if (
505
- ((_[s] = e.id),
506
- (_[r] = e.topic),
507
- (_[h] = e.expanded),
508
- e.parent &&
509
- e.parent.isroot &&
510
- (_[d] = e.direction == t.left ? 'left' : 'right'),
511
- null != e.data)
512
- ) {
513
- var c = e.data;
514
- for (var p in c) _[p] = c[p];
515
- }
516
- var v = e.children;
517
- if (v.length > 0) {
518
- _[a] = [];
519
- for (var g = 0; g < v.length; g++) _[a].push(n._build_node(v[g], i));
520
- }
521
- return _;
522
- }
523
- },
524
- },
525
- node_array: {
526
- example: {
527
- meta: _,
528
- format: 'node_array',
529
- data: [{ id: 'root', topic: 'jsMind node_array example', isroot: !0 }],
530
- },
531
- get_mind: function (e, t) {
532
- var i = u.node_array,
533
- n = new h();
534
- return (
535
- (n.name = e.meta.name),
536
- (n.author = e.meta.author),
537
- (n.version = e.meta.version),
538
- i._parse(n, e.data, t),
539
- n
540
- );
541
- },
542
- get_data: function (e, t) {
543
- var i = u.node_array,
544
- n = {};
545
- return (
546
- (n.meta = { name: e.name, author: e.author, version: e.version }),
547
- (n.format = 'node_array'),
548
- (n.data = []),
549
- i._array(e, n.data, t),
550
- n
551
- );
552
- },
553
- _parse: function (e, t, i) {
554
- var n = u.node_array,
555
- o = t.slice(0);
556
- o.reverse();
557
- var r = n._extract_root(e, o, i);
558
- r ? n._extract_subnode(e, r, o, i) : s.error('root node can not be found');
559
- },
560
- _extract_root: function (e, t, i) {
561
- for (
562
- var n = u.node_array,
563
- o = i || {},
564
- s = o.id || 'id',
565
- r = o.topic || 'topic',
566
- a = o.isroot || 'isroot',
567
- d = t.length;
568
- d--;
569
-
570
- )
571
- if (a in t[d] && t[d][a]) {
572
- var l = t[d],
573
- h = n._extract_data(l, i),
574
- _ = e.set_root(l[s], l[r], h);
575
- return t.splice(d, 1), _;
576
- }
577
- return null;
578
- },
579
- _extract_subnode: function (e, i, n, o) {
580
- for (
581
- var s = u.node_array,
582
- r = o || {},
583
- a = r.id || 'id',
584
- d = r.topic || 'topic',
585
- l = r.parentid || 'parentid',
586
- h = r.direction || 'direction',
587
- _ = r.expanded || 'expanded',
588
- c = n.length,
589
- p = null,
590
- v = null,
591
- g = 0;
592
- c--;
593
-
594
- )
595
- if ((p = n[c])[l] == i.id) {
596
- v = s._extract_data(p, o);
597
- var f = null,
598
- m = p[h];
599
- m && (f = 'left' == m ? t.left : t.right);
600
- var w = e.add_node(i, p[a], p[d], v, f, p[_]);
601
- n.splice(c, 1), g++;
602
- var y = s._extract_subnode(e, w, n, o);
603
- y > 0 && ((c = n.length), (g += y));
604
- }
605
- return g;
606
- },
607
- _extract_data: function (e, t) {
608
- var i = t || {},
609
- n = i.id || 'id',
610
- o = i.topic || 'topic',
611
- s = i.parentid || 'parentid',
612
- r = i.isroot || 'isroot',
613
- a = i.direction || 'direction',
614
- d = i.expanded || 'expanded',
615
- l = {};
616
- for (var h in e)
617
- h != n && h != o && h != s && h != r && h != a && h != d && (l[h] = e[h]);
618
- return l;
619
- },
620
- _array: function (e, t, i) {
621
- u.node_array._array_node(e.root, t, i);
622
- },
623
- _array_node: function (e, i, n) {
624
- var o = u.node_array;
625
- if (e instanceof l) {
626
- var s = n || {},
627
- r = s.id || 'id',
628
- a = s.topic || 'topic',
629
- d = s.parentid || 'parentid',
630
- h = s.isroot || 'isroot',
631
- _ = s.direction || 'direction',
632
- c = s.expanded || 'expanded',
633
- p = {};
634
- if (
635
- ((p[r] = e.id),
636
- (p[a] = e.topic),
637
- (p[c] = e.expanded),
638
- e.parent && (p[d] = e.parent.id),
639
- e.isroot && (p[h] = !0),
640
- e.parent &&
641
- e.parent.isroot &&
642
- (p[_] = e.direction == t.left ? 'left' : 'right'),
643
- null != e.data)
644
- ) {
645
- var v = e.data;
646
- for (var g in v) p[g] = v[g];
647
- }
648
- i.push(p);
649
- for (var f = e.children.length, m = 0; m < f; m++)
650
- o._array_node(e.children[m], i, n);
651
- }
652
- },
653
- },
654
- freemind: {
655
- example: {
656
- meta: _,
657
- format: 'freemind',
658
- data: '<map version="1.0.1"><node ID="root" TEXT="jsMind freemind example"/></map>',
659
- },
660
- get_mind: function (e, t) {
661
- var i = u.freemind,
662
- n = new h();
663
- (n.name = e.meta.name),
664
- (n.author = e.meta.author),
665
- (n.version = e.meta.version);
666
- var o = e.data,
667
- s = i._parse_xml(o),
668
- r = i._find_root(s);
669
- return i._load_node(n, null, r), n;
670
- },
671
- get_data: function (e, t) {
672
- var i = u.freemind,
673
- n = {};
674
- (n.meta = { name: e.name, author: e.author, version: e.version }),
675
- (n.format = 'freemind');
676
- var o = [];
677
- return (
678
- o.push('<map version="1.0.1">'),
679
- i._build_map(e.root, o),
680
- o.push('</map>'),
681
- (n.data = o.join('')),
682
- n
683
- );
684
- },
685
- _parse_xml: function (e) {
686
- var t = null;
687
- window.DOMParser
688
- ? (t = new DOMParser().parseFromString(e, 'text/xml'))
689
- : (((t = new ActiveXObject('Microsoft.XMLDOM')).async = !1), t.loadXML(e));
690
- return t;
691
- },
692
- _find_root: function (e) {
693
- for (var t = e.childNodes, i = null, n = null, o = 0; o < t.length; o++)
694
- if (1 == (n = t[o]).nodeType && 'map' == n.tagName) {
695
- i = n;
696
- break;
697
- }
698
- if (i) {
699
- var s = i.childNodes;
700
- i = null;
701
- for (o = 0; o < s.length; o++)
702
- if (1 == (n = s[o]).nodeType && 'node' == n.tagName) {
703
- i = n;
704
- break;
705
- }
706
- }
707
- return i;
708
- },
709
- _load_node: function (e, i, n) {
710
- var o = u.freemind,
711
- s = n.getAttribute('ID'),
712
- r = n.getAttribute('TEXT'),
713
- a = n.getAttribute('FOLDED');
714
- if (null == r)
715
- for (var d = n.childNodes, l = null, h = 0; h < d.length; h++)
716
- if (1 == (l = d[h]).nodeType && 'richcontent' === l.tagName) {
717
- r = l.textContent;
718
- break;
719
- }
720
- var _ = o._load_attributes(n),
721
- c = 'expanded' in _ ? 'true' == _.expanded : 'true' != a;
722
- delete _.expanded;
723
- var p = n.getAttribute('COLOR');
724
- p && (_['foreground-color'] = p);
725
- var v = n.getAttribute('BACKGROUND_COLOR');
726
- v && (_['background-color'] = v);
727
- var g = n.getAttribute('POSITION'),
728
- f = null;
729
- g && (f = 'left' == g ? t.left : t.right);
730
- var m = null;
731
- m = i ? e.add_node(i, s, r, _, f, c) : e.set_root(s, r, _);
732
- var w = n.childNodes,
733
- y = null;
734
- for (h = 0; h < w.length; h++)
735
- 1 == (y = w[h]).nodeType && 'node' == y.tagName && o._load_node(e, m, y);
736
- },
737
- _load_attributes: function (e) {
738
- for (var t = e.childNodes, i = null, n = {}, o = 0; o < t.length; o++)
739
- 1 == (i = t[o]).nodeType &&
740
- 'attribute' === i.tagName &&
741
- (n[i.getAttribute('NAME')] = i.getAttribute('VALUE'));
742
- return n;
743
- },
744
- _build_map: function (e, i) {
745
- var n = u.freemind,
746
- o = null,
747
- s = e.data;
748
- if (
749
- (e.parent &&
750
- e.parent.isroot &&
751
- (o = e.direction === t.left ? 'left' : 'right'),
752
- i.push('<node'),
753
- i.push(' ID="' + e.id + '"'),
754
- o && i.push(' POSITION="' + o + '"'),
755
- e.expanded || i.push(' FOLDED="true"'),
756
- s['foreground-color'] && i.push(' COLOR="' + s['foreground-color'] + '"'),
757
- s['background-color'] &&
758
- i.push(' BACKGROUND_COLOR="' + s['background-color'] + '"'),
759
- i.push(' TEXT="' + n._escape(e.topic) + '">'),
760
- null != s)
761
- )
762
- for (var r in s)
763
- 'foreground-color' !== r &&
764
- 'background-color' !== r &&
765
- i.push('<attribute NAME="' + r + '" VALUE="' + s[r] + '"/>');
766
- for (var a = e.children, d = 0; d < a.length; d++) n._build_map(a[d], i);
767
- i.push('</node>');
768
- },
769
- _escape: function (e) {
770
- return e
771
- .replace(/&/g, '&amp;')
772
- .replace(/</g, '&lt;')
773
- .replace(/>/g, '&gt;')
774
- .replace(/'/g, '&apos;')
775
- .replace(/"/g, '&quot;');
776
- },
777
- },
778
- text: {
779
- example: {
780
- meta: _,
781
- format: 'text',
782
- data: 'jsMind text example\n node1\n node1-sub\n node1-sub\n node2',
783
- },
784
- _line_regex: /\s*/,
785
- get_mind: function (e, t) {
786
- var i = u.text,
787
- n = new h();
788
- (n.name = e.meta.name),
789
- (n.author = e.meta.author),
790
- (n.version = e.meta.version);
791
- var o = e.data.split(/\n|\r/);
792
- return i._fill_nodes(n, o, 0, 0), n;
793
- },
794
- _fill_nodes: function (e, t) {
795
- let i = [],
796
- n = 0;
797
- for (; n < t.length; ) {
798
- let o = t[n],
799
- s = o.match(/\s*/)[0].length,
800
- r = o.substr(s);
801
- if (0 == s && i.length > 0)
802
- return void log.error('more than 1 root node was found: ' + r);
803
- if (s > i.length) return void log.error('a suspended node was found: ' + r);
804
- let d = i.length - s;
805
- for (; d--; ) i.pop();
806
- if (0 == s && 0 == i.length) {
807
- let t = e.set_root(a.uuid.newid(), r);
808
- i.push(t);
809
- } else {
810
- let t = e.add_node(i[s - 1], a.uuid.newid(), r, {}, null);
811
- i.push(t);
812
- }
813
- n++;
814
- }
815
- i.length = 0;
816
- },
817
- get_data: function (e) {
818
- var t = u.text,
819
- i = {};
820
- (i.meta = { name: e.name, author: e.author, version: e.version }),
821
- (i.format = 'text');
822
- let n = [];
823
- return t._build_lines(n, [e.root], 0), (i.data = n.join('\n')), i;
824
- },
825
- _build_lines: function (e, t, i) {
826
- let n = new Array(i + 1).join(' ');
827
- for (let o of t)
828
- e.push(n + o.topic),
829
- o.children && u.text._build_lines(e, o.children, i + 1);
830
- },
831
- },
832
- };
833
- class c {
834
- constructor(e) {
835
- this.jm = e;
836
- }
837
- init() {
838
- s.debug('data.init');
839
- }
840
- reset() {
841
- s.debug('data.reset');
842
- }
843
- load(e) {
844
- var t = null,
845
- i = null;
846
- t = 'object' == typeof e ? (e.format ? e.format : 'node_tree') : 'freemind';
847
- var n = this.jm.options.fieldNames;
848
- return (
849
- 'node_array' == t
850
- ? (i = u.node_array.get_mind(e, n))
851
- : 'node_tree' == t
852
- ? (i = u.node_tree.get_mind(e, n))
853
- : 'freemind' == t
854
- ? (i = u.freemind.get_mind(e, n))
855
- : 'text' == t
856
- ? (i = u.text.get_mind(e, n))
857
- : s.warn('unsupported format'),
858
- i
859
- );
860
- }
861
- get_data(e) {
862
- var t = null,
863
- i = this.jm.options.fieldNames;
864
- return (
865
- 'node_array' == e
866
- ? (t = u.node_array.get_data(this.jm.mind, i))
867
- : 'node_tree' == e
868
- ? (t = u.node_tree.get_data(this.jm.mind, i))
869
- : 'freemind' == e
870
- ? (t = u.freemind.get_data(this.jm.mind))
871
- : 'text' == e
872
- ? (t = u.text.get_data(this.jm.mind))
873
- : s.error('unsupported ' + e + ' format'),
874
- t
875
- );
876
- }
877
- }
878
- class p {
879
- constructor(e, t) {
880
- (this.opts = t),
881
- (this.jm = e),
882
- (this.isside = 'side' == this.opts.mode),
883
- (this.bounds = null),
884
- (this.cache_valid = !1);
885
- }
886
- init() {
887
- s.debug('layout.init');
888
- }
889
- reset() {
890
- s.debug('layout.reset'), (this.bounds = { n: 0, s: 0, w: 0, e: 0 });
891
- }
892
- calculate_next_child_direction(e) {
893
- if (this.isside) return t.right;
894
- for (var i = e.children || [], n = i.length, o = 0, s = 0; s < n; s++)
895
- i[s].direction === t.left ? o-- : o++;
896
- return n > 1 && o > 0 ? t.left : t.right;
897
- }
898
- layout() {
899
- s.debug('layout.layout'), this.layout_direction(), this.layout_offset();
900
- }
901
- layout_direction() {
902
- this._layout_direction_root();
903
- }
904
- _layout_direction_root() {
905
- var e = this.jm.mind.root,
906
- i = null;
907
- 'layout' in e._data ? (i = e._data.layout) : ((i = {}), (e._data.layout = i));
908
- var n = e.children,
909
- o = n.length;
910
- if (((i.direction = t.center), (i.side_index = 0), this.isside))
911
- for (var s = o; s--; ) this._layout_direction_side(n[s], t.right, s);
912
- else {
913
- s = o;
914
- for (var r = null; s--; )
915
- (r = n[s]).direction == t.left
916
- ? this._layout_direction_side(r, t.left, s)
917
- : this._layout_direction_side(r, t.right, s);
918
- }
919
- }
920
- _layout_direction_side(e, t, i) {
921
- var n = null;
922
- 'layout' in e._data ? (n = e._data.layout) : ((n = {}), (e._data.layout = n));
923
- var o = e.children,
924
- s = o.length;
925
- (n.direction = t), (n.side_index = i);
926
- for (var r = s; r--; ) this._layout_direction_side(o[r], t, r);
927
- }
928
- layout_offset() {
929
- var e = this.jm.mind.root,
930
- i = e._data.layout;
931
- (i.offset_x = 0), (i.offset_y = 0), (i.outer_height = 0);
932
- for (var n = e.children, o = n.length, s = [], r = [], a = null; o--; )
933
- (a = n[o])._data.layout.direction == t.right ? r.unshift(a) : s.unshift(a);
934
- (i.left_nodes = s),
935
- (i.right_nodes = r),
936
- (i.outer_height_left = this._layout_offset_subnodes(s)),
937
- (i.outer_height_right = this._layout_offset_subnodes(r)),
938
- (this.bounds.e = e._data.view.width / 2),
939
- (this.bounds.w = 0 - this.bounds.e),
940
- (this.bounds.n = 0),
941
- (this.bounds.s = Math.max(i.outer_height_left, i.outer_height_right));
942
- }
943
- _layout_offset_subnodes(e) {
944
- for (var t = 0, i = e.length, n = i, o = null, s = 0, r = null, a = 0, d = null; n--; )
945
- (r = (o = e[n])._data.layout),
946
- null == d && (d = o.parent._data),
947
- (s = this._layout_offset_subnodes(o.children)),
948
- o.expanded || ((s = 0), this.set_visible(o.children, !1)),
949
- (s = Math.max(o._data.view.height, s)),
950
- this._should_reserve_cousin_space(o) && (s += this.opts.cousin_space),
951
- (r.outer_height = s),
952
- (r.offset_y = a - s / 2),
953
- (r.offset_x =
954
- this.opts.hspace * r.direction +
955
- (d.view.width * (d.layout.direction + r.direction)) / 2),
956
- o.parent.isroot || (r.offset_x += this.opts.pspace * r.direction),
957
- (a = a - s - this.opts.vspace),
958
- (t += s);
959
- i > 1 && (t += this.opts.vspace * (i - 1)), (n = i);
960
- for (var l = t / 2; n--; ) (o = e[n])._data.layout.offset_y += l;
961
- return t;
962
- }
963
- _layout_offset_subnodes_height(e) {
964
- for (var t = 0, i = e.length, n = i, o = null, s = 0, r = null, a = 0, d = null; n--; )
965
- (r = (o = e[n])._data.layout),
966
- null == d && (d = o.parent._data),
967
- (s = this._layout_offset_subnodes_height(o.children)),
968
- o.expanded || (s = 0),
969
- (s = Math.max(o._data.view.height, s)),
970
- this._should_reserve_cousin_space(o) && (s += this.opts.cousin_space),
971
- (r.outer_height = s),
972
- (r.offset_y = a - s / 2),
973
- (a = a - s - this.opts.vspace),
974
- (t += s);
975
- i > 1 && (t += this.opts.vspace * (i - 1)), (n = i);
976
- for (var l = t / 2; n--; ) (o = e[n])._data.layout.offset_y += l;
977
- return t;
978
- }
979
- _should_reserve_cousin_space(e) {
980
- return e.children.length > 0 && e.parent.children.length > 1;
981
- }
982
- get_node_offset(e) {
983
- var t = e._data.layout,
984
- i = null;
985
- if (
986
- ('_offset_' in t && this.cache_valid
987
- ? (i = t._offset_)
988
- : ((i = { x: -1, y: -1 }), (t._offset_ = i)),
989
- -1 == i.x || -1 == i.y)
990
- ) {
991
- var n = t.offset_x,
992
- o = t.offset_y;
993
- if (!e.isroot) {
994
- var s = this.get_node_offset(e.parent);
995
- (n += s.x), (o += s.y);
996
- }
997
- (i.x = n), (i.y = o);
998
- }
999
- return i;
1000
- }
1001
- get_node_point(e) {
1002
- var t = e._data.view,
1003
- i = this.get_node_offset(e),
1004
- n = {};
1005
- return (
1006
- (n.x = i.x + (t.width * (e._data.layout.direction - 1)) / 2),
1007
- (n.y = i.y - t.height / 2),
1008
- n
1009
- );
1010
- }
1011
- get_node_point_in(e) {
1012
- return this.get_node_offset(e);
1013
- }
1014
- get_node_point_out(e) {
1015
- var t = e._data.layout,
1016
- i = null;
1017
- if (
1018
- ('_pout_' in t && this.cache_valid
1019
- ? (i = t._pout_)
1020
- : ((i = { x: -1, y: -1 }), (t._pout_ = i)),
1021
- -1 == i.x || -1 == i.y)
1022
- )
1023
- if (e.isroot) (i.x = 0), (i.y = 0);
1024
- else {
1025
- var n = e._data.view,
1026
- o = this.get_node_offset(e);
1027
- (i.x = o.x + (n.width + this.opts.pspace) * e._data.layout.direction),
1028
- (i.y = o.y);
1029
- }
1030
- return i;
1031
- }
1032
- get_expander_point(e) {
1033
- var i = this.get_node_point_out(e),
1034
- n = {};
1035
- return (
1036
- e._data.layout.direction == t.right ? (n.x = i.x - this.opts.pspace) : (n.x = i.x),
1037
- (n.y = i.y - Math.ceil(this.opts.pspace / 2)),
1038
- n
1039
- );
1040
- }
1041
- get_min_size() {
1042
- var e = this.jm.mind.nodes,
1043
- t = null,
1044
- i = null;
1045
- for (var n in e)
1046
- (t = e[n]),
1047
- (i = this.get_node_point_out(t)).x > this.bounds.e && (this.bounds.e = i.x),
1048
- i.x < this.bounds.w && (this.bounds.w = i.x);
1049
- return { w: this.bounds.e - this.bounds.w, h: this.bounds.s - this.bounds.n };
1050
- }
1051
- toggle_node(e) {
1052
- e.isroot || (e.expanded ? this.collapse_node(e) : this.expand_node(e));
1053
- }
1054
- expand_node(e) {
1055
- (e.expanded = !0),
1056
- this.part_layout(e),
1057
- this.set_visible(e.children, !0),
1058
- this.jm.invoke_event_handle(i.show, { evt: 'expand_node', data: [], node: e.id });
1059
- }
1060
- collapse_node(e) {
1061
- (e.expanded = !1),
1062
- this.part_layout(e),
1063
- this.set_visible(e.children, !1),
1064
- this.jm.invoke_event_handle(i.show, { evt: 'collapse_node', data: [], node: e.id });
1065
- }
1066
- expand_all() {
1067
- var e,
1068
- t = this.jm.mind.nodes,
1069
- i = 0;
1070
- for (var n in t) (e = t[n]).expanded || ((e.expanded = !0), i++);
1071
- if (i > 0) {
1072
- var o = this.jm.mind.root;
1073
- this.part_layout(o), this.set_visible(o.children, !0);
1074
- }
1075
- }
1076
- collapse_all() {
1077
- var e,
1078
- t = this.jm.mind.nodes,
1079
- i = 0;
1080
- for (var n in t) (e = t[n]).expanded && !e.isroot && ((e.expanded = !1), i++);
1081
- if (i > 0) {
1082
- var o = this.jm.mind.root;
1083
- this.part_layout(o), this.set_visible(o.children, !0);
1084
- }
1085
- }
1086
- expand_to_depth(e, t, i) {
1087
- if (!(e < 1))
1088
- for (
1089
- var n = t || this.jm.mind.root.children, o = i || 1, s = n.length, r = null;
1090
- s--;
1091
-
1092
- )
1093
- (r = n[s]),
1094
- o < e &&
1095
- (r.expanded || this.expand_node(r),
1096
- this.expand_to_depth(e, r.children, o + 1)),
1097
- o == e && r.expanded && this.collapse_node(r);
1098
- }
1099
- part_layout(e) {
1100
- var i = this.jm.mind.root;
1101
- if (i) {
1102
- var n = i._data.layout;
1103
- e.isroot
1104
- ? ((n.outer_height_right = this._layout_offset_subnodes_height(n.right_nodes)),
1105
- (n.outer_height_left = this._layout_offset_subnodes_height(n.left_nodes)))
1106
- : e._data.layout.direction == t.right
1107
- ? (n.outer_height_right = this._layout_offset_subnodes_height(n.right_nodes))
1108
- : (n.outer_height_left = this._layout_offset_subnodes_height(n.left_nodes)),
1109
- (this.bounds.s = Math.max(n.outer_height_left, n.outer_height_right)),
1110
- (this.cache_valid = !1);
1111
- } else s.warn('can not found root node');
1112
- }
1113
- set_visible(e, t) {
1114
- for (var i = e.length, n = null; i--; )
1115
- (n = e[i])._data.layout,
1116
- n.expanded ? this.set_visible(n.children, t) : this.set_visible(n.children, !1),
1117
- n.isroot || (n._data.layout.visible = t);
1118
- }
1119
- is_expand(e) {
1120
- return e.expanded;
1121
- }
1122
- is_visible(e) {
1123
- var t = e._data.layout;
1124
- return !('visible' in t && !t.visible);
1125
- }
1126
- }
1127
- class v {
1128
- constructor(e) {
1129
- (this.view = e),
1130
- (this.opts = e.opts),
1131
- (this.e_svg = v.c('svg')),
1132
- this.e_svg.setAttribute('class', 'jsmind'),
1133
- (this.size = { w: 0, h: 0 }),
1134
- (this.lines = []),
1135
- (this.line_drawing = { straight: this._line_to, curved: this._bezier_to }),
1136
- this.init_line_render();
1137
- }
1138
- static c(e) {
1139
- return r.d.createElementNS('http://www.w3.org/2000/svg', e);
1140
- }
1141
- init_line_render() {
1142
- 'function' == typeof this.opts.custom_line_render
1143
- ? (this.drawing = (e, t, i, n, o) => {
1144
- try {
1145
- this.opts.custom_line_render.call(this, {
1146
- ctx: e,
1147
- start_point: { x: t, y: i },
1148
- end_point: { x: n, y: o },
1149
- });
1150
- } catch (e) {
1151
- s.error('custom line renderer error: ', e);
1152
- }
1153
- })
1154
- : (this.drawing =
1155
- this.line_drawing[this.opts.line_style] || this.line_drawing.curved);
1156
- }
1157
- element() {
1158
- return this.e_svg;
1159
- }
1160
- set_size(e, t) {
1161
- (this.size.w = e),
1162
- (this.size.h = t),
1163
- this.e_svg.setAttribute('width', e),
1164
- this.e_svg.setAttribute('height', t);
1165
- }
1166
- clear() {
1167
- for (var e = this.lines.length; e--; ) this.e_svg.removeChild(this.lines[e]);
1168
- this.lines.length = 0;
1169
- }
1170
- draw_line(e, t, i, n) {
1171
- var o = v.c('path');
1172
- o.setAttribute('stroke', n || this.opts.line_color),
1173
- o.setAttribute('stroke-width', this.opts.line_width),
1174
- o.setAttribute('fill', 'transparent'),
1175
- this.lines.push(o),
1176
- this.e_svg.appendChild(o),
1177
- this.drawing(o, t.x + i.x, t.y + i.y, e.x + i.x, e.y + i.y);
1178
- }
1179
- copy_to(e, t) {
1180
- var i = new Image();
1181
- (i.onload = function () {
1182
- e.drawImage(i, 0, 0), t && t();
1183
- }),
1184
- (i.src =
1185
- 'data:image/svg+xml;base64,' +
1186
- btoa(new XMLSerializer().serializeToString(this.e_svg)));
1187
- }
1188
- _bezier_to(e, t, i, n, o) {
1189
- e.setAttribute(
1190
- 'd',
1191
- 'M ' +
1192
- t +
1193
- ' ' +
1194
- i +
1195
- ' C ' +
1196
- (t + (2 * (n - t)) / 3) +
1197
- ' ' +
1198
- i +
1199
- ', ' +
1200
- t +
1201
- ' ' +
1202
- o +
1203
- ', ' +
1204
- n +
1205
- ' ' +
1206
- o
1207
- );
1208
- }
1209
- _line_to(e, t, i, n, o) {
1210
- e.setAttribute('d', 'M ' + t + ' ' + i + ' L ' + n + ' ' + o);
1211
- }
1212
- }
1213
- class g {
1214
- constructor(e) {
1215
- (this.opts = e.opts),
1216
- (this.e_canvas = r.c('canvas')),
1217
- (this.e_canvas.className = 'jsmind'),
1218
- (this.canvas_ctx = this.e_canvas.getContext('2d')),
1219
- (this.size = { w: 0, h: 0 }),
1220
- (this.line_drawing = { straight: this._line_to, curved: this._bezier_to }),
1221
- (this.dpr = e.device_pixel_ratio),
1222
- this.init_line_render();
1223
- }
1224
- init_line_render() {
1225
- 'function' == typeof this.opts.custom_line_render
1226
- ? (this.drawing = (e, t, i, n, o) => {
1227
- try {
1228
- this.opts.custom_line_render.call(this, {
1229
- ctx: e,
1230
- start_point: { x: t, y: i },
1231
- end_point: { x: n, y: o },
1232
- });
1233
- } catch (e) {
1234
- s.error('custom line render error: ', e);
1235
- }
1236
- })
1237
- : (this.drawing =
1238
- this.line_drawing[this.opts.line_style] || this.line_drawing.curved);
1239
- }
1240
- element() {
1241
- return this.e_canvas;
1242
- }
1243
- set_size(e, t) {
1244
- (this.size.w = e),
1245
- (this.size.h = t),
1246
- this.e_canvas.width && this.e_canvas.height && this.canvas_ctx.scale
1247
- ? ((this.e_canvas.width = e * this.dpr),
1248
- (this.e_canvas.height = t * this.dpr),
1249
- (this.e_canvas.style.width = e + 'px'),
1250
- (this.e_canvas.style.height = t + 'px'),
1251
- this.canvas_ctx.scale(this.dpr, this.dpr))
1252
- : ((this.e_canvas.width = e), (this.e_canvas.height = t));
1253
- }
1254
- clear() {
1255
- this.canvas_ctx.clearRect(0, 0, this.size.w, this.size.h);
1256
- }
1257
- draw_line(e, t, i, n) {
1258
- var o = this.canvas_ctx;
1259
- (o.strokeStyle = n || this.opts.line_color),
1260
- (o.lineWidth = this.opts.line_width),
1261
- (o.lineCap = 'round'),
1262
- this.drawing(o, t.x + i.x, t.y + i.y, e.x + i.x, e.y + i.y);
1263
- }
1264
- copy_to(e, t) {
1265
- e.drawImage(this.e_canvas, 0, 0, this.size.w, this.size.h), t && t();
1266
- }
1267
- _bezier_to(e, t, i, n, o) {
1268
- e.beginPath(),
1269
- e.moveTo(t, i),
1270
- e.bezierCurveTo(t + (2 * (n - t)) / 3, i, t, o, n, o),
1271
- e.stroke();
1272
- }
1273
- _line_to(e, t, i, n, o) {
1274
- e.beginPath(), e.moveTo(t, i), e.lineTo(n, o), e.stroke();
1275
- }
1276
- }
1277
- class f {
1278
- constructor(e, t) {
1279
- (this.opts = t),
1280
- (this.jm = e),
1281
- (this.layout = e.layout),
1282
- (this.container = null),
1283
- (this.e_panel = null),
1284
- (this.e_nodes = null),
1285
- (this.size = { w: 0, h: 0 }),
1286
- (this.selected_node = null),
1287
- (this.editing_node = null),
1288
- (this.graph = null),
1289
- (this.render_node = t.custom_node_render
1290
- ? this._custom_node_render
1291
- : this._default_node_render),
1292
- (this.zoom_current = 1),
1293
- (this.device_pixel_ratio =
1294
- (this.opts.enable_device_pixel_ratio && r.w.devicePixelRatio) || 1),
1295
- (this._initialized = !1);
1296
- }
1297
- init() {
1298
- if (
1299
- (s.debug(this.opts),
1300
- s.debug('view.init'),
1301
- (this.container = r.i(this.opts.container)
1302
- ? this.opts.container
1303
- : r.g(this.opts.container)),
1304
- this.container)
1305
- ) {
1306
- var e;
1307
- (this.graph =
1308
- ((e = this), 'svg' === this.opts.engine.toLowerCase() ? new v(e) : new g(e))),
1309
- (this.e_panel = r.c('div')),
1310
- (this.e_nodes = r.c('jmnodes')),
1311
- (this.e_editor = r.c('input')),
1312
- (this.e_panel.className =
1313
- 'jsmind-inner jmnode-overflow-' + this.opts.node_overflow),
1314
- (this.e_panel.tabIndex = 1),
1315
- this.e_panel.appendChild(this.graph.element()),
1316
- this.e_panel.appendChild(this.e_nodes),
1317
- (this.e_editor.className = 'jsmind-editor'),
1318
- (this.e_editor.type = 'text');
1319
- var t = this;
1320
- r.on(this.e_editor, 'keydown', function (e) {
1321
- var i = e || event;
1322
- 13 == i.keyCode && (t.edit_node_end(), i.stopPropagation());
1323
- }),
1324
- r.on(this.e_editor, 'blur', function (e) {
1325
- t.edit_node_end();
1326
- }),
1327
- this.container.appendChild(this.e_panel),
1328
- this.container.offsetParent ||
1329
- new IntersectionObserver((e, t) => {
1330
- e[0].isIntersecting && (t.unobserve(this.e_panel), this.resize());
1331
- }).observe(this.e_panel);
1332
- } else s.error('the options.view.container was not be found in dom');
1333
- }
1334
- add_event(e, t, i, n) {
1335
- let o = n ? this.e_panel : this.e_nodes;
1336
- r.on(o, t, function (t) {
1337
- var n = t || event;
1338
- i.call(e, n);
1339
- });
1340
- }
1341
- get_binded_nodeid(e) {
1342
- if (null == e) return null;
1343
- var t = e.tagName.toLowerCase();
1344
- return 'jmnode' == t || 'jmexpander' == t
1345
- ? e.getAttribute('nodeid')
1346
- : 'jmnodes' == t || 'body' == t || 'html' == t
1347
- ? null
1348
- : this.get_binded_nodeid(e.parentElement);
1349
- }
1350
- is_node(e) {
1351
- if (null == e) return !1;
1352
- var t = e.tagName.toLowerCase();
1353
- return (
1354
- 'jmnode' == t ||
1355
- ('jmnodes' != t && 'body' != t && 'html' != t && this.is_node(e.parentElement))
1356
- );
1357
- }
1358
- is_expander(e) {
1359
- return 'jmexpander' == e.tagName.toLowerCase();
1360
- }
1361
- reset() {
1362
- s.debug('view.reset'),
1363
- (this.selected_node = null),
1364
- this.clear_lines(),
1365
- this.clear_nodes(),
1366
- this.reset_theme();
1367
- }
1368
- reset_theme() {
1369
- var e = this.jm.options.theme;
1370
- this.e_nodes.className = e ? 'theme-' + e : '';
1371
- }
1372
- reset_custom_style() {
1373
- var e = this.jm.mind.nodes;
1374
- for (var t in e) this.reset_node_custom_style(e[t]);
1375
- }
1376
- load() {
1377
- s.debug('view.load'),
1378
- this.setup_canvas_draggable(this.opts.draggable),
1379
- this.init_nodes(),
1380
- (this._initialized = !0);
1381
- }
1382
- expand_size() {
1383
- var e = this.layout.get_min_size(),
1384
- t = e.w + 2 * this.opts.hmargin,
1385
- i = e.h + 2 * this.opts.vmargin,
1386
- n = this.e_panel.clientWidth,
1387
- o = this.e_panel.clientHeight;
1388
- n < t && (n = t), o < i && (o = i), (this.size.w = n), (this.size.h = o);
1389
- }
1390
- init_nodes_size(e) {
1391
- var t = e._data.view;
1392
- (t.width = t.element.clientWidth), (t.height = t.element.clientHeight);
1393
- }
1394
- init_nodes() {
1395
- var e = this.jm.mind.nodes,
1396
- t = r.d.createDocumentFragment();
1397
- for (var i in e) this.create_node_element(e[i], t);
1398
- this.e_nodes.appendChild(t),
1399
- this.run_in_c11y_mode_if_needed(() => {
1400
- for (var t in e) this.init_nodes_size(e[t]);
1401
- });
1402
- }
1403
- add_node(e) {
1404
- this.create_node_element(e, this.e_nodes),
1405
- this.run_in_c11y_mode_if_needed(() => {
1406
- this.init_nodes_size(e);
1407
- });
1408
- }
1409
- run_in_c11y_mode_if_needed(e) {
1410
- this.container.offsetParent
1411
- ? e()
1412
- : (s.warn(
1413
- 'init nodes in compatibility mode. because the container or its parent has style {display:none}. '
1414
- ),
1415
- (this.e_panel.style.position = 'absolute'),
1416
- (this.e_panel.style.top = '-100000'),
1417
- r.d.body.appendChild(this.e_panel),
1418
- e(),
1419
- this.container.appendChild(this.e_panel),
1420
- (this.e_panel.style.position = null),
1421
- (this.e_panel.style.top = null));
1422
- }
1423
- create_node_element(e, t) {
1424
- var i = null;
1425
- 'view' in e._data ? (i = e._data.view) : ((i = {}), (e._data.view = i));
1426
- var n = r.c('jmnode');
1427
- if (e.isroot) n.className = 'root';
1428
- else {
1429
- var o = r.c('jmexpander');
1430
- r.t(o, '-'),
1431
- o.setAttribute('nodeid', e.id),
1432
- (o.style.visibility = 'hidden'),
1433
- t.appendChild(o),
1434
- (i.expander = o);
1435
- }
1436
- e.topic && this.render_node(n, e),
1437
- n.setAttribute('nodeid', e.id),
1438
- (n.style.visibility = 'hidden'),
1439
- this._reset_node_custom_style(n, e.data),
1440
- t.appendChild(n),
1441
- (i.element = n);
1442
- }
1443
- remove_node(e) {
1444
- null != this.selected_node &&
1445
- this.selected_node.id == e.id &&
1446
- (this.selected_node = null),
1447
- null != this.editing_node &&
1448
- this.editing_node.id == e.id &&
1449
- (e._data.view.element.removeChild(this.e_editor), (this.editing_node = null));
1450
- for (var t = e.children, i = t.length; i--; ) this.remove_node(t[i]);
1451
- if (e._data.view) {
1452
- var n = e._data.view.element,
1453
- o = e._data.view.expander;
1454
- this.e_nodes.removeChild(n),
1455
- this.e_nodes.removeChild(o),
1456
- (e._data.view.element = null),
1457
- (e._data.view.expander = null);
1458
- }
1459
- }
1460
- update_node(e) {
1461
- var t = e._data.view,
1462
- i = t.element;
1463
- if ((e.topic && this.render_node(i, e), this.layout.is_visible(e)))
1464
- (t.width = i.clientWidth), (t.height = i.clientHeight);
1465
- else {
1466
- let e = i.getAttribute('style');
1467
- (i.style = 'visibility: visible; left:0; top:0;'),
1468
- (t.width = i.clientWidth),
1469
- (t.height = i.clientHeight),
1470
- (i.style = e);
1471
- }
1472
- }
1473
- select_node(e) {
1474
- if (this.selected_node) {
1475
- var t = this.selected_node._data.view.element;
1476
- (t.className = t.className.replace(/\s*selected\b/i, '')),
1477
- this.restore_selected_node_custom_style(this.selected_node);
1478
- }
1479
- e &&
1480
- ((this.selected_node = e),
1481
- (e._data.view.element.className += ' selected'),
1482
- this.clear_selected_node_custom_style(e));
1483
- }
1484
- select_clear() {
1485
- this.select_node(null);
1486
- }
1487
- get_editing_node() {
1488
- return this.editing_node;
1489
- }
1490
- is_editing() {
1491
- return !!this.editing_node;
1492
- }
1493
- edit_node_begin(e) {
1494
- if (e.topic) {
1495
- null != this.editing_node && this.edit_node_end(), (this.editing_node = e);
1496
- var t = e._data.view.element,
1497
- i = e.topic,
1498
- n = getComputedStyle(t);
1499
- (this.e_editor.value = i),
1500
- (this.e_editor.style.width =
1501
- t.clientWidth -
1502
- parseInt(n.getPropertyValue('padding-left')) -
1503
- parseInt(n.getPropertyValue('padding-right')) +
1504
- 'px'),
1505
- (t.innerHTML = ''),
1506
- t.appendChild(this.e_editor),
1507
- (t.style.zIndex = 5),
1508
- this.e_editor.focus(),
1509
- this.e_editor.select();
1510
- } else s.warn("don't edit image nodes");
1511
- }
1512
- edit_node_end() {
1513
- if (null != this.editing_node) {
1514
- var e = this.editing_node;
1515
- this.editing_node = null;
1516
- var t = e._data.view.element,
1517
- i = this.e_editor.value;
1518
- (t.style.zIndex = 'auto'),
1519
- t.removeChild(this.e_editor),
1520
- a.text.is_empty(i) || e.topic === i
1521
- ? this.render_node(t, e)
1522
- : this.jm.update_node(e.id, i);
1523
- }
1524
- this.e_panel.focus();
1525
- }
1526
- get_view_offset() {
1527
- var e = this.layout.bounds;
1528
- return { x: (this.size.w - e.e - e.w) / 2, y: this.size.h / 2 };
1529
- }
1530
- resize() {
1531
- this.graph.set_size(1, 1),
1532
- (this.e_nodes.style.width = '1px'),
1533
- (this.e_nodes.style.height = '1px'),
1534
- this.expand_size(),
1535
- this._show();
1536
- }
1537
- _show() {
1538
- this.graph.set_size(this.size.w, this.size.h),
1539
- (this.e_nodes.style.width = this.size.w + 'px'),
1540
- (this.e_nodes.style.height = this.size.h + 'px'),
1541
- this.show_nodes(),
1542
- this.show_lines(),
1543
- this.jm.invoke_event_handle(i.resize, { data: [] });
1544
- }
1545
- zoom_in(e) {
1546
- return this.set_zoom(this.zoom_current + this.opts.zoom.step, e);
1547
- }
1548
- zoom_out(e) {
1549
- return this.set_zoom(this.zoom_current - this.opts.zoom.step, e);
1550
- }
1551
- set_zoom(e, t) {
1552
- if (e < this.opts.zoom.min || e > this.opts.zoom.max) return !1;
1553
- let i = this.e_panel.getBoundingClientRect();
1554
- if (
1555
- e < 1 &&
1556
- e < this.zoom_current &&
1557
- this.size.w * e < i.width &&
1558
- this.size.h * e < i.height
1559
- )
1560
- return !1;
1561
- let n = t ? { x: t.x - i.x, y: t.y - i.y } : { x: i.width / 2, y: i.height / 2 },
1562
- o = ((this.e_panel.scrollLeft + n.x) * e) / this.zoom_current - n.x,
1563
- s = ((this.e_panel.scrollTop + n.y) * e) / this.zoom_current - n.y;
1564
- this.zoom_current = e;
1565
- for (var r = 0; r < this.e_panel.children.length; r++)
1566
- this.e_panel.children[r].style.zoom = e;
1567
- return this._show(), (this.e_panel.scrollLeft = o), (this.e_panel.scrollTop = s), !0;
1568
- }
1569
- show(e) {
1570
- s.debug(`view.show: {keep_center: ${e}}`),
1571
- this.expand_size(),
1572
- this._show(),
1573
- e && this.center_node(this.jm.mind.root);
1574
- }
1575
- relayout() {
1576
- this.expand_size(), this._show();
1577
- }
1578
- save_location(e) {
1579
- var t = e._data.view;
1580
- t._saved_location = {
1581
- x: parseInt(t.element.style.left) - this.e_panel.scrollLeft,
1582
- y: parseInt(t.element.style.top) - this.e_panel.scrollTop,
1583
- };
1584
- }
1585
- restore_location(e) {
1586
- var t = e._data.view;
1587
- (this.e_panel.scrollLeft = parseInt(t.element.style.left) - t._saved_location.x),
1588
- (this.e_panel.scrollTop = parseInt(t.element.style.top) - t._saved_location.y);
1589
- }
1590
- clear_nodes() {
1591
- var e = this.jm.mind;
1592
- if (null != e) {
1593
- var t = e.nodes,
1594
- i = null;
1595
- for (var n in t)
1596
- ((i = t[n])._data.view.element = null), (i._data.view.expander = null);
1597
- this.e_nodes.innerHTML = '';
1598
- }
1599
- }
1600
- show_nodes() {
1601
- var e = this.jm.mind.nodes,
1602
- t = null,
1603
- i = null,
1604
- n = null,
1605
- o = null,
1606
- s = this.get_view_offset();
1607
- for (var r in e)
1608
- (i = (o = (t = e[r])._data.view).element),
1609
- this.layout.is_visible(t)
1610
- ? (this.reset_node_custom_style(t),
1611
- (n = this.layout.get_node_point(t)),
1612
- (o.abs_x = s.x + n.x),
1613
- (o.abs_y = s.y + n.y),
1614
- (i.style.left = s.x + n.x + 'px'),
1615
- (i.style.top = s.y + n.y + 'px'),
1616
- (i.style.display = ''),
1617
- (i.style.visibility = 'visible'),
1618
- this._show_expander(t, s))
1619
- : ((i.style.display = 'none'), (o.expander.style.display = 'none'));
1620
- }
1621
- _show_expander(e, t) {
1622
- if (e.isroot) return;
1623
- var i = e._data.view.expander;
1624
- if (0 == e.children.length)
1625
- return (i.style.display = 'none'), void (i.style.visibility = 'hidden');
1626
- let n = this._get_expander_text(e);
1627
- r.t(i, n);
1628
- let o = this.layout.get_expander_point(e);
1629
- (i.style.left = t.x + o.x + 'px'),
1630
- (i.style.top = t.y + o.y + 'px'),
1631
- (i.style.display = ''),
1632
- (i.style.visibility = 'visible');
1633
- }
1634
- _get_expander_text(e) {
1635
- let t = this.opts.expander_style ? this.opts.expander_style.toLowerCase() : 'char';
1636
- return 'number' === t
1637
- ? e.children.length > 99
1638
- ? '...'
1639
- : e.children.length
1640
- : 'char' === t
1641
- ? e.expanded
1642
- ? '-'
1643
- : '+'
1644
- : void 0;
1645
- }
1646
- _default_node_render(e, t) {
1647
- this.opts.support_html ? r.h(e, t.topic) : r.t(e, t.topic);
1648
- }
1649
- _custom_node_render(e, t) {
1650
- this.opts.custom_node_render(this.jm, e, t) || this._default_node_render(e, t);
1651
- }
1652
- reset_node_custom_style(e) {
1653
- this._reset_node_custom_style(e._data.view.element, e.data);
1654
- }
1655
- _reset_node_custom_style(e, t) {
1656
- if (
1657
- ('background-color' in t && (e.style.backgroundColor = t['background-color']),
1658
- 'foreground-color' in t && (e.style.color = t['foreground-color']),
1659
- 'width' in t && (e.style.width = t.width + 'px'),
1660
- 'height' in t && (e.style.height = t.height + 'px'),
1661
- 'font-size' in t && (e.style.fontSize = t['font-size'] + 'px'),
1662
- 'font-weight' in t && (e.style.fontWeight = t['font-weight']),
1663
- 'font-style' in t && (e.style.fontStyle = t['font-style']),
1664
- 'background-image' in t)
1665
- ) {
1666
- var i = t['background-image'];
1667
- if (i.startsWith('data') && t.width && t.height) {
1668
- var n = new Image();
1669
- (n.onload = function () {
1670
- var t = r.c('canvas');
1671
- (t.width = e.clientWidth), (t.height = e.clientHeight);
1672
- if (t.getContext) {
1673
- t.getContext('2d').drawImage(this, 2, 2, e.clientWidth, e.clientHeight);
1674
- var i = t.toDataURL();
1675
- e.style.backgroundImage = 'url(' + i + ')';
1676
- }
1677
- }),
1678
- (n.src = i);
1679
- } else e.style.backgroundImage = 'url(' + i + ')';
1680
- (e.style.backgroundSize = '99%'),
1681
- 'background-rotation' in t &&
1682
- (e.style.transform = 'rotate(' + t['background-rotation'] + 'deg)');
1683
- }
1684
- }
1685
- restore_selected_node_custom_style(e) {
1686
- var t = e._data.view.element,
1687
- i = e.data;
1688
- 'background-color' in i && (t.style.backgroundColor = i['background-color']),
1689
- 'foreground-color' in i && (t.style.color = i['foreground-color']);
1690
- }
1691
- clear_selected_node_custom_style(e) {
1692
- var t = e._data.view.element;
1693
- (t.style.backgroundColor = ''), (t.style.color = '');
1694
- }
1695
- clear_lines() {
1696
- this.graph.clear();
1697
- }
1698
- show_lines() {
1699
- this.clear_lines();
1700
- var e = this.jm.mind.nodes,
1701
- t = null,
1702
- i = null,
1703
- n = null,
1704
- o = null,
1705
- s = this.get_view_offset();
1706
- for (var r in e)
1707
- (t = e[r]).isroot ||
1708
- (this.layout.is_visible(t) &&
1709
- ((i = this.layout.get_node_point_in(t)),
1710
- (n = this.layout.get_node_point_out(t.parent)),
1711
- (o = t.data['leading-line-color']),
1712
- this.graph.draw_line(n, i, s, o)));
1713
- }
1714
- setup_canvas_draggable(e) {
1715
- if (((this.opts.draggable = e), !this._initialized)) {
1716
- let e,
1717
- t,
1718
- i = !1;
1719
- this.opts.hide_scrollbars_when_draggable &&
1720
- (this.e_panel.style = 'overflow: hidden'),
1721
- r.on(this.container, 'mousedown', n => {
1722
- this.opts.draggable && ((i = !0), (e = n.clientX), (t = n.clientY));
1723
- }),
1724
- r.on(this.container, 'mouseup', () => {
1725
- i = !1;
1726
- }),
1727
- r.on(this.container, 'mousemove', n => {
1728
- this.opts.draggable &&
1729
- i &&
1730
- (this.e_panel.scrollBy(e - n.clientX, t - n.clientY),
1731
- (e = n.clientX),
1732
- (t = n.clientY));
1733
- });
1734
- }
1735
- }
1736
- center_node(e) {
1737
- if (!this.layout.is_visible(e))
1738
- return s.warn('can not scroll to the node, because it is invisible'), !1;
1739
- let t = e._data.view,
1740
- i = this.e_panel.getBoundingClientRect(),
1741
- n = t.abs_x + t.width / 2,
1742
- o = t.abs_y + t.height / 2;
1743
- return (
1744
- this.e_panel.scrollTo(
1745
- n * this.zoom_current - i.width / 2,
1746
- o * this.zoom_current - i.height / 2
1747
- ),
1748
- !0
1749
- );
1750
- }
1751
- zoomIn(e) {
1752
- return s.warn('please use zoom_in instead'), this.zoom_in(e);
1753
- }
1754
- zoomOut(e) {
1755
- return s.warn('please use zoom_out instead'), this.zoom_out(e);
1756
- }
1757
- setZoom(e, t) {
1758
- return s.warn('please use set_zoom instead'), this.set_zoom(e, t);
1759
- }
1760
- }
1761
- class m {
1762
- constructor(e, t) {
1763
- (this.jm = e),
1764
- (this.opts = t),
1765
- (this.mapping = t.mapping),
1766
- (this.handles = t.handles),
1767
- (this._newid = null),
1768
- (this._mapping = {});
1769
- }
1770
- init() {
1771
- for (var e in (r.on(this.jm.view.e_panel, 'keydown', this.handler.bind(this)),
1772
- (this.handles.addchild = this.handle_addchild),
1773
- (this.handles.addbrother = this.handle_addbrother),
1774
- (this.handles.editnode = this.handle_editnode),
1775
- (this.handles.delnode = this.handle_delnode),
1776
- (this.handles.toggle = this.handle_toggle),
1777
- (this.handles.up = this.handle_up),
1778
- (this.handles.down = this.handle_down),
1779
- (this.handles.left = this.handle_left),
1780
- (this.handles.right = this.handle_right),
1781
- this.mapping))
1782
- if (this.mapping[e] && e in this.handles) {
1783
- let t = this.mapping[e];
1784
- Array.isArray(t) || (t = [t]);
1785
- for (let i of t) this._mapping[i] = this.handles[e];
1786
- }
1787
- 'function' == typeof this.opts.id_generator
1788
- ? (this._newid = this.opts.id_generator)
1789
- : (this._newid = a.uuid.newid);
1790
- }
1791
- enable_shortcut() {
1792
- this.opts.enable = !0;
1793
- }
1794
- disable_shortcut() {
1795
- this.opts.enable = !1;
1796
- }
1797
- handler(e) {
1798
- if ((9 == e.which && e.preventDefault(), !this.jm.view.is_editing())) {
1799
- var t = e || event;
1800
- if (!this.opts.enable) return !0;
1801
- var i =
1802
- t.keyCode +
1803
- (t.metaKey << 13) +
1804
- (t.ctrlKey << 12) +
1805
- (t.altKey << 11) +
1806
- (t.shiftKey << 10);
1807
- i in this._mapping && this._mapping[i].call(this, this.jm, e);
1808
- }
1809
- }
1810
- handle_addchild(e, t) {
1811
- var i = e.get_selected_node();
1812
- if (i) {
1813
- var n = this._newid();
1814
- e.add_node(i, n, 'New Node') && (e.select_node(n), e.begin_edit(n));
1815
- }
1816
- }
1817
- handle_addbrother(e, t) {
1818
- var i = e.get_selected_node();
1819
- if (i && !i.isroot) {
1820
- var n = this._newid();
1821
- e.insert_node_after(i, n, 'New Node') && (e.select_node(n), e.begin_edit(n));
1822
- }
1823
- }
1824
- handle_editnode(e, t) {
1825
- var i = e.get_selected_node();
1826
- i && e.begin_edit(i);
1827
- }
1828
- handle_delnode(e, t) {
1829
- var i = e.get_selected_node();
1830
- i && !i.isroot && (e.select_node(i.parent), e.remove_node(i));
1831
- }
1832
- handle_toggle(e, t) {
1833
- var i = t || event,
1834
- n = e.get_selected_node();
1835
- n && (e.toggle_node(n.id), i.stopPropagation(), i.preventDefault());
1836
- }
1837
- handle_up(e, t) {
1838
- var i = t || event,
1839
- n = e.get_selected_node();
1840
- if (n) {
1841
- var o = e.find_node_before(n);
1842
- if (!o) {
1843
- var s = e.find_node_before(n.parent);
1844
- s && s.children.length > 0 && (o = s.children[s.children.length - 1]);
1845
- }
1846
- o && e.select_node(o), i.stopPropagation(), i.preventDefault();
1847
- }
1848
- }
1849
- handle_down(e, t) {
1850
- var i = t || event,
1851
- n = e.get_selected_node();
1852
- if (n) {
1853
- var o = e.find_node_after(n);
1854
- if (!o) {
1855
- var s = e.find_node_after(n.parent);
1856
- s && s.children.length > 0 && (o = s.children[0]);
1857
- }
1858
- o && e.select_node(o), i.stopPropagation(), i.preventDefault();
1859
- }
1860
- }
1861
- handle_left(e, i) {
1862
- this._handle_direction(e, i, t.left);
1863
- }
1864
- handle_right(e, i) {
1865
- this._handle_direction(e, i, t.right);
1866
- }
1867
- _handle_direction(e, t, i) {
1868
- var n = t || event,
1869
- o = e.get_selected_node(),
1870
- s = null;
1871
- if (o) {
1872
- if (o.isroot) {
1873
- for (var r = o.children, a = [], d = 0; d < r.length; d++)
1874
- r[d].direction === i && a.push(d);
1875
- s = r[a[Math.floor((a.length - 1) / 2)]];
1876
- } else if (o.direction === i) {
1877
- var l = (a = o.children).length;
1878
- l > 0 && (s = a[Math.floor((l - 1) / 2)]);
1879
- } else s = o.parent;
1880
- s && e.select_node(s), n.stopPropagation(), n.preventDefault();
1881
- }
1882
- }
1883
- }
1884
- const w = { plugins: [] };
1885
- function y(e) {
1886
- if (!(e instanceof x))
1887
- throw new Error('can not register plugin, it is not an instance of Plugin');
1888
- if (w.plugins.map(e => e.name).includes(e.name))
1889
- throw new Error('can not register plugin ' + e.name + ': plugin name already exist');
1890
- w.plugins.push(e);
1891
- }
1892
- function b(e, t) {
1893
- r.w.setTimeout(function () {
1894
- !(function (e, t) {
1895
- w.plugins.forEach(i => i.fn_init(e, t[i.name]));
1896
- })(e, t);
1897
- }, 0);
1898
- }
1899
- class x {
1900
- constructor(e, t) {
1901
- if (!e) throw new Error('plugin must has a name');
1902
- if (!t || 'function' != typeof t) throw new Error('plugin must has an init function');
1903
- (this.name = e), (this.fn_init = t);
1904
- }
1905
- }
1906
- class z {
1907
- constructor(e) {
1908
- (this.jm = e), (this.plugins = new Map());
1909
- }
1910
- initPreloadPlugins() {
1911
- const e = this.jm.constructor.enhancedPluginList.filter(e => e.preload);
1912
- s.info('Initializing ' + e.length + ' preload plugins'),
1913
- e.forEach(e => {
1914
- this._initPlugin(e);
1915
- });
1916
- }
1917
- initNormalPlugins() {
1918
- const e = this.jm.constructor.enhancedPluginList.filter(e => !e.preload);
1919
- s.info('Initializing ' + e.length + ' normal plugins'),
1920
- e.forEach(e => {
1921
- this._initPlugin(e);
1922
- });
1923
- }
1924
- _initPlugin(e) {
1925
- try {
1926
- const { PluginClass: t, pluginOpt: i } = e;
1927
- if (!t.instanceName)
1928
- throw new Error('Plugin ' + t.name + ' must define static instanceName');
1929
- this.plugins.has(t.instanceName) &&
1930
- s.warn('Plugin ' + t.instanceName + ' already exists, will be replaced');
1931
- const n = new t({ jm: this.jm, pluginOpt: i || {} });
1932
- this.plugins.set(t.instanceName, n),
1933
- (this.jm[t.instanceName] = n),
1934
- (e.instance = n),
1935
- s.info('Enhanced plugin ' + t.instanceName + ' initialized');
1936
- } catch (t) {
1937
- s.error('Failed to initialize plugin ' + e.PluginClass.name + ':', t);
1938
- }
1939
- }
1940
- removePlugin(e) {
1941
- const t = e.instanceName;
1942
- if (!t) return;
1943
- const i = this.plugins.get(t);
1944
- if (i)
1945
- try {
1946
- 'function' == typeof i.beforePluginRemove && i.beforePluginRemove(),
1947
- this.plugins.delete(t),
1948
- delete this.jm[t];
1949
- const n = this.jm.constructor.enhancedPluginList,
1950
- o = n.findIndex(t => t.PluginClass === e);
1951
- -1 !== o && n.splice(o, 1), s.info('Enhanced plugin ' + t + ' removed');
1952
- } catch (e) {
1953
- s.error('Failed to remove plugin ' + t + ':', e);
1954
- }
1955
- }
1956
- destroyAllPlugins() {
1957
- this.plugins.forEach((e, t) => {
1958
- try {
1959
- 'function' == typeof e.beforePluginDestroy && e.beforePluginDestroy();
1960
- } catch (e) {
1961
- s.error('Failed to destroy plugin ' + t + ':', e);
1962
- }
1963
- }),
1964
- this.plugins.clear();
1965
- }
1966
- getPlugin(e) {
1967
- return this.plugins.get(e);
1968
- }
1969
- }
1970
- class j {
1971
- static instanceName = '';
1972
- static preload = !1;
1973
- constructor({ jm: e, pluginOpt: t }) {
1974
- (this.jm = e), (this.options = t || {});
1975
- }
1976
- beforePluginRemove() {}
1977
- beforePluginDestroy() {
1978
- this.beforePluginRemove();
1979
- }
1980
- }
1981
- class k {
1982
- static mind = h;
1983
- static node = l;
1984
- static direction = t;
1985
- static event_type = i;
1986
- static $ = r;
1987
- static plugin = x;
1988
- static register_plugin = y;
1989
- static util = a;
1990
- static enhanced_plugin = j;
1991
- static enhancedPluginList = [];
1992
- static usePlugin(e, t = {}) {
1993
- if (k.enhancedPluginList.some(t => t.PluginClass === e))
1994
- return s.warn('Plugin ' + e.name + ' already registered'), k;
1995
- if (!e.instanceName)
1996
- throw new Error('Plugin ' + e.name + ' must define static instanceName');
1997
- return (
1998
- k.enhancedPluginList.push({
1999
- PluginClass: e,
2000
- instanceName: e.instanceName,
2001
- preload: e.preload || !1,
2002
- pluginOpt: t,
2003
- instance: null,
2004
- }),
2005
- k
2006
- );
2007
- }
2008
- static hasEnhancedPlugin(e) {
2009
- return k.enhancedPluginList.some(t => t.PluginClass === e);
2010
- }
2011
- constructor(t) {
2012
- (k.current = this),
2013
- (this.options = (function (e) {
2014
- var t = {};
2015
- if ((a.json.merge(t, d), a.json.merge(t, e), !t.container))
2016
- throw new Error('the options.container should not be null or empty.');
2017
- return t;
2018
- })(t)),
2019
- s.level(n[this.options.log_level]),
2020
- (this.version = e),
2021
- (this.initialized = !1),
2022
- (this.mind = null),
2023
- (this.event_handles = []),
2024
- this.init();
2025
- }
2026
- init() {
2027
- if (!this.initialized) {
2028
- (this.initialized = !0),
2029
- (this.enhancedPluginManager = new z(this)),
2030
- this.enhancedPluginManager.initPreloadPlugins();
2031
- var e = {
2032
- mode: this.options.mode,
2033
- hspace: this.options.layout.hspace,
2034
- vspace: this.options.layout.vspace,
2035
- pspace: this.options.layout.pspace,
2036
- cousin_space: this.options.layout.cousin_space,
2037
- },
2038
- t = {
2039
- container: this.options.container,
2040
- support_html: this.options.support_html,
2041
- engine: this.options.view.engine,
2042
- enable_device_pixel_ratio: this.options.view.enable_device_pixel_ratio,
2043
- hmargin: this.options.view.hmargin,
2044
- vmargin: this.options.view.vmargin,
2045
- line_width: this.options.view.line_width,
2046
- line_color: this.options.view.line_color,
2047
- line_style: this.options.view.line_style,
2048
- custom_line_render: this.options.view.custom_line_render,
2049
- draggable: this.options.view.draggable,
2050
- hide_scrollbars_when_draggable:
2051
- this.options.view.hide_scrollbars_when_draggable,
2052
- node_overflow: this.options.view.node_overflow,
2053
- zoom: this.options.view.zoom,
2054
- custom_node_render: this.options.view.custom_node_render,
2055
- expander_style: this.options.view.expander_style,
2056
- };
2057
- (this.data = new c(this)),
2058
- (this.layout = new p(this, e)),
2059
- (this.view = new f(this, t)),
2060
- (this.shortcut = new m(this, this.options.shortcut)),
2061
- this.data.init(),
2062
- this.layout.init(),
2063
- this.view.init(),
2064
- this.shortcut.init(),
2065
- this._event_bind(),
2066
- this.enhancedPluginManager.initNormalPlugins(),
2067
- b(this, this.options.plugin);
2068
- }
2069
- }
2070
- get_editable() {
2071
- return this.options.editable;
2072
- }
2073
- enable_edit() {
2074
- this.options.editable = !0;
2075
- }
2076
- disable_edit() {
2077
- this.options.editable = !1;
2078
- }
2079
- get_view_draggable() {
2080
- return this.options.view.draggable;
2081
- }
2082
- enable_view_draggable() {
2083
- (this.options.view.draggable = !0), this.view.setup_canvas_draggable(!0);
2084
- }
2085
- disable_view_draggable() {
2086
- (this.options.view.draggable = !1), this.view.setup_canvas_draggable(!1);
2087
- }
2088
- enable_event_handle(e) {
2089
- this.options.default_event_handle['enable_' + e + '_handle'] = !0;
2090
- }
2091
- disable_event_handle(e) {
2092
- this.options.default_event_handle['enable_' + e + '_handle'] = !1;
2093
- }
2094
- set_theme(e) {
2095
- var t = this.options.theme;
2096
- (this.options.theme = e || null),
2097
- t != this.options.theme &&
2098
- (this.view.reset_theme(), this.view.reset_custom_style());
2099
- }
2100
- _event_bind() {
2101
- this.view.add_event(this, 'mousedown', this.mousedown_handle),
2102
- this.view.add_event(this, 'click', this.click_handle),
2103
- this.view.add_event(this, 'dblclick', this.dblclick_handle),
2104
- this.view.add_event(this, 'wheel', this.mousewheel_handle, !0);
2105
- }
2106
- mousedown_handle(e) {
2107
- if (this.options.default_event_handle.enable_mousedown_handle) {
2108
- var t = e.target || event.srcElement,
2109
- i = this.view.get_binded_nodeid(t);
2110
- i ? this.view.is_node(t) && this.select_node(i) : this.select_clear();
2111
- }
2112
- }
2113
- click_handle(e) {
2114
- if (this.options.default_event_handle.enable_click_handle) {
2115
- var t = e.target || event.srcElement;
2116
- if (this.view.is_expander(t)) {
2117
- var i = this.view.get_binded_nodeid(t);
2118
- i && this.toggle_node(i);
2119
- }
2120
- }
2121
- }
2122
- dblclick_handle(e) {
2123
- if (this.options.default_event_handle.enable_dblclick_handle && this.get_editable()) {
2124
- var t = e.target || event.srcElement;
2125
- if (this.view.is_node(t)) {
2126
- var i = this.view.get_binded_nodeid(t);
2127
- i && this.begin_edit(i);
2128
- }
2129
- }
2130
- }
2131
- mousewheel_handle(e) {
2132
- var t = (e.metaKey << 13) + (e.ctrlKey << 12) + (e.altKey << 11) + (e.shiftKey << 10);
2133
- if (
2134
- this.options.default_event_handle.enable_mousewheel_handle &&
2135
- this.options.view.zoom.mask_key === t
2136
- ) {
2137
- var i = e || event;
2138
- i.preventDefault(), i.deltaY < 0 ? this.view.zoom_in(i) : this.view.zoom_out(i);
2139
- }
2140
- }
2141
- begin_edit(e) {
2142
- if (!l.is_node(e)) {
2143
- var t = this.get_node(e);
2144
- return t
2145
- ? this.begin_edit(t)
2146
- : (s.error('the node[id=' + e + '] can not be found.'), !1);
2147
- }
2148
- this.get_editable()
2149
- ? this.view.edit_node_begin(e)
2150
- : s.error('fail, this mind map is not editable.');
2151
- }
2152
- end_edit() {
2153
- this.view.edit_node_end();
2154
- }
2155
- toggle_node(e) {
2156
- if (!l.is_node(e)) {
2157
- var t = this.get_node(e);
2158
- return t
2159
- ? void this.toggle_node(t)
2160
- : void s.error('the node[id=' + e + '] can not be found.');
2161
- }
2162
- e.isroot ||
2163
- (this.view.save_location(e),
2164
- this.layout.toggle_node(e),
2165
- this.view.relayout(),
2166
- this.view.restore_location(e));
2167
- }
2168
- expand_node(e) {
2169
- if (!l.is_node(e)) {
2170
- var t = this.get_node(e);
2171
- return t
2172
- ? void this.expand_node(t)
2173
- : void s.error('the node[id=' + e + '] can not be found.');
2174
- }
2175
- e.isroot ||
2176
- (this.view.save_location(e),
2177
- this.layout.expand_node(e),
2178
- this.view.relayout(),
2179
- this.view.restore_location(e));
2180
- }
2181
- collapse_node(e) {
2182
- if (!l.is_node(e)) {
2183
- var t = this.get_node(e);
2184
- return t
2185
- ? void this.collapse_node(t)
2186
- : void s.error('the node[id=' + e + '] can not be found.');
2187
- }
2188
- e.isroot ||
2189
- (this.view.save_location(e),
2190
- this.layout.collapse_node(e),
2191
- this.view.relayout(),
2192
- this.view.restore_location(e));
2193
- }
2194
- expand_all() {
2195
- this.layout.expand_all(), this.view.relayout();
2196
- }
2197
- collapse_all() {
2198
- this.layout.collapse_all(), this.view.relayout();
2199
- }
2200
- expand_to_depth(e) {
2201
- this.layout.expand_to_depth(e), this.view.relayout();
2202
- }
2203
- _reset() {
2204
- this.invoke_event_handle(i.reset, { data: [] }),
2205
- this.view.reset(),
2206
- this.layout.reset(),
2207
- this.data.reset();
2208
- }
2209
- _show(e, t) {
2210
- var n = e || u.node_array.example;
2211
- (this.mind = this.data.load(n)),
2212
- this.mind
2213
- ? (s.debug('data.load ok'),
2214
- this.view.load(),
2215
- s.debug('view.load ok'),
2216
- this.layout.layout(),
2217
- s.debug('layout.layout ok'),
2218
- this.view.show(!t),
2219
- s.debug('view.show ok'),
2220
- this.invoke_event_handle(i.show, { data: [e] }))
2221
- : s.error('data.load error');
2222
- }
2223
- show(e, t) {
2224
- this._reset(), this._show(e, t);
2225
- }
2226
- get_meta() {
2227
- return { name: this.mind.name, author: this.mind.author, version: this.mind.version };
2228
- }
2229
- get_data(e) {
2230
- var t = e || 'node_tree';
2231
- return this.data.get_data(t);
2232
- }
2233
- get_root() {
2234
- return this.mind.root;
2235
- }
2236
- get_node(e) {
2237
- return l.is_node(e) ? e : this.mind.get_node(e);
2238
- }
2239
- get_node_level(e) {
2240
- var t = this.get_node(e);
2241
- if (!t) return s.warn('the node[id=' + e + '] can not be found.'), -1;
2242
- if (t.isroot) return 0;
2243
- for (var i = 0, n = t; n.parent && !n.parent.isroot; ) i++, (n = n.parent);
2244
- return i + 1;
2245
- }
2246
- _add_node_data(e, i, n, o, s) {
2247
- var r = t.of(s);
2248
- void 0 === r && (r = this.layout.calculate_next_child_direction(e));
2249
- var a = this.mind.add_node(e, i, n, o, r);
2250
- return a && (this.view.add_node(a), this.view.reset_node_custom_style(a)), a;
2251
- }
2252
- _refresh_node_ui(e) {
2253
- this.layout.layout(), this.view.show(!1), this.expand_node(e);
2254
- }
2255
- add_node(e, n, o, r, a) {
2256
- if (!this.get_editable()) return s.error('fail, this mind map is not editable'), null;
2257
- var d = this.get_node(e);
2258
- if (!d) return s.error('parent node not found'), null;
2259
- var l = this._add_node_data(d, n, o, r, a);
2260
- return (
2261
- l &&
2262
- (this._refresh_node_ui(d),
2263
- this.invoke_event_handle(i.edit, {
2264
- evt: 'add_node',
2265
- data: [d.id, n, o, r, t.of(a)],
2266
- node: n,
2267
- })),
2268
- l
2269
- );
2270
- }
2271
- add_nodes(e, t) {
2272
- if (!this.get_editable()) return s.error('fail, this mind map is not editable'), [];
2273
- var n = this.get_node(e);
2274
- if (!n) return s.error('parent node not found'), [];
2275
- if (!Array.isArray(t) || 0 === t.length)
2276
- return s.warn('nodes_data should be a non-empty array'), [];
2277
- const o = this._count_expected_nodes(t);
2278
- let r = t
2279
- .map(e => this._add_nodes_recursive(n, e))
2280
- .flat()
2281
- .filter(e => null !== e);
2282
- const a = r.length;
2283
- return a === o
2284
- ? (this._refresh_node_ui(n),
2285
- this.invoke_event_handle(i.edit, {
2286
- evt: 'add_nodes',
2287
- data: [n.id, t],
2288
- nodes: r.map(e => e.id),
2289
- }),
2290
- r)
2291
- : (s.warn(`Expected ${o} nodes, but only created ${a}. Cleaning up...`),
2292
- this._cleanup_partial_nodes(r),
2293
- []);
2294
- }
2295
- _add_nodes_recursive(e, t) {
2296
- var i = [];
2297
- if (!t.id || !t.topic) return s.warn('invalid node data:', t), [];
2298
- var n = this._add_node_data(e, t.id, t.topic, t.data || {}, t.direction);
2299
- if (n && (i.push(n), Array.isArray(t.children))) {
2300
- const e = t.children.map(e => this._add_nodes_recursive(n, e)).flat();
2301
- i = i.concat(e);
2302
- }
2303
- return i;
2304
- }
2305
- _count_expected_nodes(e) {
2306
- if (!Array.isArray(e)) return 0;
2307
- var t = (this.options.fieldNames || {}).children || 'children';
2308
- return e.reduce((e, i) => (e++, (e += this._count_expected_nodes(i && i[t]))), 0);
2309
- }
2310
- _cleanup_partial_nodes(e) {
2311
- 0 !== e.length &&
2312
- [...e].reverse().forEach(e => {
2313
- e && !e.isroot && (this.view.remove_node(e), this.mind.remove_node(e));
2314
- });
2315
- }
2316
- insert_node_before(e, n, o, r, a) {
2317
- if (this.get_editable()) {
2318
- var d = this.get_node(e),
2319
- l = t.of(a);
2320
- void 0 === l && (l = this.layout.calculate_next_child_direction(d.parent));
2321
- var h = this.mind.insert_node_before(d, n, o, r, l);
2322
- return (
2323
- h &&
2324
- (this.view.add_node(h),
2325
- this.layout.layout(),
2326
- this.view.show(!1),
2327
- this.invoke_event_handle(i.edit, {
2328
- evt: 'insert_node_before',
2329
- data: [d.id, n, o, r, l],
2330
- node: n,
2331
- })),
2332
- h
2333
- );
2334
- }
2335
- return s.error('fail, this mind map is not editable'), null;
2336
- }
2337
- insert_node_after(e, n, o, r, a) {
2338
- if (this.get_editable()) {
2339
- var d = this.get_node(e),
2340
- l = t.of(a);
2341
- void 0 === l && (l = this.layout.calculate_next_child_direction(d.parent));
2342
- var h = this.mind.insert_node_after(d, n, o, r, l);
2343
- return (
2344
- h &&
2345
- (this.view.add_node(h),
2346
- this.layout.layout(),
2347
- this.view.show(!1),
2348
- this.invoke_event_handle(i.edit, {
2349
- evt: 'insert_node_after',
2350
- data: [d.id, n, o, r, l],
2351
- node: n,
2352
- })),
2353
- h
2354
- );
2355
- }
2356
- return s.error('fail, this mind map is not editable'), null;
2357
- }
2358
- remove_node(e) {
2359
- if (!l.is_node(e)) {
2360
- var t = this.get_node(e);
2361
- return t
2362
- ? this.remove_node(t)
2363
- : (s.error('the node[id=' + e + '] can not be found.'), !1);
2364
- }
2365
- if (this.get_editable()) {
2366
- if (e.isroot) return s.error('fail, can not remove root node'), !1;
2367
- var n = e.id,
2368
- o = e.parent.id,
2369
- r = this.get_node(o);
2370
- return (
2371
- this.view.save_location(r),
2372
- this.view.remove_node(e),
2373
- this.mind.remove_node(e),
2374
- this.layout.layout(),
2375
- this.view.show(!1),
2376
- this.view.restore_location(r),
2377
- this.invoke_event_handle(i.edit, { evt: 'remove_node', data: [n], node: o }),
2378
- !0
2379
- );
2380
- }
2381
- return s.error('fail, this mind map is not editable'), !1;
2382
- }
2383
- update_node(e, t) {
2384
- if (this.get_editable()) {
2385
- var n = this.get_node(e);
2386
- if (n) {
2387
- if ('string' == typeof t)
2388
- return a.text.is_empty(t)
2389
- ? void s.warn('fail, topic can not be empty')
2390
- : n.topic === t
2391
- ? (s.info('nothing changed'), void this.view.update_node(n))
2392
- : ((n.topic = t),
2393
- this.view.update_node(n),
2394
- this.layout.layout(),
2395
- this.view.show(!1),
2396
- void this.invoke_event_handle(i.edit, {
2397
- evt: 'update_node',
2398
- data: [e, t],
2399
- node: e,
2400
- }));
2401
- if ('object' == typeof t && null !== t) {
2402
- var o = n.id,
2403
- r = !1;
2404
- if (void 0 !== t.topic) {
2405
- if (a.text.is_empty(t.topic))
2406
- return void s.warn('fail, topic can not be empty');
2407
- n.topic !== t.topic && ((n.topic = t.topic), (r = !0));
2408
- }
2409
- if (t.data && 'object' == typeof t.data)
2410
- for (var d in t.data)
2411
- t.data.hasOwnProperty(d) &&
2412
- n.data[d] !== t.data[d] &&
2413
- ((n.data[d] = t.data[d]), (r = !0));
2414
- if (void 0 !== t.id) {
2415
- if ('string' != typeof t.id || '' === t.id.trim())
2416
- return void s.error('fail, new node id must be a non-empty string');
2417
- if (n.id !== t.id) {
2418
- if (n.isroot)
2419
- return void s.error('fail, cannot change root node id');
2420
- if (t.id in this.mind.nodes)
2421
- return void s.error(
2422
- 'fail, new id "' + t.id + '" already exists'
2423
- );
2424
- var l = n.id;
2425
- delete this.mind.nodes[l],
2426
- (n.id = t.id),
2427
- (this.mind.nodes[t.id] = n),
2428
- this.mind.selected &&
2429
- this.mind.selected.id === l &&
2430
- (this.mind.selected = n),
2431
- (r = !0);
2432
- }
2433
- }
2434
- if (
2435
- (['index', 'expanded', 'direction'].forEach(function (e) {
2436
- void 0 !== t[e] && n[e] !== t[e] && ((n[e] = t[e]), (r = !0));
2437
- }),
2438
- !r)
2439
- )
2440
- return s.info('nothing changed'), void this.view.update_node(n);
2441
- this.view.update_node(n),
2442
- this.layout.layout(),
2443
- this.view.show(!1),
2444
- this.invoke_event_handle(i.edit, {
2445
- evt: 'update_node',
2446
- data: [o, t],
2447
- node: o,
2448
- });
2449
- }
2450
- } else s.error('fail, node not found');
2451
- } else s.error('fail, this mind map is not editable');
2452
- }
2453
- move_node(e, t, n, o) {
2454
- if (this.get_editable()) {
2455
- var r = this.get_node(e),
2456
- a = this.mind.move_node(r, t, n, o);
2457
- a &&
2458
- (this.view.update_node(a),
2459
- this.layout.layout(),
2460
- this.view.show(!1),
2461
- this.invoke_event_handle(i.edit, {
2462
- evt: 'move_node',
2463
- data: [e, t, n, o],
2464
- node: e,
2465
- }));
2466
- } else s.error('fail, this mind map is not editable');
2467
- }
2468
- select_node(e) {
2469
- if (!l.is_node(e)) {
2470
- var t = this.get_node(e);
2471
- return t
2472
- ? void this.select_node(t)
2473
- : void s.error('the node[id=' + e + '] can not be found.');
2474
- }
2475
- this.layout.is_visible(e) &&
2476
- ((this.mind.selected = e),
2477
- this.view.select_node(e),
2478
- this.invoke_event_handle(i.select, { evt: 'select_node', data: [], node: e.id }));
2479
- }
2480
- get_selected_node() {
2481
- return this.mind ? this.mind.selected : null;
2482
- }
2483
- select_clear() {
2484
- this.mind && ((this.mind.selected = null), this.view.select_clear());
2485
- }
2486
- is_node_visible(e) {
2487
- return this.layout.is_visible(e);
2488
- }
2489
- scroll_node_to_center(e) {
2490
- if (l.is_node(e)) this.view.center_node(e);
2491
- else {
2492
- var t = this.get_node(e);
2493
- t
2494
- ? this.scroll_node_to_center(t)
2495
- : s.error('the node[id=' + e + '] can not be found.');
2496
- }
2497
- }
2498
- find_node_before(e) {
2499
- if (!l.is_node(e)) {
2500
- var t = this.get_node(e);
2501
- return t
2502
- ? this.find_node_before(t)
2503
- : void s.error('the node[id=' + e + '] can not be found.');
2504
- }
2505
- if (e.isroot) return null;
2506
- var i = null;
2507
- if (e.parent.isroot)
2508
- for (var n = e.parent.children, o = null, r = null, a = 0; a < n.length; a++)
2509
- (r = n[a]), e.direction === r.direction && (e.id === r.id && (i = o), (o = r));
2510
- else i = this.mind.get_node_before(e);
2511
- return i;
2512
- }
2513
- find_node_after(e) {
2514
- if (!l.is_node(e)) {
2515
- var t = this.get_node(e);
2516
- return t
2517
- ? this.find_node_after(t)
2518
- : void s.error('the node[id=' + e + '] can not be found.');
2519
- }
2520
- if (e.isroot) return null;
2521
- var i = null;
2522
- if (e.parent.isroot) {
2523
- for (var n = e.parent.children, o = !1, r = null, a = 0; a < n.length; a++)
2524
- if (((r = n[a]), e.direction === r.direction)) {
2525
- if (o) {
2526
- i = r;
2527
- break;
2528
- }
2529
- e.id === r.id && (o = !0);
2530
- }
2531
- } else i = this.mind.get_node_after(e);
2532
- return i;
2533
- }
2534
- set_node_color(e, t, i) {
2535
- if (!this.get_editable()) return s.error('fail, this mind map is not editable'), null;
2536
- var n = this.mind.get_node(e);
2537
- n &&
2538
- (t && (n.data['background-color'] = t),
2539
- i && (n.data['foreground-color'] = i),
2540
- this.view.reset_node_custom_style(n));
2541
- }
2542
- set_node_font_style(e, t, i, n) {
2543
- if (!this.get_editable()) return s.error('fail, this mind map is not editable'), null;
2544
- var o = this.mind.get_node(e);
2545
- o &&
2546
- (t && (o.data['font-size'] = t),
2547
- i && (o.data['font-weight'] = i),
2548
- n && (o.data['font-style'] = n),
2549
- this.view.reset_node_custom_style(o),
2550
- this.view.update_node(o),
2551
- this.layout.layout(),
2552
- this.view.show(!1));
2553
- }
2554
- set_node_background_image(e, t, i, n, o) {
2555
- if (!this.get_editable()) return s.error('fail, this mind map is not editable'), null;
2556
- var r = this.mind.get_node(e);
2557
- r &&
2558
- (t && (r.data['background-image'] = t),
2559
- i && (r.data.width = i),
2560
- n && (r.data.height = n),
2561
- o && (r.data['background-rotation'] = o),
2562
- this.view.reset_node_custom_style(r),
2563
- this.view.update_node(r),
2564
- this.layout.layout(),
2565
- this.view.show(!1));
2566
- }
2567
- set_node_background_rotation(e, t) {
2568
- if (!this.get_editable()) return s.error('fail, this mind map is not editable'), null;
2569
- var i = this.mind.get_node(e);
2570
- if (i) {
2571
- if (!i.data['background-image'])
2572
- return (
2573
- s.error(
2574
- 'fail, only can change rotation angle of node with background image'
2575
- ),
2576
- null
2577
- );
2578
- (i.data['background-rotation'] = t),
2579
- this.view.reset_node_custom_style(i),
2580
- this.view.update_node(i),
2581
- this.layout.layout(),
2582
- this.view.show(!1);
2583
- }
2584
- }
2585
- resize() {
2586
- this.view.resize();
2587
- }
2588
- add_event_listener(e) {
2589
- 'function' == typeof e && this.event_handles.push(e);
2590
- }
2591
- clear_event_listener() {
2592
- this.event_handles = [];
2593
- }
2594
- invoke_event_handle(e, t) {
2595
- var i = this;
2596
- r.w.setTimeout(function () {
2597
- i._invoke_event_handle(e, t);
2598
- }, 0);
2599
- }
2600
- _invoke_event_handle(e, t) {
2601
- for (var i = this.event_handles.length, n = 0; n < i; n++) this.event_handles[n](e, t);
2602
- }
2603
- removePlugin(e) {
2604
- this.enhancedPluginManager && this.enhancedPluginManager.removePlugin(e);
2605
- }
2606
- getPlugin(e) {
2607
- if (this.enhancedPluginManager) return this.enhancedPluginManager.getPlugin(e);
2608
- }
2609
- destroy() {
2610
- this.enhancedPluginManager && this.enhancedPluginManager.destroyAllPlugins(),
2611
- this.clear_event_listener(),
2612
- this.view && this.view.reset(),
2613
- (this.mind = null),
2614
- (this.initialized = !1);
2615
- }
2616
- static show(e, t) {
2617
- s.warn(
2618
- '`jsMind.show(options, mind)` is deprecated, please use `jm = new jsMind(options); jm.show(mind);` instead'
2619
- );
2620
- var i = new k(e);
2621
- return i.show(t), i;
2622
- }
2623
- }
2624
- return k;
2625
- });
2
+ * @license BSD-3-Clause
3
+ * @copyright 2014-2025 hizzgdev@163.com
4
+ *
5
+ * Project Home:
6
+ * https://github.com/hizzgdev/jsmind/
7
+ */
8
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).jsMind=t()}(this,function(){"use strict";const e="0.9.1";"function"!=typeof String.prototype.startsWith&&(String.prototype.startsWith=function(e){return this.slice(0,e.length)===e});const t={left:-1,center:0,right:1,of:function(e){return e&&-1!==e&&0!==e&&1!==e?"-1"===e||"0"===e||"1"===e?parseInt(e):"left"===e.toLowerCase()?this.left:"right"===e.toLowerCase()?this.right:"center"===e.toLowerCase()?this.center:void 0:e}},i={show:1,resize:2,edit:3,select:4,reset:5,history_change:6},n={debug:1,info:2,warn:3,error:4,disable:9};var o=function(){};let s="undefined"==typeof console?{level:o,log:o,debug:o,info:o,warn:o,error:o}:{level:function(e){s.debug=e>n.debug?o:console.debug;s.info=e>n.info?o:console.info;s.warn=e>n.warn?o:console.warn;s.error=e>n.error?o:console.error},log:console.log,debug:console.debug,info:console.info,warn:console.warn,error:console.error};const r=new class{constructor(e){this.w=e,this.d=e.document,this.g=function(e){return this.d.getElementById(e)},this.c=function(e){return this.d.createElement(e)},this.t=function(e,t){e.hasChildNodes()?e.firstChild.nodeValue=t:e.appendChild(this.d.createTextNode(t))},this.h=function(e,t){t instanceof HTMLElement?(e.innerHTML="",e.appendChild(t)):e.innerHTML=t},this.i=function(e){return!!e&&"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument},this.on=function(e,t,i){e.addEventListener?e.addEventListener(t,i,!1):e.attachEvent("on"+t,i)}}}(window),a={file:{read:function(e,t){var i=new FileReader;i.onload=function(){"function"==typeof t&&t(this.result,e.name)},i.readAsText(e)},save:function(e,t,i){var n;if("function"==typeof r.w.Blob)n=new Blob([e],{type:t});else{var o=new(r.w.BlobBuilder||r.w.MozBlobBuilder||r.w.WebKitBlobBuilder||r.w.MSBlobBuilder);o.append(e),n=o.getBlob(t)}if(navigator.msSaveBlob)navigator.msSaveBlob(n,i);else{var s=(r.w.URL||r.w.webkitURL).createObjectURL(n),a=r.c("a");if("download"in a){a.style.visibility="hidden",a.href=s,a.download=i,r.d.body.appendChild(a);var d=r.d.createEvent("MouseEvents");d.initEvent("click",!0,!0),a.dispatchEvent(d),r.d.body.removeChild(a)}else location.href=s}}},json:{json2string:function(e){return JSON.stringify(e)},string2json:function(e){return JSON.parse(e)},merge:function(e,t){for(var i in t)"__proto__"!==i&&"constructor"!==i&&"prototype"!==i&&(i in e?"object"!=typeof e[i]||"[object object]"!=Object.prototype.toString.call(e[i]).toLowerCase()||e[i].length?e[i]=t[i]:a.json.merge(e[i],t[i]):e[i]=t[i]);return e}},uuid:{newid:function(){return((new Date).getTime().toString(16)+Math.random().toString(16).substring(2)).substring(2,18)}},text:{is_empty:function(e){return!e||0==e.replace(/\s*/,"").length}}},d={container:"",editable:!1,theme:null,mode:"full",support_html:!0,log_level:"info",view:{engine:"canvas",enable_device_pixel_ratio:!1,hmargin:100,vmargin:50,line_width:2,line_color:"#555",line_style:"curved",draggable:!1,hide_scrollbars_when_draggable:!1,node_overflow:"hidden",zoom:{min:.5,max:2.1,step:.1,mask_key:4096},custom_node_render:null,expander_style:"char"},layout:{hspace:30,vspace:20,pspace:13,cousin_space:0},default_event_handle:{enable_mousedown_handle:!0,enable_click_handle:!0,enable_dblclick_handle:!0,enable_mousewheel_handle:!0},shortcut:{enable:!0,handles:{},mapping:{addchild:[45,4109],addbrother:13,editnode:113,delnode:46,toggle:32,left:37,up:38,right:39,down:40}},fieldNames:{id:"id",topic:"topic",children:"children",parentid:"parentid",isroot:"isroot",direction:"direction",expanded:"expanded"},plugin:{}};class l{constructor(e,t,i,n,o,r,a,d){e?"number"==typeof t?(void 0===d&&(d=!0),this.id=e,this.index=t,this.topic=i,this.data=n||{},this.isroot=o,this.parent=r,this.direction=a,this.expanded=!!d,this.children=[],this._data={}):s.error("invalid node index"):s.error("invalid node id")}get_location(){var e=this._data.view;return{x:e.abs_x,y:e.abs_y}}get_size(){var e=this._data.view;return{w:e.width,h:e.height}}static compare(e,t){var i=e.index,n=t.index;return i>=0&&n>=0?i-n:-1==i&&-1==n?0:-1==i?1:-1==n?-1:0}static inherited(e,t){if(e&&t){if(e.id===t.id)return!0;if(e.isroot)return!0;for(var i=e.id,n=t;!n.isroot;)if((n=n.parent).id===i)return!0}return!1}static is_node(e){return!!e&&e instanceof l}toObject(e,t=!1){var i=e||{},n=i.id||"id",o=i.topic||"topic",s=i.children||"children",r=i.direction||"direction",a=i.expanded||"expanded",d={};if(d[n]=this.id,d[o]=this.topic,d[a]=this.expanded,this.parent&&this.parent.isroot&&(d[r]=-1===this.direction?"left":"right"),null!=this.data)for(var l in this.data)d[l]=this.data[l];return t&&this.children.length>0&&(d[s]=this.children.map(t=>t.toObject(e,!0))),d}}class h{constructor(){this.name=null,this.author=null,this.version=null,this.root=null,this.selected=null,this.nodes={}}get_node(e){return e in this.nodes?this.nodes[e]:(s.warn("the node[id="+e+"] can not be found"),null)}set_root(e,t,i){return null==this.root?(this.root=new l(e,0,t,i,!0),this._put_node(this.root),this.root):(s.error("root node is already exist"),null)}add_node(e,i,n,o,r,a,d){if(!l.is_node(e))return s.error("the parent_node "+e+" is not a node."),null;var h=new l(i,d||-1,n,o,!1,e,e.direction,a);return e.isroot&&(h.direction=r||t.right),this._put_node(h)?(e.children.push(h),this._update_index(e)):(s.error("fail, the node id '"+h.id+"' has been already exist."),h=null),h}insert_node_before(e,t,i,n,o){if(!l.is_node(e))return s.error("the node_before "+e+" is not a node."),null;var r=e.index-.5;return this.add_node(e.parent,t,i,n,o,!0,r)}get_node_before(e){if(!l.is_node(e)){var t=this.get_node(e);return t?this.get_node_before(t):(s.error("the node[id="+e+"] can not be found."),null)}if(e.isroot)return null;var i=e.index-2;return i>=0?e.parent.children[i]:null}insert_node_after(e,t,i,n,o){if(!l.is_node(e))return s.error("the node_after "+e+" is not a node."),null;var r=e.index+.5;return this.add_node(e.parent,t,i,n,o,!0,r)}get_node_after(e){if(!l.is_node(e)){var t=this.get_node(e);return t?this.get_node_after(t):(s.error("the node[id="+e+"] can not be found."),null)}if(e.isroot)return null;var i=e.index;return e.parent.children.length>i?e.parent.children[i]:null}move_node(e,t,i,n){return l.is_node(e)?(i||(i=e.parent.id),this._move_node(e,t,i,n)):(s.error("the parameter node "+e+" is not a node."),null)}_flow_node_direction(e,t){void 0===t?t=e.direction:e.direction=t;for(var i=e.children.length;i--;)this._flow_node_direction(e.children[i],t)}_move_node_internal(e,t){if(e&&t)if("_last_"==t)e.index=-1,this._update_index(e.parent);else if("_first_"==t)e.index=0,this._update_index(e.parent);else{var i=t?this.get_node(t):null;null!=i&&null!=i.parent&&i.parent.id==e.parent.id&&(e.index=i.index-.5,this._update_index(e.parent))}return e}_move_node(e,i,n,o){if(e&&n){var r=this.get_node(n);if(l.inherited(e,r))return s.error("can not move a node to its children"),null;if(e.parent.id!=n){for(var a=e.parent.children,d=a.length;d--;)if(a[d].id==e.id){a.splice(d,1);break}let t=e.parent;e.parent=r,r.children.push(e),this._update_index(t)}e.parent.isroot?o==t.left?e.direction=o:e.direction=t.right:e.direction=e.parent.direction,this._move_node_internal(e,i),this._flow_node_direction(e)}return e}remove_node(e){if(!l.is_node(e))return s.error("the parameter node "+e+" is not a node."),!1;if(e.isroot)return s.error("fail, can not remove root node"),!1;null!=this.selected&&this.selected.id==e.id&&(this.selected=null);for(var t=e.children,i=t.length;i--;)this.remove_node(t[i]);t.length=0;for(var n=e.parent,o=n.children,r=o.length;r--;)if(o[r].id==e.id){o.splice(r,1);break}for(var a in delete this.nodes[e.id],e)delete e[a];return e=null,this._update_index(n),!0}change_node_id(e,t){if(!e||!t)return s.error("invalid node id"),!1;if(e===t)return s.warn("nothing changed"),!0;const i=this.get_node(e);return i?i.isroot?(s.error("fail, can not change root node id"),!1):t in this.nodes?(s.error("fail, the node id '"+t+"' has been already exist."),!1):(delete this.nodes[e],i.id=t,this.nodes[t]=i,!0):(s.error("the node[id="+e+"] can not be found."),!1)}_put_node(e){return e.id in this.nodes?(s.warn("the node_id '"+e.id+"' has been already exist."),!1):(this.nodes[e.id]=e,!0)}_update_index(e){if(e instanceof l){e.children.sort(l.compare);for(var t=0;t<e.children.length;t++)e.children[t].index=t+1}}}const _={name:"jsMind",author:"UmbraCi",version:e},u={node_tree:{example:{meta:_,format:"node_tree",data:{id:"root",topic:"jsMind node_tree example"}},get_mind:function(e,t){var i=u.node_tree,n=new h;return n.name=e.meta.name,n.author=e.meta.author,n.version=e.meta.version,i._parse(n,e.data,t),n},get_data:function(e,t){var i=u.node_tree,n={};return n.meta={name:e.name,author:e.author,version:e.version},n.format="node_tree",n.data=i._build_node(e.root,t),n},_parse:function(e,t,i){var n=u.node_tree,o=i||{},s=o.id||"id",r=o.topic||"topic",a=o.children||"children",d=n._extract_data(t,i);if(e.set_root(t[s],t[r],d),a in t)for(var l=t[a],h=0;h<l.length;h++)n._extract_subnode(e,e.root,l[h],i)},_extract_data:function(e,t){var i=t||{},n=i.id||"id",o=i.topic||"topic",s=i.children||"children",r=i.direction||"direction",a=i.expanded||"expanded",d={};for(var l in e)l!=n&&l!=o&&l!=s&&l!=r&&l!=a&&(d[l]=e[l]);return d},_extract_subnode:function(e,i,n,o){var s=u.node_tree,r=o||{},a=r.id||"id",d=r.topic||"topic",l=r.children||"children",h=r.direction||"direction",_=r.expanded||"expanded",c=s._extract_data(n,o),p=null;i.isroot&&(p="left"==n[h]?t.left:t.right);var v=e.add_node(i,n[a],n[d],c,p,n[_]);if(n[l])for(var g=n[l],f=0;f<g.length;f++)s._extract_subnode(e,v,g[f],o)},_build_node:function(e,i){var n=u.node_tree;if(e instanceof l){var o=i||{},s=o.id||"id",r=o.topic||"topic",a=o.children||"children",d=o.direction||"direction",h=o.expanded||"expanded",_={};if(_[s]=e.id,_[r]=e.topic,_[h]=e.expanded,e.parent&&e.parent.isroot&&(_[d]=e.direction==t.left?"left":"right"),null!=e.data){var c=e.data;for(var p in c)_[p]=c[p]}var v=e.children;if(v.length>0){_[a]=[];for(var g=0;g<v.length;g++)_[a].push(n._build_node(v[g],i))}return _}}},node_array:{example:{meta:_,format:"node_array",data:[{id:"root",topic:"jsMind node_array example",isroot:!0}]},get_mind:function(e,t){var i=u.node_array,n=new h;return n.name=e.meta.name,n.author=e.meta.author,n.version=e.meta.version,i._parse(n,e.data,t),n},get_data:function(e,t){var i=u.node_array,n={};return n.meta={name:e.name,author:e.author,version:e.version},n.format="node_array",n.data=[],i._array(e,n.data,t),n},_parse:function(e,t,i){var n=u.node_array,o=t.slice(0);o.reverse();var r=n._extract_root(e,o,i);r?n._extract_subnode(e,r,o,i):s.error("root node can not be found")},_extract_root:function(e,t,i){for(var n=u.node_array,o=i||{},s=o.id||"id",r=o.topic||"topic",a=o.isroot||"isroot",d=t.length;d--;)if(a in t[d]&&t[d][a]){var l=t[d],h=n._extract_data(l,i),_=e.set_root(l[s],l[r],h);return t.splice(d,1),_}return null},_extract_subnode:function(e,i,n,o){for(var s=u.node_array,r=o||{},a=r.id||"id",d=r.topic||"topic",l=r.parentid||"parentid",h=r.direction||"direction",_=r.expanded||"expanded",c=n.length,p=null,v=null,g=0;c--;)if((p=n[c])[l]==i.id){v=s._extract_data(p,o);var f=null,m=p[h];m&&(f="left"==m?t.left:t.right);var y=e.add_node(i,p[a],p[d],v,f,p[_]);n.splice(c,1),g++;var w=s._extract_subnode(e,y,n,o);w>0&&(c=n.length,g+=w)}return g},_extract_data:function(e,t){var i=t||{},n=i.id||"id",o=i.topic||"topic",s=i.parentid||"parentid",r=i.isroot||"isroot",a=i.direction||"direction",d=i.expanded||"expanded",l={};for(var h in e)h!=n&&h!=o&&h!=s&&h!=r&&h!=a&&h!=d&&(l[h]=e[h]);return l},_array:function(e,t,i){u.node_array._array_node(e.root,t,i)},_array_node:function(e,i,n){var o=u.node_array;if(e instanceof l){var s=n||{},r=s.id||"id",a=s.topic||"topic",d=s.parentid||"parentid",h=s.isroot||"isroot",_=s.direction||"direction",c=s.expanded||"expanded",p={};if(p[r]=e.id,p[a]=e.topic,p[c]=e.expanded,e.parent&&(p[d]=e.parent.id),e.isroot&&(p[h]=!0),e.parent&&e.parent.isroot&&(p[_]=e.direction==t.left?"left":"right"),null!=e.data){var v=e.data;for(var g in v)p[g]=v[g]}i.push(p);for(var f=e.children.length,m=0;m<f;m++)o._array_node(e.children[m],i,n)}}},freemind:{example:{meta:_,format:"freemind",data:'<map version="1.0.1"><node ID="root" TEXT="jsMind freemind example"/></map>'},get_mind:function(e,t){var i=u.freemind,n=new h;n.name=e.meta.name,n.author=e.meta.author,n.version=e.meta.version;var o=e.data,s=i._parse_xml(o),r=i._find_root(s);return i._load_node(n,null,r),n},get_data:function(e,t){var i=u.freemind,n={};n.meta={name:e.name,author:e.author,version:e.version},n.format="freemind";var o=[];return o.push('<map version="1.0.1">'),i._build_map(e.root,o),o.push("</map>"),n.data=o.join(""),n},_parse_xml:function(e){var t=null;window.DOMParser?t=(new DOMParser).parseFromString(e,"text/xml"):((t=new ActiveXObject("Microsoft.XMLDOM")).async=!1,t.loadXML(e));return t},_find_root:function(e){for(var t=e.childNodes,i=null,n=null,o=0;o<t.length;o++)if(1==(n=t[o]).nodeType&&"map"==n.tagName){i=n;break}if(i){var s=i.childNodes;i=null;for(o=0;o<s.length;o++)if(1==(n=s[o]).nodeType&&"node"==n.tagName){i=n;break}}return i},_load_node:function(e,i,n){var o=u.freemind,s=n.getAttribute("ID"),r=n.getAttribute("TEXT"),a=n.getAttribute("FOLDED");if(null==r)for(var d=n.childNodes,l=null,h=0;h<d.length;h++)if(1==(l=d[h]).nodeType&&"richcontent"===l.tagName){r=l.textContent;break}var _=o._load_attributes(n),c="expanded"in _?"true"==_.expanded:"true"!=a;delete _.expanded;var p=n.getAttribute("COLOR");p&&(_["foreground-color"]=p);var v=n.getAttribute("BACKGROUND_COLOR");v&&(_["background-color"]=v);var g=n.getAttribute("POSITION"),f=null;g&&(f="left"==g?t.left:t.right);var m=null;m=i?e.add_node(i,s,r,_,f,c):e.set_root(s,r,_);var y=n.childNodes,w=null;for(h=0;h<y.length;h++)1==(w=y[h]).nodeType&&"node"==w.tagName&&o._load_node(e,m,w)},_load_attributes:function(e){for(var t=e.childNodes,i=null,n={},o=0;o<t.length;o++)1==(i=t[o]).nodeType&&"attribute"===i.tagName&&(n[i.getAttribute("NAME")]=i.getAttribute("VALUE"));return n},_build_map:function(e,i){var n=u.freemind,o=null,s=e.data;if(e.parent&&e.parent.isroot&&(o=e.direction===t.left?"left":"right"),i.push("<node"),i.push(' ID="'+e.id+'"'),o&&i.push(' POSITION="'+o+'"'),e.expanded||i.push(' FOLDED="true"'),s["foreground-color"]&&i.push(' COLOR="'+s["foreground-color"]+'"'),s["background-color"]&&i.push(' BACKGROUND_COLOR="'+s["background-color"]+'"'),i.push(' TEXT="'+n._escape(e.topic)+'">'),null!=s)for(var r in s)"foreground-color"!==r&&"background-color"!==r&&i.push('<attribute NAME="'+r+'" VALUE="'+s[r]+'"/>');for(var a=e.children,d=0;d<a.length;d++)n._build_map(a[d],i);i.push("</node>")},_escape:function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")}},text:{example:{meta:_,format:"text",data:"jsMind text example\n node1\n node1-sub\n node1-sub\n node2"},_line_regex:/\s*/,get_mind:function(e,t){var i=u.text,n=new h;n.name=e.meta.name,n.author=e.meta.author,n.version=e.meta.version;var o=e.data.split(/\n|\r/);return i._fill_nodes(n,o,0,0),n},_fill_nodes:function(e,t){let i=[],n=0;for(;n<t.length;){let o=t[n],s=o.match(/\s*/)[0].length,r=o.substr(s);if(0==s&&i.length>0)return void log.error("more than 1 root node was found: "+r);if(s>i.length)return void log.error("a suspended node was found: "+r);let d=i.length-s;for(;d--;)i.pop();if(0==s&&0==i.length){let t=e.set_root(a.uuid.newid(),r);i.push(t)}else{let t=e.add_node(i[s-1],a.uuid.newid(),r,{},null);i.push(t)}n++}i.length=0},get_data:function(e){var t=u.text,i={};i.meta={name:e.name,author:e.author,version:e.version},i.format="text";let n=[];return t._build_lines(n,[e.root],0),i.data=n.join("\n"),i},_build_lines:function(e,t,i){let n=new Array(i+1).join(" ");for(let o of t)e.push(n+o.topic),o.children&&u.text._build_lines(e,o.children,i+1)}}};class c{constructor(e){this.jm=e}init(){s.debug("data.init")}reset(){s.debug("data.reset")}load(e){var t=null,i=null;t="object"==typeof e?e.format?e.format:"node_tree":"freemind";const n=this.jm&&this.jm.options?this.jm.options.fieldNames:void 0,o=t=>void 0===n?t.get_mind(e):t.get_mind(e,n);return"node_array"==t?i=o(u.node_array):"node_tree"==t?i=o(u.node_tree):"freemind"==t?i=o(u.freemind):"text"==t?i=o(u.text):s.warn("unsupported format"),i}get_data(e){var t=null;const i=this.jm&&this.jm.options?this.jm.options.fieldNames:void 0,n=e=>void 0===i?e.get_data(this.jm.mind):e.get_data(this.jm.mind,i);return"node_array"==e?t=n(u.node_array):"node_tree"==e?t=n(u.node_tree):"freemind"==e?t=u.freemind.get_data(this.jm.mind):"text"==e?t=u.text.get_data(this.jm.mind):s.error("unsupported "+e+" format"),t}}class p{constructor(e,t){this.opts=t,this.jm=e,this.isside="side"==this.opts.mode,this.bounds=null,this.cache_valid=!1}init(){s.debug("layout.init")}reset(){s.debug("layout.reset"),this.bounds={n:0,s:0,w:0,e:0}}calculate_next_child_direction(e){if(this.isside)return t.right;for(var i=e.children||[],n=i.length,o=0,s=0;s<n;s++)i[s].direction===t.left?o--:o++;return n>1&&o>0?t.left:t.right}layout(){s.debug("layout.layout"),this.layout_direction(),this.layout_offset()}layout_direction(){this._layout_direction_root()}_layout_direction_root(){var e=this.jm.mind.root,i=null;"layout"in e._data?i=e._data.layout:(i={},e._data.layout=i);var n=e.children,o=n.length;if(i.direction=t.center,i.side_index=0,this.isside)for(var s=o;s--;)this._layout_direction_side(n[s],t.right,s);else{s=o;for(var r=null;s--;)(r=n[s]).direction==t.left?this._layout_direction_side(r,t.left,s):this._layout_direction_side(r,t.right,s)}}_layout_direction_side(e,t,i){var n=null;"layout"in e._data?n=e._data.layout:(n={},e._data.layout=n);var o=e.children,s=o.length;n.direction=t,n.side_index=i;for(var r=s;r--;)this._layout_direction_side(o[r],t,r)}layout_offset(){var e=this.jm.mind.root,i=e._data.layout;i.offset_x=0,i.offset_y=0,i.outer_height=0;for(var n=e.children,o=n.length,s=[],r=[],a=null;o--;)(a=n[o])._data.layout.direction==t.right?r.unshift(a):s.unshift(a);i.left_nodes=s,i.right_nodes=r,i.outer_height_left=this._layout_offset_subnodes(s),i.outer_height_right=this._layout_offset_subnodes(r),this.bounds.e=e._data.view.width/2,this.bounds.w=0-this.bounds.e,this.bounds.n=0,this.bounds.s=Math.max(i.outer_height_left,i.outer_height_right)}_layout_offset_subnodes(e){for(var t=0,i=e.length,n=i,o=null,s=0,r=null,a=0,d=null;n--;)r=(o=e[n])._data.layout,null==d&&(d=o.parent._data),s=this._layout_offset_subnodes(o.children),o.expanded||(s=0,this.set_visible(o.children,!1)),s=Math.max(o._data.view.height,s),this._should_reserve_cousin_space(o)&&(s+=this.opts.cousin_space),r.outer_height=s,r.offset_y=a-s/2,r.offset_x=this.opts.hspace*r.direction+d.view.width*(d.layout.direction+r.direction)/2,o.parent.isroot||(r.offset_x+=this.opts.pspace*r.direction),a=a-s-this.opts.vspace,t+=s;i>1&&(t+=this.opts.vspace*(i-1)),n=i;for(var l=t/2;n--;)(o=e[n])._data.layout.offset_y+=l;return t}_layout_offset_subnodes_height(e){for(var t=0,i=e.length,n=i,o=null,s=0,r=null,a=0,d=null;n--;)r=(o=e[n])._data.layout,null==d&&(d=o.parent._data),s=this._layout_offset_subnodes_height(o.children),o.expanded||(s=0),s=Math.max(o._data.view.height,s),this._should_reserve_cousin_space(o)&&(s+=this.opts.cousin_space),r.outer_height=s,r.offset_y=a-s/2,a=a-s-this.opts.vspace,t+=s;i>1&&(t+=this.opts.vspace*(i-1)),n=i;for(var l=t/2;n--;)(o=e[n])._data.layout.offset_y+=l;return t}_should_reserve_cousin_space(e){return e.children.length>0&&e.parent.children.length>1}get_node_offset(e){var t=e._data.layout,i=null;if("_offset_"in t&&this.cache_valid?i=t._offset_:(i={x:-1,y:-1},t._offset_=i),-1==i.x||-1==i.y){var n=t.offset_x,o=t.offset_y;if(!e.isroot){var s=this.get_node_offset(e.parent);n+=s.x,o+=s.y}i.x=n,i.y=o}return i}get_node_point(e){var t=e._data.view,i=this.get_node_offset(e),n={};return n.x=i.x+t.width*(e._data.layout.direction-1)/2,n.y=i.y-t.height/2,n}get_node_point_in(e){return this.get_node_offset(e)}get_node_point_out(e){var t=e._data.layout,i=null;if("_pout_"in t&&this.cache_valid?i=t._pout_:(i={x:-1,y:-1},t._pout_=i),-1==i.x||-1==i.y)if(e.isroot)i.x=0,i.y=0;else{var n=e._data.view,o=this.get_node_offset(e);i.x=o.x+(n.width+this.opts.pspace)*e._data.layout.direction,i.y=o.y}return i}get_expander_point(e){var i=this.get_node_point_out(e),n={};return e._data.layout.direction==t.right?n.x=i.x-this.opts.pspace:n.x=i.x,n.y=i.y-Math.ceil(this.opts.pspace/2),n}get_min_size(){var e=this.jm.mind.nodes,t=null,i=null;for(var n in e)t=e[n],(i=this.get_node_point_out(t)).x>this.bounds.e&&(this.bounds.e=i.x),i.x<this.bounds.w&&(this.bounds.w=i.x);return{w:this.bounds.e-this.bounds.w,h:this.bounds.s-this.bounds.n}}toggle_node(e){e.isroot||(e.expanded?this.collapse_node(e):this.expand_node(e))}expand_node(e){e.expanded=!0,this.part_layout(e),this.set_visible(e.children,!0),this.jm.invoke_event_handle(i.show,{evt:"expand_node",data:[],node:e.id})}collapse_node(e){e.expanded=!1,this.part_layout(e),this.set_visible(e.children,!1),this.jm.invoke_event_handle(i.show,{evt:"collapse_node",data:[],node:e.id})}expand_all(){var e,t=this.jm.mind.nodes,i=0;for(var n in t)(e=t[n]).expanded||(e.expanded=!0,i++);if(i>0){var o=this.jm.mind.root;this.part_layout(o),this.set_visible(o.children,!0)}}collapse_all(){var e,t=this.jm.mind.nodes,i=0;for(var n in t)(e=t[n]).expanded&&!e.isroot&&(e.expanded=!1,i++);if(i>0){var o=this.jm.mind.root;this.part_layout(o),this.set_visible(o.children,!0)}}expand_to_depth(e,t,i){if(!(e<1))for(var n=t||this.jm.mind.root.children,o=i||1,s=n.length,r=null;s--;)r=n[s],o<e&&(r.expanded||this.expand_node(r),this.expand_to_depth(e,r.children,o+1)),o==e&&r.expanded&&this.collapse_node(r)}part_layout(e){var i=this.jm.mind.root;if(i){var n=i._data.layout;e.isroot?(n.outer_height_right=this._layout_offset_subnodes_height(n.right_nodes),n.outer_height_left=this._layout_offset_subnodes_height(n.left_nodes)):e._data.layout.direction==t.right?n.outer_height_right=this._layout_offset_subnodes_height(n.right_nodes):n.outer_height_left=this._layout_offset_subnodes_height(n.left_nodes),this.bounds.s=Math.max(n.outer_height_left,n.outer_height_right),this.cache_valid=!1}else s.warn("can not found root node")}set_visible(e,t){for(var i=e.length,n=null;i--;)(n=e[i])._data.layout,n.expanded?this.set_visible(n.children,t):this.set_visible(n.children,!1),n.isroot||(n._data.layout.visible=t)}is_expand(e){return e.expanded}is_visible(e){var t=e._data.layout;return!("visible"in t&&!t.visible)}}class v{constructor(e){this.view=e,this.opts=e.opts,this.e_svg=v.c("svg"),this.e_svg.setAttribute("class","jsmind"),this.size={w:0,h:0},this.lines=[],this.line_drawing={straight:this._line_to,curved:this._bezier_to},this.init_line_render()}static c(e){return r.d.createElementNS("http://www.w3.org/2000/svg",e)}init_line_render(){"function"==typeof this.opts.custom_line_render?this.drawing=(e,t,i,n,o)=>{try{this.opts.custom_line_render.call(this,{ctx:e,start_point:{x:t,y:i},end_point:{x:n,y:o}})}catch(e){s.error("custom line renderer error: ",e)}}:this.drawing=this.line_drawing[this.opts.line_style]||this.line_drawing.curved}element(){return this.e_svg}set_size(e,t){this.size.w=e,this.size.h=t,this.e_svg.setAttribute("width",e),this.e_svg.setAttribute("height",t)}clear(){for(var e=this.lines.length;e--;)this.e_svg.removeChild(this.lines[e]);this.lines.length=0}draw_line(e,t,i,n){var o=v.c("path");o.setAttribute("stroke",n||this.opts.line_color),o.setAttribute("stroke-width",this.opts.line_width),o.setAttribute("fill","transparent"),this.lines.push(o),this.e_svg.appendChild(o),this.drawing(o,t.x+i.x,t.y+i.y,e.x+i.x,e.y+i.y)}copy_to(e,t){var i=new Image;i.onload=function(){e.drawImage(i,0,0),t&&t()},i.src="data:image/svg+xml;base64,"+btoa((new XMLSerializer).serializeToString(this.e_svg))}_bezier_to(e,t,i,n,o){e.setAttribute("d","M "+t+" "+i+" C "+(t+2*(n-t)/3)+" "+i+", "+t+" "+o+", "+n+" "+o)}_line_to(e,t,i,n,o){e.setAttribute("d","M "+t+" "+i+" L "+n+" "+o)}}class g{constructor(e){this.opts=e.opts,this.e_canvas=r.c("canvas"),this.e_canvas.className="jsmind",this.canvas_ctx=this.e_canvas.getContext("2d"),this.size={w:0,h:0},this.line_drawing={straight:this._line_to,curved:this._bezier_to},this.dpr=e.device_pixel_ratio,this.init_line_render()}init_line_render(){"function"==typeof this.opts.custom_line_render?this.drawing=(e,t,i,n,o)=>{try{this.opts.custom_line_render.call(this,{ctx:e,start_point:{x:t,y:i},end_point:{x:n,y:o}})}catch(e){s.error("custom line render error: ",e)}}:this.drawing=this.line_drawing[this.opts.line_style]||this.line_drawing.curved}element(){return this.e_canvas}set_size(e,t){this.size.w=e,this.size.h=t,this.e_canvas.width&&this.e_canvas.height&&this.canvas_ctx.scale?(this.e_canvas.width=e*this.dpr,this.e_canvas.height=t*this.dpr,this.e_canvas.style.width=e+"px",this.e_canvas.style.height=t+"px",this.canvas_ctx.scale(this.dpr,this.dpr)):(this.e_canvas.width=e,this.e_canvas.height=t)}clear(){this.canvas_ctx.clearRect(0,0,this.size.w,this.size.h)}draw_line(e,t,i,n){var o=this.canvas_ctx;o.strokeStyle=n||this.opts.line_color,o.lineWidth=this.opts.line_width,o.lineCap="round",this.drawing(o,t.x+i.x,t.y+i.y,e.x+i.x,e.y+i.y)}copy_to(e,t){e.drawImage(this.e_canvas,0,0,this.size.w,this.size.h),t&&t()}_bezier_to(e,t,i,n,o){e.beginPath(),e.moveTo(t,i),e.bezierCurveTo(t+2*(n-t)/3,i,t,o,n,o),e.stroke()}_line_to(e,t,i,n,o){e.beginPath(),e.moveTo(t,i),e.lineTo(n,o),e.stroke()}}class f{constructor(e,t){this.opts=t,this.jm=e,this.layout=e.layout,this.container=null,this.e_panel=null,this.e_nodes=null,this.size={w:0,h:0},this.selected_node=null,this.editing_node=null,this.graph=null,this.render_node=t.custom_node_render?this._custom_node_render:this._default_node_render,this.zoom_current=1,this.device_pixel_ratio=this.opts.enable_device_pixel_ratio&&r.w.devicePixelRatio||1,this._initialized=!1}init(){if(s.debug(this.opts),s.debug("view.init"),this.container=r.i(this.opts.container)?this.opts.container:r.g(this.opts.container),this.container){var e;this.graph=(e=this,"svg"===this.opts.engine.toLowerCase()?new v(e):new g(e)),this.e_panel=r.c("div"),this.e_nodes=r.c("jmnodes"),this.e_editor=r.c("input"),this.e_panel.className="jsmind-inner jmnode-overflow-"+this.opts.node_overflow,this.e_panel.tabIndex=1,this.e_panel.appendChild(this.graph.element()),this.e_panel.appendChild(this.e_nodes),this.e_editor.className="jsmind-editor",this.e_editor.type="text";var t=this;r.on(this.e_editor,"keydown",function(e){var i=e||event;13==i.keyCode&&(t.edit_node_end(),i.stopPropagation())}),r.on(this.e_editor,"blur",function(e){t.edit_node_end()}),this.container.appendChild(this.e_panel),this.container.offsetParent||new IntersectionObserver((e,t)=>{e[0].isIntersecting&&(t.unobserve(this.e_panel),this.resize())}).observe(this.e_panel)}else s.error("the options.view.container was not be found in dom")}add_event(e,t,i,n){let o=n?this.e_panel:this.e_nodes;r.on(o,t,function(t){var n=t||event;i.call(e,n)})}get_binded_nodeid(e){if(null==e)return null;var t=e.tagName.toLowerCase();return"jmnode"==t||"jmexpander"==t?e.getAttribute("nodeid"):"jmnodes"==t||"body"==t||"html"==t?null:this.get_binded_nodeid(e.parentElement)}is_node(e){if(null==e)return!1;var t=e.tagName.toLowerCase();return"jmnode"==t||"jmnodes"!=t&&"body"!=t&&"html"!=t&&this.is_node(e.parentElement)}is_expander(e){return"jmexpander"==e.tagName.toLowerCase()}reset(){s.debug("view.reset"),this.selected_node=null,this.clear_lines(),this.clear_nodes(),this.reset_theme()}reset_theme(){var e=this.jm.options.theme;this.e_nodes.className=e?"theme-"+e:""}reset_custom_style(){var e=this.jm.mind.nodes;for(var t in e)this.reset_node_custom_style(e[t])}load(){s.debug("view.load"),this.setup_canvas_draggable(this.opts.draggable),this.init_nodes(),this._initialized=!0}expand_size(){var e=this.layout.get_min_size(),t=e.w+2*this.opts.hmargin,i=e.h+2*this.opts.vmargin,n=this.e_panel.clientWidth,o=this.e_panel.clientHeight;n<t&&(n=t),o<i&&(o=i),this.size.w=n,this.size.h=o}init_nodes_size(e){var t=e._data.view;t.width=t.element.clientWidth,t.height=t.element.clientHeight}init_nodes(){var e=this.jm.mind.nodes,t=r.d.createDocumentFragment();for(var i in e)this.create_node_element(e[i],t);this.e_nodes.appendChild(t),this.run_in_c11y_mode_if_needed(()=>{for(var t in e)this.init_nodes_size(e[t])})}add_node(e){this.create_node_element(e,this.e_nodes),this.run_in_c11y_mode_if_needed(()=>{this.init_nodes_size(e)})}run_in_c11y_mode_if_needed(e){this.container.offsetParent?e():(s.warn("init nodes in compatibility mode. because the container or its parent has style {display:none}. "),this.e_panel.style.position="absolute",this.e_panel.style.top="-100000",r.d.body.appendChild(this.e_panel),e(),this.container.appendChild(this.e_panel),this.e_panel.style.position=null,this.e_panel.style.top=null)}create_node_element(e,t){var i=null;"view"in e._data?i=e._data.view:(i={},e._data.view=i);var n=r.c("jmnode");if(e.isroot)n.className="root";else{var o=r.c("jmexpander");r.t(o,"-"),o.setAttribute("nodeid",e.id),o.style.visibility="hidden",t.appendChild(o),i.expander=o}e.topic&&this.render_node(n,e),n.setAttribute("nodeid",e.id),n.style.visibility="hidden",this._reset_node_custom_style(n,e.data),t.appendChild(n),i.element=n}remove_node(e){null!=this.selected_node&&this.selected_node.id==e.id&&(this.selected_node=null),null!=this.editing_node&&this.editing_node.id==e.id&&(e._data.view.element.removeChild(this.e_editor),this.editing_node=null);for(var t=e.children,i=t.length;i--;)this.remove_node(t[i]);if(e._data.view){var n=e._data.view.element,o=e._data.view.expander;this.e_nodes.removeChild(n),this.e_nodes.removeChild(o),e._data.view.element=null,e._data.view.expander=null}}update_node(e){var t=e._data.view,i=t.element;if(e.topic&&this.render_node(i,e),this.layout.is_visible(e))t.width=i.clientWidth,t.height=i.clientHeight;else{let e=i.getAttribute("style");i.style="visibility: visible; left:0; top:0;",t.width=i.clientWidth,t.height=i.clientHeight,i.style=e}}select_node(e){if(this.selected_node){var t=this.selected_node._data.view.element;t.className=t.className.replace(/\s*selected\b/i,""),this.restore_selected_node_custom_style(this.selected_node)}e&&(this.selected_node=e,e._data.view.element.className+=" selected",this.clear_selected_node_custom_style(e))}select_clear(){this.select_node(null)}get_editing_node(){return this.editing_node}is_editing(){return!!this.editing_node}edit_node_begin(e){if(e.topic){null!=this.editing_node&&this.edit_node_end(),this.editing_node=e;var t=e._data.view.element,i=e.topic,n=getComputedStyle(t);this.e_editor.value=i,this.e_editor.style.width=t.clientWidth-parseInt(n.getPropertyValue("padding-left"))-parseInt(n.getPropertyValue("padding-right"))+"px",t.innerHTML="",t.appendChild(this.e_editor),t.style.zIndex=5,this.e_editor.focus(),this.e_editor.select()}else s.warn("don't edit image nodes")}edit_node_end(){if(null!=this.editing_node){var e=this.editing_node;this.editing_node=null;var t=e._data.view.element,i=this.e_editor.value;t.style.zIndex="auto",t.removeChild(this.e_editor),a.text.is_empty(i)||e.topic===i?this.render_node(t,e):this.jm.update_node(e.id,i)}this.e_panel.focus()}get_view_offset(){var e=this.layout.bounds;return{x:(this.size.w-e.e-e.w)/2,y:this.size.h/2}}resize(){this.graph.set_size(1,1),this.e_nodes.style.width="1px",this.e_nodes.style.height="1px",this.expand_size(),this._show()}_show(){this.graph.set_size(this.size.w,this.size.h),this.e_nodes.style.width=this.size.w+"px",this.e_nodes.style.height=this.size.h+"px",this.show_nodes(),this.show_lines(),this.jm.invoke_event_handle(i.resize,{data:[]})}zoom_in(e){return this.set_zoom(this.zoom_current+this.opts.zoom.step,e)}zoom_out(e){return this.set_zoom(this.zoom_current-this.opts.zoom.step,e)}set_zoom(e,t){if(e<this.opts.zoom.min||e>this.opts.zoom.max)return!1;let i=this.e_panel.getBoundingClientRect();if(e<1&&e<this.zoom_current&&this.size.w*e<i.width&&this.size.h*e<i.height)return!1;let n=t?{x:t.x-i.x,y:t.y-i.y}:{x:i.width/2,y:i.height/2},o=(this.e_panel.scrollLeft+n.x)*e/this.zoom_current-n.x,s=(this.e_panel.scrollTop+n.y)*e/this.zoom_current-n.y;this.zoom_current=e;for(var r=0;r<this.e_panel.children.length;r++)this.e_panel.children[r].style.zoom=e;return this._show(),this.e_panel.scrollLeft=o,this.e_panel.scrollTop=s,!0}show(e){s.debug(`view.show: {keep_center: ${e}}`),this.expand_size(),this._show(),e&&this.center_node(this.jm.mind.root)}relayout(){this.expand_size(),this._show()}save_location(e){var t=e._data.view;t._saved_location={x:parseInt(t.element.style.left)-this.e_panel.scrollLeft,y:parseInt(t.element.style.top)-this.e_panel.scrollTop}}restore_location(e){var t=e._data.view;this.e_panel.scrollLeft=parseInt(t.element.style.left)-t._saved_location.x,this.e_panel.scrollTop=parseInt(t.element.style.top)-t._saved_location.y}clear_nodes(){var e=this.jm.mind;if(null!=e){var t=e.nodes,i=null;for(var n in t)(i=t[n])._data.view.element=null,i._data.view.expander=null;this.e_nodes.innerHTML=""}}show_nodes(){var e=this.jm.mind.nodes,t=null,i=null,n=null,o=null,s=this.get_view_offset();for(var r in e)i=(o=(t=e[r])._data.view).element,this.layout.is_visible(t)?(this.reset_node_custom_style(t),n=this.layout.get_node_point(t),o.abs_x=s.x+n.x,o.abs_y=s.y+n.y,i.style.left=s.x+n.x+"px",i.style.top=s.y+n.y+"px",i.style.display="",i.style.visibility="visible",this._show_expander(t,s)):(i.style.display="none",o.expander.style.display="none")}_show_expander(e,t){if(e.isroot)return;var i=e._data.view.expander;if(0==e.children.length)return i.style.display="none",void(i.style.visibility="hidden");let n=this._get_expander_text(e);r.t(i,n);let o=this.layout.get_expander_point(e);i.style.left=t.x+o.x+"px",i.style.top=t.y+o.y+"px",i.style.display="",i.style.visibility="visible"}_get_expander_text(e){let t=this.opts.expander_style?this.opts.expander_style.toLowerCase():"char";return"number"===t?e.children.length>99?"...":e.children.length:"char"===t?e.expanded?"−":"+":void 0}_default_node_render(e,t){this.opts.support_html?r.h(e,t.topic):r.t(e,t.topic)}_custom_node_render(e,t){this.opts.custom_node_render(this.jm,e,t)||this._default_node_render(e,t)}reset_node_custom_style(e){this._reset_node_custom_style(e._data.view.element,e.data)}_reset_node_custom_style(e,t){if("background-color"in t&&(e.style.backgroundColor=t["background-color"]),"foreground-color"in t&&(e.style.color=t["foreground-color"]),"width"in t&&(e.style.width=t.width+"px"),"height"in t&&(e.style.height=t.height+"px"),"font-size"in t&&(e.style.fontSize=t["font-size"]+"px"),"font-weight"in t&&(e.style.fontWeight=t["font-weight"]),"font-style"in t&&(e.style.fontStyle=t["font-style"]),"background-image"in t){var i=t["background-image"];if(i.startsWith("data")&&t.width&&t.height){var n=new Image;n.onload=function(){var t=r.c("canvas");t.width=e.clientWidth,t.height=e.clientHeight;if(t.getContext){t.getContext("2d").drawImage(this,2,2,e.clientWidth,e.clientHeight);var i=t.toDataURL();e.style.backgroundImage="url("+i+")"}},n.src=i}else e.style.backgroundImage="url("+i+")";e.style.backgroundSize="99%","background-rotation"in t&&(e.style.transform="rotate("+t["background-rotation"]+"deg)")}}restore_selected_node_custom_style(e){var t=e._data.view.element,i=e.data;"background-color"in i&&(t.style.backgroundColor=i["background-color"]),"foreground-color"in i&&(t.style.color=i["foreground-color"])}clear_selected_node_custom_style(e){var t=e._data.view.element;t.style.backgroundColor="",t.style.color=""}clear_lines(){this.graph.clear()}show_lines(){this.clear_lines();var e=this.jm.mind.nodes,t=null,i=null,n=null,o=null,s=this.get_view_offset();for(var r in e)(t=e[r]).isroot||this.layout.is_visible(t)&&(i=this.layout.get_node_point_in(t),n=this.layout.get_node_point_out(t.parent),o=t.data["leading-line-color"],this.graph.draw_line(n,i,s,o))}setup_canvas_draggable(e){if(this.opts.draggable=e,!this._initialized){let e,t,i=!1;this.opts.hide_scrollbars_when_draggable&&(this.e_panel.style="overflow: hidden"),r.on(this.container,"mousedown",n=>{this.opts.draggable&&(i=!0,e=n.clientX,t=n.clientY)}),r.on(this.container,"mouseup",()=>{i=!1}),r.on(this.container,"mousemove",n=>{this.opts.draggable&&i&&(this.e_panel.scrollBy(e-n.clientX,t-n.clientY),e=n.clientX,t=n.clientY)})}}center_node(e){if(!this.layout.is_visible(e))return s.warn("can not scroll to the node, because it is invisible"),!1;let t=e._data.view,i=this.e_panel.getBoundingClientRect(),n=t.abs_x+t.width/2,o=t.abs_y+t.height/2;return this.e_panel.scrollTo(n*this.zoom_current-i.width/2,o*this.zoom_current-i.height/2),!0}zoomIn(e){return s.warn("please use zoom_in instead"),this.zoom_in(e)}zoomOut(e){return s.warn("please use zoom_out instead"),this.zoom_out(e)}setZoom(e,t){return s.warn("please use set_zoom instead"),this.set_zoom(e,t)}}class m{constructor(e,t){this.jm=e,this.opts=t,this.mapping=t.mapping,this.handles=t.handles,this._newid=null,this._mapping={}}init(){for(var e in r.on(this.jm.view.e_panel,"keydown",this.handler.bind(this)),this.handles.addchild=this.handle_addchild,this.handles.addbrother=this.handle_addbrother,this.handles.editnode=this.handle_editnode,this.handles.delnode=this.handle_delnode,this.handles.toggle=this.handle_toggle,this.handles.up=this.handle_up,this.handles.down=this.handle_down,this.handles.left=this.handle_left,this.handles.right=this.handle_right,this.mapping)if(this.mapping[e]&&e in this.handles){let t=this.mapping[e];Array.isArray(t)||(t=[t]);for(let i of t)this._mapping[i]=this.handles[e]}"function"==typeof this.opts.id_generator?this._newid=this.opts.id_generator:this._newid=a.uuid.newid}enable_shortcut(){this.opts.enable=!0}disable_shortcut(){this.opts.enable=!1}handler(e){if(9==e.which&&e.preventDefault(),!this.jm.view.is_editing()){var t=e||event;if(!this.opts.enable)return!0;var i=t.keyCode+(t.metaKey<<13)+(t.ctrlKey<<12)+(t.altKey<<11)+(t.shiftKey<<10);i in this._mapping&&this._mapping[i].call(this,this.jm,e)}}handle_addchild(e,t){var i=e.get_selected_node();if(i){var n=this._newid();e.add_node(i,n,"New Node")&&(e.select_node(n),e.begin_edit(n))}}handle_addbrother(e,t){var i=e.get_selected_node();if(i&&!i.isroot){var n=this._newid();e.insert_node_after(i,n,"New Node")&&(e.select_node(n),e.begin_edit(n))}}handle_editnode(e,t){var i=e.get_selected_node();i&&e.begin_edit(i)}handle_delnode(e,t){var i=e.get_selected_node();i&&!i.isroot&&(e.select_node(i.parent),e.remove_node(i))}handle_toggle(e,t){var i=t||event,n=e.get_selected_node();n&&(e.toggle_node(n.id),i.stopPropagation(),i.preventDefault())}handle_up(e,t){var i=t||event,n=e.get_selected_node();if(n){var o=e.find_node_before(n);if(!o){var s=e.find_node_before(n.parent);s&&s.children.length>0&&(o=s.children[s.children.length-1])}o&&e.select_node(o),i.stopPropagation(),i.preventDefault()}}handle_down(e,t){var i=t||event,n=e.get_selected_node();if(n){var o=e.find_node_after(n);if(!o){var s=e.find_node_after(n.parent);s&&s.children.length>0&&(o=s.children[0])}o&&e.select_node(o),i.stopPropagation(),i.preventDefault()}}handle_left(e,i){this._handle_direction(e,i,t.left)}handle_right(e,i){this._handle_direction(e,i,t.right)}_handle_direction(e,t,i){var n=t||event,o=e.get_selected_node(),s=null;if(o){if(o.isroot){for(var r=o.children,a=[],d=0;d<r.length;d++)r[d].direction===i&&a.push(d);s=r[a[Math.floor((a.length-1)/2)]]}else if(o.direction===i){var l=(a=o.children).length;l>0&&(s=a[Math.floor((l-1)/2)])}else s=o.parent;s&&e.select_node(s),n.stopPropagation(),n.preventDefault()}}}class y{constructor(e){this.jm=e,this.plugins=new Map}initPreloadPlugins(){const e=this.jm.constructor.pluginList.filter(e=>e.preload);s.info("Initializing "+e.length+" preload plugins"),e.forEach(e=>{this._initPlugin(e)})}initNormalPlugins(){const e=this.jm.constructor.pluginList.filter(e=>!e.preload);s.info("Initializing "+e.length+" normal plugins"),e.forEach(e=>{this._initPlugin(e)})}_initPlugin(e){try{const{PluginClass:t,pluginOpt:i}=e;if(!t.instanceName)throw new Error("Plugin "+t.name+" must define static instanceName");this.plugins.has(t.instanceName)&&s.warn("Plugin "+t.instanceName+" already exists, will be replaced");const n=new t({jm:this.jm,pluginOpt:i||{}});this.plugins.set(t.instanceName,n),this.jm[t.instanceName]=n,e.instance=n,s.info("Plugin "+t.instanceName+" initialized")}catch(t){s.error("Failed to initialize plugin "+e.PluginClass.name+":",t)}}removePlugin(e){const t=e.instanceName;if(!t)return;const i=this.plugins.get(t);if(i)try{"function"==typeof i.beforePluginRemove&&i.beforePluginRemove(),this.plugins.delete(t),delete this.jm[t];const n=this.jm.constructor.pluginList,o=n.findIndex(t=>t.PluginClass===e);-1!==o&&n.splice(o,1),s.info("Plugin "+t+" removed")}catch(e){s.error("Failed to remove plugin "+t+":",e)}}destroyAllPlugins(){this.plugins.forEach((e,t)=>{try{"function"==typeof e.beforePluginDestroy&&e.beforePluginDestroy()}catch(e){s.error("Failed to destroy plugin "+t+":",e)}}),this.plugins.clear()}getPlugin(e){return this.plugins.get(e)}}class w{static instanceName="";static preload=!1;constructor({jm:e,pluginOpt:t}){this.jm=e,this.options=t||{}}beforePluginRemove(){}beforePluginDestroy(){this.beforePluginRemove()}}class b{static mind=h;static node=l;static direction=t;static event_type=i;static $=r;static plugin=w;static util=a;static plugin_base=w;static pluginList=[];static usePlugin(e,t={}){if(b.pluginList.some(t=>t.PluginClass===e))return s.warn("Plugin "+e.name+" already registered"),b;if(!e.instanceName)throw new Error("Plugin "+e.name+" must define static instanceName");return b.pluginList.push({PluginClass:e,instanceName:e.instanceName,preload:e.preload||!1,pluginOpt:t,instance:null}),b}static hasPlugin(e){return b.pluginList.some(t=>t.PluginClass===e)}constructor(t){b.current=this,this.options=function(e){var t={};if(a.json.merge(t,d),a.json.merge(t,e),!t.container)throw new Error("the options.container should not be null or empty.");return t}(t),s.level(n[this.options.log_level]),this.version=e,this.initialized=!1,this.mind=null,this.event_handles=[],this.init()}init(){if(!this.initialized){this.initialized=!0,this.pluginManager=new y(this),this.pluginManager.initPreloadPlugins();var e={mode:this.options.mode,hspace:this.options.layout.hspace,vspace:this.options.layout.vspace,pspace:this.options.layout.pspace,cousin_space:this.options.layout.cousin_space},t={container:this.options.container,support_html:this.options.support_html,engine:this.options.view.engine,enable_device_pixel_ratio:this.options.view.enable_device_pixel_ratio,hmargin:this.options.view.hmargin,vmargin:this.options.view.vmargin,line_width:this.options.view.line_width,line_color:this.options.view.line_color,line_style:this.options.view.line_style,custom_line_render:this.options.view.custom_line_render,draggable:this.options.view.draggable,hide_scrollbars_when_draggable:this.options.view.hide_scrollbars_when_draggable,node_overflow:this.options.view.node_overflow,zoom:this.options.view.zoom,custom_node_render:this.options.view.custom_node_render,expander_style:this.options.view.expander_style};this.data=new c(this),this.layout=new p(this,e),this.view=new f(this,t),this.shortcut=new m(this,this.options.shortcut),this.data.init(),this.layout.init(),this.view.init(),this.shortcut.init(),this._event_bind(),this.pluginManager.initNormalPlugins()}}get_editable(){return this.options.editable}enable_edit(){this.options.editable=!0}disable_edit(){this.options.editable=!1}get_view_draggable(){return this.options.view.draggable}enable_view_draggable(){this.options.view.draggable=!0,this.view.setup_canvas_draggable(!0)}disable_view_draggable(){this.options.view.draggable=!1,this.view.setup_canvas_draggable(!1)}enable_event_handle(e){this.options.default_event_handle["enable_"+e+"_handle"]=!0}disable_event_handle(e){this.options.default_event_handle["enable_"+e+"_handle"]=!1}set_theme(e){var t=this.options.theme;this.options.theme=e||null,t!=this.options.theme&&(this.view.reset_theme(),this.view.reset_custom_style())}_event_bind(){this.view.add_event(this,"mousedown",this.mousedown_handle),this.view.add_event(this,"click",this.click_handle),this.view.add_event(this,"dblclick",this.dblclick_handle),this.view.add_event(this,"wheel",this.mousewheel_handle,!0)}mousedown_handle(e){if(this.options.default_event_handle.enable_mousedown_handle){var t=e.target||event.srcElement,i=this.view.get_binded_nodeid(t);i?this.view.is_node(t)&&this.select_node(i):this.select_clear()}}click_handle(e){if(this.options.default_event_handle.enable_click_handle){var t=e.target||event.srcElement;if(this.view.is_expander(t)){var i=this.view.get_binded_nodeid(t);i&&this.toggle_node(i)}}}dblclick_handle(e){if(this.options.default_event_handle.enable_dblclick_handle&&this.get_editable()){var t=e.target||event.srcElement;if(this.view.is_node(t)){var i=this.view.get_binded_nodeid(t);i&&this.begin_edit(i)}}}mousewheel_handle(e){var t=(e.metaKey<<13)+(e.ctrlKey<<12)+(e.altKey<<11)+(e.shiftKey<<10);if(this.options.default_event_handle.enable_mousewheel_handle&&this.options.view.zoom.mask_key===t){var i=e||event;i.preventDefault(),i.deltaY<0?this.view.zoom_in(i):this.view.zoom_out(i)}}begin_edit(e){if(!l.is_node(e)){var t=this.get_node(e);return t?this.begin_edit(t):(s.error("the node[id="+e+"] can not be found."),!1)}this.get_editable()?this.view.edit_node_begin(e):s.error("fail, this mind map is not editable.")}end_edit(){this.view.edit_node_end()}toggle_node(e){if(!l.is_node(e)){var t=this.get_node(e);return t?void this.toggle_node(t):void s.error("the node[id="+e+"] can not be found.")}e.isroot||(this.view.save_location(e),this.layout.toggle_node(e),this.view.relayout(),this.view.restore_location(e))}expand_node(e){if(!l.is_node(e)){var t=this.get_node(e);return t?void this.expand_node(t):void s.error("the node[id="+e+"] can not be found.")}e.isroot||(this.view.save_location(e),this.layout.expand_node(e),this.view.relayout(),this.view.restore_location(e))}collapse_node(e){if(!l.is_node(e)){var t=this.get_node(e);return t?void this.collapse_node(t):void s.error("the node[id="+e+"] can not be found.")}e.isroot||(this.view.save_location(e),this.layout.collapse_node(e),this.view.relayout(),this.view.restore_location(e))}expand_all(){this.layout.expand_all(),this.view.relayout()}collapse_all(){this.layout.collapse_all(),this.view.relayout()}expand_to_depth(e){this.layout.expand_to_depth(e),this.view.relayout()}_reset(){this.invoke_event_handle(i.reset,{data:[]}),this.view.reset(),this.layout.reset(),this.data.reset()}_show(e,t){var n=e||u.node_array.example;this.mind=this.data.load(n),this.mind?(s.debug("data.load ok"),this.view.load(),s.debug("view.load ok"),this.layout.layout(),s.debug("layout.layout ok"),this.view.show(!t),s.debug("view.show ok"),this.invoke_event_handle(i.show,{data:[e]})):s.error("data.load error")}show(e,t){this._reset(),this._show(e,t)}get_meta(){return{name:this.mind.name,author:this.mind.author,version:this.mind.version}}get_data(e){var t=e||"node_tree";return this.data.get_data(t)}get_root(){return this.mind.root}get_node(e){return l.is_node(e)?e:this.mind.get_node(e)}get_node_level(e){var t=this.get_node(e);if(!t)return s.warn("the node[id="+e+"] can not be found."),-1;if(t.isroot)return 0;for(var i=0,n=t;n.parent&&!n.parent.isroot;)i++,n=n.parent;return i+1}_add_node_data(e,i,n,o,s){var r=t.of(s);void 0===r&&(r=this.layout.calculate_next_child_direction(e));var a=this.mind.add_node(e,i,n,o,r);return a&&(this.view.add_node(a),this.view.reset_node_custom_style(a)),a}_refresh_node_ui(e){this.layout.layout(),this.view.show(!1),this.expand_node(e)}add_node(e,n,o,r,a){if(!this.get_editable())return s.error("fail, this mind map is not editable"),null;var d=this.get_node(e);if(!d)return s.error("parent node not found"),null;var l=this._add_node_data(d,n,o,r,a);return l&&(this._refresh_node_ui(d),this.invoke_event_handle(i.edit,{evt:"add_node",data:[d.id,n,o,r,t.of(a)],node:n})),l}add_nodes(e,t){if(!this.get_editable())return s.error("fail, this mind map is not editable"),[];var n=this.get_node(e);if(!n)return s.error("parent node not found"),[];if(!Array.isArray(t)||0===t.length)return s.warn("nodes_data should be a non-empty array"),[];const o=this._count_expected_nodes(t);let r=t.map(e=>this._add_nodes_recursive(n,e)).flat().filter(e=>null!==e);const a=r.length;return a===o?(this._refresh_node_ui(n),this.invoke_event_handle(i.edit,{evt:"add_nodes",data:[n.id,t],nodes:r.map(e=>e.id)}),r):(s.warn(`Expected ${o} nodes, but only created ${a}. Cleaning up...`),this._cleanup_partial_nodes(r),[])}_add_nodes_recursive(e,t){var i=[];if(!t.id||!t.topic)return s.warn("invalid node data:",t),[];var n=this._add_node_data(e,t.id,t.topic,t.data||{},t.direction);if(n&&(i.push(n),Array.isArray(t.children))){const e=t.children.map(e=>this._add_nodes_recursive(n,e)).flat();i=i.concat(e)}return i}_count_expected_nodes(e){if(!Array.isArray(e))return 0;var t=(this.options.fieldNames||{}).children||"children";return e.reduce((e,i)=>(e++,e+=this._count_expected_nodes(i&&i[t])),0)}_cleanup_partial_nodes(e){0!==e.length&&[...e].reverse().forEach(e=>{e&&!e.isroot&&(this.view.remove_node(e),this.mind.remove_node(e))})}insert_node_before(e,n,o,r,a){if(this.get_editable()){var d=this.get_node(e),l=t.of(a);void 0===l&&(l=this.layout.calculate_next_child_direction(d.parent));var h=this.mind.insert_node_before(d,n,o,r,l);return h&&(this.view.add_node(h),this.layout.layout(),this.view.show(!1),this.invoke_event_handle(i.edit,{evt:"insert_node_before",data:[d.id,n,o,r,l],node:n})),h}return s.error("fail, this mind map is not editable"),null}insert_node_after(e,n,o,r,a){if(this.get_editable()){var d=this.get_node(e),l=t.of(a);void 0===l&&(l=this.layout.calculate_next_child_direction(d.parent));var h=this.mind.insert_node_after(d,n,o,r,l);return h&&(this.view.add_node(h),this.layout.layout(),this.view.show(!1),this.invoke_event_handle(i.edit,{evt:"insert_node_after",data:[d.id,n,o,r,l],node:n})),h}return s.error("fail, this mind map is not editable"),null}remove_node(e){if(!l.is_node(e)){var t=this.get_node(e);return t?this.remove_node(t):(s.error("the node[id="+e+"] can not be found."),!1)}if(this.get_editable()){if(e.isroot)return s.error("fail, can not remove root node"),!1;var n=e.id,o=e.parent.id,r=this.get_node(o);return this.view.save_location(r),this.view.remove_node(e),this.mind.remove_node(e),this.layout.layout(),this.view.show(!1),this.view.restore_location(r),this.invoke_event_handle(i.edit,{evt:"remove_node",data:[n],node:o}),!0}return s.error("fail, this mind map is not editable"),!1}update_node(e,t){if(this.get_editable()){var n=this.get_node(e);if(n){if("string"==typeof t)return a.text.is_empty(t)?void s.warn("fail, topic can not be empty"):n.topic===t?(s.info("nothing changed"),void this.view.update_node(n)):(n.topic=t,this.view.update_node(n),this.layout.layout(),this.view.show(!1),void this.invoke_event_handle(i.edit,{evt:"update_node",data:[e,t],node:e}));if("object"==typeof t&&null!==t){var o=n.id,r=!1;if(void 0!==t.topic){if(a.text.is_empty(t.topic))return void s.warn("fail, topic can not be empty");n.topic!==t.topic&&(n.topic=t.topic,r=!0)}if(t.data&&"object"==typeof t.data)for(var d in t.data)t.data.hasOwnProperty(d)&&n.data[d]!==t.data[d]&&(n.data[d]=t.data[d],r=!0);if(void 0!==t.id){if("string"!=typeof t.id||""===t.id.trim())return void s.error("fail, new node id must be a non-empty string");if(n.id!==t.id){if(n.isroot)return void s.error("fail, cannot change root node id");if(t.id in this.mind.nodes)return void s.error('fail, new id "'+t.id+'" already exists');var l=n.id;delete this.mind.nodes[l],n.id=t.id,this.mind.nodes[t.id]=n,this.mind.selected&&this.mind.selected.id===l&&(this.mind.selected=n),r=!0}}if(["index","expanded","direction"].forEach(function(e){void 0!==t[e]&&n[e]!==t[e]&&(n[e]=t[e],r=!0)}),!r)return s.info("nothing changed"),void this.view.update_node(n);this.view.update_node(n),this.layout.layout(),this.view.show(!1),this.invoke_event_handle(i.edit,{evt:"update_node",data:[o,t],node:o})}}else s.error("fail, node not found")}else s.error("fail, this mind map is not editable")}move_node(e,t,n,o){if(this.get_editable()){var r=this.get_node(e),a=this.mind.move_node(r,t,n,o);a&&(this.view.update_node(a),this.layout.layout(),this.view.show(!1),this.invoke_event_handle(i.edit,{evt:"move_node",data:[e,t,n,o],node:e}))}else s.error("fail, this mind map is not editable")}select_node(e){if(!l.is_node(e)){var t=this.get_node(e);return t?void this.select_node(t):void s.error("the node[id="+e+"] can not be found.")}this.layout.is_visible(e)&&(this.mind.selected=e,this.view.select_node(e),this.invoke_event_handle(i.select,{evt:"select_node",data:[],node:e.id}))}get_selected_node(){return this.mind?this.mind.selected:null}select_clear(){this.mind&&(this.mind.selected=null,this.view.select_clear())}is_node_visible(e){return this.layout.is_visible(e)}scroll_node_to_center(e){if(l.is_node(e))this.view.center_node(e);else{var t=this.get_node(e);t?this.scroll_node_to_center(t):s.error("the node[id="+e+"] can not be found.")}}find_node_before(e){if(!l.is_node(e)){var t=this.get_node(e);return t?this.find_node_before(t):void s.error("the node[id="+e+"] can not be found.")}if(e.isroot)return null;var i=null;if(e.parent.isroot)for(var n=e.parent.children,o=null,r=null,a=0;a<n.length;a++)r=n[a],e.direction===r.direction&&(e.id===r.id&&(i=o),o=r);else i=this.mind.get_node_before(e);return i}find_node_after(e){if(!l.is_node(e)){var t=this.get_node(e);return t?this.find_node_after(t):void s.error("the node[id="+e+"] can not be found.")}if(e.isroot)return null;var i=null;if(e.parent.isroot){for(var n=e.parent.children,o=!1,r=null,a=0;a<n.length;a++)if(r=n[a],e.direction===r.direction){if(o){i=r;break}e.id===r.id&&(o=!0)}}else i=this.mind.get_node_after(e);return i}set_node_color(e,t,i){if(!this.get_editable())return s.error("fail, this mind map is not editable"),null;var n=this.mind.get_node(e);n&&(t&&(n.data["background-color"]=t),i&&(n.data["foreground-color"]=i),this.view.reset_node_custom_style(n))}set_node_font_style(e,t,i,n){if(!this.get_editable())return s.error("fail, this mind map is not editable"),null;var o=this.mind.get_node(e);o&&(t&&(o.data["font-size"]=t),i&&(o.data["font-weight"]=i),n&&(o.data["font-style"]=n),this.view.reset_node_custom_style(o),this.view.update_node(o),this.layout.layout(),this.view.show(!1))}set_node_background_image(e,t,i,n,o){if(!this.get_editable())return s.error("fail, this mind map is not editable"),null;var r=this.mind.get_node(e);r&&(t&&(r.data["background-image"]=t),i&&(r.data.width=i),n&&(r.data.height=n),o&&(r.data["background-rotation"]=o),this.view.reset_node_custom_style(r),this.view.update_node(r),this.layout.layout(),this.view.show(!1))}set_node_background_rotation(e,t){if(!this.get_editable())return s.error("fail, this mind map is not editable"),null;var i=this.mind.get_node(e);if(i){if(!i.data["background-image"])return s.error("fail, only can change rotation angle of node with background image"),null;i.data["background-rotation"]=t,this.view.reset_node_custom_style(i),this.view.update_node(i),this.layout.layout(),this.view.show(!1)}}resize(){this.view.resize()}add_event_listener(e){"function"==typeof e&&this.event_handles.push(e)}clear_event_listener(){this.event_handles=[]}invoke_event_handle(e,t){var i=this;r.w.setTimeout(function(){i._invoke_event_handle(e,t)},0)}_invoke_event_handle(e,t){for(var i=this.event_handles.length,n=0;n<i;n++)this.event_handles[n](e,t)}removePlugin(e){this.pluginManager&&this.pluginManager.removePlugin(e)}getPlugin(e){if(this.pluginManager)return this.pluginManager.getPlugin(e)}destroy(){this.pluginManager&&this.pluginManager.destroyAllPlugins(),this.clear_event_listener(),this.view&&this.view.reset(),this.mind=null,this.initialized=!1}static show(e,t){s.warn("`jsMind.show(options, mind)` is deprecated, please use `jm = new jsMind(options); jm.show(mind);` instead");var i=new b(e);return i.show(t),i}}return b});
2626
9
  //# sourceMappingURL=jsmind.js.map