jsmind 0.8.7 → 0.8.8-patch

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 (56) hide show
  1. package/README.md +2 -2
  2. package/es6/jsmind.draggable-node.js +1 -1
  3. package/es6/jsmind.draggable-node.js.map +1 -1
  4. package/es6/jsmind.js +1 -1
  5. package/es6/jsmind.js.map +1 -1
  6. package/es6/jsmind.screenshot.js +1 -1
  7. package/es6/jsmind.screenshot.js.map +1 -1
  8. package/package.json +32 -7
  9. package/types/generated/index.d.ts +8 -0
  10. package/types/generated/jsmind.common.d.ts +66 -0
  11. package/types/generated/jsmind.d.ts +314 -0
  12. package/types/generated/jsmind.data_provider.d.ts +56 -0
  13. package/types/generated/jsmind.dom.d.ts +59 -0
  14. package/types/generated/jsmind.format.d.ts +100 -0
  15. package/types/generated/jsmind.graph.d.ts +180 -0
  16. package/types/generated/jsmind.layout_provider.d.ts +182 -0
  17. package/types/generated/jsmind.mind.d.ts +121 -0
  18. package/types/generated/jsmind.node.d.ts +62 -0
  19. package/types/generated/jsmind.option.d.ts +64 -0
  20. package/types/generated/jsmind.plugin.d.ts +21 -0
  21. package/types/generated/jsmind.shortcut_provider.d.ts +52 -0
  22. package/types/generated/jsmind.util.d.ts +26 -0
  23. package/types/generated/jsmind.view_provider.d.ts +347 -0
  24. package/types/generated/plugins/jsmind.draggable-node.d.ts +229 -0
  25. package/types/generated/plugins/jsmind.screenshot.d.ts +83 -0
  26. package/types/tsconfig.declaration.json +19 -0
  27. package/docs/en/1.usage.md +0 -243
  28. package/docs/en/2.options.md +0 -265
  29. package/docs/en/3.operation.md +0 -156
  30. package/docs/en/4.contribution.md +0 -40
  31. package/docs/en/5.development.md +0 -88
  32. package/docs/en/experimental-features.md +0 -27
  33. package/docs/en/index.md +0 -32
  34. package/docs/en/plugin-screenshot.md +0 -72
  35. package/docs/index.md +0 -19
  36. package/docs/zh/1.usage.md +0 -273
  37. package/docs/zh/2.options.md +0 -270
  38. package/docs/zh/3.operation.md +0 -159
  39. package/docs/zh/4.contribution.md +0 -43
  40. package/docs/zh/5.development.md +0 -81
  41. package/docs/zh/experimental-features.md +0 -27
  42. package/docs/zh/index.md +0 -32
  43. package/docs/zh/plugin-screenshot.md +0 -74
  44. package/example/1_basic.html +0 -77
  45. package/example/1_basic_cn.html +0 -77
  46. package/example/2_features.html +0 -211
  47. package/example/2_features.js +0 -462
  48. package/example/2_features_cn.html +0 -218
  49. package/example/3_requirejs.html +0 -59
  50. package/example/ant.png +0 -0
  51. package/example/data_example.json +0 -95
  52. package/example/demo.html +0 -107
  53. package/js/README.md +0 -7
  54. package/js-legacy/jsmind.draggable-node.js +0 -389
  55. package/js-legacy/jsmind.js +0 -3128
  56. package/js-legacy/jsmind.screenshot.js +0 -351
