@umoteam/editor-external 10.0.0 → 10.1.0

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.
@@ -12,112 +12,98 @@ return /******/ (function() { // webpackBootstrap
12
12
  /******/ "use strict";
13
13
  var __webpack_exports__ = {};
14
14
 
15
- ;// CONCATENATED MODULE: ./contrib/copy-tex/katex2tex.js
15
+ ;// ./contrib/copy-tex/katex2tex.ts
16
16
  // Set these to how you want inline and display math to be delimited.
17
17
  const defaultCopyDelimiters = {
18
18
  inline: ['$', '$'],
19
19
  // alternative: ['\(', '\)']
20
20
  display: ['$$', '$$'] // alternative: ['\[', '\]']
21
+ };
21
22
 
22
- }; // Replace .katex elements with their TeX source (<annotation> element).
23
+ // Replace .katex elements with their TeX source (<annotation> element).
23
24
  // Modifies fragment in-place. Useful for writing your own 'copy' handler,
24
25
  // as in copy-tex.js.
25
-
26
26
  function katexReplaceWithTex(fragment, copyDelimiters) {
27
27
  if (copyDelimiters === void 0) {
28
28
  copyDelimiters = defaultCopyDelimiters;
29
29
  }
30
-
31
30
  // Remove .katex-html blocks that are preceded by .katex-mathml blocks
32
31
  // (which will get replaced below).
33
32
  const katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html');
34
-
35
33
  for (let i = 0; i < katexHtml.length; i++) {
36
34
  const element = katexHtml[i];
37
-
38
35
  if (element.remove) {
39
36
  element.remove();
40
37
  } else if (element.parentNode) {
41
38
  element.parentNode.removeChild(element);
42
39
  }
43
- } // Replace .katex-mathml elements with their annotation (TeX source)
40
+ }
41
+ // Replace .katex-mathml elements with their annotation (TeX source)
44
42
  // descendant, with inline delimiters.
45
-
46
-
47
43
  const katexMathml = fragment.querySelectorAll('.katex-mathml');
48
-
49
44
  for (let i = 0; i < katexMathml.length; i++) {
50
45
  const element = katexMathml[i];
51
46
  const texSource = element.querySelector('annotation');
52
-
53
47
  if (texSource) {
54
48
  if (element.replaceWith) {
55
49
  element.replaceWith(texSource);
56
50
  } else if (element.parentNode) {
57
51
  element.parentNode.replaceChild(texSource, element);
58
52
  }
59
-
60
53
  texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1];
61
54
  }
62
- } // Switch display math to display delimiters.
63
-
64
-
55
+ }
56
+ // Switch display math to display delimiters.
65
57
  const displays = fragment.querySelectorAll('.katex-display annotation');
66
-
67
58
  for (let i = 0; i < displays.length; i++) {
68
59
  const element = displays[i];
69
60
  element.innerHTML = copyDelimiters.display[0] + element.innerHTML.substr(copyDelimiters.inline[0].length, element.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1];
70
61
  }
71
-
72
62
  return fragment;
73
63
  }
74
64
  /* harmony default export */ var katex2tex = (katexReplaceWithTex);
75
- ;// CONCATENATED MODULE: ./contrib/copy-tex/copy-tex.js
76
- // Return <div class="katex"> element containing node, or null if not found.
65
+ ;// ./contrib/copy-tex/copy-tex.ts
77
66
 
67
+
68
+ // Return <div class="katex"> element containing node, or null if not found.
78
69
  function closestKatex(node) {
79
70
  // If node is a Text Node, for example, go up to containing Element,
80
71
  // where we can apply the `closest` method.
81
72
  const element = node instanceof Element ? node : node.parentElement;
82
73
  return element && element.closest('.katex');
83
- } // Global copy handler to modify behavior on/within .katex elements.
84
-
74
+ }
85
75
 
