@react-fabric/lexical 1.0.0-beta.6 → 1.0.0-beta.60

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.
Files changed (76) hide show
  1. package/{src/editor/Lexical.module.css → css/_lexical.css} +8 -4
  2. package/css/styles.css +24 -0
  3. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +62 -20
  4. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +1 -1
  5. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +11 -11
  6. package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +643 -245
  7. package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +1 -1
  8. package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +29 -22
  9. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +13 -6
  10. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +1 -1
  11. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
  12. package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +242 -141
  13. package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +1 -1
  14. package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +11 -10
  15. package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +594 -255
  16. package/dist/cjs/node_modules/@lexical/list/LexicalList.js +1 -1
  17. package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +23 -16
  18. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +102 -53
  19. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +1 -1
  20. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +10 -10
  21. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +275 -194
  22. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +5 -1
  23. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +28 -18
  24. package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +2293 -878
  25. package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +1 -1
  26. package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +53 -40
  27. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +471 -193
  28. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +13 -1
  29. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +47 -32
  30. package/dist/cjs/node_modules/prismjs/prism.js +1 -1
  31. package/dist/cjs/packages/lexical/src/components/StickyComponent.js +1 -1
  32. package/dist/cjs/packages/lexical/src/editor/LexicalEditor.js +30 -5
  33. package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +86 -83
  34. package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +25 -17
  35. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +62 -20
  36. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +1 -1
  37. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +3 -3
  38. package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +637 -246
  39. package/dist/esm/node_modules/@lexical/code/LexicalCode.js +1 -1
  40. package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +4 -4
  41. package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +14 -7
  42. package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +1 -1
  43. package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
  44. package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +244 -144
  45. package/dist/esm/node_modules/@lexical/link/LexicalLink.js +1 -1
  46. package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +4 -4
  47. package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +590 -257
  48. package/dist/esm/node_modules/@lexical/list/LexicalList.js +1 -1
  49. package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +5 -4
  50. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +104 -55
  51. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +1 -1
  52. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +4 -4
  53. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +267 -196
  54. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +4 -2
  55. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +4 -4
  56. package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +2283 -881
  57. package/dist/esm/node_modules/@lexical/table/LexicalTable.js +1 -1
  58. package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +4 -4
  59. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +457 -194
  60. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +8 -2
  61. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +3 -3
  62. package/dist/esm/node_modules/prismjs/prism.js +1 -1
  63. package/dist/esm/packages/lexical/src/components/StickyComponent.js +1 -1
  64. package/dist/esm/packages/lexical/src/editor/LexicalEditor.js +30 -5
  65. package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +88 -85
  66. package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +25 -17
  67. package/dist/types/editor/LexicalEditor.d.ts +25 -0
  68. package/dist/types/hooks/useFormatWatcher.d.ts +2 -2
  69. package/dist/types/nodes/StickyNode.d.ts +0 -1
  70. package/package.json +14 -13
  71. package/src/components/StickyComponent.tsx +2 -2
  72. package/src/editor/LexicalEditor.tsx +57 -26
  73. package/src/hooks/useFormatWatcher.ts +35 -31
  74. package/src/plugins/ToolbarPlugin.tsx +27 -17
  75. package/dist/cjs/editor/Lexical.module.css +0 -1
  76. package/dist/esm/editor/Lexical.module.css +0 -1
@@ -11,7 +11,7 @@ var LexicalCode_prod = require('./LexicalCode.prod.js');
11
11
  *
12
12
  */
13
13
 
14
- const mod = process.env.NODE_ENV === 'development' ? LexicalCode_dev : LexicalCode_prod;
14
+ const mod = process.env.NODE_ENV !== 'production' ? LexicalCode_dev : LexicalCode_prod;
15
15
  const $createCodeNode = mod.$createCodeNode;
16
16
  const $isCodeNode = mod.$isCodeNode;
17
17
  const CODE_LANGUAGE_MAP = mod.CODE_LANGUAGE_MAP;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var LexicalUtils = require('../utils/LexicalUtils.js');
4
+ var lexical = require('lexical');
3
5
  require('../../prismjs/prism.js');
4
6
  require('../../prismjs/components/prism-clike.js');
5
7
  require('../../prismjs/components/prism-javascript.js');
@@ -16,8 +18,6 @@ require('../../prismjs/components/prism-swift.js');
16
18
  require('../../prismjs/components/prism-typescript.js');
17
19
  require('../../prismjs/components/prism-java.js');
18
20
  require('../../prismjs/components/prism-cpp.js');
19
- var LexicalUtils = require('../utils/LexicalUtils.js');
20
- var lexical = require('lexical');
21
21
 
22
22
  /**
23
23
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -27,24 +27,31 @@ var lexical = require('lexical');
27
27
  *
28
28
  */
29
29
 
