@lexical/code-core 0.46.1-nightly.20260706.0 → 0.46.1-nightly.20260708.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.
@@ -5,8 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { EditorConfig, LexicalNode, LexicalUpdateJSON, NodeKey, SerializedTextNode, Spread } from 'lexical';
9
- import { ElementNode, TextNode } from 'lexical';
8
+ import { type EditorConfig, type ElementNode, type LexicalNode, type LexicalUpdateJSON, type NodeKey, type SerializedTextNode, type Spread, TextNode } from 'lexical';
10
9
  type SerializedCodeHighlightNode = Spread<{
11
10
  highlightType: string | null | undefined;
12
11
  }, SerializedTextNode>;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { DOMPreprocessFn } from '@lexical/html';
8
+ import { type DOMPreprocessFn } from '@lexical/html';
9
9
  /**
10
10
  * VS Code → browser code-block pastes ship the block as either:
11
11
  *
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { LexicalEditor } from 'lexical';
8
+ import { type LexicalEditor } from 'lexical';
9
9
  /**
10
10
  * @internal
11
11
  * Register the keyboard and command handlers that drive code-block
@@ -5,8 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, LexicalUpdateJSON, NodeKey, ParagraphNode, RangeSelection, SerializedElementNode, Spread, TabNode } from 'lexical';
9
- import { ElementNode } from 'lexical';
8
+ import { type DOMConversionMap, type DOMExportOutput, type EditorConfig, ElementNode, type LexicalEditor, type LexicalNode, type LexicalUpdateJSON, type NodeKey, type ParagraphNode, type RangeSelection, type SerializedElementNode, type Spread, type TabNode } from 'lexical';
10
9
  import { type CodeHighlightNode } from './CodeHighlightNode';
11
10
  export type SerializedCodeNode = Spread<{
12
11
  language: string | null | undefined;
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { CodeHighlightNode } from './CodeHighlightNode';
9
- import type { LexicalNode, LineBreakNode, RangeSelection, TabNode } from 'lexical';
8
+ import { type LexicalNode, type LineBreakNode, type RangeSelection, type TabNode } from 'lexical';
9
+ import { type CodeHighlightNode } from './CodeHighlightNode';
10
10
  export declare function $getFirstCodeNodeOfLine(anchor: CodeHighlightNode | TabNode | LineBreakNode): CodeHighlightNode | TabNode | LineBreakNode;
11
11
  export declare function $getLastCodeNodeOfLine(anchor: CodeHighlightNode | TabNode | LineBreakNode): CodeHighlightNode | TabNode | LineBreakNode;
12
12
  /**
@@ -310,7 +310,7 @@ class CodeNode extends lexical.ElementNode {
310
310
 
311
311
  // View
312
312
  createDOM(config) {
313
- const element = document.createElement('code');
313
+ const element = lexical.$getDocument().createElement('code');
314
314
  lexical.addClassNamesToElement(element, config.theme.code);
315
315
  element.setAttribute('spellcheck', 'false');
316
316
  const language = this.getLanguage();
@@ -370,7 +370,7 @@ class CodeNode extends lexical.ElementNode {
370
370
  return false;
371
371
  }
372
372
  exportDOM(editor) {
373
- const element = document.createElement('pre');
373
+ const element = lexical.$getDocument().createElement('pre');
374
374
  lexical.addClassNamesToElement(element, editor._config.theme.code);
375
375
  element.setAttribute('spellcheck', 'false');
376
376
  const language = this.getLanguage();
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { defineImportRule, sel, ImportOverlays, defineOverlayRules, CoreImportExtension, DOMImportExtension } from '@lexical/html';
10
- import { getTextDirection, $isElementNode, $isTabNode, $isLineBreakNode, tokenizeRawText, $createTabNode, $createLineBreakNode, $getSiblingCaret, $create, ElementNode, addClassNamesToElement, setDOMStyleFromCSS, $getEditor, $isTextNode, $createParagraphNode, isHTMLElement, $applyNodeReplacement, TextNode, removeClassNamesFromElement, isDOMDocumentNode, isDOMTextNode, $generateNodesFromRawText, defineExtension, mergeRegister, KEY_ENTER_COMMAND, $getSelection, $isRangeSelection, COMMAND_PRIORITY_LOW, TabNode, configExtension, safeCast, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_TAB_COMMAND, INSERT_TAB_COMMAND, $insertNodes, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, MOVE_TO_START, MOVE_TO_END, $createPoint, $setSelectionFromCaretRange, $getCaretRangeInDirection, $getCaretRange, $getTextPointCaret, $normalizeCaret } from 'lexical';
10
+ import { getTextDirection, $isElementNode, $isTabNode, $isLineBreakNode, tokenizeRawText, $createTabNode, $createLineBreakNode, $getSiblingCaret, $create, ElementNode, $getDocument, addClassNamesToElement, setDOMStyleFromCSS, $getEditor, $isTextNode, $createParagraphNode, isHTMLElement, $applyNodeReplacement, TextNode, removeClassNamesFromElement, isDOMDocumentNode, isDOMTextNode, $generateNodesFromRawText, defineExtension, mergeRegister, KEY_ENTER_COMMAND, $getSelection, $isRangeSelection, COMMAND_PRIORITY_LOW, TabNode, configExtension, safeCast, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_TAB_COMMAND, INSERT_TAB_COMMAND, $insertNodes, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, MOVE_TO_START, MOVE_TO_END, $createPoint, $setSelectionFromCaretRange, $getCaretRangeInDirection, $getCaretRange, $getTextPointCaret, $normalizeCaret } from 'lexical';
11
11
  import { getPeerDependencyFromEditor, effect, namedSignals } from '@lexical/extension';
12
12
  import { $onEscapeDown, $onEscapeUp } from '@lexical/utils';
13
13
 
@@ -308,7 +308,7 @@ class CodeNode extends ElementNode {
308
308
 
309
309
  // View
310
310
  createDOM(config) {
311
- const element = document.createElement('code');
311
+ const element = $getDocument().createElement('code');
312
312
  addClassNamesToElement(element, config.theme.code);
313
313
  element.setAttribute('spellcheck', 'false');
314
314
  const language = this.getLanguage();
@@ -368,7 +368,7 @@ class CodeNode extends ElementNode {
368
368
  return false;
369
369
  }
370
370
  exportDOM(editor) {
371
- const element = document.createElement('pre');
371
+ const element = $getDocument().createElement('pre');
372
372
  addClassNamesToElement(element, editor._config.theme.code);
373
373
  element.setAttribute('spellcheck', 'false');
374
374
  const language = this.getLanguage();
@@ -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&&(D(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(D(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(D(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];D(s)&&" "!==e&&(o={node:s,offset:l})}if(null!==o)return o;let c=null;if(n<e.getTextContentSize())D(e)&&(c=e.getTextContent()[n]);else{const t=e.getNextSibling();D(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(!D(r)||i===s){if(r=r.getNextSibling(),null===r||t.$isLineBreakNode(r))return null;D(r)&&(i=0,o=r.getTextContent(),s=r.getTextContentSize())}if(D(r)){if(" "!==o[i])return{node:r,offset:i};i++}}}(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;static getType(){return"code"}static clone(e){return new _(e.__language,e.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){const n=document.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=document.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}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||f(e,"BR"))?{conversion:x,priority:1}:null,div:()=>({conversion:O,priority:1}),pre:()=>({conversion:x,priority:0}),table:e=>b(e)?{conversion:S,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&b(n)?{conversion:M,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&b(t)?{conversion:M,priority:3}:null}}}static importJSON(e){return T().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(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(!D(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(C(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 C(e){return e instanceof _}function x(e){return{node:T(e.getAttribute(h))}}function O(e){const t=e,n=$(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if($(t))return!0;t=t.parentElement}return!1}(t)?{node:n?T():null}:{node:null}}function S(){return{node:T()}}function M(){return{node:null}}function $(e){return null!==e.style.fontFamily.match("monospace")}function b(e){return e.classList.contains("js-file-line-container")}function E(e){const{anchor:n}=e;if(e.isCollapsed()&&"element"===n.type){const e=n.getNode();if(C(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}static getType(){return"code-highlight"}static clone(e){return new R(e.__text,e.__highlightType||void 0,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){const n=super.createDOM(e),r=y(e.theme,this.__highlightType);return t.addClassNamesToElement(n,r),n}updateDOM(e,n,r){const i=super.updateDOM(e,n,r),o=y(r.theme,e.__highlightType),s=y(r.theme,this.__highlightType);return o!==s&&(o&&t.removeClassNamesFromElement(n,o),s&&t.addClassNamesToElement(n,s)),i}static importJSON(e){return A().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return T()}}function y(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function A(e="",n){return t.$applyNodeReplacement(new R(e,n))}function D(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"}),k=/* @__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 W(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 w(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 F(e){for(const n of Array.from(e.children)){if(t.isHTMLElement(n)&&W(n)){if(null!==w(n))return!0;const e=n.nextElementSibling;if(e&&W(e))return!0;continue}if(F(n))return!0}return!1}const H=/* @__PURE__ */e.defineImportRule({$import:(e,n,r)=>{if(!W(n)||L(n))return r();const i=w(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(!W(n)||L(n))return r();const i=n.previousElementSibling;if(i&&W(i))return[];const o=[];let s=n;for(;s&&W(s);)o.push("BR"===s.tagName?"":s.textContent||""),s=s.nextElementSibling;return o.length<2?r():[T().splice(0,0,t.$generateNodesFromRawText(o.join("\n")))]},match:e.sel.tag("div","br"),name:"@lexical/code/vscode-line-run"}),K=/* @__PURE__ */e.defineOverlayRules([H,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"}),k,B,U],J=/* @__PURE__ */t.defineExtension({dependencies:[e.CoreImportExtension,/* @__PURE__ */t.configExtension(e.DOMImportExtension,{preprocess:[(n,r,i)=>{F(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()&&C(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=C(n)?n:n.getParent(),i=e.focus.getNode(),o=C(i)?i:i.getParent();return C(r)&&r.is(o)}function V(e){const n=e.getNodes(),r=[];if(1===n.length&&C(n[0]))return r;let o=[];for(let e=0;e<n.length;e++){const s=n[e];D(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&&D(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)||!D(u)&&!t.$isTabNode(u)||!D(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(!D(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 _=D(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)||!D(s)&&!t.$isTabNode(s)||!D(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(C,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_RIGHT_COMMAND,e=>r.$onEscapeDown(C,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>!e.altKey&&r.$onEscapeUp(C,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_LEFT_COMMAND,e=>r.$onEscapeUp(C,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()&&C(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()&&C(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=D,exports.$isCodeNode=C,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&&(A(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(A(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(A(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];A(s)&&" "!==e&&(o={node:s,offset:l})}if(null!==o)return o;let c=null;if(n<e.getTextContentSize())A(e)&&(c=e.getTextContent()[n]);else{const t=e.getNextSibling();A(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(!A(r)||i===s){if(r=r.getNextSibling(),null===r||t.$isLineBreakNode(r))return null;A(r)&&(i=0,o=r.getTextContent(),s=r.getTextContentSize())}if(A(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;static getType(){return"code"}static clone(e){return new _(e.__language,e.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(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}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||f(e,"BR"))?{conversion:x,priority:1}:null,div:()=>({conversion:O,priority:1}),pre:()=>({conversion:x,priority:0}),table:e=>b(e)?{conversion:S,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&b(n)?{conversion:$,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&b(t)?{conversion:$,priority:3}:null}}}static importJSON(e){return T().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(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(!A(e))break;{let t=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;t<i&&" "===r[t];)t++;if(0!==t&&n.push(y(" ".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(C(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 C(e){return e instanceof _}function x(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(C(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}static getType(){return"code-highlight"}static clone(e){return new R(e.__text,e.__highlightType||void 0,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(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}static importJSON(e){return y().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return T()}}function D(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function y(e="",n){return t.$applyNodeReplacement(new R(e,n))}function A(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"}),k=/* @__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 W(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 w(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 F(e){for(const n of Array.from(e.children)){if(t.isHTMLElement(n)&&W(n)){if(null!==w(n))return!0;const e=n.nextElementSibling;if(e&&W(e))return!0;continue}if(F(n))return!0}return!1}const H=/* @__PURE__ */e.defineImportRule({$import:(e,n,r)=>{if(!W(n)||L(n))return r();const i=w(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(!W(n)||L(n))return r();const i=n.previousElementSibling;if(i&&W(i))return[];const o=[];let s=n;for(;s&&W(s);)o.push("BR"===s.tagName?"":s.textContent||""),s=s.nextElementSibling;return o.length<2?r():[T().splice(0,0,t.$generateNodesFromRawText(o.join("\n")))]},match:e.sel.tag("div","br"),name:"@lexical/code/vscode-line-run"}),K=/* @__PURE__ */e.defineOverlayRules([H,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"}),k,B,U],J=/* @__PURE__ */t.defineExtension({dependencies:[e.CoreImportExtension,/* @__PURE__ */t.configExtension(e.DOMImportExtension,{preprocess:[(n,r,i)=>{F(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()&&C(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=C(n)?n:n.getParent(),i=e.focus.getNode(),o=C(i)?i:i.getParent();return C(r)&&r.is(o)}function V(e){const n=e.getNodes(),r=[];if(1===n.length&&C(n[0]))return r;let o=[];for(let e=0;e<n.length;e++){const s=n[e];A(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&&A(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)||!A(u)&&!t.$isTabNode(u)||!A(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(!A(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 _=A(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)||!A(s)&&!t.$isTabNode(s)||!A(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(C,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_RIGHT_COMMAND,e=>r.$onEscapeDown(C,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>!e.altKey&&r.$onEscapeUp(C,e),t.COMMAND_PRIORITY_LOW),e.registerCommand(t.KEY_ARROW_LEFT_COMMAND,e=>r.$onEscapeUp(C,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()&&C(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()&&C(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=y,exports.$createCodeNode=T,exports.$getCodeLineDirection=a,exports.$getEndOfCodeInLine=u,exports.$getFirstCodeNodeOfLine=s,exports.$getLastCodeNodeOfLine=l,exports.$getStartOfCodeInLine=c,exports.$isCodeHighlightNode=A,exports.$isCodeNode=C,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(y(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 h,$getSiblingCaret as f,$create as p,ElementNode as d,addClassNamesToElement as m,setDOMStyleFromCSS as x,$getEditor as _,$isTextNode as S,$createParagraphNode as y,isHTMLElement as b,$applyNodeReplacement as v,TextNode as C,removeClassNamesFromElement as N,isDOMDocumentNode as T,isDOMTextNode as A,$generateNodesFromRawText as O,defineExtension as P,mergeRegister as w,KEY_ENTER_COMMAND as H,$getSelection as D,$isRangeSelection as k,COMMAND_PRIORITY_LOW as B,TabNode as F,configExtension as L,safeCast as $,KEY_ARROW_DOWN_COMMAND as E,KEY_ARROW_RIGHT_COMMAND as M,KEY_ARROW_UP_COMMAND as J,KEY_ARROW_LEFT_COMMAND as z,KEY_TAB_COMMAND as K,INSERT_TAB_COMMAND as I,$insertNodes as j,INDENT_CONTENT_COMMAND as R,OUTDENT_CONTENT_COMMAND as W,MOVE_TO_START as q,MOVE_TO_END as U,$createPoint as V,$setSelectionFromCaretRange as G,$getCaretRangeInDirection as Q,$getCaretRange as X,$getTextPointCaret as Y,$normalizeCaret as Z}from"lexical";import{getPeerDependencyFromEditor as ee,effect as te,namedSignals as ne}from"@lexical/extension";import{$onEscapeDown as re,$onEscapeUp as ie}from"@lexical/utils";
10
- /*@__INLINE__*/function oe(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 se(e,t){let n=e;for(let r=f(e,t);r&&(Fe(r.origin)||u(r.origin));r=r.getAdjacentCaret())n=r.origin;return n}function le(e){return se(e,"previous")}function ue(e){return se(e,"next")}function ce(e){const t=le(e),n=ue(e);let r=t;for(;null!==r;){if(Fe(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 ae(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(Fe(e)||u(e)||c(e)||oe(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];Fe(i)&&" "!==e&&(r={node:i,offset:o})}if(null!==r)return r;let l=null;if(t<e.getTextContentSize())Fe(e)&&(l=e.getTextContent()[t]);else{const t=e.getNextSibling();Fe(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(!Fe(n)||r===o){if(n=n.getNextSibling(),null===n||c(n))return null;Fe(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize())}if(Fe(n)){if(" "!==i[r])return{node:n,offset:r};r++}}}(e,t);return null!==r?r:n}}function ge(e){const t=ue(e);return c(t)&&oe(168),t}function he(e){const t=[];return a(e,{linebreak:()=>t.push(h()),tab:()=>t.push(g()),text:e=>t.push(Be(e))}),t}function fe(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 pe="javascript",de=()=>pe;function me(e,t){for(const n of e.childNodes){if(b(n)&&n.tagName===t)return!0;if(me(n,t))return!0}return!1}const xe="data-language",_e="data-highlight-language",Se="data-theme",ye=()=>{};class be extends d{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(e){return new be(e.__language,e.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){const t=document.createElement("code");m(t,e.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(xe,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(_e,n));const r=this.getTheme();r&&t.setAttribute(Se,r);const i=this.getStyle();return i&&x(t.style,i),t}updateDOM(e,t,n){const r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(xe,r):i&&t.removeAttribute(xe);const o=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&t.setAttribute(_e,r):t.removeAttribute(_e):o&&r&&t.setAttribute(_e,r);const s=this.__theme,l=e.__theme;s?s!==l&&t.setAttribute(Se,s):l&&t.removeAttribute(Se);const u=this.__style,c=e.__style;return u!==c&&x(t.style,u,c),!1}exportDOM(e){const t=document.createElement("pre");m(t,e._config.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(xe,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(_e,n));const r=this.getTheme();r&&t.setAttribute(Se,r);const i=this.getStyle();return i&&x(t.style,i),{element:t}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||me(e,"BR"))?{conversion:Ne,priority:1}:null,div:()=>({conversion:Te,priority:1}),pre:()=>({conversion:Ne,priority:0}),table:e=>we(e)?{conversion:Ae,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&we(n)?{conversion:Oe,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&we(t)?{conversion:Oe,priority:3}:null}}}static importJSON(e){return ve().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,t=!0){if(!ee(_(),"@lexical/code")){ye();const t=He(e);if(t)return t}const{anchor:n,focus:r}=e,i=(n.isBefore(r)?n:r).getNode();if(S(i)){let e=le(i);const t=[];for(;;)if(u(e))t.push(g()),e=e.getNextSibling();else{if(!Fe(e))break;{let n=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&t.push(Be(" ".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=[h(),...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(Ce(i)){const{offset:t}=e.anchor;i.splice(t,0,[h()]),i.select(t+1,t+1)}return null}canIndent(){return!1}collapseAtStart(){const e=y();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(be).setLanguage(e).setTheme(t)}function Ce(e){return e instanceof be}function Ne(e){return{node:ve(e.getAttribute(xe))}}function Te(e){const t=e,n=Pe(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if(Pe(t))return!0;t=t.parentElement}return!1}(t)?{node:n?ve():null}:{node:null}}function Ae(){return{node:ve()}}function Oe(){return{node:null}}function Pe(e){return null!==e.style.fontFamily.match("monospace")}function we(e){return e.classList.contains("js-file-line-container")}function He(e){const{anchor:t}=e;if(e.isCollapsed()&&"element"===t.type){const e=t.getNode();if(Ce(e)){const n=e.getChildrenSize();if(n>=2&&t.offset===n){const t=e.getLastChild();if(c(t)&&c(t.getPreviousSibling())){const t=y();return e.splice(n-2,2,[]).insertAfter(t,!1),t.select(),t}}}}return null}class De extends C{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(e){return new De(e.__text,e.__highlightType||void 0,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){const t=super.createDOM(e),n=ke(e.theme,this.__highlightType);return m(t,n),t}updateDOM(e,t,n){const r=super.updateDOM(e,t,n),i=ke(n.theme,e.__highlightType),o=ke(n.theme,this.__highlightType);return i!==o&&(i&&N(t,i),o&&m(t,o)),r}static importJSON(e){return Be().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return ve()}}function ke(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function Be(e="",t){return v(new De(e,t))}function Fe(e){return e instanceof De}const Le="data-language";function $e(e){return null!==e.style.fontFamily.match("monospace")}function Ee(e){let t=e.parentElement;for(;null!==t;){if($e(t))return!0;t=t.parentElement}return!1}const Me=/* @__PURE__ */r([/* @__PURE__ */e({$import:(e,t)=>e.$importChildren(t),match:t.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),Je=/* @__PURE__ */e({$import:(e,t)=>[ve(t.getAttribute(Le)).splice(0,0,e.$importChildren(t))],match:t.tag("pre"),name:"@lexical/code/pre"}),ze=/* @__PURE__ */e({$import:(e,t,n)=>{const r=t.textContent||"";return/\r?\n/.test(r)||null!==t.querySelector("br")?[ve(t.getAttribute(Le)).splice(0,0,e.$importChildren(t))]:n()},match:t.tag("code"),name:"@lexical/code/code-multiline"});function Ke(e){if(!b(e))return!1;const t=e.style.fontFamily,n=e.style.whiteSpace;return"string"==typeof t&&/monospace/i.test(t)&&"string"==typeof n&&n.startsWith("pre")}function Ie(e){let t=!1;const n=[];let r="",i=!1;const o=()=>{i&&(n.push(r),r="",i=!1)};for(const s of Array.from(e.childNodes))if(b(s))"DIV"===s.tagName?(o(),n.push(s.textContent||""),t=!0):"BR"===s.tagName?(o(),n.push(""),t=!0):(r+=s.textContent||"",i=!0);else if(A(s)){const e=s.textContent||"";e.length>0&&(r+=e,i=!0)}return o(),t?n:null}function je(e){for(const t of Array.from(e.children)){if(b(t)&&Ke(t)){if(null!==Ie(t))return!0;const e=t.nextElementSibling;if(e&&Ke(e))return!0;continue}if(je(t))return!0}return!1}const Re=/* @__PURE__ */r([/* @__PURE__ */e({$import:(e,t,n)=>{if(!Ke(t)||Ee(t))return n();const r=Ie(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(!Ke(t)||Ee(t))return n();const r=t.previousElementSibling;if(r&&Ke(r))return[];const i=[];let o=t;for(;o&&Ke(o);)i.push("BR"===o.tagName?"":o.textContent||""),o=o.nextElementSibling;return i.length<2?n():[ve().splice(0,0,O(i.join("\n")))]},match:t.tag("div","br"),name:"@lexical/code/vscode-line-run"})]),We=/* @__PURE__ */e({$import:(e,t,n)=>$e(t)?[ve().splice(0,0,e.$importChildren(t))]:Ee(t)?e.$importChildren(t):n(),match:t.tag("div"),name:"@lexical/code/div"}),qe=[/* @__PURE__ */e({$import:(e,t)=>[ve().splice(0,0,e.$importChildren(t,{rules:Me}))],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"}),ze,Je,We],Ue=/* @__PURE__ */P({dependencies:[i,/* @__PURE__ */L(o,{preprocess:[(e,t,r)=>{je(T(e)?e.body:e)&&t.session.update(n,e=>[...e,Re]),r()}],rules:qe})],name:"@lexical/code",nodes:()=>[be,De],register:e=>w(e.registerCommand(H,e=>{const t=D();return!(!k(t)||!He(t))&&(e.preventDefault(),!0)},B),e.registerNodeTransform(F,e=>{0!==e.getFormat()&&Ce(e.getParent())&&e.setFormat(0)}))}),Ve=/* @__PURE__ */P({dependencies:[Ue],name:"@lexical/code/Import"});function Ge(e){if(!k(e))return!1;const t=e.anchor.getNode(),n=Ce(t)?t:t.getParent(),r=e.focus.getNode(),i=Ce(r)?r:r.getParent();return Ce(n)&&n.is(i)}function Qe(e){const t=e.getNodes(),n=[];if(1===t.length&&Ce(t[0]))return n;let r=[];for(let e=0;e<t.length;e++){const i=t[e];Fe(i)||u(i)||c(i)||oe(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=V(r[0].getKey(),0,"text");t.is(i)||n.push(r)}return n}function Xe(e,t){const n=D();if(!k(n)||!Ge(n))return!1;const r=Qe(n),i=r.length;if(0===i&&n.isCollapsed())return e===R&&n.insertNodes([g()]),!0;if(0===i&&e===R&&"\n"===n.getTextContent()){const e=g(),t=h(),r=n.isBackward()?"previous":"next";return n.insertNodes([e,t]),G(Q(X(Y(e,"next",0),Z(f(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=le(r)),e===R){const e=g();if(r.insertBefore(e),0===o){const t=n.isBackward()?"focus":"anchor",i=V(r.getKey(),0,"text");n[t].is(i)&&n[t].set(e.getKey(),0,"text")}}else u(r)?r.remove():void 0!==t&&Fe(r)&&fe(r,t,n)}}return!0}function Ye(e,t){const n=D();if(!k(n))return!1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,l=r.getNode(),a=i.getNode(),g=e===J;if(!Ge(n)||!Fe(l)&&!u(l)||!Fe(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 h,f;if(l.isBefore(a)?(h=le(l),f=ue(a)):(h=le(a),f=ue(l)),null==h||null==f)return!1;const p=h.getNodesBetween(f);for(let e=0;e<p.length;e++){const t=p[e];if(!Fe(t)&&!u(t)&&!c(t))return!1}t.preventDefault(),t.stopPropagation();const d=g?h.getPreviousSibling():f.getNextSibling();if(!c(d))return!0;const m=g?d.getPreviousSibling():d.getNextSibling();if(null==m)return!0;const x=Fe(m)||u(m)||c(m)?g?le(m):ue(m):null;let _=null!=x?x:m;return d.remove(),p.forEach(e=>e.remove()),e===J?(p.forEach(e=>_.insertBefore(e)),_.insertBefore(d)):(_.insertAfter(d),_=d,p.forEach(e=>{_.insertAfter(e),_=e})),n.setTextNodeRange(l,o,a,s),!0}function Ze(e,t){const n=D();if(!k(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),l=e===q;if(!Ge(n)||!Fe(o)&&!u(o)||!Fe(s)&&!u(s))return!1;const a=s,g="rtl"===ce(a)?!l:l,h=r.key,f=r.offset,p=r.type;if(g){const e=ae(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{ge(a).select()}return t.shiftKey&&n.anchor.set(h,f,p),t.preventDefault(),t.stopPropagation(),!0}function et(e,t,n){return w(...n?[e.registerCommand(E,e=>!e.altKey&&re(Ce,e),B),e.registerCommand(M,e=>re(Ce,e),B),e.registerCommand(J,e=>!e.altKey&&ie(Ce,e),B),e.registerCommand(z,e=>ie(Ce,e),B)]:[],e.registerCommand(K,t=>{const n=function(e){const t=D();if(!k(t)||!Ge(t))return null;const n=e?W:R,r=e?W:I,i=t.anchor,o=t.focus;if(i.is(o))return r;const s=Qe(t);if(1!==s.length)return n;const l=s[0];let u,c;0===l.length&&oe(285),t.isBackward()?(u=o,c=i):(u=i,c=o);const a=le(l[0]),g=ue(l[0]),h=V(a.getKey(),0,"text"),f=V(g.getKey(),g.getTextContentSize(),"text");return u.isBefore(h)||f.isBefore(c)?n:h.isBefore(u)||c.isBefore(f)?r:n}(t.shiftKey);return null!==n&&(t.preventDefault(),e.dispatchCommand(n,void 0),!0)},B),e.registerCommand(I,()=>!!Ge(D())&&(j([g()]),!0),B),e.registerCommand(R,()=>Xe(R),B),e.registerCommand(W,()=>Xe(W,t),B),e.registerCommand(J,e=>{const t=D();if(!k(t))return!1;const{anchor:n}=t,r=n.getNode();if(!Ge(t))return!1;const i=r.getParent();return t.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&Ce(i)&&null===i.getPreviousSibling()?(e.preventDefault(),!0):Ye(J,e)},B),e.registerCommand(E,e=>{const t=D();if(!k(t))return!1;const{anchor:n}=t,r=n.getNode();return!!Ge(t)&&(t.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&Ce(r.getParentOrThrow())&&null===r.getParentOrThrow().getNextSibling()?(e.preventDefault(),!0):Ye(E,e))},B),e.registerCommand(q,e=>Ze(q,e),B),e.registerCommand(U,e=>Ze(U,e),B))}const tt=/* @__PURE__ */P({build:(e,t)=>ne(t),config:/* @__PURE__ */$({disabled:!1,escapeWithArrows:!1,tabSize:void 0}),dependencies:[Ue],name:"@lexical/code-indent",register:(e,t,n)=>{const r=n.getOutput();return te(()=>{if(!r.disabled.value)return et(e,r.tabSize.value,r.escapeWithArrows.value)})}});export{Be as $createCodeHighlightNode,ve as $createCodeNode,ce as $getCodeLineDirection,ge as $getEndOfCodeInLine,le as $getFirstCodeNodeOfLine,ue as $getLastCodeNodeOfLine,ae as $getStartOfCodeInLine,Fe as $isCodeHighlightNode,Ce as $isCodeNode,fe as $outdentLeadingSpaces,he as $plainifyCodeContent,Ue as CodeExtension,De as CodeHighlightNode,Ve as CodeImportExtension,qe as CodeImportRules,tt as CodeIndentExtension,be as CodeNode,pe as DEFAULT_CODE_LANGUAGE,de as getDefaultCodeLanguage,et 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 h,$getSiblingCaret as f,$create as p,ElementNode as d,$getDocument as m,addClassNamesToElement as x,setDOMStyleFromCSS as _,$getEditor as S,$isTextNode as y,$createParagraphNode as b,isHTMLElement as v,$applyNodeReplacement as C,TextNode as N,removeClassNamesFromElement as T,isDOMDocumentNode as A,isDOMTextNode as O,$generateNodesFromRawText as P,defineExtension as w,mergeRegister as H,KEY_ENTER_COMMAND as D,$getSelection as k,$isRangeSelection as B,COMMAND_PRIORITY_LOW as F,TabNode as L,configExtension as $,safeCast as E,KEY_ARROW_DOWN_COMMAND as M,KEY_ARROW_RIGHT_COMMAND as J,KEY_ARROW_UP_COMMAND as z,KEY_ARROW_LEFT_COMMAND as K,KEY_TAB_COMMAND as I,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=f(e,t);r&&(Le(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(Le(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(Le(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];Le(i)&&" "!==e&&(r={node:i,offset:o})}if(null!==r)return r;let l=null;if(t<e.getTextContentSize())Le(e)&&(l=e.getTextContent()[t]);else{const t=e.getNextSibling();Le(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(!Le(n)||r===o){if(n=n.getNextSibling(),null===n||c(n))return null;Le(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize())}if(Le(n)){if(" "!==i[r])return{node:n,offset:r};r++}}}(e,t);return null!==r?r:n}}function he(e){const t=ce(e);return c(t)&&se(168),t}function fe(e){const t=[];return a(e,{linebreak:()=>t.push(h()),tab:()=>t.push(g()),text:e=>t.push(Fe(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 _e="data-language",Se="data-highlight-language",ye="data-theme",be=()=>{};class ve extends d{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(e){return new ve(e.__language,e.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){const t=m().createElement("code");x(t,e.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(_e,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(Se,n));const r=this.getTheme();r&&t.setAttribute(ye,r);const i=this.getStyle();return i&&_(t.style,i),t}updateDOM(e,t,n){const r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(_e,r):i&&t.removeAttribute(_e);const o=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&t.setAttribute(Se,r):t.removeAttribute(Se):o&&r&&t.setAttribute(Se,r);const s=this.__theme,l=e.__theme;s?s!==l&&t.setAttribute(ye,s):l&&t.removeAttribute(ye);const u=this.__style,c=e.__style;return u!==c&&_(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(_e,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(Se,n));const r=this.getTheme();r&&t.setAttribute(ye,r);const i=this.getStyle();return i&&_(t.style,i),{element:t}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||xe(e,"BR"))?{conversion:Te,priority:1}:null,div:()=>({conversion:Ae,priority:1}),pre:()=>({conversion:Te,priority:0}),table:e=>He(e)?{conversion:Oe,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&He(n)?{conversion:Pe,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&He(t)?{conversion:Pe,priority:3}:null}}}static importJSON(e){return Ce().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,t=!0){if(!te(S(),"@lexical/code")){be();const t=De(e);if(t)return t}const{anchor:n,focus:r}=e,i=(n.isBefore(r)?n:r).getNode();if(y(i)){let e=ue(i);const t=[];for(;;)if(u(e))t.push(g()),e=e.getNextSibling();else{if(!Le(e))break;{let n=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&t.push(Fe(" ".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=[h(),...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(Ne(i)){const{offset:t}=e.anchor;i.splice(t,0,[h()]),i.select(t+1,t+1)}return null}canIndent(){return!1}collapseAtStart(){const e=b();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 Ne(e){return e instanceof ve}function Te(e){return{node:Ce(e.getAttribute(_e))}}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 Oe(){return{node:Ce()}}function Pe(){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 De(e){const{anchor:t}=e;if(e.isCollapsed()&&"element"===t.type){const e=t.getNode();if(Ne(e)){const n=e.getChildrenSize();if(n>=2&&t.offset===n){const t=e.getLastChild();if(c(t)&&c(t.getPreviousSibling())){const t=b();return e.splice(n-2,2,[]).insertAfter(t,!1),t.select(),t}}}}return null}class ke extends N{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(e){return new ke(e.__text,e.__highlightType||void 0,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){const t=super.createDOM(e),n=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&&T(t,i),o&&x(t,o)),r}static importJSON(e){return Fe().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return Ce()}}function Be(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function Fe(e="",t){return C(new ke(e,t))}function Le(e){return e instanceof ke}const $e="data-language";function Ee(e){return null!==e.style.fontFamily.match("monospace")}function Me(e){let t=e.parentElement;for(;null!==t;){if(Ee(t))return!0;t=t.parentElement}return!1}const Je=/* @__PURE__ */r([/* @__PURE__ */e({$import:(e,t)=>e.$importChildren(t),match:t.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),ze=/* @__PURE__ */e({$import:(e,t)=>[Ce(t.getAttribute($e)).splice(0,0,e.$importChildren(t))],match:t.tag("pre"),name:"@lexical/code/pre"}),Ke=/* @__PURE__ */e({$import:(e,t,n)=>{const r=t.textContent||"";return/\r?\n/.test(r)||null!==t.querySelector("br")?[Ce(t.getAttribute($e)).splice(0,0,e.$importChildren(t))]:n()},match:t.tag("code"),name:"@lexical/code/code-multiline"});function Ie(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(O(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)&&Ie(t)){if(null!==je(t))return!0;const e=t.nextElementSibling;if(e&&Ie(e))return!0;continue}if(Re(t))return!0}return!1}const We=/* @__PURE__ */r([/* @__PURE__ */e({$import:(e,t,n)=>{if(!Ie(t)||Me(t))return n();const r=je(t);return null===r||0===r.length?n():[Ce().splice(0,0,P(r.join("\n")))]},match:t.tag("div"),name:"@lexical/code/vscode-wrapper"}),/* @__PURE__ */e({$import:(e,t,n)=>{if(!Ie(t)||Me(t))return n();const r=t.previousElementSibling;if(r&&Ie(r))return[];const i=[];let o=t;for(;o&&Ie(o);)i.push("BR"===o.tagName?"":o.textContent||""),o=o.nextElementSibling;return i.length<2?n():[Ce().splice(0,0,P(i.join("\n")))]},match:t.tag("div","br"),name:"@lexical/code/vscode-line-run"})]),qe=/* @__PURE__ */e({$import:(e,t,n)=>Ee(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:Je}))],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"}),Ke,ze,qe],Ve=/* @__PURE__ */w({dependencies:[i,/* @__PURE__ */$(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,ke],register:e=>H(e.registerCommand(D,e=>{const t=k();return!(!B(t)||!De(t))&&(e.preventDefault(),!0)},F),e.registerNodeTransform(L,e=>{0!==e.getFormat()&&Ne(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=Ne(t)?t:t.getParent(),r=e.focus.getNode(),i=Ne(r)?r:r.getParent();return Ne(n)&&n.is(i)}function Xe(e){const t=e.getNodes(),n=[];if(1===t.length&&Ne(t[0]))return n;let r=[];for(let e=0;e<t.length;e++){const i=t[e];Le(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=k();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=h(),r=n.isBackward()?"previous":"next";return n.insertNodes([e,t]),Q(X(Y(Z(e,"next",0),ee(f(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&&Le(r)&&pe(r,t,n)}}return!0}function Ze(e,t){const n=k();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===z;if(!Qe(n)||!Le(l)&&!u(l)||!Le(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 h,f;if(l.isBefore(a)?(h=ue(l),f=ce(a)):(h=ue(a),f=ce(l)),null==h||null==f)return!1;const p=h.getNodesBetween(f);for(let e=0;e<p.length;e++){const t=p[e];if(!Le(t)&&!u(t)&&!c(t))return!1}t.preventDefault(),t.stopPropagation();const d=g?h.getPreviousSibling():f.getNextSibling();if(!c(d))return!0;const m=g?d.getPreviousSibling():d.getNextSibling();if(null==m)return!0;const x=Le(m)||u(m)||c(m)?g?ue(m):ce(m):null;let _=null!=x?x:m;return d.remove(),p.forEach(e=>e.remove()),e===z?(p.forEach(e=>_.insertBefore(e)),_.insertBefore(d)):(_.insertAfter(d),_=d,p.forEach(e=>{_.insertAfter(e),_=e})),n.setTextNodeRange(l,o,a,s),!0}function et(e,t){const n=k();if(!B(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),l=e===U;if(!Qe(n)||!Le(o)&&!u(o)||!Le(s)&&!u(s))return!1;const a=s,g="rtl"===ae(a)?!l:l,h=r.key,f=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{he(a).select()}return t.shiftKey&&n.anchor.set(h,f,p),t.preventDefault(),t.stopPropagation(),!0}function tt(e,t,n){return H(...n?[e.registerCommand(M,e=>!e.altKey&&ie(Ne,e),F),e.registerCommand(J,e=>ie(Ne,e),F),e.registerCommand(z,e=>!e.altKey&&oe(Ne,e),F),e.registerCommand(K,e=>oe(Ne,e),F)]:[],e.registerCommand(I,t=>{const n=function(e){const t=k();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]),h=G(a.getKey(),0,"text"),f=G(g.getKey(),g.getTextContentSize(),"text");return u.isBefore(h)||f.isBefore(c)?n:h.isBefore(u)||c.isBefore(f)?r:n}(t.shiftKey);return null!==n&&(t.preventDefault(),e.dispatchCommand(n,void 0),!0)},F),e.registerCommand(j,()=>!!Qe(k())&&(R([g()]),!0),F),e.registerCommand(W,()=>Ye(W),F),e.registerCommand(q,()=>Ye(q,t),F),e.registerCommand(z,e=>{const t=k();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()&&Ne(i)&&null===i.getPreviousSibling()?(e.preventDefault(),!0):Ze(z,e)},F),e.registerCommand(M,e=>{const t=k();if(!B(t))return!1;const{anchor:n}=t,r=n.getNode();return!!Qe(t)&&(t.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&Ne(r.getParentOrThrow())&&null===r.getParentOrThrow().getNextSibling()?(e.preventDefault(),!0):Ze(M,e))},F),e.registerCommand(U,e=>et(U,e),F),e.registerCommand(V,e=>et(V,e),F))}const nt=/* @__PURE__ */w({build:(e,t)=>re(t),config:/* @__PURE__ */E({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{Fe as $createCodeHighlightNode,Ce as $createCodeNode,ae as $getCodeLineDirection,he as $getEndOfCodeInLine,ue as $getFirstCodeNodeOfLine,ce as $getLastCodeNodeOfLine,ge as $getStartOfCodeInLine,Le as $isCodeHighlightNode,Ne as $isCodeNode,pe as $outdentLeadingSpaces,fe as $plainifyCodeContent,Ve as CodeExtension,ke 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};
package/package.json CHANGED
@@ -8,15 +8,15 @@
8
8
  "code"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.46.1-nightly.20260706.0",
11
+ "version": "0.46.1-nightly.20260708.0",
12
12
  "main": "./dist/LexicalCodeCore.js",
13
13
  "types": "./dist/typescript-too-old.d.ts",
14
14
  "dependencies": {
15
- "@lexical/extension": "0.46.1-nightly.20260706.0",
16
- "@lexical/html": "0.46.1-nightly.20260706.0",
17
- "@lexical/utils": "0.46.1-nightly.20260706.0",
18
- "lexical": "0.46.1-nightly.20260706.0",
19
- "@lexical/internal": "0.46.1-nightly.20260706.0"
15
+ "@lexical/extension": "0.46.1-nightly.20260708.0",
16
+ "@lexical/html": "0.46.1-nightly.20260708.0",
17
+ "@lexical/internal": "0.46.1-nightly.20260708.0",
18
+ "@lexical/utils": "0.46.1-nightly.20260708.0",
19
+ "lexical": "0.46.1-nightly.20260708.0"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -6,21 +6,18 @@
6
6
  *
7
7
  */
8
8
 
9
- import type {
10
- EditorConfig,
11
- EditorThemeClasses,
12
- LexicalNode,
13
- LexicalUpdateJSON,
14
- NodeKey,
15
- SerializedTextNode,
16
- Spread,
17
- } from 'lexical';
18
-
19
9
  import {
20
10
  $applyNodeReplacement,
21
11
  addClassNamesToElement,
22
- ElementNode,
12
+ type EditorConfig,
13
+ type EditorThemeClasses,
14
+ type ElementNode,
15
+ type LexicalNode,
16
+ type LexicalUpdateJSON,
17
+ type NodeKey,
23
18
  removeClassNamesFromElement,
19
+ type SerializedTextNode,
20
+ type Spread,
24
21
  TextNode,
25
22
  } from 'lexical';
26
23
 
@@ -6,11 +6,10 @@
6
6
  *
7
7
  */
8
8
 
9
- import type {DOMPreprocessFn} from '@lexical/html';
10
-
11
9
  import {
12
10
  defineImportRule,
13
11
  defineOverlayRules,
12
+ type DOMPreprocessFn,
14
13
  ImportOverlays,
15
14
  sel,
16
15
  } from '@lexical/html';
@@ -6,16 +6,6 @@
6
6
  *
7
7
  */
8
8
 
9
- import type {CodeHighlightNode} from './CodeHighlightNode';
10
- import type {
11
- BaseSelection,
12
- LexicalCommand,
13
- LexicalEditor,
14
- LineBreakNode,
15
- RangeSelection,
16
- TabNode,
17
- } from 'lexical';
18
-
19
9
  import {effect, namedSignals} from '@lexical/extension';
20
10
  import invariant from '@lexical/internal/invariant';
21
11
  import {$onEscapeDown, $onEscapeUp} from '@lexical/utils';
@@ -34,6 +24,7 @@ import {
34
24
  $isTabNode,
35
25
  $normalizeCaret,
36
26
  $setSelectionFromCaretRange,
27
+ type BaseSelection,
37
28
  COMMAND_PRIORITY_LOW,
38
29
  defineExtension,
39
30
  INDENT_CONTENT_COMMAND,
@@ -43,15 +34,23 @@ import {
43
34
  KEY_ARROW_RIGHT_COMMAND,
44
35
  KEY_ARROW_UP_COMMAND,
45
36
  KEY_TAB_COMMAND,
37
+ type LexicalCommand,
38
+ type LexicalEditor,
39
+ type LineBreakNode,
46
40
  mergeRegister,
47
41
  MOVE_TO_END,
48
42
  MOVE_TO_START,
49
43
  OUTDENT_CONTENT_COMMAND,
44
+ type RangeSelection,
50
45
  safeCast,
46
+ type TabNode,
51
47
  } from 'lexical';
52
48
 
53
49
  import {CodeExtension} from './CodeExtension';
54
- import {$isCodeHighlightNode} from './CodeHighlightNode';
50
+ import {
51
+ $isCodeHighlightNode,
52
+ type CodeHighlightNode,
53
+ } from './CodeHighlightNode';
55
54
  import {$isCodeNode} from './CodeNode';
56
55
  import {
57
56
  $getCodeLineDirection,
package/src/CodeNode.ts CHANGED
@@ -7,21 +7,6 @@
7
7
  */
8
8
 
9
9
  import type {CodeExtension} from './CodeExtension';
10
- import type {
11
- DOMConversionMap,
12
- DOMConversionOutput,
13
- DOMExportOutput,
14
- EditorConfig,
15
- LexicalEditor,
16
- LexicalNode,
17
- LexicalUpdateJSON,
18
- NodeKey,
19
- ParagraphNode,
20
- RangeSelection,
21
- SerializedElementNode,
22
- Spread,
23
- TabNode,
24
- } from 'lexical';
25
10
 
26
11
  import {getPeerDependencyFromEditor} from '@lexical/extension';
27
12
  import warnOnlyOnce from '@lexical/internal/warnOnlyOnce';
@@ -30,14 +15,28 @@ import {
30
15
  $createLineBreakNode,
31
16
  $createParagraphNode,
32
17
  $createTabNode,
18
+ $getDocument,
33
19
  $getEditor,
34
20
  $isLineBreakNode,
35
21
  $isTabNode,
36
22
  $isTextNode,
37
23
  addClassNamesToElement,
24
+ type DOMConversionMap,
25
+ type DOMConversionOutput,
26
+ type DOMExportOutput,
27
+ type EditorConfig,
38
28
  ElementNode,
39
29
  isHTMLElement,
30
+ type LexicalEditor,
31
+ type LexicalNode,
32
+ type LexicalUpdateJSON,
33
+ type NodeKey,
34
+ type ParagraphNode,
35
+ type RangeSelection,
36
+ type SerializedElementNode,
40
37
  setDOMStyleFromCSS,
38
+ type Spread,
39
+ type TabNode,
41
40
  } from 'lexical';
42
41
 
43
42
  import {
@@ -112,7 +111,7 @@ export class CodeNode extends ElementNode {
112
111
 
113
112
  // View
114
113
  createDOM(config: EditorConfig): HTMLElement {
115
- const element = document.createElement('code');
114
+ const element = $getDocument().createElement('code');
116
115
  addClassNamesToElement(element, config.theme.code);
117
116
  element.setAttribute('spellcheck', 'false');
118
117
  const language = this.getLanguage();
@@ -183,7 +182,7 @@ export class CodeNode extends ElementNode {
183
182
  }
184
183
 
185
184
  exportDOM(editor: LexicalEditor): DOMExportOutput {
186
- const element = document.createElement('pre');
185
+ const element = $getDocument().createElement('pre');
187
186
  addClassNamesToElement(element, editor._config.theme.code);
188
187
  element.setAttribute('spellcheck', 'false');
189
188
  const language = this.getLanguage();
@@ -6,16 +6,6 @@
6
6
  *
7
7
  */
8
8
 
9
- import type {CodeHighlightNode} from './CodeHighlightNode';
10
- import type {
11
- CaretDirection,
12
- LexicalNode,
13
- LineBreakNode,
14
- RangeSelection,
15
- SiblingCaret,
16
- TabNode,
17
- } from 'lexical';
18
-
19
9
  import invariant from '@lexical/internal/invariant';
20
10
  import {
21
11
  $createLineBreakNode,
@@ -24,13 +14,20 @@ import {
24
14
  $isElementNode,
25
15
  $isLineBreakNode,
26
16
  $isTabNode,
17
+ type CaretDirection,
27
18
  getTextDirection,
19
+ type LexicalNode,
20
+ type LineBreakNode,
21
+ type RangeSelection,
22
+ type SiblingCaret,
23
+ type TabNode,
28
24
  tokenizeRawText,
29
25
  } from 'lexical';
30
26
 
31
27
  import {
32
28
  $createCodeHighlightNode,
33
29
  $isCodeHighlightNode,
30
+ type CodeHighlightNode,
34
31
  } from './CodeHighlightNode';
35
32
 
36
33
  function $getLastMatchingCodeNode<D extends CaretDirection>(