diff options
author | Raphael Aguiar <rmaguiar@tuta.io> | 2022-06-07 08:05:38 +0300 |
---|---|---|
committer | Raphael Aguiar <rmaguiar@tuta.io> | 2022-06-07 08:05:38 +0300 |
commit | cc3dcd7fa5656bc829f48562fbc7f26971466cb5 (patch) | |
tree | 3a928481da32a16a0da73be2d7ffc1f1c0b0400b /assets | |
parent | 4cb78fa1eb001ad64343a2795218b3ab37b559a8 (diff) |
Bump KaTeX from 0.15.6 to 0.16.0
Diffstat (limited to 'assets')
-rw-r--r-- | assets/libs/katex@0.15.6/dist/contrib/copy-tex.css | 13 | ||||
-rw-r--r-- | assets/libs/katex@0.16.0/dist/contrib/auto-render.js (renamed from assets/libs/katex@0.15.6/dist/contrib/auto-render.js) | 0 | ||||
-rw-r--r-- | assets/libs/katex@0.16.0/dist/contrib/copy-tex.js (renamed from assets/libs/katex@0.15.6/dist/contrib/copy-tex.js) | 62 | ||||
-rw-r--r-- | assets/libs/katex@0.16.0/dist/contrib/mhchem.js (renamed from assets/libs/katex@0.15.6/dist/contrib/mhchem.js) | 0 | ||||
-rw-r--r-- | assets/libs/katex@0.16.0/dist/katex.css (renamed from assets/libs/katex@0.15.6/dist/katex.css) | 2 | ||||
-rw-r--r-- | assets/libs/katex@0.16.0/dist/katex.js (renamed from assets/libs/katex@0.15.6/dist/katex.js) | 2 |
6 files changed, 40 insertions, 39 deletions
diff --git a/assets/libs/katex@0.15.6/dist/contrib/copy-tex.css b/assets/libs/katex@0.15.6/dist/contrib/copy-tex.css deleted file mode 100644 index 6999c63..0000000 --- a/assets/libs/katex@0.15.6/dist/contrib/copy-tex.css +++ /dev/null @@ -1,13 +0,0 @@ -/* Force selection of entire .katex/.katex-display blocks, so that we can - * copy/paste the entire source code. If you omit this CSS, partial - * selections of a formula will work, but will copy the ugly HTML - * representation instead of the LaTeX source code. (Full selections will - * still produce the LaTeX source code.) - */ -.katex, -.katex-display { - -webkit-user-select: all; - -moz-user-select: all; - user-select: all; -} - diff --git a/assets/libs/katex@0.15.6/dist/contrib/auto-render.js b/assets/libs/katex@0.16.0/dist/contrib/auto-render.js index 6980cdd..6980cdd 100644 --- a/assets/libs/katex@0.15.6/dist/contrib/auto-render.js +++ b/assets/libs/katex@0.16.0/dist/contrib/auto-render.js diff --git a/assets/libs/katex@0.15.6/dist/contrib/copy-tex.js b/assets/libs/katex@0.16.0/dist/contrib/copy-tex.js index bf54df2..2897f1e 100644 --- a/assets/libs/katex@0.15.6/dist/contrib/copy-tex.js +++ b/assets/libs/katex@0.16.0/dist/contrib/copy-tex.js @@ -23,7 +23,7 @@ var defaultCopyDelimiters = { // Modifies fragment in-place. Useful for writing your own 'copy' handler, // as in copy-tex.js. -var katexReplaceWithTex = function katexReplaceWithTex(fragment, copyDelimiters) { +function katexReplaceWithTex(fragment, copyDelimiters) { if (copyDelimiters === void 0) { copyDelimiters = defaultCopyDelimiters; } @@ -36,8 +36,8 @@ var katexReplaceWithTex = function katexReplaceWithTex(fragment, copyDelimiters) var element = katexHtml[i]; if (element.remove) { - element.remove(null); - } else { + element.remove(); + } else if (element.parentNode) { element.parentNode.removeChild(element); } } // Replace .katex-mathml elements with their annotation (TeX source) @@ -54,7 +54,7 @@ var katexReplaceWithTex = function katexReplaceWithTex(fragment, copyDelimiters) if (texSource) { if (_element.replaceWith) { _element.replaceWith(texSource); - } else { + } else if (_element.parentNode) { _element.parentNode.replaceChild(texSource, _element); } @@ -71,44 +71,58 @@ var katexReplaceWithTex = function katexReplaceWithTex(fragment, copyDelimiters) } return fragment; -}; +} /* harmony default export */ var katex2tex = (katexReplaceWithTex); ;// CONCATENATED MODULE: ./contrib/copy-tex/copy-tex.js - // Global copy handler to modify behavior on .katex elements. + // Return <div class="katex"> element containing node, or null if not found. + +function closestKatex(node) { + // If node is a Text Node, for example, go up to containing Element, + // where we can apply the `closest` method. + var element = node instanceof Element ? node : node.parentElement; + return element && element.closest('.katex'); +} // Global copy handler to modify behavior on/within .katex elements. + document.addEventListener('copy', function (event) { var selection = window.getSelection(); - if (selection.isCollapsed) { - return; // default action OK if selection is empty + if (selection.isCollapsed || !event.clipboardData) { + return; // default action OK if selection is empty or unchangeable } - var fragment = selection.getRangeAt(0).cloneContents(); + var clipboardData = event.clipboardData; + var range = selection.getRangeAt(0); // When start point is within a formula, expand to entire formula. - if (!fragment.querySelector('.katex-mathml')) { - return; // default action OK if no .katex-mathml elements - } // Preserve usual HTML copy/paste behavior. + var startKatex = closestKatex(range.startContainer); + if (startKatex) { + range.setStartBefore(startKatex); + } // Similarly, when end point is within a formula, expand to entire formula. - var html = []; - for (var i = 0; i < fragment.childNodes.length; i++) { - html.push(fragment.childNodes[i].outerHTML); + var endKatex = closestKatex(range.endContainer); + + if (endKatex) { + range.setEndAfter(endKatex); } - event.clipboardData.setData('text/html', html.join('')); // Rewrite plain-text version. + var fragment = range.cloneContents(); - event.clipboardData.setData('text/plain', katex2tex(fragment).textContent); // Prevent normal copy handling. + if (!fragment.querySelector('.katex-mathml')) { + return; // default action OK if no .katex-mathml elements + } - event.preventDefault(); -}); -;// CONCATENATED MODULE: ./contrib/copy-tex/copy-tex.webpack.js -/** - * This is the webpack entry point for KaTeX. As ECMAScript doesn't support - * CSS modules natively, a separate entry point is used. - */ + var htmlContents = Array.prototype.map.call(fragment.childNodes, function (el) { + return el instanceof Text ? el.textContent : el.outerHTML; + }).join(''); // Preserve usual HTML copy/paste behavior. + clipboardData.setData('text/html', htmlContents); // Rewrite plain-text version. + clipboardData.setData('text/plain', katex2tex(fragment).textContent); // Prevent normal copy handling. + + event.preventDefault(); +}); __webpack_exports__ = __webpack_exports__["default"]; /******/ return __webpack_exports__; /******/ })() diff --git a/assets/libs/katex@0.15.6/dist/contrib/mhchem.js b/assets/libs/katex@0.16.0/dist/contrib/mhchem.js index 3109305..3109305 100644 --- a/assets/libs/katex@0.15.6/dist/contrib/mhchem.js +++ b/assets/libs/katex@0.16.0/dist/contrib/mhchem.js diff --git a/assets/libs/katex@0.15.6/dist/katex.css b/assets/libs/katex@0.16.0/dist/katex.css index 3cbfc22..258318e 100644 --- a/assets/libs/katex@0.15.6/dist/katex.css +++ b/assets/libs/katex@0.16.0/dist/katex.css @@ -130,7 +130,7 @@ border-color: currentColor; } .katex .katex-version::after { - content: "0.15.6"; + content: "0.16.0"; } .katex .katex-mathml { /* Accessibility hack to only show to screen readers diff --git a/assets/libs/katex@0.15.6/dist/katex.js b/assets/libs/katex@0.16.0/dist/katex.js index 6758bf6..01e577b 100644 --- a/assets/libs/katex@0.15.6/dist/katex.js +++ b/assets/libs/katex@0.16.0/dist/katex.js @@ -18564,7 +18564,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) { /** * Current KaTeX version */ - version: "0.15.6", + version: "0.16.0", /** * Renders the given LaTeX into an HTML+MathML combination, and adds |