1575 lines
88 KiB
JavaScript
1575 lines
88 KiB
JavaScript
|
|
(function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode(".mind-elixir{--gap: 30px;--root-radius: 30px;--main-radius: 20px;--root-color: #ffffff;--root-bgcolor: #4c4f69;--main-color: #444446;--main-bgcolor: #ffffff;--topic-padding: 3px;--color: #777777;--bgcolor: #f6f6f6;--selected: #4dc4ff;--panel-color: #444446;--panel-bgcolor: #ffffff;--panel-border-color: #eaeaea;position:relative;-webkit-tap-highlight-color:rgba(0,0,0,0);font-family:-apple-system,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Microsoft YaHei,Source Han Sans SC,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif}.mind-elixir .hyper-link{text-decoration:none;margin-left:.3em}.map-container{-webkit-user-select:none;user-select:none;height:100%;width:100%;overflow:scroll;font-size:15px}.map-container::-webkit-scrollbar{width:0px;height:0px}.map-container .selected{box-shadow:0 0 0 2px var(--selected)}.map-container .lhs{direction:rtl}.map-container .lhs me-tpc{direction:ltr}.map-container .map-canvas{height:20000px;width:20000px;position:relative;-webkit-user-select:none;user-select:none;transition:transform .3s;transform:scale(1);background-color:var(--bgcolor)}.map-container .map-canvas me-nodes{position:absolute;display:flex;justify-content:center;align-items:center;height:fit-content;width:fit-content}.map-container .map-canvas me-root{position:relative}.map-container .map-canvas me-root me-tpc{display:block;font-size:25px;line-height:1.2em;color:var(--root-color);padding:10px var(--gap);border-radius:var(--root-radius);white-space:pre-wrap;background-color:var(--root-bgcolor)}.map-container .map-canvas me-root me-tpc #input-box{padding:10px var(--gap)}.map-container me-main>me-wrapper{position:relative;margin:20px 65px}.map-container me-main>me-wrapper>me-parent{margin:var(--gap);padding:0}.map-container me-main>me-wrapper>me-parent>me-tpc{border-radius:var(--main-radius);background-color:var(--main-bgcolor);border:2px solid var(--main-color);color:var(--main-color);padding:8px var(--gap)}.map-container me-main>me-wrapper>me-parent>me-tpc #input-box{padding:8px var(--gap)}.map-container me-wrapper{display:block;pointer-events:none;width:fit-content}.map-container me-children,.map-container me-parent{display:inline-block;vertical-align:middle}.map-container me-parent{position:relative;cursor:pointer;padding:6px var(--gap);margin-top:10px}.map-container me-parent me-tpc{position:relative;display:block;border-radius:3px;color:var(--color);pointer-events:all;max-width:35em;white-space:pre-wrap;padding:var(--topic-padding);line-height:1.2em}.map-container me-parent me-tpc .insert-preview{position:absolute;width:100%;left:0;z-index:9}.map-container me-parent me-tpc .show{background:#7ad5ff;pointer-events:none;opacity:.7}.map-container me-parent me-tpc .before{height:14px;top:-14px}.map-container me-parent me-tpc .in{height:100%;top:0}.map-container me-parent me-tpc .after{height:14px;bottom:-14px}.map-container me-parent me-epd{position:absolute;height:18px;width:18px;opacity:.8;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgdD0iMTY1NjY1NDcxNzI0MiIgY2xhc3M9Imljb24iIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIKICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+CiAgICA8cGF0aCBkPSJNNTEyIDc0LjY2NjY2N0MyNzAuOTMzMzMzIDc0LjY2NjY2NyA3NC42NjY2NjcgMjcwLjkzMzMzMyA3NC42NjY2NjcgNTEyUzI3MC45MzMzMzMgOTQ5LjMzMzMzMyA1MTIgOTQ5LjMzMzMzMyA5NDkuMzMzMzMzIDc1My4wNjY2NjcgOTQ5LjMzMzMzMyA1MTIgNzUzLjA2NjY2NyA3NC42NjY2NjcgNTEyIDc0LjY2NjY2N3oiIHN0cm9rZS13aWR0aD0iNTQiIHN0cm9rZT0nYmxhY2snIGZpbGw9J3doaXRlJyA+PC9wYXRoPgogICAgPHBhdGggZD0iTTY4Mi42NjY2NjcgNDgwaC0xMzguNjY2NjY3VjM0MS4zMzMzMzNjMC0xNy4wNjY2NjctMTQuOTMzMzMzLTMyLTMyLTMycy0zMiAxNC45MzMzMzMtMzIgMzJ2MTM4LjY2NjY2N0gzNDEuMzMzMzMzYy0xNy4wNjY2NjcgMC0zMiAxNC45MzMzMzMtMzIgMzJzMTQuOTMzM
|
||
|
|
(function(t) {
|
||
|
|
var e, n, i, s, o, r, l = '<svg><symbol id="icon-edit" viewBox="0 0 1024 1024"><path d="M423.765333 128a42.666667 42.666667 0 0 1 3.2 85.205333L423.765333 213.333333H234.666667a64 64 0 0 0-63.872 60.245334L170.666667 277.333333v512a64 64 0 0 0 60.245333 63.872L234.666667 853.333333h512a64 64 0 0 0 63.872-60.245333L810.666667 789.333333v-189.098666a42.666667 42.666667 0 0 1 85.205333-3.2l0.128 3.2V789.333333a149.333333 149.333333 0 0 1-144.213333 149.248L746.666667 938.666667h-512a149.333333 149.333333 0 0 1-149.248-144.213334L85.333333 789.333333v-512a149.333333 149.333333 0 0 1 144.213334-149.248L234.666667 128h189.098666z m324.949334-53.248a42.666667 42.666667 0 0 1 60.330666 0l150.869334 150.869333a42.666667 42.666667 0 0 1 0 60.330667l-329.386667 329.386667a42.666667 42.666667 0 0 1-29.44 12.458666l-153.386667 2.517334a42.666667 42.666667 0 0 1-43.349333-43.349334l2.56-153.386666a42.666667 42.666667 0 0 1 12.458667-29.44z m30.165333 90.496L491.946667 452.266667l-1.493334 91.989333 92.032-1.493333 286.976-286.976-90.538666-90.538667z" ></path></symbol><symbol id="icon-rising" viewBox="0 0 1024 1024"><path d="M553.173333 803.84h-64l0.021334-474.581333-224.021334 224-45.269333-45.226667L521.6 206.293333l301.717333 301.696-45.269333 45.269334-224.853333-224.896v475.477333z" ></path></symbol><symbol id="icon-falling" viewBox="0 0 1024 1024"><path d="M553.173333 238.314667h-64l0.021334 474.602666-224.021334-224-45.269333 45.226667L521.6 835.861333l301.717333-301.717333-45.269333-45.226667-224.853333 224.853334V238.336z" ></path></symbol><symbol id="icon-shanchu2" viewBox="0 0 1024 1024"><path d="M516.60601807 107.93026734c-82.64382935 0-149.71865844 65.51751709-152.5729065 147.77160644H171.37136841c-21.40603638 0-38.92044068 17.38504028-38.92044068 38.92126465 0 21.40686036 17.38504028 38.92208862 38.92126466 38.92208862h42.94308471v435.40136719c0 81.73498536 55.39828492 148.55026245 123.90106201 148.55026245h348.99444581c68.37341309 0 123.90106201-66.42553711 123.901062-148.55026245V333.80477906h38.92126465c21.40686036 0 38.92126464-17.38586426 38.92126465-38.92208863 0-21.40686036-17.38504028-38.92126464-38.92126465-38.92126465H668.91854859C666.45321656 173.44860839 599.24902344 107.93109131 516.60601807 107.93109131z m-79.65939331 147.77160644c2.85424805-42.16442872 37.2354126-74.85809326 79.78875732-74.85809326s76.93450927 32.82302857 79.39984131 74.85809326H436.94662476z m-98.86047364 589.01165771c-24.2611084 0-50.98754883-31.13717651-50.98754883-75.76693725V333.80477906h450.97036744V769.33551026c0 44.50039673-26.72644043 75.76776123-50.98754884 75.76776122H338.08615112v-0.38973999z m0 0" ></path><path d="M390.37063599 751.17263794c17.77313232 0 32.43411255-17.7739563 32.43411255-40.08883667V482.35504151c0-22.31488037-14.53079224-40.08966065-32.43411255-40.08966065-17.77478027 0-32.43493653 17.77478027-32.43493653 40.08966065v228.72875976c0 22.18469239 14.27124023 40.08883667 32.43493653 40.08883667z m117.41308594 0c17.7739563 0 32.43411255-17.7739563 32.43411255-40.08883667V482.35504151c0-22.31488037-14.53079224-40.08966065-32.43411255-40.08966065-17.7739563 0-32.43493653 17.77478027-32.43493653 40.08966065v228.72875976c0 22.18469239 14.66098023 40.08883667 32.43493653 40.08883667z m123.51049804 0c17.7739563 0 32.43493653-17.7739563 32.43493652-40.08883667V482.35504151c0-22.31488037-14.53079224-40.08966065-32.43493652-40.08966065-17.7739563 0-32.43411255 17.77478027-32.43411255 40.08966065v228.72875976c0 22.18469239 14.14105224 40.08883667 32.43411255 40.08883667z m0 0" ></path></symbol><symbol id="icon-zijiedian" viewBox="0 0 1024 1024"><path d="M312.208 472c19.568-157.856 153.432-280 315.656-280 175.68 0 318.112 143.272 318.112 320S803.552 832 627.864 832c-162.224 0-296.08-122.144-315.656-280H120a40 40 0 0 1 0-80h192.208zM632 752c132.552 0 240-107.448 240-240 0-132.552-107.448-240-240-240-132.552 0-240 107.448-240 240 0 132.552 107.448 240 240 240z m-40-280v-80a40 40 0 0 1 80 0v80h80a40 40 0 0 1 0 80h-80v80a40 40 0 0 1-80 0v-80h-80a40 40 0 0 1 0-80h80z" ></path></symbol><symbol id="icon-tongjijiedian-" vie
|
||
|
|
if (c && !t.__iconfont__svg__cssinject__) {
|
||
|
|
t.__iconfont__svg__cssinject__ = !0;
|
||
|
|
try {
|
||
|
|
document.write(
|
||
|
|
"<style>.svgfont {display: inline-block;width: 1em;height: 1em;fill: currentColor;vertical-align: -0.1em;font-size:16px;}</style>"
|
||
|
|
);
|
||
|
|
} catch (h) {
|
||
|
|
console && console.log(h);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function u() {
|
||
|
|
o || (o = !0, i());
|
||
|
|
}
|
||
|
|
e = function() {
|
||
|
|
var h, d, a, f;
|
||
|
|
(f = document.createElement("div")).innerHTML = l, l = null, (a = f.getElementsByTagName("svg")[0]) && (a.setAttribute("aria-hidden", "true"), a.style.position = "absolute", a.style.width = 0, a.style.height = 0, a.style.overflow = "hidden", h = a, (d = document.body).firstChild ? (f = h, (a = d.firstChild).parentNode.insertBefore(f, a)) : d.appendChild(h));
|
||
|
|
}, document.addEventListener ? ~["complete", "loaded", "interactive"].indexOf(document.readyState) ? setTimeout(e, 0) : (n = function() {
|
||
|
|
document.removeEventListener("DOMContentLoaded", n, !1), e();
|
||
|
|
}, document.addEventListener("DOMContentLoaded", n, !1)) : document.attachEvent && (i = e, s = t.document, o = !1, (r = function() {
|
||
|
|
try {
|
||
|
|
s.documentElement.doScroll("left");
|
||
|
|
} catch {
|
||
|
|
return void setTimeout(r, 50);
|
||
|
|
}
|
||
|
|
u();
|
||
|
|
})(), s.onreadystatechange = function() {
|
||
|
|
s.readyState == "complete" && (s.onreadystatechange = null, u());
|
||
|
|
});
|
||
|
|
})(window);
|
||
|
|
const j = 0, ee = 1, Q = 2, k = 30, S = 8, ge = {
|
||
|
|
name: "Latte",
|
||
|
|
palette: ["#dd7878", "#ea76cb", "#8839ef", "#e64553", "#fe640b", "#df8e1d", "#40a02b", "#209fb5", "#1e66f5", "#7287fd"],
|
||
|
|
cssVar: {
|
||
|
|
"--main-color": "#444446",
|
||
|
|
"--main-bgcolor": "#ffffff",
|
||
|
|
"--color": "#777777",
|
||
|
|
"--bgcolor": "#f6f6f6",
|
||
|
|
"--panel-color": "#444446",
|
||
|
|
"--panel-bgcolor": "#ffffff",
|
||
|
|
"--panel-border-color": "#eaeaea"
|
||
|
|
}
|
||
|
|
}, ve = {
|
||
|
|
name: "Dark",
|
||
|
|
palette: ["#848FA0", "#748BE9", "#D2F9FE", "#4145A5", "#789AFA", "#706CF4", "#EF987F", "#775DD5", "#FCEECF", "#DA7FBC"],
|
||
|
|
cssVar: {
|
||
|
|
"--main-color": "#ffffff",
|
||
|
|
"--main-bgcolor": "#4c4f69",
|
||
|
|
"--color": "#cccccc",
|
||
|
|
"--bgcolor": "#252526",
|
||
|
|
"--panel-color": "#ffffff",
|
||
|
|
"--panel-bgcolor": "#2d3748",
|
||
|
|
"--panel-border-color": "#696969"
|
||
|
|
}
|
||
|
|
};
|
||
|
|
function oe(t) {
|
||
|
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
||
|
|
}
|
||
|
|
const U = function(t, e) {
|
||
|
|
if (e.id === t)
|
||
|
|
return e;
|
||
|
|
if (e.children && e.children.length) {
|
||
|
|
for (let n = 0; n < e.children.length; n++) {
|
||
|
|
const i = U(t, e.children[n]);
|
||
|
|
if (i)
|
||
|
|
return i;
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
} else
|
||
|
|
return null;
|
||
|
|
}, te = (t, e) => {
|
||
|
|
if (t.parent = e, t.children)
|
||
|
|
for (let n = 0; n < t.children.length; n++)
|
||
|
|
te(t.children[n], t);
|
||
|
|
};
|
||
|
|
function ye(t, e, n, i) {
|
||
|
|
const s = i - e, o = t - n;
|
||
|
|
let r = Math.atan(Math.abs(s) / Math.abs(o)) / 3.14 * 180;
|
||
|
|
o < 0 && s > 0 && (r = 180 - r), o < 0 && s < 0 && (r = 180 + r), o > 0 && s < 0 && (r = 360 - r);
|
||
|
|
const l = 15, c = 30, u = r + c, h = r - c;
|
||
|
|
return {
|
||
|
|
x1: n + Math.cos(Math.PI * u / 180) * l,
|
||
|
|
y1: i - Math.sin(Math.PI * u / 180) * l,
|
||
|
|
x2: n + Math.cos(Math.PI * h / 180) * l,
|
||
|
|
y2: i - Math.sin(Math.PI * h / 180) * l
|
||
|
|
};
|
||
|
|
}
|
||
|
|
function ne() {
|
||
|
|
return ((/* @__PURE__ */ new Date()).getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16);
|
||
|
|
}
|
||
|
|
const $e = function() {
|
||
|
|
const t = ne();
|
||
|
|
return {
|
||
|
|
topic: this.newTopicName,
|
||
|
|
id: t
|
||
|
|
};
|
||
|
|
}, q = (t, e) => {
|
||
|
|
let n = 0, i = 0;
|
||
|
|
for (; e && e !== t; )
|
||
|
|
n += e.offsetLeft, i += e.offsetTop, e = e.offsetParent;
|
||
|
|
return { offsetLeft: n, offsetTop: i };
|
||
|
|
}, w = (t, e) => {
|
||
|
|
for (const n in e)
|
||
|
|
t.setAttribute(n, e[n]);
|
||
|
|
}, re = (t) => t ? t.tagName === "ME-TPC" : !1, N = {
|
||
|
|
moved: !1,
|
||
|
|
// diffrentiate click and move
|
||
|
|
mousedown: !1,
|
||
|
|
onMove(t, e) {
|
||
|
|
if (this.mousedown) {
|
||
|
|
this.moved = !0;
|
||
|
|
const n = t.movementX, i = t.movementY;
|
||
|
|
e.scrollTo(e.scrollLeft - n, e.scrollTop - i);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
clear() {
|
||
|
|
this.moved = !1, this.mousedown = !1;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
function Te(t) {
|
||
|
|
t.map.addEventListener("click", (e) => {
|
||
|
|
var i, s;
|
||
|
|
if (e.button !== 0)
|
||
|
|
return;
|
||
|
|
if ((i = t.helper1) != null && i.moved) {
|
||
|
|
t.helper1.clear();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if ((s = t.helper2) != null && s.moved) {
|
||
|
|
t.helper2.clear();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (N.moved) {
|
||
|
|
N.clear();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
t.unselectNode(), t.unselectNodes(), t.unselectSummary(), t.unselectLink();
|
||
|
|
const n = e.target;
|
||
|
|
if (n.tagName === "ME-EPD")
|
||
|
|
t.expandNode(n.previousSibling);
|
||
|
|
else if (t.editable)
|
||
|
|
re(n) ? t.selectNode(n, !1, e) : n.tagName === "text" ? n.dataset.type === "custom-link" ? t.selectLink(n.parentElement) : t.selectSummary(n.parentElement) : n.className === "circle" || t.hideLinkController && t.hideLinkController();
|
||
|
|
else
|
||
|
|
return;
|
||
|
|
}), t.map.addEventListener("dblclick", (e) => {
|
||
|
|
if (e.preventDefault(), !t.editable)
|
||
|
|
return;
|
||
|
|
const n = e.target;
|
||
|
|
re(n) ? t.beginEdit(n) : n.tagName === "text" && (n.dataset.type === "custom-link" ? t.editCutsomLinkLabel(n.parentElement) : t.editSummary(n.parentElement));
|
||
|
|
}), t.map.addEventListener("mousemove", (e) => {
|
||
|
|
e.target.contentEditable !== "true" && N.onMove(e, t.container);
|
||
|
|
}), t.map.addEventListener("mousedown", (e) => {
|
||
|
|
const n = t.mouseSelectionButton === 0 ? 2 : 0;
|
||
|
|
e.button === n && e.target.contentEditable !== "true" && (N.moved = !1, N.mousedown = !0);
|
||
|
|
}), t.map.addEventListener("mouseleave", (e) => {
|
||
|
|
const n = t.mouseSelectionButton === 0 ? 2 : 0;
|
||
|
|
e.button === n && N.clear();
|
||
|
|
}), t.map.addEventListener("mouseup", (e) => {
|
||
|
|
const n = t.mouseSelectionButton === 0 ? 2 : 0;
|
||
|
|
e.button === n && N.clear();
|
||
|
|
}), t.map.addEventListener("contextmenu", (e) => {
|
||
|
|
e.preventDefault();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
const Ne = {
|
||
|
|
create() {
|
||
|
|
return {
|
||
|
|
handlers: {},
|
||
|
|
showHandler: function() {
|
||
|
|
console.log(this.handlers);
|
||
|
|
},
|
||
|
|
addListener: function(t, e) {
|
||
|
|
this.handlers[t] === void 0 && (this.handlers[t] = []), this.handlers[t].push(e);
|
||
|
|
},
|
||
|
|
fire: function(t, ...e) {
|
||
|
|
if (this.handlers[t] instanceof Array) {
|
||
|
|
const n = this.handlers[t];
|
||
|
|
for (let i = 0; i < n.length; i++)
|
||
|
|
n[i](...e);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
removeListener: function(t, e) {
|
||
|
|
if (!this.handlers[t])
|
||
|
|
return;
|
||
|
|
const n = this.handlers[t];
|
||
|
|
if (!e)
|
||
|
|
n.length = 0;
|
||
|
|
else if (n.length)
|
||
|
|
for (let i = 0; i < n.length; i++)
|
||
|
|
n[i] === e && this.handlers[t].splice(i, 1);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}, K = document, De = function() {
|
||
|
|
console.time("layout"), this.nodes.innerHTML = "";
|
||
|
|
const t = this.createTopic(this.nodeData);
|
||
|
|
be(t, this.nodeData), t.draggable = !1;
|
||
|
|
const e = K.createElement("me-root");
|
||
|
|
e.appendChild(t);
|
||
|
|
const n = this.nodeData.children || [];
|
||
|
|
if (this.direction === Q) {
|
||
|
|
let i = 0, s = 0;
|
||
|
|
n.map((o) => {
|
||
|
|
o.direction === j ? i += 1 : o.direction === ee ? s += 1 : i <= s ? (o.direction = j, i += 1) : (o.direction = ee, s += 1);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
Ae(this, n, e), console.timeEnd("layout");
|
||
|
|
}, Ae = function(t, e, n) {
|
||
|
|
const i = K.createElement("me-main");
|
||
|
|
i.className = "lhs";
|
||
|
|
const s = K.createElement("me-main");
|
||
|
|
s.className = "rhs";
|
||
|
|
for (let o = 0; o < e.length; o++) {
|
||
|
|
const r = e[o], { grp: l } = t.createWrapper(r);
|
||
|
|
t.direction === Q ? r.direction === j ? i.appendChild(l) : s.appendChild(l) : t.direction === j ? i.appendChild(l) : s.appendChild(l);
|
||
|
|
}
|
||
|
|
t.nodes.appendChild(i), t.nodes.appendChild(n), t.nodes.appendChild(s), t.nodes.appendChild(t.lines);
|
||
|
|
}, He = function(t, e) {
|
||
|
|
const n = K.createElement("me-children");
|
||
|
|
for (let i = 0; i < e.length; i++) {
|
||
|
|
const s = e[i], { grp: o } = t.createWrapper(s);
|
||
|
|
n.appendChild(o);
|
||
|
|
}
|
||
|
|
return n;
|
||
|
|
}, _ = document, L = (t, e) => {
|
||
|
|
const i = (e ? e.mindElixirBox : _).querySelector(`[data-nodeid=me${t}]`);
|
||
|
|
if (!i)
|
||
|
|
throw new Error(`FindEle: Node ${t} not found, maybe it's collapsed.`);
|
||
|
|
return i;
|
||
|
|
}, be = function(t, e) {
|
||
|
|
if (t.innerHTML = "", e.style && (t.style.color = e.style.color || "", t.style.background = e.style.background || "", t.style.fontSize = e.style.fontSize + "px", t.style.fontWeight = e.style.fontWeight || "normal"), e.branchColor && (t.style.borderColor = e.branchColor), e.image) {
|
||
|
|
const n = e.image;
|
||
|
|
if (n.url && n.width && n.height) {
|
||
|
|
const i = _.createElement("img");
|
||
|
|
i.src = n.url, i.style.width = n.width + "px", i.style.height = n.height + "px", t.appendChild(i), t.image = i;
|
||
|
|
} else
|
||
|
|
console.warn("image url/width/height are required");
|
||
|
|
} else
|
||
|
|
t.image && (t.image = void 0);
|
||
|
|
{
|
||
|
|
const n = _.createElement("span");
|
||
|
|
n.className = "text", n.textContent = e.topic, t.appendChild(n), t.text = n;
|
||
|
|
}
|
||
|
|
if (e.hyperLink) {
|
||
|
|
const n = _.createElement("a");
|
||
|
|
n.className = "hyper-link", n.target = "_blank", n.innerText = "🔗", n.href = e.hyperLink, t.appendChild(n), t.linkContainer = n;
|
||
|
|
} else
|
||
|
|
t.linkContainer && (t.linkContainer = void 0);
|
||
|
|
if (e.icons && e.icons.length) {
|
||
|
|
const n = _.createElement("span");
|
||
|
|
n.className = "icons", n.innerHTML = e.icons.map((i) => `<span>${oe(i)}</span>`).join(""), t.appendChild(n), t.icons = n;
|
||
|
|
} else
|
||
|
|
t.icons && (t.icons = void 0);
|
||
|
|
if (e.tags && e.tags.length) {
|
||
|
|
const n = _.createElement("div");
|
||
|
|
n.className = "tags", n.innerHTML = e.tags.map((i) => `<span>${oe(i)}</span>`).join(""), t.appendChild(n), t.tags = n;
|
||
|
|
} else
|
||
|
|
t.tags && (t.tags = void 0);
|
||
|
|
}, Pe = function(t, e) {
|
||
|
|
const n = _.createElement("me-wrapper"), { p: i, tpc: s } = this.createParent(t);
|
||
|
|
if (n.appendChild(i), !e && t.children && t.children.length > 0) {
|
||
|
|
const o = qe(t.expanded);
|
||
|
|
if (i.appendChild(o), t.expanded !== !1) {
|
||
|
|
const r = He(this, t.children);
|
||
|
|
n.appendChild(r);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return { grp: n, top: i, tpc: s };
|
||
|
|
}, Be = function(t) {
|
||
|
|
const e = _.createElement("me-parent"), n = this.createTopic(t);
|
||
|
|
return be(n, t), e.appendChild(n), { p: e, tpc: n };
|
||
|
|
}, ze = function(t) {
|
||
|
|
const e = _.createElement("me-children");
|
||
|
|
return e.append(...t), e;
|
||
|
|
}, Oe = function(t) {
|
||
|
|
const e = _.createElement("me-tpc");
|
||
|
|
return e.nodeObj = t, e.dataset.nodeid = "me" + t.id, e.draggable = this.draggable, e;
|
||
|
|
};
|
||
|
|
function xe(t) {
|
||
|
|
const e = _.createRange();
|
||
|
|
e.selectNodeContents(t);
|
||
|
|
const n = window.getSelection();
|
||
|
|
n && (n.removeAllRanges(), n.addRange(e));
|
||
|
|
}
|
||
|
|
const je = function(t) {
|
||
|
|
if (console.time("editTopic"), !t)
|
||
|
|
return;
|
||
|
|
const e = _.createElement("div"), n = t.text.textContent;
|
||
|
|
t.appendChild(e), e.id = "input-box", e.textContent = n, e.contentEditable = "true", e.spellcheck = !1, e.style.cssText = `min-width:${t.offsetWidth - 8}px;`, this.direction === j && (e.style.right = "0"), e.focus(), xe(e), this.bus.fire("operation", {
|
||
|
|
name: "beginEdit",
|
||
|
|
obj: t.nodeObj
|
||
|
|
}), e.addEventListener("keydown", (i) => {
|
||
|
|
i.stopPropagation();
|
||
|
|
const s = i.key;
|
||
|
|
if (s === "Enter" || s === "Tab") {
|
||
|
|
if (i.shiftKey)
|
||
|
|
return;
|
||
|
|
i.preventDefault(), e == null || e.blur(), this.map.focus();
|
||
|
|
}
|
||
|
|
}), e.addEventListener("blur", () => {
|
||
|
|
var o;
|
||
|
|
if (!e)
|
||
|
|
return;
|
||
|
|
const i = t.nodeObj, s = ((o = e.textContent) == null ? void 0 : o.trim()) || "";
|
||
|
|
console.log(s), s === "" ? i.topic = n : i.topic = s, e.remove(), s !== n && (t.text.textContent = i.topic, this.linkDiv(), this.bus.fire("operation", {
|
||
|
|
name: "finishEdit",
|
||
|
|
obj: i,
|
||
|
|
origin: n
|
||
|
|
}));
|
||
|
|
}), console.timeEnd("editTopic");
|
||
|
|
}, qe = function(t) {
|
||
|
|
const e = _.createElement("me-epd");
|
||
|
|
return e.expanded = t !== !1, e.className = t !== !1 ? "minus" : "", e;
|
||
|
|
}, H = document, P = "http://www.w3.org/2000/svg", Ve = function(t, e) {
|
||
|
|
const n = H.createElementNS(P, "path");
|
||
|
|
return n.setAttribute("d", t), n.setAttribute("stroke", e || "#666"), n.setAttribute("fill", "none"), n.setAttribute("stroke-width", "3"), n;
|
||
|
|
}, W = function(t) {
|
||
|
|
const e = H.createElementNS(P, "svg");
|
||
|
|
return e.setAttribute("class", t), e.setAttribute("overflow", "visible"), e;
|
||
|
|
}, le = function() {
|
||
|
|
const t = H.createElementNS(P, "line");
|
||
|
|
return t.setAttribute("stroke", "#bbb"), t.setAttribute("fill", "none"), t.setAttribute("stroke-width", "2"), t;
|
||
|
|
}, Re = function(t, e) {
|
||
|
|
const n = H.createElementNS(P, "path");
|
||
|
|
return n.setAttribute("d", t), n.setAttribute("stroke", e || "#555"), n.setAttribute("fill", "none"), n.setAttribute("stroke-linecap", "square"), n.setAttribute("stroke-width", "2"), n;
|
||
|
|
}, We = function(t, e) {
|
||
|
|
const n = {
|
||
|
|
stroke: "rgb(235, 95, 82)",
|
||
|
|
fill: "none",
|
||
|
|
"stroke-linecap": "cap",
|
||
|
|
"stroke-width": "2"
|
||
|
|
}, i = H.createElementNS(P, "g"), s = H.createElementNS(P, "path"), o = H.createElementNS(P, "path");
|
||
|
|
return w(o, {
|
||
|
|
d: e,
|
||
|
|
...n
|
||
|
|
}), w(s, {
|
||
|
|
d: t,
|
||
|
|
...n,
|
||
|
|
"stroke-dasharray": "8,2"
|
||
|
|
}), i.appendChild(s), i.appendChild(o), i;
|
||
|
|
}, we = function(t, e, n) {
|
||
|
|
if (console.time("editSummary"), !e)
|
||
|
|
return;
|
||
|
|
const i = document.createElement("div");
|
||
|
|
t.nodes.appendChild(i);
|
||
|
|
const s = e.innerHTML;
|
||
|
|
i.id = "input-box", i.textContent = s, i.contentEditable = "true", i.spellcheck = !1;
|
||
|
|
const o = e.getAttribute("x") + "px", r = e.getAttribute("y") + "px";
|
||
|
|
i.style.cssText = `min-width:${100 - 8}px;position:absolute;left:${o};top:${r};`;
|
||
|
|
const l = e.getAttribute("text-anchor");
|
||
|
|
l === "end" ? i.style.cssText += "transform: translate(-100%, -100%);" : l === "middle" ? i.style.cssText += "transform: translate(-50%, -100%);" : i.style.cssText += "transform: translate(0, -100%);", i.focus(), xe(i), i.addEventListener("keydown", (c) => {
|
||
|
|
c.stopPropagation();
|
||
|
|
const u = c.key;
|
||
|
|
if (u === "Enter" || u === "Tab") {
|
||
|
|
if (c.shiftKey)
|
||
|
|
return;
|
||
|
|
c.preventDefault(), i.blur(), t.map.focus();
|
||
|
|
}
|
||
|
|
}), i.addEventListener("blur", () => {
|
||
|
|
i && n(i);
|
||
|
|
}), console.timeEnd("editSummary");
|
||
|
|
};
|
||
|
|
let _e = Ce;
|
||
|
|
const Fe = function(t) {
|
||
|
|
console.time("linkDiv");
|
||
|
|
const e = this.map.querySelector("me-root");
|
||
|
|
this.nodes.style.top = `${1e4 - this.nodes.offsetHeight / 2}px`, this.nodes.style.left = `${1e4 - e.offsetLeft - e.offsetWidth / 2}px`;
|
||
|
|
const n = this.map.querySelectorAll("me-main > me-wrapper");
|
||
|
|
this.lines.innerHTML = "", _e = this.subLinkStyle === 2 ? Xe : Ce;
|
||
|
|
for (let i = 0; i < n.length; i++) {
|
||
|
|
const s = n[i], o = s.querySelector("me-tpc"), r = s.firstChild, l = s.parentNode.className;
|
||
|
|
let c = e.offsetLeft + e.offsetWidth / 2;
|
||
|
|
const u = e.offsetTop + e.offsetHeight / 2;
|
||
|
|
let h;
|
||
|
|
const d = this.theme.palette, a = o.nodeObj.branchColor || d[i % d.length], { offsetLeft: f, offsetTop: g } = q(this.nodes, r);
|
||
|
|
l === "lhs" ? h = f + r.offsetWidth : h = f;
|
||
|
|
const p = g + r.offsetHeight / 2;
|
||
|
|
let m = "";
|
||
|
|
if (this.mainLinkStyle === 2)
|
||
|
|
this.direction === Q && (l === "lhs" ? c = c - e.offsetWidth / 6 : c = c + e.offsetWidth / 6), m = Ie({ x1: c, y1: u, x2: h, y2: p });
|
||
|
|
else {
|
||
|
|
const x = (1 - Math.abs(p - s.parentElement.offsetTop - s.parentElement.offsetHeight / 2) / s.parentElement.offsetHeight) * 0.25 * (e.offsetWidth / 2);
|
||
|
|
l === "lhs" ? c = c - e.offsetWidth / 10 - x : c = c + e.offsetWidth / 10 + x, m = Ye({ x1: c, y1: u, x2: h, y2: p });
|
||
|
|
}
|
||
|
|
this.lines.appendChild(Ve(m, a));
|
||
|
|
const v = s.children[0].children[1];
|
||
|
|
if (v && (v.style.top = (v.parentNode.offsetHeight - v.offsetHeight) / 2 + "px", l === "lhs" ? v.style.left = "-10px" : v.style.right = "-10px"), !(t && t !== s) && s.childElementCount) {
|
||
|
|
const y = W("subLines"), x = s.lastChild;
|
||
|
|
x.tagName === "svg" && x.remove(), s.appendChild(y);
|
||
|
|
const E = s.firstChild, C = s.children[1].children, F = Ee(C, E, l, !0);
|
||
|
|
y.appendChild(Re(F, a));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.renderCustomLink(), this.renderSummary(), console.timeEnd("linkDiv");
|
||
|
|
}, Ee = function(t, e, n, i) {
|
||
|
|
let s = "";
|
||
|
|
const o = e.offsetTop, r = e.offsetLeft, l = e.offsetWidth, c = e.offsetHeight;
|
||
|
|
for (let u = 0; u < t.length; u++) {
|
||
|
|
const h = t[u], d = h.firstChild, a = d.offsetTop, f = d.offsetLeft, g = d.offsetWidth, p = d.offsetHeight;
|
||
|
|
s += _e({ pT: o, pL: r, pW: l, pH: c, cT: a, cL: f, cW: g, cH: p, direction: n, isFirst: i });
|
||
|
|
const m = d.children[1];
|
||
|
|
if (m) {
|
||
|
|
if (m.style.bottom = -(m.offsetHeight / 2) + "px", n === "lhs" ? m.style.left = "10px" : n === "rhs" && (m.style.right = "10px"), !m.expanded)
|
||
|
|
continue;
|
||
|
|
} else
|
||
|
|
continue;
|
||
|
|
const v = h.children[1].children;
|
||
|
|
v.length > 0 && (s += Ee(v, d, n));
|
||
|
|
}
|
||
|
|
return s;
|
||
|
|
};
|
||
|
|
function Ie({ x1: t, y1: e, x2: n, y2: i }) {
|
||
|
|
return `M ${t} ${e} V ${i > e ? i - 20 : i + 20} C ${t} ${i} ${t} ${i} ${n > t ? t + 20 : t - 20} ${i} H ${n}`;
|
||
|
|
}
|
||
|
|
function Ye({ x1: t, y1: e, x2: n, y2: i }) {
|
||
|
|
return `M ${t} ${e} Q ${t} ${i} ${n} ${i}`;
|
||
|
|
}
|
||
|
|
function Xe({ pT: t, pL: e, pW: n, pH: i, cT: s, cL: o, cW: r, cH: l, direction: c, isFirst: u }) {
|
||
|
|
let h;
|
||
|
|
u ? h = t + i / 2 : h = t + i;
|
||
|
|
const d = s + l;
|
||
|
|
let a = 0, f = 0, g = 0;
|
||
|
|
return c === "lhs" ? (a = e + k, f = o, g = o + r) : c === "rhs" && (a = e + n - k, f = o + r, g = o), d < h + 50 && d > h - 50 ? `M ${a} ${h} H ${g} V ${d} H ${f}` : d >= h ? `M ${a} ${h} H ${g} V ${d - S} A ${S} ${S} 0 0 ${a > f ? 1 : 0} ${a > f ? g - S : g + S} ${d} H ${f}` : `M ${a} ${h} H ${g} V ${d + S} A ${S} ${S} 0 0 ${a > f ? 0 : 1} ${a > f ? g - S : g + S} ${d} H ${f}`;
|
||
|
|
}
|
||
|
|
function Ce({ pT: t, pL: e, pW: n, pH: i, cT: s, cL: o, cW: r, cH: l, direction: c, isFirst: u }) {
|
||
|
|
let h = 0, d = 0;
|
||
|
|
u ? h = t + i / 2 : h = t + i;
|
||
|
|
const a = s + l;
|
||
|
|
let f = 0, g = 0, p = 0;
|
||
|
|
const m = Math.min(Math.abs(h - a) / 800, 1.2) * k;
|
||
|
|
return c === "lhs" ? (p = e, f = p + k, g = p - k, d = o + k, `M ${f} ${h} C ${p} ${h} ${p + m} ${a} ${g} ${a} H ${d}`) : (p = e + n, f = p - k, g = p + k, d = o + r - k, `M ${f} ${h} C ${p} ${h} ${p - m} ${a} ${g} ${a} H ${d}`);
|
||
|
|
}
|
||
|
|
const A = (t, e) => {
|
||
|
|
const n = document.createElement("span");
|
||
|
|
return n.id = t, n.innerHTML = `<svg class="icon" aria-hidden="true">
|
||
|
|
<use xlink:href="#icon-${e}"></use>
|
||
|
|
</svg>`, n;
|
||
|
|
};
|
||
|
|
function Ge(t) {
|
||
|
|
const e = document.createElement("div"), n = A("fullscreen", "full"), i = A("toCenter", "living"), s = A("zoomout", "move"), o = A("zoomin", "add"), r = document.createElement("span");
|
||
|
|
return r.innerText = "100%", e.appendChild(n), e.appendChild(i), e.appendChild(s), e.appendChild(o), e.className = "mind-elixir-toolbar rb", n.onclick = () => {
|
||
|
|
t.container.requestFullscreen();
|
||
|
|
}, i.onclick = () => {
|
||
|
|
t.toCenter();
|
||
|
|
}, s.onclick = () => {
|
||
|
|
t.scaleVal < 0.6 || t.scale(t.scaleVal -= 0.2);
|
||
|
|
}, o.onclick = () => {
|
||
|
|
t.scaleVal > 1.6 || t.scale(t.scaleVal += 0.2);
|
||
|
|
}, e;
|
||
|
|
}
|
||
|
|
function Ue(t) {
|
||
|
|
const e = document.createElement("div"), n = A("tbltl", "left"), i = A("tbltr", "right"), s = A("tblts", "side");
|
||
|
|
return e.appendChild(n), e.appendChild(i), e.appendChild(s), e.className = "mind-elixir-toolbar lt", n.onclick = () => {
|
||
|
|
t.initLeft();
|
||
|
|
}, i.onclick = () => {
|
||
|
|
t.initRight();
|
||
|
|
}, s.onclick = () => {
|
||
|
|
t.initSide();
|
||
|
|
}, e;
|
||
|
|
}
|
||
|
|
function Ke(t) {
|
||
|
|
t.container.append(Ge(t)), t.container.append(Ue(t));
|
||
|
|
}
|
||
|
|
/*! @viselect/vanilla v3.3.1 MIT | https://github.com/Simonwep/selection/tree/master/packages/vanilla */
|
||
|
|
var Je = Object.defineProperty, Qe = (t, e, n) => e in t ? Je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, b = (t, e, n) => (Qe(t, typeof e != "symbol" ? e + "" : e, n), n);
|
||
|
|
class Ze {
|
||
|
|
constructor() {
|
||
|
|
b(this, "_listeners", /* @__PURE__ */ new Map()), b(this, "on", this.addEventListener), b(this, "off", this.removeEventListener), b(this, "emit", this.dispatchEvent);
|
||
|
|
}
|
||
|
|
addEventListener(e, n) {
|
||
|
|
const i = this._listeners.get(e) ?? /* @__PURE__ */ new Set();
|
||
|
|
return this._listeners.set(e, i), i.add(n), this;
|
||
|
|
}
|
||
|
|
removeEventListener(e, n) {
|
||
|
|
var i;
|
||
|
|
return (i = this._listeners.get(e)) == null || i.delete(n), this;
|
||
|
|
}
|
||
|
|
dispatchEvent(e, ...n) {
|
||
|
|
let i = !0;
|
||
|
|
for (const s of this._listeners.get(e) ?? [])
|
||
|
|
i = s(...n) !== !1 && i;
|
||
|
|
return i;
|
||
|
|
}
|
||
|
|
unbindAllListeners() {
|
||
|
|
this._listeners.clear();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
const ce = (t, e = "px") => typeof t == "number" ? t + e : t;
|
||
|
|
function $({ style: t }, e, n) {
|
||
|
|
if (typeof e == "object")
|
||
|
|
for (const [i, s] of Object.entries(e))
|
||
|
|
s !== void 0 && (t[i] = ce(s));
|
||
|
|
else
|
||
|
|
n !== void 0 && (t[e] = ce(n));
|
||
|
|
}
|
||
|
|
function Le(t) {
|
||
|
|
return (e, n, i, s = {}) => {
|
||
|
|
e instanceof HTMLCollection || e instanceof NodeList ? e = Array.from(e) : Array.isArray(e) || (e = [e]), Array.isArray(n) || (n = [n]);
|
||
|
|
for (const o of e)
|
||
|
|
for (const r of n)
|
||
|
|
o[t](r, i, { capture: !1, ...s });
|
||
|
|
return [e, n, i, s];
|
||
|
|
};
|
||
|
|
}
|
||
|
|
const B = Le("addEventListener"), T = Le("removeEventListener"), X = (t) => {
|
||
|
|
var e;
|
||
|
|
const { clientX: n, clientY: i, target: s } = ((e = t.touches) == null ? void 0 : e[0]) ?? t;
|
||
|
|
return { x: n, y: i, target: s };
|
||
|
|
};
|
||
|
|
function ae(t, e, n = "touch") {
|
||
|
|
switch (n) {
|
||
|
|
case "center": {
|
||
|
|
const i = e.left + e.width / 2, s = e.top + e.height / 2;
|
||
|
|
return i >= t.left && i <= t.right && s >= t.top && s <= t.bottom;
|
||
|
|
}
|
||
|
|
case "cover":
|
||
|
|
return e.left >= t.left && e.top >= t.top && e.right <= t.right && e.bottom <= t.bottom;
|
||
|
|
case "touch":
|
||
|
|
return t.right >= e.left && t.left <= e.right && t.bottom >= e.top && t.top <= e.bottom;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function z(t, e = document) {
|
||
|
|
const n = Array.isArray(t) ? t : [t];
|
||
|
|
let i = [];
|
||
|
|
for (let s = 0, o = n.length; s < o; s++) {
|
||
|
|
const r = n[s];
|
||
|
|
typeof r == "string" ? i = i.concat(Array.from(e.querySelectorAll(r))) : r instanceof Element && i.push(r);
|
||
|
|
}
|
||
|
|
return i;
|
||
|
|
}
|
||
|
|
const et = () => matchMedia("(hover: none), (pointer: coarse)").matches, tt = () => "safari" in window, nt = (t) => {
|
||
|
|
let e, n = -1, i = !1;
|
||
|
|
return {
|
||
|
|
next(...s) {
|
||
|
|
e = s, i || (i = !0, n = requestAnimationFrame(() => {
|
||
|
|
t(...e), i = !1;
|
||
|
|
}));
|
||
|
|
},
|
||
|
|
cancel() {
|
||
|
|
cancelAnimationFrame(n), i = !1;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
}, { abs: D, max: he, min: de, ceil: ue } = Math;
|
||
|
|
class it extends Ze {
|
||
|
|
constructor(e) {
|
||
|
|
var n, i, s, o, r;
|
||
|
|
super(), b(this, "_options"), b(this, "_selection", {
|
||
|
|
stored: [],
|
||
|
|
selected: [],
|
||
|
|
touched: [],
|
||
|
|
changed: {
|
||
|
|
added: [],
|
||
|
|
// Added elements since last selection
|
||
|
|
removed: []
|
||
|
|
// Removed elements since last selection
|
||
|
|
}
|
||
|
|
}), b(this, "_area"), b(this, "_clippingElement"), b(this, "_targetElement"), b(this, "_targetRect"), b(this, "_selectables", []), b(this, "_latestElement"), b(this, "_areaRect", new DOMRect()), b(this, "_areaLocation", { y1: 0, x2: 0, y2: 0, x1: 0 }), b(this, "_singleClick", !0), b(this, "_frame"), b(this, "_scrollAvailable", !0), b(this, "_scrollingActive", !1), b(this, "_scrollSpeed", { x: 0, y: 0 }), b(this, "_scrollDelta", { x: 0, y: 0 }), b(this, "disable", this._bindStartEvents.bind(this, !1)), b(this, "enable", this._bindStartEvents), this._options = {
|
||
|
|
selectionAreaClass: "selection-area",
|
||
|
|
selectionContainerClass: void 0,
|
||
|
|
selectables: [],
|
||
|
|
document: window.document,
|
||
|
|
startAreas: ["html"],
|
||
|
|
boundaries: ["html"],
|
||
|
|
container: "body",
|
||
|
|
...e,
|
||
|
|
behaviour: {
|
||
|
|
overlap: "invert",
|
||
|
|
intersect: "touch",
|
||
|
|
...e.behaviour,
|
||
|
|
startThreshold: (n = e.behaviour) != null && n.startThreshold ? typeof e.behaviour.startThreshold == "number" ? e.behaviour.startThreshold : { x: 10, y: 10, ...e.behaviour.startThreshold } : { x: 10, y: 10 },
|
||
|
|
scrolling: {
|
||
|
|
speedDivider: 10,
|
||
|
|
manualSpeed: 750,
|
||
|
|
...(i = e.behaviour) == null ? void 0 : i.scrolling,
|
||
|
|
startScrollMargins: {
|
||
|
|
x: 0,
|
||
|
|
y: 0,
|
||
|
|
...(o = (s = e.behaviour) == null ? void 0 : s.scrolling) == null ? void 0 : o.startScrollMargins
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
features: {
|
||
|
|
range: !0,
|
||
|
|
touch: !0,
|
||
|
|
...e.features,
|
||
|
|
singleTap: {
|
||
|
|
allow: !0,
|
||
|
|
intersect: "native",
|
||
|
|
...(r = e.features) == null ? void 0 : r.singleTap
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
for (const h of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))
|
||
|
|
typeof this[h] == "function" && (this[h] = this[h].bind(this));
|
||
|
|
const { document: l, selectionAreaClass: c, selectionContainerClass: u } = this._options;
|
||
|
|
this._area = l.createElement("div"), this._clippingElement = l.createElement("div"), this._clippingElement.appendChild(this._area), this._area.classList.add(c), u && this._clippingElement.classList.add(u), $(this._area, {
|
||
|
|
willChange: "top, left, bottom, right, width, height",
|
||
|
|
top: 0,
|
||
|
|
left: 0,
|
||
|
|
position: "fixed"
|
||
|
|
}), $(this._clippingElement, {
|
||
|
|
overflow: "hidden",
|
||
|
|
position: "fixed",
|
||
|
|
transform: "translate3d(0, 0, 0)",
|
||
|
|
// https://stackoverflow.com/a/38268846
|
||
|
|
pointerEvents: "none",
|
||
|
|
zIndex: "1"
|
||
|
|
}), this._frame = nt((h) => {
|
||
|
|
this._recalculateSelectionAreaRect(), this._updateElementSelection(), this._emitEvent("move", h), this._redrawSelectionArea();
|
||
|
|
}), this.enable();
|
||
|
|
}
|
||
|
|
_bindStartEvents(e = !0) {
|
||
|
|
const { document: n, features: i } = this._options, s = e ? B : T;
|
||
|
|
s(n, "mousedown", this._onTapStart), i.touch && s(n, "touchstart", this._onTapStart, {
|
||
|
|
passive: !1
|
||
|
|
});
|
||
|
|
}
|
||
|
|
_onTapStart(e, n = !1) {
|
||
|
|
const { x: i, y: s, target: o } = X(e), { _options: r } = this, { document: l } = this._options, c = o.getBoundingClientRect(), u = z(r.startAreas, r.document), h = z(r.boundaries, r.document);
|
||
|
|
this._targetElement = h.find(
|
||
|
|
(f) => ae(f.getBoundingClientRect(), c)
|
||
|
|
);
|
||
|
|
const d = e.composedPath();
|
||
|
|
if (!this._targetElement || !u.find((f) => d.includes(f)) || !h.find((f) => d.includes(f)) || !n && this._emitEvent("beforestart", e) === !1)
|
||
|
|
return;
|
||
|
|
this._areaLocation = { x1: i, y1: s, x2: 0, y2: 0 };
|
||
|
|
const a = l.scrollingElement ?? l.body;
|
||
|
|
this._scrollDelta = { x: a.scrollLeft, y: a.scrollTop }, this._singleClick = !0, this.clearSelection(!1, !0), B(l, ["touchmove", "mousemove"], this._delayedTapMove, { passive: !1 }), B(l, ["mouseup", "touchcancel", "touchend"], this._onTapStop), B(l, "scroll", this._onScroll);
|
||
|
|
}
|
||
|
|
_onSingleTap(e) {
|
||
|
|
const { singleTap: { intersect: n }, range: i } = this._options.features, s = X(e);
|
||
|
|
let o;
|
||
|
|
if (n === "native")
|
||
|
|
o = s.target;
|
||
|
|
else if (n === "touch") {
|
||
|
|
this.resolveSelectables();
|
||
|
|
const { x: l, y: c } = s;
|
||
|
|
o = this._selectables.find((u) => {
|
||
|
|
const { right: h, left: d, top: a, bottom: f } = u.getBoundingClientRect();
|
||
|
|
return l < h && l > d && c < f && c > a;
|
||
|
|
});
|
||
|
|
}
|
||
|
|
if (!o)
|
||
|
|
return;
|
||
|
|
for (this.resolveSelectables(); !this._selectables.includes(o); ) {
|
||
|
|
if (!o.parentElement)
|
||
|
|
return;
|
||
|
|
o = o.parentElement;
|
||
|
|
}
|
||
|
|
const { stored: r } = this._selection;
|
||
|
|
if (this._emitEvent("start", e), e.shiftKey && i && this._latestElement) {
|
||
|
|
const l = this._latestElement, [c, u] = l.compareDocumentPosition(o) & 4 ? [o, l] : [l, o], h = [...this._selectables.filter(
|
||
|
|
(d) => d.compareDocumentPosition(c) & 4 && d.compareDocumentPosition(u) & 2
|
||
|
|
), c, u];
|
||
|
|
this.select(h), this._latestElement = l;
|
||
|
|
} else
|
||
|
|
r.includes(o) && (r.length === 1 || e.ctrlKey || r.every((l) => this._selection.stored.includes(l))) ? this.deselect(o) : (this.select(o), this._latestElement = o);
|
||
|
|
this._emitEvent("stop", e);
|
||
|
|
}
|
||
|
|
_delayedTapMove(e) {
|
||
|
|
const { container: n, document: i, behaviour: { startThreshold: s } } = this._options, { x1: o, y1: r } = this._areaLocation, { x: l, y: c } = X(e);
|
||
|
|
if (
|
||
|
|
// Single number for both coordinates
|
||
|
|
typeof s == "number" && D(l + c - (o + r)) >= s || // Different x and y threshold
|
||
|
|
typeof s == "object" && D(l - o) >= s.x || D(c - r) >= s.y
|
||
|
|
) {
|
||
|
|
if (T(i, ["mousemove", "touchmove"], this._delayedTapMove, { passive: !1 }), this._emitEvent("beforedrag", e) === !1) {
|
||
|
|
T(i, ["mouseup", "touchcancel", "touchend"], this._onTapStop);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
B(i, ["mousemove", "touchmove"], this._onTapMove, { passive: !1 }), $(this._area, "display", "block"), z(n, i)[0].appendChild(this._clippingElement), this.resolveSelectables(), this._singleClick = !1, this._targetRect = this._targetElement.getBoundingClientRect(), this._scrollAvailable = this._targetElement.scrollHeight !== this._targetElement.clientHeight || this._targetElement.scrollWidth !== this._targetElement.clientWidth, this._scrollAvailable && (B(i, "wheel", this._manualScroll, { passive: !1 }), this._selectables = this._selectables.filter((u) => this._targetElement.contains(u))), this._setupSelectionArea(), this._emitEvent("start", e), this._onTapMove(e);
|
||
|
|
}
|
||
|
|
this._handleMoveEvent(e);
|
||
|
|
}
|
||
|
|
_setupSelectionArea() {
|
||
|
|
const { _clippingElement: e, _targetElement: n, _area: i } = this, s = this._targetRect = n.getBoundingClientRect();
|
||
|
|
this._scrollAvailable ? ($(e, {
|
||
|
|
top: s.top,
|
||
|
|
left: s.left,
|
||
|
|
width: s.width,
|
||
|
|
height: s.height
|
||
|
|
}), $(i, {
|
||
|
|
marginTop: -s.top,
|
||
|
|
marginLeft: -s.left
|
||
|
|
})) : ($(e, {
|
||
|
|
top: 0,
|
||
|
|
left: 0,
|
||
|
|
width: "100%",
|
||
|
|
height: "100%"
|
||
|
|
}), $(i, {
|
||
|
|
marginTop: 0,
|
||
|
|
marginLeft: 0
|
||
|
|
}));
|
||
|
|
}
|
||
|
|
_onTapMove(e) {
|
||
|
|
const { x: n, y: i } = X(e), { _scrollSpeed: s, _areaLocation: o, _options: r, _frame: l } = this, { speedDivider: c } = r.behaviour.scrolling, u = this._targetElement;
|
||
|
|
if (o.x2 = n, o.y2 = i, this._scrollAvailable && !this._scrollingActive && (s.y || s.x)) {
|
||
|
|
this._scrollingActive = !0;
|
||
|
|
const h = () => {
|
||
|
|
if (!s.x && !s.y) {
|
||
|
|
this._scrollingActive = !1;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
const { scrollTop: d, scrollLeft: a } = u;
|
||
|
|
s.y && (u.scrollTop += ue(s.y / c), o.y1 -= u.scrollTop - d), s.x && (u.scrollLeft += ue(s.x / c), o.x1 -= u.scrollLeft - a), l.next(e), requestAnimationFrame(h);
|
||
|
|
};
|
||
|
|
requestAnimationFrame(h);
|
||
|
|
} else
|
||
|
|
l.next(e);
|
||
|
|
this._handleMoveEvent(e);
|
||
|
|
}
|
||
|
|
_handleMoveEvent(e) {
|
||
|
|
const { features: n } = this._options;
|
||
|
|
(n.touch && et() || this._scrollAvailable && tt()) && e.preventDefault();
|
||
|
|
}
|
||
|
|
_onScroll() {
|
||
|
|
const { _scrollDelta: e, _options: { document: n } } = this, { scrollTop: i, scrollLeft: s } = n.scrollingElement ?? n.body;
|
||
|
|
this._areaLocation.x1 += e.x - s, this._areaLocation.y1 += e.y - i, e.x = s, e.y = i, this._setupSelectionArea(), this._frame.next(null);
|
||
|
|
}
|
||
|
|
_manualScroll(e) {
|
||
|
|
const { manualSpeed: n } = this._options.behaviour.scrolling, i = e.deltaY ? e.deltaY > 0 ? 1 : -1 : 0, s = e.deltaX ? e.deltaX > 0 ? 1 : -1 : 0;
|
||
|
|
this._scrollSpeed.y += i * n, this._scrollSpeed.x += s * n, this._onTapMove(e), e.preventDefault();
|
||
|
|
}
|
||
|
|
_recalculateSelectionAreaRect() {
|
||
|
|
const { _scrollSpeed: e, _areaLocation: n, _areaRect: i, _targetElement: s, _options: o } = this, { scrollTop: r, scrollHeight: l, clientHeight: c, scrollLeft: u, scrollWidth: h, clientWidth: d } = s, a = this._targetRect, { x1: f, y1: g } = n;
|
||
|
|
let { x2: p, y2: m } = n;
|
||
|
|
const { behaviour: { scrolling: { startScrollMargins: v } } } = o;
|
||
|
|
p < a.left + v.x ? (e.x = u ? -D(a.left - p + v.x) : 0, p = p < a.left ? a.left : p) : p > a.right - v.x ? (e.x = h - u - d ? D(a.left + a.width - p - v.x) : 0, p = p > a.right ? a.right : p) : e.x = 0, m < a.top + v.y ? (e.y = r ? -D(a.top - m + v.y) : 0, m = m < a.top ? a.top : m) : m > a.bottom - v.y ? (e.y = l - r - c ? D(a.top + a.height - m - v.y) : 0, m = m > a.bottom ? a.bottom : m) : e.y = 0;
|
||
|
|
const y = de(f, p), x = de(g, m), E = he(f, p), C = he(g, m);
|
||
|
|
i.x = y, i.y = x, i.width = E - y, i.height = C - x;
|
||
|
|
}
|
||
|
|
_redrawSelectionArea() {
|
||
|
|
const { x: e, y: n, width: i, height: s } = this._areaRect, { style: o } = this._area;
|
||
|
|
o.left = `${e}px`, o.top = `${n}px`, o.width = `${i}px`, o.height = `${s}px`;
|
||
|
|
}
|
||
|
|
_onTapStop(e, n) {
|
||
|
|
var i;
|
||
|
|
const { document: s, features: o } = this._options, { _singleClick: r } = this;
|
||
|
|
T(s, ["mousemove", "touchmove"], this._delayedTapMove), T(s, ["touchmove", "mousemove"], this._onTapMove), T(s, ["mouseup", "touchcancel", "touchend"], this._onTapStop), T(s, "scroll", this._onScroll), this._keepSelection(), e && r && o.singleTap.allow ? this._onSingleTap(e) : !r && !n && (this._updateElementSelection(), this._emitEvent("stop", e)), this._scrollSpeed.x = 0, this._scrollSpeed.y = 0, this._scrollAvailable && T(s, "wheel", this._manualScroll, { passive: !0 }), this._clippingElement.remove(), (i = this._frame) == null || i.cancel(), $(this._area, "display", "none");
|
||
|
|
}
|
||
|
|
_updateElementSelection() {
|
||
|
|
const { _selectables: e, _options: n, _selection: i, _areaRect: s } = this, { stored: o, selected: r, touched: l } = i, { intersect: c, overlap: u } = n.behaviour, h = u === "invert", d = [], a = [], f = [];
|
||
|
|
for (let p = 0; p < e.length; p++) {
|
||
|
|
const m = e[p];
|
||
|
|
if (ae(s, m.getBoundingClientRect(), c)) {
|
||
|
|
if (r.includes(m))
|
||
|
|
o.includes(m) && !l.includes(m) && l.push(m);
|
||
|
|
else if (h && o.includes(m)) {
|
||
|
|
f.push(m);
|
||
|
|
continue;
|
||
|
|
} else
|
||
|
|
a.push(m);
|
||
|
|
d.push(m);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
h && a.push(...o.filter((p) => !r.includes(p)));
|
||
|
|
const g = u === "keep";
|
||
|
|
for (let p = 0; p < r.length; p++) {
|
||
|
|
const m = r[p];
|
||
|
|
!d.includes(m) && !// Check if user wants to keep previously selected elements, e.g.
|
||
|
|
// not make them part of the current selection as soon as they're touched.
|
||
|
|
(g && o.includes(m)) && f.push(m);
|
||
|
|
}
|
||
|
|
i.selected = d, i.changed = { added: a, removed: f }, this._latestElement = void 0;
|
||
|
|
}
|
||
|
|
_emitEvent(e, n) {
|
||
|
|
return this.emit(e, {
|
||
|
|
event: n,
|
||
|
|
store: this._selection,
|
||
|
|
selection: this
|
||
|
|
});
|
||
|
|
}
|
||
|
|
_keepSelection() {
|
||
|
|
const { _options: e, _selection: n } = this, { selected: i, changed: s, touched: o, stored: r } = n, l = i.filter((c) => !r.includes(c));
|
||
|
|
switch (e.behaviour.overlap) {
|
||
|
|
case "drop": {
|
||
|
|
n.stored = [
|
||
|
|
...l,
|
||
|
|
...r.filter((c) => !o.includes(c))
|
||
|
|
// Elements not touched
|
||
|
|
];
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
case "invert": {
|
||
|
|
n.stored = [
|
||
|
|
...l,
|
||
|
|
...r.filter((c) => !s.removed.includes(c))
|
||
|
|
// Elements not removed from selection
|
||
|
|
];
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
case "keep": {
|
||
|
|
n.stored = [
|
||
|
|
...r,
|
||
|
|
...i.filter((c) => !r.includes(c))
|
||
|
|
// Newly added
|
||
|
|
];
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Manually triggers the start of a selection
|
||
|
|
* @param evt A MouseEvent / TouchEvent -like object
|
||
|
|
* @param silent If beforestart should be fired,
|
||
|
|
*/
|
||
|
|
trigger(e, n = !0) {
|
||
|
|
this._onTapStart(e, n);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Can be used if during a selection elements have been added.
|
||
|
|
* Will update everything which can be selected.
|
||
|
|
*/
|
||
|
|
resolveSelectables() {
|
||
|
|
this._selectables = z(this._options.selectables, this._options.document);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Same as deselect, but for all elements currently selected.
|
||
|
|
* @param includeStored If the store should also get cleared
|
||
|
|
* @param quiet If move / stop events should be fired
|
||
|
|
*/
|
||
|
|
clearSelection(e = !0, n = !1) {
|
||
|
|
const { selected: i, stored: s, changed: o } = this._selection;
|
||
|
|
o.added = [], o.removed.push(
|
||
|
|
...i,
|
||
|
|
...e ? s : []
|
||
|
|
), n || (this._emitEvent("move", null), this._emitEvent("stop", null)), this._selection = {
|
||
|
|
stored: e ? [] : s,
|
||
|
|
selected: [],
|
||
|
|
touched: [],
|
||
|
|
changed: { added: [], removed: [] }
|
||
|
|
};
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* @returns {Array} Selected elements
|
||
|
|
*/
|
||
|
|
getSelection() {
|
||
|
|
return this._selection.stored;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* @returns {HTMLElement} The selection area element
|
||
|
|
*/
|
||
|
|
getSelectionArea() {
|
||
|
|
return this._area;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Cancel the current selection process.
|
||
|
|
* @param keepEvent {boolean} true to fire a stop event after cancel.
|
||
|
|
*/
|
||
|
|
cancel(e = !1) {
|
||
|
|
this._onTapStop(null, !e);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Unbinds all events and removes the area-element.
|
||
|
|
*/
|
||
|
|
destroy() {
|
||
|
|
this.cancel(), this.disable(), this._clippingElement.remove(), super.unbindAllListeners();
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Adds elements to the selection
|
||
|
|
* @param query - CSS Query, can be an array of queries
|
||
|
|
* @param quiet - If this should not trigger the move event
|
||
|
|
*/
|
||
|
|
select(e, n = !1) {
|
||
|
|
const { changed: i, selected: s, stored: o } = this._selection, r = z(e, this._options.document).filter(
|
||
|
|
(l) => !s.includes(l) && !o.includes(l)
|
||
|
|
);
|
||
|
|
return o.push(...r), s.push(...r), i.added.push(...r), i.removed = [], this._latestElement = void 0, n || (this._emitEvent("move", null), this._emitEvent("stop", null)), r;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Removes a particular element from the selection.
|
||
|
|
* @param query - CSS Query, can be an array of queries
|
||
|
|
* @param quiet - If this should not trigger the move event
|
||
|
|
*/
|
||
|
|
deselect(e, n = !1) {
|
||
|
|
const { selected: i, stored: s, changed: o } = this._selection, r = z(e, this._options.document).filter(
|
||
|
|
(l) => i.includes(l) || s.includes(l)
|
||
|
|
);
|
||
|
|
r.length && (this._selection.stored = s.filter((l) => !r.includes(l)), this._selection.selected = i.filter((l) => !r.includes(l)), this._selection.changed.added = [], this._selection.changed.removed.push(
|
||
|
|
...r.filter((l) => !o.removed.includes(l))
|
||
|
|
), this._latestElement = void 0, n || (this._emitEvent("move", null), this._emitEvent("stop", null)));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
b(it, "version", "3.3.1");
|
||
|
|
const st = function(t, e = !0) {
|
||
|
|
this.theme = t;
|
||
|
|
const n = this.theme.cssVar, i = Object.keys(n);
|
||
|
|
for (let s = 0; s < i.length; s++) {
|
||
|
|
const o = i[s];
|
||
|
|
this.mindElixirBox.style.setProperty(o, n[o]);
|
||
|
|
}
|
||
|
|
e && this.refresh();
|
||
|
|
};
|
||
|
|
function Se(t) {
|
||
|
|
return {
|
||
|
|
nodeData: t.isFocusMode ? t.nodeDataBackup : t.nodeData,
|
||
|
|
linkData: t.linkData,
|
||
|
|
summaries: t.summaries,
|
||
|
|
direction: t.direction,
|
||
|
|
theme: t.theme
|
||
|
|
};
|
||
|
|
}
|
||
|
|
const ot = function(t, e, n) {
|
||
|
|
if (t) {
|
||
|
|
if (console.time("selectNode"), typeof t == "string") {
|
||
|
|
const i = L(t);
|
||
|
|
return i ? this.selectNode(i) : void 0;
|
||
|
|
}
|
||
|
|
this.currentNode && (this.currentNode.className = ""), t.className = "selected", t.scrollIntoView({ block: "nearest", inline: "nearest" }), this.currentNode = t, e ? this.bus.fire("selectNewNode", t.nodeObj) : this.bus.fire("selectNode", t.nodeObj, n), console.timeEnd("selectNode");
|
||
|
|
}
|
||
|
|
}, rt = function() {
|
||
|
|
this.currentNode && (this.currentNode.className = ""), this.currentNode = null, this.bus.fire("unselectNode");
|
||
|
|
}, lt = function(t) {
|
||
|
|
if (t) {
|
||
|
|
console.time("selectNodes");
|
||
|
|
for (const e of t)
|
||
|
|
e.className = "selected";
|
||
|
|
this.currentNodes = t, this.bus.fire(
|
||
|
|
"selectNodes",
|
||
|
|
t.map((e) => e.nodeObj)
|
||
|
|
), console.timeEnd("selectNodes");
|
||
|
|
}
|
||
|
|
}, ct = function() {
|
||
|
|
if (this.currentNodes)
|
||
|
|
for (const t of this.currentNodes)
|
||
|
|
t.classList.remove("selected");
|
||
|
|
this.currentNodes = null, this.bus.fire("unselectNodes");
|
||
|
|
}, at = function() {
|
||
|
|
if (!this.currentNode || this.currentNode.dataset.nodeid === "meroot")
|
||
|
|
return !1;
|
||
|
|
const t = this.currentNode.parentElement.parentElement.nextSibling;
|
||
|
|
let e;
|
||
|
|
if (t)
|
||
|
|
e = t.firstChild.firstChild;
|
||
|
|
else
|
||
|
|
return !1;
|
||
|
|
return this.selectNode(e), !0;
|
||
|
|
}, ht = function() {
|
||
|
|
if (!this.currentNode || this.currentNode.dataset.nodeid === "meroot")
|
||
|
|
return !1;
|
||
|
|
const t = this.currentNode.parentElement.parentElement.previousSibling;
|
||
|
|
let e;
|
||
|
|
if (t)
|
||
|
|
e = t.firstChild.firstChild;
|
||
|
|
else
|
||
|
|
return !1;
|
||
|
|
return this.selectNode(e), !0;
|
||
|
|
}, dt = function() {
|
||
|
|
if (!this.currentNode)
|
||
|
|
return;
|
||
|
|
const t = this.currentNode.parentElement.nextSibling;
|
||
|
|
if (t && t.firstChild) {
|
||
|
|
const e = t.firstChild.firstChild.firstChild;
|
||
|
|
this.selectNode(e);
|
||
|
|
}
|
||
|
|
}, ut = function() {
|
||
|
|
if (!this.currentNode || this.currentNode.dataset.nodeid === "meroot")
|
||
|
|
return;
|
||
|
|
const t = this.currentNode.parentElement.parentElement.parentElement.previousSibling;
|
||
|
|
if (t) {
|
||
|
|
const e = t.firstChild;
|
||
|
|
this.selectNode(e);
|
||
|
|
}
|
||
|
|
}, ft = function() {
|
||
|
|
const t = Se(this);
|
||
|
|
return JSON.stringify(t, (e, n) => {
|
||
|
|
if (!(e === "parent" && typeof n != "string"))
|
||
|
|
return n;
|
||
|
|
});
|
||
|
|
}, pt = function() {
|
||
|
|
return JSON.parse(this.getDataString());
|
||
|
|
}, mt = function() {
|
||
|
|
const t = Se(this).nodeData;
|
||
|
|
let e = "# " + t.topic + `
|
||
|
|
|
||
|
|
`;
|
||
|
|
function n(i, s) {
|
||
|
|
for (let o = 0; o < i.length; o++)
|
||
|
|
s <= 6 ? e += "".padStart(s, "#") + " " + i[o].topic + `
|
||
|
|
|
||
|
|
` : e += "".padStart(s - 7, " ") + "- " + i[o].topic + `
|
||
|
|
`, i[o].children && n(i[o].children || [], s + 1);
|
||
|
|
}
|
||
|
|
return n(t.children || [], 2), e;
|
||
|
|
}, gt = function() {
|
||
|
|
this.editable = !0;
|
||
|
|
}, vt = function() {
|
||
|
|
this.editable = !1;
|
||
|
|
}, yt = function(t) {
|
||
|
|
this.scaleVal = t, this.map.style.transform = "scale(" + t + ")";
|
||
|
|
}, bt = function() {
|
||
|
|
this.container.scrollTo(1e4 - this.container.offsetWidth / 2, 1e4 - this.container.offsetHeight / 2);
|
||
|
|
}, xt = function(t) {
|
||
|
|
t(this);
|
||
|
|
}, wt = function(t) {
|
||
|
|
t.nodeObj.root || (this.tempDirection === null && (this.tempDirection = this.direction), this.isFocusMode || (this.nodeDataBackup = this.nodeData, this.isFocusMode = !0), this.nodeData = t.nodeObj, this.nodeData.root = !0, this.initRight(), this.toCenter());
|
||
|
|
}, _t = function() {
|
||
|
|
this.isFocusMode = !1, this.tempDirection !== null && (delete this.nodeData.root, this.nodeData = this.nodeDataBackup, this.direction = this.tempDirection, this.tempDirection = null, this.refresh(), this.toCenter());
|
||
|
|
}, Et = function() {
|
||
|
|
this.direction = 0, this.refresh();
|
||
|
|
}, Ct = function() {
|
||
|
|
this.direction = 1, this.refresh();
|
||
|
|
}, Lt = function() {
|
||
|
|
this.direction = 2, this.refresh();
|
||
|
|
}, St = function(t) {
|
||
|
|
this.locale = t, this.refresh();
|
||
|
|
}, kt = function(t, e) {
|
||
|
|
const n = t.nodeObj;
|
||
|
|
typeof e == "boolean" ? n.expanded = e : n.expanded !== !1 ? n.expanded = !1 : n.expanded = !0, this.layout(), this.linkDiv(), this.bus.fire("expandNode", n);
|
||
|
|
}, Mt = function(t) {
|
||
|
|
t && (t = JSON.parse(JSON.stringify(t)), this.nodeData = t.nodeData, this.linkData = t.linkData || {}, this.summaries = t.summaries || []), te(this.nodeData), this.layout(), this.linkDiv();
|
||
|
|
}, $t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
||
|
|
__proto__: null,
|
||
|
|
cancelFocus: _t,
|
||
|
|
disableEdit: vt,
|
||
|
|
enableEdit: gt,
|
||
|
|
expandNode: kt,
|
||
|
|
focusNode: wt,
|
||
|
|
getData: pt,
|
||
|
|
getDataMd: mt,
|
||
|
|
getDataString: ft,
|
||
|
|
initLeft: Et,
|
||
|
|
initRight: Ct,
|
||
|
|
initSide: Lt,
|
||
|
|
install: xt,
|
||
|
|
refresh: Mt,
|
||
|
|
scale: yt,
|
||
|
|
selectFirstChild: dt,
|
||
|
|
selectNextSibling: at,
|
||
|
|
selectNode: ot,
|
||
|
|
selectNodes: lt,
|
||
|
|
selectParent: ut,
|
||
|
|
selectPrevSibling: ht,
|
||
|
|
setLocale: St,
|
||
|
|
toCenter: bt,
|
||
|
|
unselectNode: rt,
|
||
|
|
unselectNodes: ct
|
||
|
|
}, Symbol.toStringTag, { value: "Module" })), Tt = function(t) {
|
||
|
|
return {
|
||
|
|
dom: t,
|
||
|
|
moved: !1,
|
||
|
|
// diffrentiate click and move
|
||
|
|
mousedown: !1,
|
||
|
|
handleMouseMove(e) {
|
||
|
|
this.mousedown && (this.moved = !0, this.cb && this.cb(e.movementX, e.movementY));
|
||
|
|
},
|
||
|
|
handleMouseDown(e) {
|
||
|
|
e.button === 0 && (this.mousedown = !0);
|
||
|
|
},
|
||
|
|
handleClear(e) {
|
||
|
|
this.mousedown = !1;
|
||
|
|
},
|
||
|
|
cb: null,
|
||
|
|
init(e, n) {
|
||
|
|
this.cb = n, this.handleClear = this.handleClear.bind(this), this.handleMouseMove = this.handleMouseMove.bind(this), this.handleMouseDown = this.handleMouseDown.bind(this), e.addEventListener("mousemove", this.handleMouseMove), e.addEventListener("mouseleave", this.handleClear), e.addEventListener("mouseup", this.handleClear), this.dom.addEventListener("mousedown", this.handleMouseDown);
|
||
|
|
},
|
||
|
|
destory(e) {
|
||
|
|
e.removeEventListener("mousemove", this.handleMouseMove), e.removeEventListener("mouseleave", this.handleClear), e.removeEventListener("mouseup", this.handleClear), this.dom.removeEventListener("mousedown", this.handleMouseDown);
|
||
|
|
},
|
||
|
|
clear() {
|
||
|
|
this.moved = !1, this.mousedown = !1;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
}, fe = {
|
||
|
|
create: Tt
|
||
|
|
};
|
||
|
|
function J(t, e, n) {
|
||
|
|
const { offsetLeft: i, offsetTop: s } = q(t.nodes, e), o = e.offsetWidth, r = e.offsetHeight, l = i + o / 2, c = s + r / 2, u = l + n.x, h = c + n.y;
|
||
|
|
return {
|
||
|
|
w: o,
|
||
|
|
h: r,
|
||
|
|
cx: l,
|
||
|
|
cy: c,
|
||
|
|
ctrlX: u,
|
||
|
|
ctrlY: h
|
||
|
|
};
|
||
|
|
}
|
||
|
|
function O(t) {
|
||
|
|
let e, n;
|
||
|
|
const i = (t.cy - t.ctrlY) / (t.ctrlX - t.cx);
|
||
|
|
return i > t.h / t.w || i < -t.h / t.w ? t.cy - t.ctrlY < 0 ? (e = t.cx - t.h / 2 / i, n = t.cy + t.h / 2) : (e = t.cx + t.h / 2 / i, n = t.cy - t.h / 2) : t.cx - t.ctrlX < 0 ? (e = t.cx + t.w / 2, n = t.cy - t.w * i / 2) : (e = t.cx - t.w / 2, n = t.cy + t.w * i / 2), {
|
||
|
|
x: e,
|
||
|
|
y: n
|
||
|
|
};
|
||
|
|
}
|
||
|
|
const Nt = function(t, e, n, i) {
|
||
|
|
const s = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
||
|
|
return w(s, {
|
||
|
|
"text-anchor": "middle",
|
||
|
|
x: e + "",
|
||
|
|
y: n + "",
|
||
|
|
fill: i || "#666"
|
||
|
|
}), s.dataset.type = "custom-link", s.innerHTML = t, s;
|
||
|
|
}, Dt = function(t, e, n, i) {
|
||
|
|
if (!t || !e)
|
||
|
|
return;
|
||
|
|
const s = performance.now(), o = J(this, t, n.delta1), r = J(this, e, n.delta2), { x: l, y: c } = O(o), { ctrlX: u, ctrlY: h } = o, { ctrlX: d, ctrlY: a } = r, { x: f, y: g } = O(r), p = ye(d, a, f, g), m = We(
|
||
|
|
`M ${l} ${c} C ${u} ${h} ${d} ${a} ${f} ${g}`,
|
||
|
|
`M ${p.x1} ${p.y1} L ${f} ${g} L ${p.x2} ${p.y2}`
|
||
|
|
), v = l / 8 + u * 3 / 8 + d * 3 / 8 + f / 8, y = c / 8 + h * 3 / 8 + a * 3 / 8 + g / 8, x = Nt(n.label, v, y, this.theme.cssVar["--color"]);
|
||
|
|
m.appendChild(x), m.linkObj = n, m.dataset.linkid = n.id, this.linkSvgGroup.appendChild(m), i || (this.linkData[n.id] = n, this.currentLink = m, this.showLinkController(n, o, r));
|
||
|
|
const E = performance.now();
|
||
|
|
console.log(`DrawCustomLink Execution time: ${E - s} ms`);
|
||
|
|
}, At = function(t, e) {
|
||
|
|
const n = {
|
||
|
|
id: ne(),
|
||
|
|
label: "Custom Link",
|
||
|
|
from: t.nodeObj.id,
|
||
|
|
to: e.nodeObj.id,
|
||
|
|
delta1: {
|
||
|
|
x: 0,
|
||
|
|
y: -200
|
||
|
|
},
|
||
|
|
delta2: {
|
||
|
|
x: 0,
|
||
|
|
y: -200
|
||
|
|
}
|
||
|
|
};
|
||
|
|
this.drawCustomLink(t, e, n), this.bus.fire("operation", {
|
||
|
|
name: "createCustomLink",
|
||
|
|
obj: n
|
||
|
|
});
|
||
|
|
}, Ht = function(t) {
|
||
|
|
let e;
|
||
|
|
if (t ? e = t : e = this.currentLink, !e)
|
||
|
|
return;
|
||
|
|
this.hideLinkController();
|
||
|
|
const n = e.linkObj.id;
|
||
|
|
delete this.linkData[n], e.remove(), this.bus.fire("operation", {
|
||
|
|
name: "removeCustomLink",
|
||
|
|
obj: {
|
||
|
|
id: n
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}, Pt = function(t) {
|
||
|
|
this.currentLink = t;
|
||
|
|
const e = t.linkObj, n = L(e.from), i = L(e.to), s = J(this, n, e.delta1), o = J(this, i, e.delta2);
|
||
|
|
this.showLinkController(e, s, o);
|
||
|
|
}, Bt = function() {
|
||
|
|
this.currentLink = null, this.hideLinkController();
|
||
|
|
}, zt = function() {
|
||
|
|
this.linkController.style.display = "none", this.P2.style.display = "none", this.P3.style.display = "none";
|
||
|
|
}, Ot = function(t, e, n) {
|
||
|
|
var d;
|
||
|
|
this.linkController.style.display = "initial", this.P2.style.display = "initial", this.P3.style.display = "initial", this.nodes.appendChild(this.linkController), this.nodes.appendChild(this.P2), this.nodes.appendChild(this.P3);
|
||
|
|
let { x: i, y: s } = O(e), { ctrlX: o, ctrlY: r } = e, { ctrlX: l, ctrlY: c } = n, { x: u, y: h } = O(n);
|
||
|
|
this.P2.style.cssText = `top:${r}px;left:${o}px;`, this.P3.style.cssText = `top:${c}px;left:${l}px;`, w(this.line1, {
|
||
|
|
x1: i + "",
|
||
|
|
y1: s + "",
|
||
|
|
x2: o + "",
|
||
|
|
y2: r + ""
|
||
|
|
}), w(this.line2, {
|
||
|
|
x1: l + "",
|
||
|
|
y1: c + "",
|
||
|
|
x2: u + "",
|
||
|
|
y2: h + ""
|
||
|
|
}), this.helper1 && (this.helper1.destory(this.map), (d = this.helper2) == null || d.destory(this.map)), this.helper1 = fe.create(this.P2), this.helper2 = fe.create(this.P3), this.helper1.init(this.map, (a, f) => {
|
||
|
|
var v;
|
||
|
|
o = o + a / this.scaleVal, r = r + f / this.scaleVal;
|
||
|
|
const g = O({ ...e, ctrlX: o, ctrlY: r });
|
||
|
|
i = g.x, s = g.y;
|
||
|
|
const p = i / 8 + o * 3 / 8 + l * 3 / 8 + u / 8, m = s / 8 + r * 3 / 8 + c * 3 / 8 + h / 8;
|
||
|
|
this.P2.style.top = r + "px", this.P2.style.left = o + "px", (v = this.currentLink) == null || v.children[0].setAttribute("d", `M ${i} ${s} C ${o} ${r} ${l} ${c} ${u} ${h}`), w(this.currentLink.children[2], {
|
||
|
|
x: p + "",
|
||
|
|
y: m + ""
|
||
|
|
}), w(this.line1, {
|
||
|
|
x1: i + "",
|
||
|
|
y1: s + "",
|
||
|
|
x2: o + "",
|
||
|
|
y2: r + ""
|
||
|
|
}), t.delta1.x = o - e.cx, t.delta1.y = r - e.cy;
|
||
|
|
}), this.helper2.init(this.map, (a, f) => {
|
||
|
|
var y, x;
|
||
|
|
l = l + a / this.scaleVal, c = c + f / this.scaleVal;
|
||
|
|
const g = O({ ...n, ctrlX: l, ctrlY: c });
|
||
|
|
u = g.x, h = g.y;
|
||
|
|
const p = i / 8 + o * 3 / 8 + l * 3 / 8 + u / 8, m = s / 8 + r * 3 / 8 + c * 3 / 8 + h / 8, v = ye(l, c, u, h);
|
||
|
|
this.P3.style.top = c + "px", this.P3.style.left = l + "px", (y = this.currentLink) == null || y.children[0].setAttribute("d", `M ${i} ${s} C ${o} ${r} ${l} ${c} ${u} ${h}`), (x = this.currentLink) == null || x.children[1].setAttribute("d", `M ${v.x1} ${v.y1} L ${u} ${h} L ${v.x2} ${v.y2}`), w(this.currentLink.children[2], {
|
||
|
|
x: p + "",
|
||
|
|
y: m + ""
|
||
|
|
}), w(this.line2, {
|
||
|
|
x1: l + "",
|
||
|
|
y1: c + "",
|
||
|
|
x2: u + "",
|
||
|
|
y2: h + ""
|
||
|
|
}), t.delta2.x = l - n.cx, t.delta2.y = c - n.cy;
|
||
|
|
});
|
||
|
|
};
|
||
|
|
function jt() {
|
||
|
|
this.linkSvgGroup.innerHTML = "";
|
||
|
|
for (const t in this.linkData) {
|
||
|
|
const e = this.linkData[t];
|
||
|
|
try {
|
||
|
|
this.drawCustomLink(L(e.from), L(e.to), e, !0);
|
||
|
|
} catch {
|
||
|
|
console.warn("Node may not be expanded");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.nodes.appendChild(this.linkSvgGroup);
|
||
|
|
}
|
||
|
|
function qt(t) {
|
||
|
|
if (console.time("editSummary"), !t)
|
||
|
|
return;
|
||
|
|
const e = t.children[2];
|
||
|
|
console.log(e, t), we(this, e, (n) => {
|
||
|
|
var o;
|
||
|
|
const i = t.linkObj, s = ((o = n.textContent) == null ? void 0 : o.trim()) || "";
|
||
|
|
s === "" ? i.label = origin : i.label = s, n.remove(), s !== origin && (e.innerHTML = i.label, this.linkDiv(), this.bus.fire("operation", {
|
||
|
|
name: "finishEditCustomLinkLabel",
|
||
|
|
obj: i
|
||
|
|
}));
|
||
|
|
}), console.timeEnd("editSummary");
|
||
|
|
}
|
||
|
|
function Vt() {
|
||
|
|
for (const t in this.linkData) {
|
||
|
|
const e = this.linkData[t];
|
||
|
|
(!U(e.from, this.nodeData) || !U(e.to, this.nodeData)) && delete this.linkData[e.id];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
const Rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
||
|
|
__proto__: null,
|
||
|
|
createLink: At,
|
||
|
|
drawCustomLink: Dt,
|
||
|
|
editCutsomLinkLabel: qt,
|
||
|
|
hideLinkController: zt,
|
||
|
|
removeLink: Ht,
|
||
|
|
renderCustomLink: jt,
|
||
|
|
selectLink: Pt,
|
||
|
|
showLinkController: Ot,
|
||
|
|
tidyCustomLink: Vt,
|
||
|
|
unselectLink: Bt
|
||
|
|
}, Symbol.toStringTag, { value: "Module" })), Wt = function(t) {
|
||
|
|
var c, u;
|
||
|
|
if (t.length === 0)
|
||
|
|
throw new Error("No selected node.");
|
||
|
|
if (t.length === 1) {
|
||
|
|
const h = t[0].nodeObj, d = t[0].nodeObj.parent;
|
||
|
|
if (!d)
|
||
|
|
throw new Error("Can not select root node.");
|
||
|
|
const a = d.children.findIndex((f) => h === f);
|
||
|
|
return {
|
||
|
|
parent: d.id,
|
||
|
|
start: a,
|
||
|
|
end: a
|
||
|
|
};
|
||
|
|
}
|
||
|
|
let e = 0;
|
||
|
|
const n = t.map((h) => {
|
||
|
|
let d = h.nodeObj;
|
||
|
|
const a = [];
|
||
|
|
for (; d.parent; ) {
|
||
|
|
const f = d.parent, g = f.children, p = g == null ? void 0 : g.indexOf(d);
|
||
|
|
d = f, a.unshift({ node: d, index: p });
|
||
|
|
}
|
||
|
|
return a.length > e && (e = a.length), a;
|
||
|
|
});
|
||
|
|
let i = 0;
|
||
|
|
e:
|
||
|
|
for (; i < e; i++) {
|
||
|
|
const h = (c = n[0][i]) == null ? void 0 : c.node;
|
||
|
|
for (let d = 1; d < n.length; d++)
|
||
|
|
if (((u = n[d][i]) == null ? void 0 : u.node) !== h)
|
||
|
|
break e;
|
||
|
|
}
|
||
|
|
if (!i)
|
||
|
|
throw new Error("Can not select root node.");
|
||
|
|
const s = n.map((h) => h[i - 1].index).sort(), o = s[0] || 0, r = s[s.length - 1] || 0, l = n[0][i - 1].node;
|
||
|
|
if (l.root)
|
||
|
|
throw new Error("Please select nodes in the same main topic.");
|
||
|
|
return {
|
||
|
|
parent: l.id,
|
||
|
|
start: o,
|
||
|
|
end: r
|
||
|
|
};
|
||
|
|
}, Ft = function(t) {
|
||
|
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
||
|
|
return e.setAttribute("id", t), e;
|
||
|
|
}, pe = function(t, e) {
|
||
|
|
const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
||
|
|
return w(n, {
|
||
|
|
d: t,
|
||
|
|
stroke: e || "#666",
|
||
|
|
fill: "none",
|
||
|
|
"stroke-linecap": "round",
|
||
|
|
"stroke-width": "2"
|
||
|
|
}), n;
|
||
|
|
}, me = function(t, e, n, i, s) {
|
||
|
|
const o = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
||
|
|
return w(o, {
|
||
|
|
"text-anchor": i,
|
||
|
|
x: e + "",
|
||
|
|
y: n + "",
|
||
|
|
fill: s || "#666"
|
||
|
|
}), o.innerHTML = t, o;
|
||
|
|
}, It = (t) => L(t).parentElement.parentElement, Yt = function({ parent: t, start: e }) {
|
||
|
|
var o, r;
|
||
|
|
const n = L(t), i = n.nodeObj;
|
||
|
|
let s;
|
||
|
|
return i.root === !0 ? s = (o = L(i.children[e].id).closest("me-main")) == null ? void 0 : o.className : s = (r = n.closest("me-main")) == null ? void 0 : r.className, s;
|
||
|
|
}, ke = function(t, e) {
|
||
|
|
var F;
|
||
|
|
const { id: n, text: i, parent: s, start: o, end: r } = e, l = t.nodes, u = L(s).nodeObj, h = Yt(e);
|
||
|
|
let d = 1 / 0, a = 0, f = 0, g = 0;
|
||
|
|
for (let V = o; V <= r; V++) {
|
||
|
|
const ie = (F = u.children) == null ? void 0 : F[V];
|
||
|
|
if (!ie)
|
||
|
|
return console.warn("Child not found"), t.removeSummary(n), null;
|
||
|
|
const I = It(ie.id), { offsetLeft: Y, offsetTop: se } = q(l, I);
|
||
|
|
V === o && (f = se), V === r && (g = se + I.offsetHeight), Y < d && (d = Y), I.offsetWidth + Y > a && (a = I.offsetWidth + Y);
|
||
|
|
}
|
||
|
|
let p, m;
|
||
|
|
const v = f + 10, y = g + 10, x = (v + y) / 2, E = t.theme.cssVar["--color"];
|
||
|
|
h === "lhs" ? (p = pe(`M ${d + 10} ${v} c -5 0 -10 5 -10 10 L ${d} ${y - 10} c 0 5 5 10 10 10 M ${d} ${x} h -10`, E), m = me(i, d - 20, x + 6, "end", E)) : (p = pe(`M ${a - 10} ${v} c 5 0 10 5 10 10 L ${a} ${y - 10} c 0 5 -5 10 -10 10 M ${a} ${x} h 10`, E), m = me(i, a + 20, x + 6, "start", E));
|
||
|
|
const C = Ft("s-" + n);
|
||
|
|
return C.appendChild(p), C.appendChild(m), C.summaryObj = e, t.summarySvg.appendChild(C), C;
|
||
|
|
}, Xt = function() {
|
||
|
|
let t = [];
|
||
|
|
this.currentNode ? t = [this.currentNode] : this.currentNodes && (t = this.currentNodes);
|
||
|
|
const { parent: e, start: n, end: i } = Wt(t), s = { id: ne(), parent: e, start: n, end: i, text: "summary" }, o = ke(this, s);
|
||
|
|
this.summaries.push(s), this.editSummary(o), this.bus.fire("operation", {
|
||
|
|
name: "createSummary",
|
||
|
|
obj: s
|
||
|
|
});
|
||
|
|
}, Gt = function(t) {
|
||
|
|
var n;
|
||
|
|
const e = this.summaries.findIndex((i) => i.id === t);
|
||
|
|
e > -1 && (this.summaries.splice(e, 1), (n = document.querySelector("#s-" + t)) == null || n.remove()), this.bus.fire("operation", {
|
||
|
|
name: "removeSummary",
|
||
|
|
obj: { id: t }
|
||
|
|
});
|
||
|
|
}, Ut = function(t) {
|
||
|
|
const e = t.children[1].getBBox(), n = 6, i = 3, s = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
||
|
|
w(s, {
|
||
|
|
x: e.x - n + "",
|
||
|
|
y: e.y - n + "",
|
||
|
|
width: e.width + n * 2 + "",
|
||
|
|
height: e.height + n * 2 + "",
|
||
|
|
rx: i + "",
|
||
|
|
stroke: this.theme.cssVar["--selected"] || "#4dc4ff",
|
||
|
|
"stroke-width": "2",
|
||
|
|
fill: "none"
|
||
|
|
}), s.classList.add("selected"), t.appendChild(s), this.currentSummary = t;
|
||
|
|
}, Kt = function() {
|
||
|
|
var t, e;
|
||
|
|
(e = (t = this.currentSummary) == null ? void 0 : t.querySelector("rect")) == null || e.remove(), this.currentSummary = null;
|
||
|
|
}, Jt = function() {
|
||
|
|
this.summarySvg.innerHTML = "", this.summaries.forEach((t) => {
|
||
|
|
try {
|
||
|
|
ke(this, t);
|
||
|
|
} catch {
|
||
|
|
console.warn("Node may not be expanded");
|
||
|
|
}
|
||
|
|
}), this.nodes.insertAdjacentElement("beforeend", this.summarySvg);
|
||
|
|
}, Qt = function(t) {
|
||
|
|
if (console.time("editSummary"), !t)
|
||
|
|
return;
|
||
|
|
const e = t.childNodes[1];
|
||
|
|
we(this, e, (n) => {
|
||
|
|
var o;
|
||
|
|
const i = t.summaryObj, s = ((o = n.textContent) == null ? void 0 : o.trim()) || "";
|
||
|
|
s === "" ? i.text = origin : i.text = s, n.remove(), s !== origin && (e.innerHTML = i.text, this.linkDiv(), this.bus.fire("operation", {
|
||
|
|
name: "finishEditSummary",
|
||
|
|
obj: i
|
||
|
|
}));
|
||
|
|
}), console.timeEnd("editSummary");
|
||
|
|
}, Zt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
||
|
|
__proto__: null,
|
||
|
|
createSummary: Xt,
|
||
|
|
editSummary: Qt,
|
||
|
|
removeSummary: Gt,
|
||
|
|
renderSummary: Jt,
|
||
|
|
selectSummary: Ut,
|
||
|
|
unselectSummary: Kt
|
||
|
|
}, Symbol.toStringTag, { value: "Module" }));
|
||
|
|
function en(t, e) {
|
||
|
|
const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||
|
|
return w(n, {
|
||
|
|
version: "1.1",
|
||
|
|
xmlns: "http://www.w3.org/2000/svg",
|
||
|
|
height: t,
|
||
|
|
width: e
|
||
|
|
}), n;
|
||
|
|
}
|
||
|
|
function tn(t, e) {
|
||
|
|
return (parseInt(t) - parseInt(e)) / 2;
|
||
|
|
}
|
||
|
|
function nn(t, e, n, i) {
|
||
|
|
const s = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
||
|
|
let o = "";
|
||
|
|
return t.text ? o = t.text.textContent : o = t.childNodes[0].textContent, o.split(`
|
||
|
|
`).forEach((l, c) => {
|
||
|
|
const u = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
||
|
|
w(u, {
|
||
|
|
x: n + parseInt(e.paddingLeft) + "",
|
||
|
|
y: i + parseInt(e.paddingTop) + tn(e.lineHeight, e.fontSize) * (c + 1) + parseFloat(e.fontSize) * (c + 1) + "",
|
||
|
|
"text-anchor": "start",
|
||
|
|
"font-family": e.fontFamily,
|
||
|
|
"font-size": `${e.fontSize}`,
|
||
|
|
"font-weight": `${e.fontWeight}`,
|
||
|
|
fill: `${e.color}`
|
||
|
|
}), u.innerHTML = l, s.appendChild(u);
|
||
|
|
}), s;
|
||
|
|
}
|
||
|
|
function sn(t, e, n, i) {
|
||
|
|
let s = "";
|
||
|
|
t.text ? s = t.text.textContent : s = t.childNodes[0].textContent;
|
||
|
|
const o = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
|
||
|
|
w(o, {
|
||
|
|
x: n + parseInt(e.paddingLeft) + "",
|
||
|
|
y: i + parseInt(e.paddingTop) + "",
|
||
|
|
width: e.width,
|
||
|
|
height: e.height
|
||
|
|
});
|
||
|
|
const r = document.createElement("div");
|
||
|
|
return w(r, {
|
||
|
|
xmlns: "http://www.w3.org/1999/xhtml",
|
||
|
|
style: `font-family: ${e.fontFamily}; font-size: ${e.fontSize}; font-weight: ${e.fontWeight}; color: ${e.color}; white-space: pre-wrap;`
|
||
|
|
}), r.innerHTML = s, o.appendChild(r), o;
|
||
|
|
}
|
||
|
|
function Z(t, e, n = !1) {
|
||
|
|
const i = getComputedStyle(e), { offsetLeft: s, offsetTop: o } = q(t.nodes, e), r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
||
|
|
w(r, {
|
||
|
|
x: s + "",
|
||
|
|
y: o + "",
|
||
|
|
rx: i.borderRadius,
|
||
|
|
ry: i.borderRadius,
|
||
|
|
width: i.width,
|
||
|
|
height: i.height,
|
||
|
|
fill: i.backgroundColor,
|
||
|
|
stroke: i.borderColor,
|
||
|
|
"stroke-width": i.borderWidth
|
||
|
|
});
|
||
|
|
const l = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
||
|
|
l.appendChild(r);
|
||
|
|
let c;
|
||
|
|
return n ? c = sn(e, i, s, o) : c = nn(e, i, s, o), l.appendChild(c), l;
|
||
|
|
}
|
||
|
|
function on(t, e) {
|
||
|
|
const n = getComputedStyle(e), { offsetLeft: i, offsetTop: s } = q(t.nodes, e), o = document.createElementNS("http://www.w3.org/2000/svg", "a"), r = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
||
|
|
return w(r, {
|
||
|
|
x: i + "",
|
||
|
|
y: s + parseInt(n.fontSize) + "",
|
||
|
|
"text-anchor": "start",
|
||
|
|
"font-family": n.fontFamily,
|
||
|
|
"font-size": `${n.fontSize}`,
|
||
|
|
"font-weight": `${n.fontWeight}`,
|
||
|
|
fill: `${n.color}`
|
||
|
|
}), r.innerHTML = e.textContent, o.appendChild(r), o.setAttribute("href", e.href), o;
|
||
|
|
}
|
||
|
|
const G = 100, rn = '<?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">', Me = (t, e = !1) => {
|
||
|
|
var d, a, f;
|
||
|
|
const n = t.nodes, i = n.offsetHeight + G * 2, s = n.offsetWidth + G * 2, o = en(i + "px", s + "px"), r = document.createElementNS("http://www.w3.org/2000/svg", "svg"), l = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
||
|
|
w(l, {
|
||
|
|
x: "0",
|
||
|
|
y: "0",
|
||
|
|
width: `${s}`,
|
||
|
|
height: `${i}`,
|
||
|
|
fill: t.theme.cssVar["--bgcolor"]
|
||
|
|
}), o.appendChild(l), n.querySelectorAll(".subLines").forEach((g) => {
|
||
|
|
const p = g.cloneNode(!0), { offsetLeft: m, offsetTop: v } = q(n, g.parentElement);
|
||
|
|
p.setAttribute("x", `${m}`), p.setAttribute("y", `${v}`), r.appendChild(p);
|
||
|
|
});
|
||
|
|
const c = (d = n.querySelector(".lines")) == null ? void 0 : d.cloneNode(!0);
|
||
|
|
c && r.appendChild(c);
|
||
|
|
const u = (a = n.querySelector(".topiclinks")) == null ? void 0 : a.cloneNode(!0);
|
||
|
|
u && r.appendChild(u);
|
||
|
|
const h = (f = n.querySelector(".summary")) == null ? void 0 : f.cloneNode(!0);
|
||
|
|
return h && r.appendChild(h), n.querySelectorAll("me-tpc").forEach((g) => {
|
||
|
|
r.appendChild(Z(t, g, !e));
|
||
|
|
}), n.querySelectorAll(".tags > span").forEach((g) => {
|
||
|
|
r.appendChild(Z(t, g));
|
||
|
|
}), n.querySelectorAll(".icons > span").forEach((g) => {
|
||
|
|
r.appendChild(Z(t, g));
|
||
|
|
}), n.querySelectorAll(".hyper-link").forEach((g) => {
|
||
|
|
r.appendChild(on(t, g));
|
||
|
|
}), w(r, {
|
||
|
|
x: G + "",
|
||
|
|
y: G + "",
|
||
|
|
overflow: "visible"
|
||
|
|
}), o.appendChild(r), rn + o.outerHTML;
|
||
|
|
};
|
||
|
|
function ln(t) {
|
||
|
|
return new Promise((e, n) => {
|
||
|
|
const i = new FileReader();
|
||
|
|
i.onload = (s) => {
|
||
|
|
e(s.target.result);
|
||
|
|
}, i.onerror = (s) => {
|
||
|
|
n(s);
|
||
|
|
}, i.readAsDataURL(t);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
const cn = function(t = !1) {
|
||
|
|
const e = Me(this, t);
|
||
|
|
return new Blob([e], { type: "image/svg+xml" });
|
||
|
|
}, an = async function(t = !1) {
|
||
|
|
const e = Me(this, t), n = new Blob([e], { type: "image/svg+xml" }), i = await ln(n);
|
||
|
|
return new Promise((s, o) => {
|
||
|
|
const r = new Image();
|
||
|
|
r.setAttribute("crossOrigin", "anonymous"), r.onload = () => {
|
||
|
|
const l = document.createElement("canvas");
|
||
|
|
l.width = r.width, l.height = r.height, l.getContext("2d").drawImage(r, 0, 0), l.toBlob(s, "image/png", 1);
|
||
|
|
}, r.src = i, r.onerror = o;
|
||
|
|
});
|
||
|
|
}, hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
||
|
|
__proto__: null,
|
||
|
|
exportPng: an,
|
||
|
|
exportSvg: cn
|
||
|
|
}, Symbol.toStringTag, { value: "Module" })), dn = {}, un = {
|
||
|
|
getObjById: U,
|
||
|
|
generateNewObj: $e,
|
||
|
|
layout: De,
|
||
|
|
linkDiv: Fe,
|
||
|
|
editTopic: je,
|
||
|
|
createWrapper: Pe,
|
||
|
|
createParent: Be,
|
||
|
|
createChildren: ze,
|
||
|
|
createTopic: Oe,
|
||
|
|
findEle: L,
|
||
|
|
changeTheme: st,
|
||
|
|
...$t,
|
||
|
|
...dn,
|
||
|
|
...Rt,
|
||
|
|
...Zt,
|
||
|
|
...hn,
|
||
|
|
init(t) {
|
||
|
|
if (!t || !t.nodeData)
|
||
|
|
return new Error("MindElixir: `data` is required");
|
||
|
|
t.direction !== void 0 && (this.direction = t.direction), this.changeTheme(t.theme || this.theme, !1), this.nodeData = t.nodeData, te(this.nodeData), this.linkData = t.linkData || {}, this.summaries = t.summaries || [], this.tidyCustomLink(), this.toolBar && Ke(this), this.toCenter(), this.layout(), this.linkDiv();
|
||
|
|
}
|
||
|
|
}, R = document;
|
||
|
|
function M({
|
||
|
|
el: t,
|
||
|
|
direction: e,
|
||
|
|
locale: n,
|
||
|
|
draggable: i,
|
||
|
|
editable: s,
|
||
|
|
contextMenu: o,
|
||
|
|
contextMenuOption: r,
|
||
|
|
toolBar: l,
|
||
|
|
keypress: c,
|
||
|
|
mouseSelectionButton: u,
|
||
|
|
before: h,
|
||
|
|
newTopicName: d,
|
||
|
|
allowUndo: a,
|
||
|
|
mainLinkStyle: f,
|
||
|
|
subLinkStyle: g,
|
||
|
|
overflowHidden: p,
|
||
|
|
mobileMenu: m,
|
||
|
|
theme: v
|
||
|
|
}) {
|
||
|
|
console.log("ME_version " + M.version, this);
|
||
|
|
let y = null;
|
||
|
|
const x = Object.prototype.toString.call(t);
|
||
|
|
if (x === "[object HTMLDivElement]" ? y = t : x === "[object String]" && (y = document.querySelector(t)), !y)
|
||
|
|
throw new Error("MindElixir: el is not a valid element");
|
||
|
|
y.className += " mind-elixir", y.innerHTML = "", y.style.setProperty("--gap", k + "px"), this.mindElixirBox = y, this.before = h || {}, this.locale = n || "en", this.contextMenuOption = r, this.contextMenu = o === void 0 ? !0 : o, this.toolBar = l === void 0 ? !0 : l, this.keypress = c === void 0 ? !0 : c, this.mouseSelectionButton = u || 0, this.mobileMenu = m || !1, this.direction = typeof e == "number" ? e : 1, this.draggable = i === void 0 ? !0 : i, this.newTopicName = d || "new node", this.editable = s === void 0 ? !0 : s, this.allowUndo = a === void 0 ? !1 : a, this.currentNode = null, this.currentLink = null, this.scaleVal = 1, this.tempDirection = null, this.mainLinkStyle = f || 0, this.subLinkStyle = g || 0, this.overflowHidden = p || !1, this.bus = Ne.create(), this.container = R.createElement("div"), this.container.className = "map-container";
|
||
|
|
const E = window.matchMedia("(prefers-color-scheme: dark)");
|
||
|
|
this.theme = v || (E.matches ? ve : ge);
|
||
|
|
const C = R.createElement("div");
|
||
|
|
C.className = "map-canvas", this.map = C, this.map.setAttribute("tabindex", "0"), this.container.appendChild(this.map), this.mindElixirBox.appendChild(this.container), this.nodes = R.createElement("me-nodes"), this.nodes.className = "main-node-container", this.lines = W("lines"), this.summarySvg = W("summary"), this.linkController = W("linkcontroller"), this.P2 = R.createElement("div"), this.P3 = R.createElement("div"), this.P2.className = this.P3.className = "circle", this.P2.style.display = this.P3.style.display = "none", this.line1 = le(), this.line2 = le(), this.linkController.appendChild(this.line1), this.linkController.appendChild(this.line2), this.linkSvgGroup = W("topiclinks"), this.map.appendChild(this.nodes), this.overflowHidden ? this.container.style.overflow = "hidden" : Te(this);
|
||
|
|
}
|
||
|
|
M.prototype = un;
|
||
|
|
M.LEFT = j;
|
||
|
|
M.RIGHT = ee;
|
||
|
|
M.SIDE = Q;
|
||
|
|
M.THEME = ge;
|
||
|
|
M.DARK_THEME = ve;
|
||
|
|
M.version = "3.3.2";
|
||
|
|
M.E = L;
|
||
|
|
export {
|
||
|
|
M as default
|
||
|
|
};
|