30
- function w(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var P=w((function(t){const e=new URLSearchParams;e.append("code",t);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${t}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const k=t=>{try{return !!t&&window.Prism.languages.hasOwnProperty(t)}catch(t){return !1}};function L(e,n){for(const r of e.childNodes){if(LexicalUtils.isHTMLElement(r)&&r.tagName===n)return !0;L(r,n);}return !1}const A="data-language",O="data-highlight-language";class M extends lexical.ElementNode{static getType(){return "code"}static clone(t){return new M(t.__language,t.__key)}constructor(t,e){super(e),this.__language=t,this.__isSyntaxHighlightSupported=k(t);}createDOM(t){const n=document.createElement("code");LexicalUtils.addClassNamesToElement(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();return r&&(n.setAttribute(A,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(O,r)),n}updateDOM(t,e,n){const r=this.__language,o=t.__language;return r?r!==o&&(e.setAttribute(A,r),this.__isSyntaxHighlightSupported&&e.setAttribute(O,r)):o&&(e.removeAttribute(A),t.__isSyntaxHighlightSupported&&e.removeAttribute(O)),!1}exportDOM(t){const n=document.createElement("pre");LexicalUtils.addClassNamesToElement(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();return r&&(n.setAttribute(A,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(O,r)),{element:n}}static importDOM(){return {code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||L(t,"BR"))?{conversion:z,priority:1}:null,div:()=>({conversion:E,priority:1}),pre:()=>({conversion:z,priority:0}),table:t=>R(t)?{conversion:B,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&R(n)?{conversion:I,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&R(e)?{conversion:I,priority:3}:null}}}static importJSON(t){const e=H(t.language);return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}exportJSON(){return {...super.exportJSON(),language:this.getLanguage(),type:"code",version:1}}insertNewAfter(t,e=!0){const n=this.getChildren(),r=n.length;if(r>=2&&"\n"===n[r-1].getTextContent()&&"\n"===n[r-2].getTextContent()&&t.isCollapsed()&&t.anchor.key===this.__key&&t.anchor.offset===r){n[r-1].remove(),n[r-2].remove();const t=lexical.$createParagraphNode();return this.insertAfter(t,e),t}const{anchor:o,focus:a}=t,g=(o.isBefore(a)?o:a).getNode();if(lexical.$isTextNode(g)){let t=Z(g);const e=[];for(;;)if(lexical.$isTabNode(t))e.push(lexical.$createTabNode()),t=t.getNextSibling();else {if(!Y(t))break;{let n=0;const r=t.getTextContent(),o=t.getTextContentSize();for(;n<o&&" "===r[n];)n++;if(0!==n&&e.push(V(" ".repeat(n))),n!==o)break;t=t.getNextSibling();}}const n=g.splitText(o.offset)[0],r=0===o.offset?0:1,i=n.getIndexWithinParent()+r,s=g.getParentOrThrow(),a=[lexical.$createLineBreakNode(),...e];s.splice(i,0,a);const f=e[e.length-1];f?f.select():0===o.offset?n.selectPrevious():n.getNextSibling().selectNext(0,0);}if(D(g)){const{offset:e}=t.anchor;g.splice(e,0,[lexical.$createLineBreakNode()]),g.select(e+1,e+1);}return null}canIndent(){return !1}collapseAtStart(){const t=lexical.$createParagraphNode();return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}setLanguage(t){const e=this.getWritable();e.__language=t,e.__isSyntaxHighlightSupported=k(t);}getLanguage(){return this.getLatest().__language}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}}function H(t){return lexical.$applyNodeReplacement(new M(t))}function D(t){return t instanceof M}function z(t){return {node:H(t.getAttribute(A))}}function E(t){const e=t,n=J(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(J(e))return !0;e=e.parentElement;}return !1}(e)?{node:n?H():null}:{node:null}}function B(){return {node:H()}}function I(){return {node:null}}function J(t){return null!==t.style.fontFamily.match("monospace")}function R(t){return t.classList.contains("js-file-line-container")}const F="javascript",K={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},q={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function U(t){return q[t]||t}function W(t){const e=U(t);return K[e]||e}const $=()=>F,Q=()=>Object.keys(window.Prism.languages).filter((t=>"function"!=typeof window.Prism.languages[t])).sort();class X extends lexical.TextNode{constructor(t,e,n){super(t,n),this.__highlightType=e;}static getType(){return "code-highlight"}static clone(t){return new X(t.__text,t.__highlightType||void 0,t.__key)}getHighlightType(){return this.getLatest().__highlightType}canHaveFormat(){return !1}createDOM(t){const n=super.createDOM(t),r=G(t.theme,this.__highlightType);return LexicalUtils.addClassNamesToElement(n,r),n}updateDOM(t,r,o){const i=super.updateDOM(t,r,o),s=G(o.theme,t.__highlightType),l=G(o.theme,this.__highlightType);return s!==l&&(s&&LexicalUtils.removeClassNamesFromElement(r,s),l&&LexicalUtils.addClassNamesToElement(r,l)),i}static importJSON(t){const e=V(t.text,t.highlightType);return e.setFormat(t.format),e.setDetail(t.detail),e.setMode(t.mode),e.setStyle(t.style),e}exportJSON(){return {...super.exportJSON(),highlightType:this.getHighlightType(),type:"code-highlight",version:1}}setFormat(t){return this}isParentRequired(){return !0}createParentElementNode(){return H()}}function G(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function V(t,e){return lexical.$applyNodeReplacement(new X(t,e))}function Y(t){return t instanceof X}function Z(t){let e=t,n=t;for(;Y(n)||lexical.$isTabNode(n);)e=n,n=n.getPreviousSibling();return e}function tt(t){let e=t,n=t;for(;Y(n)||lexical.$isTabNode(n);)e=n,n=n.getNextSibling();return e}const et={defaultLanguage:F,tokenize(t,e){return window.Prism.tokenize(t,window.Prism.languages[e||""]||window.Prism.languages[this.defaultLanguage])}};function nt(t,e){let n=null,r=null,o=t,i=e,s=t.getTextContent();for(;;){if(0===i){if(o=o.getPreviousSibling(),null===o)break;if(Y(o)||lexical.$isTabNode(o)||lexical.$isLineBreakNode(o)||P(167),lexical.$isLineBreakNode(o)){n={node:o,offset:1};break}i=Math.max(0,o.getTextContentSize()-1),s=o.getTextContent();}else i--;const t=s[i];Y(o)&&" "!==t&&(r={node:o,offset:i});}if(null!==r)return r;let u=null;if(e<t.getTextContentSize())Y(t)&&(u=t.getTextContent()[e]);else {const e=t.getNextSibling();Y(e)&&(u=e.getTextContent()[0]);}if(null!==u&&" "!==u)return n;{const r=function(t,e){let n=t,r=e,o=t.getTextContent(),i=t.getTextContentSize();for(;;){if(!Y(n)||r===i){if(n=n.getNextSibling(),null===n||lexical.$isLineBreakNode(n))return null;Y(n)&&(r=0,o=n.getTextContent(),i=n.getTextContentSize());}if(Y(n)){if(" "!==o[r])return {node:n,offset:r};r++;}}}(t,e);return null!==r?r:n}}function rt(t){const e=tt(t);return lexical.$isLineBreakNode(e)&&P(168),e}function ot(t,e,n){const r=t.getParent();D(r)?lt(r,e,n):Y(t)&&t.replace(lexical.$createTextNode(t.__text));}function it(t,e){const n=e.getElementByKey(t.getKey());if(null===n)return;const r=t.getChildren(),o=r.length;if(o===n.__cachedChildrenLength)return;n.__cachedChildrenLength=o;let i="1",s=1;for(let t=0;t<o;t++)lexical.$isLineBreakNode(r[t])&&(i+="\n"+ ++s);n.setAttribute("data-gutter",i);}const st=new Set;function lt(t,e,n){const r=t.getKey();st.has(r)||(st.add(r),void 0===t.getLanguage()&&t.setLanguage(n.defaultLanguage),e.update((()=>{!function(t,e){const n=lexical.$getNodeByKey(t);if(!D(n)||!n.isAttached())return;const r=lexical.$getSelection();if(!lexical.$isRangeSelection(r))return void e();const o=r.anchor,i=o.offset,l="element"===o.type&&lexical.$isLineBreakNode(n.getChildAtIndex(o.offset-1));let u=0;if(!l){const t=o.getNode();u=i+t.getPreviousSiblings().reduce(((t,e)=>t+e.getTextContentSize()),0);}if(!e())return;if(l)return void o.getNode().select(i,i);n.getChildren().some((t=>{const e=lexical.$isTextNode(t);if(e||lexical.$isLineBreakNode(t)){const n=t.getTextContentSize();if(e&&n>=u)return t.select(u,u),!0;u-=n;}return !1}));}(r,(()=>{const e=lexical.$getNodeByKey(r);if(!D(e)||!e.isAttached())return !1;const o=e.getTextContent(),i=ut(n.tokenize(o,e.getLanguage()||n.defaultLanguage)),s=function(t,e){let n=0;for(;n<t.length&&ct(t[n],e[n]);)n++;const r=t.length,o=e.length,i=Math.min(r,o)-n;let s=0;for(;s<i;)if(s++,!ct(t[r-s],e[o-s])){s--;break}const l=n,u=r-s,c=e.slice(n,o-s);return {from:l,nodesForReplacement:c,to:u}}(e.getChildren(),i),{from:l,to:u,nodesForReplacement:c}=s;return !(l===u&&!c.length)&&(t.splice(l,u-l,c),!0)}));}),{onUpdate:()=>{st.delete(r);},skipTransforms:!0}));}function ut(t,e){const n=[];for(const r of t)if("string"==typeof r){const t=r.split(/(\n|\t)/),o=t.length;for(let r=0;r<o;r++){const o=t[r];"\n"===o||"\r\n"===o?n.push(lexical.$createLineBreakNode()):"\t"===o?n.push(lexical.$createTabNode()):o.length>0&&n.push(V(o,e));}}else {const{content:t}=r;"string"==typeof t?n.push(...ut([t],r.type)):Array.isArray(t)&&n.push(...ut(t,r.type));}return n}function ct(t,e){return Y(t)&&Y(e)&&t.__text===e.__text&&t.__highlightType===e.__highlightType||lexical.$isTabNode(t)&&lexical.$isTabNode(e)||lexical.$isLineBreakNode(t)&&lexical.$isLineBreakNode(e)}function at(t){if(!lexical.$isRangeSelection(t))return !1;const e=t.anchor.getNode(),n=t.focus.getNode();if(e.is(n)&&D(e))return !0;const r=e.getParent();return D(r)&&r.is(n.getParent())}function gt(t){const e=t.getNodes(),n=[[]];if(1===e.length&&D(e[0]))return n;let r=n[0];for(let t=0;t<e.length;t++){const o=e[t];Y(o)||lexical.$isTabNode(o)||lexical.$isLineBreakNode(o)||P(169),lexical.$isLineBreakNode(o)?0!==t&&r.length>0&&(r=[],n.push(r)):r.push(o);}return n}function ft(t){const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e)||!at(e))return !1;const n=gt(e),r=n.length;if(n.length>1){for(let e=0;e<r;e++){const r=n[e];if(r.length>0){let n=r[0];0===e&&(n=Z(n)),null!==n&&(t===lexical.INDENT_CONTENT_COMMAND?n.insertBefore(lexical.$createTabNode()):lexical.$isTabNode(n)&&n.remove());}}return !0}const o=e.getNodes()[0];if(D(o)||Y(o)||lexical.$isTabNode(o)||lexical.$isLineBreakNode(o)||P(171),D(o))return t===lexical.INDENT_CONTENT_COMMAND&&e.insertNodes([lexical.$createTabNode()]),!0;const i=Z(o);return null===i&&P(172),t===lexical.INDENT_CONTENT_COMMAND?lexical.$isLineBreakNode(i)?i.insertAfter(lexical.$createTabNode()):i.insertBefore(lexical.$createTabNode()):lexical.$isTabNode(i)&&i.remove(),!0}function pt(t,e){const n=lexical.$getSelection();if(!lexical.$isRangeSelection(n))return !1;const{anchor:r,focus:o}=n,i=r.offset,s=o.offset,u=r.getNode(),c=o.getNode(),a=t===lexical.KEY_ARROW_UP_COMMAND;if(!at(n)||!Y(u)&&!lexical.$isTabNode(u)||!Y(c)&&!lexical.$isTabNode(c))return !1;if(!e.altKey){if(n.isCollapsed()){const t=u.getParentOrThrow();if(a&&0===i&&null===u.getPreviousSibling()){if(null===t.getPreviousSibling())return t.selectPrevious(),e.preventDefault(),!0}else if(!a&&i===u.getTextContentSize()&&null===u.getNextSibling()){if(null===t.getNextSibling())return t.selectNext(),e.preventDefault(),!0}}return !1}let g,p;if(u.isBefore(c)?(g=Z(u),p=tt(c)):(g=Z(c),p=tt(u)),null==g||null==p)return !1;const h=g.getNodesBetween(p);for(let t=0;t<h.length;t++){const e=h[t];if(!Y(e)&&!lexical.$isTabNode(e)&&!lexical.$isLineBreakNode(e))return !1}e.preventDefault(),e.stopPropagation();const y=a?g.getPreviousSibling():p.getNextSibling();if(!lexical.$isLineBreakNode(y))return !0;const x=a?y.getPreviousSibling():y.getNextSibling();if(null==x)return !0;const S=Y(x)||lexical.$isTabNode(x)||lexical.$isLineBreakNode(x)?a?Z(x):tt(x):null;let v=null!=S?S:x;return y.remove(),h.forEach((t=>t.remove())),t===lexical.KEY_ARROW_UP_COMMAND?(h.forEach((t=>v.insertBefore(t))),v.insertBefore(y)):(v.insertAfter(y),v=y,h.forEach((t=>{v.insertAfter(t),v=t;}))),n.setTextNodeRange(u,i,c,s),!0}function ht(t,e){const n=lexical.$getSelection();if(!lexical.$isRangeSelection(n))return !1;const{anchor:r,focus:o}=n,i=r.getNode(),s=o.getNode(),u=t===lexical.MOVE_TO_START;if(!Y(i)&&!lexical.$isTabNode(i)||!Y(s)&&!lexical.$isTabNode(s))return !1;if(u){const t=nt(s,o.offset);if(null!==t){const{node:e,offset:r}=t;lexical.$isLineBreakNode(e)?e.selectNext(0,0):n.setTextNodeRange(e,r,e,r);}else s.getParentOrThrow().selectStart();}else {rt(s).select();}return e.preventDefault(),e.stopPropagation(),!0}function dt(t,e){if(!t.hasNodes([M,X]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");return null==e&&(e=et),LexicalUtils.mergeRegister(t.registerMutationListener(M,(e=>{t.update((()=>{for(const[n,r]of e)if("destroyed"!==r){const e=lexical.$getNodeByKey(n);null!==e&&it(e,t);}}));}),{skipInitialization:!1}),t.registerNodeTransform(M,(n=>lt(n,t,e))),t.registerNodeTransform(lexical.TextNode,(n=>ot(n,t,e))),t.registerNodeTransform(X,(n=>ot(n,t,e))),t.registerCommand(lexical.KEY_TAB_COMMAND,(e=>{const n=function(t){const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e)||!at(e))return null;const n=t?lexical.OUTDENT_CONTENT_COMMAND:lexical.INDENT_CONTENT_COMMAND,r=t?lexical.OUTDENT_CONTENT_COMMAND:lexical.INSERT_TAB_COMMAND;if(gt(e).length>1)return n;const o=e.getNodes()[0];if(D(o)||Y(o)||lexical.$isTabNode(o)||lexical.$isLineBreakNode(o)||P(170),D(o))return n;const i=Z(o),s=tt(o),u=e.anchor,c=e.focus;let a,g;return c.isBefore(u)?(a=c,g=u):(a=u,g=c),null!==i&&null!==s&&a.key===i.getKey()&&0===a.offset&&g.key===s.getKey()&&g.offset===s.getTextContentSize()?n:r}(e.shiftKey);return null!==n&&(e.preventDefault(),t.dispatchCommand(n,void 0),!0)}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.INSERT_TAB_COMMAND,(()=>!!at(lexical.$getSelection())&&(lexical.$insertNodes([lexical.$createTabNode()]),!0)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.INDENT_CONTENT_COMMAND,(t=>ft(lexical.INDENT_CONTENT_COMMAND)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.OUTDENT_CONTENT_COMMAND,(t=>ft(lexical.OUTDENT_CONTENT_COMMAND)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_ARROW_UP_COMMAND,(t=>pt(lexical.KEY_ARROW_UP_COMMAND,t)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND,(t=>pt(lexical.KEY_ARROW_DOWN_COMMAND,t)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.MOVE_TO_END,(t=>ht(lexical.MOVE_TO_END,t)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.MOVE_TO_START,(t=>ht(lexical.MOVE_TO_START,t)),lexical.COMMAND_PRIORITY_LOW))}
30
+ function B(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const D="javascript",F=()=>D;function I(e,n){for(const r of e.childNodes){if(LexicalUtils.isHTMLElement(r)&&r.tagName===n)return !0;I(r,n);}return !1}const M="data-language",J="data-highlight-language",R="data-theme";class K extends lexical.ElementNode{static getType(){return "code"}static clone(t){return new K(t.__language,t.__key)}constructor(t,e){super(e),this.__language=t||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0;}afterCloneFrom(t){super.afterCloneFrom(t),this.__language=t.__language,this.__theme=t.__theme,this.__isSyntaxHighlightSupported=t.__isSyntaxHighlightSupported;}createDOM(t){const n=document.createElement("code");LexicalUtils.addClassNamesToElement(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(M,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(J,r));const i=this.getTheme();i&&n.setAttribute(R,i);const o=this.getStyle();return o&&n.setAttribute("style",o),n}updateDOM(t,e,n){const r=this.__language,i=t.__language;r?r!==i&&e.setAttribute(M,r):i&&e.removeAttribute(M);const o=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&e.setAttribute(J,r):e.removeAttribute(J):o&&r&&e.setAttribute(J,r);const s=this.__theme,u=t.__theme;s?s!==u&&e.setAttribute(R,s):u&&e.removeAttribute(R);const l=this.__style,c=t.__style;return l?l!==c&&e.setAttribute("style",l):c&&e.removeAttribute("style"),!1}exportDOM(t){const n=document.createElement("pre");LexicalUtils.addClassNamesToElement(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(M,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(J,r));const i=this.getTheme();i&&n.setAttribute(R,i);const o=this.getStyle();return o&&n.setAttribute("style",o),{element:n}}static importDOM(){return {code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||I(t,"BR"))?{conversion:q,priority:1}:null,div:()=>({conversion:U,priority:1}),pre:()=>({conversion:q,priority:0}),table:t=>V(t)?{conversion:X,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&V(n)?{conversion:Q,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&V(e)?{conversion:Q,priority:3}:null}}}static importJSON(t){return $().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setLanguage(t.language).setTheme(t.theme)}exportJSON(){return {...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(t,e=!0){const n=this.getChildren(),r=n.length;if(r>=2&&"\n"===n[r-1].getTextContent()&&"\n"===n[r-2].getTextContent()&&t.isCollapsed()&&t.anchor.key===this.__key&&t.anchor.offset===r){n[r-1].remove(),n[r-2].remove();const t=lexical.$createParagraphNode();return this.insertAfter(t,e),t}const{anchor:i,focus:o}=t,g=(i.isBefore(o)?i:o).getNode();if(lexical.$isTextNode(g)){let t=rt(g);const e=[];for(;;)if(lexical.$isTabNode(t))e.push(lexical.$createTabNode()),t=t.getNextSibling();else {if(!et(t))break;{let n=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&e.push(tt(" ".repeat(n))),n!==i)break;t=t.getNextSibling();}}const n=g.splitText(i.offset)[0],r=0===i.offset?0:1,o=n.getIndexWithinParent()+r,s=g.getParentOrThrow(),u=[lexical.$createLineBreakNode(),...e];s.splice(o,0,u);const f=e[e.length-1];f?f.select():0===i.offset?n.selectPrevious():n.getNextSibling().selectNext(0,0);}if(W(g)){const{offset:e}=t.anchor;g.splice(e,0,[lexical.$createLineBreakNode()]),g.select(e+1,e+1);}return null}canIndent(){return !1}collapseAtStart(){const t=lexical.$createParagraphNode();return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}setLanguage(t){const e=this.getWritable();return e.__language=t||void 0,e}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(t){const e=this.getWritable();return e.__isSyntaxHighlightSupported=t,e}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(t){const e=this.getWritable();return e.__theme=t||void 0,e}getTheme(){return this.getLatest().__theme}}function $(t,e){return lexical.$create(K).setLanguage(t).setTheme(e)}function W(t){return t instanceof K}function q(t){return {node:$(t.getAttribute(M))}}function U(t){const e=t,n=G(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(G(e))return !0;e=e.parentElement;}return !1}(e)?{node:n?$():null}:{node:null}}function X(){return {node:$()}}function Q(){return {node:null}}function G(t){return null!==t.style.fontFamily.match("monospace")}function V(t){return t.classList.contains("js-file-line-container")}class Y extends lexical.TextNode{constructor(t="",e,n){super(t,n),this.__highlightType=e;}static getType(){return "code-highlight"}static clone(t){return new Y(t.__text,t.__highlightType||void 0,t.__key)}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(t){const e=this.getWritable();return e.__highlightType=t||void 0,e}canHaveFormat(){return !1}createDOM(t){const n=super.createDOM(t),r=Z(t.theme,this.__highlightType);return LexicalUtils.addClassNamesToElement(n,r),n}updateDOM(t,r,i){const o=super.updateDOM(t,r,i),s=Z(i.theme,t.__highlightType),u=Z(i.theme,this.__highlightType);return s!==u&&(s&&LexicalUtils.removeClassNamesFromElement(r,s),u&&LexicalUtils.addClassNamesToElement(r,u)),o}static importJSON(t){return tt().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setHighlightType(t.highlightType)}exportJSON(){return {...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(t){return this}isParentRequired(){return !0}createParentElementNode(){return $()}}function Z(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function tt(t="",e){return lexical.$applyNodeReplacement(new Y(t,e))}function et(t){return t instanceof Y}function nt(t,e){let n=t;for(let i=lexical.$getSiblingCaret(t,e);i&&(et(i.origin)||lexical.$isTabNode(i.origin));i=LexicalUtils.$getAdjacentCaret(i))n=i.origin;return n}function rt(t){return nt(t,"previous")}function it(t){return nt(t,"next")}function ot(t,e){let n=null,r=null,i=t,o=e,s=t.getTextContent();for(;;){if(0===o){if(i=i.getPreviousSibling(),null===i)break;if(et(i)||lexical.$isTabNode(i)||lexical.$isLineBreakNode(i)||B(167),lexical.$isLineBreakNode(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent();}else o--;const t=s[o];et(i)&&" "!==t&&(r={node:i,offset:o});}if(null!==r)return r;let u=null;if(e<t.getTextContentSize())et(t)&&(u=t.getTextContent()[e]);else {const e=t.getNextSibling();et(e)&&(u=e.getTextContent()[0]);}if(null!==u&&" "!==u)return n;{const r=function(t,e){let n=t,r=e,i=t.getTextContent(),o=t.getTextContentSize();for(;;){if(!et(n)||r===o){if(n=n.getNextSibling(),null===n||lexical.$isLineBreakNode(n))return null;et(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize());}if(et(n)){if(" "!==i[r])return {node:n,offset:r};r++;}}}(t,e);return null!==r?r:n}}function st(t){const e=it(t);return lexical.$isLineBreakNode(e)&&B(168),e}!function(t){t.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var e={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(e).forEach((function(n){var r=e[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),"diff"===n&&i.push("bold"),t.languages.diff[n]={pattern:RegExp("^(?:["+r+"].*(?:\r\n?|\n|(?![\\s\\S])))+","m"),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}};})),Object.defineProperty(t.languages.diff,"PREFIXES",{value:e});}(Prism);const ut=globalThis.Prism||window.Prism,lt={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},ct={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function at(t){return ct[t]||t}function gt(t){const e=at(t);return lt[e]||e}const ft=()=>Object.keys(ut.languages).filter((t=>"function"!=typeof ut.languages[t])).sort();function pt(){const t=[];for(const[e,n]of Object.entries(lt))t.push([e,n]);return t}function ht(){return []}function dt(t){return "string"==typeof t?t:Array.isArray(t)?t.map(dt).join(""):dt(t.content)}function mt(t,e){const n=/^diff-([\w-]+)/i.exec(e),r=t.getTextContent();let i=ut.tokenize(r,ut.languages[n?"diff":e]);return n&&(i=function(t,e){const n=e,r=ut.languages[n],i={tokens:t},o=ut.languages.diff.PREFIXES;for(const t of i.tokens){if("string"==typeof t||!(t.type in o)||!Array.isArray(t.content))continue;const e=t.type;let n=0;const i=()=>(n++,new ut.Token("prefix",o[e],e.replace(/^(\w+).*/,"$1"))),s=t.content.filter((t=>"string"==typeof t||"prefix"!==t.type)),u=t.content.length-s.length,l=ut.tokenize(dt(s),r);l.unshift(i());const c=/\r\n|\n/g,a=t=>{const e=[];c.lastIndex=0;let r,o=0;for(;n<u&&(r=c.exec(t));){const n=r.index+r[0].length;e.push(t.slice(o,n)),o=n,e.push(i());}if(0!==e.length)return o<t.length&&e.push(t.slice(o)),e},g=t=>{for(let e=0;e<t.length&&n<u;e++){const n=t[e];if("string"==typeof n){const r=a(n);r&&(t.splice(e,1,...r),e+=r.length-1);}else if("string"==typeof n.content){const t=a(n.content);t&&(n.content=t);}else Array.isArray(n.content)?g(n.content):g([n.content]);}};g(l),n<u&&l.push(i()),t.content=l;}return i.tokens}(i,n[1])),yt(i)}function yt(t,e){const n=[];for(const r of t)if("string"==typeof r){const t=r.split(/(\n|\t)/),i=t.length;for(let r=0;r<i;r++){const i=t[r];"\n"===i||"\r\n"===i?n.push(lexical.$createLineBreakNode()):"\t"===i?n.push(lexical.$createTabNode()):i.length>0&&n.push(tt(i,e));}}else {const{content:t,alias:e}=r;"string"==typeof t?n.push(...yt([t],"prefix"===r.type&&"string"==typeof e?e:r.type)):Array.isArray(t)&&n.push(...yt(t,"unchanged"===r.type?void 0:r.type));}return n}const xt={$tokenize(t,e){return mt(t,e||this.defaultLanguage)},defaultLanguage:D,tokenize(t,e){return ut.tokenize(t,ut.languages[e||""]||ut.languages[this.defaultLanguage])}};function St(t,e,n){const r=t.getParent();W(r)?Tt(r,e,n):et(t)&&t.replace(lexical.$createTextNode(t.__text));}function _t(t,e){const n=e.getElementByKey(t.getKey());if(null===n)return;const r=t.getChildren(),i=r.length;if(i===n.__cachedChildrenLength)return;n.__cachedChildrenLength=i;let o="1",s=1;for(let t=0;t<i;t++)lexical.$isLineBreakNode(r[t])&&(o+="\n"+ ++s);n.setAttribute("data-gutter",o);}const vt=new Set;function Tt(t,e,n){const r=t.getKey();void 0===t.getLanguage()&&t.setLanguage(n.defaultLanguage);const i=t.getLanguage()||n.defaultLanguage;if(!function(t){const e=function(t){const e=/^diff-([\w-]+)/i.exec(t);return e?e[1]:null}(t),n=e||t;try{return !!n&&ut.languages.hasOwnProperty(n)}catch(t){return !1}}(i))return t.getIsSyntaxHighlightSupported()&&t.setIsSyntaxHighlightSupported(!1),void async function(t,e,n){}();t.getIsSyntaxHighlightSupported()||t.setIsSyntaxHighlightSupported(!0),vt.has(r)||(vt.add(r),e.update((()=>{!function(t,e){const n=lexical.$getNodeByKey(t);if(!W(n)||!n.isAttached())return;const r=lexical.$getSelection();if(!lexical.$isRangeSelection(r))return void e();const i=r.anchor,o=i.offset,s="element"===i.type&&lexical.$isLineBreakNode(n.getChildAtIndex(i.offset-1));let l=0;if(!s){const t=i.getNode();l=o+t.getPreviousSiblings().reduce(((t,e)=>t+e.getTextContentSize()),0);}if(!e())return;if(s)return void i.getNode().select(o,o);n.getChildren().some((t=>{const e=lexical.$isTextNode(t);if(e||lexical.$isLineBreakNode(t)){const n=t.getTextContentSize();if(e&&n>=l)return t.select(l,l),!0;l-=n;}return !1}));}(r,(()=>{const e=lexical.$getNodeByKey(r);if(!W(e)||!e.isAttached())return !1;const i=e.getLanguage()||n.defaultLanguage,o=n.$tokenize(e,i),s=function(t,e){let n=0;for(;n<t.length&&bt(t[n],e[n]);)n++;const r=t.length,i=e.length,o=Math.min(r,i)-n;let s=0;for(;s<o;)if(s++,!bt(t[r-s],e[i-s])){s--;break}const u=n,l=r-s,c=e.slice(n,i-s);return {from:u,nodesForReplacement:c,to:l}}(e.getChildren(),o),{from:u,to:l,nodesForReplacement:c}=s;return !(u===l&&!c.length)&&(t.splice(u,l-u,c),!0)}));}),{onUpdate:()=>{vt.delete(r);},skipTransforms:!0}));}function bt(t,e){return et(t)&&et(e)&&t.__text===e.__text&&t.__highlightType===e.__highlightType||lexical.$isTabNode(t)&&lexical.$isTabNode(e)||lexical.$isLineBreakNode(t)&&lexical.$isLineBreakNode(e)}function Ct(t){if(!lexical.$isRangeSelection(t))return !1;const e=t.anchor.getNode(),n=W(e)?e:e.getParent(),r=t.focus.getNode(),i=W(r)?r:r.getParent();return W(n)&&n.is(i)}function Nt(t){const e=t.getNodes(),n=[];if(1===e.length&&W(e[0]))return n;let r=[];for(let t=0;t<e.length;t++){const i=e[t];et(i)||lexical.$isTabNode(i)||lexical.$isLineBreakNode(i)||B(169),lexical.$isLineBreakNode(i)?r.length>0&&(n.push(r),r=[]):r.push(i);}if(r.length>0){const e=t.isBackward()?t.anchor:t.focus,i=lexical.$createPoint(r[0].getKey(),0,"text");e.is(i)||n.push(r);}return n}function jt(t){const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e)||!Ct(e))return !1;const n=Nt(e),r=n.length;if(0===r&&e.isCollapsed())return t===lexical.INDENT_CONTENT_COMMAND&&e.insertNodes([lexical.$createTabNode()]),!0;if(0===r&&t===lexical.INDENT_CONTENT_COMMAND&&"\n"===e.getTextContent()){const t=lexical.$createTabNode(),n=lexical.$createLineBreakNode(),r=e.isBackward()?"previous":"next";return e.insertNodes([t,n]),lexical.$setSelectionFromCaretRange(lexical.$getCaretRangeInDirection(lexical.$getCaretRange(lexical.$getTextPointCaret(t,"next",0),lexical.$normalizeCaret(lexical.$getSiblingCaret(n,"next"))),r)),!0}for(let i=0;i<r;i++){const r=n[i];if(r.length>0){let n=r[0];if(0===i&&(n=rt(n)),t===lexical.INDENT_CONTENT_COMMAND){const t=lexical.$createTabNode();if(n.insertBefore(t),0===i){const r=e.isBackward()?"focus":"anchor",i=lexical.$createPoint(n.getKey(),0,"text");e[r].is(i)&&e[r].set(t.getKey(),0,"text");}}else lexical.$isTabNode(n)&&n.remove();}}return !0}function wt(t,e){const n=lexical.$getSelection();if(!lexical.$isRangeSelection(n))return !1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,u=r.getNode(),c=i.getNode(),a=t===lexical.KEY_ARROW_UP_COMMAND;if(!Ct(n)||!et(u)&&!lexical.$isTabNode(u)||!et(c)&&!lexical.$isTabNode(c))return !1;if(!e.altKey){if(n.isCollapsed()){const t=u.getParentOrThrow();if(a&&0===o&&null===u.getPreviousSibling()){if(null===t.getPreviousSibling())return t.selectPrevious(),e.preventDefault(),!0}else if(!a&&o===u.getTextContentSize()&&null===u.getNextSibling()){if(null===t.getNextSibling())return t.selectNext(),e.preventDefault(),!0}}return !1}let g,f;if(u.isBefore(c)?(g=rt(u),f=it(c)):(g=rt(c),f=it(u)),null==g||null==f)return !1;const p=g.getNodesBetween(f);for(let t=0;t<p.length;t++){const e=p[t];if(!et(e)&&!lexical.$isTabNode(e)&&!lexical.$isLineBreakNode(e))return !1}e.preventDefault(),e.stopPropagation();const h=a?g.getPreviousSibling():f.getNextSibling();if(!lexical.$isLineBreakNode(h))return !0;const m=a?h.getPreviousSibling():h.getNextSibling();if(null==m)return !0;const y=et(m)||lexical.$isTabNode(m)||lexical.$isLineBreakNode(m)?a?rt(m):it(m):null;let _=null!=y?y:m;return h.remove(),p.forEach((t=>t.remove())),t===lexical.KEY_ARROW_UP_COMMAND?(p.forEach((t=>_.insertBefore(t))),_.insertBefore(h)):(_.insertAfter(h),_=h,p.forEach((t=>{_.insertAfter(t),_=t;}))),n.setTextNodeRange(u,o,c,s),!0}function kt(t,e){const n=lexical.$getSelection();if(!lexical.$isRangeSelection(n))return !1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),u=t===lexical.MOVE_TO_START;if(!Ct(n)||!et(o)&&!lexical.$isTabNode(o)||!et(s)&&!lexical.$isTabNode(s))return !1;if(u){const t=ot(s,i.offset);if(null!==t){const{node:e,offset:r}=t;lexical.$isLineBreakNode(e)?e.selectNext(0,0):n.setTextNodeRange(e,r,e,r);}else s.getParentOrThrow().selectStart();}else {st(s).select();}return e.preventDefault(),e.stopPropagation(),!0}function At(t,e){if(!t.hasNodes([K,Y]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==e&&(e=xt);const n=[];return !0!==t._headless&&n.push(t.registerMutationListener(K,(e=>{t.update((()=>{for(const[n,r]of e)if("destroyed"!==r){const e=lexical.$getNodeByKey(n);null!==e&&_t(e,t);}}));}),{skipInitialization:!1})),n.push(t.registerNodeTransform(K,(n=>Tt(n,t,e))),t.registerNodeTransform(lexical.TextNode,(n=>St(n,t,e))),t.registerNodeTransform(Y,(n=>St(n,t,e))),t.registerCommand(lexical.KEY_TAB_COMMAND,(e=>{const n=function(t){const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e)||!Ct(e))return null;const n=t?lexical.OUTDENT_CONTENT_COMMAND:lexical.INDENT_CONTENT_COMMAND,r=t?lexical.OUTDENT_CONTENT_COMMAND:lexical.INSERT_TAB_COMMAND,i=e.anchor,o=e.focus;if(i.is(o))return r;const s=Nt(e);if(1!==s.length)return n;const u=s[0];let l,c;0===u.length&&B(285),e.isBackward()?(l=o,c=i):(l=i,c=o);const a=rt(u[0]),g=it(u[0]),f=lexical.$createPoint(a.getKey(),0,"text"),p=lexical.$createPoint(g.getKey(),g.getTextContentSize(),"text");return l.isBefore(f)||p.isBefore(c)?n:f.isBefore(l)||c.isBefore(p)?r:n}(e.shiftKey);return null!==n&&(e.preventDefault(),t.dispatchCommand(n,void 0),!0)}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.INSERT_TAB_COMMAND,(()=>!!Ct(lexical.$getSelection())&&(lexical.$insertNodes([lexical.$createTabNode()]),!0)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.INDENT_CONTENT_COMMAND,(t=>jt(lexical.INDENT_CONTENT_COMMAND)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.OUTDENT_CONTENT_COMMAND,(t=>jt(lexical.OUTDENT_CONTENT_COMMAND)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_ARROW_UP_COMMAND,(t=>{const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e))return !1;const{anchor:n}=e,r=n.getNode();return !!Ct(e)&&(e.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&W(r.getParentOrThrow())?(t.preventDefault(),!0):wt(lexical.KEY_ARROW_UP_COMMAND,t))}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND,(t=>{const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e))return !1;const{anchor:n}=e,r=n.getNode();return !!Ct(e)&&(e.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&W(r.getParentOrThrow())?(t.preventDefault(),!0):wt(lexical.KEY_ARROW_DOWN_COMMAND,t))}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.MOVE_TO_START,(t=>kt(lexical.MOVE_TO_START,t)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.MOVE_TO_END,(t=>kt(lexical.MOVE_TO_END,t)),lexical.COMMAND_PRIORITY_LOW)),LexicalUtils.mergeRegister(...n)}const Pt=rt,Lt=it,Ot=st,Ht=ot;
31
31
 
32
- exports.$createCodeHighlightNode = V;
33
- exports.$createCodeNode = H;
34
- exports.$isCodeHighlightNode = Y;
35
- exports.$isCodeNode = D;
36
- exports.CODE_LANGUAGE_FRIENDLY_NAME_MAP = K;
37
- exports.CODE_LANGUAGE_MAP = q;
38
- exports.CodeHighlightNode = X;
39
- exports.CodeNode = M;
40
- exports.DEFAULT_CODE_LANGUAGE = F;
41
- exports.PrismTokenizer = et;
42
- exports.getCodeLanguages = Q;
43
- exports.getDefaultCodeLanguage = $;
44
- exports.getEndOfCodeInLine = rt;
45
- exports.getFirstCodeNodeOfLine = Z;
46
- exports.getLanguageFriendlyName = W;
47
- exports.getLastCodeNodeOfLine = tt;
48
- exports.getStartOfCodeInLine = nt;
49
- exports.normalizeCodeLang = U;
50
- exports.registerCodeHighlighting = dt;
32
+ exports.$createCodeHighlightNode = tt;
33
+ exports.$createCodeNode = $;
34
+ exports.$getEndOfCodeInLine = st;
35
+ exports.$getFirstCodeNodeOfLine = rt;
36
+ exports.$getLastCodeNodeOfLine = it;
37
+ exports.$getStartOfCodeInLine = ot;
38
+ exports.$isCodeHighlightNode = et;
39
+ exports.$isCodeNode = W;
40
+ exports.CODE_LANGUAGE_FRIENDLY_NAME_MAP = lt;
41
+ exports.CODE_LANGUAGE_MAP = ct;
42
+ exports.CodeHighlightNode = Y;
43
+ exports.CodeNode = K;
44
+ exports.DEFAULT_CODE_LANGUAGE = D;
45
+ exports.PrismTokenizer = xt;
46
+ exports.getCodeLanguageOptions = pt;
47
+ exports.getCodeLanguages = ft;
48
+ exports.getCodeThemeOptions = ht;
49
+ exports.getDefaultCodeLanguage = F;
50
+ exports.getEndOfCodeInLine = Ot;
51
+ exports.getFirstCodeNodeOfLine = Pt;
52
+ exports.getLanguageFriendlyName = gt;
53
+ exports.getLastCodeNodeOfLine = Lt;
54
+ exports.getStartOfCodeInLine = Ht;
55
+ exports.normalizeCodeLang = at;
56
+ exports.normalizeCodeLanguage = at;
57
+ exports.registerCodeHighlighting = At;
@@ -40,7 +40,7 @@ function $generateNodesFromDOM(editor, dom) {
40
40
  }
41
41
  }
42
42
  }
43
- $unwrapArtificalNodes(allArtificialNodes);
43
+ $unwrapArtificialNodes(allArtificialNodes);
44
44
  return lexicalNodes;
45
45
  }
46
46
  function $generateHtmlFromNodes(editor, selection) {
@@ -66,7 +66,7 @@ function $appendNodesToHTML(editor, currentNode, parentElement, selection = null
66
66
  target = clone;
67
67
  }
68
68
  const children = lexical.$isElementNode(target) ? target.getChildren() : [];
69
- const registeredNode = editor._nodes.get(target.getType());
69
+ const registeredNode = lexical.getRegisteredNode(editor, target.getType());
70
70
  let exportOutput;
71
71
 
72
72
  // Use HTMLConfig overrides, if available.
@@ -91,14 +91,18 @@ function $appendNodesToHTML(editor, currentNode, parentElement, selection = null
91
91
  }
92
92
  }
93
93
  if (shouldInclude && !shouldExclude) {
94
- if (LexicalUtils.isHTMLElement(element)) {
94
+ if (LexicalUtils.isHTMLElement(element) || lexical.isDocumentFragment(element)) {
95
95
  element.append(fragment);
96
96
  }
97
97
  parentElement.append(element);
98
98
  if (after) {
99
99
  const newElement = after.call(target, element);
100
100
  if (newElement) {
101
- element.replaceWith(newElement);
101
+ if (lexical.isDocumentFragment(element)) {
102
+ element.replaceChildren(newElement);
103
+ } else {
104
+ element.replaceWith(newElement);
105
+ }
102
106
  }
103
107
  }
104
108
  } else {
@@ -115,7 +119,10 @@ function getConversionFunction(domNode, editor) {
115
119
  if (cachedConversions !== undefined) {
116
120
  for (const cachedConversion of cachedConversions) {
117
121
  const domConversion = cachedConversion(domNode);
118
- if (domConversion !== null && (currentConversion === null || (currentConversion.priority || 0) < (domConversion.priority || 0))) {
122
+ if (domConversion !== null && (currentConversion === null ||
123
+ // Given equal priority, prefer the last registered importer
124
+ // which is typically an application custom node or HTMLConfig['import']
125
+ (currentConversion.priority || 0) <= (domConversion.priority || 0))) {
119
126
  currentConversion = domConversion;
120
127
  }
121
128
  }
@@ -219,7 +226,7 @@ function wrapContinuousInlines(domNode, nodes, createWrapperFn) {
219
226
  }
220
227
  return out;
221
228
  }
222
- function $unwrapArtificalNodes(allArtificialNodes) {
229
+ function $unwrapArtificialNodes(allArtificialNodes) {
223
230
  for (const node of allArtificialNodes) {
224
231
  if (node.getNextSibling() instanceof lexical.ArtificialNode__DO_NOT_USE) {
225
232
  node.insertAfter(lexical.$createLineBreakNode());
@@ -11,7 +11,7 @@ var LexicalHtml_prod = require('./LexicalHtml.prod.js');
11
11
  *
12
12
  */
13
13
 
14
- const mod = process.env.NODE_ENV === 'development' ? LexicalHtml_dev : LexicalHtml_prod;
14
+ const mod = process.env.NODE_ENV !== 'production' ? LexicalHtml_dev : LexicalHtml_prod;
15
15
  const $generateHtmlFromNodes = mod.$generateHtmlFromNodes;
16
16
  const $generateNodesFromDOM = mod.$generateNodesFromDOM;
17
17
 
@@ -12,7 +12,7 @@ var lexical = require('lexical');
12
12
  *
13
13
  */
14
14
 
15
- function p(e,n){const t=n.body?n.body.childNodes:[];let o=[];const l=[];for(let n=0;n<t.length;n++){const r=t[n];if(!g.has(r.nodeName)){const n=x(r,e,l,!1);null!==n&&(o=o.concat(n));}}return function(e){for(const n of e)n.getNextSibling()instanceof lexical.ArtificialNode__DO_NOT_USE&&n.insertAfter(lexical.$createLineBreakNode());for(const n of e){const e=n.getChildren();for(const t of e)n.insertBefore(t);n.remove();}}(l),o}function h(e,n){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),l=lexical.$getRoot().getChildren();for(let o=0;o<l.length;o++){m(e,l[o],t,n);}return t.innerHTML}function m(t,o,s,c=null){let u=null===c||o.isSelected(c);const f=lexical.$isElementNode(o)&&o.excludeFromCopy("html");let a=o;if(null!==c){let n=lexical.$cloneWithProperties(o);n=lexical.$isTextNode(n)&&null!==c?LexicalSelection.$sliceSelectedTextNodeContent(c,n):n,a=n;}const d=lexical.$isElementNode(a)?a.getChildren():[],p=t._nodes.get(a.getType());let h;h=p&&void 0!==p.exportDOM?p.exportDOM(t,a):a.exportDOM(t);const{element:g,after:x}=h;if(!g)return !1;const y=document.createDocumentFragment();for(let e=0;e<d.length;e++){const n=d[e],r=m(t,n,y,c);!u&&lexical.$isElementNode(o)&&r&&o.extractWithChild(n,c,"html")&&(u=!0);}if(u&&!f){if(LexicalUtils.isHTMLElement(g)&&g.append(y),s.append(g),x){const e=x.call(a,g);e&&g.replaceWith(e);}}else s.append(y);return u}const g=new Set(["STYLE","SCRIPT"]);function x(e,n,o,r,i=new Map,p){let h=[];if(g.has(e.nodeName))return h;let m=null;const w=function(e,n){const{nodeName:t}=e,o=n._htmlConversions.get(t.toLowerCase());let l=null;if(void 0!==o)for(const n of o){const t=n(e);null!==t&&(null===l||(l.priority||0)<(t.priority||0))&&(l=t);}return null!==l?l.conversion:null}(e,n),b=w?w(e):null;let C=null;if(null!==b){C=b.after;const n=b.node;if(m=Array.isArray(n)?n[n.length-1]:n,null!==m){for(const[,e]of i)if(m=e(m,p),!m)break;m&&h.push(...Array.isArray(n)?n:[m]);}null!=b.forChild&&i.set(e.nodeName,b.forChild);}const S=e.childNodes;let v=[];const N=(null==m||!lexical.$isRootOrShadowRoot(m))&&(null!=m&&lexical.$isBlockElementNode(m)||r);for(let e=0;e<S.length;e++)v.push(...x(S[e],n,o,N,new Map(i),m));return null!=C&&(v=C(v)),LexicalUtils.isBlockDomNode(e)&&(v=y(e,v,N?()=>{const e=new lexical.ArtificialNode__DO_NOT_USE;return o.push(e),e}:lexical.$createParagraphNode)),null==m?v.length>0?h=h.concat(v):LexicalUtils.isBlockDomNode(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return !1;return lexical.isInlineDomNode(e.nextSibling)&&lexical.isInlineDomNode(e.previousSibling)}(e)&&(h=h.concat(lexical.$createLineBreakNode())):lexical.$isElementNode(m)&&m.append(...v),h}function y(e,n,t){const o=e.style.textAlign,l=[];let r=[];for(let e=0;e<n.length;e++){const i=n[e];if(lexical.$isBlockElementNode(i))o&&!i.getFormat()&&i.setFormat(o),l.push(i);else if(r.push(i),e===n.length-1||e<n.length-1&&lexical.$isBlockElementNode(n[e+1])){const e=t();e.setFormat(o),e.append(...r),l.push(e),r=[];}}return l}
15
+ function m(e,n){const t=n.body?n.body.childNodes:[];let o=[];const l=[];for(let n=0;n<t.length;n++){const r=t[n];if(!y.has(r.nodeName)){const n=w(r,e,l,!1);null!==n&&(o=o.concat(n));}}return function(e){for(const n of e)n.getNextSibling()instanceof lexical.ArtificialNode__DO_NOT_USE&&n.insertAfter(lexical.$createLineBreakNode());for(const n of e){const e=n.getChildren();for(const t of e)n.insertBefore(t);n.remove();}}(l),o}function g(e,n){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),l=lexical.$getRoot().getChildren();for(let o=0;o<l.length;o++){x(e,l[o],t,n);}return t.innerHTML}function x(t,o,u,f=null){let a=null===f||o.isSelected(f);const d=lexical.$isElementNode(o)&&o.excludeFromCopy("html");let p=o;if(null!==f){let n=lexical.$cloneWithProperties(o);n=lexical.$isTextNode(n)&&null!==f?LexicalSelection.$sliceSelectedTextNodeContent(f,n):n,p=n;}const h=lexical.$isElementNode(p)?p.getChildren():[],m=lexical.getRegisteredNode(t,p.getType());let g;g=m&&void 0!==m.exportDOM?m.exportDOM(t,p):p.exportDOM(t);const{element:y,after:w}=g;if(!y)return !1;const b=document.createDocumentFragment();for(let e=0;e<h.length;e++){const n=h[e],r=x(t,n,b,f);!a&&lexical.$isElementNode(o)&&r&&o.extractWithChild(n,f,"html")&&(a=!0);}if(a&&!d){if((LexicalUtils.isHTMLElement(y)||lexical.isDocumentFragment(y))&&y.append(b),u.append(y),w){const e=w.call(p,y);e&&(lexical.isDocumentFragment(y)?y.replaceChildren(e):y.replaceWith(e));}}else u.append(b);return a}const y=new Set(["STYLE","SCRIPT"]);function w(e,n,o,r,i=new Map,s){let c=[];if(y.has(e.nodeName))return c;let m=null;const g=function(e,n){const{nodeName:t}=e,o=n._htmlConversions.get(t.toLowerCase());let l=null;if(void 0!==o)for(const n of o){const t=n(e);null!==t&&(null===l||(l.priority||0)<=(t.priority||0))&&(l=t);}return null!==l?l.conversion:null}(e,n),x=g?g(e):null;let C=null;if(null!==x){C=x.after;const n=x.node;if(m=Array.isArray(n)?n[n.length-1]:n,null!==m){for(const[,e]of i)if(m=e(m,s),!m)break;m&&c.push(...Array.isArray(n)?n:[m]);}null!=x.forChild&&i.set(e.nodeName,x.forChild);}const S=e.childNodes;let v=[];const N=(null==m||!lexical.$isRootOrShadowRoot(m))&&(null!=m&&lexical.$isBlockElementNode(m)||r);for(let e=0;e<S.length;e++)v.push(...w(S[e],n,o,N,new Map(i),m));return null!=C&&(v=C(v)),LexicalUtils.isBlockDomNode(e)&&(v=b(e,v,N?()=>{const e=new lexical.ArtificialNode__DO_NOT_USE;return o.push(e),e}:lexical.$createParagraphNode)),null==m?v.length>0?c=c.concat(v):LexicalUtils.isBlockDomNode(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return !1;return lexical.isInlineDomNode(e.nextSibling)&&lexical.isInlineDomNode(e.previousSibling)}(e)&&(c=c.concat(lexical.$createLineBreakNode())):lexical.$isElementNode(m)&&m.append(...v),c}function b(e,n,t){const o=e.style.textAlign,l=[];let r=[];for(let e=0;e<n.length;e++){const i=n[e];if(lexical.$isBlockElementNode(i))o&&!i.getFormat()&&i.setFormat(o),l.push(i);else if(r.push(i),e===n.length-1||e<n.length-1&&lexical.$isBlockElementNode(n[e+1])){const e=t();e.setFormat(o),e.append(...r),l.push(e),r=[];}}return l}
16
16
 
17
- exports.$generateHtmlFromNodes = h;
18
- exports.$generateNodesFromDOM = p;
17
+ exports.$generateHtmlFromNodes = g;
18
+ exports.$generateNodesFromDOM = m;