mind-elixir 3.2.0 → 3.2.2

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.
@@ -203,7 +203,7 @@ function st(t) {
203
203
  D.clear();
204
204
  return;
205
205
  }
206
- t.unselectNode(), t.unselectNodes(), t.unselectSummary();
206
+ t.unselectNode(), t.unselectNodes(), t.unselectSummary(), t.unselectLink();
207
207
  const n = e.target;
208
208
  if (n.tagName === "ME-EPD")
209
209
  t.expandNode(n.previousSibling);
@@ -224,6 +224,8 @@ function st(t) {
224
224
  console.log(e.button), e.button === 2 && D.clear();
225
225
  }), t.map.addEventListener("mouseup", (e) => {
226
226
  e.button === 2 && D.clear();
227
+ }), t.map.addEventListener("contextmenu", (e) => {
228
+ e.preventDefault();
227
229
  });
228
230
  }
229
231
  const rt = {
@@ -1314,8 +1316,8 @@ w(ze, "version", "3.3.1");
1314
1316
  function Rt(t) {
1315
1317
  const e = new ze({
1316
1318
  selectables: [".map-container me-tpc"],
1317
- boundaries: [".map-container"],
1318
- container: ".map-container",
1319
+ boundaries: [t.container],
1320
+ container: t.container,
1319
1321
  behaviour: {
1320
1322
  // Scroll configuration.
1321
1323
  scrolling: {
@@ -1332,7 +1334,7 @@ function Rt(t) {
1332
1334
  }
1333
1335
  }
1334
1336
  }).on("beforestart", ({ event: n }) => !(n.button !== 0 || n.target.tagName === "ME-TPC" || n.target.id === "input-box" || n.target.className === "circle")).on("start", ({ event: n }) => {
1335
- !n.ctrlKey && !n.metaKey && (t.unselectNode(), t.unselectNodes(), t.unselectSummary(), e.clearSelection(!0, !0));
1337
+ !n.ctrlKey && !n.metaKey && (t.unselectNode(), t.unselectNodes(), t.unselectSummary(), t.unselectLink(), e.clearSelection(!0, !0));
1336
1338
  }).on(
1337
1339
  "move",
1338
1340
  ({
@@ -1349,7 +1351,6 @@ function Rt(t) {
1349
1351
  ).on("stop", ({ store: { stored: n } }) => {
1350
1352
  console.log(n, "stored"), t.selectNodes(n);
1351
1353
  });
1352
- console.log(e, "selection");
1353
1354
  }
1354
1355
  const qt = function(t, e = !0) {
1355
1356
  this.theme = t;
@@ -1850,8 +1851,10 @@ const Mn = function(t, e, n, i) {
1850
1851
  const e = t.linkObj, n = E(e.from), i = E(e.to), o = ne(this, n, e.delta1), s = ne(this, i, e.delta2);
1851
1852
  this.showLinkController(e, o, s);
1852
1853
  }, An = function() {
1854
+ this.currentLink = null, this.hideLinkController();
1855
+ }, Pn = function() {
1853
1856
  this.linkController.style.display = "none", this.P2.style.display = "none", this.P3.style.display = "none";
1854
- }, Pn = function(t, e, n) {
1857
+ }, jn = function(t, e, n) {
1855
1858
  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);
1856
1859
  let { x: i, y: o } = V(e), { ctrlX: s, ctrlY: r } = e, { ctrlX: l, ctrlY: c } = n, { x: h, y: a } = V(n);
1857
1860
  this.P2.style.cssText = `top:${r}px;left:${s}px;`, this.P3.style.cssText = `top:${c}px;left:${l}px;`, N(this.line1, {
@@ -1896,7 +1899,7 @@ const Mn = function(t, e, n, i) {
1896
1899
  }), t.delta2.x = l - n.cx, t.delta2.y = c - n.cy;
1897
1900
  });
1898
1901
  };
1899
- function jn() {
1902
+ function Hn() {
1900
1903
  this.linkSvgGroup.innerHTML = "";
1901
1904
  for (const t in this.linkData) {
1902
1905
  const e = this.linkData[t];
@@ -1904,7 +1907,7 @@ function jn() {
1904
1907
  }
1905
1908
  this.nodes.appendChild(this.linkSvgGroup);
1906
1909
  }
1907
- function Hn(t) {
1910
+ function Bn(t) {
1908
1911
  if (console.time("editSummary"), !t)
1909
1912
  return;
1910
1913
  const e = t.children[2];
@@ -1914,17 +1917,18 @@ function Hn(t) {
1914
1917
  o === "" ? i.label = origin : i.label = o, n.remove(), o !== origin && (e.innerHTML = i.label, this.linkDiv());
1915
1918
  }), console.timeEnd("editSummary");
1916
1919
  }
1917
- const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1920
+ const zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1918
1921
  __proto__: null,
1919
1922
  createLink: $n,
1920
1923
  drawCustomLink: Tn,
1921
- editCutsomLinkLabel: Hn,
1922
- hideLinkController: An,
1924
+ editCutsomLinkLabel: Bn,
1925
+ hideLinkController: Pn,
1923
1926
  removeLink: Dn,
1924
- renderCustomLink: jn,
1927
+ renderCustomLink: Hn,
1925
1928
  selectLink: On,
1926
- showLinkController: Pn
1927
- }, Symbol.toStringTag, { value: "Module" })), zn = function(t) {
1929
+ showLinkController: jn,
1930
+ unselectLink: An
1931
+ }, Symbol.toStringTag, { value: "Module" })), Rn = function(t) {
1928
1932
  var c, h;
1929
1933
  if (t.length === 0)
1930
1934
  throw new Error("No selected node.");
@@ -1967,7 +1971,7 @@ const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1967
1971
  start: s,
1968
1972
  end: r
1969
1973
  };
1970
- }, Rn = function(t) {
1974
+ }, qn = function(t) {
1971
1975
  const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
1972
1976
  return e.setAttribute("id", t), e;
1973
1977
  }, Ce = function(t, e) {
@@ -1987,37 +1991,37 @@ const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1987
1991
  y: n + "",
1988
1992
  fill: o || "#666"
1989
1993
  }), s.innerHTML = t, s;
