@modusoperandi/licit 1.3.0 → 1.3.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.
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
3
3
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
4
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
5
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
@@ -114,7 +114,7 @@ var LinkSetURLCommand = /*#__PURE__*/function (_UICommand) {
114
114
  return _context2.abrupt("return", Promise.resolve(undefined));
115
115
  case 5:
116
116
  from = selection.from, to = selection.to;
117
- result = findNodesWithSameMark(doc, from, to, markType);
117
+ result = findNodesWithSameMark(doc, from, to - 1, markType);
118
118
  href = result ? result.mark.attrs.href : null;
119
119
  _context2.next = 10;
120
120
  return _this.showTocList(view);
@@ -86,7 +86,7 @@ class LinkSetURLCommand extends UICommand {
86
86
  return Promise.resolve(undefined);
87
87
  }
88
88
  const { from, to } = selection;
89
- const result = findNodesWithSameMark(doc, from, to, markType);
89
+ const result = findNodesWithSameMark(doc, from, to - 1, markType);
90
90
  const href = result ? result.mark.attrs.href : null;
91
91
  const tocItemsNode = await this.showTocList(view);
92
92
  const viewPops = {
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
3
3
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
4
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
5
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -15,23 +15,39 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
15
15
  function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
16
16
  function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
17
17
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
18
- import { EditorState, Plugin, PluginKey, TextSelection } from 'prosemirror-state';
18
+ import { Plugin, PluginKey, TextSelection } from 'prosemirror-state';
19
19
  import { EditorView } from 'prosemirror-view';
20
20
  import { MARK_LINK } from './MarkNames.js';
21
- import { hideSelectionPlaceholder } from './SelectionPlaceholderPlugin.js';
22
- import { applyMark, findNodesWithSameMark, atAnchorTopCenter, createPopUp } from '@modusoperandi/licit-ui-commands';
21
+ import { atAnchorTopCenter, createPopUp, findNodesWithSameMark } from '@modusoperandi/licit-ui-commands';
23
22
  import lookUpElement from './lookUpElement.js';
24
23
  import LinkTooltip from './ui/LinkTooltip.js';
25
- import LinkURLEditor from './ui/LinkURLEditor.js';
26
- import { INNER_LINK } from './Types.js';
27
-
28
- // https://prosemirror.net/examples/tooltip/
24
+ import scrollIntoView from 'smooth-scroll-into-view-if-needed';
25
+ import sanitizeURL from './sanitizeURL.js';
26
+ import '@modusoperandi/licit-ui-commands/ui/czi-pop-up.css';
29
27
  var SPEC = {
30
- // [FS] IRAD-1005 2020-07-07
31
- // Upgrade outdated packages.
32
28
  key: new PluginKey('LinkTooltipPlugin'),
29
+ props: {
30
+ handleDOMEvents: {
31
+ mouseover: function mouseover(view, event) {
32
+ var _pluginView$_handleMo;
33
+ var pluginView = view.dom._linkTooltipView;
34
+ return (_pluginView$_handleMo = pluginView === null || pluginView === void 0 ? void 0 : pluginView._handleMouseOver(event)) !== null && _pluginView$_handleMo !== void 0 ? _pluginView$_handleMo : false;
35
+ },
36
+ mouseout: function mouseout(view, event) {
37
+ var pluginView = view.dom._linkTooltipView;
38
+ return pluginView === null || pluginView === void 0 ? void 0 : pluginView._handleMouseOut.call(view, event);
39
+ },
40
+ click: function click(view, event) {
41
+ var pluginView = view.dom._linkTooltipView;
42
+ return pluginView === null || pluginView === void 0 ? void 0 : pluginView._handleClick.call(view, event);
43
+ }
44
+ }
45
+ },
33
46
  view: function view(editorView) {
34
- return new LinkTooltipView(editorView);
47
+ var pluginView = new LinkTooltipView(editorView);
48
+ // Store the instance for use in DOM handlers
49
+ editorView.dom._linkTooltipView = pluginView;
50
+ return pluginView;
35
51
  }
36
52
  };
37
53
  var LinkTooltipPlugin = /*#__PURE__*/function (_Plugin) {
@@ -43,153 +59,78 @@ var LinkTooltipPlugin = /*#__PURE__*/function (_Plugin) {
43
59
  return _createClass(LinkTooltipPlugin);
44
60
  }(Plugin);
45
61
  var LinkTooltipView = /*#__PURE__*/function () {
46
- function LinkTooltipView(editorView) {
62
+ function LinkTooltipView(_view) {
47
63
  var _this = this;
48
64
  _classCallCheck(this, LinkTooltipView);
49
- _defineProperty(this, "_anchorEl", null);
50
65
  _defineProperty(this, "_popup", null);
51
- _defineProperty(this, "_editor", null);
52
- _defineProperty(this, "_onCancel", function (view) {
53
- _this.destroy();
54
- view.focus();
66
+ _defineProperty(this, "_anchorEl", null);
67
+ _defineProperty(this, "_view", null);
68
+ _defineProperty(this, "jumpLink", function (view, tocItemPos, href, selectionId) {
69
+ if (selectionId || selectionId === 0 && tocItemPos) {
70
+ _this.jumpInnerLink(view, tocItemPos);
71
+ } else {
72
+ _this._openLink(href);
73
+ }
55
74
  });
56
- _defineProperty(this, "_onClose", function () {
57
- _this._anchorEl = null;
58
- _this._editor = null;
59
- _this._popup = null;
75
+ _defineProperty(this, "jumpInnerLink", function (view, tocItemPos) {
76
+ var transaction = view.state.tr;
77
+ var tr = transaction.setSelection(TextSelection.create(transaction.doc, tocItemPos.position + 1));
78
+ view.dispatch(tr.scrollIntoView(true));
79
+ var dom = view.domAtPos((tocItemPos === null || tocItemPos === void 0 ? void 0 : tocItemPos.position) + 1).node;
80
+ if (dom !== null && dom !== void 0 && dom.scrollIntoView) {
81
+ dom.scrollIntoView({
82
+ behavior: 'smooth',
83
+ block: 'start'
84
+ });
85
+ }
60
86
  });
61
- _defineProperty(this, "showTocList", /*#__PURE__*/function () {
62
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(view) {
63
- var storeTOCvalue, TOCselectedNode, stylePromise, styles;
64
- return _regeneratorRuntime().wrap(function _callee$(_context) {
65
- while (1) switch (_context.prev = _context.next) {
66
- case 0:
67
- storeTOCvalue = [];
68
- TOCselectedNode = [];
69
- stylePromise = view.runtime;
70
- if (!(stylePromise === null || undefined)) {
71
- _context.next = 7;
72
- break;
87
+ _defineProperty(this, "_openLink", function (href) {
88
+ if (_this.isBookMarkHref(href)) {
89
+ var id = href.substr(1);
90
+ var el = document.getElementById(id);
91
+ if (el) {
92
+ var _this$props = _this.props,
93
+ onCancel = _this$props.onCancel,
94
+ editorView = _this$props.editorView;
95
+ onCancel(editorView);
96
+ _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
97
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
98
+ while (1) switch (_context.prev = _context.next) {
99
+ case 0:
100
+ _context.next = 2;
101
+ return scrollIntoView(el, {
102
+ scrollMode: 'if-needed',
103
+ behavior: 'smooth'
104
+ });
105
+ case 2:
106
+ case "end":
107
+ return _context.stop();
73
108
  }
74
- return _context.abrupt("return", TOCselectedNode);
75
- case 7:
76
- _context.next = 9;
77
- return stylePromise.fetchStyles();
78
- case 9:
79
- styles = _context.sent;
80
- storeTOCvalue = styles.filter(function (style // Added TOT/TOF selected styles to be listed as well
81
- ) {
82
- var _style$styles, _style$styles2, _style$styles3;
83
- return (style === null || style === void 0 || (_style$styles = style.styles) === null || _style$styles === void 0 ? void 0 : _style$styles.toc) === true || (style === null || style === void 0 || (_style$styles2 = style.styles) === null || _style$styles2 === void 0 ? void 0 : _style$styles2.tot) === true || (style === null || style === void 0 || (_style$styles3 = style.styles) === null || _style$styles3 === void 0 ? void 0 : _style$styles3.tof) === true;
84
- }).map(function (style) {
85
- return style === null || style === void 0 ? void 0 : style.styleName;
86
- });
87
- view.state.tr.doc.descendants(function (node, pos) {
88
- if (node.attrs.styleName) {
89
- for (var i = 0; i <= storeTOCvalue.length; i++) {
90
- if (storeTOCvalue[i] === node.attrs.styleName) {
91
- TOCselectedNode.push({
92
- node_: node,
93
- pos_: pos
94
- });
95
- }
96
- }
97
- }
98
- });
99
- return _context.abrupt("return", TOCselectedNode);
100
- case 13:
101
- case "end":
102
- return _context.stop();
103
- }
104
- }, _callee);
105
- }));
106
- return function (_x) {
107
- return _ref.apply(this, arguments);
108
- };
109
- }());
110
- _defineProperty(this, "_onEdit", function (view) {
111
- _this._popup.close();
112
- if (_this._editor) {
113
- return;
114
- }
115
- var state = view.state;
116
- var schema = state.schema,
117
- doc = state.doc,
118
- selection = state.selection;
119
- var from = selection.from,
120
- to = selection.to;
121
- var markType = schema.marks[MARK_LINK];
122
- var result = findNodesWithSameMark(doc, from, to, markType);
123
- if (!result) {
109
+ }, _callee);
110
+ }))();
111
+ }
124
112
  return;
125
113
  }
126
- _this.showTocList(view).then(function (data) {
127
- var tocItemsNode = data;
128
- var href = result.mark.attrs.href;
129
- var viewPops = {
130
- selectionId_: result.mark.attrs.selectionId,
131
- href_: href,
132
- TOCselectedNode_: tocItemsNode,
133
- view_: view
134
- };
135
- _this._editor = createPopUp(LinkURLEditor, viewPops, {
136
- onClose: function onClose(value) {
137
- _this._editor = null;
138
- _this._onEditEnd(view, selection, value);
139
- }
140
- });
141
- });
142
- });
143
- _defineProperty(this, "_onRemove", function (view) {
144
- _this._popup.close();
145
- _this._onEditEnd(view, view.state.selection, null);
146
- });
147
- _defineProperty(this, "_onEditEnd", function (view, initialSelection, url) {
148
- var state = view.state,
149
- dispatch = view.dispatch;
150
- var tr = hideSelectionPlaceholder(state);
151
- if (url !== undefined) {
152
- var schema = state.schema;
153
- var markType = schema.marks[MARK_LINK];
154
- if (markType) {
155
- var result = findNodesWithSameMark(tr.doc, initialSelection.from, initialSelection.to, markType);
156
- if (result) {
157
- var linkSelection = TextSelection.create(tr.doc, result.from.pos, result.to.pos + 1);
158
- tr = tr.setSelection(linkSelection);
159
- var selectionId;
160
- var href;
161
- if (url === null) {
162
- selectionId = null;
163
- href = null;
164
- } else if (url.includes(INNER_LINK)) {
165
- selectionId = url.split(INNER_LINK)[0];
166
- href = url.split(INNER_LINK)[1];
167
- } else {
168
- selectionId = null;
169
- href = url;
170
- }
171
- var attrs = href ? {
172
- href: href,
173
- selectionId: selectionId
174
- } : null;
175
- tr = applyMark(tr, schema, markType, attrs);
176
-
177
- // [FS] IRAD-1005 2020-07-09
178
- // Upgrade outdated packages.
179
- // reset selection to original using the latest doc.
180
- var origSelection = TextSelection.create(tr.doc, initialSelection.from, initialSelection.to);
181
- tr = tr.setSelection(origSelection);
182
- }
114
+ if (href) {
115
+ var _this$_view;
116
+ var url = sanitizeURL(href);
117
+ var popupString;
118
+ if (_this._view.editable) {
119
+ popupString = 'Any unsaved changes will be lost';
120
+ } else {
121
+ popupString = '';
122
+ }
123
+ if ((_this$_view = _this._view) !== null && _this$_view !== void 0 && (_this$_view = _this$_view.runtime) !== null && _this$_view !== void 0 && _this$_view.openLinkDialog) {
124
+ _this._view.runtime.openLinkDialog(url, popupString);
125
+ } else {
126
+ window.open(url);
183
127
  }
184
128
  }
185
- dispatch(tr);
186
- view.focus();
187
129
  });
188
- this.update(editorView, null);
189
- }
190
- return _createClass(LinkTooltipView, [{
191
- key: "getInnerlinkSelected_position",
192
- value: function getInnerlinkSelected_position(view, selectionId) {
130
+ _defineProperty(this, "isBookMarkHref", function (href) {
131
+ return !!href && href.startsWith('#') && href.length >= 2;
132
+ });
133
+ _defineProperty(this, "getInnerlinkSelected_position", function (view, selectionId) {
193
134
  var tocItemPos = null;
194
135
  if (selectionId) {
195
136
  view.state.tr.doc.descendants(function (node, pos) {
@@ -202,68 +143,80 @@ var LinkTooltipView = /*#__PURE__*/function () {
202
143
  });
203
144
  }
204
145
  return tocItemPos;
146
+ });
147
+ this._view = _view;
148
+ }
149
+ return _createClass(LinkTooltipView, [{
150
+ key: "_handleMouseOver",
151
+ value: function _handleMouseOver(event) {
152
+ var _event$target,
153
+ _this$_popup,
154
+ _this2 = this;
155
+ var anchor = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest('a');
156
+ if (!anchor || anchor === this._anchorEl) return;
157
+ this._anchorEl = anchor;
158
+ var href = anchor.getAttribute('href');
159
+ (_this$_popup = this._popup) === null || _this$_popup === void 0 || _this$_popup.close();
160
+ this._popup = createPopUp(LinkTooltip, {
161
+ href: href,
162
+ selectionId: null,
163
+ editorView: this._view
164
+ }, {
165
+ anchor: anchor,
166
+ autoDismiss: true,
167
+ onClose: function onClose() {
168
+ _this2._popup = null;
169
+ _this2._anchorEl = null;
170
+ },
171
+ position: atAnchorTopCenter
172
+ });
205
173
  }
206
174
  }, {
207
- key: "update",
208
- value: function update(view, lastState) {
209
- var state = view.state;
175
+ key: "_handleClick",
176
+ value: function _handleClick(event) {
177
+ var state = this.dom._linkTooltipView._view.state;
210
178
  var doc = state.doc,
211
179
  selection = state.selection,
212
180
  schema = state.schema;
213
- var markType = schema.marks[MARK_LINK];
214
- if (!markType) {
215
- return;
216
- }
217
181
  var from = selection.from,
218
182
  to = selection.to;
183
+ var markType = schema.marks[MARK_LINK];
219
184
  var result = findNodesWithSameMark(doc, from, to, markType);
220
185
  if (!result) {
221
- this.destroy();
222
- return;
186
+ return false;
223
187
  }
224
- var domFound = view.domAtPos(from);
188
+ var domFound = this.dom._linkTooltipView._view.domAtPos(from);
225
189
  if (!domFound) {
226
- this.destroy();
227
- return;
190
+ return false;
228
191
  }
229
- var anchorEl = lookUpElement(domFound.node, function (el) {
192
+ var anchor = lookUpElement(domFound.node, function (el) {
230
193
  return el.nodeName === 'A';
231
194
  });
232
- if (!anchorEl) {
233
- this.destroy();
234
- return;
195
+ if (!anchor) {
196
+ return false;
235
197
  }
236
- var tocItemPos = this.getInnerlinkSelected_position(view, result.mark.attrs.selectionId);
237
- var popup = this._popup;
238
- var viewPops = {
239
- editorState: state,
240
- editorView: view,
241
- href: result.mark.attrs.href,
242
- selectionId_: result.mark.attrs.selectionId,
243
- onCancel: this._onCancel,
244
- onEdit: this._onEdit,
245
- onRemove: this._onRemove,
246
- tocItemPos_: tocItemPos
247
- };
248
- if (popup && anchorEl === this._anchorEl) {
249
- popup.update(viewPops);
250
- } else {
251
- popup === null || popup === void 0 || popup.close();
252
- this._anchorEl = anchorEl;
253
- this._popup = createPopUp(LinkTooltip, viewPops, {
254
- anchor: anchorEl,
255
- autoDismiss: false,
256
- onClose: this._onClose,
257
- position: atAnchorTopCenter
258
- });
198
+ var href = anchor.getAttribute('href');
199
+ var selectionId = anchor.getAttribute('selectionid');
200
+ var tocItemPos = this.dom._linkTooltipView.getInnerlinkSelected_position(this.dom._linkTooltipView._view, result.mark.attrs.selectionId);
201
+ this.dom._linkTooltipView.jumpLink(this.dom._linkTooltipView._view, tocItemPos, href, selectionId);
202
+ event.preventDefault(); // prevent default browser navigation
203
+ return true;
204
+ }
205
+ }, {
206
+ key: "_handleMouseOut",
207
+ value: function _handleMouseOut(event) {
208
+ if (this._anchorEl && !this._anchorEl.contains(event.relatedTarget)) {
209
+ var _this$_popup2;
210
+ (_this$_popup2 = this._popup) === null || _this$_popup2 === void 0 || _this$_popup2.close();
211
+ this._popup = null;
212
+ this._anchorEl = null;
259
213
  }
260
214
  }
261
215
  }, {
262
216
  key: "destroy",
263
217
  value: function destroy() {
264
- var _this$_popup, _this$_editor;
265
- (_this$_popup = this._popup) === null || _this$_popup === void 0 || _this$_popup.close();
266
- (_this$_editor = this._editor) === null || _this$_editor === void 0 || _this$_editor.close();
218
+ var _this$_popup3;
219
+ (_this$_popup3 = this._popup) === null || _this$_popup3 === void 0 || _this$_popup3.close();
267
220
  }
268
221
  }]);
269
222
  }();