@lexical/code-core 0.45.1-nightly.20260609.0 → 0.45.1-nightly.20260610.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -104,13 +104,17 @@ function $getStartOfCodeInLine(anchor, offset) {
104
104
  let nodeTextContent = anchor.getTextContent();
105
105
  while (true) {
106
106
  if (nodeOffset === 0) {
107
- node = node.getPreviousSibling();
108
- if (node === null) {
107
+ // Annotation breaks a circular inference through the loop (TS7022),
108
+ // remove when the deprecated generic signatures from #8661 are removed
109
+ const prevSibling = node.getPreviousSibling();
110
+ if (prevSibling === null) {
111
+ node = null;
109
112
  break;
110
113
  }
111
- if (!($isCodeHighlightNode(node) || lexical.$isTabNode(node) || lexical.$isLineBreakNode(node))) {
114
+ if (!($isCodeHighlightNode(prevSibling) || lexical.$isTabNode(prevSibling) || lexical.$isLineBreakNode(prevSibling))) {
112
115
  formatDevErrorMessage(`Expected a valid Code Node: CodeHighlightNode, TabNode, LineBreakNode`);
113
116
  }
117
+ node = prevSibling;
114
118
  if (lexical.$isLineBreakNode(node)) {
115
119
  last = {
116
120
  node,
@@ -102,13 +102,17 @@ function $getStartOfCodeInLine(anchor, offset) {
102
102
  let nodeTextContent = anchor.getTextContent();
103
103
  while (true) {
104
104
  if (nodeOffset === 0) {
105
- node = node.getPreviousSibling();
106
- if (node === null) {
105
+ // Annotation breaks a circular inference through the loop (TS7022),
106
+ // remove when the deprecated generic signatures from #8661 are removed
107
+ const prevSibling = node.getPreviousSibling();
108
+ if (prevSibling === null) {
109
+ node = null;
107
110
  break;
108
111
  }
109
- if (!($isCodeHighlightNode(node) || $isTabNode(node) || $isLineBreakNode(node))) {
112
+ if (!($isCodeHighlightNode(prevSibling) || $isTabNode(prevSibling) || $isLineBreakNode(prevSibling))) {
110
113
  formatDevErrorMessage(`Expected a valid Code Node: CodeHighlightNode, TabNode, LineBreakNode`);
111
114
  }
115
+ node = prevSibling;
112
116
  if ($isLineBreakNode(node)) {
113
117
  last = {
114
118
  node,
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("lexical"),t=require("@lexical/extension"),n=require("@lexical/html"),r=require("@lexical/utils");function i(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function o(t,n){let r=t;for(let i=e.$getSiblingCaret(t,n);i&&(D(i.origin)||e.$isTabNode(i.origin));i=i.getAdjacentCaret())r=i.origin;return r}function s(e){return o(e,"previous")}function l(e){return o(e,"next")}function a(t){const n=s(t),r=l(t);let i=n;for(;null!==i;){if(D(i)){const t=e.getTextDirection(i.getTextContent());if(null!==t)return t}if(i===r)break;i=i.getNextSibling()}const o=n.getParent();if(e.$isElementNode(o)){const e=o.getDirection();if("ltr"===e||"rtl"===e)return e}return null}function c(t,n){let r=null,o=null,s=t,l=n,a=t.getTextContent();for(;;){if(0===l){if(s=s.getPreviousSibling(),null===s)break;if(D(s)||e.$isTabNode(s)||e.$isLineBreakNode(s)||i(167),e.$isLineBreakNode(s)){r={node:s,offset:1};break}l=Math.max(0,s.getTextContentSize()-1),a=s.getTextContent()}else l--;const t=a[l];D(s)&&" "!==t&&(o={node:s,offset:l})}if(null!==o)return o;let c=null;if(n<t.getTextContentSize())D(t)&&(c=t.getTextContent()[n]);else{const e=t.getNextSibling();D(e)&&(c=e.getTextContent()[0])}if(null!==c&&" "!==c)return r;{const i=function(t,n){let r=t,i=n,o=t.getTextContent(),s=t.getTextContentSize();for(;;){if(!D(r)||i===s){if(r=r.getNextSibling(),null===r||e.$isLineBreakNode(r))return null;D(r)&&(i=0,o=r.getTextContent(),s=r.getTextContentSize())}if(D(r)){if(" "!==o[i])return{node:r,offset:i};i++}}}(t,n);return null!==i?i:r}}function u(t){const n=l(t);return e.$isLineBreakNode(n)&&i(168),n}function g(e,t,n){if(!Number.isInteger(t)||t<=0)return!1;const r=e.getTextContent(),i=/^ +/.exec(r);if(!i)return!1;const o=Math.min(t,i[0].length),s=e.getKey(),l=n.anchor.key===s&&"text"===n.anchor.type?n.anchor.offset:null,a=n.focus.key===s&&"text"===n.focus.type?n.focus.offset:null;return e.spliceText(0,o,""),null!==l&&n.anchor.set(s,Math.max(0,l-o),"text"),null!==a&&n.focus.set(s,Math.max(0,a-o),"text"),!0}const d="javascript";function f(t,n){for(const r of t.childNodes){if(e.isHTMLElement(r)&&r.tagName===n)return!0;if(f(r,n))return!0}return!1}const h="data-language",p="data-highlight-language",N="data-theme",m=()=>{};class _ extends e.ElementNode{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(e){return new _(e.__language,e.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(t){const n=document.createElement("code");e.addClassNamesToElement(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(h,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(p,r));const i=this.getTheme();i&&n.setAttribute(N,i);const o=this.getStyle();return o&&e.setDOMStyleFromCSS(n.style,o),n}updateDOM(t,n,r){const i=this.__language,o=t.__language;i?i!==o&&n.setAttribute(h,i):o&&n.removeAttribute(h);const s=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&o?s&&i?i!==o&&n.setAttribute(p,i):n.removeAttribute(p):s&&i&&n.setAttribute(p,i);const l=this.__theme,a=t.__theme;l?l!==a&&n.setAttribute(N,l):a&&n.removeAttribute(N);const c=this.__style,u=t.__style;return c!==u&&e.setDOMStyleFromCSS(n.style,c,u),!1}exportDOM(t){const n=document.createElement("pre");e.addClassNamesToElement(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(h,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(p,r));const i=this.getTheme();i&&n.setAttribute(N,i);const o=this.getStyle();return o&&e.setDOMStyleFromCSS(n.style,o),{element:n}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||f(e,"BR"))?{conversion:x,priority:1}:null,div:()=>({conversion:O,priority:1}),pre:()=>({conversion:x,priority:0}),table:e=>b(e)?{conversion:S,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&b(n)?{conversion:M,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&b(t)?{conversion:M,priority:3}:null}}}static importJSON(e){return T().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(n,r=!0){if(!t.getPeerDependencyFromEditor(e.$getEditor(),"@lexical/code")){m();const e=E(n);if(e)return e}const{anchor:i,focus:o}=n,l=(i.isBefore(o)?i:o).getNode();if(e.$isTextNode(l)){let t=s(l);const n=[];for(;;)if(e.$isTabNode(t))n.push(e.$createTabNode()),t=t.getNextSibling();else{if(!D(t))break;{let e=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;e<i&&" "===r[e];)e++;if(0!==e&&n.push(A(" ".repeat(e))),e!==i)break;t=t.getNextSibling()}}const r=l.splitText(i.offset)[0],o=0===i.offset?0:1,a=r.getIndexWithinParent()+o,c=l.getParentOrThrow(),u=[e.$createLineBreakNode(),...n];c.splice(a,0,u);const g=n[n.length-1];g?g.select():0===i.offset?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(C(l)){const{offset:t}=n.anchor;l.splice(t,0,[e.$createLineBreakNode()]),l.select(t+1,t+1)}return null}canIndent(){return!1}collapseAtStart(){const t=e.$createParagraphNode();return this.getChildren().forEach(e=>t.append(e)),this.replace(t),!0}setLanguage(e){const t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){const t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){const t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}}function T(t,n){return e.$create(_).setLanguage(t).setTheme(n)}function C(e){return e instanceof _}function x(e){return{node:T(e.getAttribute(h))}}function O(e){const t=e,n=$(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if($(t))return!0;t=t.parentElement}return!1}(t)?{node:n?T():null}:{node:null}}function S(){return{node:T()}}function M(){return{node:null}}function $(e){return null!==e.style.fontFamily.match("monospace")}function b(e){return e.classList.contains("js-file-line-container")}function E(t){const{anchor:n}=t;if(t.isCollapsed()&&"element"===n.type){const t=n.getNode();if(C(t)){const r=t.getChildrenSize();if(r>=2&&n.offset===r){const n=t.getLastChild();if(e.$isLineBreakNode(n)&&e.$isLineBreakNode(n.getPreviousSibling())){const n=e.$createParagraphNode();return t.splice(r-2,2,[]).insertAfter(n,!1),n.select(),n}}}}return null}class R extends e.TextNode{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(e){return new R(e.__text,e.__highlightType||void 0,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(t){const n=super.createDOM(t),r=y(t.theme,this.__highlightType);return e.addClassNamesToElement(n,r),n}updateDOM(t,n,r){const i=super.updateDOM(t,n,r),o=y(r.theme,t.__highlightType),s=y(r.theme,this.__highlightType);return o!==s&&(o&&e.removeClassNamesFromElement(n,o),s&&e.addClassNamesToElement(n,s)),i}static importJSON(e){return A().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return T()}}function y(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function A(t="",n){return e.$applyNodeReplacement(new R(t,n))}function D(e){return e instanceof R}const v=e.defineExtension({name:"@lexical/code",nodes:()=>[_,R],register:t=>t.registerCommand(e.KEY_ENTER_COMMAND,t=>{const n=e.$getSelection();return!(!e.$isRangeSelection(n)||!E(n))&&(t.preventDefault(),!0)},e.COMMAND_PRIORITY_LOW)}),I="data-language";function L(e){return null!==e.style.fontFamily.match("monospace")}function P(e){let t=e.parentElement;for(;null!==t;){if(L(t))return!0;t=t.parentElement}return!1}const B=n.defineOverlayRules([n.defineImportRule({$import:(e,t)=>e.$importChildren(t),match:n.sel.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),k=n.defineImportRule({$import:(e,t)=>[T(t.getAttribute(I)).splice(0,0,e.$importChildren(t))],match:n.sel.tag("pre"),name:"@lexical/code/pre"}),W=n.defineImportRule({$import:(e,t,n)=>{const r=t.textContent||"";return/\r?\n/.test(r)||null!==t.querySelector("br")?[T(t.getAttribute(I)).splice(0,0,e.$importChildren(t))]:n()},match:n.sel.tag("code"),name:"@lexical/code/code-multiline"});function w(t){if(!e.isHTMLElement(t))return!1;const n=t.style.fontFamily,r=t.style.whiteSpace;return"string"==typeof n&&/monospace/i.test(n)&&"string"==typeof r&&r.startsWith("pre")}function H(t){let n=!1;const r=[];let i="",o=!1;const s=()=>{o&&(r.push(i),i="",o=!1)};for(const l of Array.from(t.childNodes))if(e.isHTMLElement(l))"DIV"===l.tagName?(s(),r.push(l.textContent||""),n=!0):"BR"===l.tagName?(s(),r.push(""),n=!0):(i+=l.textContent||"",o=!0);else if(e.isDOMTextNode(l)){const e=l.textContent||"";e.length>0&&(i+=e,o=!0)}return s(),n?r:null}function F(t){for(const n of Array.from(t.children)){if(e.isHTMLElement(n)&&w(n)){if(null!==H(n))return!0;const e=n.nextElementSibling;if(e&&w(e))return!0;continue}if(F(n))return!0}return!1}const Y=n.defineImportRule({$import:(t,n,r)=>{if(!w(n)||P(n))return r();const i=H(n);return null===i||0===i.length?r():[T().splice(0,0,e.$generateNodesFromRawText(i.join("\n")))]},match:n.sel.tag("div"),name:"@lexical/code/vscode-wrapper"}),K=n.defineImportRule({$import:(t,n,r)=>{if(!w(n)||P(n))return r();const i=n.previousElementSibling;if(i&&w(i))return[];const o=[];let s=n;for(;s&&w(s);)o.push("BR"===s.tagName?"":s.textContent||""),s=s.nextElementSibling;return o.length<2?r():[T().splice(0,0,e.$generateNodesFromRawText(o.join("\n")))]},match:n.sel.tag("div","br"),name:"@lexical/code/vscode-line-run"}),U=n.defineOverlayRules([Y,K]),z=n.defineImportRule({$import:(e,t,n)=>L(t)?[T().splice(0,0,e.$importChildren(t))]:P(t)?e.$importChildren(t):n(),match:n.sel.tag("div"),name:"@lexical/code/div"}),J=[n.defineImportRule({$import:(e,t)=>[T().splice(0,0,e.$importChildren(t,{rules:B}))],match:n.sel.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"}),n.defineImportRule({$import:(e,t)=>e.$importChildren(t),match:n.sel.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"}),W,k,z],j=e.defineExtension({dependencies:[n.CoreImportExtension,v,e.configExtension(n.DOMImportExtension,{preprocess:[(t,r,i)=>{F(e.isDOMDocumentNode(t)?t.body:t)&&r.session.update(n.ImportOverlays,e=>[...e,U]),i()}],rules:J})],name:"@lexical/code/Import"});function q(t){if(!e.$isRangeSelection(t))return!1;const n=t.anchor.getNode(),r=C(n)?n:n.getParent(),i=t.focus.getNode(),o=C(i)?i:i.getParent();return C(r)&&r.is(o)}function V(t){const n=t.getNodes(),r=[];if(1===n.length&&C(n[0]))return r;let o=[];for(let t=0;t<n.length;t++){const s=n[t];D(s)||e.$isTabNode(s)||e.$isLineBreakNode(s)||i(169),e.$isLineBreakNode(s)?o.length>0&&(r.push(o),o=[]):o.push(s)}if(o.length>0){const n=t.isBackward()?t.anchor:t.focus,i=e.$createPoint(o[0].getKey(),0,"text");n.is(i)||r.push(o)}return r}function G(t,n){const r=e.$getSelection();if(!e.$isRangeSelection(r)||!q(r))return!1;const i=V(r),o=i.length;if(0===o&&r.isCollapsed())return t===e.INDENT_CONTENT_COMMAND&&r.insertNodes([e.$createTabNode()]),!0;if(0===o&&t===e.INDENT_CONTENT_COMMAND&&"\n"===r.getTextContent()){const t=e.$createTabNode(),n=e.$createLineBreakNode(),i=r.isBackward()?"previous":"next";return r.insertNodes([t,n]),e.$setSelectionFromCaretRange(e.$getCaretRangeInDirection(e.$getCaretRange(e.$getTextPointCaret(t,"next",0),e.$normalizeCaret(e.$getSiblingCaret(n,"next"))),i)),!0}for(let l=0;l<o;l++){const o=i[l];if(o.length>0){let i=o[0];if(0===l&&(i=s(i)),t===e.INDENT_CONTENT_COMMAND){const t=e.$createTabNode();if(i.insertBefore(t),0===l){const n=r.isBackward()?"focus":"anchor",o=e.$createPoint(i.getKey(),0,"text");r[n].is(o)&&r[n].set(t.getKey(),0,"text")}}else e.$isTabNode(i)?i.remove():void 0!==n&&D(i)&&g(i,n,r)}}return!0}function Q(t,n){const r=e.$getSelection();if(!e.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,a=i.offset,c=o.offset,u=i.getNode(),g=o.getNode(),d=t===e.KEY_ARROW_UP_COMMAND;if(!q(r)||!D(u)&&!e.$isTabNode(u)||!D(g)&&!e.$isTabNode(g))return!1;if(!n.altKey){if(r.isCollapsed()){const e=u.getParentOrThrow();if(d&&0===a&&null===u.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),n.preventDefault(),!1}else if(!d&&a===u.getTextContentSize()&&null===u.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),n.preventDefault(),!1}}return!1}let f,h;if(u.isBefore(g)?(f=s(u),h=l(g)):(f=s(g),h=l(u)),null==f||null==h)return!1;const p=f.getNodesBetween(h);for(let t=0;t<p.length;t++){const n=p[t];if(!D(n)&&!e.$isTabNode(n)&&!e.$isLineBreakNode(n))return!1}n.preventDefault(),n.stopPropagation();const N=d?f.getPreviousSibling():h.getNextSibling();if(!e.$isLineBreakNode(N))return!0;const m=d?N.getPreviousSibling():N.getNextSibling();if(null==m)return!0;const _=D(m)||e.$isTabNode(m)||e.$isLineBreakNode(m)?d?s(m):l(m):null;let T=null!=_?_:m;return N.remove(),p.forEach(e=>e.remove()),t===e.KEY_ARROW_UP_COMMAND?(p.forEach(e=>T.insertBefore(e)),T.insertBefore(N)):(T.insertAfter(N),T=N,p.forEach(e=>{T.insertAfter(e),T=e})),r.setTextNodeRange(u,a,g,c),!0}function X(t,n){const r=e.$getSelection();if(!e.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,s=i.getNode(),l=o.getNode(),g=t===e.MOVE_TO_START;if(!q(r)||!D(s)&&!e.$isTabNode(s)||!D(l)&&!e.$isTabNode(l))return!1;const d=l,f="rtl"===a(d)?!g:g,h=i.key,p=i.offset,N=i.type;if(f){const t=c(d,o.offset);if(null!==t){const{node:n,offset:i}=t;e.$isLineBreakNode(n)?n.selectNext(0,0):r.setTextNodeRange(n,i,n,i)}else d.getParentOrThrow().selectStart()}else{u(d).select()}return n.shiftKey&&r.anchor.set(h,p,N),n.preventDefault(),n.stopPropagation(),!0}function Z(t,n,o){return e.mergeRegister(...o?[t.registerCommand(e.KEY_ARROW_DOWN_COMMAND,e=>!e.altKey&&r.$onEscapeDown(C),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.KEY_ARROW_RIGHT_COMMAND,()=>r.$onEscapeDown(C),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.KEY_ARROW_UP_COMMAND,e=>!e.altKey&&r.$onEscapeUp(C),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.KEY_ARROW_LEFT_COMMAND,()=>r.$onEscapeUp(C),e.COMMAND_PRIORITY_LOW)]:[],t.registerCommand(e.KEY_TAB_COMMAND,n=>{const r=function(t){const n=e.$getSelection();if(!e.$isRangeSelection(n)||!q(n))return null;const r=t?e.OUTDENT_CONTENT_COMMAND:e.INDENT_CONTENT_COMMAND,o=t?e.OUTDENT_CONTENT_COMMAND:e.INSERT_TAB_COMMAND,a=n.anchor,c=n.focus;if(a.is(c))return o;const u=V(n);if(1!==u.length)return r;const g=u[0];let d,f;0===g.length&&i(285),n.isBackward()?(d=c,f=a):(d=a,f=c);const h=s(g[0]),p=l(g[0]),N=e.$createPoint(h.getKey(),0,"text"),m=e.$createPoint(p.getKey(),p.getTextContentSize(),"text");return d.isBefore(N)||m.isBefore(f)?r:N.isBefore(d)||f.isBefore(m)?o:r}(n.shiftKey);return null!==r&&(n.preventDefault(),t.dispatchCommand(r,void 0),!0)},e.COMMAND_PRIORITY_LOW),t.registerCommand(e.INSERT_TAB_COMMAND,()=>!!q(e.$getSelection())&&(e.$insertNodes([e.$createTabNode()]),!0),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.INDENT_CONTENT_COMMAND,()=>G(e.INDENT_CONTENT_COMMAND),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.OUTDENT_CONTENT_COMMAND,()=>G(e.OUTDENT_CONTENT_COMMAND,n),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.KEY_ARROW_UP_COMMAND,t=>{const n=e.$getSelection();if(!e.$isRangeSelection(n))return!1;const{anchor:r}=n,i=r.getNode();if(!q(n))return!1;const o=i.getParent();return n.isCollapsed()&&0===r.offset&&null===i.getPreviousSibling()&&C(o)&&null===o.getPreviousSibling()?(t.preventDefault(),!0):Q(e.KEY_ARROW_UP_COMMAND,t)},e.COMMAND_PRIORITY_LOW),t.registerCommand(e.KEY_ARROW_DOWN_COMMAND,t=>{const n=e.$getSelection();if(!e.$isRangeSelection(n))return!1;const{anchor:r}=n,i=r.getNode();return!!q(n)&&(n.isCollapsed()&&r.offset===i.getTextContentSize()&&null===i.getNextSibling()&&C(i.getParentOrThrow())&&null===i.getParentOrThrow().getNextSibling()?(t.preventDefault(),!0):Q(e.KEY_ARROW_DOWN_COMMAND,t))},e.COMMAND_PRIORITY_LOW),t.registerCommand(e.MOVE_TO_START,t=>X(e.MOVE_TO_START,t),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.MOVE_TO_END,t=>X(e.MOVE_TO_END,t),e.COMMAND_PRIORITY_LOW))}const ee=e.defineExtension({build:(e,n)=>t.namedSignals(n),config:e.safeCast({disabled:!1,escapeWithArrows:!1,tabSize:void 0}),dependencies:[v],name:"@lexical/code-indent",register:(e,n,r)=>{const i=r.getOutput();return t.effect(()=>{if(!i.disabled.value)return Z(e,i.tabSize.value,i.escapeWithArrows.value)})}});exports.$createCodeHighlightNode=A,exports.$createCodeNode=T,exports.$getCodeLineDirection=a,exports.$getEndOfCodeInLine=u,exports.$getFirstCodeNodeOfLine=s,exports.$getLastCodeNodeOfLine=l,exports.$getStartOfCodeInLine=c,exports.$isCodeHighlightNode=D,exports.$isCodeNode=C,exports.$outdentLeadingSpaces=g,exports.$plainifyCodeContent=function(t){const n=[];return e.tokenizeRawText(t,{linebreak:()=>n.push(e.$createLineBreakNode()),tab:()=>n.push(e.$createTabNode()),text:e=>n.push(A(e))}),n},exports.CodeExtension=v,exports.CodeHighlightNode=R,exports.CodeImportExtension=j,exports.CodeImportRules=J,exports.CodeIndentExtension=ee,exports.CodeNode=_,exports.DEFAULT_CODE_LANGUAGE=d,exports.getDefaultCodeLanguage=()=>d,exports.registerCodeIndentation=Z;
9
+ "use strict";var e=require("lexical"),t=require("@lexical/extension"),n=require("@lexical/html"),r=require("@lexical/utils");function i(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function o(t,n){let r=t;for(let i=e.$getSiblingCaret(t,n);i&&(D(i.origin)||e.$isTabNode(i.origin));i=i.getAdjacentCaret())r=i.origin;return r}function s(e){return o(e,"previous")}function l(e){return o(e,"next")}function a(t){const n=s(t),r=l(t);let i=n;for(;null!==i;){if(D(i)){const t=e.getTextDirection(i.getTextContent());if(null!==t)return t}if(i===r)break;i=i.getNextSibling()}const o=n.getParent();if(e.$isElementNode(o)){const e=o.getDirection();if("ltr"===e||"rtl"===e)return e}return null}function c(t,n){let r=null,o=null,s=t,l=n,a=t.getTextContent();for(;;){if(0===l){const t=s.getPreviousSibling();if(null===t){s=null;break}if(D(t)||e.$isTabNode(t)||e.$isLineBreakNode(t)||i(167),s=t,e.$isLineBreakNode(s)){r={node:s,offset:1};break}l=Math.max(0,s.getTextContentSize()-1),a=s.getTextContent()}else l--;const t=a[l];D(s)&&" "!==t&&(o={node:s,offset:l})}if(null!==o)return o;let c=null;if(n<t.getTextContentSize())D(t)&&(c=t.getTextContent()[n]);else{const e=t.getNextSibling();D(e)&&(c=e.getTextContent()[0])}if(null!==c&&" "!==c)return r;{const i=function(t,n){let r=t,i=n,o=t.getTextContent(),s=t.getTextContentSize();for(;;){if(!D(r)||i===s){if(r=r.getNextSibling(),null===r||e.$isLineBreakNode(r))return null;D(r)&&(i=0,o=r.getTextContent(),s=r.getTextContentSize())}if(D(r)){if(" "!==o[i])return{node:r,offset:i};i++}}}(t,n);return null!==i?i:r}}function u(t){const n=l(t);return e.$isLineBreakNode(n)&&i(168),n}function g(e,t,n){if(!Number.isInteger(t)||t<=0)return!1;const r=e.getTextContent(),i=/^ +/.exec(r);if(!i)return!1;const o=Math.min(t,i[0].length),s=e.getKey(),l=n.anchor.key===s&&"text"===n.anchor.type?n.anchor.offset:null,a=n.focus.key===s&&"text"===n.focus.type?n.focus.offset:null;return e.spliceText(0,o,""),null!==l&&n.anchor.set(s,Math.max(0,l-o),"text"),null!==a&&n.focus.set(s,Math.max(0,a-o),"text"),!0}const d="javascript";function f(t,n){for(const r of t.childNodes){if(e.isHTMLElement(r)&&r.tagName===n)return!0;if(f(r,n))return!0}return!1}const h="data-language",p="data-highlight-language",N="data-theme",m=()=>{};class _ extends e.ElementNode{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(e){return new _(e.__language,e.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(t){const n=document.createElement("code");e.addClassNamesToElement(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(h,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(p,r));const i=this.getTheme();i&&n.setAttribute(N,i);const o=this.getStyle();return o&&e.setDOMStyleFromCSS(n.style,o),n}updateDOM(t,n,r){const i=this.__language,o=t.__language;i?i!==o&&n.setAttribute(h,i):o&&n.removeAttribute(h);const s=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&o?s&&i?i!==o&&n.setAttribute(p,i):n.removeAttribute(p):s&&i&&n.setAttribute(p,i);const l=this.__theme,a=t.__theme;l?l!==a&&n.setAttribute(N,l):a&&n.removeAttribute(N);const c=this.__style,u=t.__style;return c!==u&&e.setDOMStyleFromCSS(n.style,c,u),!1}exportDOM(t){const n=document.createElement("pre");e.addClassNamesToElement(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(h,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(p,r));const i=this.getTheme();i&&n.setAttribute(N,i);const o=this.getStyle();return o&&e.setDOMStyleFromCSS(n.style,o),{element:n}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||f(e,"BR"))?{conversion:x,priority:1}:null,div:()=>({conversion:O,priority:1}),pre:()=>({conversion:x,priority:0}),table:e=>b(e)?{conversion:S,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&b(n)?{conversion:M,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&b(t)?{conversion:M,priority:3}:null}}}static importJSON(e){return T().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(n,r=!0){if(!t.getPeerDependencyFromEditor(e.$getEditor(),"@lexical/code")){m();const e=E(n);if(e)return e}const{anchor:i,focus:o}=n,l=(i.isBefore(o)?i:o).getNode();if(e.$isTextNode(l)){let t=s(l);const n=[];for(;;)if(e.$isTabNode(t))n.push(e.$createTabNode()),t=t.getNextSibling();else{if(!D(t))break;{let e=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;e<i&&" "===r[e];)e++;if(0!==e&&n.push(A(" ".repeat(e))),e!==i)break;t=t.getNextSibling()}}const r=l.splitText(i.offset)[0],o=0===i.offset?0:1,a=r.getIndexWithinParent()+o,c=l.getParentOrThrow(),u=[e.$createLineBreakNode(),...n];c.splice(a,0,u);const g=n[n.length-1];g?g.select():0===i.offset?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(C(l)){const{offset:t}=n.anchor;l.splice(t,0,[e.$createLineBreakNode()]),l.select(t+1,t+1)}return null}canIndent(){return!1}collapseAtStart(){const t=e.$createParagraphNode();return this.getChildren().forEach(e=>t.append(e)),this.replace(t),!0}setLanguage(e){const t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){const t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){const t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}}function T(t,n){return e.$create(_).setLanguage(t).setTheme(n)}function C(e){return e instanceof _}function x(e){return{node:T(e.getAttribute(h))}}function O(e){const t=e,n=$(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if($(t))return!0;t=t.parentElement}return!1}(t)?{node:n?T():null}:{node:null}}function S(){return{node:T()}}function M(){return{node:null}}function $(e){return null!==e.style.fontFamily.match("monospace")}function b(e){return e.classList.contains("js-file-line-container")}function E(t){const{anchor:n}=t;if(t.isCollapsed()&&"element"===n.type){const t=n.getNode();if(C(t)){const r=t.getChildrenSize();if(r>=2&&n.offset===r){const n=t.getLastChild();if(e.$isLineBreakNode(n)&&e.$isLineBreakNode(n.getPreviousSibling())){const n=e.$createParagraphNode();return t.splice(r-2,2,[]).insertAfter(n,!1),n.select(),n}}}}return null}class R extends e.TextNode{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(e){return new R(e.__text,e.__highlightType||void 0,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(t){const n=super.createDOM(t),r=y(t.theme,this.__highlightType);return e.addClassNamesToElement(n,r),n}updateDOM(t,n,r){const i=super.updateDOM(t,n,r),o=y(r.theme,t.__highlightType),s=y(r.theme,this.__highlightType);return o!==s&&(o&&e.removeClassNamesFromElement(n,o),s&&e.addClassNamesToElement(n,s)),i}static importJSON(e){return A().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return T()}}function y(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function A(t="",n){return e.$applyNodeReplacement(new R(t,n))}function D(e){return e instanceof R}const v=e.defineExtension({name:"@lexical/code",nodes:()=>[_,R],register:t=>t.registerCommand(e.KEY_ENTER_COMMAND,t=>{const n=e.$getSelection();return!(!e.$isRangeSelection(n)||!E(n))&&(t.preventDefault(),!0)},e.COMMAND_PRIORITY_LOW)}),I="data-language";function L(e){return null!==e.style.fontFamily.match("monospace")}function P(e){let t=e.parentElement;for(;null!==t;){if(L(t))return!0;t=t.parentElement}return!1}const B=n.defineOverlayRules([n.defineImportRule({$import:(e,t)=>e.$importChildren(t),match:n.sel.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),k=n.defineImportRule({$import:(e,t)=>[T(t.getAttribute(I)).splice(0,0,e.$importChildren(t))],match:n.sel.tag("pre"),name:"@lexical/code/pre"}),W=n.defineImportRule({$import:(e,t,n)=>{const r=t.textContent||"";return/\r?\n/.test(r)||null!==t.querySelector("br")?[T(t.getAttribute(I)).splice(0,0,e.$importChildren(t))]:n()},match:n.sel.tag("code"),name:"@lexical/code/code-multiline"});function w(t){if(!e.isHTMLElement(t))return!1;const n=t.style.fontFamily,r=t.style.whiteSpace;return"string"==typeof n&&/monospace/i.test(n)&&"string"==typeof r&&r.startsWith("pre")}function H(t){let n=!1;const r=[];let i="",o=!1;const s=()=>{o&&(r.push(i),i="",o=!1)};for(const l of Array.from(t.childNodes))if(e.isHTMLElement(l))"DIV"===l.tagName?(s(),r.push(l.textContent||""),n=!0):"BR"===l.tagName?(s(),r.push(""),n=!0):(i+=l.textContent||"",o=!0);else if(e.isDOMTextNode(l)){const e=l.textContent||"";e.length>0&&(i+=e,o=!0)}return s(),n?r:null}function F(t){for(const n of Array.from(t.children)){if(e.isHTMLElement(n)&&w(n)){if(null!==H(n))return!0;const e=n.nextElementSibling;if(e&&w(e))return!0;continue}if(F(n))return!0}return!1}const Y=n.defineImportRule({$import:(t,n,r)=>{if(!w(n)||P(n))return r();const i=H(n);return null===i||0===i.length?r():[T().splice(0,0,e.$generateNodesFromRawText(i.join("\n")))]},match:n.sel.tag("div"),name:"@lexical/code/vscode-wrapper"}),K=n.defineImportRule({$import:(t,n,r)=>{if(!w(n)||P(n))return r();const i=n.previousElementSibling;if(i&&w(i))return[];const o=[];let s=n;for(;s&&w(s);)o.push("BR"===s.tagName?"":s.textContent||""),s=s.nextElementSibling;return o.length<2?r():[T().splice(0,0,e.$generateNodesFromRawText(o.join("\n")))]},match:n.sel.tag("div","br"),name:"@lexical/code/vscode-line-run"}),U=n.defineOverlayRules([Y,K]),z=n.defineImportRule({$import:(e,t,n)=>L(t)?[T().splice(0,0,e.$importChildren(t))]:P(t)?e.$importChildren(t):n(),match:n.sel.tag("div"),name:"@lexical/code/div"}),J=[n.defineImportRule({$import:(e,t)=>[T().splice(0,0,e.$importChildren(t,{rules:B}))],match:n.sel.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"}),n.defineImportRule({$import:(e,t)=>e.$importChildren(t),match:n.sel.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"}),W,k,z],j=e.defineExtension({dependencies:[n.CoreImportExtension,v,e.configExtension(n.DOMImportExtension,{preprocess:[(t,r,i)=>{F(e.isDOMDocumentNode(t)?t.body:t)&&r.session.update(n.ImportOverlays,e=>[...e,U]),i()}],rules:J})],name:"@lexical/code/Import"});function q(t){if(!e.$isRangeSelection(t))return!1;const n=t.anchor.getNode(),r=C(n)?n:n.getParent(),i=t.focus.getNode(),o=C(i)?i:i.getParent();return C(r)&&r.is(o)}function V(t){const n=t.getNodes(),r=[];if(1===n.length&&C(n[0]))return r;let o=[];for(let t=0;t<n.length;t++){const s=n[t];D(s)||e.$isTabNode(s)||e.$isLineBreakNode(s)||i(169),e.$isLineBreakNode(s)?o.length>0&&(r.push(o),o=[]):o.push(s)}if(o.length>0){const n=t.isBackward()?t.anchor:t.focus,i=e.$createPoint(o[0].getKey(),0,"text");n.is(i)||r.push(o)}return r}function G(t,n){const r=e.$getSelection();if(!e.$isRangeSelection(r)||!q(r))return!1;const i=V(r),o=i.length;if(0===o&&r.isCollapsed())return t===e.INDENT_CONTENT_COMMAND&&r.insertNodes([e.$createTabNode()]),!0;if(0===o&&t===e.INDENT_CONTENT_COMMAND&&"\n"===r.getTextContent()){const t=e.$createTabNode(),n=e.$createLineBreakNode(),i=r.isBackward()?"previous":"next";return r.insertNodes([t,n]),e.$setSelectionFromCaretRange(e.$getCaretRangeInDirection(e.$getCaretRange(e.$getTextPointCaret(t,"next",0),e.$normalizeCaret(e.$getSiblingCaret(n,"next"))),i)),!0}for(let l=0;l<o;l++){const o=i[l];if(o.length>0){let i=o[0];if(0===l&&(i=s(i)),t===e.INDENT_CONTENT_COMMAND){const t=e.$createTabNode();if(i.insertBefore(t),0===l){const n=r.isBackward()?"focus":"anchor",o=e.$createPoint(i.getKey(),0,"text");r[n].is(o)&&r[n].set(t.getKey(),0,"text")}}else e.$isTabNode(i)?i.remove():void 0!==n&&D(i)&&g(i,n,r)}}return!0}function Q(t,n){const r=e.$getSelection();if(!e.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,a=i.offset,c=o.offset,u=i.getNode(),g=o.getNode(),d=t===e.KEY_ARROW_UP_COMMAND;if(!q(r)||!D(u)&&!e.$isTabNode(u)||!D(g)&&!e.$isTabNode(g))return!1;if(!n.altKey){if(r.isCollapsed()){const e=u.getParentOrThrow();if(d&&0===a&&null===u.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),n.preventDefault(),!1}else if(!d&&a===u.getTextContentSize()&&null===u.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),n.preventDefault(),!1}}return!1}let f,h;if(u.isBefore(g)?(f=s(u),h=l(g)):(f=s(g),h=l(u)),null==f||null==h)return!1;const p=f.getNodesBetween(h);for(let t=0;t<p.length;t++){const n=p[t];if(!D(n)&&!e.$isTabNode(n)&&!e.$isLineBreakNode(n))return!1}n.preventDefault(),n.stopPropagation();const N=d?f.getPreviousSibling():h.getNextSibling();if(!e.$isLineBreakNode(N))return!0;const m=d?N.getPreviousSibling():N.getNextSibling();if(null==m)return!0;const _=D(m)||e.$isTabNode(m)||e.$isLineBreakNode(m)?d?s(m):l(m):null;let T=null!=_?_:m;return N.remove(),p.forEach(e=>e.remove()),t===e.KEY_ARROW_UP_COMMAND?(p.forEach(e=>T.insertBefore(e)),T.insertBefore(N)):(T.insertAfter(N),T=N,p.forEach(e=>{T.insertAfter(e),T=e})),r.setTextNodeRange(u,a,g,c),!0}function X(t,n){const r=e.$getSelection();if(!e.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,s=i.getNode(),l=o.getNode(),g=t===e.MOVE_TO_START;if(!q(r)||!D(s)&&!e.$isTabNode(s)||!D(l)&&!e.$isTabNode(l))return!1;const d=l,f="rtl"===a(d)?!g:g,h=i.key,p=i.offset,N=i.type;if(f){const t=c(d,o.offset);if(null!==t){const{node:n,offset:i}=t;e.$isLineBreakNode(n)?n.selectNext(0,0):r.setTextNodeRange(n,i,n,i)}else d.getParentOrThrow().selectStart()}else{u(d).select()}return n.shiftKey&&r.anchor.set(h,p,N),n.preventDefault(),n.stopPropagation(),!0}function Z(t,n,o){return e.mergeRegister(...o?[t.registerCommand(e.KEY_ARROW_DOWN_COMMAND,e=>!e.altKey&&r.$onEscapeDown(C),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.KEY_ARROW_RIGHT_COMMAND,()=>r.$onEscapeDown(C),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.KEY_ARROW_UP_COMMAND,e=>!e.altKey&&r.$onEscapeUp(C),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.KEY_ARROW_LEFT_COMMAND,()=>r.$onEscapeUp(C),e.COMMAND_PRIORITY_LOW)]:[],t.registerCommand(e.KEY_TAB_COMMAND,n=>{const r=function(t){const n=e.$getSelection();if(!e.$isRangeSelection(n)||!q(n))return null;const r=t?e.OUTDENT_CONTENT_COMMAND:e.INDENT_CONTENT_COMMAND,o=t?e.OUTDENT_CONTENT_COMMAND:e.INSERT_TAB_COMMAND,a=n.anchor,c=n.focus;if(a.is(c))return o;const u=V(n);if(1!==u.length)return r;const g=u[0];let d,f;0===g.length&&i(285),n.isBackward()?(d=c,f=a):(d=a,f=c);const h=s(g[0]),p=l(g[0]),N=e.$createPoint(h.getKey(),0,"text"),m=e.$createPoint(p.getKey(),p.getTextContentSize(),"text");return d.isBefore(N)||m.isBefore(f)?r:N.isBefore(d)||f.isBefore(m)?o:r}(n.shiftKey);return null!==r&&(n.preventDefault(),t.dispatchCommand(r,void 0),!0)},e.COMMAND_PRIORITY_LOW),t.registerCommand(e.INSERT_TAB_COMMAND,()=>!!q(e.$getSelection())&&(e.$insertNodes([e.$createTabNode()]),!0),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.INDENT_CONTENT_COMMAND,()=>G(e.INDENT_CONTENT_COMMAND),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.OUTDENT_CONTENT_COMMAND,()=>G(e.OUTDENT_CONTENT_COMMAND,n),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.KEY_ARROW_UP_COMMAND,t=>{const n=e.$getSelection();if(!e.$isRangeSelection(n))return!1;const{anchor:r}=n,i=r.getNode();if(!q(n))return!1;const o=i.getParent();return n.isCollapsed()&&0===r.offset&&null===i.getPreviousSibling()&&C(o)&&null===o.getPreviousSibling()?(t.preventDefault(),!0):Q(e.KEY_ARROW_UP_COMMAND,t)},e.COMMAND_PRIORITY_LOW),t.registerCommand(e.KEY_ARROW_DOWN_COMMAND,t=>{const n=e.$getSelection();if(!e.$isRangeSelection(n))return!1;const{anchor:r}=n,i=r.getNode();return!!q(n)&&(n.isCollapsed()&&r.offset===i.getTextContentSize()&&null===i.getNextSibling()&&C(i.getParentOrThrow())&&null===i.getParentOrThrow().getNextSibling()?(t.preventDefault(),!0):Q(e.KEY_ARROW_DOWN_COMMAND,t))},e.COMMAND_PRIORITY_LOW),t.registerCommand(e.MOVE_TO_START,t=>X(e.MOVE_TO_START,t),e.COMMAND_PRIORITY_LOW),t.registerCommand(e.MOVE_TO_END,t=>X(e.MOVE_TO_END,t),e.COMMAND_PRIORITY_LOW))}const ee=e.defineExtension({build:(e,n)=>t.namedSignals(n),config:e.safeCast({disabled:!1,escapeWithArrows:!1,tabSize:void 0}),dependencies:[v],name:"@lexical/code-indent",register:(e,n,r)=>{const i=r.getOutput();return t.effect(()=>{if(!i.disabled.value)return Z(e,i.tabSize.value,i.escapeWithArrows.value)})}});exports.$createCodeHighlightNode=A,exports.$createCodeNode=T,exports.$getCodeLineDirection=a,exports.$getEndOfCodeInLine=u,exports.$getFirstCodeNodeOfLine=s,exports.$getLastCodeNodeOfLine=l,exports.$getStartOfCodeInLine=c,exports.$isCodeHighlightNode=D,exports.$isCodeNode=C,exports.$outdentLeadingSpaces=g,exports.$plainifyCodeContent=function(t){const n=[];return e.tokenizeRawText(t,{linebreak:()=>n.push(e.$createLineBreakNode()),tab:()=>n.push(e.$createTabNode()),text:e=>n.push(A(e))}),n},exports.CodeExtension=v,exports.CodeHighlightNode=R,exports.CodeImportExtension=j,exports.CodeImportRules=J,exports.CodeIndentExtension=ee,exports.CodeNode=_,exports.DEFAULT_CODE_LANGUAGE=d,exports.getDefaultCodeLanguage=()=>d,exports.registerCodeIndentation=Z;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{getTextDirection as e,$isElementNode as t,$isTabNode as n,$isLineBreakNode as r,tokenizeRawText as i,$createTabNode as o,$createLineBreakNode as s,$getSiblingCaret as l,$create as u,ElementNode as c,addClassNamesToElement as a,setDOMStyleFromCSS as g,$getEditor as h,$isTextNode as f,$createParagraphNode as p,isHTMLElement as d,$applyNodeReplacement as m,TextNode as x,removeClassNamesFromElement as _,defineExtension as S,KEY_ENTER_COMMAND as y,$getSelection as b,$isRangeSelection as v,COMMAND_PRIORITY_LOW as C,configExtension as N,isDOMDocumentNode as T,isDOMTextNode as A,$generateNodesFromRawText as O,safeCast as P,mergeRegister as w,KEY_ARROW_DOWN_COMMAND as H,KEY_ARROW_RIGHT_COMMAND as D,KEY_ARROW_UP_COMMAND as k,KEY_ARROW_LEFT_COMMAND as B,KEY_TAB_COMMAND as L,INSERT_TAB_COMMAND as $,$insertNodes as E,INDENT_CONTENT_COMMAND as F,OUTDENT_CONTENT_COMMAND as M,MOVE_TO_START as J,MOVE_TO_END as z,$createPoint as K,$setSelectionFromCaretRange as I,$getCaretRangeInDirection as j,$getCaretRange as R,$getTextPointCaret as W,$normalizeCaret as q}from"lexical";import{getPeerDependencyFromEditor as U,effect as V,namedSignals as G}from"@lexical/extension";import{CoreImportExtension as Q,DOMImportExtension as X,defineImportRule as Y,sel as Z,ImportOverlays as ee,defineOverlayRules as te}from"@lexical/html";import{$onEscapeDown as ne,$onEscapeUp as re}from"@lexical/utils";function ie(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function oe(e,t){let r=e;for(let i=l(e,t);i&&(Be(i.origin)||n(i.origin));i=i.getAdjacentCaret())r=i.origin;return r}function se(e){return oe(e,"previous")}function le(e){return oe(e,"next")}function ue(n){const r=se(n),i=le(n);let o=r;for(;null!==o;){if(Be(o)){const t=e(o.getTextContent());if(null!==t)return t}if(o===i)break;o=o.getNextSibling()}const s=r.getParent();if(t(s)){const e=s.getDirection();if("ltr"===e||"rtl"===e)return e}return null}function ce(e,t){let i=null,o=null,s=e,l=t,u=e.getTextContent();for(;;){if(0===l){if(s=s.getPreviousSibling(),null===s)break;if(Be(s)||n(s)||r(s)||ie(167),r(s)){i={node:s,offset:1};break}l=Math.max(0,s.getTextContentSize()-1),u=s.getTextContent()}else l--;const e=u[l];Be(s)&&" "!==e&&(o={node:s,offset:l})}if(null!==o)return o;let c=null;if(t<e.getTextContentSize())Be(e)&&(c=e.getTextContent()[t]);else{const t=e.getNextSibling();Be(t)&&(c=t.getTextContent()[0])}if(null!==c&&" "!==c)return i;{const n=function(e,t){let n=e,i=t,o=e.getTextContent(),s=e.getTextContentSize();for(;;){if(!Be(n)||i===s){if(n=n.getNextSibling(),null===n||r(n))return null;Be(n)&&(i=0,o=n.getTextContent(),s=n.getTextContentSize())}if(Be(n)){if(" "!==o[i])return{node:n,offset:i};i++}}}(e,t);return null!==n?n:i}}function ae(e){const t=le(e);return r(t)&&ie(168),t}function ge(e){const t=[];return i(e,{linebreak:()=>t.push(s()),tab:()=>t.push(o()),text:e=>t.push(ke(e))}),t}function he(e,t,n){if(!Number.isInteger(t)||t<=0)return!1;const r=e.getTextContent(),i=/^ +/.exec(r);if(!i)return!1;const o=Math.min(t,i[0].length),s=e.getKey(),l=n.anchor.key===s&&"text"===n.anchor.type?n.anchor.offset:null,u=n.focus.key===s&&"text"===n.focus.type?n.focus.offset:null;return e.spliceText(0,o,""),null!==l&&n.anchor.set(s,Math.max(0,l-o),"text"),null!==u&&n.focus.set(s,Math.max(0,u-o),"text"),!0}const fe="javascript",pe=()=>fe;function de(e,t){for(const n of e.childNodes){if(d(n)&&n.tagName===t)return!0;if(de(n,t))return!0}return!1}const me="data-language",xe="data-highlight-language",_e="data-theme",Se=()=>{};class ye extends c{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(e){return new ye(e.__language,e.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){const t=document.createElement("code");a(t,e.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(me,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(xe,n));const r=this.getTheme();r&&t.setAttribute(_e,r);const i=this.getStyle();return i&&g(t.style,i),t}updateDOM(e,t,n){const r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(me,r):i&&t.removeAttribute(me);const o=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&t.setAttribute(xe,r):t.removeAttribute(xe):o&&r&&t.setAttribute(xe,r);const s=this.__theme,l=e.__theme;s?s!==l&&t.setAttribute(_e,s):l&&t.removeAttribute(_e);const u=this.__style,c=e.__style;return u!==c&&g(t.style,u,c),!1}exportDOM(e){const t=document.createElement("pre");a(t,e._config.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(me,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(xe,n));const r=this.getTheme();r&&t.setAttribute(_e,r);const i=this.getStyle();return i&&g(t.style,i),{element:t}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||de(e,"BR"))?{conversion:Ce,priority:1}:null,div:()=>({conversion:Ne,priority:1}),pre:()=>({conversion:Ce,priority:0}),table:e=>Pe(e)?{conversion:Te,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&Pe(n)?{conversion:Ae,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&Pe(t)?{conversion:Ae,priority:3}:null}}}static importJSON(e){return be().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,t=!0){if(!U(h(),"@lexical/code")){Se();const t=we(e);if(t)return t}const{anchor:r,focus:i}=e,l=(r.isBefore(i)?r:i).getNode();if(f(l)){let e=se(l);const t=[];for(;;)if(n(e))t.push(o()),e=e.getNextSibling();else{if(!Be(e))break;{let n=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&t.push(ke(" ".repeat(n))),n!==i)break;e=e.getNextSibling()}}const i=l.splitText(r.offset)[0],u=0===r.offset?0:1,c=i.getIndexWithinParent()+u,a=l.getParentOrThrow(),g=[s(),...t];a.splice(c,0,g);const h=t[t.length-1];h?h.select():0===r.offset?i.selectPrevious():i.getNextSibling().selectNext(0,0)}if(ve(l)){const{offset:t}=e.anchor;l.splice(t,0,[s()]),l.select(t+1,t+1)}return null}canIndent(){return!1}collapseAtStart(){const e=p();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}setLanguage(e){const t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){const t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){const t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}}function be(e,t){return u(ye).setLanguage(e).setTheme(t)}function ve(e){return e instanceof ye}function Ce(e){return{node:be(e.getAttribute(me))}}function Ne(e){const t=e,n=Oe(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if(Oe(t))return!0;t=t.parentElement}return!1}(t)?{node:n?be():null}:{node:null}}function Te(){return{node:be()}}function Ae(){return{node:null}}function Oe(e){return null!==e.style.fontFamily.match("monospace")}function Pe(e){return e.classList.contains("js-file-line-container")}function we(e){const{anchor:t}=e;if(e.isCollapsed()&&"element"===t.type){const e=t.getNode();if(ve(e)){const n=e.getChildrenSize();if(n>=2&&t.offset===n){const t=e.getLastChild();if(r(t)&&r(t.getPreviousSibling())){const t=p();return e.splice(n-2,2,[]).insertAfter(t,!1),t.select(),t}}}}return null}class He extends x{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(e){return new He(e.__text,e.__highlightType||void 0,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){const t=super.createDOM(e),n=De(e.theme,this.__highlightType);return a(t,n),t}updateDOM(e,t,n){const r=super.updateDOM(e,t,n),i=De(n.theme,e.__highlightType),o=De(n.theme,this.__highlightType);return i!==o&&(i&&_(t,i),o&&a(t,o)),r}static importJSON(e){return ke().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return be()}}function De(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function ke(e="",t){return m(new He(e,t))}function Be(e){return e instanceof He}const Le=S({name:"@lexical/code",nodes:()=>[ye,He],register:e=>e.registerCommand(y,e=>{const t=b();return!(!v(t)||!we(t))&&(e.preventDefault(),!0)},C)}),$e="data-language";function Ee(e){return null!==e.style.fontFamily.match("monospace")}function Fe(e){let t=e.parentElement;for(;null!==t;){if(Ee(t))return!0;t=t.parentElement}return!1}const Me=te([Y({$import:(e,t)=>e.$importChildren(t),match:Z.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),Je=Y({$import:(e,t)=>[be(t.getAttribute($e)).splice(0,0,e.$importChildren(t))],match:Z.tag("pre"),name:"@lexical/code/pre"}),ze=Y({$import:(e,t,n)=>{const r=t.textContent||"";return/\r?\n/.test(r)||null!==t.querySelector("br")?[be(t.getAttribute($e)).splice(0,0,e.$importChildren(t))]:n()},match:Z.tag("code"),name:"@lexical/code/code-multiline"});function Ke(e){if(!d(e))return!1;const t=e.style.fontFamily,n=e.style.whiteSpace;return"string"==typeof t&&/monospace/i.test(t)&&"string"==typeof n&&n.startsWith("pre")}function Ie(e){let t=!1;const n=[];let r="",i=!1;const o=()=>{i&&(n.push(r),r="",i=!1)};for(const s of Array.from(e.childNodes))if(d(s))"DIV"===s.tagName?(o(),n.push(s.textContent||""),t=!0):"BR"===s.tagName?(o(),n.push(""),t=!0):(r+=s.textContent||"",i=!0);else if(A(s)){const e=s.textContent||"";e.length>0&&(r+=e,i=!0)}return o(),t?n:null}function je(e){for(const t of Array.from(e.children)){if(d(t)&&Ke(t)){if(null!==Ie(t))return!0;const e=t.nextElementSibling;if(e&&Ke(e))return!0;continue}if(je(t))return!0}return!1}const Re=te([Y({$import:(e,t,n)=>{if(!Ke(t)||Fe(t))return n();const r=Ie(t);return null===r||0===r.length?n():[be().splice(0,0,O(r.join("\n")))]},match:Z.tag("div"),name:"@lexical/code/vscode-wrapper"}),Y({$import:(e,t,n)=>{if(!Ke(t)||Fe(t))return n();const r=t.previousElementSibling;if(r&&Ke(r))return[];const i=[];let o=t;for(;o&&Ke(o);)i.push("BR"===o.tagName?"":o.textContent||""),o=o.nextElementSibling;return i.length<2?n():[be().splice(0,0,O(i.join("\n")))]},match:Z.tag("div","br"),name:"@lexical/code/vscode-line-run"})]),We=Y({$import:(e,t,n)=>Ee(t)?[be().splice(0,0,e.$importChildren(t))]:Fe(t)?e.$importChildren(t):n(),match:Z.tag("div"),name:"@lexical/code/div"}),qe=[Y({$import:(e,t)=>[be().splice(0,0,e.$importChildren(t,{rules:Me}))],match:Z.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"}),Y({$import:(e,t)=>e.$importChildren(t),match:Z.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"}),ze,Je,We],Ue=S({dependencies:[Q,Le,N(X,{preprocess:[(e,t,n)=>{je(T(e)?e.body:e)&&t.session.update(ee,e=>[...e,Re]),n()}],rules:qe})],name:"@lexical/code/Import"});function Ve(e){if(!v(e))return!1;const t=e.anchor.getNode(),n=ve(t)?t:t.getParent(),r=e.focus.getNode(),i=ve(r)?r:r.getParent();return ve(n)&&n.is(i)}function Ge(e){const t=e.getNodes(),i=[];if(1===t.length&&ve(t[0]))return i;let o=[];for(let e=0;e<t.length;e++){const s=t[e];Be(s)||n(s)||r(s)||ie(169),r(s)?o.length>0&&(i.push(o),o=[]):o.push(s)}if(o.length>0){const t=e.isBackward()?e.anchor:e.focus,n=K(o[0].getKey(),0,"text");t.is(n)||i.push(o)}return i}function Qe(e,t){const r=b();if(!v(r)||!Ve(r))return!1;const i=Ge(r),u=i.length;if(0===u&&r.isCollapsed())return e===F&&r.insertNodes([o()]),!0;if(0===u&&e===F&&"\n"===r.getTextContent()){const e=o(),t=s(),n=r.isBackward()?"previous":"next";return r.insertNodes([e,t]),I(j(R(W(e,"next",0),q(l(t,"next"))),n)),!0}for(let s=0;s<u;s++){const l=i[s];if(l.length>0){let i=l[0];if(0===s&&(i=se(i)),e===F){const e=o();if(i.insertBefore(e),0===s){const t=r.isBackward()?"focus":"anchor",n=K(i.getKey(),0,"text");r[t].is(n)&&r[t].set(e.getKey(),0,"text")}}else n(i)?i.remove():void 0!==t&&Be(i)&&he(i,t,r)}}return!0}function Xe(e,t){const i=b();if(!v(i))return!1;const{anchor:o,focus:s}=i,l=o.offset,u=s.offset,c=o.getNode(),a=s.getNode(),g=e===k;if(!Ve(i)||!Be(c)&&!n(c)||!Be(a)&&!n(a))return!1;if(!t.altKey){if(i.isCollapsed()){const e=c.getParentOrThrow();if(g&&0===l&&null===c.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),t.preventDefault(),!1}else if(!g&&l===c.getTextContentSize()&&null===c.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),t.preventDefault(),!1}}return!1}let h,f;if(c.isBefore(a)?(h=se(c),f=le(a)):(h=se(a),f=le(c)),null==h||null==f)return!1;const p=h.getNodesBetween(f);for(let e=0;e<p.length;e++){const t=p[e];if(!Be(t)&&!n(t)&&!r(t))return!1}t.preventDefault(),t.stopPropagation();const d=g?h.getPreviousSibling():f.getNextSibling();if(!r(d))return!0;const m=g?d.getPreviousSibling():d.getNextSibling();if(null==m)return!0;const x=Be(m)||n(m)||r(m)?g?se(m):le(m):null;let _=null!=x?x:m;return d.remove(),p.forEach(e=>e.remove()),e===k?(p.forEach(e=>_.insertBefore(e)),_.insertBefore(d)):(_.insertAfter(d),_=d,p.forEach(e=>{_.insertAfter(e),_=e})),i.setTextNodeRange(c,l,a,u),!0}function Ye(e,t){const i=b();if(!v(i))return!1;const{anchor:o,focus:s}=i,l=o.getNode(),u=s.getNode(),c=e===J;if(!Ve(i)||!Be(l)&&!n(l)||!Be(u)&&!n(u))return!1;const a=u,g="rtl"===ue(a)?!c:c,h=o.key,f=o.offset,p=o.type;if(g){const e=ce(a,s.offset);if(null!==e){const{node:t,offset:n}=e;r(t)?t.selectNext(0,0):i.setTextNodeRange(t,n,t,n)}else a.getParentOrThrow().selectStart()}else{ae(a).select()}return t.shiftKey&&i.anchor.set(h,f,p),t.preventDefault(),t.stopPropagation(),!0}function Ze(e,t,n){return w(...n?[e.registerCommand(H,e=>!e.altKey&&ne(ve),C),e.registerCommand(D,()=>ne(ve),C),e.registerCommand(k,e=>!e.altKey&&re(ve),C),e.registerCommand(B,()=>re(ve),C)]:[],e.registerCommand(L,t=>{const n=function(e){const t=b();if(!v(t)||!Ve(t))return null;const n=e?M:F,r=e?M:$,i=t.anchor,o=t.focus;if(i.is(o))return r;const s=Ge(t);if(1!==s.length)return n;const l=s[0];let u,c;0===l.length&&ie(285),t.isBackward()?(u=o,c=i):(u=i,c=o);const a=se(l[0]),g=le(l[0]),h=K(a.getKey(),0,"text"),f=K(g.getKey(),g.getTextContentSize(),"text");return u.isBefore(h)||f.isBefore(c)?n:h.isBefore(u)||c.isBefore(f)?r:n}(t.shiftKey);return null!==n&&(t.preventDefault(),e.dispatchCommand(n,void 0),!0)},C),e.registerCommand($,()=>!!Ve(b())&&(E([o()]),!0),C),e.registerCommand(F,()=>Qe(F),C),e.registerCommand(M,()=>Qe(M,t),C),e.registerCommand(k,e=>{const t=b();if(!v(t))return!1;const{anchor:n}=t,r=n.getNode();if(!Ve(t))return!1;const i=r.getParent();return t.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&ve(i)&&null===i.getPreviousSibling()?(e.preventDefault(),!0):Xe(k,e)},C),e.registerCommand(H,e=>{const t=b();if(!v(t))return!1;const{anchor:n}=t,r=n.getNode();return!!Ve(t)&&(t.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&ve(r.getParentOrThrow())&&null===r.getParentOrThrow().getNextSibling()?(e.preventDefault(),!0):Xe(H,e))},C),e.registerCommand(J,e=>Ye(J,e),C),e.registerCommand(z,e=>Ye(z,e),C))}const et=S({build:(e,t)=>G(t),config:P({disabled:!1,escapeWithArrows:!1,tabSize:void 0}),dependencies:[Le],name:"@lexical/code-indent",register:(e,t,n)=>{const r=n.getOutput();return V(()=>{if(!r.disabled.value)return Ze(e,r.tabSize.value,r.escapeWithArrows.value)})}});export{ke as $createCodeHighlightNode,be as $createCodeNode,ue as $getCodeLineDirection,ae as $getEndOfCodeInLine,se as $getFirstCodeNodeOfLine,le as $getLastCodeNodeOfLine,ce as $getStartOfCodeInLine,Be as $isCodeHighlightNode,ve as $isCodeNode,he as $outdentLeadingSpaces,ge as $plainifyCodeContent,Le as CodeExtension,He as CodeHighlightNode,Ue as CodeImportExtension,qe as CodeImportRules,et as CodeIndentExtension,ye as CodeNode,fe as DEFAULT_CODE_LANGUAGE,pe as getDefaultCodeLanguage,Ze as registerCodeIndentation};
9
+ import{getTextDirection as e,$isElementNode as t,$isTabNode as n,$isLineBreakNode as r,tokenizeRawText as i,$createTabNode as o,$createLineBreakNode as s,$getSiblingCaret as l,$create as u,ElementNode as c,addClassNamesToElement as a,setDOMStyleFromCSS as g,$getEditor as h,$isTextNode as f,$createParagraphNode as p,isHTMLElement as d,$applyNodeReplacement as m,TextNode as x,removeClassNamesFromElement as _,defineExtension as S,KEY_ENTER_COMMAND as y,$getSelection as b,$isRangeSelection as v,COMMAND_PRIORITY_LOW as C,configExtension as N,isDOMDocumentNode as T,isDOMTextNode as A,$generateNodesFromRawText as O,safeCast as P,mergeRegister as w,KEY_ARROW_DOWN_COMMAND as H,KEY_ARROW_RIGHT_COMMAND as D,KEY_ARROW_UP_COMMAND as k,KEY_ARROW_LEFT_COMMAND as B,KEY_TAB_COMMAND as L,INSERT_TAB_COMMAND as $,$insertNodes as E,INDENT_CONTENT_COMMAND as F,OUTDENT_CONTENT_COMMAND as M,MOVE_TO_START as J,MOVE_TO_END as z,$createPoint as K,$setSelectionFromCaretRange as I,$getCaretRangeInDirection as j,$getCaretRange as R,$getTextPointCaret as W,$normalizeCaret as q}from"lexical";import{getPeerDependencyFromEditor as U,effect as V,namedSignals as G}from"@lexical/extension";import{CoreImportExtension as Q,DOMImportExtension as X,defineImportRule as Y,sel as Z,ImportOverlays as ee,defineOverlayRules as te}from"@lexical/html";import{$onEscapeDown as ne,$onEscapeUp as re}from"@lexical/utils";function ie(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function oe(e,t){let r=e;for(let i=l(e,t);i&&(Be(i.origin)||n(i.origin));i=i.getAdjacentCaret())r=i.origin;return r}function se(e){return oe(e,"previous")}function le(e){return oe(e,"next")}function ue(n){const r=se(n),i=le(n);let o=r;for(;null!==o;){if(Be(o)){const t=e(o.getTextContent());if(null!==t)return t}if(o===i)break;o=o.getNextSibling()}const s=r.getParent();if(t(s)){const e=s.getDirection();if("ltr"===e||"rtl"===e)return e}return null}function ce(e,t){let i=null,o=null,s=e,l=t,u=e.getTextContent();for(;;){if(0===l){const e=s.getPreviousSibling();if(null===e){s=null;break}if(Be(e)||n(e)||r(e)||ie(167),s=e,r(s)){i={node:s,offset:1};break}l=Math.max(0,s.getTextContentSize()-1),u=s.getTextContent()}else l--;const e=u[l];Be(s)&&" "!==e&&(o={node:s,offset:l})}if(null!==o)return o;let c=null;if(t<e.getTextContentSize())Be(e)&&(c=e.getTextContent()[t]);else{const t=e.getNextSibling();Be(t)&&(c=t.getTextContent()[0])}if(null!==c&&" "!==c)return i;{const n=function(e,t){let n=e,i=t,o=e.getTextContent(),s=e.getTextContentSize();for(;;){if(!Be(n)||i===s){if(n=n.getNextSibling(),null===n||r(n))return null;Be(n)&&(i=0,o=n.getTextContent(),s=n.getTextContentSize())}if(Be(n)){if(" "!==o[i])return{node:n,offset:i};i++}}}(e,t);return null!==n?n:i}}function ae(e){const t=le(e);return r(t)&&ie(168),t}function ge(e){const t=[];return i(e,{linebreak:()=>t.push(s()),tab:()=>t.push(o()),text:e=>t.push(ke(e))}),t}function he(e,t,n){if(!Number.isInteger(t)||t<=0)return!1;const r=e.getTextContent(),i=/^ +/.exec(r);if(!i)return!1;const o=Math.min(t,i[0].length),s=e.getKey(),l=n.anchor.key===s&&"text"===n.anchor.type?n.anchor.offset:null,u=n.focus.key===s&&"text"===n.focus.type?n.focus.offset:null;return e.spliceText(0,o,""),null!==l&&n.anchor.set(s,Math.max(0,l-o),"text"),null!==u&&n.focus.set(s,Math.max(0,u-o),"text"),!0}const fe="javascript",pe=()=>fe;function de(e,t){for(const n of e.childNodes){if(d(n)&&n.tagName===t)return!0;if(de(n,t))return!0}return!1}const me="data-language",xe="data-highlight-language",_e="data-theme",Se=()=>{};class ye extends c{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(e){return new ye(e.__language,e.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){const t=document.createElement("code");a(t,e.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(me,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(xe,n));const r=this.getTheme();r&&t.setAttribute(_e,r);const i=this.getStyle();return i&&g(t.style,i),t}updateDOM(e,t,n){const r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(me,r):i&&t.removeAttribute(me);const o=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&t.setAttribute(xe,r):t.removeAttribute(xe):o&&r&&t.setAttribute(xe,r);const s=this.__theme,l=e.__theme;s?s!==l&&t.setAttribute(_e,s):l&&t.removeAttribute(_e);const u=this.__style,c=e.__style;return u!==c&&g(t.style,u,c),!1}exportDOM(e){const t=document.createElement("pre");a(t,e._config.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(me,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(xe,n));const r=this.getTheme();r&&t.setAttribute(_e,r);const i=this.getStyle();return i&&g(t.style,i),{element:t}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||de(e,"BR"))?{conversion:Ce,priority:1}:null,div:()=>({conversion:Ne,priority:1}),pre:()=>({conversion:Ce,priority:0}),table:e=>Pe(e)?{conversion:Te,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&Pe(n)?{conversion:Ae,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&Pe(t)?{conversion:Ae,priority:3}:null}}}static importJSON(e){return be().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,t=!0){if(!U(h(),"@lexical/code")){Se();const t=we(e);if(t)return t}const{anchor:r,focus:i}=e,l=(r.isBefore(i)?r:i).getNode();if(f(l)){let e=se(l);const t=[];for(;;)if(n(e))t.push(o()),e=e.getNextSibling();else{if(!Be(e))break;{let n=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&t.push(ke(" ".repeat(n))),n!==i)break;e=e.getNextSibling()}}const i=l.splitText(r.offset)[0],u=0===r.offset?0:1,c=i.getIndexWithinParent()+u,a=l.getParentOrThrow(),g=[s(),...t];a.splice(c,0,g);const h=t[t.length-1];h?h.select():0===r.offset?i.selectPrevious():i.getNextSibling().selectNext(0,0)}if(ve(l)){const{offset:t}=e.anchor;l.splice(t,0,[s()]),l.select(t+1,t+1)}return null}canIndent(){return!1}collapseAtStart(){const e=p();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}setLanguage(e){const t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){const t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){const t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}}function be(e,t){return u(ye).setLanguage(e).setTheme(t)}function ve(e){return e instanceof ye}function Ce(e){return{node:be(e.getAttribute(me))}}function Ne(e){const t=e,n=Oe(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if(Oe(t))return!0;t=t.parentElement}return!1}(t)?{node:n?be():null}:{node:null}}function Te(){return{node:be()}}function Ae(){return{node:null}}function Oe(e){return null!==e.style.fontFamily.match("monospace")}function Pe(e){return e.classList.contains("js-file-line-container")}function we(e){const{anchor:t}=e;if(e.isCollapsed()&&"element"===t.type){const e=t.getNode();if(ve(e)){const n=e.getChildrenSize();if(n>=2&&t.offset===n){const t=e.getLastChild();if(r(t)&&r(t.getPreviousSibling())){const t=p();return e.splice(n-2,2,[]).insertAfter(t,!1),t.select(),t}}}}return null}class He extends x{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(e){return new He(e.__text,e.__highlightType||void 0,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){const t=super.createDOM(e),n=De(e.theme,this.__highlightType);return a(t,n),t}updateDOM(e,t,n){const r=super.updateDOM(e,t,n),i=De(n.theme,e.__highlightType),o=De(n.theme,this.__highlightType);return i!==o&&(i&&_(t,i),o&&a(t,o)),r}static importJSON(e){return ke().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return be()}}function De(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function ke(e="",t){return m(new He(e,t))}function Be(e){return e instanceof He}const Le=S({name:"@lexical/code",nodes:()=>[ye,He],register:e=>e.registerCommand(y,e=>{const t=b();return!(!v(t)||!we(t))&&(e.preventDefault(),!0)},C)}),$e="data-language";function Ee(e){return null!==e.style.fontFamily.match("monospace")}function Fe(e){let t=e.parentElement;for(;null!==t;){if(Ee(t))return!0;t=t.parentElement}return!1}const Me=te([Y({$import:(e,t)=>e.$importChildren(t),match:Z.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),Je=Y({$import:(e,t)=>[be(t.getAttribute($e)).splice(0,0,e.$importChildren(t))],match:Z.tag("pre"),name:"@lexical/code/pre"}),ze=Y({$import:(e,t,n)=>{const r=t.textContent||"";return/\r?\n/.test(r)||null!==t.querySelector("br")?[be(t.getAttribute($e)).splice(0,0,e.$importChildren(t))]:n()},match:Z.tag("code"),name:"@lexical/code/code-multiline"});function Ke(e){if(!d(e))return!1;const t=e.style.fontFamily,n=e.style.whiteSpace;return"string"==typeof t&&/monospace/i.test(t)&&"string"==typeof n&&n.startsWith("pre")}function Ie(e){let t=!1;const n=[];let r="",i=!1;const o=()=>{i&&(n.push(r),r="",i=!1)};for(const s of Array.from(e.childNodes))if(d(s))"DIV"===s.tagName?(o(),n.push(s.textContent||""),t=!0):"BR"===s.tagName?(o(),n.push(""),t=!0):(r+=s.textContent||"",i=!0);else if(A(s)){const e=s.textContent||"";e.length>0&&(r+=e,i=!0)}return o(),t?n:null}function je(e){for(const t of Array.from(e.children)){if(d(t)&&Ke(t)){if(null!==Ie(t))return!0;const e=t.nextElementSibling;if(e&&Ke(e))return!0;continue}if(je(t))return!0}return!1}const Re=te([Y({$import:(e,t,n)=>{if(!Ke(t)||Fe(t))return n();const r=Ie(t);return null===r||0===r.length?n():[be().splice(0,0,O(r.join("\n")))]},match:Z.tag("div"),name:"@lexical/code/vscode-wrapper"}),Y({$import:(e,t,n)=>{if(!Ke(t)||Fe(t))return n();const r=t.previousElementSibling;if(r&&Ke(r))return[];const i=[];let o=t;for(;o&&Ke(o);)i.push("BR"===o.tagName?"":o.textContent||""),o=o.nextElementSibling;return i.length<2?n():[be().splice(0,0,O(i.join("\n")))]},match:Z.tag("div","br"),name:"@lexical/code/vscode-line-run"})]),We=Y({$import:(e,t,n)=>Ee(t)?[be().splice(0,0,e.$importChildren(t))]:Fe(t)?e.$importChildren(t):n(),match:Z.tag("div"),name:"@lexical/code/div"}),qe=[Y({$import:(e,t)=>[be().splice(0,0,e.$importChildren(t,{rules:Me}))],match:Z.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"}),Y({$import:(e,t)=>e.$importChildren(t),match:Z.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"}),ze,Je,We],Ue=S({dependencies:[Q,Le,N(X,{preprocess:[(e,t,n)=>{je(T(e)?e.body:e)&&t.session.update(ee,e=>[...e,Re]),n()}],rules:qe})],name:"@lexical/code/Import"});function Ve(e){if(!v(e))return!1;const t=e.anchor.getNode(),n=ve(t)?t:t.getParent(),r=e.focus.getNode(),i=ve(r)?r:r.getParent();return ve(n)&&n.is(i)}function Ge(e){const t=e.getNodes(),i=[];if(1===t.length&&ve(t[0]))return i;let o=[];for(let e=0;e<t.length;e++){const s=t[e];Be(s)||n(s)||r(s)||ie(169),r(s)?o.length>0&&(i.push(o),o=[]):o.push(s)}if(o.length>0){const t=e.isBackward()?e.anchor:e.focus,n=K(o[0].getKey(),0,"text");t.is(n)||i.push(o)}return i}function Qe(e,t){const r=b();if(!v(r)||!Ve(r))return!1;const i=Ge(r),u=i.length;if(0===u&&r.isCollapsed())return e===F&&r.insertNodes([o()]),!0;if(0===u&&e===F&&"\n"===r.getTextContent()){const e=o(),t=s(),n=r.isBackward()?"previous":"next";return r.insertNodes([e,t]),I(j(R(W(e,"next",0),q(l(t,"next"))),n)),!0}for(let s=0;s<u;s++){const l=i[s];if(l.length>0){let i=l[0];if(0===s&&(i=se(i)),e===F){const e=o();if(i.insertBefore(e),0===s){const t=r.isBackward()?"focus":"anchor",n=K(i.getKey(),0,"text");r[t].is(n)&&r[t].set(e.getKey(),0,"text")}}else n(i)?i.remove():void 0!==t&&Be(i)&&he(i,t,r)}}return!0}function Xe(e,t){const i=b();if(!v(i))return!1;const{anchor:o,focus:s}=i,l=o.offset,u=s.offset,c=o.getNode(),a=s.getNode(),g=e===k;if(!Ve(i)||!Be(c)&&!n(c)||!Be(a)&&!n(a))return!1;if(!t.altKey){if(i.isCollapsed()){const e=c.getParentOrThrow();if(g&&0===l&&null===c.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),t.preventDefault(),!1}else if(!g&&l===c.getTextContentSize()&&null===c.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),t.preventDefault(),!1}}return!1}let h,f;if(c.isBefore(a)?(h=se(c),f=le(a)):(h=se(a),f=le(c)),null==h||null==f)return!1;const p=h.getNodesBetween(f);for(let e=0;e<p.length;e++){const t=p[e];if(!Be(t)&&!n(t)&&!r(t))return!1}t.preventDefault(),t.stopPropagation();const d=g?h.getPreviousSibling():f.getNextSibling();if(!r(d))return!0;const m=g?d.getPreviousSibling():d.getNextSibling();if(null==m)return!0;const x=Be(m)||n(m)||r(m)?g?se(m):le(m):null;let _=null!=x?x:m;return d.remove(),p.forEach(e=>e.remove()),e===k?(p.forEach(e=>_.insertBefore(e)),_.insertBefore(d)):(_.insertAfter(d),_=d,p.forEach(e=>{_.insertAfter(e),_=e})),i.setTextNodeRange(c,l,a,u),!0}function Ye(e,t){const i=b();if(!v(i))return!1;const{anchor:o,focus:s}=i,l=o.getNode(),u=s.getNode(),c=e===J;if(!Ve(i)||!Be(l)&&!n(l)||!Be(u)&&!n(u))return!1;const a=u,g="rtl"===ue(a)?!c:c,h=o.key,f=o.offset,p=o.type;if(g){const e=ce(a,s.offset);if(null!==e){const{node:t,offset:n}=e;r(t)?t.selectNext(0,0):i.setTextNodeRange(t,n,t,n)}else a.getParentOrThrow().selectStart()}else{ae(a).select()}return t.shiftKey&&i.anchor.set(h,f,p),t.preventDefault(),t.stopPropagation(),!0}function Ze(e,t,n){return w(...n?[e.registerCommand(H,e=>!e.altKey&&ne(ve),C),e.registerCommand(D,()=>ne(ve),C),e.registerCommand(k,e=>!e.altKey&&re(ve),C),e.registerCommand(B,()=>re(ve),C)]:[],e.registerCommand(L,t=>{const n=function(e){const t=b();if(!v(t)||!Ve(t))return null;const n=e?M:F,r=e?M:$,i=t.anchor,o=t.focus;if(i.is(o))return r;const s=Ge(t);if(1!==s.length)return n;const l=s[0];let u,c;0===l.length&&ie(285),t.isBackward()?(u=o,c=i):(u=i,c=o);const a=se(l[0]),g=le(l[0]),h=K(a.getKey(),0,"text"),f=K(g.getKey(),g.getTextContentSize(),"text");return u.isBefore(h)||f.isBefore(c)?n:h.isBefore(u)||c.isBefore(f)?r:n}(t.shiftKey);return null!==n&&(t.preventDefault(),e.dispatchCommand(n,void 0),!0)},C),e.registerCommand($,()=>!!Ve(b())&&(E([o()]),!0),C),e.registerCommand(F,()=>Qe(F),C),e.registerCommand(M,()=>Qe(M,t),C),e.registerCommand(k,e=>{const t=b();if(!v(t))return!1;const{anchor:n}=t,r=n.getNode();if(!Ve(t))return!1;const i=r.getParent();return t.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&ve(i)&&null===i.getPreviousSibling()?(e.preventDefault(),!0):Xe(k,e)},C),e.registerCommand(H,e=>{const t=b();if(!v(t))return!1;const{anchor:n}=t,r=n.getNode();return!!Ve(t)&&(t.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&ve(r.getParentOrThrow())&&null===r.getParentOrThrow().getNextSibling()?(e.preventDefault(),!0):Xe(H,e))},C),e.registerCommand(J,e=>Ye(J,e),C),e.registerCommand(z,e=>Ye(z,e),C))}const et=S({build:(e,t)=>G(t),config:P({disabled:!1,escapeWithArrows:!1,tabSize:void 0}),dependencies:[Le],name:"@lexical/code-indent",register:(e,t,n)=>{const r=n.getOutput();return V(()=>{if(!r.disabled.value)return Ze(e,r.tabSize.value,r.escapeWithArrows.value)})}});export{ke as $createCodeHighlightNode,be as $createCodeNode,ue as $getCodeLineDirection,ae as $getEndOfCodeInLine,se as $getFirstCodeNodeOfLine,le as $getLastCodeNodeOfLine,ce as $getStartOfCodeInLine,Be as $isCodeHighlightNode,ve as $isCodeNode,he as $outdentLeadingSpaces,ge as $plainifyCodeContent,Le as CodeExtension,He as CodeHighlightNode,Ue as CodeImportExtension,qe as CodeImportRules,et as CodeIndentExtension,ye as CodeNode,fe as DEFAULT_CODE_LANGUAGE,pe as getDefaultCodeLanguage,Ze as registerCodeIndentation};
package/package.json CHANGED
@@ -8,15 +8,15 @@
8
8
  "code"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.45.1-nightly.20260609.0",
11
+ "version": "0.45.1-nightly.20260610.0",
12
12
  "main": "./dist/LexicalCodeCore.js",
13
13
  "types": "./dist/typescript-too-old.d.ts",
14
14
  "dependencies": {
15
- "@lexical/extension": "0.45.1-nightly.20260609.0",
16
- "@lexical/internal": "0.45.1-nightly.20260609.0",
17
- "@lexical/utils": "0.45.1-nightly.20260609.0",
18
- "lexical": "0.45.1-nightly.20260609.0",
19
- "@lexical/html": "0.45.1-nightly.20260609.0"
15
+ "@lexical/extension": "0.45.1-nightly.20260610.0",
16
+ "@lexical/html": "0.45.1-nightly.20260610.0",
17
+ "@lexical/utils": "0.45.1-nightly.20260610.0",
18
+ "lexical": "0.45.1-nightly.20260610.0",
19
+ "@lexical/internal": "0.45.1-nightly.20260610.0"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -122,16 +122,20 @@ export function $getStartOfCodeInLine(
122
122
 
123
123
  while (true) {
124
124
  if (nodeOffset === 0) {
125
- node = node.getPreviousSibling();
126
- if (node === null) {
125
+ // Annotation breaks a circular inference through the loop (TS7022),
126
+ // remove when the deprecated generic signatures from #8661 are removed
127
+ const prevSibling: LexicalNode | null = node.getPreviousSibling();
128
+ if (prevSibling === null) {
129
+ node = null;
127
130
  break;
128
131
  }
129
132
  invariant(
130
- $isCodeHighlightNode(node) ||
131
- $isTabNode(node) ||
132
- $isLineBreakNode(node),
133
+ $isCodeHighlightNode(prevSibling) ||
134
+ $isTabNode(prevSibling) ||
135
+ $isLineBreakNode(prevSibling),
133
136
  'Expected a valid Code Node: CodeHighlightNode, TabNode, LineBreakNode',
134
137
  );
138
+ node = prevSibling;
135
139
  if ($isLineBreakNode(node)) {
136
140
  last = {
137
141
  node,