1990
- }, qn = (t) => E(t).parentElement.parentElement, Fn = function({ parent: t, start: e }) {
1994
+ }, Fn = (t) => E(t).parentElement.parentElement, Vn = function({ parent: t, start: e }) {
1991
1995
  var s, r;
1992
1996
  const n = E(t), i = n.nodeObj;
1993
1997
  let o;
1994
1998
  return i.root === !0 ? o = (s = E(i.children[e].id).closest("me-main")) == null ? void 0 : s.className : o = (r = n.closest("me-main")) == null ? void 0 : r.className, o;
1995
1999
  }, We = function(t, e) {
1996
2000
  var _;
1997
- const { id: n, text: i, parent: o, start: s, end: r } = e, l = t.nodes, h = E(o).nodeObj, a = Fn(e);
2001
+ const { id: n, text: i, parent: o, start: s, end: r } = e, l = t.nodes, h = E(o).nodeObj, a = Vn(e);
1998
2002
  let u = 1 / 0, d = 0, p = 0, g = 0;
1999
2003
  for (let Y = s; Y <= r; Y++) {
2000
2004
  const de = (_ = h.children) == null ? void 0 : _[Y];
2001
2005
  if (!de)
2002
2006
  return console.warn("Child not found"), t.removeSummary(n), null;
2003
- const G = qn(de.id), { offsetLeft: J, offsetTop: he } = W(l, G);
2007
+ const G = Fn(de.id), { offsetLeft: J, offsetTop: he } = W(l, G);
2004
2008
  Y === s && (p = he), Y === r && (g = he + G.offsetHeight), J < u && (u = J), G.offsetWidth + J > d && (d = G.offsetWidth + J);
2005
2009
  }
2006
2010
  let m, f;
2007
2011
  const v = p + 10, x = g + 10, b = (v + x) / 2, y = t.theme.cssVar["--color"];
2008
2012
  a === "lhs" ? (m = Ce(`M ${u + 10} ${v} c -5 0 -10 5 -10 10 L ${u} ${x - 10} c 0 5 5 10 10 10 M ${u} ${b} h -10`, y), f = _e(i, u - 20, b + 6, "end", y)) : (m = Ce(`M ${d - 10} ${v} c 5 0 10 5 10 10 L ${d} ${x - 10} c 0 5 -5 10 -10 10 M ${d} ${b} h 10`, y), f = _e(i, d + 20, b + 6, "start", y));
2009
- const C = Rn("s-" + n);
2013
+ const C = qn("s-" + n);
2010
2014
  return C.appendChild(m), C.appendChild(f), C.summaryObj = e, t.summarySvg.appendChild(C), C;
2011
- }, Vn = function() {
2015
+ }, Wn = function() {
2012
2016
  let t = [];
2013
2017
  this.currentNode ? t = [this.currentNode] : this.currentNodes && (t = this.currentNodes);
2014
- const { parent: e, start: n, end: i } = zn(t), o = { id: U(), parent: e, start: n, end: i, text: "summary" }, s = We(this, o);
2018
+ const { parent: e, start: n, end: i } = Rn(t), o = { id: U(), parent: e, start: n, end: i, text: "summary" }, s = We(this, o);
2015
2019
  this.summaries.push(o), this.editSummary(s);
2016
- }, Wn = function(t) {
2020
+ }, Yn = function(t) {
2017
2021
  var n;
2018
2022
  const e = this.summaries.findIndex((i) => i.id === t);
2019
2023
  e > -1 && (this.summaries.splice(e, 1), (n = document.querySelector("#s-" + t)) == null || n.remove());
2020
- }, Yn = function(t) {
2024
+ }, In = function(t) {
2021
2025
  const e = t.children[1].getBBox(), n = 6, i = 3, o = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2022
2026
  N(o, {
2023
2027
  x: e.x - n + "",
@@ -2029,14 +2033,14 @@ const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2029
2033
  "stroke-width": "2",
2030
2034
  fill: "none"
2031
2035
  }), o.classList.add("selected"), t.appendChild(o), this.currentSummary = t;
2032
- }, In = function() {
2036
+ }, Xn = function() {
2033
2037
  var t, e;
2034
2038
  (e = (t = this.currentSummary) == null ? void 0 : t.querySelector("rect")) == null || e.remove(), this.currentSummary = null;
2035
- }, Xn = function() {
2039
+ }, Kn = function() {
2036
2040
  this.summarySvg.innerHTML = "", this.summaries.forEach((t) => {
2037
2041
  We(this, t);
2038
2042
  }), this.nodes.insertAdjacentElement("beforeend", this.summarySvg);
2039
- }, Kn = function(t) {
2043
+ }, Un = function(t) {
2040
2044
  if (console.time("editSummary"), !t)
2041
2045
  return;
2042
2046
  const e = t.childNodes[1];
@@ -2049,16 +2053,16 @@ const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2049
2053
  origin
2050
2054
  }));
