@umbraci/jsmind 0.10.17 → 0.10.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jsmind.copy-paste.js +281 -7
- package/dist/jsmind.draggable-node.js +472 -7
- package/dist/jsmind.history.js +980 -7
- package/dist/jsmind.history.js.map +1 -1
- package/dist/jsmind.js +2624 -7
- package/dist/jsmind.multi-select.js +671 -7
- package/dist/jsmind.multiline-text.js +156 -7
- package/dist/jsmind.screenshot.js +156 -7
- package/es/jsmind.copy-paste.js +258 -7
- package/es/jsmind.draggable-node.js +443 -7
- package/es/jsmind.history.js +944 -7
- package/es/jsmind.history.js.map +1 -1
- package/es/jsmind.js +2570 -7
- package/es/jsmind.multi-select.js +621 -7
- package/es/jsmind.multiline-text.js +136 -7
- package/es/jsmind.screenshot.js +136 -7
- package/lib/jsmind.copy-paste.js +262 -7
- package/lib/jsmind.draggable-node.js +450 -7
- package/lib/jsmind.history.js +946 -7
- package/lib/jsmind.history.js.map +1 -1
- package/lib/jsmind.js +2571 -7
- package/lib/jsmind.multi-select.js +623 -7
- package/lib/jsmind.multiline-text.js +141 -7
- package/lib/jsmind.screenshot.js +145 -7
- package/package.json +1 -1
|
@@ -1,9 +1,283 @@
|
|
|
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
|
-
!
|
|
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
|
+
? t(exports, require('@umbraci/jsmind'))
|
|
11
|
+
: 'function' == typeof define && define.amd
|
|
12
|
+
? define(['exports', '@umbraci/jsmind'], t)
|
|
13
|
+
: t(
|
|
14
|
+
((e = 'undefined' != typeof globalThis ? globalThis : e || self).jsMindCopyPaste =
|
|
15
|
+
{}),
|
|
16
|
+
e.jsMind
|
|
17
|
+
);
|
|
18
|
+
})(this, function (e, t) {
|
|
19
|
+
'use strict';
|
|
20
|
+
function i(e) {
|
|
21
|
+
return e && 'object' == typeof e && 'default' in e ? e : { default: e };
|
|
22
|
+
}
|
|
23
|
+
var n = i(t);
|
|
24
|
+
const o = new (class {
|
|
25
|
+
constructor(e) {
|
|
26
|
+
(this.w = e),
|
|
27
|
+
(this.d = e.document),
|
|
28
|
+
(this.g = function (e) {
|
|
29
|
+
return this.d.getElementById(e);
|
|
30
|
+
}),
|
|
31
|
+
(this.c = function (e) {
|
|
32
|
+
return this.d.createElement(e);
|
|
33
|
+
}),
|
|
34
|
+
(this.t = function (e, t) {
|
|
35
|
+
e.hasChildNodes()
|
|
36
|
+
? (e.firstChild.nodeValue = t)
|
|
37
|
+
: e.appendChild(this.d.createTextNode(t));
|
|
38
|
+
}),
|
|
39
|
+
(this.h = function (e, t) {
|
|
40
|
+
t instanceof HTMLElement
|
|
41
|
+
? ((e.innerHTML = ''), e.appendChild(t))
|
|
42
|
+
: (e.innerHTML = t);
|
|
43
|
+
}),
|
|
44
|
+
(this.i = function (e) {
|
|
45
|
+
return (
|
|
46
|
+
!!e &&
|
|
47
|
+
'object' == typeof e &&
|
|
48
|
+
1 === e.nodeType &&
|
|
49
|
+
'object' == typeof e.style &&
|
|
50
|
+
'object' == typeof e.ownerDocument
|
|
51
|
+
);
|
|
52
|
+
}),
|
|
53
|
+
(this.on = function (e, t, i) {
|
|
54
|
+
e.addEventListener
|
|
55
|
+
? e.addEventListener(t, i, !1)
|
|
56
|
+
: e.attachEvent('on' + t, i);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
})(window),
|
|
60
|
+
a = {
|
|
61
|
+
file: {
|
|
62
|
+
read: function (e, t) {
|
|
63
|
+
var i = new FileReader();
|
|
64
|
+
(i.onload = function () {
|
|
65
|
+
'function' == typeof t && t(this.result, e.name);
|
|
66
|
+
}),
|
|
67
|
+
i.readAsText(e);
|
|
68
|
+
},
|
|
69
|
+
save: function (e, t, i) {
|
|
70
|
+
var n;
|
|
71
|
+
if ('function' == typeof o.w.Blob) n = new Blob([e], { type: t });
|
|
72
|
+
else {
|
|
73
|
+
var a = new (o.w.BlobBuilder ||
|
|
74
|
+
o.w.MozBlobBuilder ||
|
|
75
|
+
o.w.WebKitBlobBuilder ||
|
|
76
|
+
o.w.MSBlobBuilder)();
|
|
77
|
+
a.append(e), (n = a.getBlob(t));
|
|
78
|
+
}
|
|
79
|
+
if (navigator.msSaveBlob) navigator.msSaveBlob(n, i);
|
|
80
|
+
else {
|
|
81
|
+
var r = (o.w.URL || o.w.webkitURL).createObjectURL(n),
|
|
82
|
+
s = o.c('a');
|
|
83
|
+
if ('download' in s) {
|
|
84
|
+
(s.style.visibility = 'hidden'),
|
|
85
|
+
(s.href = r),
|
|
86
|
+
(s.download = i),
|
|
87
|
+
o.d.body.appendChild(s);
|
|
88
|
+
var d = o.d.createEvent('MouseEvents');
|
|
89
|
+
d.initEvent('click', !0, !0),
|
|
90
|
+
s.dispatchEvent(d),
|
|
91
|
+
o.d.body.removeChild(s);
|
|
92
|
+
} else location.href = r;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
json: {
|
|
97
|
+
json2string: function (e) {
|
|
98
|
+
return JSON.stringify(e);
|
|
99
|
+
},
|
|
100
|
+
string2json: function (e) {
|
|
101
|
+
return JSON.parse(e);
|
|
102
|
+
},
|
|
103
|
+
merge: function (e, t) {
|
|
104
|
+
for (var i in t)
|
|
105
|
+
i in e
|
|
106
|
+
? 'object' != typeof e[i] ||
|
|
107
|
+
'[object object]' !=
|
|
108
|
+
Object.prototype.toString.call(e[i]).toLowerCase() ||
|
|
109
|
+
e[i].length
|
|
110
|
+
? (e[i] = t[i])
|
|
111
|
+
: a.json.merge(e[i], t[i])
|
|
112
|
+
: (e[i] = t[i]);
|
|
113
|
+
return e;
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
uuid: {
|
|
117
|
+
newid: function () {
|
|
118
|
+
return (
|
|
119
|
+
new Date().getTime().toString(16) + Math.random().toString(16).substring(2)
|
|
120
|
+
).substring(2, 18);
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
text: {
|
|
124
|
+
is_empty: function (e) {
|
|
125
|
+
return !e || 0 == e.replace(/\s*/, '').length;
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
class r {
|
|
130
|
+
constructor(e, t = {}) {
|
|
131
|
+
(this.jsMind = e),
|
|
132
|
+
(this.options = {
|
|
133
|
+
enabled: !0,
|
|
134
|
+
shortcuts: { copy: 'meta+c', paste: 'meta+v', cut: 'meta+x' },
|
|
135
|
+
...t,
|
|
136
|
+
}),
|
|
137
|
+
(this.clipboardData = null),
|
|
138
|
+
(this.logger = {
|
|
139
|
+
info: e => console.info('[CopyPaste]', e),
|
|
140
|
+
warn: e => console.warn('[CopyPaste]', e),
|
|
141
|
+
error: e => console.error('[CopyPaste]', e),
|
|
142
|
+
debug: e => console.debug('[CopyPaste]', e),
|
|
143
|
+
}),
|
|
144
|
+
this.init();
|
|
145
|
+
}
|
|
146
|
+
init() {
|
|
147
|
+
return this.logger.info('CopyPaste plugin initialized'), !0;
|
|
148
|
+
}
|
|
149
|
+
handleCopy(e) {
|
|
150
|
+
if (!this.options.enabled) return;
|
|
151
|
+
const t = this.jsMind.get_selected_node();
|
|
152
|
+
if (t)
|
|
153
|
+
try {
|
|
154
|
+
e.preventDefault(),
|
|
155
|
+
(this.clipboardData = {
|
|
156
|
+
id: t.id,
|
|
157
|
+
topic: t.topic,
|
|
158
|
+
data: t.data || {},
|
|
159
|
+
direction: t.direction,
|
|
160
|
+
expanded: t.expanded,
|
|
161
|
+
children: this.copyChildren(t),
|
|
162
|
+
}),
|
|
163
|
+
this.logger.info('Node copied:', t.topic),
|
|
164
|
+
this.showMessage('节点已复制');
|
|
165
|
+
} catch (e) {
|
|
166
|
+
this.logger.error('Copy failed:', e), this.showMessage('复制失败', 'error');
|
|
167
|
+
}
|
|
168
|
+
else this.logger.warn('No node selected for copying');
|
|
169
|
+
}
|
|
170
|
+
handlePaste(e) {
|
|
171
|
+
if (!this.options.enabled) return;
|
|
172
|
+
if (!this.clipboardData)
|
|
173
|
+
return (
|
|
174
|
+
this.logger.warn('No data in clipboard'),
|
|
175
|
+
void this.showMessage('剪贴板为空,请先复制节点', 'warning')
|
|
176
|
+
);
|
|
177
|
+
const t = this.jsMind.get_selected_node();
|
|
178
|
+
if (!t)
|
|
179
|
+
return (
|
|
180
|
+
this.logger.warn('No target node selected for pasting'),
|
|
181
|
+
void this.showMessage('请选择目标节点', 'warning')
|
|
182
|
+
);
|
|
183
|
+
try {
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
const i = this.prepareBatchData(this.clipboardData),
|
|
186
|
+
n = this.jsMind.add_nodes(t, [i]);
|
|
187
|
+
n &&
|
|
188
|
+
n.length > 0 &&
|
|
189
|
+
(this.logger.info('Nodes pasted successfully:', this.clipboardData.topic),
|
|
190
|
+
this.showMessage('粘贴成功'));
|
|
191
|
+
} catch (e) {
|
|
192
|
+
this.logger.error('Paste failed:', e), this.showMessage('粘贴失败', 'error');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
handleCut(e) {
|
|
196
|
+
if (!this.options.enabled) return;
|
|
197
|
+
const t = this.jsMind.get_selected_node();
|
|
198
|
+
if (t) {
|
|
199
|
+
if (t.isroot)
|
|
200
|
+
return (
|
|
201
|
+
this.logger.warn('Cannot cut root node'),
|
|
202
|
+
void this.showMessage('不能剪切根节点', 'warning')
|
|
203
|
+
);
|
|
204
|
+
try {
|
|
205
|
+
e.preventDefault(),
|
|
206
|
+
(this.clipboardData = {
|
|
207
|
+
id: t.id,
|
|
208
|
+
topic: t.topic,
|
|
209
|
+
data: t.data || {},
|
|
210
|
+
direction: t.direction,
|
|
211
|
+
expanded: t.expanded,
|
|
212
|
+
children: this.copyChildren(t),
|
|
213
|
+
});
|
|
214
|
+
this.jsMind.remove_node(t) &&
|
|
215
|
+
(this.logger.info('Node cut:', t.topic), this.showMessage('节点已剪切'));
|
|
216
|
+
} catch (e) {
|
|
217
|
+
this.logger.error('Cut failed:', e), this.showMessage('剪切失败', 'error');
|
|
218
|
+
}
|
|
219
|
+
} else this.logger.warn('No node selected for cutting');
|
|
220
|
+
}
|
|
221
|
+
copyChildren(e) {
|
|
222
|
+
return e.children && 0 !== e.children.length
|
|
223
|
+
? e.children.map(e => ({
|
|
224
|
+
id: e.id,
|
|
225
|
+
topic: e.topic,
|
|
226
|
+
data: e.data || {},
|
|
227
|
+
direction: e.direction,
|
|
228
|
+
expanded: e.expanded,
|
|
229
|
+
children: this.copyChildren(e),
|
|
230
|
+
}))
|
|
231
|
+
: [];
|
|
232
|
+
}
|
|
233
|
+
prepareBatchData(e) {
|
|
234
|
+
return {
|
|
235
|
+
id: a.uuid.newid(),
|
|
236
|
+
topic: e.topic,
|
|
237
|
+
data: e.data || {},
|
|
238
|
+
children:
|
|
239
|
+
e.children && e.children.length > 0
|
|
240
|
+
? e.children.map(e => this.prepareBatchData(e))
|
|
241
|
+
: void 0,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
pasteChildren(e, t) {
|
|
245
|
+
if (!t || 0 === t.length) return [];
|
|
246
|
+
const i = t.map(e => this.prepareBatchData(e));
|
|
247
|
+
return this.jsMind.add_nodes(e, i);
|
|
248
|
+
}
|
|
249
|
+
showMessage(e, t = 'info') {
|
|
250
|
+
console.log(`[CopyPaste ${t.toUpperCase()}]: ${e}`);
|
|
251
|
+
}
|
|
252
|
+
clear() {
|
|
253
|
+
(this.clipboardData = null), this.logger.info('Clipboard cleared');
|
|
254
|
+
}
|
|
255
|
+
getStatus() {
|
|
256
|
+
return { hasData: !!this.clipboardData, data: this.clipboardData };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
const s = new n.default.plugin('copy-paste', function (e, t) {
|
|
260
|
+
var i = t || {};
|
|
261
|
+
i.shortcuts = i.shortcuts || { copy: 'meta+c', paste: 'meta+v', cut: 'meta+x' };
|
|
262
|
+
var n = new r(e, i);
|
|
263
|
+
e.view &&
|
|
264
|
+
e.view.e_panel &&
|
|
265
|
+
e.view.e_panel.addEventListener('keydown', function (e) {
|
|
266
|
+
(!e.metaKey && !e.ctrlKey) || 'c' !== e.key || e.shiftKey || e.altKey
|
|
267
|
+
? (!e.metaKey && !e.ctrlKey) || 'v' !== e.key || e.shiftKey || e.altKey
|
|
268
|
+
? (!e.metaKey && !e.ctrlKey) ||
|
|
269
|
+
'x' !== e.key ||
|
|
270
|
+
e.shiftKey ||
|
|
271
|
+
e.altKey ||
|
|
272
|
+
n.handleCut(e)
|
|
273
|
+
: n.handlePaste(e)
|
|
274
|
+
: n.handleCopy(e);
|
|
275
|
+
}),
|
|
276
|
+
(e.copy_paste_handler = n);
|
|
277
|
+
});
|
|
278
|
+
n.default.register_plugin(s),
|
|
279
|
+
(e.copy_paste_plugin = s),
|
|
280
|
+
(e.default = r),
|
|
281
|
+
Object.defineProperty(e, '__esModule', { value: !0 });
|
|
282
|
+
});
|
|
9
283
|
//# sourceMappingURL=jsmind.copy-paste.js.map
|