@lexical/code 0.35.1-nightly.20250924.0 → 0.36.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.
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Add code blocks to the editor (syntax highlighting provided separately)
3
+ */
4
+ export declare const CodeExtension: import("lexical").LexicalExtension<import("lexical").ExtensionConfigBase, "@lexical/code", unknown, unknown>;
@@ -85,11 +85,11 @@ const THEME_DATA_ATTRIBUTE = 'data-theme';
85
85
  /** @noInheritDoc */
86
86
  class CodeNode extends lexical.ElementNode {
87
87
  /** @internal */
88
-
88
+ __language;
89
89
  /** @internal */
90
-
90
+ __theme;
91
91
  /** @internal */
92
-
92
+ __isSyntaxHighlightSupported;
93
93
  static getType() {
94
94
  return 'code';
95
95
  }
@@ -442,7 +442,7 @@ function isGitHubCodeTable(table) {
442
442
  /** @noInheritDoc */
443
443
  class CodeHighlightNode extends lexical.TextNode {
444
444
  /** @internal */
445
-
445
+ __highlightType;
446
446
  constructor(text = '', highlightType, key) {
447
447
  super(text, key);
448
448
  this.__highlightType = highlightType;
@@ -633,6 +633,22 @@ function $getEndOfCodeInLine(anchor) {
633
633
  return lastNode;
634
634
  }
635
635
 
636
+ /**
637
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
638
+ *
639
+ * This source code is licensed under the MIT license found in the
640
+ * LICENSE file in the root directory of this source tree.
641
+ *
642
+ */
643
+
644
+ /**
645
+ * Add code blocks to the editor (syntax highlighting provided separately)
646
+ */
647
+ const CodeExtension = lexical.defineExtension({
648
+ name: '@lexical/code',
649
+ nodes: [CodeNode, CodeHighlightNode]
650
+ });
651
+
636
652
  (function (Prism) {
637
653
 
638
654
  Prism.languages.diff = {
@@ -1536,6 +1552,7 @@ exports.$isCodeHighlightNode = $isCodeHighlightNode;
1536
1552
  exports.$isCodeNode = $isCodeNode;
1537
1553
  exports.CODE_LANGUAGE_FRIENDLY_NAME_MAP = CODE_LANGUAGE_FRIENDLY_NAME_MAP;
1538
1554
  exports.CODE_LANGUAGE_MAP = CODE_LANGUAGE_MAP;
1555
+ exports.CodeExtension = CodeExtension;
1539
1556
  exports.CodeHighlightNode = CodeHighlightNode;
1540
1557
  exports.CodeNode = CodeNode;
1541
1558
  exports.DEFAULT_CODE_LANGUAGE = DEFAULT_CODE_LANGUAGE;
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { isHTMLElement, addClassNamesToElement, removeClassNamesFromElement, $getAdjacentCaret, mergeRegister } from '@lexical/utils';
10
- import { ElementNode, $createParagraphNode, $isTextNode, $isTabNode, $createTabNode, $createLineBreakNode, $create, TextNode, $applyNodeReplacement, $getSiblingCaret, $isLineBreakNode, $createTextNode, $getNodeByKey, $getSelection, $isRangeSelection, $createPoint, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, INSERT_TAB_COMMAND, $setSelectionFromCaretRange, $getCaretRangeInDirection, $getCaretRange, $getTextPointCaret, $normalizeCaret, KEY_ARROW_UP_COMMAND, MOVE_TO_START, KEY_TAB_COMMAND, COMMAND_PRIORITY_LOW, $insertNodes, KEY_ARROW_DOWN_COMMAND, MOVE_TO_END } from 'lexical';
10
+ import { ElementNode, $createParagraphNode, $isTextNode, $isTabNode, $createTabNode, $createLineBreakNode, $create, TextNode, $applyNodeReplacement, $getSiblingCaret, $isLineBreakNode, defineExtension, $createTextNode, $getNodeByKey, $getSelection, $isRangeSelection, $createPoint, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, INSERT_TAB_COMMAND, $setSelectionFromCaretRange, $getCaretRangeInDirection, $getCaretRange, $getTextPointCaret, $normalizeCaret, KEY_ARROW_UP_COMMAND, MOVE_TO_START, KEY_TAB_COMMAND, COMMAND_PRIORITY_LOW, $insertNodes, KEY_ARROW_DOWN_COMMAND, MOVE_TO_END } from 'lexical';
11
11
  import 'prismjs';
12
12
  import 'prismjs/components/prism-clike.js';
13
13
  import 'prismjs/components/prism-javascript.js';
@@ -83,11 +83,11 @@ const THEME_DATA_ATTRIBUTE = 'data-theme';
83
83
  /** @noInheritDoc */
84
84
  class CodeNode extends ElementNode {
85
85
  /** @internal */
86
-
86
+ __language;
87
87
  /** @internal */
88
-
88
+ __theme;
89
89
  /** @internal */
90
-
90
+ __isSyntaxHighlightSupported;
91
91
  static getType() {
92
92
  return 'code';
93
93
  }
@@ -440,7 +440,7 @@ function isGitHubCodeTable(table) {
440
440
  /** @noInheritDoc */
441
441
  class CodeHighlightNode extends TextNode {
442
442
  /** @internal */
443
-
443
+ __highlightType;
444
444
  constructor(text = '', highlightType, key) {
445
445
  super(text, key);
446
446
  this.__highlightType = highlightType;
@@ -631,6 +631,22 @@ function $getEndOfCodeInLine(anchor) {
631
631
  return lastNode;
632
632
  }
633
633
 
634
+ /**
635
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
636
+ *
637
+ * This source code is licensed under the MIT license found in the
638
+ * LICENSE file in the root directory of this source tree.
639
+ *
640
+ */
641
+
642
+ /**
643
+ * Add code blocks to the editor (syntax highlighting provided separately)
644
+ */
645
+ const CodeExtension = defineExtension({
646
+ name: '@lexical/code',
647
+ nodes: [CodeNode, CodeHighlightNode]
648
+ });
649
+
634
650
  (function (Prism) {
635
651
 
636
652
  Prism.languages.diff = {
@@ -1524,4 +1540,4 @@ const getEndOfCodeInLine = $getEndOfCodeInLine;
1524
1540
  /** @deprecated renamed to {@link $getStartOfCodeInLine} by @lexical/eslint-plugin rules-of-lexical */
1525
1541
  const getStartOfCodeInLine = $getStartOfCodeInLine;
1526
1542
 
1527
- export { $createCodeHighlightNode, $createCodeNode, $getEndOfCodeInLine, $getFirstCodeNodeOfLine, $getLastCodeNodeOfLine, $getStartOfCodeInLine, $isCodeHighlightNode, $isCodeNode, CODE_LANGUAGE_FRIENDLY_NAME_MAP, CODE_LANGUAGE_MAP, CodeHighlightNode, CodeNode, DEFAULT_CODE_LANGUAGE, PrismTokenizer, getCodeLanguageOptions, getCodeLanguages, getCodeThemeOptions, getDefaultCodeLanguage, getEndOfCodeInLine, getFirstCodeNodeOfLine, getLanguageFriendlyName, getLastCodeNodeOfLine, getStartOfCodeInLine, normalizeCodeLang, normalizeCodeLang as normalizeCodeLanguage, registerCodeHighlighting };
1543
+ export { $createCodeHighlightNode, $createCodeNode, $getEndOfCodeInLine, $getFirstCodeNodeOfLine, $getLastCodeNodeOfLine, $getStartOfCodeInLine, $isCodeHighlightNode, $isCodeNode, CODE_LANGUAGE_FRIENDLY_NAME_MAP, CODE_LANGUAGE_MAP, CodeExtension, CodeHighlightNode, CodeNode, DEFAULT_CODE_LANGUAGE, PrismTokenizer, getCodeLanguageOptions, getCodeLanguages, getCodeThemeOptions, getDefaultCodeLanguage, getEndOfCodeInLine, getFirstCodeNodeOfLine, getLanguageFriendlyName, getLastCodeNodeOfLine, getStartOfCodeInLine, normalizeCodeLang, normalizeCodeLang as normalizeCodeLanguage, registerCodeHighlighting };
@@ -19,6 +19,8 @@ import type {
19
19
  SerializedElementNode,
20
20
  SerializedTabNode,
21
21
  TabNode,
22
+ LexicalExtension,
23
+ ExtensionConfigBase,
22
24
  } from 'lexical';
23
25
 
24
26
  import {ElementNode, TextNode} from 'lexical';
@@ -146,3 +148,5 @@ declare export class CodeNode extends ElementNode {
146
148
  setLanguage(language: string): void;
147
149
  getLanguage(): string | void;
148
150
  }
151
+
152
+ declare export var CodeExtension: LexicalExtension<ExtensionConfigBase, "@lexical/code", mixed, mixed>;
package/LexicalCode.mjs CHANGED
@@ -19,6 +19,7 @@ export const $isCodeHighlightNode = mod.$isCodeHighlightNode;
19
19
  export const $isCodeNode = mod.$isCodeNode;
20
20
  export const CODE_LANGUAGE_FRIENDLY_NAME_MAP = mod.CODE_LANGUAGE_FRIENDLY_NAME_MAP;
21
21
  export const CODE_LANGUAGE_MAP = mod.CODE_LANGUAGE_MAP;
22
+ export const CodeExtension = mod.CodeExtension;
22
23
  export const CodeHighlightNode = mod.CodeHighlightNode;
23
24
  export const CodeNode = mod.CodeNode;
24
25
  export const DEFAULT_CODE_LANGUAGE = mod.DEFAULT_CODE_LANGUAGE;
@@ -17,6 +17,7 @@ export const $isCodeHighlightNode = mod.$isCodeHighlightNode;
17
17
  export const $isCodeNode = mod.$isCodeNode;
18
18
  export const CODE_LANGUAGE_FRIENDLY_NAME_MAP = mod.CODE_LANGUAGE_FRIENDLY_NAME_MAP;
19
19
  export const CODE_LANGUAGE_MAP = mod.CODE_LANGUAGE_MAP;
20
+ export const CodeExtension = mod.CodeExtension;
20
21
  export const CodeHighlightNode = mod.CodeHighlightNode;
21
22
  export const CodeNode = mod.CodeNode;
22
23
  export const DEFAULT_CODE_LANGUAGE = mod.DEFAULT_CODE_LANGUAGE;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/utils"),t=require("lexical");function n(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.`)}require("prismjs"),require("prismjs/components/prism-clike"),require("prismjs/components/prism-javascript"),require("prismjs/components/prism-markup"),require("prismjs/components/prism-markdown"),require("prismjs/components/prism-c"),require("prismjs/components/prism-css"),require("prismjs/components/prism-objectivec"),require("prismjs/components/prism-sql"),require("prismjs/components/prism-powershell"),require("prismjs/components/prism-python"),require("prismjs/components/prism-rust"),require("prismjs/components/prism-swift"),require("prismjs/components/prism-typescript"),require("prismjs/components/prism-java"),require("prismjs/components/prism-cpp");const r="javascript";function i(t,n){for(const r of t.childNodes){if(e.isHTMLElement(r)&&r.tagName===n)return!0;i(r,n)}return!1}const o="data-language",s="data-highlight-language",a="data-theme";class g extends t.ElementNode{static getType(){return"code"}static clone(e){return new g(e.__language,e.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(t){const n=document.createElement("code");e.addClassNamesToElement(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(o,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(s,r));const i=this.getTheme();i&&n.setAttribute(a,i);const g=this.getStyle();return g&&n.setAttribute("style",g),n}updateDOM(e,t,n){const r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(o,r):i&&t.removeAttribute(o);const g=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?g&&r?r!==i&&t.setAttribute(s,r):t.removeAttribute(s):g&&r&&t.setAttribute(s,r);const l=this.__theme,u=e.__theme;l?l!==u&&t.setAttribute(a,l):u&&t.removeAttribute(a);const c=this.__style,p=e.__style;return c?c!==p&&t.setAttribute("style",c):p&&t.removeAttribute("style"),!1}exportDOM(t){const n=document.createElement("pre");e.addClassNamesToElement(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(o,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(s,r));const i=this.getTheme();i&&n.setAttribute(a,i);const g=this.getStyle();return g&&n.setAttribute("style",g),{element:n}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||i(e,"BR"))?{conversion:c,priority:1}:null,div:()=>({conversion:p,priority:1}),pre:()=>({conversion:c,priority:0}),table:e=>N(e)?{conversion:d,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&N(n)?{conversion:f,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&N(t)?{conversion:f,priority:3}:null}}}static importJSON(e){return l().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,n=!0){const r=this.getChildren(),i=r.length;if(i>=2&&"\n"===r[i-1].getTextContent()&&"\n"===r[i-2].getTextContent()&&e.isCollapsed()&&e.anchor.key===this.__key&&e.anchor.offset===i){r[i-1].remove(),r[i-2].remove();const e=t.$createParagraphNode();return this.insertAfter(e,n),e}const{anchor:o,focus:s}=e,a=(o.isBefore(s)?o:s).getNode();if(t.$isTextNode(a)){let e=O(a);const n=[];for(;;)if(t.$isTabNode(e))n.push(t.$createTabNode()),e=e.getNextSibling();else{if(!x(e))break;{let t=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;t<i&&" "===r[t];)t++;if(0!==t&&n.push(T(" ".repeat(t))),t!==i)break;e=e.getNextSibling()}}const r=a.splitText(o.offset)[0],i=0===o.offset?0:1,s=r.getIndexWithinParent()+i,g=a.getParentOrThrow(),l=[t.$createLineBreakNode(),...n];g.splice(s,0,l);const u=n[n.length-1];u?u.select():0===o.offset?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(u(a)){const{offset:n}=e.anchor;a.splice(n,0,[t.$createLineBreakNode()]),a.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 l(e,n){return t.$create(g).setLanguage(e).setTheme(n)}function u(e){return e instanceof g}function c(e){return{node:l(e.getAttribute(o))}}function p(e){const t=e,n=h(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if(h(t))return!0;t=t.parentElement}return!1}(t)?{node:n?l():null}:{node:null}}function d(){return{node:l()}}function f(){return{node:null}}function h(e){return null!==e.style.fontFamily.match("monospace")}function N(e){return e.classList.contains("js-file-line-container")}class m extends t.TextNode{constructor(e="",t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(e){return new m(e.__text,e.__highlightType||void 0,e.__key)}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(t){const n=super.createDOM(t),r=_(t.theme,this.__highlightType);return e.addClassNamesToElement(n,r),n}updateDOM(t,n,r){const i=super.updateDOM(t,n,r),o=_(r.theme,t.__highlightType),s=_(r.theme,this.__highlightType);return o!==s&&(o&&e.removeClassNamesFromElement(n,o),s&&e.addClassNamesToElement(n,s)),i}static importJSON(e){return T().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 l()}}function _(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function T(e="",n){return t.$applyNodeReplacement(new m(e,n))}function x(e){return e instanceof m}function C(n,r){let i=n;for(let o=t.$getSiblingCaret(n,r);o&&(x(o.origin)||t.$isTabNode(o.origin));o=e.$getAdjacentCaret(o))i=o.origin;return i}function O(e){return C(e,"previous")}function S(e){return C(e,"next")}function y(e,r){let i=null,o=null,s=e,a=r,g=e.getTextContent();for(;;){if(0===a){if(s=s.getPreviousSibling(),null===s)break;if(x(s)||t.$isTabNode(s)||t.$isLineBreakNode(s)||n(167),t.$isLineBreakNode(s)){i={node:s,offset:1};break}a=Math.max(0,s.getTextContentSize()-1),g=s.getTextContent()}else a--;const e=g[a];x(s)&&" "!==e&&(o={node:s,offset:a})}if(null!==o)return o;let l=null;if(r<e.getTextContentSize())x(e)&&(l=e.getTextContent()[r]);else{const t=e.getNextSibling();x(t)&&(l=t.getTextContent()[0])}if(null!==l&&" "!==l)return i;{const n=function(e,n){let r=e,i=n,o=e.getTextContent(),s=e.getTextContentSize();for(;;){if(!x(r)||i===s){if(r=r.getNextSibling(),null===r||t.$isLineBreakNode(r))return null;x(r)&&(i=0,o=r.getTextContent(),s=r.getTextContentSize())}if(x(r)){if(" "!==o[i])return{node:r,offset:i};i++}}}(e,r);return null!==n?n:i}}function $(e){const r=S(e);return t.$isLineBreakNode(r)&&n(168),r}!function(e){e.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var t={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(t).forEach((function(n){var r=t[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),"diff"===n&&i.push("bold"),e.languages.diff[n]={pattern:RegExp("^(?:["+r+"].*(?:\r\n?|\n|(?![\\s\\S])))+","m"),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}}})),Object.defineProperty(e.languages.diff,"PREFIXES",{value:t})}(Prism);const A=globalThis.Prism||window.Prism,b={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},L={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function M(e){return L[e]||e}function E(e){return"string"==typeof e?e:Array.isArray(e)?e.map(E).join(""):E(e.content)}function v(e,t){const n=/^diff-([\w-]+)/i.exec(t),r=e.getTextContent();let i=A.tokenize(r,A.languages[n?"diff":t]);return n&&(i=function(e,t){const n=t,r=A.languages[n],i={tokens:e},o=A.languages.diff.PREFIXES;for(const e of i.tokens){if("string"==typeof e||!(e.type in o)||!Array.isArray(e.content))continue;const t=e.type;let n=0;const i=()=>(n++,new A.Token("prefix",o[t],t.replace(/^(\w+).*/,"$1"))),s=e.content.filter((e=>"string"==typeof e||"prefix"!==e.type)),a=e.content.length-s.length,g=A.tokenize(E(s),r);g.unshift(i());const l=/\r\n|\n/g,u=e=>{const t=[];l.lastIndex=0;let r,o=0;for(;n<a&&(r=l.exec(e));){const n=r.index+r[0].length;t.push(e.slice(o,n)),o=n,t.push(i())}if(0!==t.length)return o<e.length&&t.push(e.slice(o)),t},c=e=>{for(let t=0;t<e.length&&n<a;t++){const n=e[t];if("string"==typeof n){const r=u(n);r&&(e.splice(t,1,...r),t+=r.length-1)}else if("string"==typeof n.content){const e=u(n.content);e&&(n.content=e)}else Array.isArray(n.content)?c(n.content):c([n.content])}};c(g),n<a&&g.push(i()),e.content=g}return i.tokens}(i,n[1])),D(i)}function D(e,n){const r=[];for(const i of e)if("string"==typeof i){const e=i.split(/(\n|\t)/),o=e.length;for(let i=0;i<o;i++){const o=e[i];"\n"===o||"\r\n"===o?r.push(t.$createLineBreakNode()):"\t"===o?r.push(t.$createTabNode()):o.length>0&&r.push(T(o,n))}}else{const{content:e,alias:t}=i;"string"==typeof e?r.push(...D([e],"prefix"===i.type&&"string"==typeof t?t:i.type)):Array.isArray(e)&&r.push(...D(e,"unchanged"===i.type?void 0:i.type))}return r}const R={$tokenize(e,t){return v(e,t||this.defaultLanguage)},defaultLanguage:r,tokenize(e,t){return A.tokenize(e,A.languages[t||""]||A.languages[this.defaultLanguage])}};function k(e,n,r){const i=e.getParent();u(i)?w(i,n,r):x(e)&&e.replace(t.$createTextNode(e.__text))}function P(e,n){const r=n.getElementByKey(e.getKey());if(null===r)return;const i=e.getChildren(),o=i.length;if(o===r.__cachedChildrenLength)return;r.__cachedChildrenLength=o;let s="1",a=1;for(let e=0;e<o;e++)t.$isLineBreakNode(i[e])&&(s+="\n"+ ++a);r.setAttribute("data-gutter",s)}const I=new Set;function w(e,n,r){const i=e.getKey();void 0===e.getLanguage()&&e.setLanguage(r.defaultLanguage);const o=e.getLanguage()||r.defaultLanguage;if(!function(e){const t=function(e){const t=/^diff-([\w-]+)/i.exec(e);return t?t[1]:null}(e),n=t||e;try{return!!n&&A.languages.hasOwnProperty(n)}catch(e){return!1}}(o))return e.getIsSyntaxHighlightSupported()&&e.setIsSyntaxHighlightSupported(!1),void async function(e,t,n){}();e.getIsSyntaxHighlightSupported()||e.setIsSyntaxHighlightSupported(!0),I.has(i)||(I.add(i),n.update((()=>{!function(e,n){const r=t.$getNodeByKey(e);if(!u(r)||!r.isAttached())return;const i=t.$getSelection();if(!t.$isRangeSelection(i))return void n();const o=i.anchor,s=o.offset,a="element"===o.type&&t.$isLineBreakNode(r.getChildAtIndex(o.offset-1));let g=0;if(!a){const e=o.getNode();g=s+e.getPreviousSiblings().reduce(((e,t)=>e+t.getTextContentSize()),0)}if(!n())return;if(a)return void o.getNode().select(s,s);r.getChildren().some((e=>{const n=t.$isTextNode(e);if(n||t.$isLineBreakNode(e)){const t=e.getTextContentSize();if(n&&t>=g)return e.select(g,g),!0;g-=t}return!1}))}(i,(()=>{const n=t.$getNodeByKey(i);if(!u(n)||!n.isAttached())return!1;const o=n.getLanguage()||r.defaultLanguage,s=r.$tokenize(n,o),a=function(e,t){let n=0;for(;n<e.length&&B(e[n],t[n]);)n++;const r=e.length,i=t.length,o=Math.min(r,i)-n;let s=0;for(;s<o;)if(s++,!B(e[r-s],t[i-s])){s--;break}const a=n,g=r-s,l=t.slice(n,i-s);return{from:a,nodesForReplacement:l,to:g}}(n.getChildren(),s),{from:g,to:l,nodesForReplacement:c}=a;return!(g===l&&!c.length)&&(e.splice(g,l-g,c),!0)}))}),{onUpdate:()=>{I.delete(i)},skipTransforms:!0}))}function B(e,n){return x(e)&&x(n)&&e.__text===n.__text&&e.__highlightType===n.__highlightType||t.$isTabNode(e)&&t.$isTabNode(n)||t.$isLineBreakNode(e)&&t.$isLineBreakNode(n)}function j(e){if(!t.$isRangeSelection(e))return!1;const n=e.anchor.getNode(),r=u(n)?n:n.getParent(),i=e.focus.getNode(),o=u(i)?i:i.getParent();return u(r)&&r.is(o)}function H(e){const r=e.getNodes(),i=[];if(1===r.length&&u(r[0]))return i;let o=[];for(let e=0;e<r.length;e++){const s=r[e];x(s)||t.$isTabNode(s)||t.$isLineBreakNode(s)||n(169),t.$isLineBreakNode(s)?o.length>0&&(i.push(o),o=[]):o.push(s)}if(o.length>0){const n=e.isBackward()?e.anchor:e.focus,r=t.$createPoint(o[0].getKey(),0,"text");n.is(r)||i.push(o)}return i}function F(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!j(n))return!1;const r=H(n),i=r.length;if(0===i&&n.isCollapsed())return e===t.INDENT_CONTENT_COMMAND&&n.insertNodes([t.$createTabNode()]),!0;if(0===i&&e===t.INDENT_CONTENT_COMMAND&&"\n"===n.getTextContent()){const e=t.$createTabNode(),r=t.$createLineBreakNode(),i=n.isBackward()?"previous":"next";return n.insertNodes([e,r]),t.$setSelectionFromCaretRange(t.$getCaretRangeInDirection(t.$getCaretRange(t.$getTextPointCaret(e,"next",0),t.$normalizeCaret(t.$getSiblingCaret(r,"next"))),i)),!0}for(let o=0;o<i;o++){const i=r[o];if(i.length>0){let r=i[0];if(0===o&&(r=O(r)),e===t.INDENT_CONTENT_COMMAND){const e=t.$createTabNode();if(r.insertBefore(e),0===o){const i=n.isBackward()?"focus":"anchor",o=t.$createPoint(r.getKey(),0,"text");n[i].is(o)&&n[i].set(e.getKey(),0,"text")}}else t.$isTabNode(r)&&r.remove()}}return!0}function q(e,n){const r=t.$getSelection();if(!t.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,s=i.offset,a=o.offset,g=i.getNode(),l=o.getNode(),u=e===t.KEY_ARROW_UP_COMMAND;if(!j(r)||!x(g)&&!t.$isTabNode(g)||!x(l)&&!t.$isTabNode(l))return!1;if(!n.altKey){if(r.isCollapsed()){const e=g.getParentOrThrow();if(u&&0===s&&null===g.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),n.preventDefault(),!0}else if(!u&&s===g.getTextContentSize()&&null===g.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),n.preventDefault(),!0}}return!1}let c,p;if(g.isBefore(l)?(c=O(g),p=S(l)):(c=O(l),p=S(g)),null==c||null==p)return!1;const d=c.getNodesBetween(p);for(let e=0;e<d.length;e++){const n=d[e];if(!x(n)&&!t.$isTabNode(n)&&!t.$isLineBreakNode(n))return!1}n.preventDefault(),n.stopPropagation();const f=u?c.getPreviousSibling():p.getNextSibling();if(!t.$isLineBreakNode(f))return!0;const h=u?f.getPreviousSibling():f.getNextSibling();if(null==h)return!0;const N=x(h)||t.$isTabNode(h)||t.$isLineBreakNode(h)?u?O(h):S(h):null;let m=null!=N?N:h;return f.remove(),d.forEach((e=>e.remove())),e===t.KEY_ARROW_UP_COMMAND?(d.forEach((e=>m.insertBefore(e))),m.insertBefore(f)):(m.insertAfter(f),m=f,d.forEach((e=>{m.insertAfter(e),m=e}))),r.setTextNodeRange(g,s,l,a),!0}function z(e,n){const r=t.$getSelection();if(!t.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,s=i.getNode(),a=o.getNode(),g=e===t.MOVE_TO_START;if(!j(r)||!x(s)&&!t.$isTabNode(s)||!x(a)&&!t.$isTabNode(a))return!1;if(g){const e=y(a,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 a.getParentOrThrow().selectStart()}else{$(a).select()}return n.preventDefault(),n.stopPropagation(),!0}const W=O,K=S,Y=$,U=y;exports.$createCodeHighlightNode=T,exports.$createCodeNode=l,exports.$getEndOfCodeInLine=$,exports.$getFirstCodeNodeOfLine=O,exports.$getLastCodeNodeOfLine=S,exports.$getStartOfCodeInLine=y,exports.$isCodeHighlightNode=x,exports.$isCodeNode=u,exports.CODE_LANGUAGE_FRIENDLY_NAME_MAP=b,exports.CODE_LANGUAGE_MAP=L,exports.CodeHighlightNode=m,exports.CodeNode=g,exports.DEFAULT_CODE_LANGUAGE=r,exports.PrismTokenizer=R,exports.getCodeLanguageOptions=function(){const e=[];for(const[t,n]of Object.entries(b))e.push([t,n]);return e},exports.getCodeLanguages=()=>Object.keys(A.languages).filter((e=>"function"!=typeof A.languages[e])).sort(),exports.getCodeThemeOptions=function(){return[]},exports.getDefaultCodeLanguage=()=>r,exports.getEndOfCodeInLine=Y,exports.getFirstCodeNodeOfLine=W,exports.getLanguageFriendlyName=function(e){const t=M(e);return b[t]||t},exports.getLastCodeNodeOfLine=K,exports.getStartOfCodeInLine=U,exports.normalizeCodeLang=M,exports.normalizeCodeLanguage=M,exports.registerCodeHighlighting=function(r,i){if(!r.hasNodes([g,m]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==i&&(i=R);const o=[];return!0!==r._headless&&o.push(r.registerMutationListener(g,(e=>{r.update((()=>{for(const[n,i]of e)if("destroyed"!==i){const e=t.$getNodeByKey(n);null!==e&&P(e,r)}}))}),{skipInitialization:!1})),o.push(r.registerNodeTransform(g,(e=>w(e,r,i))),r.registerNodeTransform(t.TextNode,(e=>k(e,r,i))),r.registerNodeTransform(m,(e=>k(e,r,i))),r.registerCommand(t.KEY_TAB_COMMAND,(e=>{const i=function(e){const r=t.$getSelection();if(!t.$isRangeSelection(r)||!j(r))return null;const i=e?t.OUTDENT_CONTENT_COMMAND:t.INDENT_CONTENT_COMMAND,o=e?t.OUTDENT_CONTENT_COMMAND:t.INSERT_TAB_COMMAND,s=r.anchor,a=r.focus;if(s.is(a))return o;const g=H(r);if(1!==g.length)return i;const l=g[0];let u,c;0===l.length&&n(285),r.isBackward()?(u=a,c=s):(u=s,c=a);const p=O(l[0]),d=S(l[0]),f=t.$createPoint(p.getKey(),0,"text"),h=t.$createPoint(d.getKey(),d.getTextContentSize(),"text");return u.isBefore(f)||h.isBefore(c)?i:f.isBefore(u)||c.isBefore(h)?o:i}(e.shiftKey);return null!==i&&(e.preventDefault(),r.dispatchCommand(i,void 0),!0)}),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.INSERT_TAB_COMMAND,(()=>!!j(t.$getSelection())&&(t.$insertNodes([t.$createTabNode()]),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.INDENT_CONTENT_COMMAND,(e=>F(t.INDENT_CONTENT_COMMAND)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.OUTDENT_CONTENT_COMMAND,(e=>F(t.OUTDENT_CONTENT_COMMAND)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_UP_COMMAND,(e=>{const n=t.$getSelection();if(!t.$isRangeSelection(n))return!1;const{anchor:r}=n,i=r.getNode();return!!j(n)&&(n.isCollapsed()&&0===r.offset&&null===i.getPreviousSibling()&&u(i.getParentOrThrow())?(e.preventDefault(),!0):q(t.KEY_ARROW_UP_COMMAND,e))}),t.COMMAND_PRIORITY_LOW),r.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!!j(n)&&(n.isCollapsed()&&r.offset===i.getTextContentSize()&&null===i.getNextSibling()&&u(i.getParentOrThrow())?(e.preventDefault(),!0):q(t.KEY_ARROW_DOWN_COMMAND,e))}),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.MOVE_TO_START,(e=>z(t.MOVE_TO_START,e)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.MOVE_TO_END,(e=>z(t.MOVE_TO_END,e)),t.COMMAND_PRIORITY_LOW)),e.mergeRegister(...o)};
9
+ "use strict";var e=require("@lexical/utils"),t=require("lexical");function n(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.`)}require("prismjs"),require("prismjs/components/prism-clike"),require("prismjs/components/prism-javascript"),require("prismjs/components/prism-markup"),require("prismjs/components/prism-markdown"),require("prismjs/components/prism-c"),require("prismjs/components/prism-css"),require("prismjs/components/prism-objectivec"),require("prismjs/components/prism-sql"),require("prismjs/components/prism-powershell"),require("prismjs/components/prism-python"),require("prismjs/components/prism-rust"),require("prismjs/components/prism-swift"),require("prismjs/components/prism-typescript"),require("prismjs/components/prism-java"),require("prismjs/components/prism-cpp");const r="javascript";function i(t,n){for(const r of t.childNodes){if(e.isHTMLElement(r)&&r.tagName===n)return!0;i(r,n)}return!1}const o="data-language",s="data-highlight-language",a="data-theme";class g extends t.ElementNode{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(e){return new g(e.__language,e.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(t){const n=document.createElement("code");e.addClassNamesToElement(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(o,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(s,r));const i=this.getTheme();i&&n.setAttribute(a,i);const g=this.getStyle();return g&&n.setAttribute("style",g),n}updateDOM(e,t,n){const r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(o,r):i&&t.removeAttribute(o);const g=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?g&&r?r!==i&&t.setAttribute(s,r):t.removeAttribute(s):g&&r&&t.setAttribute(s,r);const l=this.__theme,u=e.__theme;l?l!==u&&t.setAttribute(a,l):u&&t.removeAttribute(a);const c=this.__style,p=e.__style;return c?c!==p&&t.setAttribute("style",c):p&&t.removeAttribute("style"),!1}exportDOM(t){const n=document.createElement("pre");e.addClassNamesToElement(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(o,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(s,r));const i=this.getTheme();i&&n.setAttribute(a,i);const g=this.getStyle();return g&&n.setAttribute("style",g),{element:n}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||i(e,"BR"))?{conversion:c,priority:1}:null,div:()=>({conversion:p,priority:1}),pre:()=>({conversion:c,priority:0}),table:e=>N(e)?{conversion:d,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&N(n)?{conversion:f,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&N(t)?{conversion:f,priority:3}:null}}}static importJSON(e){return l().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,n=!0){const r=this.getChildren(),i=r.length;if(i>=2&&"\n"===r[i-1].getTextContent()&&"\n"===r[i-2].getTextContent()&&e.isCollapsed()&&e.anchor.key===this.__key&&e.anchor.offset===i){r[i-1].remove(),r[i-2].remove();const e=t.$createParagraphNode();return this.insertAfter(e,n),e}const{anchor:o,focus:s}=e,a=(o.isBefore(s)?o:s).getNode();if(t.$isTextNode(a)){let e=O(a);const n=[];for(;;)if(t.$isTabNode(e))n.push(t.$createTabNode()),e=e.getNextSibling();else{if(!x(e))break;{let t=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;t<i&&" "===r[t];)t++;if(0!==t&&n.push(T(" ".repeat(t))),t!==i)break;e=e.getNextSibling()}}const r=a.splitText(o.offset)[0],i=0===o.offset?0:1,s=r.getIndexWithinParent()+i,g=a.getParentOrThrow(),l=[t.$createLineBreakNode(),...n];g.splice(s,0,l);const u=n[n.length-1];u?u.select():0===o.offset?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(u(a)){const{offset:n}=e.anchor;a.splice(n,0,[t.$createLineBreakNode()]),a.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 l(e,n){return t.$create(g).setLanguage(e).setTheme(n)}function u(e){return e instanceof g}function c(e){return{node:l(e.getAttribute(o))}}function p(e){const t=e,n=h(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if(h(t))return!0;t=t.parentElement}return!1}(t)?{node:n?l():null}:{node:null}}function d(){return{node:l()}}function f(){return{node:null}}function h(e){return null!==e.style.fontFamily.match("monospace")}function N(e){return e.classList.contains("js-file-line-container")}class m extends t.TextNode{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(e){return new m(e.__text,e.__highlightType||void 0,e.__key)}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(t){const n=super.createDOM(t),r=_(t.theme,this.__highlightType);return e.addClassNamesToElement(n,r),n}updateDOM(t,n,r){const i=super.updateDOM(t,n,r),o=_(r.theme,t.__highlightType),s=_(r.theme,this.__highlightType);return o!==s&&(o&&e.removeClassNamesFromElement(n,o),s&&e.addClassNamesToElement(n,s)),i}static importJSON(e){return T().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 l()}}function _(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function T(e="",n){return t.$applyNodeReplacement(new m(e,n))}function x(e){return e instanceof m}function C(n,r){let i=n;for(let o=t.$getSiblingCaret(n,r);o&&(x(o.origin)||t.$isTabNode(o.origin));o=e.$getAdjacentCaret(o))i=o.origin;return i}function O(e){return C(e,"previous")}function S(e){return C(e,"next")}function y(e,r){let i=null,o=null,s=e,a=r,g=e.getTextContent();for(;;){if(0===a){if(s=s.getPreviousSibling(),null===s)break;if(x(s)||t.$isTabNode(s)||t.$isLineBreakNode(s)||n(167),t.$isLineBreakNode(s)){i={node:s,offset:1};break}a=Math.max(0,s.getTextContentSize()-1),g=s.getTextContent()}else a--;const e=g[a];x(s)&&" "!==e&&(o={node:s,offset:a})}if(null!==o)return o;let l=null;if(r<e.getTextContentSize())x(e)&&(l=e.getTextContent()[r]);else{const t=e.getNextSibling();x(t)&&(l=t.getTextContent()[0])}if(null!==l&&" "!==l)return i;{const n=function(e,n){let r=e,i=n,o=e.getTextContent(),s=e.getTextContentSize();for(;;){if(!x(r)||i===s){if(r=r.getNextSibling(),null===r||t.$isLineBreakNode(r))return null;x(r)&&(i=0,o=r.getTextContent(),s=r.getTextContentSize())}if(x(r)){if(" "!==o[i])return{node:r,offset:i};i++}}}(e,r);return null!==n?n:i}}function $(e){const r=S(e);return t.$isLineBreakNode(r)&&n(168),r}const A=t.defineExtension({name:"@lexical/code",nodes:[g,m]});!function(e){e.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var t={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(t).forEach((function(n){var r=t[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),"diff"===n&&i.push("bold"),e.languages.diff[n]={pattern:RegExp("^(?:["+r+"].*(?:\r\n?|\n|(?![\\s\\S])))+","m"),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}}})),Object.defineProperty(e.languages.diff,"PREFIXES",{value:t})}(Prism);const b=globalThis.Prism||window.Prism,L={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},M={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function E(e){return M[e]||e}function v(e){return"string"==typeof e?e:Array.isArray(e)?e.map(v).join(""):v(e.content)}function D(e,t){const n=/^diff-([\w-]+)/i.exec(t),r=e.getTextContent();let i=b.tokenize(r,b.languages[n?"diff":t]);return n&&(i=function(e,t){const n=t,r=b.languages[n],i={tokens:e},o=b.languages.diff.PREFIXES;for(const e of i.tokens){if("string"==typeof e||!(e.type in o)||!Array.isArray(e.content))continue;const t=e.type;let n=0;const i=()=>(n++,new b.Token("prefix",o[t],t.replace(/^(\w+).*/,"$1"))),s=e.content.filter((e=>"string"==typeof e||"prefix"!==e.type)),a=e.content.length-s.length,g=b.tokenize(v(s),r);g.unshift(i());const l=/\r\n|\n/g,u=e=>{const t=[];l.lastIndex=0;let r,o=0;for(;n<a&&(r=l.exec(e));){const n=r.index+r[0].length;t.push(e.slice(o,n)),o=n,t.push(i())}if(0!==t.length)return o<e.length&&t.push(e.slice(o)),t},c=e=>{for(let t=0;t<e.length&&n<a;t++){const n=e[t];if("string"==typeof n){const r=u(n);r&&(e.splice(t,1,...r),t+=r.length-1)}else if("string"==typeof n.content){const e=u(n.content);e&&(n.content=e)}else Array.isArray(n.content)?c(n.content):c([n.content])}};c(g),n<a&&g.push(i()),e.content=g}return i.tokens}(i,n[1])),R(i)}function R(e,n){const r=[];for(const i of e)if("string"==typeof i){const e=i.split(/(\n|\t)/),o=e.length;for(let i=0;i<o;i++){const o=e[i];"\n"===o||"\r\n"===o?r.push(t.$createLineBreakNode()):"\t"===o?r.push(t.$createTabNode()):o.length>0&&r.push(T(o,n))}}else{const{content:e,alias:t}=i;"string"==typeof e?r.push(...R([e],"prefix"===i.type&&"string"==typeof t?t:i.type)):Array.isArray(e)&&r.push(...R(e,"unchanged"===i.type?void 0:i.type))}return r}const k={$tokenize(e,t){return D(e,t||this.defaultLanguage)},defaultLanguage:r,tokenize(e,t){return b.tokenize(e,b.languages[t||""]||b.languages[this.defaultLanguage])}};function P(e,n,r){const i=e.getParent();u(i)?B(i,n,r):x(e)&&e.replace(t.$createTextNode(e.__text))}function I(e,n){const r=n.getElementByKey(e.getKey());if(null===r)return;const i=e.getChildren(),o=i.length;if(o===r.__cachedChildrenLength)return;r.__cachedChildrenLength=o;let s="1",a=1;for(let e=0;e<o;e++)t.$isLineBreakNode(i[e])&&(s+="\n"+ ++a);r.setAttribute("data-gutter",s)}const w=new Set;function B(e,n,r){const i=e.getKey();void 0===e.getLanguage()&&e.setLanguage(r.defaultLanguage);const o=e.getLanguage()||r.defaultLanguage;if(!function(e){const t=function(e){const t=/^diff-([\w-]+)/i.exec(e);return t?t[1]:null}(e),n=t||e;try{return!!n&&b.languages.hasOwnProperty(n)}catch(e){return!1}}(o))return e.getIsSyntaxHighlightSupported()&&e.setIsSyntaxHighlightSupported(!1),void async function(e,t,n){}();e.getIsSyntaxHighlightSupported()||e.setIsSyntaxHighlightSupported(!0),w.has(i)||(w.add(i),n.update((()=>{!function(e,n){const r=t.$getNodeByKey(e);if(!u(r)||!r.isAttached())return;const i=t.$getSelection();if(!t.$isRangeSelection(i))return void n();const o=i.anchor,s=o.offset,a="element"===o.type&&t.$isLineBreakNode(r.getChildAtIndex(o.offset-1));let g=0;if(!a){const e=o.getNode();g=s+e.getPreviousSiblings().reduce(((e,t)=>e+t.getTextContentSize()),0)}if(!n())return;if(a)return void o.getNode().select(s,s);r.getChildren().some((e=>{const n=t.$isTextNode(e);if(n||t.$isLineBreakNode(e)){const t=e.getTextContentSize();if(n&&t>=g)return e.select(g,g),!0;g-=t}return!1}))}(i,(()=>{const n=t.$getNodeByKey(i);if(!u(n)||!n.isAttached())return!1;const o=n.getLanguage()||r.defaultLanguage,s=r.$tokenize(n,o),a=function(e,t){let n=0;for(;n<e.length&&j(e[n],t[n]);)n++;const r=e.length,i=t.length,o=Math.min(r,i)-n;let s=0;for(;s<o;)if(s++,!j(e[r-s],t[i-s])){s--;break}const a=n,g=r-s,l=t.slice(n,i-s);return{from:a,nodesForReplacement:l,to:g}}(n.getChildren(),s),{from:g,to:l,nodesForReplacement:c}=a;return!(g===l&&!c.length)&&(e.splice(g,l-g,c),!0)}))}),{onUpdate:()=>{w.delete(i)},skipTransforms:!0}))}function j(e,n){return x(e)&&x(n)&&e.__text===n.__text&&e.__highlightType===n.__highlightType||t.$isTabNode(e)&&t.$isTabNode(n)||t.$isLineBreakNode(e)&&t.$isLineBreakNode(n)}function H(e){if(!t.$isRangeSelection(e))return!1;const n=e.anchor.getNode(),r=u(n)?n:n.getParent(),i=e.focus.getNode(),o=u(i)?i:i.getParent();return u(r)&&r.is(o)}function F(e){const r=e.getNodes(),i=[];if(1===r.length&&u(r[0]))return i;let o=[];for(let e=0;e<r.length;e++){const s=r[e];x(s)||t.$isTabNode(s)||t.$isLineBreakNode(s)||n(169),t.$isLineBreakNode(s)?o.length>0&&(i.push(o),o=[]):o.push(s)}if(o.length>0){const n=e.isBackward()?e.anchor:e.focus,r=t.$createPoint(o[0].getKey(),0,"text");n.is(r)||i.push(o)}return i}function q(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!H(n))return!1;const r=F(n),i=r.length;if(0===i&&n.isCollapsed())return e===t.INDENT_CONTENT_COMMAND&&n.insertNodes([t.$createTabNode()]),!0;if(0===i&&e===t.INDENT_CONTENT_COMMAND&&"\n"===n.getTextContent()){const e=t.$createTabNode(),r=t.$createLineBreakNode(),i=n.isBackward()?"previous":"next";return n.insertNodes([e,r]),t.$setSelectionFromCaretRange(t.$getCaretRangeInDirection(t.$getCaretRange(t.$getTextPointCaret(e,"next",0),t.$normalizeCaret(t.$getSiblingCaret(r,"next"))),i)),!0}for(let o=0;o<i;o++){const i=r[o];if(i.length>0){let r=i[0];if(0===o&&(r=O(r)),e===t.INDENT_CONTENT_COMMAND){const e=t.$createTabNode();if(r.insertBefore(e),0===o){const i=n.isBackward()?"focus":"anchor",o=t.$createPoint(r.getKey(),0,"text");n[i].is(o)&&n[i].set(e.getKey(),0,"text")}}else t.$isTabNode(r)&&r.remove()}}return!0}function z(e,n){const r=t.$getSelection();if(!t.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,s=i.offset,a=o.offset,g=i.getNode(),l=o.getNode(),u=e===t.KEY_ARROW_UP_COMMAND;if(!H(r)||!x(g)&&!t.$isTabNode(g)||!x(l)&&!t.$isTabNode(l))return!1;if(!n.altKey){if(r.isCollapsed()){const e=g.getParentOrThrow();if(u&&0===s&&null===g.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),n.preventDefault(),!0}else if(!u&&s===g.getTextContentSize()&&null===g.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),n.preventDefault(),!0}}return!1}let c,p;if(g.isBefore(l)?(c=O(g),p=S(l)):(c=O(l),p=S(g)),null==c||null==p)return!1;const d=c.getNodesBetween(p);for(let e=0;e<d.length;e++){const n=d[e];if(!x(n)&&!t.$isTabNode(n)&&!t.$isLineBreakNode(n))return!1}n.preventDefault(),n.stopPropagation();const f=u?c.getPreviousSibling():p.getNextSibling();if(!t.$isLineBreakNode(f))return!0;const h=u?f.getPreviousSibling():f.getNextSibling();if(null==h)return!0;const N=x(h)||t.$isTabNode(h)||t.$isLineBreakNode(h)?u?O(h):S(h):null;let m=null!=N?N:h;return f.remove(),d.forEach((e=>e.remove())),e===t.KEY_ARROW_UP_COMMAND?(d.forEach((e=>m.insertBefore(e))),m.insertBefore(f)):(m.insertAfter(f),m=f,d.forEach((e=>{m.insertAfter(e),m=e}))),r.setTextNodeRange(g,s,l,a),!0}function W(e,n){const r=t.$getSelection();if(!t.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,s=i.getNode(),a=o.getNode(),g=e===t.MOVE_TO_START;if(!H(r)||!x(s)&&!t.$isTabNode(s)||!x(a)&&!t.$isTabNode(a))return!1;if(g){const e=y(a,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 a.getParentOrThrow().selectStart()}else{$(a).select()}return n.preventDefault(),n.stopPropagation(),!0}const K=O,Y=S,U=$,J=y;exports.$createCodeHighlightNode=T,exports.$createCodeNode=l,exports.$getEndOfCodeInLine=$,exports.$getFirstCodeNodeOfLine=O,exports.$getLastCodeNodeOfLine=S,exports.$getStartOfCodeInLine=y,exports.$isCodeHighlightNode=x,exports.$isCodeNode=u,exports.CODE_LANGUAGE_FRIENDLY_NAME_MAP=L,exports.CODE_LANGUAGE_MAP=M,exports.CodeExtension=A,exports.CodeHighlightNode=m,exports.CodeNode=g,exports.DEFAULT_CODE_LANGUAGE=r,exports.PrismTokenizer=k,exports.getCodeLanguageOptions=function(){const e=[];for(const[t,n]of Object.entries(L))e.push([t,n]);return e},exports.getCodeLanguages=()=>Object.keys(b.languages).filter((e=>"function"!=typeof b.languages[e])).sort(),exports.getCodeThemeOptions=function(){return[]},exports.getDefaultCodeLanguage=()=>r,exports.getEndOfCodeInLine=U,exports.getFirstCodeNodeOfLine=K,exports.getLanguageFriendlyName=function(e){const t=E(e);return L[t]||t},exports.getLastCodeNodeOfLine=Y,exports.getStartOfCodeInLine=J,exports.normalizeCodeLang=E,exports.normalizeCodeLanguage=E,exports.registerCodeHighlighting=function(r,i){if(!r.hasNodes([g,m]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==i&&(i=k);const o=[];return!0!==r._headless&&o.push(r.registerMutationListener(g,(e=>{r.update((()=>{for(const[n,i]of e)if("destroyed"!==i){const e=t.$getNodeByKey(n);null!==e&&I(e,r)}}))}),{skipInitialization:!1})),o.push(r.registerNodeTransform(g,(e=>B(e,r,i))),r.registerNodeTransform(t.TextNode,(e=>P(e,r,i))),r.registerNodeTransform(m,(e=>P(e,r,i))),r.registerCommand(t.KEY_TAB_COMMAND,(e=>{const i=function(e){const r=t.$getSelection();if(!t.$isRangeSelection(r)||!H(r))return null;const i=e?t.OUTDENT_CONTENT_COMMAND:t.INDENT_CONTENT_COMMAND,o=e?t.OUTDENT_CONTENT_COMMAND:t.INSERT_TAB_COMMAND,s=r.anchor,a=r.focus;if(s.is(a))return o;const g=F(r);if(1!==g.length)return i;const l=g[0];let u,c;0===l.length&&n(285),r.isBackward()?(u=a,c=s):(u=s,c=a);const p=O(l[0]),d=S(l[0]),f=t.$createPoint(p.getKey(),0,"text"),h=t.$createPoint(d.getKey(),d.getTextContentSize(),"text");return u.isBefore(f)||h.isBefore(c)?i:f.isBefore(u)||c.isBefore(h)?o:i}(e.shiftKey);return null!==i&&(e.preventDefault(),r.dispatchCommand(i,void 0),!0)}),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.INSERT_TAB_COMMAND,(()=>!!H(t.$getSelection())&&(t.$insertNodes([t.$createTabNode()]),!0)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.INDENT_CONTENT_COMMAND,(e=>q(t.INDENT_CONTENT_COMMAND)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.OUTDENT_CONTENT_COMMAND,(e=>q(t.OUTDENT_CONTENT_COMMAND)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.KEY_ARROW_UP_COMMAND,(e=>{const n=t.$getSelection();if(!t.$isRangeSelection(n))return!1;const{anchor:r}=n,i=r.getNode();return!!H(n)&&(n.isCollapsed()&&0===r.offset&&null===i.getPreviousSibling()&&u(i.getParentOrThrow())?(e.preventDefault(),!0):z(t.KEY_ARROW_UP_COMMAND,e))}),t.COMMAND_PRIORITY_LOW),r.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!!H(n)&&(n.isCollapsed()&&r.offset===i.getTextContentSize()&&null===i.getNextSibling()&&u(i.getParentOrThrow())?(e.preventDefault(),!0):z(t.KEY_ARROW_DOWN_COMMAND,e))}),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.MOVE_TO_START,(e=>W(t.MOVE_TO_START,e)),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.MOVE_TO_END,(e=>W(t.MOVE_TO_END,e)),t.COMMAND_PRIORITY_LOW)),e.mergeRegister(...o)};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{isHTMLElement as t,addClassNamesToElement as e,removeClassNamesFromElement as n,$getAdjacentCaret as r,mergeRegister as i}from"@lexical/utils";import{ElementNode as o,$createParagraphNode as s,$isTextNode as u,$isTabNode as l,$createTabNode as c,$createLineBreakNode as a,$create as g,TextNode as f,$applyNodeReplacement as p,$getSiblingCaret as h,$isLineBreakNode as d,$createTextNode as m,$getNodeByKey as y,$getSelection as x,$isRangeSelection as S,$createPoint as _,INDENT_CONTENT_COMMAND as v,OUTDENT_CONTENT_COMMAND as T,INSERT_TAB_COMMAND as b,$setSelectionFromCaretRange as C,$getCaretRangeInDirection as N,$getCaretRange as j,$getTextPointCaret as w,$normalizeCaret as k,KEY_ARROW_UP_COMMAND as A,MOVE_TO_START as P,KEY_TAB_COMMAND as L,COMMAND_PRIORITY_LOW as O,$insertNodes as H,KEY_ARROW_DOWN_COMMAND as z,MOVE_TO_END as E}from"lexical";import"prismjs";import"prismjs/components/prism-clike.js";import"prismjs/components/prism-javascript.js";import"prismjs/components/prism-markup.js";import"prismjs/components/prism-markdown.js";import"prismjs/components/prism-c.js";import"prismjs/components/prism-css.js";import"prismjs/components/prism-objectivec.js";import"prismjs/components/prism-sql.js";import"prismjs/components/prism-powershell.js";import"prismjs/components/prism-python.js";import"prismjs/components/prism-rust.js";import"prismjs/components/prism-swift.js";import"prismjs/components/prism-typescript.js";import"prismjs/components/prism-java.js";import"prismjs/components/prism-cpp.js";function B(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const D="javascript",F=()=>D;function I(e,n){for(const r of e.childNodes){if(t(r)&&r.tagName===n)return!0;I(r,n)}return!1}const M="data-language",J="data-highlight-language",R="data-theme";class K extends o{static getType(){return"code"}static clone(t){return new K(t.__language,t.__key)}constructor(t,e){super(e),this.__language=t||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(t){super.afterCloneFrom(t),this.__language=t.__language,this.__theme=t.__theme,this.__isSyntaxHighlightSupported=t.__isSyntaxHighlightSupported}createDOM(t){const n=document.createElement("code");e(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(M,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(J,r));const i=this.getTheme();i&&n.setAttribute(R,i);const o=this.getStyle();return o&&n.setAttribute("style",o),n}updateDOM(t,e,n){const r=this.__language,i=t.__language;r?r!==i&&e.setAttribute(M,r):i&&e.removeAttribute(M);const o=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&e.setAttribute(J,r):e.removeAttribute(J):o&&r&&e.setAttribute(J,r);const s=this.__theme,u=t.__theme;s?s!==u&&e.setAttribute(R,s):u&&e.removeAttribute(R);const l=this.__style,c=t.__style;return l?l!==c&&e.setAttribute("style",l):c&&e.removeAttribute("style"),!1}exportDOM(t){const n=document.createElement("pre");e(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(M,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(J,r));const i=this.getTheme();i&&n.setAttribute(R,i);const o=this.getStyle();return o&&n.setAttribute("style",o),{element:n}}static importDOM(){return{code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||I(t,"BR"))?{conversion:q,priority:1}:null,div:()=>({conversion:U,priority:1}),pre:()=>({conversion:q,priority:0}),table:t=>V(t)?{conversion:X,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&V(n)?{conversion:Q,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&V(e)?{conversion:Q,priority:3}:null}}}static importJSON(t){return $().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setLanguage(t.language).setTheme(t.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(t,e=!0){const n=this.getChildren(),r=n.length;if(r>=2&&"\n"===n[r-1].getTextContent()&&"\n"===n[r-2].getTextContent()&&t.isCollapsed()&&t.anchor.key===this.__key&&t.anchor.offset===r){n[r-1].remove(),n[r-2].remove();const t=s();return this.insertAfter(t,e),t}const{anchor:i,focus:o}=t,g=(i.isBefore(o)?i:o).getNode();if(u(g)){let t=rt(g);const e=[];for(;;)if(l(t))e.push(c()),t=t.getNextSibling();else{if(!et(t))break;{let n=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&e.push(tt(" ".repeat(n))),n!==i)break;t=t.getNextSibling()}}const n=g.splitText(i.offset)[0],r=0===i.offset?0:1,o=n.getIndexWithinParent()+r,s=g.getParentOrThrow(),u=[a(),...e];s.splice(o,0,u);const f=e[e.length-1];f?f.select():0===i.offset?n.selectPrevious():n.getNextSibling().selectNext(0,0)}if(W(g)){const{offset:e}=t.anchor;g.splice(e,0,[a()]),g.select(e+1,e+1)}return null}canIndent(){return!1}collapseAtStart(){const t=s();return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}setLanguage(t){const e=this.getWritable();return e.__language=t||void 0,e}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(t){const e=this.getWritable();return e.__isSyntaxHighlightSupported=t,e}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(t){const e=this.getWritable();return e.__theme=t||void 0,e}getTheme(){return this.getLatest().__theme}}function $(t,e){return g(K).setLanguage(t).setTheme(e)}function W(t){return t instanceof K}function q(t){return{node:$(t.getAttribute(M))}}function U(t){const e=t,n=G(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(G(e))return!0;e=e.parentElement}return!1}(e)?{node:n?$():null}:{node:null}}function X(){return{node:$()}}function Q(){return{node:null}}function G(t){return null!==t.style.fontFamily.match("monospace")}function V(t){return t.classList.contains("js-file-line-container")}class Y extends f{constructor(t="",e,n){super(t,n),this.__highlightType=e}static getType(){return"code-highlight"}static clone(t){return new Y(t.__text,t.__highlightType||void 0,t.__key)}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(t){const e=this.getWritable();return e.__highlightType=t||void 0,e}canHaveFormat(){return!1}createDOM(t){const n=super.createDOM(t),r=Z(t.theme,this.__highlightType);return e(n,r),n}updateDOM(t,r,i){const o=super.updateDOM(t,r,i),s=Z(i.theme,t.__highlightType),u=Z(i.theme,this.__highlightType);return s!==u&&(s&&n(r,s),u&&e(r,u)),o}static importJSON(t){return tt().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setHighlightType(t.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(t){return this}isParentRequired(){return!0}createParentElementNode(){return $()}}function Z(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function tt(t="",e){return p(new Y(t,e))}function et(t){return t instanceof Y}function nt(t,e){let n=t;for(let i=h(t,e);i&&(et(i.origin)||l(i.origin));i=r(i))n=i.origin;return n}function rt(t){return nt(t,"previous")}function it(t){return nt(t,"next")}function ot(t,e){let n=null,r=null,i=t,o=e,s=t.getTextContent();for(;;){if(0===o){if(i=i.getPreviousSibling(),null===i)break;if(et(i)||l(i)||d(i)||B(167),d(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent()}else o--;const t=s[o];et(i)&&" "!==t&&(r={node:i,offset:o})}if(null!==r)return r;let u=null;if(e<t.getTextContentSize())et(t)&&(u=t.getTextContent()[e]);else{const e=t.getNextSibling();et(e)&&(u=e.getTextContent()[0])}if(null!==u&&" "!==u)return n;{const r=function(t,e){let n=t,r=e,i=t.getTextContent(),o=t.getTextContentSize();for(;;){if(!et(n)||r===o){if(n=n.getNextSibling(),null===n||d(n))return null;et(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize())}if(et(n)){if(" "!==i[r])return{node:n,offset:r};r++}}}(t,e);return null!==r?r:n}}function st(t){const e=it(t);return d(e)&&B(168),e}!function(t){t.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var e={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(e).forEach((function(n){var r=e[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),"diff"===n&&i.push("bold"),t.languages.diff[n]={pattern:RegExp("^(?:["+r+"].*(?:\r\n?|\n|(?![\\s\\S])))+","m"),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}}})),Object.defineProperty(t.languages.diff,"PREFIXES",{value:e})}(Prism);const ut=globalThis.Prism||window.Prism,lt={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},ct={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function at(t){return ct[t]||t}function gt(t){const e=at(t);return lt[e]||e}const ft=()=>Object.keys(ut.languages).filter((t=>"function"!=typeof ut.languages[t])).sort();function pt(){const t=[];for(const[e,n]of Object.entries(lt))t.push([e,n]);return t}function ht(){return[]}function dt(t){return"string"==typeof t?t:Array.isArray(t)?t.map(dt).join(""):dt(t.content)}function mt(t,e){const n=/^diff-([\w-]+)/i.exec(e),r=t.getTextContent();let i=ut.tokenize(r,ut.languages[n?"diff":e]);return n&&(i=function(t,e){const n=e,r=ut.languages[n],i={tokens:t},o=ut.languages.diff.PREFIXES;for(const t of i.tokens){if("string"==typeof t||!(t.type in o)||!Array.isArray(t.content))continue;const e=t.type;let n=0;const i=()=>(n++,new ut.Token("prefix",o[e],e.replace(/^(\w+).*/,"$1"))),s=t.content.filter((t=>"string"==typeof t||"prefix"!==t.type)),u=t.content.length-s.length,l=ut.tokenize(dt(s),r);l.unshift(i());const c=/\r\n|\n/g,a=t=>{const e=[];c.lastIndex=0;let r,o=0;for(;n<u&&(r=c.exec(t));){const n=r.index+r[0].length;e.push(t.slice(o,n)),o=n,e.push(i())}if(0!==e.length)return o<t.length&&e.push(t.slice(o)),e},g=t=>{for(let e=0;e<t.length&&n<u;e++){const n=t[e];if("string"==typeof n){const r=a(n);r&&(t.splice(e,1,...r),e+=r.length-1)}else if("string"==typeof n.content){const t=a(n.content);t&&(n.content=t)}else Array.isArray(n.content)?g(n.content):g([n.content])}};g(l),n<u&&l.push(i()),t.content=l}return i.tokens}(i,n[1])),yt(i)}function yt(t,e){const n=[];for(const r of t)if("string"==typeof r){const t=r.split(/(\n|\t)/),i=t.length;for(let r=0;r<i;r++){const i=t[r];"\n"===i||"\r\n"===i?n.push(a()):"\t"===i?n.push(c()):i.length>0&&n.push(tt(i,e))}}else{const{content:t,alias:e}=r;"string"==typeof t?n.push(...yt([t],"prefix"===r.type&&"string"==typeof e?e:r.type)):Array.isArray(t)&&n.push(...yt(t,"unchanged"===r.type?void 0:r.type))}return n}const xt={$tokenize(t,e){return mt(t,e||this.defaultLanguage)},defaultLanguage:D,tokenize(t,e){return ut.tokenize(t,ut.languages[e||""]||ut.languages[this.defaultLanguage])}};function St(t,e,n){const r=t.getParent();W(r)?Tt(r,e,n):et(t)&&t.replace(m(t.__text))}function _t(t,e){const n=e.getElementByKey(t.getKey());if(null===n)return;const r=t.getChildren(),i=r.length;if(i===n.__cachedChildrenLength)return;n.__cachedChildrenLength=i;let o="1",s=1;for(let t=0;t<i;t++)d(r[t])&&(o+="\n"+ ++s);n.setAttribute("data-gutter",o)}const vt=new Set;function Tt(t,e,n){const r=t.getKey();void 0===t.getLanguage()&&t.setLanguage(n.defaultLanguage);const i=t.getLanguage()||n.defaultLanguage;if(!function(t){const e=function(t){const e=/^diff-([\w-]+)/i.exec(t);return e?e[1]:null}(t),n=e||t;try{return!!n&&ut.languages.hasOwnProperty(n)}catch(t){return!1}}(i))return t.getIsSyntaxHighlightSupported()&&t.setIsSyntaxHighlightSupported(!1),void async function(t,e,n){}();t.getIsSyntaxHighlightSupported()||t.setIsSyntaxHighlightSupported(!0),vt.has(r)||(vt.add(r),e.update((()=>{!function(t,e){const n=y(t);if(!W(n)||!n.isAttached())return;const r=x();if(!S(r))return void e();const i=r.anchor,o=i.offset,s="element"===i.type&&d(n.getChildAtIndex(i.offset-1));let l=0;if(!s){const t=i.getNode();l=o+t.getPreviousSiblings().reduce(((t,e)=>t+e.getTextContentSize()),0)}if(!e())return;if(s)return void i.getNode().select(o,o);n.getChildren().some((t=>{const e=u(t);if(e||d(t)){const n=t.getTextContentSize();if(e&&n>=l)return t.select(l,l),!0;l-=n}return!1}))}(r,(()=>{const e=y(r);if(!W(e)||!e.isAttached())return!1;const i=e.getLanguage()||n.defaultLanguage,o=n.$tokenize(e,i),s=function(t,e){let n=0;for(;n<t.length&&bt(t[n],e[n]);)n++;const r=t.length,i=e.length,o=Math.min(r,i)-n;let s=0;for(;s<o;)if(s++,!bt(t[r-s],e[i-s])){s--;break}const u=n,l=r-s,c=e.slice(n,i-s);return{from:u,nodesForReplacement:c,to:l}}(e.getChildren(),o),{from:u,to:l,nodesForReplacement:c}=s;return!(u===l&&!c.length)&&(t.splice(u,l-u,c),!0)}))}),{onUpdate:()=>{vt.delete(r)},skipTransforms:!0}))}function bt(t,e){return et(t)&&et(e)&&t.__text===e.__text&&t.__highlightType===e.__highlightType||l(t)&&l(e)||d(t)&&d(e)}function Ct(t){if(!S(t))return!1;const e=t.anchor.getNode(),n=W(e)?e:e.getParent(),r=t.focus.getNode(),i=W(r)?r:r.getParent();return W(n)&&n.is(i)}function Nt(t){const e=t.getNodes(),n=[];if(1===e.length&&W(e[0]))return n;let r=[];for(let t=0;t<e.length;t++){const i=e[t];et(i)||l(i)||d(i)||B(169),d(i)?r.length>0&&(n.push(r),r=[]):r.push(i)}if(r.length>0){const e=t.isBackward()?t.anchor:t.focus,i=_(r[0].getKey(),0,"text");e.is(i)||n.push(r)}return n}function jt(t){const e=x();if(!S(e)||!Ct(e))return!1;const n=Nt(e),r=n.length;if(0===r&&e.isCollapsed())return t===v&&e.insertNodes([c()]),!0;if(0===r&&t===v&&"\n"===e.getTextContent()){const t=c(),n=a(),r=e.isBackward()?"previous":"next";return e.insertNodes([t,n]),C(N(j(w(t,"next",0),k(h(n,"next"))),r)),!0}for(let i=0;i<r;i++){const r=n[i];if(r.length>0){let n=r[0];if(0===i&&(n=rt(n)),t===v){const t=c();if(n.insertBefore(t),0===i){const r=e.isBackward()?"focus":"anchor",i=_(n.getKey(),0,"text");e[r].is(i)&&e[r].set(t.getKey(),0,"text")}}else l(n)&&n.remove()}}return!0}function wt(t,e){const n=x();if(!S(n))return!1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,u=r.getNode(),c=i.getNode(),a=t===A;if(!Ct(n)||!et(u)&&!l(u)||!et(c)&&!l(c))return!1;if(!e.altKey){if(n.isCollapsed()){const t=u.getParentOrThrow();if(a&&0===o&&null===u.getPreviousSibling()){if(null===t.getPreviousSibling())return t.selectPrevious(),e.preventDefault(),!0}else if(!a&&o===u.getTextContentSize()&&null===u.getNextSibling()){if(null===t.getNextSibling())return t.selectNext(),e.preventDefault(),!0}}return!1}let g,f;if(u.isBefore(c)?(g=rt(u),f=it(c)):(g=rt(c),f=it(u)),null==g||null==f)return!1;const p=g.getNodesBetween(f);for(let t=0;t<p.length;t++){const e=p[t];if(!et(e)&&!l(e)&&!d(e))return!1}e.preventDefault(),e.stopPropagation();const h=a?g.getPreviousSibling():f.getNextSibling();if(!d(h))return!0;const m=a?h.getPreviousSibling():h.getNextSibling();if(null==m)return!0;const y=et(m)||l(m)||d(m)?a?rt(m):it(m):null;let _=null!=y?y:m;return h.remove(),p.forEach((t=>t.remove())),t===A?(p.forEach((t=>_.insertBefore(t))),_.insertBefore(h)):(_.insertAfter(h),_=h,p.forEach((t=>{_.insertAfter(t),_=t}))),n.setTextNodeRange(u,o,c,s),!0}function kt(t,e){const n=x();if(!S(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),u=t===P;if(!Ct(n)||!et(o)&&!l(o)||!et(s)&&!l(s))return!1;if(u){const t=ot(s,i.offset);if(null!==t){const{node:e,offset:r}=t;d(e)?e.selectNext(0,0):n.setTextNodeRange(e,r,e,r)}else s.getParentOrThrow().selectStart()}else{st(s).select()}return e.preventDefault(),e.stopPropagation(),!0}function At(t,e){if(!t.hasNodes([K,Y]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==e&&(e=xt);const n=[];return!0!==t._headless&&n.push(t.registerMutationListener(K,(e=>{t.update((()=>{for(const[n,r]of e)if("destroyed"!==r){const e=y(n);null!==e&&_t(e,t)}}))}),{skipInitialization:!1})),n.push(t.registerNodeTransform(K,(n=>Tt(n,t,e))),t.registerNodeTransform(f,(n=>St(n,t,e))),t.registerNodeTransform(Y,(n=>St(n,t,e))),t.registerCommand(L,(e=>{const n=function(t){const e=x();if(!S(e)||!Ct(e))return null;const n=t?T:v,r=t?T:b,i=e.anchor,o=e.focus;if(i.is(o))return r;const s=Nt(e);if(1!==s.length)return n;const u=s[0];let l,c;0===u.length&&B(285),e.isBackward()?(l=o,c=i):(l=i,c=o);const a=rt(u[0]),g=it(u[0]),f=_(a.getKey(),0,"text"),p=_(g.getKey(),g.getTextContentSize(),"text");return l.isBefore(f)||p.isBefore(c)?n:f.isBefore(l)||c.isBefore(p)?r:n}(e.shiftKey);return null!==n&&(e.preventDefault(),t.dispatchCommand(n,void 0),!0)}),O),t.registerCommand(b,(()=>!!Ct(x())&&(H([c()]),!0)),O),t.registerCommand(v,(t=>jt(v)),O),t.registerCommand(T,(t=>jt(T)),O),t.registerCommand(A,(t=>{const e=x();if(!S(e))return!1;const{anchor:n}=e,r=n.getNode();return!!Ct(e)&&(e.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&W(r.getParentOrThrow())?(t.preventDefault(),!0):wt(A,t))}),O),t.registerCommand(z,(t=>{const e=x();if(!S(e))return!1;const{anchor:n}=e,r=n.getNode();return!!Ct(e)&&(e.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&W(r.getParentOrThrow())?(t.preventDefault(),!0):wt(z,t))}),O),t.registerCommand(P,(t=>kt(P,t)),O),t.registerCommand(E,(t=>kt(E,t)),O)),i(...n)}const Pt=rt,Lt=it,Ot=st,Ht=ot;export{tt as $createCodeHighlightNode,$ as $createCodeNode,st as $getEndOfCodeInLine,rt as $getFirstCodeNodeOfLine,it as $getLastCodeNodeOfLine,ot as $getStartOfCodeInLine,et as $isCodeHighlightNode,W as $isCodeNode,lt as CODE_LANGUAGE_FRIENDLY_NAME_MAP,ct as CODE_LANGUAGE_MAP,Y as CodeHighlightNode,K as CodeNode,D as DEFAULT_CODE_LANGUAGE,xt as PrismTokenizer,pt as getCodeLanguageOptions,ft as getCodeLanguages,ht as getCodeThemeOptions,F as getDefaultCodeLanguage,Ot as getEndOfCodeInLine,Pt as getFirstCodeNodeOfLine,gt as getLanguageFriendlyName,Lt as getLastCodeNodeOfLine,Ht as getStartOfCodeInLine,at as normalizeCodeLang,at as normalizeCodeLanguage,At as registerCodeHighlighting};
9
+ import{isHTMLElement as t,addClassNamesToElement as e,removeClassNamesFromElement as n,$getAdjacentCaret as r,mergeRegister as i}from"@lexical/utils";import{ElementNode as o,$createParagraphNode as s,$isTextNode as l,$isTabNode as u,$createTabNode as c,$createLineBreakNode as g,$create as a,TextNode as p,$applyNodeReplacement as f,$getSiblingCaret as h,$isLineBreakNode as d,defineExtension as m,$createTextNode as y,$getNodeByKey as x,$getSelection as _,$isRangeSelection as S,$createPoint as v,INDENT_CONTENT_COMMAND as T,OUTDENT_CONTENT_COMMAND as b,INSERT_TAB_COMMAND as C,$setSelectionFromCaretRange as N,$getCaretRangeInDirection as j,$getCaretRange as w,$getTextPointCaret as k,$normalizeCaret as A,KEY_ARROW_UP_COMMAND as P,MOVE_TO_START as L,KEY_TAB_COMMAND as O,COMMAND_PRIORITY_LOW as H,$insertNodes as z,KEY_ARROW_DOWN_COMMAND as E,MOVE_TO_END as B}from"lexical";import"prismjs";import"prismjs/components/prism-clike.js";import"prismjs/components/prism-javascript.js";import"prismjs/components/prism-markup.js";import"prismjs/components/prism-markdown.js";import"prismjs/components/prism-c.js";import"prismjs/components/prism-css.js";import"prismjs/components/prism-objectivec.js";import"prismjs/components/prism-sql.js";import"prismjs/components/prism-powershell.js";import"prismjs/components/prism-python.js";import"prismjs/components/prism-rust.js";import"prismjs/components/prism-swift.js";import"prismjs/components/prism-typescript.js";import"prismjs/components/prism-java.js";import"prismjs/components/prism-cpp.js";function D(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const F="javascript",I=()=>F;function M(e,n){for(const r of e.childNodes){if(t(r)&&r.tagName===n)return!0;M(r,n)}return!1}const J="data-language",R="data-highlight-language",K="data-theme";class $ extends o{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(t){return new $(t.__language,t.__key)}constructor(t,e){super(e),this.__language=t||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(t){super.afterCloneFrom(t),this.__language=t.__language,this.__theme=t.__theme,this.__isSyntaxHighlightSupported=t.__isSyntaxHighlightSupported}createDOM(t){const n=document.createElement("code");e(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(J,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(R,r));const i=this.getTheme();i&&n.setAttribute(K,i);const o=this.getStyle();return o&&n.setAttribute("style",o),n}updateDOM(t,e,n){const r=this.__language,i=t.__language;r?r!==i&&e.setAttribute(J,r):i&&e.removeAttribute(J);const o=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&e.setAttribute(R,r):e.removeAttribute(R):o&&r&&e.setAttribute(R,r);const s=this.__theme,l=t.__theme;s?s!==l&&e.setAttribute(K,s):l&&e.removeAttribute(K);const u=this.__style,c=t.__style;return u?u!==c&&e.setAttribute("style",u):c&&e.removeAttribute("style"),!1}exportDOM(t){const n=document.createElement("pre");e(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(J,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(R,r));const i=this.getTheme();i&&n.setAttribute(K,i);const o=this.getStyle();return o&&n.setAttribute("style",o),{element:n}}static importDOM(){return{code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||M(t,"BR"))?{conversion:U,priority:1}:null,div:()=>({conversion:X,priority:1}),pre:()=>({conversion:U,priority:0}),table:t=>Y(t)?{conversion:Q,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&Y(n)?{conversion:G,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&Y(e)?{conversion:G,priority:3}:null}}}static importJSON(t){return W().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setLanguage(t.language).setTheme(t.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(t,e=!0){const n=this.getChildren(),r=n.length;if(r>=2&&"\n"===n[r-1].getTextContent()&&"\n"===n[r-2].getTextContent()&&t.isCollapsed()&&t.anchor.key===this.__key&&t.anchor.offset===r){n[r-1].remove(),n[r-2].remove();const t=s();return this.insertAfter(t,e),t}const{anchor:i,focus:o}=t,a=(i.isBefore(o)?i:o).getNode();if(l(a)){let t=it(a);const e=[];for(;;)if(u(t))e.push(c()),t=t.getNextSibling();else{if(!nt(t))break;{let n=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&e.push(et(" ".repeat(n))),n!==i)break;t=t.getNextSibling()}}const n=a.splitText(i.offset)[0],r=0===i.offset?0:1,o=n.getIndexWithinParent()+r,s=a.getParentOrThrow(),l=[g(),...e];s.splice(o,0,l);const p=e[e.length-1];p?p.select():0===i.offset?n.selectPrevious():n.getNextSibling().selectNext(0,0)}if(q(a)){const{offset:e}=t.anchor;a.splice(e,0,[g()]),a.select(e+1,e+1)}return null}canIndent(){return!1}collapseAtStart(){const t=s();return this.getChildren().forEach((e=>t.append(e))),this.replace(t),!0}setLanguage(t){const e=this.getWritable();return e.__language=t||void 0,e}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(t){const e=this.getWritable();return e.__isSyntaxHighlightSupported=t,e}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(t){const e=this.getWritable();return e.__theme=t||void 0,e}getTheme(){return this.getLatest().__theme}}function W(t,e){return a($).setLanguage(t).setTheme(e)}function q(t){return t instanceof $}function U(t){return{node:W(t.getAttribute(J))}}function X(t){const e=t,n=V(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(V(e))return!0;e=e.parentElement}return!1}(e)?{node:n?W():null}:{node:null}}function Q(){return{node:W()}}function G(){return{node:null}}function V(t){return null!==t.style.fontFamily.match("monospace")}function Y(t){return t.classList.contains("js-file-line-container")}class Z extends p{__highlightType;constructor(t="",e,n){super(t,n),this.__highlightType=e}static getType(){return"code-highlight"}static clone(t){return new Z(t.__text,t.__highlightType||void 0,t.__key)}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(t){const e=this.getWritable();return e.__highlightType=t||void 0,e}canHaveFormat(){return!1}createDOM(t){const n=super.createDOM(t),r=tt(t.theme,this.__highlightType);return e(n,r),n}updateDOM(t,r,i){const o=super.updateDOM(t,r,i),s=tt(i.theme,t.__highlightType),l=tt(i.theme,this.__highlightType);return s!==l&&(s&&n(r,s),l&&e(r,l)),o}static importJSON(t){return et().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setHighlightType(t.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(t){return this}isParentRequired(){return!0}createParentElementNode(){return W()}}function tt(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function et(t="",e){return f(new Z(t,e))}function nt(t){return t instanceof Z}function rt(t,e){let n=t;for(let i=h(t,e);i&&(nt(i.origin)||u(i.origin));i=r(i))n=i.origin;return n}function it(t){return rt(t,"previous")}function ot(t){return rt(t,"next")}function st(t,e){let n=null,r=null,i=t,o=e,s=t.getTextContent();for(;;){if(0===o){if(i=i.getPreviousSibling(),null===i)break;if(nt(i)||u(i)||d(i)||D(167),d(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent()}else o--;const t=s[o];nt(i)&&" "!==t&&(r={node:i,offset:o})}if(null!==r)return r;let l=null;if(e<t.getTextContentSize())nt(t)&&(l=t.getTextContent()[e]);else{const e=t.getNextSibling();nt(e)&&(l=e.getTextContent()[0])}if(null!==l&&" "!==l)return n;{const r=function(t,e){let n=t,r=e,i=t.getTextContent(),o=t.getTextContentSize();for(;;){if(!nt(n)||r===o){if(n=n.getNextSibling(),null===n||d(n))return null;nt(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize())}if(nt(n)){if(" "!==i[r])return{node:n,offset:r};r++}}}(t,e);return null!==r?r:n}}function lt(t){const e=ot(t);return d(e)&&D(168),e}const ut=m({name:"@lexical/code",nodes:[$,Z]});!function(t){t.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var e={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(e).forEach((function(n){var r=e[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),"diff"===n&&i.push("bold"),t.languages.diff[n]={pattern:RegExp("^(?:["+r+"].*(?:\r\n?|\n|(?![\\s\\S])))+","m"),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}}})),Object.defineProperty(t.languages.diff,"PREFIXES",{value:e})}(Prism);const ct=globalThis.Prism||window.Prism,gt={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},at={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function pt(t){return at[t]||t}function ft(t){const e=pt(t);return gt[e]||e}const ht=()=>Object.keys(ct.languages).filter((t=>"function"!=typeof ct.languages[t])).sort();function dt(){const t=[];for(const[e,n]of Object.entries(gt))t.push([e,n]);return t}function mt(){return[]}function yt(t){return"string"==typeof t?t:Array.isArray(t)?t.map(yt).join(""):yt(t.content)}function xt(t,e){const n=/^diff-([\w-]+)/i.exec(e),r=t.getTextContent();let i=ct.tokenize(r,ct.languages[n?"diff":e]);return n&&(i=function(t,e){const n=e,r=ct.languages[n],i={tokens:t},o=ct.languages.diff.PREFIXES;for(const t of i.tokens){if("string"==typeof t||!(t.type in o)||!Array.isArray(t.content))continue;const e=t.type;let n=0;const i=()=>(n++,new ct.Token("prefix",o[e],e.replace(/^(\w+).*/,"$1"))),s=t.content.filter((t=>"string"==typeof t||"prefix"!==t.type)),l=t.content.length-s.length,u=ct.tokenize(yt(s),r);u.unshift(i());const c=/\r\n|\n/g,g=t=>{const e=[];c.lastIndex=0;let r,o=0;for(;n<l&&(r=c.exec(t));){const n=r.index+r[0].length;e.push(t.slice(o,n)),o=n,e.push(i())}if(0!==e.length)return o<t.length&&e.push(t.slice(o)),e},a=t=>{for(let e=0;e<t.length&&n<l;e++){const n=t[e];if("string"==typeof n){const r=g(n);r&&(t.splice(e,1,...r),e+=r.length-1)}else if("string"==typeof n.content){const t=g(n.content);t&&(n.content=t)}else Array.isArray(n.content)?a(n.content):a([n.content])}};a(u),n<l&&u.push(i()),t.content=u}return i.tokens}(i,n[1])),_t(i)}function _t(t,e){const n=[];for(const r of t)if("string"==typeof r){const t=r.split(/(\n|\t)/),i=t.length;for(let r=0;r<i;r++){const i=t[r];"\n"===i||"\r\n"===i?n.push(g()):"\t"===i?n.push(c()):i.length>0&&n.push(et(i,e))}}else{const{content:t,alias:e}=r;"string"==typeof t?n.push(..._t([t],"prefix"===r.type&&"string"==typeof e?e:r.type)):Array.isArray(t)&&n.push(..._t(t,"unchanged"===r.type?void 0:r.type))}return n}const St={$tokenize(t,e){return xt(t,e||this.defaultLanguage)},defaultLanguage:F,tokenize(t,e){return ct.tokenize(t,ct.languages[e||""]||ct.languages[this.defaultLanguage])}};function vt(t,e,n){const r=t.getParent();q(r)?Ct(r,e,n):nt(t)&&t.replace(y(t.__text))}function Tt(t,e){const n=e.getElementByKey(t.getKey());if(null===n)return;const r=t.getChildren(),i=r.length;if(i===n.__cachedChildrenLength)return;n.__cachedChildrenLength=i;let o="1",s=1;for(let t=0;t<i;t++)d(r[t])&&(o+="\n"+ ++s);n.setAttribute("data-gutter",o)}const bt=new Set;function Ct(t,e,n){const r=t.getKey();void 0===t.getLanguage()&&t.setLanguage(n.defaultLanguage);const i=t.getLanguage()||n.defaultLanguage;if(!function(t){const e=function(t){const e=/^diff-([\w-]+)/i.exec(t);return e?e[1]:null}(t),n=e||t;try{return!!n&&ct.languages.hasOwnProperty(n)}catch(t){return!1}}(i))return t.getIsSyntaxHighlightSupported()&&t.setIsSyntaxHighlightSupported(!1),void async function(t,e,n){}();t.getIsSyntaxHighlightSupported()||t.setIsSyntaxHighlightSupported(!0),bt.has(r)||(bt.add(r),e.update((()=>{!function(t,e){const n=x(t);if(!q(n)||!n.isAttached())return;const r=_();if(!S(r))return void e();const i=r.anchor,o=i.offset,s="element"===i.type&&d(n.getChildAtIndex(i.offset-1));let u=0;if(!s){const t=i.getNode();u=o+t.getPreviousSiblings().reduce(((t,e)=>t+e.getTextContentSize()),0)}if(!e())return;if(s)return void i.getNode().select(o,o);n.getChildren().some((t=>{const e=l(t);if(e||d(t)){const n=t.getTextContentSize();if(e&&n>=u)return t.select(u,u),!0;u-=n}return!1}))}(r,(()=>{const e=x(r);if(!q(e)||!e.isAttached())return!1;const i=e.getLanguage()||n.defaultLanguage,o=n.$tokenize(e,i),s=function(t,e){let n=0;for(;n<t.length&&Nt(t[n],e[n]);)n++;const r=t.length,i=e.length,o=Math.min(r,i)-n;let s=0;for(;s<o;)if(s++,!Nt(t[r-s],e[i-s])){s--;break}const l=n,u=r-s,c=e.slice(n,i-s);return{from:l,nodesForReplacement:c,to:u}}(e.getChildren(),o),{from:l,to:u,nodesForReplacement:c}=s;return!(l===u&&!c.length)&&(t.splice(l,u-l,c),!0)}))}),{onUpdate:()=>{bt.delete(r)},skipTransforms:!0}))}function Nt(t,e){return nt(t)&&nt(e)&&t.__text===e.__text&&t.__highlightType===e.__highlightType||u(t)&&u(e)||d(t)&&d(e)}function jt(t){if(!S(t))return!1;const e=t.anchor.getNode(),n=q(e)?e:e.getParent(),r=t.focus.getNode(),i=q(r)?r:r.getParent();return q(n)&&n.is(i)}function wt(t){const e=t.getNodes(),n=[];if(1===e.length&&q(e[0]))return n;let r=[];for(let t=0;t<e.length;t++){const i=e[t];nt(i)||u(i)||d(i)||D(169),d(i)?r.length>0&&(n.push(r),r=[]):r.push(i)}if(r.length>0){const e=t.isBackward()?t.anchor:t.focus,i=v(r[0].getKey(),0,"text");e.is(i)||n.push(r)}return n}function kt(t){const e=_();if(!S(e)||!jt(e))return!1;const n=wt(e),r=n.length;if(0===r&&e.isCollapsed())return t===T&&e.insertNodes([c()]),!0;if(0===r&&t===T&&"\n"===e.getTextContent()){const t=c(),n=g(),r=e.isBackward()?"previous":"next";return e.insertNodes([t,n]),N(j(w(k(t,"next",0),A(h(n,"next"))),r)),!0}for(let i=0;i<r;i++){const r=n[i];if(r.length>0){let n=r[0];if(0===i&&(n=it(n)),t===T){const t=c();if(n.insertBefore(t),0===i){const r=e.isBackward()?"focus":"anchor",i=v(n.getKey(),0,"text");e[r].is(i)&&e[r].set(t.getKey(),0,"text")}}else u(n)&&n.remove()}}return!0}function At(t,e){const n=_();if(!S(n))return!1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,l=r.getNode(),c=i.getNode(),g=t===P;if(!jt(n)||!nt(l)&&!u(l)||!nt(c)&&!u(c))return!1;if(!e.altKey){if(n.isCollapsed()){const t=l.getParentOrThrow();if(g&&0===o&&null===l.getPreviousSibling()){if(null===t.getPreviousSibling())return t.selectPrevious(),e.preventDefault(),!0}else if(!g&&o===l.getTextContentSize()&&null===l.getNextSibling()){if(null===t.getNextSibling())return t.selectNext(),e.preventDefault(),!0}}return!1}let a,p;if(l.isBefore(c)?(a=it(l),p=ot(c)):(a=it(c),p=ot(l)),null==a||null==p)return!1;const f=a.getNodesBetween(p);for(let t=0;t<f.length;t++){const e=f[t];if(!nt(e)&&!u(e)&&!d(e))return!1}e.preventDefault(),e.stopPropagation();const h=g?a.getPreviousSibling():p.getNextSibling();if(!d(h))return!0;const m=g?h.getPreviousSibling():h.getNextSibling();if(null==m)return!0;const y=nt(m)||u(m)||d(m)?g?it(m):ot(m):null;let x=null!=y?y:m;return h.remove(),f.forEach((t=>t.remove())),t===P?(f.forEach((t=>x.insertBefore(t))),x.insertBefore(h)):(x.insertAfter(h),x=h,f.forEach((t=>{x.insertAfter(t),x=t}))),n.setTextNodeRange(l,o,c,s),!0}function Pt(t,e){const n=_();if(!S(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),l=t===L;if(!jt(n)||!nt(o)&&!u(o)||!nt(s)&&!u(s))return!1;if(l){const t=st(s,i.offset);if(null!==t){const{node:e,offset:r}=t;d(e)?e.selectNext(0,0):n.setTextNodeRange(e,r,e,r)}else s.getParentOrThrow().selectStart()}else{lt(s).select()}return e.preventDefault(),e.stopPropagation(),!0}function Lt(t,e){if(!t.hasNodes([$,Z]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==e&&(e=St);const n=[];return!0!==t._headless&&n.push(t.registerMutationListener($,(e=>{t.update((()=>{for(const[n,r]of e)if("destroyed"!==r){const e=x(n);null!==e&&Tt(e,t)}}))}),{skipInitialization:!1})),n.push(t.registerNodeTransform($,(n=>Ct(n,t,e))),t.registerNodeTransform(p,(n=>vt(n,t,e))),t.registerNodeTransform(Z,(n=>vt(n,t,e))),t.registerCommand(O,(e=>{const n=function(t){const e=_();if(!S(e)||!jt(e))return null;const n=t?b:T,r=t?b:C,i=e.anchor,o=e.focus;if(i.is(o))return r;const s=wt(e);if(1!==s.length)return n;const l=s[0];let u,c;0===l.length&&D(285),e.isBackward()?(u=o,c=i):(u=i,c=o);const g=it(l[0]),a=ot(l[0]),p=v(g.getKey(),0,"text"),f=v(a.getKey(),a.getTextContentSize(),"text");return u.isBefore(p)||f.isBefore(c)?n:p.isBefore(u)||c.isBefore(f)?r:n}(e.shiftKey);return null!==n&&(e.preventDefault(),t.dispatchCommand(n,void 0),!0)}),H),t.registerCommand(C,(()=>!!jt(_())&&(z([c()]),!0)),H),t.registerCommand(T,(t=>kt(T)),H),t.registerCommand(b,(t=>kt(b)),H),t.registerCommand(P,(t=>{const e=_();if(!S(e))return!1;const{anchor:n}=e,r=n.getNode();return!!jt(e)&&(e.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&q(r.getParentOrThrow())?(t.preventDefault(),!0):At(P,t))}),H),t.registerCommand(E,(t=>{const e=_();if(!S(e))return!1;const{anchor:n}=e,r=n.getNode();return!!jt(e)&&(e.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&q(r.getParentOrThrow())?(t.preventDefault(),!0):At(E,t))}),H),t.registerCommand(L,(t=>Pt(L,t)),H),t.registerCommand(B,(t=>Pt(B,t)),H)),i(...n)}const Ot=it,Ht=ot,zt=lt,Et=st;export{et as $createCodeHighlightNode,W as $createCodeNode,lt as $getEndOfCodeInLine,it as $getFirstCodeNodeOfLine,ot as $getLastCodeNodeOfLine,st as $getStartOfCodeInLine,nt as $isCodeHighlightNode,q as $isCodeNode,gt as CODE_LANGUAGE_FRIENDLY_NAME_MAP,at as CODE_LANGUAGE_MAP,ut as CodeExtension,Z as CodeHighlightNode,$ as CodeNode,F as DEFAULT_CODE_LANGUAGE,St as PrismTokenizer,dt as getCodeLanguageOptions,ht as getCodeLanguages,mt as getCodeThemeOptions,I as getDefaultCodeLanguage,zt as getEndOfCodeInLine,Ot as getFirstCodeNodeOfLine,ft as getLanguageFriendlyName,Ht as getLastCodeNodeOfLine,Et as getStartOfCodeInLine,pt as normalizeCodeLang,pt as normalizeCodeLanguage,Lt as registerCodeHighlighting};
package/index.d.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  *
7
7
  */
8
8
  import { $getEndOfCodeInLine, $getFirstCodeNodeOfLine, $getLastCodeNodeOfLine, $getStartOfCodeInLine } from './FlatStructureUtils';
9
+ export { CodeExtension } from './CodeExtension';
9
10
  export { PrismTokenizer, registerCodeHighlighting } from './CodeHighlighterPrism';
10
11
  export { $createCodeHighlightNode, $isCodeHighlightNode, CodeHighlightNode, } from './CodeHighlightNode';
11
12
  export type { SerializedCodeNode } from './CodeNode';
package/package.json CHANGED
@@ -8,12 +8,12 @@
8
8
  "code"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.35.1-nightly.20250924.0",
11
+ "version": "0.36.0",
12
12
  "main": "LexicalCode.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/utils": "0.35.1-nightly.20250924.0",
16
- "lexical": "0.35.1-nightly.20250924.0",
15
+ "@lexical/utils": "0.36.0",
16
+ "lexical": "0.36.0",
17
17
  "prismjs": "^1.30.0"
18
18
  },
19
19
  "repository": {