2051
2055
  }), console.timeEnd("editSummary");
2052
- }, Un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2056
+ }, Gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2053
2057
  __proto__: null,
2054
- createSummary: Vn,
2055
- editSummary: Kn,
2056
- removeSummary: Wn,
2057
- renderSummary: Xn,
2058
- selectSummary: Yn,
2059
- unselectSummary: In
2058
+ createSummary: Wn,
2059
+ editSummary: Un,
2060
+ removeSummary: Yn,
2061
+ renderSummary: Kn,
2062
+ selectSummary: In,
2063
+ unselectSummary: Xn
2060
2064
  }, Symbol.toStringTag, { value: "Module" }));
2061
- function Gn(t, e) {
2065
+ function Jn(t, e) {
2062
2066
  const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2063
2067
  return N(n, {
2064
2068
  version: "1.1",
@@ -2067,17 +2071,17 @@ function Gn(t, e) {
2067
2071
  width: e
2068
2072
  }), n;
2069
2073
  }
2070
- function Jn(t, e) {
2074
+ function Qn(t, e) {
2071
2075
  return (parseInt(t) - parseInt(e)) / 2;
2072
2076
  }
2073
- function Qn(t, e, n, i) {
2077
+ function Zn(t, e, n, i) {
2074
2078
  const o = document.createElementNS("http://www.w3.org/2000/svg", "g");
2075
2079
  return t.childNodes[0].textContent.split(`
2076
2080
  `).forEach((l, c) => {
2077
2081
  const h = document.createElementNS("http://www.w3.org/2000/svg", "text");
2078
2082
  N(h, {
2079
2083
  x: n + parseInt(e.paddingLeft) + "",
2080
- y: i + parseInt(e.paddingTop) + Jn(e.lineHeight, e.fontSize) * (c + 1) + parseFloat(e.fontSize) * (c + 1) + "",
2084
+ y: i + parseInt(e.paddingTop) + Qn(e.lineHeight, e.fontSize) * (c + 1) + parseFloat(e.fontSize) * (c + 1) + "",
2081
2085
  "text-anchor": "start",
2082
2086
  "font-family": e.fontFamily,
2083
2087
  "font-size": `${e.fontSize}`,
@@ -2086,7 +2090,7 @@ function Qn(t, e, n, i) {
2086
2090
  }), h.innerHTML = l, o.appendChild(h);
2087
2091
  }), o;
2088
2092
  }
2089
- function Zn(t, e, n, i) {
2093
+ function ei(t, e, n, i) {
2090
2094
  const o = t.childNodes[0].textContent, s = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
2091
2095
  N(s, {
2092
2096
  x: n + parseInt(e.paddingLeft) + "",
@@ -2116,9 +2120,9 @@ function re(t, e, n = !1) {
2116
2120
  const l = document.createElementNS("http://www.w3.org/2000/svg", "g");
2117
2121
  l.appendChild(r);
2118
2122
  let c;
2119
- return n ? c = Zn(e, i, o, s) : c = Qn(e, i, o, s), l.appendChild(c), l;
2123
+ return n ? c = ei(e, i, o, s) : c = Zn(e, i, o, s), l.appendChild(c), l;
2120
2124
  }
2121
- function ei(t, e) {
2125
+ function ti(t, e) {
2122
2126
  const n = getComputedStyle(e), { offsetLeft: i, offsetTop: o } = W(t.nodes, e), s = document.createElementNS("http://www.w3.org/2000/svg", "a"), r = document.createElementNS("http://www.w3.org/2000/svg", "text");
2123
2127
  return N(r, {
2124
2128
  x: i + "",
@@ -2130,9 +2134,9 @@ function ei(t, e) {
2130
2134
  fill: `${n.color}`
2131
2135
  }), r.innerHTML = e.textContent, s.appendChild(r), s.setAttribute("href", e.href), s;
2132
2136
  }
2133
- const Z = 100, ti = '<?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">', Ye = (t) => {
2137
+ const Z = 100, ni = '<?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">', Ye = (t) => {
2134
2138
  var a, u, d;
2135
- const e = t.nodes, n = e.offsetHeight + Z * 2, i = e.offsetWidth + Z * 2, o = Gn(n + "px", i + "px"), s = document.createElementNS("http://www.w3.org/2000/svg", "svg"), r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2139
+ const e = t.nodes, n = e.offsetHeight + Z * 2, i = e.offsetWidth + Z * 2, o = Jn(n + "px", i + "px"), s = document.createElementNS("http://www.w3.org/2000/svg", "svg"), r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2136
2140
  N(r, {
2137
2141
  x: "0",
2138
2142
  y: "0",
@@ -2155,14 +2159,14 @@ const Z = 100, ti = '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "
2155
2159
  }), e.querySelectorAll(".icons > span").forEach((p) => {
2156
2160
  s.appendChild(re(t, p));
2157
2161
  }), e.querySelectorAll(".hyper-link").forEach((p) => {
2158
- s.appendChild(ei(t, p));
2162
+ s.appendChild(ti(t, p));
2159
2163
  }), N(s, {
2160
2164
  x: Z + "",
2161
2165
  y: Z + "",
2162
2166
  overflow: "visible"
2163
- }), o.appendChild(s), ti + o.outerHTML;
2167
+ }), o.appendChild(s), ni + o.outerHTML;
2164
2168
  };
2165
- function ni(t) {
2169
+ function ii(t) {
2166
2170
  return new Promise((e, n) => {
2167
2171
  const i = new FileReader();
2168
2172
  i.onload = (o) => {
@@ -2172,11 +2176,11 @@ function ni(t) {
2172
2176
  }, i.readAsDataURL(t);
2173
2177
  });
2174
2178
  }
2175
- const ii = function() {
2179
+ const oi = function() {
2176
2180
  const t = Ye(this);
2177
2181
  return new Blob([t], { type: "image/svg+xml" });
2178
- }, oi = async function() {
2179
- const t = Ye(this), e = new Blob([t], { type: "image/svg+xml" }), n = await ni(e);
2182
+ }, si = async function() {
2183
+ const t = Ye(this), e = new Blob([t], { type: "image/svg+xml" }), n = await ii(e);
2180
2184
  return new Promise((i, o) => {
2181
2185
  const s = new Image();
2182
2186
  s.setAttribute("crossOrigin", "anonymous"), s.onload = () => {
@@ -2184,12 +2188,12 @@ const ii = function() {
2184
2188
  r.width = s.width, r.height = s.height, r.getContext("2d").drawImage(s, 0, 0), r.toBlob(i, "image/png", 1);
2185
2189
  }, s.src = n, s.onerror = o;
2186
2190
  });
2187
- }, si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2191
+ }, ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2188
2192
  __proto__: null,
2189
- exportPng: oi,
2190
- exportSvg: ii
2193
+ exportPng: si,
2194
+ exportSvg: oi
2191
2195
  }, Symbol.toStringTag, { value: "Module" }));
2192
- function ri(t, e) {
2196
+ function li(t, e) {
2193
2197
  return async function(...n) {
2194
2198
  const i = this.before[e];
2195
2199
  i && !await i.apply(this, n) || t.apply(this, n);
@@ -2198,9 +2202,9 @@ function ri(t, e) {
2198
2202
  const ke = Object.keys(Ve), Ie = {};
2199
2203
  for (let t = 0; t < ke.length; t++) {
2200
2204
  const e = ke[t];
2201
- Ie[e] = ri(Ve[e], e);
2205
+ Ie[e] = li(Ve[e], e);
2202
2206
  }
2203
- const li = {
2207
+ const ci = {
2204
2208
  getObjById: Me,
2205
2209
  generateNewObj: Ue,
2206
2210
  layout: lt,
@@ -2214,13 +2218,13 @@ const li = {
2214
2218
  changeTheme: qt,
2215
2219
  ...fn,
2216
2220
  ...Ie,
2217
- ...Bn,
2218
- ...Un,
2219
- ...si,
2221
+ ...zn,
2222
+ ...Gn,
2223
+ ...ri,
2220
2224
  init(t) {
2221
2225
  if (!t || !t.nodeData)
2222
2226
  return new Error("MindElixir: `data` is required");
2223
- t.direction !== void 0 && (this.direction = t.direction), this.changeTheme(t.theme || this.theme, !1), this.nodeData = t.nodeData, T(this.nodeData), this.linkData = t.linkData || {}, this.summaries = t.summaries || [], this.toolBar && Ot(this), this.keypress && _t(this), Xe() && this.mobileMenu ? kt(this) : this.contextMenu && Et(this, this.contextMenuOption), this.draggable && Mt(this), this.allowUndo && Tt(this), Rt(this), this.toCenter(), this.layout(), this.linkDiv();
2227
+ t.direction !== void 0 && (this.direction = t.direction), this.changeTheme(t.theme || this.theme, !1), this.nodeData = t.nodeData, T(this.nodeData), this.linkData = t.linkData || {}, this.summaries = t.summaries || [], this.toolBar && Ot(this), this.keypress && _t(this), this.editable && Rt(this), Xe() && this.mobileMenu ? kt(this) : this.contextMenu && Et(this, this.contextMenuOption), this.draggable && Mt(this), this.allowUndo && Tt(this), this.toCenter(), this.layout(), this.linkDiv();
2224
2228
  }
2225
2229
  }, I = document;
2226
2230
  function $({
@@ -2253,13 +2257,13 @@ function $({
2253
2257
  const y = I.createElement("div");
2254
2258
  y.className = "map-canvas", this.map = y, this.map.setAttribute("tabindex", "0"), this.container.appendChild(this.map), this.mindElixirBox.appendChild(this.container), this.nodes = I.createElement("me-nodes"), this.nodes.className = "main-node-container", this.lines = X("lines"), this.summarySvg = X("summary"), this.linkController = X("linkcontroller"), this.P2 = I.createElement("div"), this.P3 = I.createElement("div"), this.P2.className = this.P3.className = "circle", this.P2.style.display = this.P3.style.display = "none", this.line1 = fe(), this.line2 = fe(), this.linkController.appendChild(this.line1), this.linkController.appendChild(this.line2), this.linkSvgGroup = X("topiclinks"), this.map.appendChild(this.nodes), this.overflowHidden ? this.container.style.overflow = "hidden" : st(this);
2255
2259
  }
2256
- $.prototype = li;
2260
+ $.prototype = ci;
2257
2261
  $.LEFT = S;
2258
2262
  $.RIGHT = H;
2259
2263
  $.SIDE = K;
2260
2264
  $.THEME = Se;
2261
2265
  $.DARK_THEME = Le;
2262
- $.version = "3.2.0";
2266
+ $.version = "3.2.2";
2263
2267
  $.E = E;
2264
2268
  $.new = (t) => ({
2265
2269
  nodeData: {