mind-elixir 4.6.0 → 4.6.1
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/MindElixir.iife.js +6 -6
- package/dist/MindElixir.js +33 -32
- package/dist/MindElixirLite.iife.js +6 -6
- package/dist/MindElixirLite.js +93 -92
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/MindElixirLite.js
CHANGED
|
@@ -103,7 +103,7 @@ const Ne = function() {
|
|
|
103
103
|
for (; t && t !== e; )
|
|
104
104
|
n += t.offsetLeft, o += t.offsetTop, t = t.offsetParent;
|
|
105
105
|
return { offsetLeft: n, offsetTop: o };
|
|
106
|
-
},
|
|
106
|
+
}, x = (e, t) => {
|
|
107
107
|
for (const n in t)
|
|
108
108
|
e.setAttribute(n, t[n]);
|
|
109
109
|
}, he = (e) => e ? e.tagName === "ME-TPC" : !1, k = {
|
|
@@ -234,8 +234,8 @@ const Q = document, De = function() {
|
|
|
234
234
|
n.appendChild(i);
|
|
235
235
|
}
|
|
236
236
|
return n;
|
|
237
|
-
},
|
|
238
|
-
const o = (t ? t.el :
|
|
237
|
+
}, C = document, M = (e, t) => {
|
|
238
|
+
const o = (t ? t.el : C).querySelector(`[data-nodeid=me${e}]`);
|
|
239
239
|
if (!o)
|
|
240
240
|
throw new Error(`FindEle: Node ${e} not found, maybe it's collapsed.`);
|
|
241
241
|
return o;
|
|
@@ -247,32 +247,32 @@ const Q = document, De = function() {
|
|
|
247
247
|
if (t.image) {
|
|
248
248
|
const n = t.image;
|
|
249
249
|
if (n.url && n.width && n.height) {
|
|
250
|
-
const o =
|
|
250
|
+
const o = C.createElement("img");
|
|
251
251
|
o.src = n.url, o.style.width = n.width + "px", o.style.height = n.height + "px", n.fit && (o.style.objectFit = n.fit), e.appendChild(o), e.image = o;
|
|
252
252
|
}
|
|
253
253
|
} else
|
|
254
254
|
e.image && (e.image = void 0);
|
|
255
255
|
{
|
|
256
|
-
const n =
|
|
256
|
+
const n = C.createElement("span");
|
|
257
257
|
n.className = "text", n.textContent = t.topic, e.appendChild(n), e.text = n;
|
|
258
258
|
}
|
|
259
259
|
if (t.hyperLink) {
|
|
260
|
-
const n =
|
|
260
|
+
const n = C.createElement("a");
|
|
261
261
|
n.className = "hyper-link", n.target = "_blank", n.innerText = "🔗", n.href = t.hyperLink, e.appendChild(n), e.link = n;
|
|
262
262
|
} else
|
|
263
263
|
e.link && (e.link = void 0);
|
|
264
264
|
if (t.icons && t.icons.length) {
|
|
265
|
-
const n =
|
|
265
|
+
const n = C.createElement("span");
|
|
266
266
|
n.className = "icons", n.innerHTML = t.icons.map((o) => `<span>${ae(o)}</span>`).join(""), e.appendChild(n), e.icons = n;
|
|
267
267
|
} else
|
|
268
268
|
e.icons && (e.icons = void 0);
|
|
269
269
|
if (t.tags && t.tags.length) {
|
|
270
|
-
const n =
|
|
270
|
+
const n = C.createElement("div");
|
|
271
271
|
n.className = "tags", n.innerHTML = t.tags.map((o) => `<span>${ae(o)}</span>`).join(""), e.appendChild(n), e.tags = n;
|
|
272
272
|
} else
|
|
273
273
|
e.tags && (e.tags = void 0);
|
|
274
274
|
}, ze = function(e, t) {
|
|
275
|
-
const n =
|
|
275
|
+
const n = C.createElement("me-wrapper"), { p: o, tpc: s } = this.createParent(e);
|
|
276
276
|
if (n.appendChild(o), !t && e.children && e.children.length > 0) {
|
|
277
277
|
const i = Ve(e.expanded);
|
|
278
278
|
if (o.appendChild(i), e.expanded !== !1) {
|
|
@@ -282,17 +282,17 @@ const Q = document, De = function() {
|
|
|
282
282
|
}
|
|
283
283
|
return { grp: n, top: o, tpc: s };
|
|
284
284
|
}, Oe = function(e) {
|
|
285
|
-
const t =
|
|
285
|
+
const t = C.createElement("me-parent"), n = this.createTopic(e);
|
|
286
286
|
return _e(n, e), t.appendChild(n), { p: t, tpc: n };
|
|
287
287
|
}, je = function(e) {
|
|
288
|
-
const t =
|
|
288
|
+
const t = C.createElement("me-children");
|
|
289
289
|
return t.append(...e), t;
|
|
290
290
|
}, Re = function(e) {
|
|
291
|
-
const t =
|
|
291
|
+
const t = C.createElement("me-tpc");
|
|
292
292
|
return t.nodeObj = e, t.dataset.nodeid = "me" + e.id, t.draggable = this.draggable, t;
|
|
293
293
|
};
|
|
294
294
|
function Ee(e) {
|
|
295
|
-
const t =
|
|
295
|
+
const t = C.createRange();
|
|
296
296
|
t.selectNodeContents(e);
|
|
297
297
|
const n = window.getSelection();
|
|
298
298
|
n && (n.removeAllRanges(), n.addRange(t));
|
|
@@ -300,7 +300,7 @@ function Ee(e) {
|
|
|
300
300
|
const qe = function(e) {
|
|
301
301
|
if (!e)
|
|
302
302
|
return;
|
|
303
|
-
const t =
|
|
303
|
+
const t = C.createElement("div"), n = e.text.textContent;
|
|
304
304
|
e.appendChild(t), t.id = "input-box", t.textContent = n, t.contentEditable = "plaintext-only", t.spellcheck = !1;
|
|
305
305
|
const o = getComputedStyle(e);
|
|
306
306
|
t.style.cssText = `min-width:${e.offsetWidth - 8}px;
|
|
@@ -332,11 +332,11 @@ const qe = function(e) {
|
|
|
332
332
|
}));
|
|
333
333
|
});
|
|
334
334
|
}, Ve = function(e) {
|
|
335
|
-
const t =
|
|
335
|
+
const t = C.createElement("me-epd");
|
|
336
336
|
return t.expanded = e !== !1, t.className = e !== !1 ? "minus" : "", t;
|
|
337
337
|
}, R = document, F = "http://www.w3.org/2000/svg", Se = function(e, t, n) {
|
|
338
338
|
const o = R.createElementNS(F, "path");
|
|
339
|
-
return
|
|
339
|
+
return x(o, {
|
|
340
340
|
d: e,
|
|
341
341
|
stroke: t || "#666",
|
|
342
342
|
fill: "none",
|
|
@@ -360,7 +360,7 @@ const qe = function(e) {
|
|
|
360
360
|
d: i,
|
|
361
361
|
...o
|
|
362
362
|
};
|
|
363
|
-
|
|
363
|
+
x(l, c), r === 0 && l.setAttribute("stroke-dasharray", "8,2"), s.appendChild(l);
|
|
364
364
|
}), s;
|
|
365
365
|
}, Ce = function(e, t, n) {
|
|
366
366
|
if (!t)
|
|
@@ -394,13 +394,13 @@ const qe = function(e) {
|
|
|
394
394
|
const c = this.map.querySelectorAll("me-main > me-wrapper");
|
|
395
395
|
this.lines.innerHTML = "";
|
|
396
396
|
for (let d = 0; d < c.length; d++) {
|
|
397
|
-
const a = c[d], u = a.querySelector("me-tpc"), { offsetLeft: h, offsetTop: p } = H(this.nodes, u), m = u.offsetWidth, g = u.offsetHeight, f = a.parentNode.className, v = this.generateMainBranch({ pT: n, pL: o, pW: s, pH: i, cT: p, cL: h, cW: m, cH: g, direction: f, containerHeight: this.nodes.offsetHeight }),
|
|
398
|
-
u.style.borderColor =
|
|
397
|
+
const a = c[d], u = a.querySelector("me-tpc"), { offsetLeft: h, offsetTop: p } = H(this.nodes, u), m = u.offsetWidth, g = u.offsetHeight, f = a.parentNode.className, v = this.generateMainBranch({ pT: n, pL: o, pW: s, pH: i, cT: p, cL: h, cW: m, cH: g, direction: f, containerHeight: this.nodes.offsetHeight }), _ = this.theme.palette, y = u.nodeObj.branchColor || _[d % _.length];
|
|
398
|
+
u.style.borderColor = y, this.lines.appendChild(Se(v, y, "3"));
|
|
399
399
|
const E = a.children[0].children[1];
|
|
400
400
|
if (E && (E.style.top = (E.parentNode.offsetHeight - E.offsetHeight) / 2 + "px", f === T.LHS ? E.style.left = "-10px" : E.style.right = "-10px"), e && e !== a)
|
|
401
401
|
continue;
|
|
402
|
-
const
|
|
403
|
-
|
|
402
|
+
const w = W("subLines"), S = a.lastChild;
|
|
403
|
+
S.tagName === "svg" && S.remove(), a.appendChild(w), Le(this, w, y, a, f, !0);
|
|
404
404
|
}
|
|
405
405
|
this.renderArrow(), this.renderSummary(), this.bus.fire("linkDiv");
|
|
406
406
|
}, Le = function(e, t, n, o, s, i) {
|
|
@@ -409,15 +409,15 @@ const qe = function(e) {
|
|
|
409
409
|
return;
|
|
410
410
|
const c = r.offsetTop, d = r.offsetLeft, a = r.offsetWidth, u = r.offsetHeight;
|
|
411
411
|
for (let h = 0; h < l.length; h++) {
|
|
412
|
-
const p = l[h], m = p.firstChild, g = m.offsetTop, f = m.offsetLeft, v = m.offsetWidth,
|
|
413
|
-
t.appendChild(Se(E,
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
416
|
-
if (
|
|
412
|
+
const p = l[h], m = p.firstChild, g = m.offsetTop, f = m.offsetLeft, v = m.offsetWidth, _ = m.offsetHeight, y = m.firstChild.nodeObj.branchColor || n, E = e.generateSubBranch({ pT: c, pL: d, pW: a, pH: u, cT: g, cL: f, cW: v, cH: _, direction: s, isFirst: i });
|
|
413
|
+
t.appendChild(Se(E, y, "2"));
|
|
414
|
+
const w = m.children[1];
|
|
415
|
+
if (w) {
|
|
416
|
+
if (w.style.bottom = -(w.offsetHeight / 2) + "px", s === T.LHS ? w.style.left = "10px" : s === T.RHS && (w.style.right = "10px"), !w.expanded)
|
|
417
417
|
continue;
|
|
418
418
|
} else
|
|
419
419
|
continue;
|
|
420
|
-
Le(e, t,
|
|
420
|
+
Le(e, t, y, p, s);
|
|
421
421
|
}
|
|
422
422
|
};
|
|
423
423
|
const P = (e, t) => {
|
|
@@ -429,13 +429,13 @@ const P = (e, t) => {
|
|
|
429
429
|
function Ie(e) {
|
|
430
430
|
const t = document.createElement("div"), n = P("fullscreen", "full"), o = P("toCenter", "living"), s = P("zoomout", "move"), i = P("zoomin", "add"), r = document.createElement("span");
|
|
431
431
|
return r.innerText = "100%", t.appendChild(n), t.appendChild(o), t.appendChild(s), t.appendChild(i), t.className = "mind-elixir-toolbar rb", n.onclick = () => {
|
|
432
|
-
e.el.requestFullscreen();
|
|
432
|
+
document.fullscreenElement === e.el ? document.exitFullscreen() : e.el.requestFullscreen();
|
|
433
433
|
}, o.onclick = () => {
|
|
434
434
|
e.toCenter();
|
|
435
435
|
}, s.onclick = () => {
|
|
436
|
-
e.scaleVal < 0.6 || e.scale(e.scaleVal -
|
|
436
|
+
e.scaleVal < 0.6 || e.scale(e.scaleVal - e.scaleSensitivity);
|
|
437
437
|
}, i.onclick = () => {
|
|
438
|
-
e.scaleVal > 1.6 || e.scale(e.scaleVal +
|
|
438
|
+
e.scaleVal > 1.6 || e.scale(e.scaleVal + e.scaleSensitivity);
|
|
439
439
|
}, t;
|
|
440
440
|
}
|
|
441
441
|
function Xe(e) {
|
|
@@ -738,8 +738,8 @@ class tt extends Je {
|
|
|
738
738
|
let { x2: g, y2: f } = n;
|
|
739
739
|
const { behaviour: { scrolling: { startScrollMargins: v } } } = i;
|
|
740
740
|
g < h.left + v.x ? (t.x = d ? -D(h.left - g + v.x) : 0, g = g < h.left ? h.left : g) : g > h.right - v.x ? (t.x = a - d - u ? D(h.left + h.width - g - v.x) : 0, g = g > h.right ? h.right : g) : t.x = 0, f < h.top + v.y ? (t.y = r ? -D(h.top - f + v.y) : 0, f = f < h.top ? h.top : f) : f > h.bottom - v.y ? (t.y = l - r - c ? D(h.top + h.height - f - v.y) : 0, f = f > h.bottom ? h.bottom : f) : t.y = 0;
|
|
741
|
-
const
|
|
742
|
-
o.x =
|
|
741
|
+
const _ = me(p, g), y = me(m, f), E = pe(p, g), w = pe(m, f);
|
|
742
|
+
o.x = _, o.y = y, o.width = E - _, o.height = w - y;
|
|
743
743
|
}
|
|
744
744
|
_redrawSelectionArea() {
|
|
745
745
|
const { x: t, y: n, width: o, height: s } = this._areaRect, { style: i } = this._area;
|
|
@@ -919,7 +919,7 @@ function Te(e) {
|
|
|
919
919
|
const st = function(e, t, n) {
|
|
920
920
|
if (e) {
|
|
921
921
|
if (this.clearSelection(), typeof e == "string") {
|
|
922
|
-
const o =
|
|
922
|
+
const o = M(e);
|
|
923
923
|
return o ? this.selectNode(o) : void 0;
|
|
924
924
|
}
|
|
925
925
|
e.className = "selected", e.scrollIntoView({ block: "nearest", inline: "nearest" }), this.currentNode = e, t ? this.bus.fire("selectNewNode", e.nodeObj) : this.bus.fire("selectNode", e.nodeObj, n);
|
|
@@ -1077,7 +1077,7 @@ function O(e) {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
const Tt = function(e, t, n, o) {
|
|
1079
1079
|
const s = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
1080
|
-
return
|
|
1080
|
+
return x(s, {
|
|
1081
1081
|
"text-anchor": "middle",
|
|
1082
1082
|
x: t + "",
|
|
1083
1083
|
y: n + "",
|
|
@@ -1090,11 +1090,11 @@ const Tt = function(e, t, n, o) {
|
|
|
1090
1090
|
const i = Z(e, t, o.delta1), r = Z(e, n, o.delta2), { x: l, y: c } = O(i), { ctrlX: d, ctrlY: a } = i, { ctrlX: u, ctrlY: h } = r, { x: p, y: m } = O(r), g = U(u, h, p, m), f = `M ${g.x1} ${g.y1} L ${p} ${m} L ${g.x2} ${g.y2}`;
|
|
1091
1091
|
let v = "";
|
|
1092
1092
|
if (o.bidirectional) {
|
|
1093
|
-
const
|
|
1094
|
-
v = `M ${
|
|
1093
|
+
const S = U(d, a, l, c);
|
|
1094
|
+
v = `M ${S.x1} ${S.y1} L ${l} ${c} L ${S.x2} ${S.y2}`;
|
|
1095
1095
|
}
|
|
1096
|
-
const
|
|
1097
|
-
|
|
1096
|
+
const _ = We(`M ${l} ${c} C ${d} ${a} ${u} ${h} ${p} ${m}`, f, v), y = l / 8 + d * 3 / 8 + u * 3 / 8 + p / 8, E = c / 8 + a * 3 / 8 + h * 3 / 8 + m / 8, w = Tt(o.label, y, E, e.theme.cssVar["--color"]);
|
|
1097
|
+
_.appendChild(w), _.arrowObj = o, _.dataset.linkid = o.id, e.linkSvgGroup.appendChild(_), s || (e.arrows.push(o), e.currentArrow = _, Ae(e, o, i, r)), performance.now();
|
|
1098
1098
|
}, $t = function(e, t, n = {}) {
|
|
1099
1099
|
const o = {
|
|
1100
1100
|
id: ee(),
|
|
@@ -1129,7 +1129,7 @@ const Tt = function(e, t, n, o) {
|
|
|
1129
1129
|
});
|
|
1130
1130
|
}, Nt = function(e) {
|
|
1131
1131
|
this.currentArrow = e;
|
|
1132
|
-
const t = e.arrowObj, n =
|
|
1132
|
+
const t = e.arrowObj, n = M(t.from), o = M(t.to), s = Z(this, n, t.delta1), i = Z(this, o, t.delta2);
|
|
1133
1133
|
Ae(this, t, s, i);
|
|
1134
1134
|
}, kt = function() {
|
|
1135
1135
|
this.currentArrow = null, se(this);
|
|
@@ -1139,12 +1139,12 @@ const Tt = function(e, t, n, o) {
|
|
|
1139
1139
|
}, Ae = function(e, t, n, o) {
|
|
1140
1140
|
e.linkController.style.display = "initial", e.P2.style.display = "initial", e.P3.style.display = "initial", e.nodes.appendChild(e.linkController), e.nodes.appendChild(e.P2), e.nodes.appendChild(e.P3);
|
|
1141
1141
|
let { x: s, y: i } = O(n), { ctrlX: r, ctrlY: l } = n, { ctrlX: c, ctrlY: d } = o, { x: a, y: u } = O(o);
|
|
1142
|
-
e.P2.style.cssText = `top:${l}px;left:${r}px;`, e.P3.style.cssText = `top:${d}px;left:${c}px;`,
|
|
1142
|
+
e.P2.style.cssText = `top:${l}px;left:${r}px;`, e.P3.style.cssText = `top:${d}px;left:${c}px;`, x(e.line1, {
|
|
1143
1143
|
x1: s + "",
|
|
1144
1144
|
y1: i + "",
|
|
1145
1145
|
x2: r + "",
|
|
1146
1146
|
y2: l + ""
|
|
1147
|
-
}),
|
|
1147
|
+
}), x(e.line2, {
|
|
1148
1148
|
x1: c + "",
|
|
1149
1149
|
y1: d + "",
|
|
1150
1150
|
x2: a + "",
|
|
@@ -1160,10 +1160,10 @@ const Tt = function(e, t, n, o) {
|
|
|
1160
1160
|
const v = U(r, l, s, i);
|
|
1161
1161
|
e.currentArrow.children[2].setAttribute("d", `M ${v.x1} ${v.y1} L ${s} ${i} L ${v.x2} ${v.y2}`);
|
|
1162
1162
|
}
|
|
1163
|
-
|
|
1163
|
+
x(e.currentArrow.children[3], {
|
|
1164
1164
|
x: g + "",
|
|
1165
1165
|
y: f + ""
|
|
1166
|
-
}),
|
|
1166
|
+
}), x(e.line1, {
|
|
1167
1167
|
x1: s + "",
|
|
1168
1168
|
y1: i + "",
|
|
1169
1169
|
x2: r + "",
|
|
@@ -1176,10 +1176,10 @@ const Tt = function(e, t, n, o) {
|
|
|
1176
1176
|
const m = O({ ...o, ctrlX: c, ctrlY: d });
|
|
1177
1177
|
a = m.x, u = m.y;
|
|
1178
1178
|
const g = s / 8 + r * 3 / 8 + c * 3 / 8 + a / 8, f = i / 8 + l * 3 / 8 + d * 3 / 8 + u / 8, v = U(c, d, a, u);
|
|
1179
|
-
e.P3.style.top = d + "px", e.P3.style.left = c + "px", e.currentArrow.children[0].setAttribute("d", `M ${s} ${i} C ${r} ${l} ${c} ${d} ${a} ${u}`), e.currentArrow.children[1].setAttribute("d", `M ${v.x1} ${v.y1} L ${a} ${u} L ${v.x2} ${v.y2}`),
|
|
1179
|
+
e.P3.style.top = d + "px", e.P3.style.left = c + "px", e.currentArrow.children[0].setAttribute("d", `M ${s} ${i} C ${r} ${l} ${c} ${d} ${a} ${u}`), e.currentArrow.children[1].setAttribute("d", `M ${v.x1} ${v.y1} L ${a} ${u} L ${v.x2} ${v.y2}`), x(e.currentArrow.children[3], {
|
|
1180
1180
|
x: g + "",
|
|
1181
1181
|
y: f + ""
|
|
1182
|
-
}),
|
|
1182
|
+
}), x(e.line2, {
|
|
1183
1183
|
x1: c + "",
|
|
1184
1184
|
y1: d + "",
|
|
1185
1185
|
x2: a + "",
|
|
@@ -1192,7 +1192,7 @@ function Ht() {
|
|
|
1192
1192
|
for (let e = 0; e < this.arrows.length; e++) {
|
|
1193
1193
|
const t = this.arrows[e];
|
|
1194
1194
|
try {
|
|
1195
|
-
$e(this,
|
|
1195
|
+
$e(this, M(t.from), M(t.to), t, !0);
|
|
1196
1196
|
} catch {
|
|
1197
1197
|
}
|
|
1198
1198
|
}
|
|
@@ -1271,7 +1271,7 @@ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1271
1271
|
return t.setAttribute("id", e), t;
|
|
1272
1272
|
}, ye = function(e, t) {
|
|
1273
1273
|
const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1274
|
-
return
|
|
1274
|
+
return x(n, {
|
|
1275
1275
|
d: e,
|
|
1276
1276
|
stroke: t || "#666",
|
|
1277
1277
|
fill: "none",
|
|
@@ -1280,32 +1280,32 @@ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1280
1280
|
}), n;
|
|
1281
1281
|
}, be = function(e, t, n, o, s) {
|
|
1282
1282
|
const i = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
1283
|
-
return
|
|
1283
|
+
return x(i, {
|
|
1284
1284
|
"text-anchor": o,
|
|
1285
1285
|
x: t + "",
|
|
1286
1286
|
y: n + "",
|
|
1287
1287
|
fill: s || "#666"
|
|
1288
1288
|
}), i.innerHTML = e, i;
|
|
1289
|
-
}, jt = (e) =>
|
|
1290
|
-
const n =
|
|
1289
|
+
}, jt = (e) => M(e).parentElement.parentElement, Rt = function({ parent: e, start: t }) {
|
|
1290
|
+
const n = M(e), o = n.nodeObj;
|
|
1291
1291
|
let s;
|
|
1292
|
-
return o.parent ? s = n.closest("me-main").className : s =
|
|
1292
|
+
return o.parent ? s = n.closest("me-main").className : s = M(o.children[t].id).closest("me-main").className, s;
|
|
1293
1293
|
}, ie = function(e, t) {
|
|
1294
|
-
var
|
|
1295
|
-
const { id: n, text: o, parent: s, start: i, end: r } = t, l = e.nodes, d =
|
|
1294
|
+
var S;
|
|
1295
|
+
const { id: n, text: o, parent: s, start: i, end: r } = t, l = e.nodes, d = M(s).nodeObj, a = Rt(t);
|
|
1296
1296
|
let u = 1 / 0, h = 0, p = 0, m = 0;
|
|
1297
1297
|
for (let q = i; q <= r; q++) {
|
|
1298
|
-
const re = (
|
|
1298
|
+
const re = (S = d.children) == null ? void 0 : S[q];
|
|
1299
1299
|
if (!re)
|
|
1300
1300
|
return e.removeSummary(n), null;
|
|
1301
1301
|
const I = jt(re.id), { offsetLeft: X, offsetTop: le } = H(l, I), ce = i === r ? 10 : 20;
|
|
1302
1302
|
q === i && (p = le + ce), q === r && (m = le + I.offsetHeight - ce), X < u && (u = X), I.offsetWidth + X > h && (h = I.offsetWidth + X);
|
|
1303
1303
|
}
|
|
1304
1304
|
let g, f;
|
|
1305
|
-
const v = p + 10,
|
|
1306
|
-
a === T.LHS ? (g = ye(`M ${u + 10} ${v} c -5 0 -10 5 -10 10 L ${u} ${
|
|
1307
|
-
const
|
|
1308
|
-
return
|
|
1305
|
+
const v = p + 10, _ = m + 10, y = (v + _) / 2, E = e.theme.cssVar["--color"];
|
|
1306
|
+
a === T.LHS ? (g = ye(`M ${u + 10} ${v} c -5 0 -10 5 -10 10 L ${u} ${_ - 10} c 0 5 5 10 10 10 M ${u} ${y} h -10`, E), f = be(o, u - 20, y + 6, "end", E)) : (g = ye(`M ${h - 10} ${v} c 5 0 10 5 10 10 L ${h} ${_ - 10} c 0 5 -5 10 -10 10 M ${h} ${y} h 10`, E), f = be(o, h + 20, y + 6, "start", E));
|
|
1307
|
+
const w = Ot("s-" + n);
|
|
1308
|
+
return w.appendChild(g), w.appendChild(f), w.summaryObj = t, e.summarySvg.appendChild(w), w;
|
|
1309
1309
|
}, qt = function() {
|
|
1310
1310
|
let e = [];
|
|
1311
1311
|
this.currentNode ? e = [this.currentNode] : this.currentNodes && (e = this.currentNodes);
|
|
@@ -1329,7 +1329,7 @@ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1329
1329
|
});
|
|
1330
1330
|
}, Ft = function(e) {
|
|
1331
1331
|
const t = e.children[1].getBBox(), n = 6, o = 3, s = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
1332
|
-
|
|
1332
|
+
x(s, {
|
|
1333
1333
|
x: t.x - n + "",
|
|
1334
1334
|
y: t.y - n + "",
|
|
1335
1335
|
width: t.width + n * 2 + "",
|
|
@@ -1370,12 +1370,12 @@ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1370
1370
|
renderSummary: Xt,
|
|
1371
1371
|
selectSummary: Ft,
|
|
1372
1372
|
unselectSummary: It
|
|
1373
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1373
|
+
}, Symbol.toStringTag, { value: "Module" })), L = "http://www.w3.org/2000/svg";
|
|
1374
1374
|
function Kt(e, t) {
|
|
1375
|
-
const n = document.createElementNS(
|
|
1376
|
-
return
|
|
1375
|
+
const n = document.createElementNS(L, "svg");
|
|
1376
|
+
return x(n, {
|
|
1377
1377
|
version: "1.1",
|
|
1378
|
-
xmlns:
|
|
1378
|
+
xmlns: L,
|
|
1379
1379
|
height: e,
|
|
1380
1380
|
width: t
|
|
1381
1381
|
}), n;
|
|
@@ -1384,12 +1384,12 @@ function Jt(e, t) {
|
|
|
1384
1384
|
return (parseInt(e) - parseInt(t)) / 2;
|
|
1385
1385
|
}
|
|
1386
1386
|
function Ut(e, t, n, o) {
|
|
1387
|
-
const s = document.createElementNS(
|
|
1387
|
+
const s = document.createElementNS(L, "g");
|
|
1388
1388
|
let i = "";
|
|
1389
1389
|
return e.text ? i = e.text.textContent : i = e.childNodes[0].textContent, i.split(`
|
|
1390
1390
|
`).forEach((l, c) => {
|
|
1391
|
-
const d = document.createElementNS(
|
|
1392
|
-
|
|
1391
|
+
const d = document.createElementNS(L, "text");
|
|
1392
|
+
x(d, {
|
|
1393
1393
|
x: n + parseInt(t.paddingLeft) + "",
|
|
1394
1394
|
y: o + parseInt(t.paddingTop) + Jt(t.lineHeight, t.fontSize) * (c + 1) + parseFloat(t.fontSize) * (c + 1) + "",
|
|
1395
1395
|
"text-anchor": "start",
|
|
@@ -1404,22 +1404,22 @@ function Qt(e, t, n, o) {
|
|
|
1404
1404
|
var l;
|
|
1405
1405
|
let s = "";
|
|
1406
1406
|
(l = e.nodeObj) != null && l.dangerouslySetInnerHTML ? s = e.nodeObj.dangerouslySetInnerHTML : e.text ? s = e.text.textContent : s = e.childNodes[0].textContent;
|
|
1407
|
-
const i = document.createElementNS(
|
|
1408
|
-
|
|
1407
|
+
const i = document.createElementNS(L, "foreignObject");
|
|
1408
|
+
x(i, {
|
|
1409
1409
|
x: n + parseInt(t.paddingLeft) + "",
|
|
1410
1410
|
y: o + parseInt(t.paddingTop) + "",
|
|
1411
1411
|
width: t.width,
|
|
1412
1412
|
height: t.height
|
|
1413
1413
|
});
|
|
1414
1414
|
const r = document.createElement("div");
|
|
1415
|
-
return
|
|
1415
|
+
return x(r, {
|
|
1416
1416
|
xmlns: "http://www.w3.org/1999/xhtml",
|
|
1417
1417
|
style: `font-family: ${t.fontFamily}; font-size: ${t.fontSize}; font-weight: ${t.fontWeight}; color: ${t.color}; white-space: pre-wrap;`
|
|
1418
1418
|
}), r.innerHTML = s, i.appendChild(r), i;
|
|
1419
1419
|
}
|
|
1420
1420
|
function Zt(e, t) {
|
|
1421
|
-
const n = getComputedStyle(t), { offsetLeft: o, offsetTop: s } = H(e.nodes, t), i = document.createElementNS(
|
|
1422
|
-
return
|
|
1421
|
+
const n = getComputedStyle(t), { offsetLeft: o, offsetTop: s } = H(e.nodes, t), i = document.createElementNS(L, "rect");
|
|
1422
|
+
return x(i, {
|
|
1423
1423
|
x: o + "",
|
|
1424
1424
|
y: s + "",
|
|
1425
1425
|
rx: n.borderRadius,
|
|
@@ -1432,8 +1432,8 @@ function Zt(e, t) {
|
|
|
1432
1432
|
}), i;
|
|
1433
1433
|
}
|
|
1434
1434
|
function G(e, t, n = !1) {
|
|
1435
|
-
const o = getComputedStyle(t), { offsetLeft: s, offsetTop: i } = H(e.nodes, t), r = document.createElementNS(
|
|
1436
|
-
|
|
1435
|
+
const o = getComputedStyle(t), { offsetLeft: s, offsetTop: i } = H(e.nodes, t), r = document.createElementNS(L, "rect");
|
|
1436
|
+
x(r, {
|
|
1437
1437
|
x: s + "",
|
|
1438
1438
|
y: i + "",
|
|
1439
1439
|
rx: o.borderRadius,
|
|
@@ -1444,14 +1444,14 @@ function G(e, t, n = !1) {
|
|
|
1444
1444
|
stroke: o.borderColor,
|
|
1445
1445
|
"stroke-width": o.borderWidth
|
|
1446
1446
|
});
|
|
1447
|
-
const l = document.createElementNS(
|
|
1447
|
+
const l = document.createElementNS(L, "g");
|
|
1448
1448
|
l.appendChild(r);
|
|
1449
1449
|
let c;
|
|
1450
1450
|
return n ? c = Qt(t, o, s, i) : c = Ut(t, o, s, i), l.appendChild(c), l;
|
|
1451
1451
|
}
|
|
1452
1452
|
function en(e, t) {
|
|
1453
|
-
const n = getComputedStyle(t), { offsetLeft: o, offsetTop: s } = H(e.nodes, t), i = document.createElementNS(
|
|
1454
|
-
return
|
|
1453
|
+
const n = getComputedStyle(t), { offsetLeft: o, offsetTop: s } = H(e.nodes, t), i = document.createElementNS(L, "a"), r = document.createElementNS(L, "text");
|
|
1454
|
+
return x(r, {
|
|
1455
1455
|
x: o + "",
|
|
1456
1456
|
y: s + parseInt(n.fontSize) + "",
|
|
1457
1457
|
"text-anchor": "start",
|
|
@@ -1462,8 +1462,8 @@ function en(e, t) {
|
|
|
1462
1462
|
}), r.innerHTML = t.textContent, i.appendChild(r), i.setAttribute("href", t.href), i;
|
|
1463
1463
|
}
|
|
1464
1464
|
function tn(e, t) {
|
|
1465
|
-
const n = getComputedStyle(t), { offsetLeft: o, offsetTop: s } = H(e.nodes, t), i = document.createElementNS(
|
|
1466
|
-
return
|
|
1465
|
+
const n = getComputedStyle(t), { offsetLeft: o, offsetTop: s } = H(e.nodes, t), i = document.createElementNS(L, "image");
|
|
1466
|
+
return x(i, {
|
|
1467
1467
|
x: o + "",
|
|
1468
1468
|
y: s + "",
|
|
1469
1469
|
width: n.width + "",
|
|
@@ -1473,8 +1473,8 @@ function tn(e, t) {
|
|
|
1473
1473
|
}
|
|
1474
1474
|
const K = 100, nn = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">', on = (e, t = !1) => {
|
|
1475
1475
|
var u, h, p;
|
|
1476
|
-
const n = e.nodes, o = n.offsetHeight + K * 2, s = n.offsetWidth + K * 2, i = Kt(o + "px", s + "px"), r = document.createElementNS(
|
|
1477
|
-
|
|
1476
|
+
const n = e.nodes, o = n.offsetHeight + K * 2, s = n.offsetWidth + K * 2, i = Kt(o + "px", s + "px"), r = document.createElementNS(L, "svg"), l = document.createElementNS(L, "rect");
|
|
1477
|
+
x(l, {
|
|
1478
1478
|
x: "0",
|
|
1479
1479
|
y: "0",
|
|
1480
1480
|
width: `${s}`,
|
|
@@ -1499,7 +1499,7 @@ const K = 100, nn = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "
|
|
|
1499
1499
|
r.appendChild(en(e, m));
|
|
1500
1500
|
}), n.querySelectorAll("img").forEach((m) => {
|
|
1501
1501
|
r.appendChild(tn(e, m));
|
|
1502
|
-
}),
|
|
1502
|
+
}), x(r, {
|
|
1503
1503
|
x: K + "",
|
|
1504
1504
|
y: K + "",
|
|
1505
1505
|
overflow: "visible"
|
|
@@ -1541,7 +1541,7 @@ const ln = function(e = !1, t) {
|
|
|
1541
1541
|
createParent: Oe,
|
|
1542
1542
|
createChildren: je,
|
|
1543
1543
|
createTopic: Re,
|
|
1544
|
-
findEle:
|
|
1544
|
+
findEle: M,
|
|
1545
1545
|
changeTheme: nt,
|
|
1546
1546
|
...Lt,
|
|
1547
1547
|
...hn,
|
|
@@ -1575,7 +1575,7 @@ function fn({ pT: e, pL: t, pW: n, pH: o, cT: s, cL: i, cW: r, cH: l, direction:
|
|
|
1575
1575
|
const v = Math.abs(u - p) / 300 * a;
|
|
1576
1576
|
return c === T.LHS ? (f = t, m = f + a, g = f - a, h = i + a, `M ${m} ${u} C ${f} ${u} ${f + v} ${p} ${g} ${p} H ${h}`) : (f = t + n, m = f - a, g = f + a, h = i + r - a, `M ${m} ${u} C ${f} ${u} ${f - v} ${p} ${g} ${p} H ${h}`);
|
|
1577
1577
|
}
|
|
1578
|
-
const pn = "4.6.
|
|
1578
|
+
const pn = "4.6.1", V = document;
|
|
1579
1579
|
function $({
|
|
1580
1580
|
el: e,
|
|
1581
1581
|
direction: t,
|
|
@@ -1594,17 +1594,18 @@ function $({
|
|
|
1594
1594
|
generateSubBranch: m,
|
|
1595
1595
|
overflowHidden: g,
|
|
1596
1596
|
theme: f,
|
|
1597
|
-
alignment: v
|
|
1597
|
+
alignment: v,
|
|
1598
|
+
scaleSensitivity: _
|
|
1598
1599
|
}) {
|
|
1599
1600
|
let y = null;
|
|
1600
|
-
const
|
|
1601
|
-
if (
|
|
1601
|
+
const E = Object.prototype.toString.call(e);
|
|
1602
|
+
if (E === "[object HTMLDivElement]" ? y = e : E === "[object String]" && (y = document.querySelector(e)), !y)
|
|
1602
1603
|
throw new Error("MindElixir: el is not a valid element");
|
|
1603
|
-
y.style.position = "relative", y.innerHTML = "", this.el = y, this.disposable = [], this.before = a || {}, this.locale = n || "en", this.contextMenu = i === void 0 ? !0 : i, this.toolBar = r === void 0 ? !0 : r, this.keypress = l === void 0 ? !0 : l, this.mouseSelectionButton = c || 0, this.direction = typeof t == "number" ? t : 1, this.draggable = o === void 0 ? !0 : o, this.newTopicName = u || "new node", this.editable = s === void 0 ? !0 : s, this.allowUndo = h === void 0 ? !1 : h, this.currentNode = null, this.currentArrow = null, this.scaleVal = 1, this.tempDirection = null, this.generateMainBranch = p || un, this.generateSubBranch = m || fn, this.overflowHidden = g || !1, this.bus = He.create(), this.container = V.createElement("div"), this.selectionContainer = d || this.container, this.container.className = "map-container";
|
|
1604
|
-
const
|
|
1605
|
-
this.theme = f || (
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1604
|
+
y.style.position = "relative", y.innerHTML = "", this.el = y, this.disposable = [], this.before = a || {}, this.locale = n || "en", this.contextMenu = i === void 0 ? !0 : i, this.toolBar = r === void 0 ? !0 : r, this.keypress = l === void 0 ? !0 : l, this.mouseSelectionButton = c || 0, this.direction = typeof t == "number" ? t : 1, this.draggable = o === void 0 ? !0 : o, this.newTopicName = u || "new node", this.editable = s === void 0 ? !0 : s, this.allowUndo = h === void 0 ? !1 : h, this.scaleSensitivity = typeof _ == "number" ? _ : 0.2, this.currentNode = null, this.currentArrow = null, this.scaleVal = 1, this.tempDirection = null, this.generateMainBranch = p || un, this.generateSubBranch = m || fn, this.overflowHidden = g || !1, this.bus = He.create(), this.container = V.createElement("div"), this.selectionContainer = d || this.container, this.container.className = "map-container";
|
|
1605
|
+
const w = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1606
|
+
this.theme = f || (w.matches ? we : xe);
|
|
1607
|
+
const S = V.createElement("div");
|
|
1608
|
+
S.className = "map-canvas", this.map = S, this.map.setAttribute("tabindex", "0"), this.container.appendChild(this.map), this.el.appendChild(this.container), this.nodes = V.createElement("me-nodes"), this.nodes.className = "main-node-container", this.lines = W("lines"), this.summarySvg = W("summary"), this.linkController = W("linkcontroller"), this.P2 = V.createElement("div"), this.P3 = V.createElement("div"), this.P2.className = this.P3.className = "circle", this.P2.style.display = this.P3.style.display = "none", this.line1 = de(), this.line2 = de(), this.linkController.appendChild(this.line1), this.linkController.appendChild(this.line2), this.linkSvgGroup = W("topiclinks"), this.alignment = v ?? "root", this.map.appendChild(this.nodes), this.overflowHidden ? this.container.style.overflow = "hidden" : ke(this);
|
|
1608
1609
|
}
|
|
1609
1610
|
$.prototype = dn;
|
|
1610
1611
|
$.LEFT = j;
|
|
@@ -1613,7 +1614,7 @@ $.SIDE = ne;
|
|
|
1613
1614
|
$.THEME = xe;
|
|
1614
1615
|
$.DARK_THEME = we;
|
|
1615
1616
|
$.version = pn;
|
|
1616
|
-
$.E =
|
|
1617
|
+
$.E = M;
|
|
1617
1618
|
$.dragMoveHelper = k;
|
|
1618
1619
|
export {
|
|
1619
1620
|
$ as default
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { LEFT, RIGHT, SIDE, DARK_THEME, THEME } from './const';
|
|
|
4
4
|
import { findEle } from './utils/dom';
|
|
5
5
|
import dragMoveHelper from './utils/dragMoveHelper';
|
|
6
6
|
import type { MindElixirData, MindElixirInstance, MindElixirMethods, Options } from './types/index';
|
|
7
|
-
declare function MindElixir(this: MindElixirInstance, { el, direction, locale, draggable, editable, contextMenu, toolBar, keypress, mouseSelectionButton, selectionContainer, before, newTopicName, allowUndo, generateMainBranch, generateSubBranch, overflowHidden, theme, alignment, }: Options): void;
|
|
7
|
+
declare function MindElixir(this: MindElixirInstance, { el, direction, locale, draggable, editable, contextMenu, toolBar, keypress, mouseSelectionButton, selectionContainer, before, newTopicName, allowUndo, generateMainBranch, generateSubBranch, overflowHidden, theme, alignment, scaleSensitivity, }: Options): void;
|
|
8
8
|
declare namespace MindElixir {
|
|
9
9
|
export var prototype: {
|
|
10
10
|
init(this: MindElixirInstance, data: MindElixirData): Error | undefined;
|