@lexical/code-core 0.52.1-nightly.20261002.0 → 0.52.1-nightly.20261006.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.
@@ -9,13 +9,3 @@
9
9
  * Add code blocks to the editor (syntax highlighting provided separately)
10
10
  */
11
11
  export declare const CodeExtension: import("lexical").LexicalExtension<import("lexical").ExtensionConfigBase, "@lexical/code", unknown, unknown>;
12
- /**
13
- * Bundles {@link CodeImportRules} together with the runtime
14
- * {@link CodeExtension}.
15
- *
16
- * @experimental
17
- * @deprecated {@link CodeExtension} now registers
18
- * {@link CodeImportRules} (and `CoreImportExtension`) itself — depend on
19
- * it directly instead.
20
- */
21
- export declare const CodeImportExtension: import("lexical").LexicalExtension<import("lexical").ExtensionConfigBase, "@lexical/code/Import", unknown, unknown>;
@@ -1357,20 +1357,6 @@ const CodeExtension = {
1357
1357
  }
1358
1358
  };
1359
1359
 
1360
- /**
1361
- * Bundles {@link CodeImportRules} together with the runtime
1362
- * {@link CodeExtension}.
1363
- *
1364
- * @experimental
1365
- * @deprecated {@link CodeExtension} now registers
1366
- * {@link CodeImportRules} (and `CoreImportExtension`) itself — depend on
1367
- * it directly instead.
1368
- */
1369
- const CodeImportExtension = {
1370
- dependencies: [CodeExtension],
1371
- name: '@lexical/code/Import'
1372
- };
1373
-
1374
1360
  /**
1375
1361
  * Copyright (c) Meta Platforms, Inc. and affiliates.
1376
1362
  *
@@ -1920,4 +1906,4 @@ const CodeIndentExtension = {
1920
1906
  }
1921
1907
  };
1922
1908
 
1923
- export { $createCodeHighlightNode, $createCodeNode, $getCodeLineDirection, $getEndOfCodeInLine, $getFirstCodeNodeOfLine, $getLastCodeNodeOfLine, $getStartOfCodeInLine, $isCodeHighlightNode, $isCodeNode, $outdentLeadingSpaces, $plainifyCodeContent, CodeExtension, CodeHighlightNode, CodeImportExtension, CodeImportRules, CodeIndentExtension, CodeNode, DEFAULT_CODE_LANGUAGE, getDefaultCodeLanguage, registerCodeGutter, registerCodeIndentation };
1909
+ export { $createCodeHighlightNode, $createCodeNode, $getCodeLineDirection, $getEndOfCodeInLine, $getFirstCodeNodeOfLine, $getLastCodeNodeOfLine, $getStartOfCodeInLine, $isCodeHighlightNode, $isCodeNode, $outdentLeadingSpaces, $plainifyCodeContent, CodeExtension, CodeHighlightNode, CodeImportRules, CodeIndentExtension, CodeNode, DEFAULT_CODE_LANGUAGE, getDefaultCodeLanguage, registerCodeGutter, registerCodeIndentation };
@@ -22,7 +22,6 @@ export const $outdentLeadingSpaces = mod.$outdentLeadingSpaces;
22
22
  export const $plainifyCodeContent = mod.$plainifyCodeContent;
23
23
  export const CodeExtension = mod.CodeExtension;
24
24
  export const CodeHighlightNode = mod.CodeHighlightNode;
25
- export const CodeImportExtension = mod.CodeImportExtension;
26
25
  export const CodeImportRules = mod.CodeImportRules;
27
26
  export const CodeIndentExtension = mod.CodeIndentExtension;
28
27
  export const CodeNode = mod.CodeNode;
@@ -6,5 +6,5 @@
6
6
  *
7
7
  */
8
8
 
