@lexical/code-core 0.48.1-nightly.20260724.0 → 0.48.1-nightly.20260727.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.
@@ -1075,7 +1075,9 @@ const CodeExtension = /* @__PURE__ */lexical.defineExtension({
1075
1075
  return lexical.mergeRegister(editor.registerCommand(lexical.KEY_ENTER_COMMAND, event => {
1076
1076
  const selection = lexical.$getSelection();
1077
1077
  if (lexical.$isRangeSelection(selection) && $exitCodeNodeOnEnter(selection)) {
1078
- event.preventDefault();
1078
+ if (event !== null) {
1079
+ event.preventDefault();
1080
+ }
1079
1081
  return true;
1080
1082
  }
1081
1083
  return false;
@@ -1456,7 +1458,7 @@ function registerCodeIndentation(editor, tabSize, escapeWithArrows) {
1456
1458
  return false;
1457
1459
  }
1458
1460
  event.preventDefault();
1459
- editor.dispatchCommand(command, undefined);
1461
+ editor.dispatchCommand(command);
1460
1462
  return true;
1461
1463
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.INSERT_TAB_COMMAND, () => {
1462
1464
  const selection = lexical.$getSelection();
@@ -1073,7 +1073,9 @@ const CodeExtension = /* @__PURE__ */defineExtension({
1073
1073
  return mergeRegister(editor.registerCommand(KEY_ENTER_COMMAND, event => {
1074
1074
  const selection = $getSelection();
1075
1075
  if ($isRangeSelection(selection) && $exitCodeNodeOnEnter(selection)) {
1076
- event.preventDefault();
1076
+ if (event !== null) {
1077
+ event.preventDefault();
1078
+ }
1077
1079
  return true;
1078
1080
  }
1079
1081
  return false;
@@ -1454,7 +1456,7 @@ function registerCodeIndentation(editor, tabSize, escapeWithArrows) {
1454
1456
  return false;
1455
1457
  }
1456
1458
  event.preventDefault();
1457
- editor.dispatchCommand(command, undefined);
1459
+ editor.dispatchCommand(command);
1458
1460
  return true;
1459
1461
  }, COMMAND_PRIORITY_LOW), editor.registerCommand(INSERT_TAB_COMMAND, () => {
1460
1462
  const selection = $getSelection();
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/html"),t=require("lexical"),n=require("@lexical/extension"),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(e,n){let r=e;for(let i=t.$getSiblingCaret(e,n);i&&(y(i.origin)||t.$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(e){const n=s(e),r=l(e);let i=n;for(;null!==i;){if(y(i)){const e=t.getTextDirection(i.getTextContent());if(null!==e)return e}if(i===r)break;i=i.getNextSibling()}const o=n.getParent();if(t.$isElementNode(o)){const e=o.getDirection();if("ltr"===e||"rtl"===e)return e}return null}function c(e,n){let r=null,o=null,s=e,l=n,a=e.getTextContent();for(;;){if(0===l){const e=s.getPreviousSibling();if(null===e){s=null;break}if(y(e)||t.$isTabNode(e)||t.$isLineBreakNode(e)||i(167),s=e,t.$isLineBreakNode(s)){r={node:s,offset:1};break}l=Math.max(0,s.getTextContentSize()-1),a=s.getTextContent()}else l--;const e=a[l];y(s)&&" "!==e&&(o={node:s,offset:l})}if(null!==o)return o;let c=null;if(n<e.getTextContentSize())y(e)&&(c=e.getTextContent()[n]);else{const t=e.getNextSibling();y(t)&&(c=t.getTextContent()[0])}if(null!==c&&" "!==c)return r;{const i=function(e,n){let r=e,i=n,o=e.getTextContent(),s=e.getTextContentSize();for(;;){if(!y(r)||i===s){if(r=r.getNextSibling(),null===r||t.$isLineBreakNode(r))return null;y(r)&&(i=0,o=r.getTextContent(),s=r.getTextContentSize())}if(y(r)){if(" "!==o[i])return{node:r,offset:i};i++}}}(e,n);return null!==i?i:r}}function u(e){const n=l(e);return t.$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(e,n){for(const r of e.childNodes){if(t.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 t.ElementNode{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:t.ElementNode,importDOM:{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||f(e,"BR"))?{conversion:C,priority:1}:null,div:()=>({conversion:O,priority:1}),pre:()=>({conversion:C,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:$,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&b(t)?{conversion:$,priority:3}:null}}})}constructor(e=void 0,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 n=t.$getDocument().createElement("code");t.addClassNamesToElement(n,e.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&&t.setDOMStyleFromCSS(n.style,o),n}updateDOM(e,n,r){const i=this.__language,o=e.__language;i?i!==o&&n.setAttribute(h,i):o&&n.removeAttribute(h);const s=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&o?s&&i?i!==o&&n.setAttribute(p,i):n.removeAttribute(p):s&&i&&n.setAttribute(p,i);const l=this.__theme,a=e.__theme;l?l!==a&&n.setAttribute(N,l):a&&n.removeAttribute(N);const c=this.__style,u=e.__style;return c!==u&&t.setDOMStyleFromCSS(n.style,c,u),!1}exportDOM(e){const n=t.$getDocument().createElement("pre");t.addClassNamesToElement(n,e._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&&t.setDOMStyleFromCSS(n.style,o),{element:n}}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,r=!0){if(!n.getPeerDependencyFromEditor(t.$getEditor(),"@lexical/code")){m();const t=E(e);if(t)return t}const{anchor:i,focus:o}=e,l=(i.isBefore(o)?i:o).getNode();if(t.$isTextNode(l)){let e=s(l);const n=[];for(;;)if(t.$isTabNode(e))n.push(t.$createTabNode()),e=e.getNextSibling();else{if(!y(e))break;{let t=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;t<i&&" "===r[t];)t++;if(0!==t&&n.push(A(" ".repeat(t))),t!==i)break;e=e.getNextSibling()}}const r=l.splitText(i.offset)[0],o=0===i.offset?0:1,a=r.getIndexWithinParent()+o,c=l.getParentOrThrow(),u=[t.$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(x(l)){const{offset:n}=e.anchor;l.splice(n,0,[t.$createLineBreakNode()]),l.select(n+1,n+1)}return null}canIndent(){return!1}collapseAtStart(){const e=t.$createParagraphNode();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 T(e,n){return t.$create(_).setLanguage(e).setTheme(n)}function x(e){return e instanceof _}function C(e){return{node:T(e.getAttribute(h))}}function O(e){const t=e,n=M(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if(M(t))return!0;t=t.parentElement}return!1}(t)?{node:n?T():null}:{node:null}}function S(){return{node:T()}}function $(){return{node:null}}function M(e){return null!==e.style.fontFamily.match("monospace")}function b(e){return e.classList.contains("js-file-line-container")}function E(e){const{anchor:n}=e;if(e.isCollapsed()&&"element"===n.type){const e=n.getNode();if(x(e)){const r=e.getChildrenSize();if(r>=2&&n.offset===r){const n=e.getLastChild();if(t.$isLineBreakNode(n)&&t.$isLineBreakNode(n.getPreviousSibling())){const n=t.$createParagraphNode();return e.splice(r-2,2,[]).insertAfter(n,!1),n.select(),n}}}}return null}class R extends t.TextNode{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}$config(){return this.config("code-highlight",{extends:t.TextNode})}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 n=super.createDOM(e),r=D(e.theme,this.__highlightType);return t.addClassNamesToElement(n,r),n}updateDOM(e,n,r){const i=super.updateDOM(e,n,r),o=D(r.theme,e.__highlightType),s=D(r.theme,this.__highlightType);return o!==s&&(o&&t.removeClassNamesFromElement(n,o),s&&t.addClassNamesToElement(n,s)),i}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 D(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function A(e="",n){return t.$applyNodeReplacement(new R(e,n))}function y(e){return e instanceof R}const v="data-language";function I(e){return null!==e.style.fontFamily.match("monospace")}function L(e){let t=e.parentElement;for(;null!==t;){if(I(t))return!0;t=t.parentElement}return!1}const P=/* @__PURE__ */e.defineOverlayRules([/* @__PURE__ */e.defineImportRule({$import:(e,t)=>e.$importChildren(t),match:e.sel.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),B=/* @__PURE__ */e.defineImportRule({$import:(e,t)=>[T(t.getAttribute(v)).splice(0,0,e.$importChildren(t))],match:e.sel.tag("pre"),name:"@lexical/code/pre"}),W=/* @__PURE__ */e.defineImportRule({$import:(e,t,n)=>{const r=t.textContent||"";return/\r?\n/.test(r)||null!==t.querySelector("br")?[T(t.getAttribute(v)).splice(0,0,e.$importChildren(t))]:n()},match:e.sel.tag("code"),name:"@lexical/code/code-multiline"});function k(e){if(!t.isHTMLElement(e))return!1;const n=e.style.fontFamily,r=e.style.whiteSpace;return"string"==typeof n&&/monospace/i.test(n)&&"string"==typeof r&&r.startsWith("pre")}function H(e){let n=!1;const r=[];let i="",o=!1;const s=()=>{o&&(r.push(i),i="",o=!1)};for(const l of Array.from(e.childNodes))if(t.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(t.isDOMTextNode(l)){const e=l.textContent||"";e.length>0&&(i+=e,o=!0)}return s(),n?r:null}function w(e){for(const n of Array.from(e.children)){if(t.isHTMLElement(n)&&k(n)){if(null!==H(n))return!0;const e=n.nextElementSibling;if(e&&k(e))return!0;continue}if(w(n))return!0}return!1}const F=/* @__PURE__ */e.defineImportRule({$import:(e,n,r)=>{if(!k(n)||L(n))return r();const i=H(n);return null===i||0===i.length?r():[T().splice(0,0,t.$generateNodesFromRawText(i.join("\n")))]},match:e.sel.tag("div"),name:"@lexical/code/vscode-wrapper"}),Y=/* @__PURE__ */e.defineImportRule({$import:(e,n,r)=>{if(!k(n)||L(n))return r();const i=n.previousElementSibling;if(i&&k(i))return[];const o=[];let s=n;for(;s&&k(s);)o.push("BR"===s.tagName?"":s.textContent||""),s=s.nextElementSibling;return o.length<2?r():[T().splice(0,0,t.$generateNodesFromRawText(o.join("\n")))]},match:e.sel.tag("div","br"),name:"@lexical/code/vscode-line-run"}),K=/* @__PURE__ */e.defineOverlayRules([F,Y]),U=/* @__PURE__ */e.defineImportRule({$import:(e,t,n)=>I(t)?[T().splice(0,0,e.$importChildren(t))]:L(t)?e.$importChildren(t):n(),match:e.sel.tag("div"),name:"@lexical/code/div"}),z=[/* @__PURE__ */e.defineImportRule({$import:(e,t)=>[T().splice(0,0,e.$importChildren(t,{rules:P}))],match:e.sel.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"}),/* @__PURE__ */e.defineImportRule({$import:(e,t)=>e.$importChildren(t),match:e.sel.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"}),W,B,U],j=/* @__PURE__ */t.defineExtension({dependencies:[e.CoreImportExtension,/* @__PURE__ */t.configExtension(e.DOMImportExtension,{preprocess:[(n,r,i)=>{w(t.isDOMDocumentNode(n)?n.body:n)&&r.session.update(e.ImportOverlays,e=>[...e,K]),i()}],rules:z})],name:"@lexical/code",nodes:()=>[_,R],register:e=>t.mergeRegister(e.registerCommand(t.KEY_ENTER_COMMAND,e=>{const n=t.$getSelection();return!(!t.$isRangeSelection(n)||!E(n))&&(e.preventDefault(),!0)},t.COMMAND_PRIORITY_LOW),e.registerNodeTransform(t.TabNode,e=>{0!==e.getFormat()&&x(e.getParent())&&e.setFormat(0)}))}),J=/* @__PURE__ */t.defineExtension({dependencies:[j],name:"@lexical/code/Import"});function q(e){if(!t.$isRangeSelection(e))return!1;const n=e.anchor.getNode(),r=x(n)?n:n.getParent(),i=e.focus.getNode(),o=x(i)?i:i.getParent();return x(r)&&r.is(o)}function V(e){const n=e.getNodes(),r=[];if(1===n.length&&x(n[0]))return r;let o=[];for(let e=0;e<n.length;e++){const s=n[e];y(s)||t.$isTabNode(s)||t.$isLineBreakNode(s)||i(169),t.$isLineBreakNode(s)?o.length>0&&(r.push(o),o=[]):o.push(s)}if(o.length>0){const n=e.isBackward()?e.anchor:e.focus,i=t.$createPoint(o[0].getKey(),0,"text");n.is(i)||r.push(o)}return r}function G(e,n){const r=t.$getSelection();if(!t.$isRangeSelection(r)||!q(r))return!1;const i=V(r),o=i.length;if(0===o&&r.isCollapsed())return e===t.INDENT_CONTENT_COMMAND&&r.insertNodes([t.$createTabNode()]),!0;if(0===o&&e===t.INDENT_CONTENT_COMMAND&&"\n"===r.getTextContent()){const e=t.$createTabNode(),n=t.$createLineBreakNode(),i=r.isBackward()?"previous":"next";return r.insertNodes([e,n]),t.$setSelectionFromCaretRange(t.$getCaretRangeInDirection(t.$getCaretRange(t.$getTextPointCaret(e,"next",0),t.$normalizeCaret(t.$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)),e===t.INDENT_CONTENT_COMMAND){const e=t.$createTabNode();if(i.insertBefore(e),0===l){const n=r.isBackward()?"focus":"anchor",o=t.$createPoint(i.getKey(),0,"text");r[n].is(o)&&r[n].set(e.getKey(),0,"text")}}else t.$isTabNode(i)?i.remove():void 0!==n&&y(i)&&g(i,n,r)}}return!0}function Q(e,n){const r=t.$getSelection();if(!t.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,a=i.offset,c=o.offset,u=i.getNode(),g=o.getNode(),d=e===t.KEY_ARROW_UP_COMMAND;if(!q(r)||!y(u)&&!t.$isTabNode(u)||!y(g)&&!t.$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 e=0;e<p.length;e++){const n=p[e];if(!y(n)&&!t.$isTabNode(n)&&!t.$isLineBreakNode(n))return!1}n.preventDefault(),n.stopPropagation();const N=d?f.getPreviousSibling():h.getNextSibling();if(!t.$isLineBreakNode(N))return!0;const m=d?N.getPreviousSibling():N.getNextSibling();if(null==m)return!0;const _=y(m)||t.$isTabNode(m)||t.$isLineBreakNode(m)?d?s(m):l(m):null;let T=null!=_?_:m;return N.remove(),p.forEach(e=>e.remove()),e===t.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(e,n){const r=t.$getSelection();if(!t.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,s=i.getNode(),l=o.getNode(),g=e===t.MOVE_TO_START;if(!q(r)||!y(s)&&!t.$isTabNode(s)||!y(l)&&!t.$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 e=c(d,o.offset);if(null!==e){const{node:n,offset:i}=e;t.$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(e,n,o){return t.mergeRegister(...o?[e.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>!e.altKey&&r.$onEscapeDown(x,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_RIGHT_COMMAND,e=>r.$onEscapeDown(x,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>!e.altKey&&r.$onEscapeUp(x,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_LEFT_COMMAND,e=>r.$onEscapeUp(x,e),t.COMMAND_PRIORITY_LOW)]:[],e.registerCommand(t.KEY_TAB_COMMAND,n=>{const r=function(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!q(n))return null;const r=e?t.OUTDENT_CONTENT_COMMAND:t.INDENT_CONTENT_COMMAND,o=e?t.OUTDENT_CONTENT_COMMAND:t.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=t.$createPoint(h.getKey(),0,"text"),m=t.$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(),e.dispatchCommand(r,void 0),!0)},t.COMMAND_PRIORITY_LOW),e.registerCommand(t.INSERT_TAB_COMMAND,()=>!!q(t.$getSelection())&&(t.$insertNodes([t.$createTabNode()]),!0),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.INDENT_CONTENT_COMMAND,()=>G(t.INDENT_CONTENT_COMMAND),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.OUTDENT_CONTENT_COMMAND,()=>G(t.OUTDENT_CONTENT_COMMAND,n),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>{const n=t.$getSelection();if(!t.$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()&&x(o)&&null===o.getPreviousSibling()?(e.preventDefault(),!0):Q(t.KEY_ARROW_UP_COMMAND,e)},t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>{const n=t.$getSelection();if(!t.$isRangeSelection(n))return!1;const{anchor:r}=n,i=r.getNode();return!!q(n)&&(n.isCollapsed()&&r.offset===i.getTextContentSize()&&null===i.getNextSibling()&&x(i.getParentOrThrow())&&null===i.getParentOrThrow().getNextSibling()?(e.preventDefault(),!0):Q(t.KEY_ARROW_DOWN_COMMAND,e))},t.COMMAND_PRIORITY_LOW),e.registerCommand(t.MOVE_TO_START,e=>X(t.MOVE_TO_START,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.MOVE_TO_END,e=>X(t.MOVE_TO_END,e),t.COMMAND_PRIORITY_LOW))}const ee=/* @__PURE__ */t.defineExtension({build:(e,t)=>n.namedSignals(t),config:/* @__PURE__ */t.safeCast({disabled:!1,escapeWithArrows:!1,tabSize:void 0}),dependencies:[j],name:"@lexical/code-indent",register:(e,t,r)=>{const i=r.getOutput();return n.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=y,exports.$isCodeNode=x,exports.$outdentLeadingSpaces=g,exports.$plainifyCodeContent=function(e){const n=[];return t.tokenizeRawText(e,{linebreak:()=>n.push(t.$createLineBreakNode()),tab:()=>n.push(t.$createTabNode()),text:e=>n.push(A(e))}),n},exports.CodeExtension=j,exports.CodeHighlightNode=R,exports.CodeImportExtension=J,exports.CodeImportRules=z,exports.CodeIndentExtension=ee,exports.CodeNode=_,exports.DEFAULT_CODE_LANGUAGE=d,exports.getDefaultCodeLanguage=()=>d,exports.registerCodeIndentation=Z;
9
+ "use strict";var e=require("@lexical/html"),t=require("lexical"),n=require("@lexical/extension"),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(e,n){let r=e;for(let i=t.$getSiblingCaret(e,n);i&&(y(i.origin)||t.$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(e){const n=s(e),r=l(e);let i=n;for(;null!==i;){if(y(i)){const e=t.getTextDirection(i.getTextContent());if(null!==e)return e}if(i===r)break;i=i.getNextSibling()}const o=n.getParent();if(t.$isElementNode(o)){const e=o.getDirection();if("ltr"===e||"rtl"===e)return e}return null}function c(e,n){let r=null,o=null,s=e,l=n,a=e.getTextContent();for(;;){if(0===l){const e=s.getPreviousSibling();if(null===e){s=null;break}if(y(e)||t.$isTabNode(e)||t.$isLineBreakNode(e)||i(167),s=e,t.$isLineBreakNode(s)){r={node:s,offset:1};break}l=Math.max(0,s.getTextContentSize()-1),a=s.getTextContent()}else l--;const e=a[l];y(s)&&" "!==e&&(o={node:s,offset:l})}if(null!==o)return o;let c=null;if(n<e.getTextContentSize())y(e)&&(c=e.getTextContent()[n]);else{const t=e.getNextSibling();y(t)&&(c=t.getTextContent()[0])}if(null!==c&&" "!==c)return r;{const i=function(e,n){let r=e,i=n,o=e.getTextContent(),s=e.getTextContentSize();for(;;){if(!y(r)||i===s){if(r=r.getNextSibling(),null===r||t.$isLineBreakNode(r))return null;y(r)&&(i=0,o=r.getTextContent(),s=r.getTextContentSize())}if(y(r)){if(" "!==o[i])return{node:r,offset:i};i++}}}(e,n);return null!==i?i:r}}function u(e){const n=l(e);return t.$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(e,n){for(const r of e.childNodes){if(t.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 t.ElementNode{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:t.ElementNode,importDOM:{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||f(e,"BR"))?{conversion:C,priority:1}:null,div:()=>({conversion:O,priority:1}),pre:()=>({conversion:C,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:$,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&b(t)?{conversion:$,priority:3}:null}}})}constructor(e=void 0,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 n=t.$getDocument().createElement("code");t.addClassNamesToElement(n,e.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&&t.setDOMStyleFromCSS(n.style,o),n}updateDOM(e,n,r){const i=this.__language,o=e.__language;i?i!==o&&n.setAttribute(h,i):o&&n.removeAttribute(h);const s=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&o?s&&i?i!==o&&n.setAttribute(p,i):n.removeAttribute(p):s&&i&&n.setAttribute(p,i);const l=this.__theme,a=e.__theme;l?l!==a&&n.setAttribute(N,l):a&&n.removeAttribute(N);const c=this.__style,u=e.__style;return c!==u&&t.setDOMStyleFromCSS(n.style,c,u),!1}exportDOM(e){const n=t.$getDocument().createElement("pre");t.addClassNamesToElement(n,e._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&&t.setDOMStyleFromCSS(n.style,o),{element:n}}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,r=!0){if(!n.getPeerDependencyFromEditor(t.$getEditor(),"@lexical/code")){m();const t=E(e);if(t)return t}const{anchor:i,focus:o}=e,l=(i.isBefore(o)?i:o).getNode();if(t.$isTextNode(l)){let e=s(l);const n=[];for(;;)if(t.$isTabNode(e))n.push(t.$createTabNode()),e=e.getNextSibling();else{if(!y(e))break;{let t=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;t<i&&" "===r[t];)t++;if(0!==t&&n.push(A(" ".repeat(t))),t!==i)break;e=e.getNextSibling()}}const r=l.splitText(i.offset)[0],o=0===i.offset?0:1,a=r.getIndexWithinParent()+o,c=l.getParentOrThrow(),u=[t.$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(x(l)){const{offset:n}=e.anchor;l.splice(n,0,[t.$createLineBreakNode()]),l.select(n+1,n+1)}return null}canIndent(){return!1}collapseAtStart(){const e=t.$createParagraphNode();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 T(e,n){return t.$create(_).setLanguage(e).setTheme(n)}function x(e){return e instanceof _}function C(e){return{node:T(e.getAttribute(h))}}function O(e){const t=e,n=M(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if(M(t))return!0;t=t.parentElement}return!1}(t)?{node:n?T():null}:{node:null}}function S(){return{node:T()}}function $(){return{node:null}}function M(e){return null!==e.style.fontFamily.match("monospace")}function b(e){return e.classList.contains("js-file-line-container")}function E(e){const{anchor:n}=e;if(e.isCollapsed()&&"element"===n.type){const e=n.getNode();if(x(e)){const r=e.getChildrenSize();if(r>=2&&n.offset===r){const n=e.getLastChild();if(t.$isLineBreakNode(n)&&t.$isLineBreakNode(n.getPreviousSibling())){const n=t.$createParagraphNode();return e.splice(r-2,2,[]).insertAfter(n,!1),n.select(),n}}}}return null}class R extends t.TextNode{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}$config(){return this.config("code-highlight",{extends:t.TextNode})}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 n=super.createDOM(e),r=D(e.theme,this.__highlightType);return t.addClassNamesToElement(n,r),n}updateDOM(e,n,r){const i=super.updateDOM(e,n,r),o=D(r.theme,e.__highlightType),s=D(r.theme,this.__highlightType);return o!==s&&(o&&t.removeClassNamesFromElement(n,o),s&&t.addClassNamesToElement(n,s)),i}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 D(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function A(e="",n){return t.$applyNodeReplacement(new R(e,n))}function y(e){return e instanceof R}const v="data-language";function I(e){return null!==e.style.fontFamily.match("monospace")}function L(e){let t=e.parentElement;for(;null!==t;){if(I(t))return!0;t=t.parentElement}return!1}const P=/* @__PURE__ */e.defineOverlayRules([/* @__PURE__ */e.defineImportRule({$import:(e,t)=>e.$importChildren(t),match:e.sel.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),B=/* @__PURE__ */e.defineImportRule({$import:(e,t)=>[T(t.getAttribute(v)).splice(0,0,e.$importChildren(t))],match:e.sel.tag("pre"),name:"@lexical/code/pre"}),W=/* @__PURE__ */e.defineImportRule({$import:(e,t,n)=>{const r=t.textContent||"";return/\r?\n/.test(r)||null!==t.querySelector("br")?[T(t.getAttribute(v)).splice(0,0,e.$importChildren(t))]:n()},match:e.sel.tag("code"),name:"@lexical/code/code-multiline"});function k(e){if(!t.isHTMLElement(e))return!1;const n=e.style.fontFamily,r=e.style.whiteSpace;return"string"==typeof n&&/monospace/i.test(n)&&"string"==typeof r&&r.startsWith("pre")}function H(e){let n=!1;const r=[];let i="",o=!1;const s=()=>{o&&(r.push(i),i="",o=!1)};for(const l of Array.from(e.childNodes))if(t.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(t.isDOMTextNode(l)){const e=l.textContent||"";e.length>0&&(i+=e,o=!0)}return s(),n?r:null}function w(e){for(const n of Array.from(e.children)){if(t.isHTMLElement(n)&&k(n)){if(null!==H(n))return!0;const e=n.nextElementSibling;if(e&&k(e))return!0;continue}if(w(n))return!0}return!1}const F=/* @__PURE__ */e.defineImportRule({$import:(e,n,r)=>{if(!k(n)||L(n))return r();const i=H(n);return null===i||0===i.length?r():[T().splice(0,0,t.$generateNodesFromRawText(i.join("\n")))]},match:e.sel.tag("div"),name:"@lexical/code/vscode-wrapper"}),Y=/* @__PURE__ */e.defineImportRule({$import:(e,n,r)=>{if(!k(n)||L(n))return r();const i=n.previousElementSibling;if(i&&k(i))return[];const o=[];let s=n;for(;s&&k(s);)o.push("BR"===s.tagName?"":s.textContent||""),s=s.nextElementSibling;return o.length<2?r():[T().splice(0,0,t.$generateNodesFromRawText(o.join("\n")))]},match:e.sel.tag("div","br"),name:"@lexical/code/vscode-line-run"}),K=/* @__PURE__ */e.defineOverlayRules([F,Y]),U=/* @__PURE__ */e.defineImportRule({$import:(e,t,n)=>I(t)?[T().splice(0,0,e.$importChildren(t))]:L(t)?e.$importChildren(t):n(),match:e.sel.tag("div"),name:"@lexical/code/div"}),z=[/* @__PURE__ */e.defineImportRule({$import:(e,t)=>[T().splice(0,0,e.$importChildren(t,{rules:P}))],match:e.sel.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"}),/* @__PURE__ */e.defineImportRule({$import:(e,t)=>e.$importChildren(t),match:e.sel.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"}),W,B,U],j=/* @__PURE__ */t.defineExtension({dependencies:[e.CoreImportExtension,/* @__PURE__ */t.configExtension(e.DOMImportExtension,{preprocess:[(n,r,i)=>{w(t.isDOMDocumentNode(n)?n.body:n)&&r.session.update(e.ImportOverlays,e=>[...e,K]),i()}],rules:z})],name:"@lexical/code",nodes:()=>[_,R],register:e=>t.mergeRegister(e.registerCommand(t.KEY_ENTER_COMMAND,e=>{const n=t.$getSelection();return!(!t.$isRangeSelection(n)||!E(n))&&(null!==e&&e.preventDefault(),!0)},t.COMMAND_PRIORITY_LOW),e.registerNodeTransform(t.TabNode,e=>{0!==e.getFormat()&&x(e.getParent())&&e.setFormat(0)}))}),J=/* @__PURE__ */t.defineExtension({dependencies:[j],name:"@lexical/code/Import"});function q(e){if(!t.$isRangeSelection(e))return!1;const n=e.anchor.getNode(),r=x(n)?n:n.getParent(),i=e.focus.getNode(),o=x(i)?i:i.getParent();return x(r)&&r.is(o)}function V(e){const n=e.getNodes(),r=[];if(1===n.length&&x(n[0]))return r;let o=[];for(let e=0;e<n.length;e++){const s=n[e];y(s)||t.$isTabNode(s)||t.$isLineBreakNode(s)||i(169),t.$isLineBreakNode(s)?o.length>0&&(r.push(o),o=[]):o.push(s)}if(o.length>0){const n=e.isBackward()?e.anchor:e.focus,i=t.$createPoint(o[0].getKey(),0,"text");n.is(i)||r.push(o)}return r}function G(e,n){const r=t.$getSelection();if(!t.$isRangeSelection(r)||!q(r))return!1;const i=V(r),o=i.length;if(0===o&&r.isCollapsed())return e===t.INDENT_CONTENT_COMMAND&&r.insertNodes([t.$createTabNode()]),!0;if(0===o&&e===t.INDENT_CONTENT_COMMAND&&"\n"===r.getTextContent()){const e=t.$createTabNode(),n=t.$createLineBreakNode(),i=r.isBackward()?"previous":"next";return r.insertNodes([e,n]),t.$setSelectionFromCaretRange(t.$getCaretRangeInDirection(t.$getCaretRange(t.$getTextPointCaret(e,"next",0),t.$normalizeCaret(t.$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)),e===t.INDENT_CONTENT_COMMAND){const e=t.$createTabNode();if(i.insertBefore(e),0===l){const n=r.isBackward()?"focus":"anchor",o=t.$createPoint(i.getKey(),0,"text");r[n].is(o)&&r[n].set(e.getKey(),0,"text")}}else t.$isTabNode(i)?i.remove():void 0!==n&&y(i)&&g(i,n,r)}}return!0}function Q(e,n){const r=t.$getSelection();if(!t.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,a=i.offset,c=o.offset,u=i.getNode(),g=o.getNode(),d=e===t.KEY_ARROW_UP_COMMAND;if(!q(r)||!y(u)&&!t.$isTabNode(u)||!y(g)&&!t.$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 e=0;e<p.length;e++){const n=p[e];if(!y(n)&&!t.$isTabNode(n)&&!t.$isLineBreakNode(n))return!1}n.preventDefault(),n.stopPropagation();const N=d?f.getPreviousSibling():h.getNextSibling();if(!t.$isLineBreakNode(N))return!0;const m=d?N.getPreviousSibling():N.getNextSibling();if(null==m)return!0;const _=y(m)||t.$isTabNode(m)||t.$isLineBreakNode(m)?d?s(m):l(m):null;let T=null!=_?_:m;return N.remove(),p.forEach(e=>e.remove()),e===t.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(e,n){const r=t.$getSelection();if(!t.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,s=i.getNode(),l=o.getNode(),g=e===t.MOVE_TO_START;if(!q(r)||!y(s)&&!t.$isTabNode(s)||!y(l)&&!t.$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 e=c(d,o.offset);if(null!==e){const{node:n,offset:i}=e;t.$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(e,n,o){return t.mergeRegister(...o?[e.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>!e.altKey&&r.$onEscapeDown(x,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_RIGHT_COMMAND,e=>r.$onEscapeDown(x,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>!e.altKey&&r.$onEscapeUp(x,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_LEFT_COMMAND,e=>r.$onEscapeUp(x,e),t.COMMAND_PRIORITY_LOW)]:[],e.registerCommand(t.KEY_TAB_COMMAND,n=>{const r=function(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!q(n))return null;const r=e?t.OUTDENT_CONTENT_COMMAND:t.INDENT_CONTENT_COMMAND,o=e?t.OUTDENT_CONTENT_COMMAND:t.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=t.$createPoint(h.getKey(),0,"text"),m=t.$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(),e.dispatchCommand(r),!0)},t.COMMAND_PRIORITY_LOW),e.registerCommand(t.INSERT_TAB_COMMAND,()=>!!q(t.$getSelection())&&(t.$insertNodes([t.$createTabNode()]),!0),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.INDENT_CONTENT_COMMAND,()=>G(t.INDENT_CONTENT_COMMAND),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.OUTDENT_CONTENT_COMMAND,()=>G(t.OUTDENT_CONTENT_COMMAND,n),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>{const n=t.$getSelection();if(!t.$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()&&x(o)&&null===o.getPreviousSibling()?(e.preventDefault(),!0):Q(t.KEY_ARROW_UP_COMMAND,e)},t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>{const n=t.$getSelection();if(!t.$isRangeSelection(n))return!1;const{anchor:r}=n,i=r.getNode();return!!q(n)&&(n.isCollapsed()&&r.offset===i.getTextContentSize()&&null===i.getNextSibling()&&x(i.getParentOrThrow())&&null===i.getParentOrThrow().getNextSibling()?(e.preventDefault(),!0):Q(t.KEY_ARROW_DOWN_COMMAND,e))},t.COMMAND_PRIORITY_LOW),e.registerCommand(t.MOVE_TO_START,e=>X(t.MOVE_TO_START,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.MOVE_TO_END,e=>X(t.MOVE_TO_END,e),t.COMMAND_PRIORITY_LOW))}const ee=/* @__PURE__ */t.defineExtension({build:(e,t)=>n.namedSignals(t),config:/* @__PURE__ */t.safeCast({disabled:!1,escapeWithArrows:!1,tabSize:void 0}),dependencies:[j],name:"@lexical/code-indent",register:(e,t,r)=>{const i=r.getOutput();return n.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=y,exports.$isCodeNode=x,exports.$outdentLeadingSpaces=g,exports.$plainifyCodeContent=function(e){const n=[];return t.tokenizeRawText(e,{linebreak:()=>n.push(t.$createLineBreakNode()),tab:()=>n.push(t.$createTabNode()),text:e=>n.push(A(e))}),n},exports.CodeExtension=j,exports.CodeHighlightNode=R,exports.CodeImportExtension=J,exports.CodeImportRules=z,exports.CodeIndentExtension=ee,exports.CodeNode=_,exports.DEFAULT_CODE_LANGUAGE=d,exports.getDefaultCodeLanguage=()=>d,exports.registerCodeIndentation=Z;
@@ -6,5 +6,5 @@
6
6
  *
7
7
  */
8
8
 
9
- import{defineImportRule as e,sel as t,ImportOverlays 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,$create as p,ElementNode as d,$getDocument as m,addClassNamesToElement as x,setDOMStyleFromCSS as S,$getEditor as y,$isTextNode as b,$createParagraphNode as _,isHTMLElement as v,$applyNodeReplacement as C,TextNode as T,removeClassNamesFromElement as N,isDOMDocumentNode as A,isDOMTextNode as P,$generateNodesFromRawText as O,defineExtension as w,mergeRegister as H,KEY_ENTER_COMMAND as $,$getSelection as D,$isRangeSelection as B,COMMAND_PRIORITY_LOW as L,TabNode as k,configExtension as E,safeCast as F,KEY_ARROW_DOWN_COMMAND as M,KEY_ARROW_RIGHT_COMMAND as z,KEY_ARROW_UP_COMMAND as K,KEY_ARROW_LEFT_COMMAND as I,KEY_TAB_COMMAND as j,INSERT_TAB_COMMAND as J,$insertNodes as R,INDENT_CONTENT_COMMAND as W,OUTDENT_CONTENT_COMMAND as q,MOVE_TO_START as U,MOVE_TO_END as V,$createPoint as G,$setSelectionFromCaretRange as Q,$getCaretRangeInDirection as X,$getCaretRange as Y,$getTextPointCaret as Z,$normalizeCaret as ee}from"lexical";import{getPeerDependencyFromEditor as te,effect as ne,namedSignals as re}from"@lexical/extension";import{$onEscapeDown as ie,$onEscapeUp as oe}from"@lexical/utils";
10
- /*@__INLINE__*/function se(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 le(e,t){let n=e;for(let r=h(e,t);r&&(ke(r.origin)||u(r.origin));r=r.getAdjacentCaret())n=r.origin;return n}function ue(e){return le(e,"previous")}function ce(e){return le(e,"next")}function ae(e){const t=ue(e),n=ce(e);let r=t;for(;null!==r;){if(ke(r)){const e=s(r.getTextContent());if(null!==e)return e}if(r===n)break;r=r.getNextSibling()}const i=t.getParent();if(l(i)){const e=i.getDirection();if("ltr"===e||"rtl"===e)return e}return null}function ge(e,t){let n=null,r=null,i=e,o=t,s=e.getTextContent();for(;;){if(0===o){const e=i.getPreviousSibling();if(null===e){i=null;break}if(ke(e)||u(e)||c(e)||se(167),i=e,c(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent()}else o--;const e=s[o];ke(i)&&" "!==e&&(r={node:i,offset:o})}if(null!==r)return r;let l=null;if(t<e.getTextContentSize())ke(e)&&(l=e.getTextContent()[t]);else{const t=e.getNextSibling();ke(t)&&(l=t.getTextContent()[0])}if(null!==l&&" "!==l)return n;{const r=function(e,t){let n=e,r=t,i=e.getTextContent(),o=e.getTextContentSize();for(;;){if(!ke(n)||r===o){if(n=n.getNextSibling(),null===n||c(n))return null;ke(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize())}if(ke(n)){if(" "!==i[r])return{node:n,offset:r};r++}}}(e,t);return null!==r?r:n}}function fe(e){const t=ce(e);return c(t)&&se(168),t}function he(e){const t=[];return a(e,{linebreak:()=>t.push(f()),tab:()=>t.push(g()),text:e=>t.push(Le(e))}),t}function pe(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 de="javascript",me=()=>de;function xe(e,t){for(const n of e.childNodes){if(v(n)&&n.tagName===t)return!0;if(xe(n,t))return!0}return!1}const Se="data-language",ye="data-highlight-language",be="data-theme",_e=()=>{};class ve extends d{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:d,importDOM:{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||xe(e,"BR"))?{conversion:Ne,priority:1}:null,div:()=>({conversion:Ae,priority:1}),pre:()=>({conversion:Ne,priority:0}),table:e=>He(e)?{conversion:Pe,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&He(n)?{conversion:Oe,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&He(t)?{conversion:Oe,priority:3}:null}}})}constructor(e=void 0,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=m().createElement("code");x(t,e.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(Se,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(ye,n));const r=this.getTheme();r&&t.setAttribute(be,r);const i=this.getStyle();return i&&S(t.style,i),t}updateDOM(e,t,n){const r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(Se,r):i&&t.removeAttribute(Se);const o=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&t.setAttribute(ye,r):t.removeAttribute(ye):o&&r&&t.setAttribute(ye,r);const s=this.__theme,l=e.__theme;s?s!==l&&t.setAttribute(be,s):l&&t.removeAttribute(be);const u=this.__style,c=e.__style;return u!==c&&S(t.style,u,c),!1}exportDOM(e){const t=m().createElement("pre");x(t,e._config.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(Se,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(ye,n));const r=this.getTheme();r&&t.setAttribute(be,r);const i=this.getStyle();return i&&S(t.style,i),{element:t}}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(!te(y(),"@lexical/code")){_e();const t=$e(e);if(t)return t}const{anchor:n,focus:r}=e,i=(n.isBefore(r)?n:r).getNode();if(b(i)){let e=ue(i);const t=[];for(;;)if(u(e))t.push(g()),e=e.getNextSibling();else{if(!ke(e))break;{let n=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&t.push(Le(" ".repeat(n))),n!==i)break;e=e.getNextSibling()}}const r=i.splitText(n.offset)[0],o=0===n.offset?0:1,s=r.getIndexWithinParent()+o,l=i.getParentOrThrow(),c=[f(),...t];l.splice(s,0,c);const a=t[t.length-1];a?a.select():0===n.offset?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(Te(i)){const{offset:t}=e.anchor;i.splice(t,0,[f()]),i.select(t+1,t+1)}return null}canIndent(){return!1}collapseAtStart(){const e=_();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 Ce(e,t){return p(ve).setLanguage(e).setTheme(t)}function Te(e){return e instanceof ve}function Ne(e){return{node:Ce(e.getAttribute(Se))}}function Ae(e){const t=e,n=we(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if(we(t))return!0;t=t.parentElement}return!1}(t)?{node:n?Ce():null}:{node:null}}function Pe(){return{node:Ce()}}function Oe(){return{node:null}}function we(e){return null!==e.style.fontFamily.match("monospace")}function He(e){return e.classList.contains("js-file-line-container")}function $e(e){const{anchor:t}=e;if(e.isCollapsed()&&"element"===t.type){const e=t.getNode();if(Te(e)){const n=e.getChildrenSize();if(n>=2&&t.offset===n){const t=e.getLastChild();if(c(t)&&c(t.getPreviousSibling())){const t=_();return e.splice(n-2,2,[]).insertAfter(t,!1),t.select(),t}}}}return null}class De extends T{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}$config(){return this.config("code-highlight",{extends:T})}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=Be(e.theme,this.__highlightType);return x(t,n),t}updateDOM(e,t,n){const r=super.updateDOM(e,t,n),i=Be(n.theme,e.__highlightType),o=Be(n.theme,this.__highlightType);return i!==o&&(i&&N(t,i),o&&x(t,o)),r}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 Ce()}}function Be(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function Le(e="",t){return C(new De(e,t))}function ke(e){return e instanceof De}const Ee="data-language";function Fe(e){return null!==e.style.fontFamily.match("monospace")}function Me(e){let t=e.parentElement;for(;null!==t;){if(Fe(t))return!0;t=t.parentElement}return!1}const ze=/* @__PURE__ */r([/* @__PURE__ */e({$import:(e,t)=>e.$importChildren(t),match:t.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),Ke=/* @__PURE__ */e({$import:(e,t)=>[Ce(t.getAttribute(Ee)).splice(0,0,e.$importChildren(t))],match:t.tag("pre"),name:"@lexical/code/pre"}),Ie=/* @__PURE__ */e({$import:(e,t,n)=>{const r=t.textContent||"";return/\r?\n/.test(r)||null!==t.querySelector("br")?[Ce(t.getAttribute(Ee)).splice(0,0,e.$importChildren(t))]:n()},match:t.tag("code"),name:"@lexical/code/code-multiline"});function je(e){if(!v(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 Je(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(v(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(P(s)){const e=s.textContent||"";e.length>0&&(r+=e,i=!0)}return o(),t?n:null}function Re(e){for(const t of Array.from(e.children)){if(v(t)&&je(t)){if(null!==Je(t))return!0;const e=t.nextElementSibling;if(e&&je(e))return!0;continue}if(Re(t))return!0}return!1}const We=/* @__PURE__ */r([/* @__PURE__ */e({$import:(e,t,n)=>{if(!je(t)||Me(t))return n();const r=Je(t);return null===r||0===r.length?n():[Ce().splice(0,0,O(r.join("\n")))]},match:t.tag("div"),name:"@lexical/code/vscode-wrapper"}),/* @__PURE__ */e({$import:(e,t,n)=>{if(!je(t)||Me(t))return n();const r=t.previousElementSibling;if(r&&je(r))return[];const i=[];let o=t;for(;o&&je(o);)i.push("BR"===o.tagName?"":o.textContent||""),o=o.nextElementSibling;return i.length<2?n():[Ce().splice(0,0,O(i.join("\n")))]},match:t.tag("div","br"),name:"@lexical/code/vscode-line-run"})]),qe=/* @__PURE__ */e({$import:(e,t,n)=>Fe(t)?[Ce().splice(0,0,e.$importChildren(t))]:Me(t)?e.$importChildren(t):n(),match:t.tag("div"),name:"@lexical/code/div"}),Ue=[/* @__PURE__ */e({$import:(e,t)=>[Ce().splice(0,0,e.$importChildren(t,{rules:ze}))],match:t.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"}),/* @__PURE__ */e({$import:(e,t)=>e.$importChildren(t),match:t.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"}),Ie,Ke,qe],Ve=/* @__PURE__ */w({dependencies:[i,/* @__PURE__ */E(o,{preprocess:[(e,t,r)=>{Re(A(e)?e.body:e)&&t.session.update(n,e=>[...e,We]),r()}],rules:Ue})],name:"@lexical/code",nodes:()=>[ve,De],register:e=>H(e.registerCommand($,e=>{const t=D();return!(!B(t)||!$e(t))&&(e.preventDefault(),!0)},L),e.registerNodeTransform(k,e=>{0!==e.getFormat()&&Te(e.getParent())&&e.setFormat(0)}))}),Ge=/* @__PURE__ */w({dependencies:[Ve],name:"@lexical/code/Import"});function Qe(e){if(!B(e))return!1;const t=e.anchor.getNode(),n=Te(t)?t:t.getParent(),r=e.focus.getNode(),i=Te(r)?r:r.getParent();return Te(n)&&n.is(i)}function Xe(e){const t=e.getNodes(),n=[];if(1===t.length&&Te(t[0]))return n;let r=[];for(let e=0;e<t.length;e++){const i=t[e];ke(i)||u(i)||c(i)||se(169),c(i)?r.length>0&&(n.push(r),r=[]):r.push(i)}if(r.length>0){const t=e.isBackward()?e.anchor:e.focus,i=G(r[0].getKey(),0,"text");t.is(i)||n.push(r)}return n}function Ye(e,t){const n=D();if(!B(n)||!Qe(n))return!1;const r=Xe(n),i=r.length;if(0===i&&n.isCollapsed())return e===W&&n.insertNodes([g()]),!0;if(0===i&&e===W&&"\n"===n.getTextContent()){const e=g(),t=f(),r=n.isBackward()?"previous":"next";return n.insertNodes([e,t]),Q(X(Y(Z(e,"next",0),ee(h(t,"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=ue(r)),e===W){const e=g();if(r.insertBefore(e),0===o){const t=n.isBackward()?"focus":"anchor",i=G(r.getKey(),0,"text");n[t].is(i)&&n[t].set(e.getKey(),0,"text")}}else u(r)?r.remove():void 0!==t&&ke(r)&&pe(r,t,n)}}return!0}function Ze(e,t){const n=D();if(!B(n))return!1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,l=r.getNode(),a=i.getNode(),g=e===K;if(!Qe(n)||!ke(l)&&!u(l)||!ke(a)&&!u(a))return!1;if(!t.altKey){if(n.isCollapsed()){const e=l.getParentOrThrow();if(g&&0===o&&null===l.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),t.preventDefault(),!1}else if(!g&&o===l.getTextContentSize()&&null===l.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),t.preventDefault(),!1}}return!1}let f,h;if(l.isBefore(a)?(f=ue(l),h=ce(a)):(f=ue(a),h=ce(l)),null==f||null==h)return!1;const p=f.getNodesBetween(h);for(let e=0;e<p.length;e++){const t=p[e];if(!ke(t)&&!u(t)&&!c(t))return!1}t.preventDefault(),t.stopPropagation();const d=g?f.getPreviousSibling():h.getNextSibling();if(!c(d))return!0;const m=g?d.getPreviousSibling():d.getNextSibling();if(null==m)return!0;const x=ke(m)||u(m)||c(m)?g?ue(m):ce(m):null;let S=null!=x?x:m;return d.remove(),p.forEach(e=>e.remove()),e===K?(p.forEach(e=>S.insertBefore(e)),S.insertBefore(d)):(S.insertAfter(d),S=d,p.forEach(e=>{S.insertAfter(e),S=e})),n.setTextNodeRange(l,o,a,s),!0}function et(e,t){const n=D();if(!B(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),l=e===U;if(!Qe(n)||!ke(o)&&!u(o)||!ke(s)&&!u(s))return!1;const a=s,g="rtl"===ae(a)?!l:l,f=r.key,h=r.offset,p=r.type;if(g){const e=ge(a,i.offset);if(null!==e){const{node:t,offset:r}=e;c(t)?t.selectNext(0,0):n.setTextNodeRange(t,r,t,r)}else a.getParentOrThrow().selectStart()}else{fe(a).select()}return t.shiftKey&&n.anchor.set(f,h,p),t.preventDefault(),t.stopPropagation(),!0}function tt(e,t,n){return H(...n?[e.registerCommand(M,e=>!e.altKey&&ie(Te,e),L),e.registerCommand(z,e=>ie(Te,e),L),e.registerCommand(K,e=>!e.altKey&&oe(Te,e),L),e.registerCommand(I,e=>oe(Te,e),L)]:[],e.registerCommand(j,t=>{const n=function(e){const t=D();if(!B(t)||!Qe(t))return null;const n=e?q:W,r=e?q:J,i=t.anchor,o=t.focus;if(i.is(o))return r;const s=Xe(t);if(1!==s.length)return n;const l=s[0];let u,c;0===l.length&&se(285),t.isBackward()?(u=o,c=i):(u=i,c=o);const a=ue(l[0]),g=ce(l[0]),f=G(a.getKey(),0,"text"),h=G(g.getKey(),g.getTextContentSize(),"text");return u.isBefore(f)||h.isBefore(c)?n:f.isBefore(u)||c.isBefore(h)?r:n}(t.shiftKey);return null!==n&&(t.preventDefault(),e.dispatchCommand(n,void 0),!0)},L),e.registerCommand(J,()=>!!Qe(D())&&(R([g()]),!0),L),e.registerCommand(W,()=>Ye(W),L),e.registerCommand(q,()=>Ye(q,t),L),e.registerCommand(K,e=>{const t=D();if(!B(t))return!1;const{anchor:n}=t,r=n.getNode();if(!Qe(t))return!1;const i=r.getParent();return t.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&Te(i)&&null===i.getPreviousSibling()?(e.preventDefault(),!0):Ze(K,e)},L),e.registerCommand(M,e=>{const t=D();if(!B(t))return!1;const{anchor:n}=t,r=n.getNode();return!!Qe(t)&&(t.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&Te(r.getParentOrThrow())&&null===r.getParentOrThrow().getNextSibling()?(e.preventDefault(),!0):Ze(M,e))},L),e.registerCommand(U,e=>et(U,e),L),e.registerCommand(V,e=>et(V,e),L))}const nt=/* @__PURE__ */w({build:(e,t)=>re(t),config:/* @__PURE__ */F({disabled:!1,escapeWithArrows:!1,tabSize:void 0}),dependencies:[Ve],name:"@lexical/code-indent",register:(e,t,n)=>{const r=n.getOutput();return ne(()=>{if(!r.disabled.value)return tt(e,r.tabSize.value,r.escapeWithArrows.value)})}});export{Le as $createCodeHighlightNode,Ce as $createCodeNode,ae as $getCodeLineDirection,fe as $getEndOfCodeInLine,ue as $getFirstCodeNodeOfLine,ce as $getLastCodeNodeOfLine,ge as $getStartOfCodeInLine,ke as $isCodeHighlightNode,Te as $isCodeNode,pe as $outdentLeadingSpaces,he as $plainifyCodeContent,Ve as CodeExtension,De as CodeHighlightNode,Ge as CodeImportExtension,Ue as CodeImportRules,nt as CodeIndentExtension,ve as CodeNode,de as DEFAULT_CODE_LANGUAGE,me as getDefaultCodeLanguage,tt as registerCodeIndentation};
9
+ import{defineImportRule as e,sel as t,ImportOverlays 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,$create as p,ElementNode as d,$getDocument as m,addClassNamesToElement as x,setDOMStyleFromCSS as S,$getEditor as y,$isTextNode as b,$createParagraphNode as _,isHTMLElement as C,$applyNodeReplacement as v,TextNode as T,removeClassNamesFromElement as N,isDOMDocumentNode as A,isDOMTextNode as P,$generateNodesFromRawText as O,defineExtension as w,mergeRegister as H,KEY_ENTER_COMMAND as $,$getSelection as D,$isRangeSelection as B,COMMAND_PRIORITY_LOW as L,TabNode as k,configExtension as E,safeCast as F,KEY_ARROW_DOWN_COMMAND as M,KEY_ARROW_RIGHT_COMMAND as z,KEY_ARROW_UP_COMMAND as K,KEY_ARROW_LEFT_COMMAND as I,KEY_TAB_COMMAND as j,INSERT_TAB_COMMAND as J,$insertNodes as R,INDENT_CONTENT_COMMAND as W,OUTDENT_CONTENT_COMMAND as q,MOVE_TO_START as U,MOVE_TO_END as V,$createPoint as G,$setSelectionFromCaretRange as Q,$getCaretRangeInDirection as X,$getCaretRange as Y,$getTextPointCaret as Z,$normalizeCaret as ee}from"lexical";import{getPeerDependencyFromEditor as te,effect as ne,namedSignals as re}from"@lexical/extension";import{$onEscapeDown as ie,$onEscapeUp as oe}from"@lexical/utils";
10
+ /*@__INLINE__*/function se(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 le(e,t){let n=e;for(let r=h(e,t);r&&(ke(r.origin)||u(r.origin));r=r.getAdjacentCaret())n=r.origin;return n}function ue(e){return le(e,"previous")}function ce(e){return le(e,"next")}function ae(e){const t=ue(e),n=ce(e);let r=t;for(;null!==r;){if(ke(r)){const e=s(r.getTextContent());if(null!==e)return e}if(r===n)break;r=r.getNextSibling()}const i=t.getParent();if(l(i)){const e=i.getDirection();if("ltr"===e||"rtl"===e)return e}return null}function ge(e,t){let n=null,r=null,i=e,o=t,s=e.getTextContent();for(;;){if(0===o){const e=i.getPreviousSibling();if(null===e){i=null;break}if(ke(e)||u(e)||c(e)||se(167),i=e,c(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent()}else o--;const e=s[o];ke(i)&&" "!==e&&(r={node:i,offset:o})}if(null!==r)return r;let l=null;if(t<e.getTextContentSize())ke(e)&&(l=e.getTextContent()[t]);else{const t=e.getNextSibling();ke(t)&&(l=t.getTextContent()[0])}if(null!==l&&" "!==l)return n;{const r=function(e,t){let n=e,r=t,i=e.getTextContent(),o=e.getTextContentSize();for(;;){if(!ke(n)||r===o){if(n=n.getNextSibling(),null===n||c(n))return null;ke(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize())}if(ke(n)){if(" "!==i[r])return{node:n,offset:r};r++}}}(e,t);return null!==r?r:n}}function fe(e){const t=ce(e);return c(t)&&se(168),t}function he(e){const t=[];return a(e,{linebreak:()=>t.push(f()),tab:()=>t.push(g()),text:e=>t.push(Le(e))}),t}function pe(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 de="javascript",me=()=>de;function xe(e,t){for(const n of e.childNodes){if(C(n)&&n.tagName===t)return!0;if(xe(n,t))return!0}return!1}const Se="data-language",ye="data-highlight-language",be="data-theme",_e=()=>{};class Ce extends d{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:d,importDOM:{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||xe(e,"BR"))?{conversion:Ne,priority:1}:null,div:()=>({conversion:Ae,priority:1}),pre:()=>({conversion:Ne,priority:0}),table:e=>He(e)?{conversion:Pe,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&He(n)?{conversion:Oe,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&He(t)?{conversion:Oe,priority:3}:null}}})}constructor(e=void 0,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=m().createElement("code");x(t,e.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(Se,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(ye,n));const r=this.getTheme();r&&t.setAttribute(be,r);const i=this.getStyle();return i&&S(t.style,i),t}updateDOM(e,t,n){const r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(Se,r):i&&t.removeAttribute(Se);const o=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&t.setAttribute(ye,r):t.removeAttribute(ye):o&&r&&t.setAttribute(ye,r);const s=this.__theme,l=e.__theme;s?s!==l&&t.setAttribute(be,s):l&&t.removeAttribute(be);const u=this.__style,c=e.__style;return u!==c&&S(t.style,u,c),!1}exportDOM(e){const t=m().createElement("pre");x(t,e._config.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(Se,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(ye,n));const r=this.getTheme();r&&t.setAttribute(be,r);const i=this.getStyle();return i&&S(t.style,i),{element:t}}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(!te(y(),"@lexical/code")){_e();const t=$e(e);if(t)return t}const{anchor:n,focus:r}=e,i=(n.isBefore(r)?n:r).getNode();if(b(i)){let e=ue(i);const t=[];for(;;)if(u(e))t.push(g()),e=e.getNextSibling();else{if(!ke(e))break;{let n=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&t.push(Le(" ".repeat(n))),n!==i)break;e=e.getNextSibling()}}const r=i.splitText(n.offset)[0],o=0===n.offset?0:1,s=r.getIndexWithinParent()+o,l=i.getParentOrThrow(),c=[f(),...t];l.splice(s,0,c);const a=t[t.length-1];a?a.select():0===n.offset?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(Te(i)){const{offset:t}=e.anchor;i.splice(t,0,[f()]),i.select(t+1,t+1)}return null}canIndent(){return!1}collapseAtStart(){const e=_();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 ve(e,t){return p(Ce).setLanguage(e).setTheme(t)}function Te(e){return e instanceof Ce}function Ne(e){return{node:ve(e.getAttribute(Se))}}function Ae(e){const t=e,n=we(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if(we(t))return!0;t=t.parentElement}return!1}(t)?{node:n?ve():null}:{node:null}}function Pe(){return{node:ve()}}function Oe(){return{node:null}}function we(e){return null!==e.style.fontFamily.match("monospace")}function He(e){return e.classList.contains("js-file-line-container")}function $e(e){const{anchor:t}=e;if(e.isCollapsed()&&"element"===t.type){const e=t.getNode();if(Te(e)){const n=e.getChildrenSize();if(n>=2&&t.offset===n){const t=e.getLastChild();if(c(t)&&c(t.getPreviousSibling())){const t=_();return e.splice(n-2,2,[]).insertAfter(t,!1),t.select(),t}}}}return null}class De extends T{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}$config(){return this.config("code-highlight",{extends:T})}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=Be(e.theme,this.__highlightType);return x(t,n),t}updateDOM(e,t,n){const r=super.updateDOM(e,t,n),i=Be(n.theme,e.__highlightType),o=Be(n.theme,this.__highlightType);return i!==o&&(i&&N(t,i),o&&x(t,o)),r}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 ve()}}function Be(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function Le(e="",t){return v(new De(e,t))}function ke(e){return e instanceof De}const Ee="data-language";function Fe(e){return null!==e.style.fontFamily.match("monospace")}function Me(e){let t=e.parentElement;for(;null!==t;){if(Fe(t))return!0;t=t.parentElement}return!1}const ze=/* @__PURE__ */r([/* @__PURE__ */e({$import:(e,t)=>e.$importChildren(t),match:t.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),Ke=/* @__PURE__ */e({$import:(e,t)=>[ve(t.getAttribute(Ee)).splice(0,0,e.$importChildren(t))],match:t.tag("pre"),name:"@lexical/code/pre"}),Ie=/* @__PURE__ */e({$import:(e,t,n)=>{const r=t.textContent||"";return/\r?\n/.test(r)||null!==t.querySelector("br")?[ve(t.getAttribute(Ee)).splice(0,0,e.$importChildren(t))]:n()},match:t.tag("code"),name:"@lexical/code/code-multiline"});function je(e){if(!C(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 Je(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(C(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(P(s)){const e=s.textContent||"";e.length>0&&(r+=e,i=!0)}return o(),t?n:null}function Re(e){for(const t of Array.from(e.children)){if(C(t)&&je(t)){if(null!==Je(t))return!0;const e=t.nextElementSibling;if(e&&je(e))return!0;continue}if(Re(t))return!0}return!1}const We=/* @__PURE__ */r([/* @__PURE__ */e({$import:(e,t,n)=>{if(!je(t)||Me(t))return n();const r=Je(t);return null===r||0===r.length?n():[ve().splice(0,0,O(r.join("\n")))]},match:t.tag("div"),name:"@lexical/code/vscode-wrapper"}),/* @__PURE__ */e({$import:(e,t,n)=>{if(!je(t)||Me(t))return n();const r=t.previousElementSibling;if(r&&je(r))return[];const i=[];let o=t;for(;o&&je(o);)i.push("BR"===o.tagName?"":o.textContent||""),o=o.nextElementSibling;return i.length<2?n():[ve().splice(0,0,O(i.join("\n")))]},match:t.tag("div","br"),name:"@lexical/code/vscode-line-run"})]),qe=/* @__PURE__ */e({$import:(e,t,n)=>Fe(t)?[ve().splice(0,0,e.$importChildren(t))]:Me(t)?e.$importChildren(t):n(),match:t.tag("div"),name:"@lexical/code/div"}),Ue=[/* @__PURE__ */e({$import:(e,t)=>[ve().splice(0,0,e.$importChildren(t,{rules:ze}))],match:t.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"}),/* @__PURE__ */e({$import:(e,t)=>e.$importChildren(t),match:t.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"}),Ie,Ke,qe],Ve=/* @__PURE__ */w({dependencies:[i,/* @__PURE__ */E(o,{preprocess:[(e,t,r)=>{Re(A(e)?e.body:e)&&t.session.update(n,e=>[...e,We]),r()}],rules:Ue})],name:"@lexical/code",nodes:()=>[Ce,De],register:e=>H(e.registerCommand($,e=>{const t=D();return!(!B(t)||!$e(t))&&(null!==e&&e.preventDefault(),!0)},L),e.registerNodeTransform(k,e=>{0!==e.getFormat()&&Te(e.getParent())&&e.setFormat(0)}))}),Ge=/* @__PURE__ */w({dependencies:[Ve],name:"@lexical/code/Import"});function Qe(e){if(!B(e))return!1;const t=e.anchor.getNode(),n=Te(t)?t:t.getParent(),r=e.focus.getNode(),i=Te(r)?r:r.getParent();return Te(n)&&n.is(i)}function Xe(e){const t=e.getNodes(),n=[];if(1===t.length&&Te(t[0]))return n;let r=[];for(let e=0;e<t.length;e++){const i=t[e];ke(i)||u(i)||c(i)||se(169),c(i)?r.length>0&&(n.push(r),r=[]):r.push(i)}if(r.length>0){const t=e.isBackward()?e.anchor:e.focus,i=G(r[0].getKey(),0,"text");t.is(i)||n.push(r)}return n}function Ye(e,t){const n=D();if(!B(n)||!Qe(n))return!1;const r=Xe(n),i=r.length;if(0===i&&n.isCollapsed())return e===W&&n.insertNodes([g()]),!0;if(0===i&&e===W&&"\n"===n.getTextContent()){const e=g(),t=f(),r=n.isBackward()?"previous":"next";return n.insertNodes([e,t]),Q(X(Y(Z(e,"next",0),ee(h(t,"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=ue(r)),e===W){const e=g();if(r.insertBefore(e),0===o){const t=n.isBackward()?"focus":"anchor",i=G(r.getKey(),0,"text");n[t].is(i)&&n[t].set(e.getKey(),0,"text")}}else u(r)?r.remove():void 0!==t&&ke(r)&&pe(r,t,n)}}return!0}function Ze(e,t){const n=D();if(!B(n))return!1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,l=r.getNode(),a=i.getNode(),g=e===K;if(!Qe(n)||!ke(l)&&!u(l)||!ke(a)&&!u(a))return!1;if(!t.altKey){if(n.isCollapsed()){const e=l.getParentOrThrow();if(g&&0===o&&null===l.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),t.preventDefault(),!1}else if(!g&&o===l.getTextContentSize()&&null===l.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),t.preventDefault(),!1}}return!1}let f,h;if(l.isBefore(a)?(f=ue(l),h=ce(a)):(f=ue(a),h=ce(l)),null==f||null==h)return!1;const p=f.getNodesBetween(h);for(let e=0;e<p.length;e++){const t=p[e];if(!ke(t)&&!u(t)&&!c(t))return!1}t.preventDefault(),t.stopPropagation();const d=g?f.getPreviousSibling():h.getNextSibling();if(!c(d))return!0;const m=g?d.getPreviousSibling():d.getNextSibling();if(null==m)return!0;const x=ke(m)||u(m)||c(m)?g?ue(m):ce(m):null;let S=null!=x?x:m;return d.remove(),p.forEach(e=>e.remove()),e===K?(p.forEach(e=>S.insertBefore(e)),S.insertBefore(d)):(S.insertAfter(d),S=d,p.forEach(e=>{S.insertAfter(e),S=e})),n.setTextNodeRange(l,o,a,s),!0}function et(e,t){const n=D();if(!B(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),l=e===U;if(!Qe(n)||!ke(o)&&!u(o)||!ke(s)&&!u(s))return!1;const a=s,g="rtl"===ae(a)?!l:l,f=r.key,h=r.offset,p=r.type;if(g){const e=ge(a,i.offset);if(null!==e){const{node:t,offset:r}=e;c(t)?t.selectNext(0,0):n.setTextNodeRange(t,r,t,r)}else a.getParentOrThrow().selectStart()}else{fe(a).select()}return t.shiftKey&&n.anchor.set(f,h,p),t.preventDefault(),t.stopPropagation(),!0}function tt(e,t,n){return H(...n?[e.registerCommand(M,e=>!e.altKey&&ie(Te,e),L),e.registerCommand(z,e=>ie(Te,e),L),e.registerCommand(K,e=>!e.altKey&&oe(Te,e),L),e.registerCommand(I,e=>oe(Te,e),L)]:[],e.registerCommand(j,t=>{const n=function(e){const t=D();if(!B(t)||!Qe(t))return null;const n=e?q:W,r=e?q:J,i=t.anchor,o=t.focus;if(i.is(o))return r;const s=Xe(t);if(1!==s.length)return n;const l=s[0];let u,c;0===l.length&&se(285),t.isBackward()?(u=o,c=i):(u=i,c=o);const a=ue(l[0]),g=ce(l[0]),f=G(a.getKey(),0,"text"),h=G(g.getKey(),g.getTextContentSize(),"text");return u.isBefore(f)||h.isBefore(c)?n:f.isBefore(u)||c.isBefore(h)?r:n}(t.shiftKey);return null!==n&&(t.preventDefault(),e.dispatchCommand(n),!0)},L),e.registerCommand(J,()=>!!Qe(D())&&(R([g()]),!0),L),e.registerCommand(W,()=>Ye(W),L),e.registerCommand(q,()=>Ye(q,t),L),e.registerCommand(K,e=>{const t=D();if(!B(t))return!1;const{anchor:n}=t,r=n.getNode();if(!Qe(t))return!1;const i=r.getParent();return t.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&Te(i)&&null===i.getPreviousSibling()?(e.preventDefault(),!0):Ze(K,e)},L),e.registerCommand(M,e=>{const t=D();if(!B(t))return!1;const{anchor:n}=t,r=n.getNode();return!!Qe(t)&&(t.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&Te(r.getParentOrThrow())&&null===r.getParentOrThrow().getNextSibling()?(e.preventDefault(),!0):Ze(M,e))},L),e.registerCommand(U,e=>et(U,e),L),e.registerCommand(V,e=>et(V,e),L))}const nt=/* @__PURE__ */w({build:(e,t)=>re(t),config:/* @__PURE__ */F({disabled:!1,escapeWithArrows:!1,tabSize:void 0}),dependencies:[Ve],name:"@lexical/code-indent",register:(e,t,n)=>{const r=n.getOutput();return ne(()=>{if(!r.disabled.value)return tt(e,r.tabSize.value,r.escapeWithArrows.value)})}});export{Le as $createCodeHighlightNode,ve as $createCodeNode,ae as $getCodeLineDirection,fe as $getEndOfCodeInLine,ue as $getFirstCodeNodeOfLine,ce as $getLastCodeNodeOfLine,ge as $getStartOfCodeInLine,ke as $isCodeHighlightNode,Te as $isCodeNode,pe as $outdentLeadingSpaces,he as $plainifyCodeContent,Ve as CodeExtension,De as CodeHighlightNode,Ge as CodeImportExtension,Ue as CodeImportRules,nt as CodeIndentExtension,Ce as CodeNode,de as DEFAULT_CODE_LANGUAGE,me as getDefaultCodeLanguage,tt as registerCodeIndentation};
package/package.json CHANGED
@@ -8,15 +8,15 @@
8
8
  "code"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.48.1-nightly.20260724.0",
11
+ "version": "0.48.1-nightly.20260727.0",
12
12
  "main": "./dist/LexicalCodeCore.js",
13
13
  "types": "./dist/typescript-too-old.d.ts",
14
14
  "dependencies": {
15
- "@lexical/html": "0.48.1-nightly.20260724.0",
16
- "@lexical/internal": "0.48.1-nightly.20260724.0",
17
- "@lexical/extension": "0.48.1-nightly.20260724.0",
18
- "lexical": "0.48.1-nightly.20260724.0",
19
- "@lexical/utils": "0.48.1-nightly.20260724.0"
15
+ "@lexical/extension": "0.48.1-nightly.20260727.0",
16
+ "@lexical/internal": "0.48.1-nightly.20260727.0",
17
+ "@lexical/utils": "0.48.1-nightly.20260727.0",
18
+ "lexical": "0.48.1-nightly.20260727.0",
19
+ "@lexical/html": "0.48.1-nightly.20260727.0"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -43,12 +43,14 @@ export const CodeExtension = /* @__PURE__ */ defineExtension({
43
43
  nodes: () => [CodeNode, CodeHighlightNode],
44
44
  register(editor) {
45
45
  return mergeRegister(
46
- editor.registerCommand<KeyboardEvent>(
46
+ editor.registerCommand(
47
47
  KEY_ENTER_COMMAND,
48
48
  event => {
49
49
  const selection = $getSelection();
50
50
  if ($isRangeSelection(selection) && $exitCodeNodeOnEnter(selection)) {
51
- event.preventDefault();
51
+ if (event !== null) {
52
+ event.preventDefault();
53
+ }
52
54
  return true;
53
55
  }
54
56
  return false;
@@ -542,7 +542,7 @@ export function registerCodeIndentation(
542
542
  return false;
543
543
  }
544
544
  event.preventDefault();
545
- editor.dispatchCommand(command, undefined);
545
+ editor.dispatchCommand(command);
546
546
  return true;
547
547
  },
548
548
  COMMAND_PRIORITY_LOW,