76
+ // Global copy handler to modify behavior on/within .katex elements.
86
77
  document.addEventListener('copy', function (event) {
87
78
  const selection = window.getSelection();
88
-
89
- if (selection.isCollapsed || !event.clipboardData) {
79
+ if (!selection || selection.isCollapsed || !event.clipboardData) {
90
80
  return; // default action OK if selection is empty or unchangeable
91
81
  }
92
-
93
82
  const clipboardData = event.clipboardData;
94
- const range = selection.getRangeAt(0); // When start point is within a formula, expand to entire formula.
83
+ const range = selection.getRangeAt(0);
95
84
 
85
+ // When start point is within a formula, expand to entire formula.
96
86
  const startKatex = closestKatex(range.startContainer);
97
-
98
87
  if (startKatex) {
99
88
  range.setStartBefore(startKatex);
100
- } // Similarly, when end point is within a formula, expand to entire formula.
101
-
89
+ }
102
90
 
91
+ // Similarly, when end point is within a formula, expand to entire formula.
103
92
  const endKatex = closestKatex(range.endContainer);
104
-
105
93
  if (endKatex) {
106
94
  range.setEndAfter(endKatex);
107
95
  }
108
-
109
96
  const fragment = range.cloneContents();
110
-
111
97
  if (!fragment.querySelector('.katex-mathml')) {
112
98
  return; // default action OK if no .katex-mathml elements
113
99
  }
100
+ const htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join('');
114
101
 
115
- const htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join(''); // Preserve usual HTML copy/paste behavior.
116
-
117
- clipboardData.setData('text/html', htmlContents); // Rewrite plain-text version.
118
-
119
- clipboardData.setData('text/plain', katex2tex(fragment).textContent); // Prevent normal copy handling.
120
-
102
+ // Preserve usual HTML copy/paste behavior.
103
+ clipboardData.setData('text/html', htmlContents);
104
+ // Rewrite plain-text version.
105
+ clipboardData.setData('text/plain', katex2tex(fragment).textContent);
106
+ // Prevent normal copy handling.
121
107
  event.preventDefault();
122
108
  });
123
109
  __webpack_exports__ = __webpack_exports__["default"];
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}("undefined"!=typeof self?self:this,(function(){return function(){"use strict";var e={};const t={inline:["$","$"],display:["$$","$$"]};var n=function(e,n){void 0===n&&(n=t);const o=e.querySelectorAll(".katex-mathml + .katex-html");for(let e=0;e<o.length;e++){const t=o[e];t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)}const r=e.querySelectorAll(".katex-mathml");for(let e=0;e<r.length;e++){const t=r[e],o=t.querySelector("annotation");o&&(t.replaceWith?t.replaceWith(o):t.parentNode&&t.parentNode.replaceChild(o,t),o.innerHTML=n.inline[0]+o.innerHTML+n.inline[1])}const l=e.querySelectorAll(".katex-display annotation");for(let e=0;e<l.length;e++){const t=l[e];t.innerHTML=n.display[0]+t.innerHTML.substr(n.inline[0].length,t.innerHTML.length-n.inline[0].length-n.inline[1].length)+n.display[1]}return e};function o(e){const t=e instanceof Element?e:e.parentElement;return t&&t.closest(".katex")}return document.addEventListener("copy",(function(e){const t=window.getSelection();if(t.isCollapsed||!e.clipboardData)return;const r=e.clipboardData,l=t.getRangeAt(0),i=o(l.startContainer);i&&l.setStartBefore(i);const a=o(l.endContainer);a&&l.setEndAfter(a);const s=l.cloneContents();if(!s.querySelector(".katex-mathml"))return;const c=Array.prototype.map.call(s.childNodes,(e=>e instanceof Text?e.textContent:e.outerHTML)).join("");r.setData("text/html",c),r.setData("text/plain",n(s).textContent),e.preventDefault()})),e=e.default}()}));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}("undefined"!=typeof self?self:this,function(){return function(){"use strict";var e={};const t={inline:["$","$"],display:["$$","$$"]};var n=function(e,n){void 0===n&&(n=t);const o=e.querySelectorAll(".katex-mathml + .katex-html");for(let e=0;e<o.length;e++){const t=o[e];t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)}const r=e.querySelectorAll(".katex-mathml");for(let e=0;e<r.length;e++){const t=r[e],o=t.querySelector("annotation");o&&(t.replaceWith?t.replaceWith(o):t.parentNode&&t.parentNode.replaceChild(o,t),o.innerHTML=n.inline[0]+o.innerHTML+n.inline[1])}const l=e.querySelectorAll(".katex-display annotation");for(let e=0;e<l.length;e++){const t=l[e];t.innerHTML=n.display[0]+t.innerHTML.substr(n.inline[0].length,t.innerHTML.length-n.inline[0].length-n.inline[1].length)+n.display[1]}return e};function o(e){const t=e instanceof Element?e:e.parentElement;return t&&t.closest(".katex")}return document.addEventListener("copy",function(e){const t=window.getSelection();if(!t||t.isCollapsed||!e.clipboardData)return;const r=e.clipboardData,l=t.getRangeAt(0),i=o(l.startContainer);i&&l.setStartBefore(i);const a=o(l.endContainer);a&&l.setEndAfter(a);const s=l.cloneContents();if(!s.querySelector(".katex-mathml"))return;const c=Array.prototype.map.call(s.childNodes,e=>e instanceof Text?e.textContent:e.outerHTML).join("");r.setData("text/html",c),r.setData("text/plain",n(s).textContent),e.preventDefault()}),e=e.default}()});
@@ -3,103 +3,83 @@ var defaultCopyDelimiters = {
3
3
  inline: ['$', '$'],
4
4
  // alternative: ['\(', '\)']
5
5
  display: ['$$', '$$'] // alternative: ['\[', '\]']
6
-
7
- }; // Replace .katex elements with their TeX source (<annotation> element).
6
+ };
7
+ // Replace .katex elements with their TeX source (<annotation> element).
8
8
  // Modifies fragment in-place. Useful for writing your own 'copy' handler,
