@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modusoperandi/licit",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"subversion": "1",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"exports-loader": "^5.0.0",
|
|
91
91
|
"express": "^5.1.0",
|
|
92
92
|
"file-loader": "^6.2.0",
|
|
93
|
-
"flow-bin": "^0.
|
|
93
|
+
"flow-bin": "^0.269.1",
|
|
94
94
|
"flow-copy-source": "^2.0.9",
|
|
95
95
|
"flow-typed": "^4.0.0",
|
|
96
96
|
"flow-webpack-plugin": "^1.2.0",
|
package/ui/Icon.js
CHANGED
|
@@ -12,7 +12,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
12
12
|
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
13
13
|
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); }
|
|
14
14
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
15
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/
|
|
15
|
+
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; }
|
|
16
16
|
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); }
|
|
17
17
|
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); }); }; }
|
|
18
18
|
import cx from 'classnames';
|
package/ui/LinkTooltip.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
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; }
|
|
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
|
-
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
2
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
6
3
|
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); } }
|
|
7
4
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -16,14 +13,8 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
16
13
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
14
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
15
|
import { EditorView } from 'prosemirror-view';
|
|
19
|
-
import { TextSelection } from 'prosemirror-state';
|
|
20
16
|
import * as React from 'react';
|
|
21
|
-
import scrollIntoView from 'smooth-scroll-into-view-if-needed';
|
|
22
|
-
import sanitizeURL from '../sanitizeURL.js';
|
|
23
17
|
import { CustomButton } from '@modusoperandi/licit-ui-commands';
|
|
24
|
-
function isBookMarkHref(href) {
|
|
25
|
-
return !!href && href.startsWith('#') && href.length >= 2;
|
|
26
|
-
}
|
|
27
18
|
var LinkTooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
28
19
|
function LinkTooltip() {
|
|
29
20
|
var _this;
|
|
@@ -33,77 +24,16 @@ var LinkTooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
33
24
|
}
|
|
34
25
|
_this = _callSuper(this, LinkTooltip, [].concat(args));
|
|
35
26
|
_defineProperty(_this, "props", void 0);
|
|
36
|
-
_defineProperty(_this, "jumpLink", function (view, tocItemPos, href, selectionId) {
|
|
37
|
-
if (selectionId || selectionId === 0 && tocItemPos) {
|
|
38
|
-
_this.jumpInnerLink(view, tocItemPos);
|
|
39
|
-
} else {
|
|
40
|
-
_this._openLink(href);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
_defineProperty(_this, "jumpInnerLink", function (view, tocItemPos) {
|
|
44
|
-
var transaction = view.state.tr;
|
|
45
|
-
var tr = transaction.setSelection(TextSelection.create(transaction.doc, tocItemPos + 1));
|
|
46
|
-
view.dispatch(tr.scrollIntoView(true));
|
|
47
|
-
});
|
|
48
|
-
_defineProperty(_this, "_openLink", function (href) {
|
|
49
|
-
if (isBookMarkHref(href)) {
|
|
50
|
-
var id = href.substr(1);
|
|
51
|
-
var el = document.getElementById(id);
|
|
52
|
-
if (el) {
|
|
53
|
-
var _this$props = _this.props,
|
|
54
|
-
onCancel = _this$props.onCancel,
|
|
55
|
-
editorView = _this$props.editorView;
|
|
56
|
-
onCancel(editorView);
|
|
57
|
-
_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
58
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
59
|
-
while (1) switch (_context.prev = _context.next) {
|
|
60
|
-
case 0:
|
|
61
|
-
_context.next = 2;
|
|
62
|
-
return scrollIntoView(el, {
|
|
63
|
-
scrollMode: 'if-needed',
|
|
64
|
-
behavior: 'smooth'
|
|
65
|
-
});
|
|
66
|
-
case 2:
|
|
67
|
-
case "end":
|
|
68
|
-
return _context.stop();
|
|
69
|
-
}
|
|
70
|
-
}, _callee);
|
|
71
|
-
}))();
|
|
72
|
-
}
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (href) {
|
|
76
|
-
var _this$props$editorVie;
|
|
77
|
-
var url = sanitizeURL(href);
|
|
78
|
-
var popupString;
|
|
79
|
-
if (_this.props.editorView.editable) {
|
|
80
|
-
popupString = 'Any unsaved changes will be lost';
|
|
81
|
-
} else {
|
|
82
|
-
popupString = '';
|
|
83
|
-
}
|
|
84
|
-
if ((_this$props$editorVie = _this.props.editorView) !== null && _this$props$editorVie !== void 0 && (_this$props$editorVie = _this$props$editorVie.runtime) !== null && _this$props$editorVie !== void 0 && _this$props$editorVie.openLinkDialog) {
|
|
85
|
-
_this.props.editorView.runtime.openLinkDialog(url, popupString);
|
|
86
|
-
} else {
|
|
87
|
-
window.open(url);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
27
|
return _this;
|
|
92
28
|
}
|
|
93
29
|
_inherits(LinkTooltip, _React$PureComponent);
|
|
94
30
|
return _createClass(LinkTooltip, [{
|
|
95
31
|
key: "render",
|
|
96
32
|
value: function render() {
|
|
97
|
-
var
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
onEdit = _this$props2.onEdit,
|
|
102
|
-
onRemove = _this$props2.onRemove,
|
|
103
|
-
tocItemPos_ = _this$props2.tocItemPos_,
|
|
104
|
-
selectionId_ = _this$props2.selectionId_;
|
|
105
|
-
var canEdit = editorView.editable;
|
|
106
|
-
// [FS] IRAD-1013 2020-07-09
|
|
33
|
+
var _this$props = this.props,
|
|
34
|
+
href = _this$props.href,
|
|
35
|
+
tocItemPos_ = _this$props.tocItemPos_,
|
|
36
|
+
selectionId_ = _this$props.selectionId_;
|
|
107
37
|
var getLabel = function getLabel() {
|
|
108
38
|
if (tocItemPos_ && selectionId_) {
|
|
109
39
|
return tocItemPos_.textContent === '' ? 'Reference not found' : tocItemPos_.textContent;
|
|
@@ -123,23 +53,12 @@ var LinkTooltip = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
123
53
|
}, /*#__PURE__*/React.createElement(CustomButton, {
|
|
124
54
|
className: "czi-link-tooltip-href ".concat(isRemoved ? 'red-text disabled' : ''),
|
|
125
55
|
label: label,
|
|
126
|
-
onClick: !isRemoved ? function () {
|
|
127
|
-
return _this2.jumpLink(editorView, tocItemPos_ === null || tocItemPos_ === void 0 ? void 0 : tocItemPos_.position, href, selectionId_);
|
|
128
|
-
} : undefined,
|
|
129
56
|
style: {
|
|
130
57
|
color: isRemoved ? 'red' : undefined
|
|
131
58
|
},
|
|
132
59
|
target: "new",
|
|
133
60
|
title: label,
|
|
134
61
|
value: label
|
|
135
|
-
}), canEdit && /*#__PURE__*/React.createElement(CustomButton, {
|
|
136
|
-
label: "Change",
|
|
137
|
-
onClick: onEdit,
|
|
138
|
-
value: editorView
|
|
139
|
-
}), canEdit && /*#__PURE__*/React.createElement(CustomButton, {
|
|
140
|
-
label: "Remove",
|
|
141
|
-
onClick: onRemove,
|
|
142
|
-
value: editorView
|
|
143
62
|
}))));
|
|
144
63
|
}
|
|
145
64
|
}]);
|
package/ui/LinkTooltip.js.flow
CHANGED
|
@@ -1,35 +1,24 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
3
|
import { EditorView } from 'prosemirror-view';
|
|
4
|
-
import { TextSelection } from 'prosemirror-state';
|
|
5
4
|
import * as React from 'react';
|
|
6
|
-
import scrollIntoView from 'smooth-scroll-into-view-if-needed';
|
|
7
5
|
|
|
8
|
-
import sanitizeURL from '../sanitizeURL.js';
|
|
9
6
|
import { CustomButton } from '@modusoperandi/licit-ui-commands';
|
|
10
7
|
|
|
11
|
-
function isBookMarkHref(href: string): boolean {
|
|
12
|
-
return !!href && href.startsWith('#') && href.length >= 2;
|
|
13
|
-
}
|
|
14
8
|
|
|
15
9
|
class LinkTooltip extends React.PureComponent<any, any> {
|
|
16
10
|
props: {
|
|
17
11
|
editorView: EditorView,
|
|
18
12
|
href: string,
|
|
19
|
-
onCancel: (view: EditorView) => void,
|
|
20
|
-
onEdit: (view: EditorView) => void,
|
|
21
|
-
onRemove: (view: EditorView) => void,
|
|
22
13
|
};
|
|
23
14
|
|
|
24
15
|
render(): React.Element<any> {
|
|
25
|
-
const { href,
|
|
16
|
+
const { href, tocItemPos_, selectionId_ } =
|
|
26
17
|
this.props;
|
|
27
|
-
const canEdit = editorView.editable;
|
|
28
|
-
// [FS] IRAD-1013 2020-07-09
|
|
29
18
|
const getLabel = () => {
|
|
30
19
|
if (tocItemPos_ && selectionId_) {
|
|
31
20
|
return tocItemPos_.textContent === '' ? 'Reference not found' : tocItemPos_.textContent;
|
|
32
|
-
}else if(!tocItemPos_ && selectionId_){
|
|
21
|
+
} else if (!tocItemPos_ && selectionId_) {
|
|
33
22
|
return 'Reference not found';
|
|
34
23
|
}
|
|
35
24
|
return href;
|
|
@@ -45,81 +34,18 @@ class LinkTooltip extends React.PureComponent<any, any> {
|
|
|
45
34
|
<CustomButton
|
|
46
35
|
className={`czi-link-tooltip-href ${isRemoved ? 'red-text disabled' : ''}`}
|
|
47
36
|
label={label}
|
|
48
|
-
onClick={!isRemoved ? () =>
|
|
49
|
-
this.jumpLink(editorView, tocItemPos_?.position, href, selectionId_)
|
|
50
|
-
: undefined
|
|
51
|
-
}
|
|
52
37
|
style={{ color: isRemoved ? 'red' : undefined }}
|
|
53
38
|
target="new"
|
|
54
39
|
title={label}
|
|
55
40
|
value={label}
|
|
56
41
|
/>
|
|
57
|
-
|
|
58
|
-
<CustomButton label="Change" onClick={onEdit} value={editorView} />
|
|
59
|
-
)}
|
|
60
|
-
{canEdit && (
|
|
61
|
-
<CustomButton
|
|
62
|
-
label="Remove"
|
|
63
|
-
onClick={onRemove}
|
|
64
|
-
value={editorView}
|
|
65
|
-
/>
|
|
66
|
-
)}
|
|
42
|
+
|
|
67
43
|
</div>
|
|
68
44
|
</div>
|
|
69
45
|
</div>
|
|
70
46
|
);
|
|
71
47
|
}
|
|
72
48
|
|
|
73
|
-
jumpLink = (view: EditorView, tocItemPos, href, selectionId): void => {
|
|
74
|
-
if (selectionId || (selectionId === 0 && tocItemPos)) {
|
|
75
|
-
this.jumpInnerLink(view, tocItemPos);
|
|
76
|
-
} else {
|
|
77
|
-
this._openLink(href);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
jumpInnerLink = (view: EditorView, tocItemPos): void => {
|
|
82
|
-
const transaction = view.state.tr;
|
|
83
|
-
const tr = transaction.setSelection(
|
|
84
|
-
TextSelection.create(transaction.doc, tocItemPos + 1)
|
|
85
|
-
);
|
|
86
|
-
view.dispatch(tr.scrollIntoView(true));
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
_openLink = (href: string): void => {
|
|
90
|
-
if (isBookMarkHref(href)) {
|
|
91
|
-
const id = href.substr(1);
|
|
92
|
-
const el = document.getElementById(id);
|
|
93
|
-
if (el) {
|
|
94
|
-
const { onCancel, editorView } = this.props;
|
|
95
|
-
onCancel(editorView);
|
|
96
|
-
(async () => {
|
|
97
|
-
// https://www.npmjs.com/package/smooth-scroll-into-view-if-needed
|
|
98
|
-
await scrollIntoView(el, {
|
|
99
|
-
scrollMode: 'if-needed',
|
|
100
|
-
behavior: 'smooth',
|
|
101
|
-
});
|
|
102
|
-
})();
|
|
103
|
-
}
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (href) {
|
|
107
|
-
const url = sanitizeURL(href);
|
|
108
|
-
let popupString;
|
|
109
|
-
|
|
110
|
-
if (this.props.editorView.editable) {
|
|
111
|
-
popupString = 'Any unsaved changes will be lost';
|
|
112
|
-
} else {
|
|
113
|
-
popupString = '';
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (this.props.editorView?.runtime?.openLinkDialog) {
|
|
117
|
-
this.props.editorView.runtime.openLinkDialog(url, popupString);
|
|
118
|
-
} else {
|
|
119
|
-
window.open(url);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
49
|
}
|
|
124
50
|
|
|
125
51
|
export default LinkTooltip;
|