@modusoperandi/licit 1.3.7 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
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/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) { 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), c(GeneratorFunctionPrototype, u, GeneratorFunction.displayName = "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; }
2
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (c = i[4] || 3, u = i[5] === e ? i[3] : i[5], i[4] = 3, i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
3
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
3
4
  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
5
  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
6
  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); } }
@@ -48,24 +49,22 @@ var LinkSetURLCommand = /*#__PURE__*/function (_UICommand) {
48
49
  return from < to;
49
50
  });
50
51
  _defineProperty(_this, "showTocList", /*#__PURE__*/function () {
51
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(view) {
52
- var storeTOCvalue, TOCselectedNode, stylePromise, styles;
53
- return _regeneratorRuntime().wrap(function _callee$(_context) {
54
- while (1) switch (_context.prev = _context.next) {
52
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(view) {
53
+ var stylePromise, styles, storeTOCvalue;
54
+ return _regenerator().w(function (_context) {
55
+ while (1) switch (_context.n) {
55
56
  case 0:
56
- storeTOCvalue = [];
57
- TOCselectedNode = [];
58
57
  stylePromise = view.runtime;
59
58
  if (!(stylePromise === null || undefined)) {
60
- _context.next = 5;
59
+ _context.n = 1;
61
60
  break;
62
61
  }
63
- return _context.abrupt("return", TOCselectedNode);
64
- case 5:
65
- _context.next = 7;
62
+ return _context.a(2, []);
63
+ case 1:
64
+ _context.n = 2;
66
65
  return stylePromise.fetchStyles();
67
- case 7:
68
- styles = _context.sent;
66
+ case 2:
67
+ styles = _context.v;
69
68
  storeTOCvalue = styles.filter(function (style // Added TOT/TOF selected styles to be listed as well
70
69
  ) {
71
70
  var _style$styles, _style$styles2, _style$styles3;
@@ -73,22 +72,7 @@ var LinkSetURLCommand = /*#__PURE__*/function (_UICommand) {
73
72
  }).map(function (style) {
74
73
  return style === null || style === void 0 ? void 0 : style.styleName;
75
74
  });
76
- view.state.tr.doc.descendants(function (node, pos) {
77
- if (node.attrs.styleName) {
78
- for (var i = 0; i <= storeTOCvalue.length; i++) {
79
- if (storeTOCvalue[i] === node.attrs.styleName) {
80
- TOCselectedNode.push({
81
- node_: node,
82
- pos_: pos
83
- });
84
- }
85
- }
86
- }
87
- });
88
- return _context.abrupt("return", TOCselectedNode);
89
- case 11:
90
- case "end":
91
- return _context.stop();
75
+ return _context.a(2, stylePromise.fetchInnerLinkSelectionIds(storeTOCvalue));
92
76
  }
93
77
  }, _callee);
94
78
  }));
@@ -97,10 +81,10 @@ var LinkSetURLCommand = /*#__PURE__*/function (_UICommand) {
97
81
  };
98
82
  }());
99
83
  _defineProperty(_this, "waitForUserInput", /*#__PURE__*/function () {
100
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(state, dispatch, view, event) {
84
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(state, dispatch, view, event) {
101
85
  var doc, schema, selection, markType, from, to, result, href, tocItemsNode, viewPops;
102
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
103
- while (1) switch (_context2.prev = _context2.next) {
86
+ return _regenerator().w(function (_context2) {
87
+ while (1) switch (_context2.n) {
104
88
  case 0:
105
89
  if (dispatch) {
106
90
  dispatch(showSelectionPlaceholder(state));
@@ -108,24 +92,23 @@ var LinkSetURLCommand = /*#__PURE__*/function (_UICommand) {
108
92
  doc = state.doc, schema = state.schema, selection = state.selection;
109
93
  markType = schema.marks[MARK_LINK];
110
94
  if (markType) {
111
- _context2.next = 5;
95
+ _context2.n = 1;
112
96
  break;
113
97
  }
114
- return _context2.abrupt("return", Promise.resolve(undefined));
115
- case 5:
98
+ return _context2.a(2, Promise.resolve(undefined));
99
+ case 1:
116
100
  from = selection.from, to = selection.to;
117
101
  result = findNodesWithSameMark(doc, from, to - 1, markType);
118
102
  href = result ? result.mark.attrs.href : null;
119
- _context2.next = 10;
103
+ _context2.n = 2;
120
104
  return _this.showTocList(view);
121
- case 10:
122
- tocItemsNode = _context2.sent;
105
+ case 2:
106
+ tocItemsNode = _context2.v;
123
107
  viewPops = {
124
108
  href_: href,
125
- TOCselectedNode_: tocItemsNode,
126
- view_: view
109
+ TOCselectedNode_: tocItemsNode
127
110
  };
128
- return _context2.abrupt("return", new Promise(function (resolve) {
111
+ return _context2.a(2, new Promise(function (resolve) {
129
112
  _this._popUp = createPopUp(LinkURLEditor, viewPops, {
130
113
  modal: true,
131
114
  onClose: function onClose(val) {
@@ -136,9 +119,6 @@ var LinkSetURLCommand = /*#__PURE__*/function (_UICommand) {
136
119
  }
137
120
  });
138
121
  }));
139
- case 13:
140
- case "end":
141
- return _context2.stop();
142
122
  }
143
123
  }, _callee2);
144
124
  }));
@@ -36,17 +36,15 @@ class LinkSetURLCommand extends UICommand {
36
36
  };
37
37
 
38
38
  showTocList = async (view) => {
39
- let storeTOCvalue = [];
40
- const TOCselectedNode = [];
41
39
 
42
40
  const stylePromise = view.runtime;
43
41
 
44
42
  if (stylePromise === null || undefined) {
45
- return TOCselectedNode;
43
+ return [];
46
44
  }
47
45
  const styles = await stylePromise.fetchStyles();
48
46
 
49
- storeTOCvalue = styles
47
+ const storeTOCvalue = styles
50
48
  .filter(
51
49
  (
52
50
  style // Added TOT/TOF selected styles to be listed as well
@@ -56,18 +54,7 @@ class LinkSetURLCommand extends UICommand {
56
54
  style?.styles?.tof === true
57
55
  )
58
56
  .map((style) => style?.styleName);
59
-
60
- view.state.tr.doc.descendants((node, pos) => {
61
- if (node.attrs.styleName) {
62
- for (let i = 0; i <= storeTOCvalue.length; i++) {
63
- if (storeTOCvalue[i] === node.attrs.styleName) {
64
- TOCselectedNode.push({ node_: node, pos_: pos });
65
- }
66
- }
67
- }
68
- });
69
-
70
- return TOCselectedNode;
57
+ return stylePromise.fetchInnerLinkSelectionIds(storeTOCvalue); // Fetching the selection IDs for the TOC items from MSD
71
58
  };
72
59
 
73
60
  waitForUserInput = async (
@@ -91,8 +78,7 @@ class LinkSetURLCommand extends UICommand {
91
78
  const tocItemsNode = await this.showTocList(view);
92
79
  const viewPops = {
93
80
  href_: href,
94
- TOCselectedNode_: tocItemsNode,
95
- view_: view,
81
+ TOCselectedNode_: tocItemsNode
96
82
  };
97
83
 
98
84
  return new Promise((resolve) => {
@@ -1,5 +1,6 @@
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/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) { 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), c(GeneratorFunctionPrototype, u, GeneratorFunction.displayName = "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; }
2
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (c = i[4] || 3, u = i[5] === e ? i[3] : i[5], i[4] = 3, i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
3
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
3
4
  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
5
  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
6
  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; }
@@ -64,6 +65,14 @@ var LinkTooltipView = /*#__PURE__*/function () {
64
65
  _defineProperty(this, "_popup", null);
65
66
  _defineProperty(this, "_anchorEl", null);
66
67
  _defineProperty(this, "_view", null);
68
+ _defineProperty(this, "openSelectedSection", function (selectionId) {
69
+ if (selectionId) {
70
+ var _this$_view;
71
+ if ((_this$_view = _this._view) !== null && _this$_view !== void 0 && (_this$_view = _this$_view.runtime) !== null && _this$_view !== void 0 && _this$_view.goToInnerLinkSection) {
72
+ _this._view.runtime.goToInnerLinkSection(selectionId);
73
+ }
74
+ }
75
+ });
67
76
  _defineProperty(this, "jumpLink", function (view, tocItemPos, href, selectionId) {
68
77
  if (selectionId || selectionId === 0 && tocItemPos) {
69
78
  _this.jumpInnerLink(view, tocItemPos);
@@ -92,18 +101,17 @@ var LinkTooltipView = /*#__PURE__*/function () {
92
101
  onCancel = _this$props.onCancel,
93
102
  editorView = _this$props.editorView;
94
103
  onCancel(editorView);
95
- _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
96
- return _regeneratorRuntime().wrap(function _callee$(_context) {
97
- while (1) switch (_context.prev = _context.next) {
104
+ _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
105
+ return _regenerator().w(function (_context) {
106
+ while (1) switch (_context.n) {
98
107
  case 0:
99
- _context.next = 2;
108
+ _context.n = 1;
100
109
  return scrollIntoView(el, {
101
110
  scrollMode: 'if-needed',
102
111
  behavior: 'smooth'
103
112
  });
104
- case 2:
105
- case "end":
106
- return _context.stop();
113
+ case 1:
114
+ return _context.a(2);
107
115
  }
108
116
  }, _callee);
109
117
  }))();
@@ -112,7 +120,7 @@ var LinkTooltipView = /*#__PURE__*/function () {
112
120
  }
113
121
  var urlObj = new URL(href);
114
122
  if (href) {
115
- var _this$_view;
123
+ var _this$_view2;
116
124
  var url = sanitizeURL(href);
117
125
  var popupString;
118
126
  if (_this._view.editable) {
@@ -120,7 +128,7 @@ var LinkTooltipView = /*#__PURE__*/function () {
120
128
  } else {
121
129
  popupString = '';
122
130
  }
123
- if ((_this$_view = _this._view) !== null && _this$_view !== void 0 && (_this$_view = _this$_view.runtime) !== null && _this$_view !== void 0 && _this$_view.openLinkDialog && urlObj.hostname !== window.location.hostname) {
131
+ if ((_this$_view2 = _this._view) !== null && _this$_view2 !== void 0 && (_this$_view2 = _this$_view2.runtime) !== null && _this$_view2 !== void 0 && _this$_view2.openLinkDialog && urlObj.hostname !== window.location.hostname) {
124
132
  _this._view.runtime.openLinkDialog(url, popupString);
125
133
  } else {
126
134
  window.open(url);
@@ -134,7 +142,7 @@ var LinkTooltipView = /*#__PURE__*/function () {
134
142
  var tocItemPos = null;
135
143
  if (selectionId) {
136
144
  view.state.tr.doc.descendants(function (node, pos) {
137
- if (node.attrs.styleName && node.attrs.innerLink === selectionId) {
145
+ if (node.attrs.styleName && node.attrs.selectionId === selectionId) {
138
146
  tocItemPos = {
139
147
  position: pos,
140
148
  textContent: node.textContent
@@ -198,6 +206,11 @@ var LinkTooltipView = /*#__PURE__*/function () {
198
206
  var href = anchor.getAttribute('href');
199
207
  var selectionId = anchor.getAttribute('selectionid');
200
208
  var tocItemPos = this.dom._linkTooltipView.getInnerlinkSelected_position(this.dom._linkTooltipView._view, result.mark.attrs.selectionId);
209
+ if (null === tocItemPos) {
210
+ this.dom._linkTooltipView.openSelectedSection(selectionId);
211
+ event.preventDefault(); // prevent default browser navigation
212
+ return true;
213
+ }
201
214
  this.dom._linkTooltipView.jumpLink(this.dom._linkTooltipView._view, tocItemPos, href, selectionId);
202
215
  event.preventDefault(); // prevent default browser navigation
203
216
  return true;
@@ -107,7 +107,11 @@ class LinkTooltipView {
107
107
  this.dom._linkTooltipView._view,
108
108
  result.mark.attrs.selectionId
109
109
  );
110
-
110
+ if (null === tocItemPos) {
111
+ this.dom._linkTooltipView.openSelectedSection(selectionId);
112
+ event.preventDefault(); // prevent default browser navigation
113
+ return true;
114
+ }
111
115
  this.dom._linkTooltipView.jumpLink(
112
116
  this.dom._linkTooltipView._view,
113
117
  tocItemPos,
@@ -130,6 +134,13 @@ class LinkTooltipView {
130
134
  this._popup?.close();
131
135
  }
132
136
 
137
+ openSelectedSection = (selectionId): void => {
138
+ if (selectionId) {
139
+ if (this._view?.runtime?.goToInnerLinkSection) {
140
+ this._view.runtime.goToInnerLinkSection(selectionId);
141
+ }
142
+ }
143
+ };
133
144
  jumpLink = (view: EditorView, tocItemPos, href, selectionId): void => {
134
145
  if (selectionId || (selectionId === 0 && tocItemPos)) {
135
146
  this.jumpInnerLink(view, tocItemPos);
@@ -194,7 +205,7 @@ class LinkTooltipView {
194
205
  let tocItemPos = null;
195
206
  if (selectionId) {
196
207
  view.state.tr.doc.descendants((node, pos) => {
197
- if (node.attrs.styleName && node.attrs.innerLink === selectionId) {
208
+ if (node.attrs.styleName && node.attrs.selectionId === selectionId) {
198
209
  tocItemPos = { position: pos, textContent: node.textContent };
199
210
  }
200
211
  });
@@ -48,9 +48,6 @@ var ParagraphNodeSpec = {
48
48
  reset: {
49
49
  "default": null
50
50
  },
51
- innerLink: {
52
- "default": null
53
- },
54
51
  // added attributes for indent, align and linespacing overrides.
55
52
  overriddenAlign: {
56
53
  "default": null
@@ -103,7 +100,7 @@ function getAttrs(dom) {
103
100
  var overriddenLineSpacingValue = dom.getAttribute('overriddenLineSpacingValue') || '';
104
101
  var overriddenIndent = dom.getAttribute('overriddenIndent') || '';
105
102
  var overriddenIndentValue = dom.getAttribute('overriddenIndentValue') || '';
106
- var innerLink = dom.getAttribute('innerLink') || '';
103
+ var selectionId = dom.getAttribute('selectionId') || '';
107
104
  var objectId = dom.getAttribute('objectId') || '';
108
105
  return {
109
106
  align: align,
@@ -119,7 +116,7 @@ function getAttrs(dom) {
119
116
  overriddenLineSpacingValue: overriddenLineSpacingValue,
120
117
  overriddenIndent: overriddenIndent,
121
118
  overriddenIndentValue: overriddenIndentValue,
122
- innerLink: innerLink,
119
+ selectionId: selectionId,
123
120
  objectId: objectId
124
121
  };
125
122
  }
@@ -158,7 +155,7 @@ function toDOM(node) {
158
155
  overriddenLineSpacingValue = _node$attrs.overriddenLineSpacingValue,
159
156
  overriddenIndent = _node$attrs.overriddenIndent,
160
157
  overriddenIndentValue = _node$attrs.overriddenIndentValue,
161
- innerLink = _node$attrs.innerLink;
158
+ selectionId = _node$attrs.selectionId;
162
159
  var attrs = _objectSpread({}, node.attrs);
163
160
  var _getStyle = getStyle(node.attrs),
164
161
  style = _getStyle.style;
@@ -176,8 +173,8 @@ function toDOM(node) {
176
173
  attrs.overriddenAlignValue = overriddenAlignValue;
177
174
  attrs.overriddenLineSpacingValue = overriddenLineSpacingValue;
178
175
  attrs.overriddenIndentValue = overriddenIndentValue;
179
- if (innerLink) {
180
- attrs.innerLink = innerLink;
176
+ if (selectionId) {
177
+ attrs.selectionId = selectionId;
181
178
  }
182
179
  return ['p', attrs, 0];
183
180
  }
@@ -3,7 +3,6 @@
3
3
  import convertToCSSPTValue from './convertToCSSPTValue.js';
4
4
  import toCSSLineSpacing from './ui/toCSSLineSpacing.js';
5
5
  import { Node } from 'prosemirror-model';
6
-
7
6
  import type { NodeSpec } from './Types.js';
8
7
 
9
8
  // This assumes that every 36pt maps to one indent level.
@@ -49,9 +48,7 @@ const ParagraphNodeSpec: NodeSpec = {
49
48
  reset: {
50
49
  default: null,
51
50
  },
52
- innerLink: {
53
- default: null,
54
- },
51
+
55
52
  // added attributes for indent, align and linespacing overrides.
56
53
  overriddenAlign: {
57
54
  default: null,
@@ -110,7 +107,7 @@ function getAttrs(dom: HTMLElement): Object {
110
107
  dom.getAttribute('overriddenLineSpacingValue') || '';
111
108
  const overriddenIndent = dom.getAttribute('overriddenIndent') || '';
112
109
  const overriddenIndentValue = dom.getAttribute('overriddenIndentValue') || '';
113
- const innerLink = dom.getAttribute('innerLink') || '';
110
+ const selectionId = dom.getAttribute('selectionId') || '';
114
111
  const objectId = dom.getAttribute('objectId') || '';
115
112
  return {
116
113
  align,
@@ -126,7 +123,7 @@ function getAttrs(dom: HTMLElement): Object {
126
123
  overriddenLineSpacingValue,
127
124
  overriddenIndent,
128
125
  overriddenIndentValue,
129
- innerLink,
126
+ selectionId,
130
127
  objectId,
131
128
  };
132
129
  }
@@ -175,7 +172,7 @@ function toDOM(node: Node): Array<any> {
175
172
  overriddenLineSpacingValue,
176
173
  overriddenIndent,
177
174
  overriddenIndentValue,
178
- innerLink,
175
+ selectionId,
179
176
  } = node.attrs;
180
177
  const attrs = { ...node.attrs };
181
178
  const { style } = getStyle(node.attrs);
@@ -196,9 +193,10 @@ function toDOM(node: Node): Array<any> {
196
193
  attrs.overriddenLineSpacingValue = overriddenLineSpacingValue;
197
194
  attrs.overriddenIndentValue = overriddenIndentValue;
198
195
 
199
- if (innerLink) {
200
- attrs.innerLink = innerLink;
196
+ if (selectionId) {
197
+ attrs.selectionId = selectionId;
201
198
  }
199
+
202
200
  return ['p', attrs, 0];
203
201
  }
204
202