9
9
  // as in copy-tex.js.
10
-
11
10
  function katexReplaceWithTex(fragment, copyDelimiters) {
12
11
  if (copyDelimiters === void 0) {
13
12
  copyDelimiters = defaultCopyDelimiters;
14
13
  }
15
-
16
14
  // Remove .katex-html blocks that are preceded by .katex-mathml blocks
17
15
  // (which will get replaced below).
18
16
  var katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html');
19
-
20
17
  for (var i = 0; i < katexHtml.length; i++) {
21
18
  var element = katexHtml[i];
22
-
23
19
  if (element.remove) {
24
20
  element.remove();
25
21
  } else if (element.parentNode) {
26
22
  element.parentNode.removeChild(element);
27
23
  }
28
- } // Replace .katex-mathml elements with their annotation (TeX source)
24
+ }
25
+ // Replace .katex-mathml elements with their annotation (TeX source)
29
26
  // descendant, with inline delimiters.
30
-
31
-
32
27
  var katexMathml = fragment.querySelectorAll('.katex-mathml');
33
-
34
28
  for (var _i = 0; _i < katexMathml.length; _i++) {
35
29
  var _element = katexMathml[_i];
36
-
37
30
  var texSource = _element.querySelector('annotation');
38
-
39
31
  if (texSource) {
40
32
  if (_element.replaceWith) {
41
33
  _element.replaceWith(texSource);
42
34
  } else if (_element.parentNode) {
43
35
  _element.parentNode.replaceChild(texSource, _element);
44
36
  }
45
-
46
37
  texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1];
47
38
  }
48
- } // Switch display math to display delimiters.
49
-
50
-
39
+ }
40
+ // Switch display math to display delimiters.
51
41
  var displays = fragment.querySelectorAll('.katex-display annotation');
52
-
53
42
  for (var _i2 = 0; _i2 < displays.length; _i2++) {
54
43
  var _element2 = displays[_i2];
55
44
  _element2.innerHTML = copyDelimiters.display[0] + _element2.innerHTML.substr(copyDelimiters.inline[0].length, _element2.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1];
56
45
  }
57
-
58
46
  return fragment;
59
47
  }
60
48
 
49
+ // Return <div class="katex"> element containing node, or null if not found.
61
50
  function closestKatex(node) {
62
51
  // If node is a Text Node, for example, go up to containing Element,
63
52
  // where we can apply the `closest` method.
64
53
  var element = node instanceof Element ? node : node.parentElement;
65
54
  return element && element.closest('.katex');
66
- } // Global copy handler to modify behavior on/within .katex elements.
67
-
68
-
55
+ }
56
+ // Global copy handler to modify behavior on/within .katex elements.
69
57
  document.addEventListener('copy', function (event) {
70
58
  var selection = window.getSelection();
71
-
72
- if (selection.isCollapsed || !event.clipboardData) {
59
+ if (!selection || selection.isCollapsed || !event.clipboardData) {
73
60
  return; // default action OK if selection is empty or unchangeable
74
61
  }
75
-
76
62
  var clipboardData = event.clipboardData;
77
- var range = selection.getRangeAt(0); // When start point is within a formula, expand to entire formula.
78
-
63
+ var range = selection.getRangeAt(0);
64
+ // When start point is within a formula, expand to entire formula.
79
65
  var startKatex = closestKatex(range.startContainer);
80
-
81
66
  if (startKatex) {
82
67
  range.setStartBefore(startKatex);
83
- } // Similarly, when end point is within a formula, expand to entire formula.
84
-
85
-
68
+ }
69
+ // Similarly, when end point is within a formula, expand to entire formula.
86
70
  var endKatex = closestKatex(range.endContainer);
87
-
88
71
  if (endKatex) {
89
72
  range.setEndAfter(endKatex);
90
73
  }
91
-
92
74
  var fragment = range.cloneContents();
93
-
94
75
  if (!fragment.querySelector('.katex-mathml')) {
95
76
  return; // default action OK if no .katex-mathml elements
96
77
  }
97
-
98
- var htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join(''); // Preserve usual HTML copy/paste behavior.
99
-
100
- clipboardData.setData('text/html', htmlContents); // Rewrite plain-text version.
101
-
102
- clipboardData.setData('text/plain', katexReplaceWithTex(fragment).textContent); // Prevent normal copy handling.
103
-
78
+ var htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join('');
79
+ // Preserve usual HTML copy/paste behavior.
80
+ clipboardData.setData('text/html', htmlContents);
81
+ // Rewrite plain-text version.
82
+ clipboardData.setData('text/plain', katexReplaceWithTex(fragment).textContent);
83
+ // Prevent normal copy handling.
104
84
  event.preventDefault();
105
85
  });