9
- import{sel as t,ImportOverlays as e,$isBlockLevel as n,defineOverlayRules as r,CoreImportExtension as i,DOMImportExtension as o}from"@lexical/html";import{getTextDirection as s,$isElementNode as l,$isTabNode as u,$isLineBreakNode as c,tokenizeRawText as a,$createTabNode as g,$createLineBreakNode as f,$getSiblingCaret as h,getterTableOf as d,setterTableOf as p,setterDefaultOf as m,aliasTableOf as _,$create as x,ElementNode as y,$getDocument as S,addClassNamesToElement as b,setDOMStyleFromCSS as v,$getEditor as C,$isTextNode as T,$createParagraphNode as N,nodeSchema as A,withAccessors as P,optional as w,stringValue as F,nullable as O,isHTMLElement as D,$applyNodeReplacement as E,TextNode as L,removeClassNamesFromElement as $,isDOMDocumentNode as B,isDOMTextNode as H,mergeRegister as k,KEY_ENTER_COMMAND as z,$getSelection as M,$isRangeSelection as K,COMMAND_PRIORITY_LOW as I,TabNode as j,$getNodeByKey as R,KEY_ARROW_DOWN_COMMAND as W,KEY_ARROW_RIGHT_COMMAND as J,KEY_ARROW_UP_COMMAND as q,KEY_ARROW_LEFT_COMMAND as U,KEY_TAB_COMMAND as V,INSERT_TAB_COMMAND as G,$insertNodes as Q,INDENT_CONTENT_COMMAND as X,OUTDENT_CONTENT_COMMAND as Y,MOVE_TO_START as Z,MOVE_TO_END as tt,$createPoint as et,$setSelectionFromCaretRange as nt,$getCaretRangeInDirection as rt,$getCaretRange as it,$getTextPointCaret as ot,$normalizeCaret as st}from"lexical";import{getPeerDependencyFromEditor as lt}from"@lexical/extension/getPeerDependencyFromEditor";import{effect as ut}from"@lexical/extension/signals";import{namedSignals as ct}from"@lexical/extension/namedSignals";import{$onEscapeDown as at,$onEscapeUp as gt}from"@lexical/utils";
10
- /*@__INLINE__*/function ft(t){return()=>{}}function ht(t,...e){throw function(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);return n.search=r.toString(),new 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.`)}(t,...e)}function dt(t,e){let n=t;for(let r=h(t,e);r&&(Gt(r.origin)||u(r.origin));r=r.getAdjacentCaret())n=r.origin;return n}function pt(t){return dt(t,"previous")}function mt(t){return dt(t,"next")}function _t(t){const e=pt(t),n=mt(t);let r=e;for(;null!==r;){if(Gt(r)){const t=s(r.getTextContent());if(null!==t)return t}if(r===n)break;r=r.getNextSibling()}const i=e.getParent();if(l(i)){const t=i.getDirection();if("ltr"===t||"rtl"===t)return t}return null}function xt(t,e){let n=null,r=null,i=t,o=e,s=t.getTextContent();for(;;){if(0===o){const t=i.getPreviousSibling();if(null===t){i=null;break}if(Gt(t)||u(t)||c(t)||ht(167),i=t,c(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent()}else o--;const t=s[o];Gt(i)&&" "!==t&&(r={node:i,offset:o})}if(null!==r)return r;let l=null;if(e<t.getTextContentSize())Gt(t)&&(l=t.getTextContent()[e]);else{const e=t.getNextSibling();Gt(e)&&(l=e.getTextContent()[0])}if(null!==l&&" "!==l)return n;{const r=function(t,e){let n=t,r=e,i=t.getTextContent(),o=t.getTextContentSize();for(;;){if(!Gt(n)||r===o){if(n=n.getNextSibling(),null===n||c(n))return null;Gt(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize())}if(Gt(n)){if(" "!==i[r])return{node:n,offset:r};r++}}}(t,e);return null!==r?r:n}}function yt(t){const e=mt(t);return c(e)&&ht(168),e}function St(t){const e=[];return a(t,{linebreak:()=>e.push(f()),tab:()=>e.push(g()),text:t=>e.push(Vt(t))}),e}function bt(t,e,n){if(!Number.isInteger(e)||e<=0)return!1;const r=t.getTextContent(),i=/^ +/.exec(r);if(!i)return!1;const o=Math.min(e,i[0].length),s=t.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 t.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 vt=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function Ct(t,e){if("number"==typeof t)return Number.isFinite(t)?t:e;if("string"!=typeof t||!vt.test(t))return e;const n=Number(t);return Number.isFinite(n)?n:e}const Tt=t=>{const e=d(t,"format"),n=p(t,"format"),r=m(t,"format");return{exportJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles();return{children:[],language:t.__language,theme:t.__theme,direction:t.__dir,format:e[t.__format],indent:t.__indent,textFormat:0!==n&&i?n:void 0,textStyle:""!==r&&i?r:void 0,type:t.__type,version:1}},exportCompactJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles(),o={type:t.__type,children:[]},s=t.__language;void 0!==s&&(o.language=s);const l=t.__theme;void 0!==l&&(o.theme=l);const u=t.__dir;null!=u&&(o.direction=u);const c=e[t.__format];void 0!==c&&""!==c&&(o.format=c);const a=t.__indent;return void 0!==a&&0!==a&&(o.indent=a),void 0!==n&&0!==n&&i&&(o.textFormat=n),void 0!==r&&""!==r&&i&&(o.textStyle=r),o},updateFromJSON:function(t,e){const i=e.direction;t.__dir=null===i||"ltr"===i||"rtl"===i?i:null;const o=e.format;t.__format="string"==typeof o&&o in n?n[o]:r,t.__indent=function(t){const e=Ct(t,0);return e>=0&&e<=Infinity&&Number.isInteger(e)?e:0}(e.indent),t.__textFormat=Ct(e.textFormat,0);const s=e.textStyle;t.__textStyle="string"==typeof s?s:"";const l=e.language;t.setLanguage(null==l||"string"==typeof l?l:"");const u=e.theme;return t.setTheme(void 0===u?void 0:"string"==typeof u?u:""),t}}};function Nt(t,e){t.__highlightType=e.__highlightType}const At=t=>{const e=d(t,"mode"),n=_(t,"detail",0),r=_(t,"format",0),i=p(t,"mode"),o=m(t,"mode");return{exportJSON:function(t){return{highlightType:t.__highlightType,detail:t.__detail,format:t.__format,mode:e[t.__mode],style:t.__style,text:t.__text,type:t.__type,version:1}},exportCompactJSON:function(t){const n={type:t.__type},r=t.__highlightType;void 0!==r&&(n.highlightType=r);const i=t.__detail;void 0!==i&&0!==i&&(n.detail=i);const o=t.__format;void 0!==o&&0!==o&&(n.format=o);const s=e[t.__mode];void 0!==s&&"normal"!==s&&(n.mode=s);const l=t.__style;void 0!==l&&""!==l&&(n.style=l);const u=t.__text;return void 0!==u&&""!==u&&(n.text=u),n},updateFromJSON:function(t,e){const s=e.detail;t.__detail="string"==typeof s&&s in n?n[s]:Ct(s,0);const l=e.format;t.setFormat("string"==typeof l&&l in r?r[l]:Ct(l,0));const u=e.mode;t.__mode="string"==typeof u&&u in i?i[u]:o;const c=e.style;t.__style="string"==typeof c?c:"";const a=e.text;t.__text="string"==typeof a?a:"";const g=e.highlightType;return t.setHighlightType(null==g||"string"==typeof g?g:""),t},afterCloneFrom:Nt}},Pt=/* @__PURE__ */A()({language:/* @__PURE__ */P(/* @__PURE__ */w(/* @__PURE__ */O(/* @__PURE__ */F())),{getter:{field:"__language"}}),theme:/* @__PURE__ */P(/* @__PURE__ */w(/* @__PURE__ */F()),{getter:{field:"__theme"}})}),wt="javascript",Ft=()=>wt;function Ot(t,e){for(const n of t.childNodes){if(D(n)&&n.tagName===e)return!0;if(Ot(n,e))return!0}return!1}const Dt="data-language",Et="data-highlight-language",Lt="data-theme",$t=/* @__PURE__ */ft();class Bt extends y{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:y,generated:Tt,importDOM:{code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||Ot(t,"BR"))?{conversion:zt,priority:1}:null,div:()=>({conversion:Mt,priority:1}),pre:()=>({conversion:zt,priority:0}),table:t=>Rt(t)?{conversion:Kt,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&Rt(n)?{conversion:It,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&Rt(e)?{conversion:It,priority:3}:null}},json:Pt})}constructor(t=void 0,e){super(e),this.__language=t||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(t){super.afterCloneFrom(t),function(t,e){t.__language=e.__language,t.__theme=e.__theme}(this,t),this.__isSyntaxHighlightSupported=t.__isSyntaxHighlightSupported}createDOM(t){const e=S().createElement("code");b(e,t.theme.code),e.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(e.setAttribute(Dt,n),this.getIsSyntaxHighlightSupported()&&e.setAttribute(Et,n));const r=this.getTheme();r&&e.setAttribute(Lt,r);const i=this.getStyle();return i&&v(e.style,i),e}updateDOM(t,e,n){const r=this.__language,i=t.__language;r?r!==i&&e.setAttribute(Dt,r):i&&e.removeAttribute(Dt);const o=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&e.setAttribute(Et,r):e.removeAttribute(Et):o&&r&&e.setAttribute(Et,r);const s=this.__theme,l=t.__theme;s?s!==l&&e.setAttribute(Lt,s):l&&e.removeAttribute(Lt);const u=this.__style,c=t.__style;return u!==c&&v(e.style,u,c),!1}exportDOM(t){const e=S().createElement("pre");b(e,t._config.theme.code),e.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(e.setAttribute(Dt,n),this.getIsSyntaxHighlightSupported()&&e.setAttribute(Et,n));const r=this.getTheme();r&&e.setAttribute(Lt,r);const i=this.getStyle();return i&&v(e.style,i),{element:e}}insertNewAfter(t,e=!0){if(!lt(C(),"@lexical/code")){$t();const e=Wt(t);if(e)return e}const{anchor:n,focus:r}=t,i=(n.isBefore(r)?n:r).getNode();if(T(i)){let t=pt(i);const e=[];for(;;)if(u(t))e.push(g()),t=t.getNextSibling();else{if(!Gt(t))break;{let n=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&e.push(Vt(" ".repeat(n))),n!==i)break;t=t.getNextSibling()}}const r=i.splitText(n.offset)[0],o=0===n.offset?0:1,s=r.getIndexWithinParent()+o,l=i.getParentOrThrow(),c=[f(),...e];l.splice(s,0,c);const a=e[e.length-1];a?a.select():0===n.offset?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(kt(i)){const{offset:e}=t.anchor;i.splice(e,0,[f()]),i.select(e+1,e+1)}return null}canIndent(){return!1}collapseAtStart(){const t=N();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 Ht(t,e){return x(Bt).setLanguage(t).setTheme(e)}function kt(t){return t instanceof Bt}function zt(t){return{node:Ht(t.getAttribute(Dt),t.getAttribute(Lt))}}function Mt(t){const e=t,n=jt(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(jt(e))return!0;e=e.parentElement}return!1}(e)?{node:n?Ht():null}:{node:null}}function Kt(){return{node:Ht()}}function It(){return{node:null}}function jt(t){return null!==t.style.fontFamily.match("monospace")}function Rt(t){return t.classList.contains("js-file-line-container")}function Wt(t){const{anchor:e}=t;if(t.isCollapsed()&&"element"===e.type){const t=e.getNode();if(kt(t)){const n=t.getChildrenSize();if(n>=2&&e.offset===n){const e=t.getLastChild();if(c(e)&&c(e.getPreviousSibling())){const e=N();return t.splice(n-2,2,[]).insertAfter(e,!1),e.select(),e}}}}return null}const Jt=/* @__PURE__ */A()({highlightType:/* @__PURE__ */P(/* @__PURE__ */w(/* @__PURE__ */O(/* @__PURE__ */F())),{getter:{field:"__highlightType"}})});class qt extends L{__highlightType;constructor(t="",e,n){super(t,n),this.__highlightType=e}$config(){return this.config("code-highlight",{extends:L,generated:At,json:Jt})}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(t){const e=this.getWritable();return e.__highlightType=t||void 0,e}canHaveFormat(){return!1}createDOM(t){const e=super.createDOM(t),n=Ut(t.theme,this.__highlightType);return b(e,n),e}updateDOM(t,e,n){const r=super.updateDOM(t,e,n),i=Ut(n.theme,t.__highlightType),o=Ut(n.theme,this.__highlightType);return i!==o&&(i&&$(e,i),o&&b(e,o)),r}setFormat(t){return this}isParentRequired(){return!0}createParentElementNode(){return Ht()}}function Ut(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function Vt(t="",e){return E(new qt(t,e))}function Gt(t){return t instanceof qt}const Qt="data-language",Xt="data-theme";function Yt(t){const e=[];let r=!1;for(let i=0;i<t.length;i++){const o=t[i],s=n(o);i>0&&(s||r)&&e.push("\n"),e.push(o.getTextContent()),r=s}return St(e.join(""))}function Zt(t){return null!==t.style.fontFamily.match("monospace")}function te(t){let e=t.parentElement;for(;null!==e;){if(Zt(e))return!0;e=e.parentElement}return!1}const ee=/* @__PURE__ */r([{$import:(t,e)=>t.$importChildren(e),match:/* @__PURE__ */t.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"}]),ne={$import:(t,e)=>[Ht(e.getAttribute(Qt),e.getAttribute(Xt)).splice(0,0,Yt(t.$importChildren(e)))],match:/* @__PURE__ */t.tag("pre"),name:"@lexical/code/pre"},re={$import:(t,e,n)=>{const r=e.textContent||"";return/\r?\n/.test(r)||null!==e.querySelector("br")?[Ht(e.getAttribute(Qt),e.getAttribute(Xt)).splice(0,0,Yt(t.$importChildren(e)))]:n()},match:/* @__PURE__ */t.tag("code"),name:"@lexical/code/code-multiline"};function ie(t){if(!D(t))return!1;const e=t.style.fontFamily,n=t.style.whiteSpace;return"string"==typeof e&&/monospace/i.test(e)&&"string"==typeof n&&n.startsWith("pre")}function oe(t){let e=!1;const n=[];let r="",i=!1;const o=()=>{i&&(n.push(r),r="",i=!1)};for(const s of Array.from(t.childNodes))if(D(s))"DIV"===s.tagName?(o(),n.push(s.textContent||""),e=!0):"BR"===s.tagName?(o(),n.push(""),e=!0):(r+=s.textContent||"",i=!0);else if(H(s)){const t=s.textContent||"";t.length>0&&(r+=t,i=!0)}return o(),e?n:null}function se(t){for(const e of Array.from(t.children)){if(D(e)&&ie(e)){if(null!==oe(e))return!0;const t=e.nextElementSibling;if(t&&ie(t))return!0;continue}if(se(e))return!0}return!1}const le=/* @__PURE__ */r([{$import:(t,e,n)=>{if(!ie(e)||te(e))return n();const r=oe(e);return null===r||0===r.length?n():[Ht().splice(0,0,St(r.join("\n")))]},match:/* @__PURE__ */t.tag("div"),name:"@lexical/code/vscode-wrapper"},{$import:(t,e,n)=>{if(!ie(e)||te(e))return n();const r=e.previousElementSibling;if(r&&ie(r))return[];const i=[];let o=e;for(;o&&ie(o);)i.push("BR"===o.tagName?"":o.textContent||""),o=o.nextElementSibling;return i.length<2?n():[Ht().splice(0,0,St(i.join("\n")))]},match:/* @__PURE__ */t.tag("div","br"),name:"@lexical/code/vscode-line-run"}]),ue={$import:(t,e,n)=>Zt(e)?[Ht().splice(0,0,Yt(t.$importChildren(e)))]:n(),match:/* @__PURE__ */t.tag("div"),name:"@lexical/code/div"},ce=[{$import:(t,e)=>[Ht().splice(0,0,Yt(t.$importChildren(e,{rules:ee})))],match:/* @__PURE__ */t.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"},{$import:(t,e)=>t.$importChildren(e),match:/* @__PURE__ */t.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"},re,ne,ue],ae={dependencies:[i,[o,{preprocess:[(t,n,r)=>{se(B(t)?t.body:t)&&n.session.update(e,t=>[...t,le]),r()}],rules:ce}]],name:"@lexical/code",nodes:()=>[Bt,qt],register:t=>k(t.registerCommand(z,t=>{const e=M();return!(!K(e)||!Wt(e)||(null!==t&&t.preventDefault(),0))},I),t.registerNodeTransform(j,t=>{0!==t.getFormat()&&kt(t.getParent())&&t.setFormat(0)}))},ge={dependencies:[ae],name:"@lexical/code/Import"};function fe(t){const e=C().getElementByKey(t.getKey());if(null===e)return;const n=t.getChildren(),r=n.length;if(r===e.__cachedChildrenLength)return;e.__cachedChildrenLength=r;let i="1",o=1;for(let t=0;t<r;t++)c(n[t])&&(i+="\n"+ ++o);e.setAttribute("data-gutter",i)}function he(t){return t._headless?()=>{}:t.registerMutationListener(Bt,e=>{t.read("latest",()=>{for(const[t,n]of e)if("destroyed"!==n){const e=R(t);null!==e&&fe(e)}})},{skipInitialization:!1})}function de(t){if(!K(t))return!1;const e=t.anchor.getNode(),n=kt(e)?e:e.getParent(),r=t.focus.getNode(),i=kt(r)?r:r.getParent();return kt(n)&&n.is(i)}function pe(t){const e=t.getNodes(),n=[];if(1===e.length&&kt(e[0]))return n;let r=[];for(let t=0;t<e.length;t++){const i=e[t];Gt(i)||u(i)||c(i)||ht(169),c(i)?r.length>0&&(n.push(r),r=[]):r.push(i)}if(r.length>0){const e=t.isBackward()?t.anchor:t.focus,i=et(r[0].getKey(),0,"text");e.is(i)||n.push(r)}return n}function me(t,e){const n=M();if(!K(n)||!de(n))return!1;const r=pe(n),i=r.length;if(0===i&&n.isCollapsed())return t===X?n.insertNodes([g()]):function(t,e){const n=t.anchor.getNode();if(!Gt(n)&&!u(n))return;const r=pt(n);u(r)?r.remove():void 0!==e&&Gt(r)&&bt(r,e,t)}(n,e),!0;if(0===i&&t===X&&"\n"===n.getTextContent()){const t=g(),e=f(),r=n.isBackward()?"previous":"next";return n.insertNodes([t,e]),nt(rt(it(ot(t,"next",0),st(h(e,"next"))),r)),!0}for(let o=0;o<i;o++){const i=r[o];if(i.length>0){let r=i[0];if(0===o&&(r=pt(r)),t===X){const t=g();if(r.insertBefore(t),0===o){const e=n.isBackward()?"focus":"anchor",i=et(r.getKey(),0,"text");n[e].is(i)&&n[e].set(t.getKey(),0,"text")}}else u(r)?r.remove():void 0!==e&&Gt(r)&&bt(r,e,n)}}return!0}function _e(t,e){const n=M();if(!K(n))return!1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,l=r.getNode(),a=i.getNode(),g=t===q;if(!de(n)||!Gt(l)&&!u(l)||!Gt(a)&&!u(a))return!1;if(!e.altKey){if(n.isCollapsed()){const t=l.getParentOrThrow();if(g&&0===o&&null===l.getPreviousSibling()){if(null===t.getPreviousSibling())return t.selectPrevious(),e.preventDefault(),!1}else if(!g&&o===l.getTextContentSize()&&null===l.getNextSibling()&&null===t.getNextSibling())return t.selectNext(),e.preventDefault(),!1}return!1}let f,h;if(l.isBefore(a)?(f=pt(l),h=mt(a)):(f=pt(a),h=mt(l)),null==f||null==h)return!1;const d=f.getNodesBetween(h);for(let t=0;t<d.length;t++){const e=d[t];if(!Gt(e)&&!u(e)&&!c(e))return!1}e.preventDefault(),e.stopPropagation();const p=g?f.getPreviousSibling():h.getNextSibling();if(!c(p))return!0;const m=g?p.getPreviousSibling():p.getNextSibling();if(null==m)return!0;const _=c(m),x=_||!Gt(m)&&!u(m)?null:g?pt(m):mt(m);let y=null!=x?x:m;return p.remove(),d.forEach(t=>t.remove()),_?(d.forEach(t=>{y.insertAfter(t),y=t}),y.insertAfter(p)):t===q?(d.forEach(t=>y.insertBefore(t)),y.insertBefore(p)):(y.insertAfter(p),y=p,d.forEach(t=>{y.insertAfter(t),y=t})),n.setTextNodeRange(l,o,a,s),!0}function xe(t,e){const n=M();if(!K(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),l=t===Z;if(!de(n)||!Gt(o)&&!u(o)||!Gt(s)&&!u(s))return!1;const a=s,g="rtl"===_t(a)?!l:l,f=r.key,h=r.offset,d=r.type;if(g){const t=xt(a,i.offset);if(null!==t){const{node:e,offset:r}=t;c(e)?e.selectNext(0,0):n.setTextNodeRange(e,r,e,r)}else a.getParentOrThrow().selectStart()}else yt(a).select();return e.shiftKey&&n.anchor.set(f,h,d),e.preventDefault(),e.stopPropagation(),!0}function ye(t,e,n){return k(...n?[t.registerCommand(W,t=>!t.altKey&&at(kt,t),I),t.registerCommand(J,t=>at(kt,t),I),t.registerCommand(q,t=>!t.altKey&&gt(kt,t),I),t.registerCommand(U,t=>gt(kt,t),I)]:[],t.registerCommand(V,e=>{const n=function(t){const e=M();if(!K(e)||!de(e))return null;const n=t?Y:X,r=t?Y:G,i=e.anchor,o=e.focus;if(i.is(o))return r;const s=pe(e);if(1!==s.length)return n;const l=s[0];let u,c;0===l.length&&ht(285),e.isBackward()?(u=o,c=i):(u=i,c=o);const a=pt(l[0]),g=mt(l[0]),f=et(a.getKey(),0,"text"),h=et(g.getKey(),g.getTextContentSize(),"text");return u.isBefore(f)||h.isBefore(c)?n:f.isBefore(u)||c.isBefore(h)?r:n}(e.shiftKey);return null!==n&&(e.preventDefault(),t.dispatchCommand(n),!0)},I),t.registerCommand(G,()=>!!de(M())&&(Q([g()]),!0),I),t.registerCommand(X,()=>me(X),I),t.registerCommand(Y,()=>me(Y,e),I),t.registerCommand(q,t=>{const e=M();if(!K(e))return!1;const{anchor:n}=e,r=n.getNode();if(!de(e))return!1;const i=r.getParent();return e.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&kt(i)&&null===i.getPreviousSibling()?(t.preventDefault(),!0):_e(q,t)},I),t.registerCommand(W,t=>{const e=M();if(!K(e))return!1;const{anchor:n}=e,r=n.getNode();return!!de(e)&&(e.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&kt(r.getParentOrThrow())&&null===r.getParentOrThrow().getNextSibling()?(t.preventDefault(),!0):_e(W,t))},I),t.registerCommand(Z,t=>xe(Z,t),I),t.registerCommand(tt,t=>xe(tt,t),I))}const Se={build:(t,e)=>ct(e),config:{disabled:!1,escapeWithArrows:!1,tabSize:void 0},dependencies:[ae],name:"@lexical/code-indent",register:(t,e,n)=>{const r=n.getOutput();return ut(()=>{if(!r.disabled.value)return ye(t,r.tabSize.value,r.escapeWithArrows.value)})}};export{Vt as $createCodeHighlightNode,Ht as $createCodeNode,_t as $getCodeLineDirection,yt as $getEndOfCodeInLine,pt as $getFirstCodeNodeOfLine,mt as $getLastCodeNodeOfLine,xt as $getStartOfCodeInLine,Gt as $isCodeHighlightNode,kt as $isCodeNode,bt as $outdentLeadingSpaces,St as $plainifyCodeContent,ae as CodeExtension,qt as CodeHighlightNode,ge as CodeImportExtension,ce as CodeImportRules,Se as CodeIndentExtension,Bt as CodeNode,wt as DEFAULT_CODE_LANGUAGE,Ft as getDefaultCodeLanguage,he as registerCodeGutter,ye as registerCodeIndentation};
9
+ import{sel as t,ImportOverlays as e,$isBlockLevel as n,defineOverlayRules as r,CoreImportExtension as i,DOMImportExtension as o}from"@lexical/html";import{getTextDirection as s,$isElementNode as l,$isTabNode as u,$isLineBreakNode as c,tokenizeRawText as a,$createTabNode as g,$createLineBreakNode as f,$getSiblingCaret as h,getterTableOf as d,setterTableOf as p,setterDefaultOf as m,aliasTableOf as _,$create as x,ElementNode as y,$getDocument as S,addClassNamesToElement as b,setDOMStyleFromCSS as v,$getEditor as C,$isTextNode as T,$createParagraphNode as N,nodeSchema as A,withAccessors as P,optional as w,stringValue as F,nullable as O,isHTMLElement as D,$applyNodeReplacement as E,TextNode as L,removeClassNamesFromElement as $,isDOMDocumentNode as B,isDOMTextNode as H,mergeRegister as k,KEY_ENTER_COMMAND as z,$getSelection as M,$isRangeSelection as K,COMMAND_PRIORITY_LOW as j,TabNode as I,$getNodeByKey as R,KEY_ARROW_DOWN_COMMAND as W,KEY_ARROW_RIGHT_COMMAND as J,KEY_ARROW_UP_COMMAND as q,KEY_ARROW_LEFT_COMMAND as U,KEY_TAB_COMMAND as V,INSERT_TAB_COMMAND as G,$insertNodes as Q,INDENT_CONTENT_COMMAND as X,OUTDENT_CONTENT_COMMAND as Y,MOVE_TO_START as Z,MOVE_TO_END as tt,$createPoint as et,$setSelectionFromCaretRange as nt,$getCaretRangeInDirection as rt,$getCaretRange as it,$getTextPointCaret as ot,$normalizeCaret as st}from"lexical";import{getPeerDependencyFromEditor as lt}from"@lexical/extension/getPeerDependencyFromEditor";import{effect as ut}from"@lexical/extension/signals";import{namedSignals as ct}from"@lexical/extension/namedSignals";import{$onEscapeDown as at,$onEscapeUp as gt}from"@lexical/utils";
10
+ /*@__INLINE__*/function ft(t){return()=>{}}function ht(t,...e){throw function(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);return n.search=r.toString(),new 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.`)}(t,...e)}function dt(t,e){let n=t;for(let r=h(t,e);r&&(Gt(r.origin)||u(r.origin));r=r.getAdjacentCaret())n=r.origin;return n}function pt(t){return dt(t,"previous")}function mt(t){return dt(t,"next")}function _t(t){const e=pt(t),n=mt(t);let r=e;for(;null!==r;){if(Gt(r)){const t=s(r.getTextContent());if(null!==t)return t}if(r===n)break;r=r.getNextSibling()}const i=e.getParent();if(l(i)){const t=i.getDirection();if("ltr"===t||"rtl"===t)return t}return null}function xt(t,e){let n=null,r=null,i=t,o=e,s=t.getTextContent();for(;;){if(0===o){const t=i.getPreviousSibling();if(null===t){i=null;break}if(Gt(t)||u(t)||c(t)||ht(167),i=t,c(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent()}else o--;const t=s[o];Gt(i)&&" "!==t&&(r={node:i,offset:o})}if(null!==r)return r;let l=null;if(e<t.getTextContentSize())Gt(t)&&(l=t.getTextContent()[e]);else{const e=t.getNextSibling();Gt(e)&&(l=e.getTextContent()[0])}if(null!==l&&" "!==l)return n;{const r=function(t,e){let n=t,r=e,i=t.getTextContent(),o=t.getTextContentSize();for(;;){if(!Gt(n)||r===o){if(n=n.getNextSibling(),null===n||c(n))return null;Gt(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize())}if(Gt(n)){if(" "!==i[r])return{node:n,offset:r};r++}}}(t,e);return null!==r?r:n}}function yt(t){const e=mt(t);return c(e)&&ht(168),e}function St(t){const e=[];return a(t,{linebreak:()=>e.push(f()),tab:()=>e.push(g()),text:t=>e.push(Vt(t))}),e}function bt(t,e,n){if(!Number.isInteger(e)||e<=0)return!1;const r=t.getTextContent(),i=/^ +/.exec(r);if(!i)return!1;const o=Math.min(e,i[0].length),s=t.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 t.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 vt=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function Ct(t,e){if("number"==typeof t)return Number.isFinite(t)?t:e;if("string"!=typeof t||!vt.test(t))return e;const n=Number(t);return Number.isFinite(n)?n:e}const Tt=t=>{const e=d(t,"format"),n=p(t,"format"),r=m(t,"format");return{exportJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles();return{children:[],language:t.__language,theme:t.__theme,direction:t.__dir,format:e[t.__format],indent:t.__indent,textFormat:0!==n&&i?n:void 0,textStyle:""!==r&&i?r:void 0,type:t.__type,version:1}},exportCompactJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles(),o={type:t.__type,children:[]},s=t.__language;void 0!==s&&(o.language=s);const l=t.__theme;void 0!==l&&(o.theme=l);const u=t.__dir;null!=u&&(o.direction=u);const c=e[t.__format];void 0!==c&&""!==c&&(o.format=c);const a=t.__indent;return void 0!==a&&0!==a&&(o.indent=a),void 0!==n&&0!==n&&i&&(o.textFormat=n),void 0!==r&&""!==r&&i&&(o.textStyle=r),o},updateFromJSON:function(t,e){const i=e.direction;t.__dir=null===i||"ltr"===i||"rtl"===i?i:null;const o=e.format;t.__format="string"==typeof o&&o in n?n[o]:r,t.__indent=function(t){const e=Ct(t,0);return e>=0&&e<=Infinity&&Number.isInteger(e)?e:0}(e.indent),t.__textFormat=Ct(e.textFormat,0);const s=e.textStyle;t.__textStyle="string"==typeof s?s:"";const l=e.language;t.setLanguage(null==l||"string"==typeof l?l:"");const u=e.theme;return t.setTheme(void 0===u?void 0:"string"==typeof u?u:""),t}}};function Nt(t,e){t.__highlightType=e.__highlightType}const At=t=>{const e=d(t,"mode"),n=_(t,"detail",0),r=_(t,"format",0),i=p(t,"mode"),o=m(t,"mode");return{exportJSON:function(t){return{highlightType:t.__highlightType,detail:t.__detail,format:t.__format,mode:e[t.__mode],style:t.__style,text:t.__text,type:t.__type,version:1}},exportCompactJSON:function(t){const n={type:t.__type},r=t.__highlightType;void 0!==r&&(n.highlightType=r);const i=t.__detail;void 0!==i&&0!==i&&(n.detail=i);const o=t.__format;void 0!==o&&0!==o&&(n.format=o);const s=e[t.__mode];void 0!==s&&"normal"!==s&&(n.mode=s);const l=t.__style;void 0!==l&&""!==l&&(n.style=l);const u=t.__text;return void 0!==u&&""!==u&&(n.text=u),n},updateFromJSON:function(t,e){const s=e.detail;t.__detail="string"==typeof s&&s in n?n[s]:Ct(s,0);const l=e.format;t.setFormat("string"==typeof l&&l in r?r[l]:Ct(l,0));const u=e.mode;t.__mode="string"==typeof u&&u in i?i[u]:o;const c=e.style;t.__style="string"==typeof c?c:"";const a=e.text;t.__text="string"==typeof a?a:"";const g=e.highlightType;return t.setHighlightType(null==g||"string"==typeof g?g:""),t},afterCloneFrom:Nt}},Pt=/* @__PURE__ */A()({language:/* @__PURE__ */P(/* @__PURE__ */w(/* @__PURE__ */O(/* @__PURE__ */F())),{getter:{field:"__language"}}),theme:/* @__PURE__ */P(/* @__PURE__ */w(/* @__PURE__ */F()),{getter:{field:"__theme"}})}),wt="javascript",Ft=()=>wt;function Ot(t,e){for(const n of t.childNodes){if(D(n)&&n.tagName===e)return!0;if(Ot(n,e))return!0}return!1}const Dt="data-language",Et="data-highlight-language",Lt="data-theme",$t=/* @__PURE__ */ft();class Bt extends y{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:y,generated:Tt,importDOM:{code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||Ot(t,"BR"))?{conversion:zt,priority:1}:null,div:()=>({conversion:Mt,priority:1}),pre:()=>({conversion:zt,priority:0}),table:t=>Rt(t)?{conversion:Kt,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&Rt(n)?{conversion:jt,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&Rt(e)?{conversion:jt,priority:3}:null}},json:Pt})}constructor(t=void 0,e){super(e),this.__language=t||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(t){super.afterCloneFrom(t),function(t,e){t.__language=e.__language,t.__theme=e.__theme}(this,t),this.__isSyntaxHighlightSupported=t.__isSyntaxHighlightSupported}createDOM(t){const e=S().createElement("code");b(e,t.theme.code),e.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(e.setAttribute(Dt,n),this.getIsSyntaxHighlightSupported()&&e.setAttribute(Et,n));const r=this.getTheme();r&&e.setAttribute(Lt,r);const i=this.getStyle();return i&&v(e.style,i),e}updateDOM(t,e,n){const r=this.__language,i=t.__language;r?r!==i&&e.setAttribute(Dt,r):i&&e.removeAttribute(Dt);const o=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&e.setAttribute(Et,r):e.removeAttribute(Et):o&&r&&e.setAttribute(Et,r);const s=this.__theme,l=t.__theme;s?s!==l&&e.setAttribute(Lt,s):l&&e.removeAttribute(Lt);const u=this.__style,c=t.__style;return u!==c&&v(e.style,u,c),!1}exportDOM(t){const e=S().createElement("pre");b(e,t._config.theme.code),e.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(e.setAttribute(Dt,n),this.getIsSyntaxHighlightSupported()&&e.setAttribute(Et,n));const r=this.getTheme();r&&e.setAttribute(Lt,r);const i=this.getStyle();return i&&v(e.style,i),{element:e}}insertNewAfter(t,e=!0){if(!lt(C(),"@lexical/code")){$t();const e=Wt(t);if(e)return e}const{anchor:n,focus:r}=t,i=(n.isBefore(r)?n:r).getNode();if(T(i)){let t=pt(i);const e=[];for(;;)if(u(t))e.push(g()),t=t.getNextSibling();else{if(!Gt(t))break;{let n=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&e.push(Vt(" ".repeat(n))),n!==i)break;t=t.getNextSibling()}}const r=i.splitText(n.offset)[0],o=0===n.offset?0:1,s=r.getIndexWithinParent()+o,l=i.getParentOrThrow(),c=[f(),...e];l.splice(s,0,c);const a=e[e.length-1];a?a.select():0===n.offset?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(kt(i)){const{offset:e}=t.anchor;i.splice(e,0,[f()]),i.select(e+1,e+1)}return null}canIndent(){return!1}collapseAtStart(){const t=N();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 Ht(t,e){return x(Bt).setLanguage(t).setTheme(e)}function kt(t){return t instanceof Bt}function zt(t){return{node:Ht(t.getAttribute(Dt),t.getAttribute(Lt))}}function Mt(t){const e=t,n=It(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(It(e))return!0;e=e.parentElement}return!1}(e)?{node:n?Ht():null}:{node:null}}function Kt(){return{node:Ht()}}function jt(){return{node:null}}function It(t){return null!==t.style.fontFamily.match("monospace")}function Rt(t){return t.classList.contains("js-file-line-container")}function Wt(t){const{anchor:e}=t;if(t.isCollapsed()&&"element"===e.type){const t=e.getNode();if(kt(t)){const n=t.getChildrenSize();if(n>=2&&e.offset===n){const e=t.getLastChild();if(c(e)&&c(e.getPreviousSibling())){const e=N();return t.splice(n-2,2,[]).insertAfter(e,!1),e.select(),e}}}}return null}const Jt=/* @__PURE__ */A()({highlightType:/* @__PURE__ */P(/* @__PURE__ */w(/* @__PURE__ */O(/* @__PURE__ */F())),{getter:{field:"__highlightType"}})});class qt extends L{__highlightType;constructor(t="",e,n){super(t,n),this.__highlightType=e}$config(){return this.config("code-highlight",{extends:L,generated:At,json:Jt})}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(t){const e=this.getWritable();return e.__highlightType=t||void 0,e}canHaveFormat(){return!1}createDOM(t){const e=super.createDOM(t),n=Ut(t.theme,this.__highlightType);return b(e,n),e}updateDOM(t,e,n){const r=super.updateDOM(t,e,n),i=Ut(n.theme,t.__highlightType),o=Ut(n.theme,this.__highlightType);return i!==o&&(i&&$(e,i),o&&b(e,o)),r}setFormat(t){return this}isParentRequired(){return!0}createParentElementNode(){return Ht()}}function Ut(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function Vt(t="",e){return E(new qt(t,e))}function Gt(t){return t instanceof qt}const Qt="data-language",Xt="data-theme";function Yt(t){const e=[];let r=!1;for(let i=0;i<t.length;i++){const o=t[i],s=n(o);i>0&&(s||r)&&e.push("\n"),e.push(o.getTextContent()),r=s}return St(e.join(""))}function Zt(t){return null!==t.style.fontFamily.match("monospace")}function te(t){let e=t.parentElement;for(;null!==e;){if(Zt(e))return!0;e=e.parentElement}return!1}const ee=/* @__PURE__ */r([{$import:(t,e)=>t.$importChildren(e),match:/* @__PURE__ */t.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"}]),ne={$import:(t,e)=>[Ht(e.getAttribute(Qt),e.getAttribute(Xt)).splice(0,0,Yt(t.$importChildren(e)))],match:/* @__PURE__ */t.tag("pre"),name:"@lexical/code/pre"},re={$import:(t,e,n)=>{const r=e.textContent||"";return/\r?\n/.test(r)||null!==e.querySelector("br")?[Ht(e.getAttribute(Qt),e.getAttribute(Xt)).splice(0,0,Yt(t.$importChildren(e)))]:n()},match:/* @__PURE__ */t.tag("code"),name:"@lexical/code/code-multiline"};function ie(t){if(!D(t))return!1;const e=t.style.fontFamily,n=t.style.whiteSpace;return"string"==typeof e&&/monospace/i.test(e)&&"string"==typeof n&&n.startsWith("pre")}function oe(t){let e=!1;const n=[];let r="",i=!1;const o=()=>{i&&(n.push(r),r="",i=!1)};for(const s of Array.from(t.childNodes))if(D(s))"DIV"===s.tagName?(o(),n.push(s.textContent||""),e=!0):"BR"===s.tagName?(o(),n.push(""),e=!0):(r+=s.textContent||"",i=!0);else if(H(s)){const t=s.textContent||"";t.length>0&&(r+=t,i=!0)}return o(),e?n:null}function se(t){for(const e of Array.from(t.children)){if(D(e)&&ie(e)){if(null!==oe(e))return!0;const t=e.nextElementSibling;if(t&&ie(t))return!0;continue}if(se(e))return!0}return!1}const le=/* @__PURE__ */r([{$import:(t,e,n)=>{if(!ie(e)||te(e))return n();const r=oe(e);return null===r||0===r.length?n():[Ht().splice(0,0,St(r.join("\n")))]},match:/* @__PURE__ */t.tag("div"),name:"@lexical/code/vscode-wrapper"},{$import:(t,e,n)=>{if(!ie(e)||te(e))return n();const r=e.previousElementSibling;if(r&&ie(r))return[];const i=[];let o=e;for(;o&&ie(o);)i.push("BR"===o.tagName?"":o.textContent||""),o=o.nextElementSibling;return i.length<2?n():[Ht().splice(0,0,St(i.join("\n")))]},match:/* @__PURE__ */t.tag("div","br"),name:"@lexical/code/vscode-line-run"}]),ue={$import:(t,e,n)=>Zt(e)?[Ht().splice(0,0,Yt(t.$importChildren(e)))]:n(),match:/* @__PURE__ */t.tag("div"),name:"@lexical/code/div"},ce=[{$import:(t,e)=>[Ht().splice(0,0,Yt(t.$importChildren(e,{rules:ee})))],match:/* @__PURE__ */t.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"},{$import:(t,e)=>t.$importChildren(e),match:/* @__PURE__ */t.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"},re,ne,ue],ae={dependencies:[i,[o,{preprocess:[(t,n,r)=>{se(B(t)?t.body:t)&&n.session.update(e,t=>[...t,le]),r()}],rules:ce}]],name:"@lexical/code",nodes:()=>[Bt,qt],register:t=>k(t.registerCommand(z,t=>{const e=M();return!(!K(e)||!Wt(e)||(null!==t&&t.preventDefault(),0))},j),t.registerNodeTransform(I,t=>{0!==t.getFormat()&&kt(t.getParent())&&t.setFormat(0)}))};function ge(t){const e=C().getElementByKey(t.getKey());if(null===e)return;const n=t.getChildren(),r=n.length;if(r===e.__cachedChildrenLength)return;e.__cachedChildrenLength=r;let i="1",o=1;for(let t=0;t<r;t++)c(n[t])&&(i+="\n"+ ++o);e.setAttribute("data-gutter",i)}function fe(t){return t._headless?()=>{}:t.registerMutationListener(Bt,e=>{t.read("latest",()=>{for(const[t,n]of e)if("destroyed"!==n){const e=R(t);null!==e&&ge(e)}})},{skipInitialization:!1})}function he(t){if(!K(t))return!1;const e=t.anchor.getNode(),n=kt(e)?e:e.getParent(),r=t.focus.getNode(),i=kt(r)?r:r.getParent();return kt(n)&&n.is(i)}function de(t){const e=t.getNodes(),n=[];if(1===e.length&&kt(e[0]))return n;let r=[];for(let t=0;t<e.length;t++){const i=e[t];Gt(i)||u(i)||c(i)||ht(169),c(i)?r.length>0&&(n.push(r),r=[]):r.push(i)}if(r.length>0){const e=t.isBackward()?t.anchor:t.focus,i=et(r[0].getKey(),0,"text");e.is(i)||n.push(r)}return n}function pe(t,e){const n=M();if(!K(n)||!he(n))return!1;const r=de(n),i=r.length;if(0===i&&n.isCollapsed())return t===X?n.insertNodes([g()]):function(t,e){const n=t.anchor.getNode();if(!Gt(n)&&!u(n))return;const r=pt(n);u(r)?r.remove():void 0!==e&&Gt(r)&&bt(r,e,t)}(n,e),!0;if(0===i&&t===X&&"\n"===n.getTextContent()){const t=g(),e=f(),r=n.isBackward()?"previous":"next";return n.insertNodes([t,e]),nt(rt(it(ot(t,"next",0),st(h(e,"next"))),r)),!0}for(let o=0;o<i;o++){const i=r[o];if(i.length>0){let r=i[0];if(0===o&&(r=pt(r)),t===X){const t=g();if(r.insertBefore(t),0===o){const e=n.isBackward()?"focus":"anchor",i=et(r.getKey(),0,"text");n[e].is(i)&&n[e].set(t.getKey(),0,"text")}}else u(r)?r.remove():void 0!==e&&Gt(r)&&bt(r,e,n)}}return!0}function me(t,e){const n=M();if(!K(n))return!1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,l=r.getNode(),a=i.getNode(),g=t===q;if(!he(n)||!Gt(l)&&!u(l)||!Gt(a)&&!u(a))return!1;if(!e.altKey){if(n.isCollapsed()){const t=l.getParentOrThrow();if(g&&0===o&&null===l.getPreviousSibling()){if(null===t.getPreviousSibling())return t.selectPrevious(),e.preventDefault(),!1}else if(!g&&o===l.getTextContentSize()&&null===l.getNextSibling()&&null===t.getNextSibling())return t.selectNext(),e.preventDefault(),!1}return!1}let f,h;if(l.isBefore(a)?(f=pt(l),h=mt(a)):(f=pt(a),h=mt(l)),null==f||null==h)return!1;const d=f.getNodesBetween(h);for(let t=0;t<d.length;t++){const e=d[t];if(!Gt(e)&&!u(e)&&!c(e))return!1}e.preventDefault(),e.stopPropagation();const p=g?f.getPreviousSibling():h.getNextSibling();if(!c(p))return!0;const m=g?p.getPreviousSibling():p.getNextSibling();if(null==m)return!0;const _=c(m),x=_||!Gt(m)&&!u(m)?null:g?pt(m):mt(m);let y=null!=x?x:m;return p.remove(),d.forEach(t=>t.remove()),_?(d.forEach(t=>{y.insertAfter(t),y=t}),y.insertAfter(p)):t===q?(d.forEach(t=>y.insertBefore(t)),y.insertBefore(p)):(y.insertAfter(p),y=p,d.forEach(t=>{y.insertAfter(t),y=t})),n.setTextNodeRange(l,o,a,s),!0}function _e(t,e){const n=M();if(!K(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),l=t===Z;if(!he(n)||!Gt(o)&&!u(o)||!Gt(s)&&!u(s))return!1;const a=s,g="rtl"===_t(a)?!l:l,f=r.key,h=r.offset,d=r.type;if(g){const t=xt(a,i.offset);if(null!==t){const{node:e,offset:r}=t;c(e)?e.selectNext(0,0):n.setTextNodeRange(e,r,e,r)}else a.getParentOrThrow().selectStart()}else yt(a).select();return e.shiftKey&&n.anchor.set(f,h,d),e.preventDefault(),e.stopPropagation(),!0}function xe(t,e,n){return k(...n?[t.registerCommand(W,t=>!t.altKey&&at(kt,t),j),t.registerCommand(J,t=>at(kt,t),j),t.registerCommand(q,t=>!t.altKey&&gt(kt,t),j),t.registerCommand(U,t=>gt(kt,t),j)]:[],t.registerCommand(V,e=>{const n=function(t){const e=M();if(!K(e)||!he(e))return null;const n=t?Y:X,r=t?Y:G,i=e.anchor,o=e.focus;if(i.is(o))return r;const s=de(e);if(1!==s.length)return n;const l=s[0];let u,c;0===l.length&&ht(285),e.isBackward()?(u=o,c=i):(u=i,c=o);const a=pt(l[0]),g=mt(l[0]),f=et(a.getKey(),0,"text"),h=et(g.getKey(),g.getTextContentSize(),"text");return u.isBefore(f)||h.isBefore(c)?n:f.isBefore(u)||c.isBefore(h)?r:n}(e.shiftKey);return null!==n&&(e.preventDefault(),t.dispatchCommand(n),!0)},j),t.registerCommand(G,()=>!!he(M())&&(Q([g()]),!0),j),t.registerCommand(X,()=>pe(X),j),t.registerCommand(Y,()=>pe(Y,e),j),t.registerCommand(q,t=>{const e=M();if(!K(e))return!1;const{anchor:n}=e,r=n.getNode();if(!he(e))return!1;const i=r.getParent();return e.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&kt(i)&&null===i.getPreviousSibling()?(t.preventDefault(),!0):me(q,t)},j),t.registerCommand(W,t=>{const e=M();if(!K(e))return!1;const{anchor:n}=e,r=n.getNode();return!!he(e)&&(e.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&kt(r.getParentOrThrow())&&null===r.getParentOrThrow().getNextSibling()?(t.preventDefault(),!0):me(W,t))},j),t.registerCommand(Z,t=>_e(Z,t),j),t.registerCommand(tt,t=>_e(tt,t),j))}const ye={build:(t,e)=>ct(e),config:{disabled:!1,escapeWithArrows:!1,tabSize:void 0},dependencies:[ae],name:"@lexical/code-indent",register:(t,e,n)=>{const r=n.getOutput();return ut(()=>{if(!r.disabled.value)return xe(t,r.tabSize.value,r.escapeWithArrows.value)})}};export{Vt as $createCodeHighlightNode,Ht as $createCodeNode,_t as $getCodeLineDirection,yt as $getEndOfCodeInLine,pt as $getFirstCodeNodeOfLine,mt as $getLastCodeNodeOfLine,xt as $getStartOfCodeInLine,Gt as $isCodeHighlightNode,kt as $isCodeNode,bt as $outdentLeadingSpaces,St as $plainifyCodeContent,ae as CodeExtension,qt as CodeHighlightNode,ce as CodeImportRules,ye as CodeIndentExtension,Bt as CodeNode,wt as DEFAULT_CODE_LANGUAGE,Ft as getDefaultCodeLanguage,fe as registerCodeGutter,xe as registerCodeIndentation};
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export { CodeExtension, CodeImportExtension } from './CodeExtension.js';
8
+ export { CodeExtension } from './CodeExtension.js';
9
9
  export { registerCodeGutter } from './CodeGutter.js';
10
10
  export { $createCodeHighlightNode, $isCodeHighlightNode, CodeHighlightNode, } from './CodeHighlightNode.js';
11
11
  export { CodeImportRules } from './CodeImportExtension.js';
package/package.json CHANGED
@@ -8,15 +8,15 @@
8
8
  "code"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.52.1-nightly.20261002.0",
11
+ "version": "0.52.1-nightly.20261006.0",
12
12
  "main": "./dist/LexicalCodeCore.js",
13
13
  "types": "./dist/typescript-too-old.d.ts",
14
14
  "dependencies": {
15
- "@lexical/extension": "0.52.1-nightly.20261002.0",
16
- "@lexical/html": "0.52.1-nightly.20261002.0",
17
- "@lexical/internal": "0.52.1-nightly.20261002.0",
18
- "@lexical/utils": "0.52.1-nightly.20261002.0",
19
- "lexical": "0.52.1-nightly.20261002.0"
15
+ "@lexical/extension": "0.52.1-nightly.20261006.0",
16
+ "@lexical/html": "0.52.1-nightly.20261006.0",
17
+ "@lexical/internal": "0.52.1-nightly.20261006.0",
18
+ "@lexical/utils": "0.52.1-nightly.20261006.0",
19
+ "lexical": "0.52.1-nightly.20261006.0"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -65,17 +65,3 @@ export const CodeExtension = defineExtension({
65
65
  );
66
66
  },
67
67
  });
68
-
69
- /**
70
- * Bundles {@link CodeImportRules} together with the runtime
71
- * {@link CodeExtension}.
72
- *
73
- * @experimental
74
- * @deprecated {@link CodeExtension} now registers
75
- * {@link CodeImportRules} (and `CoreImportExtension`) itself — depend on
76
- * it directly instead.
77
- */
78
- export const CodeImportExtension = defineExtension({
79
- dependencies: [CodeExtension],
80
- name: '@lexical/code/Import',
81
- });
package/src/index.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- export {CodeExtension, CodeImportExtension} from './CodeExtension';
9
+ export {CodeExtension} from './CodeExtension';
10
10
  export {registerCodeGutter} from './CodeGutter';
11
11
  export {
12
12
  $createCodeHighlightNode,