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

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 (127) hide show
  1. package/dist/cjs/{packages/lexical/src/components → components}/StickyComponent.js +2 -3
  2. package/dist/cjs/{packages/lexical/src/editor → editor}/LexicalEditor.js +5 -5
  3. package/dist/cjs/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +101 -95
  4. package/dist/cjs/i18n/ar.json.js +24 -0
  5. package/dist/cjs/i18n/en.json.js +24 -0
  6. package/dist/cjs/i18n/index.js +33 -0
  7. package/dist/cjs/{packages/lexical/src/index.js → index.js} +1 -0
  8. package/dist/cjs/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +5 -5
  9. package/dist/cjs/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +35 -22
  10. package/dist/esm/{packages/lexical/src/components → components}/StickyComponent.js +2 -3
  11. package/dist/esm/{packages/lexical/src/editor → editor}/LexicalEditor.js +4 -4
  12. package/dist/esm/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +43 -37
  13. package/dist/esm/i18n/ar.json.js +21 -0
  14. package/dist/esm/i18n/en.json.js +21 -0
  15. package/dist/esm/i18n/index.js +33 -0
  16. package/dist/esm/{packages/lexical/src/index.js → index.js} +1 -0
  17. package/dist/esm/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +2 -2
  18. package/dist/esm/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +36 -23
  19. package/dist/types/hooks/useFormatWatcher.d.ts +1 -0
  20. package/dist/types/i18n/index.d.ts +1 -0
  21. package/dist/types/index.d.ts +1 -0
  22. package/package.json +5 -5
  23. package/src/components/StickyComponent.tsx +2 -3
  24. package/src/hooks/useFormatWatcher.ts +3 -0
  25. package/src/i18n/ar.json +16 -0
  26. package/src/i18n/en.json +16 -0
  27. package/src/i18n/index.ts +28 -0
  28. package/src/index.ts +2 -0
  29. package/src/plugins/ToolbarPlugin.tsx +34 -23
  30. package/dist/cjs/_virtual/prism.js +0 -5
  31. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -474
  32. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -21
  33. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -27
  34. package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +0 -1537
  35. package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +0 -25
  36. package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +0 -57
  37. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +0 -252
  38. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +0 -19
  39. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +0 -18
  40. package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +0 -572
  41. package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +0 -17
  42. package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +0 -25
  43. package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +0 -1614
  44. package/dist/cjs/node_modules/@lexical/list/LexicalList.js +0 -29
  45. package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +0 -36
  46. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -838
  47. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +0 -29
  48. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -26
  49. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -1057
  50. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +0 -39
  51. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -45
  52. package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +0 -4207
  53. package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +0 -23
  54. package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +0 -68
  55. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -1166
  56. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +0 -47
  57. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -81
  58. package/dist/cjs/node_modules/@mdi/js/mdi.js +0 -8
  59. package/dist/cjs/node_modules/prismjs/components/prism-c.js +0 -82
  60. package/dist/cjs/node_modules/prismjs/components/prism-clike.js +0 -33
  61. package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +0 -101
  62. package/dist/cjs/node_modules/prismjs/components/prism-css.js +0 -66
  63. package/dist/cjs/node_modules/prismjs/components/prism-java.js +0 -126
  64. package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +0 -174
  65. package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +0 -417
  66. package/dist/cjs/node_modules/prismjs/components/prism-markup.js +0 -188
  67. package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +0 -14
  68. package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +0 -60
  69. package/dist/cjs/node_modules/prismjs/components/prism-python.js +0 -67
  70. package/dist/cjs/node_modules/prismjs/components/prism-rust.js +0 -130
  71. package/dist/cjs/node_modules/prismjs/components/prism-sql.js +0 -34
  72. package/dist/cjs/node_modules/prismjs/components/prism-swift.js +0 -150
  73. package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +0 -62
  74. package/dist/cjs/node_modules/prismjs/prism.js +0 -1951
  75. package/dist/esm/_virtual/prism.js +0 -5
  76. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -465
  77. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -19
  78. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -18
  79. package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +0 -1512
  80. package/dist/esm/node_modules/@lexical/code/LexicalCode.js +0 -21
  81. package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +0 -32
  82. package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +0 -251
  83. package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +0 -18
  84. package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +0 -17
  85. package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +0 -563
  86. package/dist/esm/node_modules/@lexical/link/LexicalLink.js +0 -17
  87. package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +0 -16
  88. package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +0 -1595
  89. package/dist/esm/node_modules/@lexical/list/LexicalList.js +0 -23
  90. package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +0 -17
  91. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -830
  92. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +0 -23
  93. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -18
  94. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -1028
  95. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +0 -28
  96. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -16
  97. package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +0 -4156
  98. package/dist/esm/node_modules/@lexical/table/LexicalTable.js +0 -20
  99. package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +0 -17
  100. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -1102
  101. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +0 -32
  102. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -17
  103. package/dist/esm/node_modules/@mdi/js/mdi.js +0 -7
  104. package/dist/esm/node_modules/prismjs/components/prism-c.js +0 -82
  105. package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -33
  106. package/dist/esm/node_modules/prismjs/components/prism-cpp.js +0 -101
  107. package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -66
  108. package/dist/esm/node_modules/prismjs/components/prism-java.js +0 -126
  109. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -174
  110. package/dist/esm/node_modules/prismjs/components/prism-markdown.js +0 -417
  111. package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -188
  112. package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +0 -14
  113. package/dist/esm/node_modules/prismjs/components/prism-powershell.js +0 -60
  114. package/dist/esm/node_modules/prismjs/components/prism-python.js +0 -67
  115. package/dist/esm/node_modules/prismjs/components/prism-rust.js +0 -130
  116. package/dist/esm/node_modules/prismjs/components/prism-sql.js +0 -34
  117. package/dist/esm/node_modules/prismjs/components/prism-swift.js +0 -150
  118. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -62
  119. package/dist/esm/node_modules/prismjs/prism.js +0 -1951
  120. /package/dist/cjs/{packages/lexical/src/editor → editor}/theme.js +0 -0
  121. /package/dist/cjs/{packages/lexical/src/nodes → nodes}/StickyNode.js +0 -0
  122. /package/dist/cjs/{packages/lexical/src/plugins → plugins}/StickyPlugin.js +0 -0
  123. /package/dist/cjs/{packages/lexical/src/utils → utils}/index.js +0 -0
  124. /package/dist/esm/{packages/lexical/src/editor → editor}/theme.js +0 -0
  125. /package/dist/esm/{packages/lexical/src/nodes → nodes}/StickyNode.js +0 -0
  126. /package/dist/esm/{packages/lexical/src/plugins → plugins}/StickyPlugin.js +0 -0
  127. /package/dist/esm/{packages/lexical/src/utils → utils}/index.js +0 -0
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- var LexicalCode_dev = require('./LexicalCode.dev.js');
4
- var LexicalCode_prod = require('./LexicalCode.prod.js');
5
-
6
- /**
7
- * Copyright (c) Meta Platforms, Inc. and affiliates.
8
- *
9
- * This source code is licensed under the MIT license found in the
10
- * LICENSE file in the root directory of this source tree.
11
- *
12
- */
13
-
14
- const mod = process.env.NODE_ENV !== 'production' ? LexicalCode_dev : LexicalCode_prod;
15
- const $createCodeNode = mod.$createCodeNode;
16
- const $isCodeNode = mod.$isCodeNode;
17
- const CODE_LANGUAGE_MAP = mod.CODE_LANGUAGE_MAP;
18
- const CodeHighlightNode = mod.CodeHighlightNode;
19
- const CodeNode = mod.CodeNode;
20
-
21
- exports.$createCodeNode = $createCodeNode;
22
- exports.$isCodeNode = $isCodeNode;
23
- exports.CODE_LANGUAGE_MAP = CODE_LANGUAGE_MAP;
24
- exports.CodeHighlightNode = CodeHighlightNode;
25
- exports.CodeNode = CodeNode;
@@ -1,57 +0,0 @@
1
- 'use strict';
2
-
3
- var LexicalUtils = require('../utils/LexicalUtils.js');
4
- var lexical = require('lexical');
5
- require('../../prismjs/prism.js');
6
- require('../../prismjs/components/prism-clike.js');
7
- require('../../prismjs/components/prism-javascript.js');
8
- require('../../prismjs/components/prism-markup.js');
9
- require('../../prismjs/components/prism-markdown.js');
10
- require('../../prismjs/components/prism-c.js');
11
- require('../../prismjs/components/prism-css.js');
12
- require('../../prismjs/components/prism-objectivec.js');
13
- require('../../prismjs/components/prism-sql.js');
14
- require('../../prismjs/components/prism-powershell.js');
15
- require('../../prismjs/components/prism-python.js');
16
- require('../../prismjs/components/prism-rust.js');
17
- require('../../prismjs/components/prism-swift.js');
18
- require('../../prismjs/components/prism-typescript.js');
19
- require('../../prismjs/components/prism-java.js');
20
- require('../../prismjs/components/prism-cpp.js');
21
-
22
- /**
23
- * Copyright (c) Meta Platforms, Inc. and affiliates.
24
- *
25
- * This source code is licensed under the MIT license found in the
26
- * LICENSE file in the root directory of this source tree.
27
- *
28
- */
29
-
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
-
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;
@@ -1,252 +0,0 @@
1
- 'use strict';
2
-
3
- var LexicalSelection = require('../selection/LexicalSelection.js');
4
- var LexicalUtils = require('../utils/LexicalUtils.js');
5
- var lexical = require('lexical');
6
-
7
- /**
8
- * Copyright (c) Meta Platforms, Inc. and affiliates.
9
- *
10
- * This source code is licensed under the MIT license found in the
11
- * LICENSE file in the root directory of this source tree.
12
- *
13
- */
14
-
15
-
16
- /**
17
- * Copyright (c) Meta Platforms, Inc. and affiliates.
18
- *
19
- * This source code is licensed under the MIT license found in the
20
- * LICENSE file in the root directory of this source tree.
21
- *
22
- */
23
-
24
-
25
- /**
26
- * How you parse your html string to get a document is left up to you. In the browser you can use the native
27
- * DOMParser API to generate a document (see clipboard.ts), but to use in a headless environment you can use JSDom
28
- * or an equivalent library and pass in the document here.
29
- */
30
- function $generateNodesFromDOM(editor, dom) {
31
- const elements = dom.body ? dom.body.childNodes : [];
32
- let lexicalNodes = [];
33
- const allArtificialNodes = [];
34
- for (let i = 0; i < elements.length; i++) {
35
- const element = elements[i];
36
- if (!IGNORE_TAGS.has(element.nodeName)) {
37
- const lexicalNode = $createNodesFromDOM(element, editor, allArtificialNodes, false);
38
- if (lexicalNode !== null) {
39
- lexicalNodes = lexicalNodes.concat(lexicalNode);
40
- }
41
- }
42
- }
43
- $unwrapArtificialNodes(allArtificialNodes);
44
- return lexicalNodes;
45
- }
46
- function $generateHtmlFromNodes(editor, selection) {
47
- if (typeof document === 'undefined' || typeof window === 'undefined' && typeof global.window === 'undefined') {
48
- throw new Error('To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.');
49
- }
50
- const container = document.createElement('div');
51
- const root = lexical.$getRoot();
52
- const topLevelChildren = root.getChildren();
53
- for (let i = 0; i < topLevelChildren.length; i++) {
54
- const topLevelNode = topLevelChildren[i];
55
- $appendNodesToHTML(editor, topLevelNode, container, selection);
56
- }
57
- return container.innerHTML;
58
- }
59
- function $appendNodesToHTML(editor, currentNode, parentElement, selection = null) {
60
- let shouldInclude = selection !== null ? currentNode.isSelected(selection) : true;
61
- const shouldExclude = lexical.$isElementNode(currentNode) && currentNode.excludeFromCopy('html');
62
- let target = currentNode;
63
- if (selection !== null) {
64
- let clone = lexical.$cloneWithProperties(currentNode);
65
- clone = lexical.$isTextNode(clone) && selection !== null ? LexicalSelection.$sliceSelectedTextNodeContent(selection, clone) : clone;
66
- target = clone;
67
- }
68
- const children = lexical.$isElementNode(target) ? target.getChildren() : [];
69
- const registeredNode = lexical.getRegisteredNode(editor, target.getType());
70
- let exportOutput;
71
-
72
- // Use HTMLConfig overrides, if available.
73
- if (registeredNode && registeredNode.exportDOM !== undefined) {
74
- exportOutput = registeredNode.exportDOM(editor, target);
75
- } else {
76
- exportOutput = target.exportDOM(editor);
77
- }
78
- const {
79
- element,
80
- after
81
- } = exportOutput;
82
- if (!element) {
83
- return false;
84
- }
85
- const fragment = document.createDocumentFragment();
86
- for (let i = 0; i < children.length; i++) {
87
- const childNode = children[i];
88
- const shouldIncludeChild = $appendNodesToHTML(editor, childNode, fragment, selection);
89
- if (!shouldInclude && lexical.$isElementNode(currentNode) && shouldIncludeChild && currentNode.extractWithChild(childNode, selection, 'html')) {
90
- shouldInclude = true;
91
- }
92
- }
93
- if (shouldInclude && !shouldExclude) {
94
- if (LexicalUtils.isHTMLElement(element) || lexical.isDocumentFragment(element)) {
95
- element.append(fragment);
96
- }
97
- parentElement.append(element);
98
- if (after) {
99
- const newElement = after.call(target, element);
100
- if (newElement) {
101
- if (lexical.isDocumentFragment(element)) {
102
- element.replaceChildren(newElement);
103
- } else {
104
- element.replaceWith(newElement);
105
- }
106
- }
107
- }
108
- } else {
109
- parentElement.append(fragment);
110
- }
111
- return shouldInclude;
112
- }
113
- function getConversionFunction(domNode, editor) {
114
- const {
115
- nodeName
116
- } = domNode;
117
- const cachedConversions = editor._htmlConversions.get(nodeName.toLowerCase());
118
- let currentConversion = null;
119
- if (cachedConversions !== undefined) {
120
- for (const cachedConversion of cachedConversions) {
121
- const domConversion = cachedConversion(domNode);
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))) {
126
- currentConversion = domConversion;
127
- }
128
- }
129
- }
130
- return currentConversion !== null ? currentConversion.conversion : null;
131
- }
132
- const IGNORE_TAGS = new Set(['STYLE', 'SCRIPT']);
133
- function $createNodesFromDOM(node, editor, allArtificialNodes, hasBlockAncestorLexicalNode, forChildMap = new Map(), parentLexicalNode) {
134
- let lexicalNodes = [];
135
- if (IGNORE_TAGS.has(node.nodeName)) {
136
- return lexicalNodes;
137
- }
138
- let currentLexicalNode = null;
139
- const transformFunction = getConversionFunction(node, editor);
140
- const transformOutput = transformFunction ? transformFunction(node) : null;
141
- let postTransform = null;
142
- if (transformOutput !== null) {
143
- postTransform = transformOutput.after;
144
- const transformNodes = transformOutput.node;
145
- currentLexicalNode = Array.isArray(transformNodes) ? transformNodes[transformNodes.length - 1] : transformNodes;
146
- if (currentLexicalNode !== null) {
147
- for (const [, forChildFunction] of forChildMap) {
148
- currentLexicalNode = forChildFunction(currentLexicalNode, parentLexicalNode);
149
- if (!currentLexicalNode) {
150
- break;
151
- }
152
- }
153
- if (currentLexicalNode) {
154
- lexicalNodes.push(...(Array.isArray(transformNodes) ? transformNodes : [currentLexicalNode]));
155
- }
156
- }
157
- if (transformOutput.forChild != null) {
158
- forChildMap.set(node.nodeName, transformOutput.forChild);
159
- }
160
- }
161
-
162
- // If the DOM node doesn't have a transformer, we don't know what
163
- // to do with it but we still need to process any childNodes.
164
- const children = node.childNodes;
165
- let childLexicalNodes = [];
166
- const hasBlockAncestorLexicalNodeForChildren = currentLexicalNode != null && lexical.$isRootOrShadowRoot(currentLexicalNode) ? false : currentLexicalNode != null && lexical.$isBlockElementNode(currentLexicalNode) || hasBlockAncestorLexicalNode;
167
- for (let i = 0; i < children.length; i++) {
168
- childLexicalNodes.push(...$createNodesFromDOM(children[i], editor, allArtificialNodes, hasBlockAncestorLexicalNodeForChildren, new Map(forChildMap), currentLexicalNode));
169
- }
170
- if (postTransform != null) {
171
- childLexicalNodes = postTransform(childLexicalNodes);
172
- }
173
- if (LexicalUtils.isBlockDomNode(node)) {
174
- if (!hasBlockAncestorLexicalNodeForChildren) {
175
- childLexicalNodes = wrapContinuousInlines(node, childLexicalNodes, lexical.$createParagraphNode);
176
- } else {
177
- childLexicalNodes = wrapContinuousInlines(node, childLexicalNodes, () => {
178
- const artificialNode = new lexical.ArtificialNode__DO_NOT_USE();
179
- allArtificialNodes.push(artificialNode);
180
- return artificialNode;
181
- });
182
- }
183
- }
184
- if (currentLexicalNode == null) {
185
- if (childLexicalNodes.length > 0) {
186
- // If it hasn't been converted to a LexicalNode, we hoist its children
187
- // up to the same level as it.
188
- lexicalNodes = lexicalNodes.concat(childLexicalNodes);
189
- } else {
190
- if (LexicalUtils.isBlockDomNode(node) && isDomNodeBetweenTwoInlineNodes(node)) {
191
- // Empty block dom node that hasnt been converted, we replace it with a linebreak if its between inline nodes
192
- lexicalNodes = lexicalNodes.concat(lexical.$createLineBreakNode());
193
- }
194
- }
195
- } else {
196
- if (lexical.$isElementNode(currentLexicalNode)) {
197
- // If the current node is a ElementNode after conversion,
198
- // we can append all the children to it.
199
- currentLexicalNode.append(...childLexicalNodes);
200
- }
201
- }
202
- return lexicalNodes;
203
- }
204
- function wrapContinuousInlines(domNode, nodes, createWrapperFn) {
205
- const textAlign = domNode.style.textAlign;
206
- const out = [];
207
- let continuousInlines = [];
208
- // wrap contiguous inline child nodes in para
209
- for (let i = 0; i < nodes.length; i++) {
210
- const node = nodes[i];
211
- if (lexical.$isBlockElementNode(node)) {
212
- if (textAlign && !node.getFormat()) {
213
- node.setFormat(textAlign);
214
- }
215
- out.push(node);
216
- } else {
217
- continuousInlines.push(node);
218
- if (i === nodes.length - 1 || i < nodes.length - 1 && lexical.$isBlockElementNode(nodes[i + 1])) {
219
- const wrapper = createWrapperFn();
220
- wrapper.setFormat(textAlign);
221
- wrapper.append(...continuousInlines);
222
- out.push(wrapper);
223
- continuousInlines = [];
224
- }
225
- }
226
- }
227
- return out;
228
- }
229
- function $unwrapArtificialNodes(allArtificialNodes) {
230
- for (const node of allArtificialNodes) {
231
- if (node.getNextSibling() instanceof lexical.ArtificialNode__DO_NOT_USE) {
232
- node.insertAfter(lexical.$createLineBreakNode());
233
- }
234
- }
235
- // Replace artificial node with it's children
236
- for (const node of allArtificialNodes) {
237
- const children = node.getChildren();
238
- for (const child of children) {
239
- node.insertBefore(child);
240
- }
241
- node.remove();
242
- }
243
- }
244
- function isDomNodeBetweenTwoInlineNodes(node) {
245
- if (node.nextSibling == null || node.previousSibling == null) {
246
- return false;
247
- }
248
- return lexical.isInlineDomNode(node.nextSibling) && lexical.isInlineDomNode(node.previousSibling);
249
- }
250
-
251
- exports.$generateHtmlFromNodes = $generateHtmlFromNodes;
252
- exports.$generateNodesFromDOM = $generateNodesFromDOM;
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- var LexicalHtml_dev = require('./LexicalHtml.dev.js');
4
- var LexicalHtml_prod = require('./LexicalHtml.prod.js');
5
-
6
- /**
7
- * Copyright (c) Meta Platforms, Inc. and affiliates.
8
- *
9
- * This source code is licensed under the MIT license found in the
10
- * LICENSE file in the root directory of this source tree.
11
- *
12
- */
13
-
14
- const mod = process.env.NODE_ENV !== 'production' ? LexicalHtml_dev : LexicalHtml_prod;
15
- const $generateHtmlFromNodes = mod.$generateHtmlFromNodes;
16
- const $generateNodesFromDOM = mod.$generateNodesFromDOM;
17
-
18
- exports.$generateHtmlFromNodes = $generateHtmlFromNodes;
19
- exports.$generateNodesFromDOM = $generateNodesFromDOM;
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- var LexicalSelection = require('../selection/LexicalSelection.js');
4
- var LexicalUtils = require('../utils/LexicalUtils.js');
5
- var lexical = require('lexical');
6
-
7
- /**
8
- * Copyright (c) Meta Platforms, Inc. and affiliates.
9
- *
10
- * This source code is licensed under the MIT license found in the
11
- * LICENSE file in the root directory of this source tree.
12
- *
13
- */
14
-
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
-
17
- exports.$generateHtmlFromNodes = g;
18
- exports.$generateNodesFromDOM = m;