@@ -7,15 +7,15 @@
7
7
  var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]);
8
8
  for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9
9
  }
10
- })((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__771__) {
10
+ })((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__757__) {
11
11
  return /******/ (function() { // webpackBootstrap
12
12
  /******/ "use strict";
13
13
  /******/ var __webpack_modules__ = ({
14
14
 
15
- /***/ 771:
15
+ /***/ 757:
16
16
  /***/ (function(module) {
17
17
 
18
- module.exports = __WEBPACK_EXTERNAL_MODULE__771__;
18
+ module.exports = __WEBPACK_EXTERNAL_MODULE__757__;
19
19
 
20
20
  /***/ })
21
21
 
@@ -77,9 +77,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__771__;
77
77
  /******/
78
78
  /************************************************************************/
79
79
  var __webpack_exports__ = {};
80
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
81
- !function() {
82
- /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(771);
80
+ /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(757);
83
81
  /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__);
84
82
 
85
83
  let scripts = document.body.getElementsByTagName("script");
@@ -88,11 +86,9 @@ scripts.forEach(function (script) {
88
86
  if (!script.type || !script.type.match(/math\/tex/i)) {
89
87
  return -1;
90
88
  }
91
-
92
89
  const display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null;
93
90
  const katexElement = document.createElement(display ? "div" : "span");
94
91
  katexElement.setAttribute("class", display ? "equation" : "inline-equation");
95
-
96
92
  try {
97
93
  katex__WEBPACK_IMPORTED_MODULE_0___default().render(script.text, katexElement, {
98
94
  displayMode: display
@@ -101,10 +97,8 @@ scripts.forEach(function (script) {
101
97
  //console.error(err); linter doesn't like this
102
98
  katexElement.textContent = script.text;
103
99
  }
104
-
105
100
  script.parentNode.replaceChild(katexElement, script);
106
101
  });
107
- }();
108
102
  __webpack_exports__ = __webpack_exports__["default"];
109
103
  /******/ return __webpack_exports__;
110
104
  /******/ })()
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],t);else{var n="object"==typeof exports?t(require("katex")):t(e.katex);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}("undefined"!=typeof self?self:this,(function(e){return function(){"use strict";var t={771:function(t){t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o={};return function(){var e=r(771),t=r.n(e);let n=document.body.getElementsByTagName("script");n=Array.prototype.slice.call(n),n.forEach((function(e){if(!e.type||!e.type.match(/math\/tex/i))return-1;const n=null!=e.type.match(/mode\s*=\s*display(;|\s|\n|$)/),r=document.createElement(n?"div":"span");r.setAttribute("class",n?"equation":"inline-equation");try{t().render(e.text,r,{displayMode:n})}catch(t){r.textContent=e.text}e.parentNode.replaceChild(r,e)}))}(),o=o.default}()}));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],t);else{var n="object"==typeof exports?t(require("katex")):t(e.katex);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}("undefined"!=typeof self?self:this,function(e){return function(){"use strict";var t={757:function(t){t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o={},i=r(757),a=r.n(i);let u=document.body.getElementsByTagName("script");return u=Array.prototype.slice.call(u),u.forEach(function(e){if(!e.type||!e.type.match(/math\/tex/i))return-1;const t=null!=e.type.match(/mode\s*=\s*display(;|\s|\n|$)/),n=document.createElement(t?"div":"span");n.setAttribute("class",t?"equation":"inline-equation");try{a().render(e.text,n,{displayMode:t})}catch(t){n.textContent=e.text}e.parentNode.replaceChild(n,e)}),o=o.default}()});
@@ -6,11 +6,9 @@ scripts.forEach(function (script) {
6
6
  if (!script.type || !script.type.match(/math\/tex/i)) {
7
7
  return -1;
8
8
  }
9
-
10
9
  var display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null;
11
10
  var katexElement = document.createElement(display ? "div" : "span");
12
11
  katexElement.setAttribute("class", display ? "equation" : "inline-equation");
13
-
14
12
  try {
15
13
  katex.render(script.text, katexElement, {
16
14
  displayMode: display
@@ -19,6 +17,5 @@ scripts.forEach(function (script) {
19
17
  //console.error(err); linter doesn't like this
20
18
  katexElement.textContent = script.text;
21
19
  }
22
-
23
20
  script.parentNode.replaceChild(katexElement, script);
24
21
  });