@@ -1,389 +0,0 @@
1
- /**
2
- * @license BSD
3
- * @copyright 2014-2025 hizzgdev@163.com
4
- *
5
- * Project Home:
6
- * https://github.com/hizzgdev/jsmind/
7
- */
8
-
9
- (function ($w) {
10
- 'use strict';
11
- console.warn("The version is outdated. see details: https://hizzgdev.github.io/jsmind/es6/")
12
- var $d = $w.document;
13
- var __name__ = 'jsMind';
14
- var jsMind = $w[__name__];
15
- if (!jsMind) { return; }
16
- if (typeof jsMind.draggable != 'undefined') { return; }
17
-
18
- var jdom = jsMind.util.dom;
19
- var clear_selection = 'getSelection' in $w ? function () {
20
- $w.getSelection().removeAllRanges();
21
- } : function () {
22
- $d.selection.empty();
23
- };
24
-
25
- var options = {
26
- line_width: 5,
27
- line_color: 'rgba(0,0,0,0.3)',
28
- lookup_delay: 500,
29
- lookup_interval: 80,
30
- scrolling_trigger_width: 20,
31
- scrolling_step_length: 10
32
- };
33
-
34
- jsMind.draggable = function (jm) {
35
- this.jm = jm;
36
- this.e_canvas = null;
37
- this.canvas_ctx = null;
38
- this.shadow = null;
39
- this.shadow_w = 0;
40
- this.shadow_h = 0;
41
- this.active_node = null;
42
- this.target_node = null;
43
- this.target_direct = null;
44
- this.client_w = 0;
45
- this.client_h = 0;
46
- this.offset_x = 0;
47
- this.offset_y = 0;
48
- this.hlookup_delay = 0;
49
- this.hlookup_timer = 0;
50
- this.capture = false;
51
- this.moved = false;
52
- this.view_panel = jm.view.e_panel;
53
- this.view_panel_rect = null
54
- };
55
-
56
- jsMind.draggable.prototype = {
57
- init: function () {
58
- this._create_canvas();
59
- this._create_shadow();
60
- this._event_bind();
61
- },
62
-
63
- resize: function () {
64
- this.jm.view.e_nodes.appendChild(this.shadow);
65
- this.e_canvas.width = this.jm.view.size.w;
66
- this.e_canvas.height = this.jm.view.size.h;
67
- },
68
-
69
- _create_canvas: function () {
70
- var c = $d.createElement('canvas');
71
- this.jm.view.e_panel.appendChild(c);
72
- var ctx = c.getContext('2d');
73
- this.e_canvas = c;
74
- this.canvas_ctx = ctx;
75
- },
76
-
77
- _create_shadow: function () {
78
- var s = $d.createElement('jmnode');
79
- s.style.visibility = 'hidden';
80
- s.style.zIndex = '3';
81
- s.style.cursor = 'move';
82
- s.style.opacity = '0.7';
83
- this.shadow = s;
84
- },
85
-
86
- reset_shadow: function (el) {
87
- var s = this.shadow.style;
88
- this.shadow.innerHTML = el.innerHTML;
89
- s.left = el.style.left;
90
- s.top = el.style.top;
91
- s.width = el.style.width;
92
- s.height = el.style.height;
93
- s.backgroundImage = el.style.backgroundImage;
94
- s.backgroundSize = el.style.backgroundSize;
95
- s.transform = el.style.transform;
96
- this.shadow_w = this.shadow.clientWidth;
97
- this.shadow_h = this.shadow.clientHeight;
98
-
99
- },
100
-
101
- show_shadow: function () {
102
- if (!this.moved) {
103
- this.shadow.style.visibility = 'visible';
104
- }
105
- },
106
-
107
- hide_shadow: function () {
108
- this.shadow.style.visibility = 'hidden';
109
- },
110
-
111
- _magnet_shadow: function (node) {
112
- if (!!node) {
113
- this.canvas_ctx.lineWidth = options.line_width;
114
- this.canvas_ctx.strokeStyle = options.line_color;
115
- this.canvas_ctx.lineCap = 'round';
116
- this._clear_lines();
117
- this._canvas_lineto(node.sp.x, node.sp.y, node.np.x, node.np.y);
118
- }
119
- },
120
-
121
- _clear_lines: function () {
122
- this.canvas_ctx.clearRect(0, 0, this.jm.view.size.w, this.jm.view.size.h);
123
- },
124
-
125
- _canvas_lineto: function (x1, y1, x2, y2) {
126
- this.canvas_ctx.beginPath();
127
- this.canvas_ctx.moveTo(x1, y1);
128
- this.canvas_ctx.lineTo(x2, y2);
129
- this.canvas_ctx.stroke();
130
- },
131
-
132
- _lookup_close_node: function () {
133
- var root = this.jm.get_root();
134
- var root_location = root.get_location();
135
- var root_size = root.get_size();
136
- var root_x = root_location.x + root_size.w / 2;
137
-
138
- var sw = this.shadow_w;
139
- var sh = this.shadow_h;
140
- var sx = this.shadow.offsetLeft;
141
- var sy = this.shadow.offsetTop;
142
-
143
- var ns, nl;
144
-
145
- var direct = (sx + sw / 2) >= root_x ?
146
- jsMind.direction.right : jsMind.direction.left;
147
- var nodes = this.jm.mind.nodes;
148
- var node = null;
149
- var layout = this.jm.layout;
150
- var min_distance = Number.MAX_VALUE;
151
- var distance = 0;
152
- var closest_node = null;
153
- var closest_p = null;
154
- var shadow_p = null;
155
- for (var nodeid in nodes) {
156
- var np, sp;
157
- node = nodes[nodeid];
158
- if (node.isroot || node.direction == direct) {
159
- if (node.id == this.active_node.id) {
160
- continue;
161
- }
162
- if (!layout.is_visible(node)) {
163
- continue;
164
- }
165
- ns = node.get_size();
166
- nl = node.get_location();
167
- if (direct == jsMind.direction.right) {
168
- if (sx - nl.x - ns.w <= 0) { continue; }
169
- distance = Math.abs(sx - nl.x - ns.w) + Math.abs(sy + sh / 2 - nl.y - ns.h / 2);
170
- np = { x: nl.x + ns.w - options.line_width, y: nl.y + ns.h / 2 };
171
- sp = { x: sx + options.line_width, y: sy + sh / 2 };
172
- } else {
173
- if (nl.x - sx - sw <= 0) { continue; }
174
- distance = Math.abs(sx + sw - nl.x) + Math.abs(sy + sh / 2 - nl.y - ns.h / 2);
175
- np = { x: nl.x + options.line_width, y: nl.y + ns.h / 2 };
176
- sp = { x: sx + sw - options.line_width, y: sy + sh / 2 };
177
- }
178
- if (distance < min_distance) {
179
- closest_node = node;
180
- closest_p = np;
181
- shadow_p = sp;
182
- min_distance = distance;
183
- }
184
- }
185
- }
186
- var result_node = null;
187
- if (!!closest_node) {
188
- result_node = {
189
- node: closest_node,
190
- direction: direct,
191
- sp: shadow_p,
192
- np: closest_p
193
- };
194
- }
195
- return result_node;
196
- },
197
-
198
- lookup_close_node: function () {
199
- var node_data = this._lookup_close_node();
200
- if (!!node_data) {
201
- this._magnet_shadow(node_data);
202
- this.target_node = node_data.node;
203
- this.target_direct = node_data.direction;
204
- }
205
- },
206
-
207
- _event_bind: function () {
208
- var jd = this;
209
- var container = this.jm.view.container;
210
- jdom.add_event(container, 'mousedown', function (e) {
211
- var evt = e || event;
212
- jd.dragstart.call(jd, evt);
213
- });
214
- jdom.add_event(container, 'mousemove', function (e) {
215
- var evt = e || event;
216
- jd.drag.call(jd, evt);
217
- });
218
- jdom.add_event(container, 'mouseup', function (e) {
219
- var evt = e || event;
220
- jd.dragend.call(jd, evt);
221
- });
222
- jdom.add_event(container, 'touchstart', function (e) {
223
- var evt = e || event;
224
- jd.dragstart.call(jd, evt);
225
- });
226
- jdom.add_event(container, 'touchmove', function (e) {
227
- var evt = e || event;
228
- jd.drag.call(jd, evt);
229
- });
230
- jdom.add_event(container, 'touchend', function (e) {
231
- var evt = e || event;
232
- jd.dragend.call(jd, evt);
233
- });
234
- },
235
-
236
- dragstart: function (e) {
237
- if (!this.jm.get_editable()) { return; }
238
- if (this.capture) { return; }
239
- this.active_node = null;
240
-
241
- var jview = this.jm.view;
242
- var el = e.target || event.srcElement;
243
- if (el.tagName.toLowerCase() != 'jmnode') { return; }
244
- if (jview.get_draggable_canvas()) { jview.disable_draggable_canvas() }
245
- var nodeid = jview.get_binded_nodeid(el);
246
- if (!!nodeid) {
247
- var node = this.jm.get_node(nodeid);
248
- if (!node.isroot) {
249
- this.reset_shadow(el);
250
- this.view_panel_rect = this.view_panel.getBoundingClientRect()
251
- this.active_node = node;
252
- this.offset_x = (e.clientX || e.touches[0].clientX) / jview.actualZoom - el.offsetLeft;
253
- this.offset_y = (e.clientY || e.touches[0].clientY) / jview.actualZoom - el.offsetTop;
254
- this.client_hw = Math.floor(el.clientWidth / 2);
255
- this.client_hh = Math.floor(el.clientHeight / 2);
256
- if (this.hlookup_delay != 0) {
257
- $w.clearTimeout(this.hlookup_delay);
258
- }
259
- if (this.hlookup_timer != 0) {
260
- $w.clearInterval(this.hlookup_timer);
261
- }
262
- var jd = this;
263
- this.hlookup_delay = $w.setTimeout(function () {
264
- jd.hlookup_delay = 0;
265
- jd.hlookup_timer = $w.setInterval(function () {
266
- jd.lookup_close_node.call(jd);
267
- }, options.lookup_interval);
268
- }, options.lookup_delay);
269
- this.capture = true;
270
- }
271
- }
272
- },
273
-
274
- drag: function (e) {
275
- if (!this.jm.get_editable()) { return; }
276
- if (this.capture) {
277
- e.preventDefault();
278
- this.show_shadow();
279
- this.moved = true;
280
- clear_selection();
281
- var jview = this.jm.view;
282
- var px = (e.clientX || e.touches[0].clientX) / jview.actualZoom - this.offset_x;
283
- var py = (e.clientY || e.touches[0].clientY) / jview.actualZoom - this.offset_y;
284
- // scrolling container axisY if drag nodes exceeding container
285
- if (
286
- e.clientY - this.view_panel_rect.top < options.scrolling_trigger_width &&
287
- this.view_panel.scrollTop > options.scrolling_step_length
288
- ) {
289
- this.view_panel.scrollBy(0, -options.scrolling_step_length);
290
- this.offset_y += options.scrolling_step_length / jview.actualZoom;
291
- } else if (
292
- this.view_panel_rect.bottom - e.clientY < options.scrolling_trigger_width &&
293
- this.view_panel.scrollTop <
294
- this.view_panel.scrollHeight - this.view_panel_rect.height - options.scrolling_step_length
295
- ) {
296
- this.view_panel.scrollBy(0, options.scrolling_step_length);
297
- this.offset_y -= options.scrolling_step_length / jview.actualZoom;
298
- }
299
- // scrolling container axisX if drag nodes exceeding container
300
- if (e.clientX - this.view_panel_rect.left < options.scrolling_trigger_width && this.view_panel.scrollLeft > options.scrolling_step_length) {
301
- this.view_panel.scrollBy(-options.scrolling_step_length, 0);
302
- this.offset_x += options.scrolling_step_length / jview.actualZoom;
303
- } else if (
304
- this.view_panel_rect.right - e.clientX < options.scrolling_trigger_width &&
305
- this.view_panel.scrollLeft < this.view_panel.scrollWidth - this.view_panel_rect.width - options.scrolling_step_length
306
- ) {
307
- this.view_panel.scrollBy(options.scrolling_step_length, 0);
308
- this.offset_x -= options.scrolling_step_length / jview.actualZoom;
309
- }
310
- this.shadow.style.left = px + 'px';
311
- this.shadow.style.top = py + 'px';
312
- clear_selection();
313
- }
314
- },
315
-
316
- dragend: function (e) {
317
- if (!this.jm.get_editable()) { return; }
318
- if (this.jm.view.get_draggable_canvas()) { this.jm.view.enable_draggable_canvas() }
319
- if (this.capture) {
320
- if (this.hlookup_delay != 0) {
321
- $w.clearTimeout(this.hlookup_delay);
322
- this.hlookup_delay = 0;
323
- this._clear_lines();
324
- }
325
- if (this.hlookup_timer != 0) {
326
- $w.clearInterval(this.hlookup_timer);
327
- this.hlookup_timer = 0;
328
- this._clear_lines();
329
- }
330
- if (this.moved) {
331
- var src_node = this.active_node;
332
- var target_node = this.target_node;
333
- var target_direct = this.target_direct;
334
- this.move_node(src_node, target_node, target_direct);
335
- }
336
- this.hide_shadow();
337
- }
338
- this.view_panel_rect = null
339
- this.moved = false;
340
- this.capture = false;
341
- },
342
-
343
- move_node: function (src_node, target_node, target_direct) {
344
- var shadow_h = this.shadow.offsetTop;
345
- if (!!target_node && !!src_node && !jsMind.node.inherited(src_node, target_node)) {
346
- // lookup before_node
347
- var sibling_nodes = target_node.children;
348
- var sc = sibling_nodes.length;
349
- var node = null;
350
- var delta_y = Number.MAX_VALUE;
351
- var node_before = null;
352
- var beforeid = '_last_';
353
- while (sc--) {
354
- node = sibling_nodes[sc];
355
- if (node.direction == target_direct && node.id != src_node.id) {
356
- var dy = node.get_location().y - shadow_h;
357
- if (dy > 0 && dy < delta_y) {
358
- delta_y = dy;
359
- node_before = node;
360
- beforeid = '_first_';
361
- }
362
- }
363
- }
364
- if (!!node_before) { beforeid = node_before.id; }
365
- this.jm.move_node(src_node.id, beforeid, target_node.id, target_direct);
366
- }
367
- this.active_node = null;
368
- this.target_node = null;
369
- this.target_direct = null;
370
- },
371
-
372
- jm_event_handle: function (type, data) {
373
- if (type === jsMind.event_type.resize) {
374
- this.resize();
375
- }
376
- }
377
- };
378
-
379
- var draggable_plugin = new jsMind.plugin('draggable', function (jm) {
380
- var jd = new jsMind.draggable(jm);
381
- jd.init();
382
- jm.add_event_listener(function (type, data) {
383
- jd.jm_event_handle.call(jd, type, data);
384
- });
385
- });
386
-
387
- jsMind.register_plugin(draggable_plugin);
388
-
389
- })(window);