@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.
- package/LinkSetURLCommand.js +2 -2
- package/LinkSetURLCommand.js.flow +1 -1
- package/LinkTooltipPlugin.js +142 -189
- package/LinkTooltipPlugin.js.flow +140 -195
- package/bom.xml +1902 -1696
- package/package.json +2 -2
- package/ui/Icon.js +1 -1
- package/ui/LinkTooltip.js +4 -85
- package/ui/LinkTooltip.js.flow +3 -77
- package/ui/czi-editor.css +4 -0
package/LinkSetURLCommand.js
CHANGED
|
@@ -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/
|
|
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 = {
|
package/LinkTooltipPlugin.js
CHANGED
|
@@ -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/
|
|
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 {
|
|
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 {
|
|
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
|
|
26
|
-
import
|
|
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
|
-
|
|
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(
|
|
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, "
|
|
52
|
-
_defineProperty(this, "
|
|
53
|
-
|
|
54
|
-
|
|
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, "
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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, "
|
|
62
|
-
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
127
|
-
var
|
|
128
|
-
var
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
_this
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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: "
|
|
208
|
-
value: function
|
|
209
|
-
var 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
|
-
|
|
222
|
-
return;
|
|
186
|
+
return false;
|
|
223
187
|
}
|
|
224
|
-
var domFound =
|
|
188
|
+
var domFound = this.dom._linkTooltipView._view.domAtPos(from);
|
|
225
189
|
if (!domFound) {
|
|
226
|
-
|
|
227
|
-
return;
|
|
190
|
+
return false;
|
|
228
191
|
}
|
|
229
|
-
var
|
|
192
|
+
var anchor = lookUpElement(domFound.node, function (el) {
|
|
230
193
|
return el.nodeName === 'A';
|
|
231
194
|
});
|
|
232
|
-
if (!
|
|
233
|
-
|
|
234
|
-
return;
|
|
195
|
+
if (!anchor) {
|
|
196
|
+
return false;
|
|
235
197
|
}
|
|
236
|
-
var
|
|
237
|
-
var
|
|
238
|
-
var
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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$
|
|
265
|
-
(_this$
|
|
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
|
}();
|