@lexical/code-core 0.51.0 → 0.51.1-nightly.20260921.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.
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import{sel as t,ImportOverlays as e,defineOverlayRules as n,CoreImportExtension as r,DOMImportExtension as i}from"@lexical/html";import{getTextDirection as o,$isElementNode as s,$isTabNode as l,$isLineBreakNode as c,tokenizeRawText as u,$createTabNode as a,$createLineBreakNode as g,$getSiblingCaret as f,getterTableOf as h,setterTableOf as d,setterDefaultOf as p,aliasTableOf as m,$create as _,ElementNode as x,$getDocument as y,addClassNamesToElement as S,setDOMStyleFromCSS as b,$getEditor as v,$isTextNode as C,$createParagraphNode as T,nodeSchema as N,withAccessors as A,optional as P,stringValue as F,nullable as w,isHTMLElement as O,$applyNodeReplacement as $,TextNode as D,removeClassNamesFromElement as E,isDOMDocumentNode as H,isDOMTextNode as B,$generateNodesFromRawText as L,mergeRegister as k,KEY_ENTER_COMMAND as z,$getSelection as M,$isRangeSelection as I,COMMAND_PRIORITY_LOW as K,TabNode as j,KEY_ARROW_DOWN_COMMAND as R,KEY_ARROW_RIGHT_COMMAND as W,KEY_ARROW_UP_COMMAND as J,KEY_ARROW_LEFT_COMMAND as q,KEY_TAB_COMMAND as U,INSERT_TAB_COMMAND as V,$insertNodes as G,INDENT_CONTENT_COMMAND as Q,OUTDENT_CONTENT_COMMAND as X,MOVE_TO_START as Y,MOVE_TO_END as Z,$createPoint as tt,$setSelectionFromCaretRange as et,$getCaretRangeInDirection as nt,$getCaretRange as rt,$getTextPointCaret as it,$normalizeCaret as ot}from"lexical";import{getPeerDependencyFromEditor as st}from"@lexical/extension/getPeerDependencyFromEditor";import{effect as lt}from"@lexical/extension/signals";import{namedSignals as ct}from"@lexical/extension/namedSignals";import{$onEscapeDown as ut,$onEscapeUp as at}from"@lexical/utils";
|
|
10
|
-
/*@__INLINE__*/function gt(t){return()=>{}}function ft(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.`)}function ht(t,e){let n=t;for(let r=f(t,e);r&&(Vt(r.origin)||l(r.origin));r=r.getAdjacentCaret())n=r.origin;return n}function dt(t){return ht(t,"previous")}function pt(t){return ht(t,"next")}function mt(t){const e=dt(t),n=pt(t);let r=e;for(;null!==r;){if(Vt(r)){const t=o(r.getTextContent());if(null!==t)return t}if(r===n)break;r=r.getNextSibling()}const i=e.getParent();if(s(i)){const t=i.getDirection();if("ltr"===t||"rtl"===t)return t}return null}function _t(t,e){let n=null,r=null,i=t,o=e,s=t.getTextContent();for(;;){if(0===o){const t=i.getPreviousSibling();if(null===t){i=null;break}if(Vt(t)||l(t)||c(t)||ft(167),i=t,c(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent()}else o--;const t=s[o];Vt(i)&&" "!==t&&(r={node:i,offset:o})}if(null!==r)return r;let u=null;if(e<t.getTextContentSize())Vt(t)&&(u=t.getTextContent()[e]);else{const e=t.getNextSibling();Vt(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(!Vt(n)||r===o){if(n=n.getNextSibling(),null===n||c(n))return null;Vt(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize())}if(Vt(n)){if(" "!==i[r])return{node:n,offset:r};r++}}}(t,e);return null!==r?r:n}}function xt(t){const e=pt(t);return c(e)&&ft(168),e}function yt(t){const e=[];return u(t,{linebreak:()=>e.push(g()),tab:()=>e.push(a()),text:t=>e.push(Ut(t))}),e}function St(t,e,n){if(!Number.isInteger(e)||e<=0)return!1;const r=t.getTextContent(),i=/^ +/.exec(r);if(!i)return!1;const o=Math.min(e,i[0].length),s=t.getKey(),l=n.anchor.key===s&&"text"===n.anchor.type?n.anchor.offset:null,c=n.focus.key===s&&"text"===n.focus.type?n.focus.offset:null;return t.spliceText(0,o,""),null!==l&&n.anchor.set(s,Math.max(0,l-o),"text"),null!==c&&n.focus.set(s,Math.max(0,c-o),"text"),!0}const bt=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function vt(t,e){if("number"==typeof t)return Number.isFinite(t)?t:e;if("string"!=typeof t||!bt.test(t))return e;const n=Number(t);return Number.isFinite(n)?n:e}const Ct=t=>{const e=h(t,"format"),n=d(t,"format"),r=p(t,"format");return{exportJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles();return{children:[],language:t.__language,theme:t.__theme,direction:t.__dir,format:e[t.__format],indent:t.__indent,textFormat:0!==n&&i?n:void 0,textStyle:""!==r&&i?r:void 0,type:t.__type,version:1}},exportCompactJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles(),o={type:t.__type,children:[]},s=t.__language;void 0!==s&&(o.language=s);const l=t.__theme;void 0!==l&&(o.theme=l);const c=t.__dir;null!=c&&(o.direction=c);const u=e[t.__format];void 0!==u&&""!==u&&(o.format=u);const a=t.__indent;return void 0!==a&&0!==a&&(o.indent=a),void 0!==n&&0!==n&&i&&(o.textFormat=n),void 0!==r&&""!==r&&i&&(o.textStyle=r),o},updateFromJSON:function(t,e){const i=e.direction;t.__dir=null===i||"ltr"===i||"rtl"===i?i:null;const o=e.format;t.__format="string"==typeof o&&o in n?n[o]:r,t.__indent=function(t,e,n,r){const i=vt(t,e);return i>=n&&i<=r&&Number.isInteger(i)?i:e}(e.indent,0,0,Infinity),t.__textFormat=vt(e.textFormat,0);const s=e.textStyle;t.__textStyle="string"==typeof s?s:"";const l=e.language;t.setLanguage(null==l||"string"==typeof l?l:"");const c=e.theme;return t.setTheme(void 0===c?void 0:"string"==typeof c?c:""),t}}};function Tt(t,e){t.__highlightType=e.__highlightType}const Nt=t=>{const e=h(t,"mode"),n=m(t,"detail",0),r=m(t,"format",0),i=d(t,"mode"),o=p(t,"mode");return{exportJSON:function(t){return{highlightType:t.__highlightType,detail:t.__detail,format:t.__format,mode:e[t.__mode],style:t.__style,text:t.__text,type:t.__type,version:1}},exportCompactJSON:function(t){const n={type:t.__type},r=t.__highlightType;void 0!==r&&(n.highlightType=r);const i=t.__detail;void 0!==i&&0!==i&&(n.detail=i);const o=t.__format;void 0!==o&&0!==o&&(n.format=o);const s=e[t.__mode];void 0!==s&&"normal"!==s&&(n.mode=s);const l=t.__style;void 0!==l&&""!==l&&(n.style=l);const c=t.__text;return void 0!==c&&""!==c&&(n.text=c),n},updateFromJSON:function(t,e){const s=e.detail;t.__detail="string"==typeof s&&s in n?n[s]:vt(s,0);const l=e.format;t.setFormat("string"==typeof l&&l in r?r[l]:vt(l,0));const c=e.mode;t.__mode="string"==typeof c&&c in i?i[c]:o;const u=e.style;t.__style="string"==typeof u?u:"";const a=e.text;t.__text="string"==typeof a?a:"";const g=e.highlightType;return t.setHighlightType(null==g||"string"==typeof g?g:""),t},afterCloneFrom:Tt}},At=/* @__PURE__ */N()({language:/* @__PURE__ */A(/* @__PURE__ */P(/* @__PURE__ */w(/* @__PURE__ */F())),{getter:{field:"__language"}}),theme:/* @__PURE__ */A(/* @__PURE__ */P(/* @__PURE__ */F()),{getter:{field:"__theme"}})}),Pt="javascript",Ft=()=>Pt;function wt(t,e){for(const n of t.childNodes){if(O(n)&&n.tagName===e)return!0;if(wt(n,e))return!0}return!1}const Ot="data-language",$t="data-highlight-language",Dt="data-theme",Et=/* @__PURE__ */gt();class Ht extends x{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:x,generated:Ct,importDOM:{code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||wt(t,"BR"))?{conversion:kt,priority:1}:null,div:()=>({conversion:zt,priority:1}),pre:()=>({conversion:kt,priority:0}),table:t=>jt(t)?{conversion:Mt,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&jt(n)?{conversion:It,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&jt(e)?{conversion:It,priority:3}:null}},json:At})}constructor(t=void 0,e){super(e),this.__language=t||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(t){super.afterCloneFrom(t),function(t,e){t.__language=e.__language,t.__theme=e.__theme}(this,t),this.__isSyntaxHighlightSupported=t.__isSyntaxHighlightSupported}createDOM(t){const e=y().createElement("code");S(e,t.theme.code),e.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(e.setAttribute(Ot,n),this.getIsSyntaxHighlightSupported()&&e.setAttribute($t,n));const r=this.getTheme();r&&e.setAttribute(Dt,r);const i=this.getStyle();return i&&b(e.style,i),e}updateDOM(t,e,n){const r=this.__language,i=t.__language;r?r!==i&&e.setAttribute(Ot,r):i&&e.removeAttribute(Ot);const o=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&e.setAttribute($t,r):e.removeAttribute($t):o&&r&&e.setAttribute($t,r);const s=this.__theme,l=t.__theme;s?s!==l&&e.setAttribute(Dt,s):l&&e.removeAttribute(Dt);const c=this.__style,u=t.__style;return c!==u&&b(e.style,c,u),!1}exportDOM(t){const e=y().createElement("pre");S(e,t._config.theme.code),e.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(e.setAttribute(Ot,n),this.getIsSyntaxHighlightSupported()&&e.setAttribute($t,n));const r=this.getTheme();r&&e.setAttribute(Dt,r);const i=this.getStyle();return i&&b(e.style,i),{element:e}}insertNewAfter(t,e=!0){if(!st(v(),"@lexical/code")){Et();const e=Rt(t);if(e)return e}const{anchor:n,focus:r}=t,i=(n.isBefore(r)?n:r).getNode();if(C(i)){let t=dt(i);const e=[];for(;;)if(l(t))e.push(a()),t=t.getNextSibling();else{if(!Vt(t))break;{let n=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&e.push(Ut(" ".repeat(n))),n!==i)break;t=t.getNextSibling()}}const r=i.splitText(n.offset)[0],o=0===n.offset?0:1,s=r.getIndexWithinParent()+o,c=i.getParentOrThrow(),u=[g(),...e];c.splice(s,0,u);const f=e[e.length-1];f?f.select():0===n.offset?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(Lt(i)){const{offset:e}=t.anchor;i.splice(e,0,[g()]),i.select(e+1,e+1)}return null}canIndent(){return!1}collapseAtStart(){const t=T();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 Bt(t,e){return _(Ht).setLanguage(t).setTheme(e)}function Lt(t){return t instanceof Ht}function kt(t){return{node:Bt(t.getAttribute(Ot),t.getAttribute(Dt))}}function zt(t){const e=t,n=Kt(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(Kt(e))return!0;e=e.parentElement}return!1}(e)?{node:n?Bt():null}:{node:null}}function Mt(){return{node:Bt()}}function It(){return{node:null}}function Kt(t){return null!==t.style.fontFamily.match("monospace")}function jt(t){return t.classList.contains("js-file-line-container")}function Rt(t){const{anchor:e}=t;if(t.isCollapsed()&&"element"===e.type){const t=e.getNode();if(Lt(t)){const n=t.getChildrenSize();if(n>=2&&e.offset===n){const e=t.getLastChild();if(c(e)&&c(e.getPreviousSibling())){const e=T();return t.splice(n-2,2,[]).insertAfter(e,!1),e.select(),e}}}}return null}const Wt=/* @__PURE__ */N()({highlightType:/* @__PURE__ */A(/* @__PURE__ */P(/* @__PURE__ */w(/* @__PURE__ */F())),{getter:{field:"__highlightType"}})});class Jt extends D{__highlightType;constructor(t="",e,n){super(t,n),this.__highlightType=e}$config(){return this.config("code-highlight",{extends:D,generated:Nt,json:Wt})}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(t){const e=this.getWritable();return e.__highlightType=t||void 0,e}canHaveFormat(){return!1}createDOM(t){const e=super.createDOM(t),n=qt(t.theme,this.__highlightType);return S(e,n),e}updateDOM(t,e,n){const r=super.updateDOM(t,e,n),i=qt(n.theme,t.__highlightType),o=qt(n.theme,this.__highlightType);return i!==o&&(i&&E(e,i),o&&S(e,o)),r}setFormat(t){return this}isParentRequired(){return!0}createParentElementNode(){return Bt()}}function qt(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function Ut(t="",e){return $(new Jt(t,e))}function Vt(t){return t instanceof Jt}const Gt="data-language",Qt="data-theme";function Xt(t){return null!==t.style.fontFamily.match("monospace")}function Yt(t){let e=t.parentElement;for(;null!==e;){if(Xt(e))return!0;e=e.parentElement}return!1}const Zt=/* @__PURE__ */n([{$import:(t,e)=>t.$importChildren(e),match:/* @__PURE__ */t.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"}]),te={$import:(t,e)=>[Bt(e.getAttribute(Gt),e.getAttribute(Qt)).splice(0,0,t.$importChildren(e))],match:/* @__PURE__ */t.tag("pre"),name:"@lexical/code/pre"},ee={$import:(t,e,n)=>{const r=e.textContent||"";return/\r?\n/.test(r)||null!==e.querySelector("br")?[Bt(e.getAttribute(Gt),e.getAttribute(Qt)).splice(0,0,t.$importChildren(e))]:n()},match:/* @__PURE__ */t.tag("code"),name:"@lexical/code/code-multiline"};function ne(t){if(!O(t))return!1;const e=t.style.fontFamily,n=t.style.whiteSpace;return"string"==typeof e&&/monospace/i.test(e)&&"string"==typeof n&&n.startsWith("pre")}function re(t){let e=!1;const n=[];let r="",i=!1;const o=()=>{i&&(n.push(r),r="",i=!1)};for(const s of Array.from(t.childNodes))if(O(s))"DIV"===s.tagName?(o(),n.push(s.textContent||""),e=!0):"BR"===s.tagName?(o(),n.push(""),e=!0):(r+=s.textContent||"",i=!0);else if(B(s)){const t=s.textContent||"";t.length>0&&(r+=t,i=!0)}return o(),e?n:null}function ie(t){for(const e of Array.from(t.children)){if(O(e)&&ne(e)){if(null!==re(e))return!0;const t=e.nextElementSibling;if(t&&ne(t))return!0;continue}if(ie(e))return!0}return!1}const oe=/* @__PURE__ */n([{$import:(t,e,n)=>{if(!ne(e)||Yt(e))return n();const r=re(e);return null===r||0===r.length?n():[Bt().splice(0,0,L(r.join("\n")))]},match:/* @__PURE__ */t.tag("div"),name:"@lexical/code/vscode-wrapper"},{$import:(t,e,n)=>{if(!ne(e)||Yt(e))return n();const r=e.previousElementSibling;if(r&&ne(r))return[];const i=[];let o=e;for(;o&&ne(o);)i.push("BR"===o.tagName?"":o.textContent||""),o=o.nextElementSibling;return i.length<2?n():[Bt().splice(0,0,L(i.join("\n")))]},match:/* @__PURE__ */t.tag("div","br"),name:"@lexical/code/vscode-line-run"}]),se={$import:(t,e,n)=>Xt(e)?[Bt().splice(0,0,t.$importChildren(e))]:Yt(e)?t.$importChildren(e):n(),match:/* @__PURE__ */t.tag("div"),name:"@lexical/code/div"},le=[{$import:(t,e)=>[Bt().splice(0,0,t.$importChildren(e,{rules:Zt}))],match:/* @__PURE__ */t.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"},{$import:(t,e)=>t.$importChildren(e),match:/* @__PURE__ */t.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"},ee,te,se],ce={dependencies:[r,[i,{preprocess:[(t,n,r)=>{ie(H(t)?t.body:t)&&n.session.update(e,t=>[...t,oe]),r()}],rules:le}]],name:"@lexical/code",nodes:()=>[Ht,Jt],register:t=>k(t.registerCommand(z,t=>{const e=M();return!(!I(e)||!Rt(e))&&(null!==t&&t.preventDefault(),!0)},K),t.registerNodeTransform(j,t=>{0!==t.getFormat()&&Lt(t.getParent())&&t.setFormat(0)}))},ue={dependencies:[ce],name:"@lexical/code/Import"};function ae(t){if(!I(t))return!1;const e=t.anchor.getNode(),n=Lt(e)?e:e.getParent(),r=t.focus.getNode(),i=Lt(r)?r:r.getParent();return Lt(n)&&n.is(i)}function ge(t){const e=t.getNodes(),n=[];if(1===e.length&&Lt(e[0]))return n;let r=[];for(let t=0;t<e.length;t++){const i=e[t];Vt(i)||l(i)||c(i)||ft(169),c(i)?r.length>0&&(n.push(r),r=[]):r.push(i)}if(r.length>0){const e=t.isBackward()?t.anchor:t.focus,i=tt(r[0].getKey(),0,"text");e.is(i)||n.push(r)}return n}function fe(t,e){const n=M();if(!I(n)||!ae(n))return!1;const r=ge(n),i=r.length;if(0===i&&n.isCollapsed())return t===Q?n.insertNodes([a()]):function(t,e){const n=t.anchor.getNode();if(!Vt(n)&&!l(n))return;const r=dt(n);l(r)?r.remove():void 0!==e&&Vt(r)&&St(r,e,t)}(n,e),!0;if(0===i&&t===Q&&"\n"===n.getTextContent()){const t=a(),e=g(),r=n.isBackward()?"previous":"next";return n.insertNodes([t,e]),et(nt(rt(it(t,"next",0),ot(f(e,"next"))),r)),!0}for(let o=0;o<i;o++){const i=r[o];if(i.length>0){let r=i[0];if(0===o&&(r=dt(r)),t===Q){const t=a();if(r.insertBefore(t),0===o){const e=n.isBackward()?"focus":"anchor",i=tt(r.getKey(),0,"text");n[e].is(i)&&n[e].set(t.getKey(),0,"text")}}else l(r)?r.remove():void 0!==e&&Vt(r)&&St(r,e,n)}}return!0}function he(t,e){const n=M();if(!I(n))return!1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,u=r.getNode(),a=i.getNode(),g=t===J;if(!ae(n)||!Vt(u)&&!l(u)||!Vt(a)&&!l(a))return!1;if(!e.altKey){if(n.isCollapsed()){const t=u.getParentOrThrow();if(g&&0===o&&null===u.getPreviousSibling()){if(null===t.getPreviousSibling())return t.selectPrevious(),e.preventDefault(),!1}else if(!g&&o===u.getTextContentSize()&&null===u.getNextSibling()){if(null===t.getNextSibling())return t.selectNext(),e.preventDefault(),!1}}return!1}let f,h;if(u.isBefore(a)?(f=dt(u),h=pt(a)):(f=dt(a),h=pt(u)),null==f||null==h)return!1;const d=f.getNodesBetween(h);for(let t=0;t<d.length;t++){const e=d[t];if(!Vt(e)&&!l(e)&&!c(e))return!1}e.preventDefault(),e.stopPropagation();const p=g?f.getPreviousSibling():h.getNextSibling();if(!c(p))return!0;const m=g?p.getPreviousSibling():p.getNextSibling();if(null==m)return!0;const _=c(m),x=_||!Vt(m)&&!l(m)?null:g?dt(m):pt(m);let y=null!=x?x:m;return p.remove(),d.forEach(t=>t.remove()),_?(d.forEach(t=>{y.insertAfter(t),y=t}),y.insertAfter(p)):t===J?(d.forEach(t=>y.insertBefore(t)),y.insertBefore(p)):(y.insertAfter(p),y=p,d.forEach(t=>{y.insertAfter(t),y=t})),n.setTextNodeRange(u,o,a,s),!0}function de(t,e){const n=M();if(!I(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),u=t===Y;if(!ae(n)||!Vt(o)&&!l(o)||!Vt(s)&&!l(s))return!1;const a=s,g="rtl"===mt(a)?!u:u,f=r.key,h=r.offset,d=r.type;if(g){const t=_t(a,i.offset);if(null!==t){const{node:e,offset:r}=t;c(e)?e.selectNext(0,0):n.setTextNodeRange(e,r,e,r)}else a.getParentOrThrow().selectStart()}else{xt(a).select()}return e.shiftKey&&n.anchor.set(f,h,d),e.preventDefault(),e.stopPropagation(),!0}function pe(t,e,n){return k(...n?[t.registerCommand(R,t=>!t.altKey&&ut(Lt,t),K),t.registerCommand(W,t=>ut(Lt,t),K),t.registerCommand(J,t=>!t.altKey&&at(Lt,t),K),t.registerCommand(q,t=>at(Lt,t),K)]:[],t.registerCommand(U,e=>{const n=function(t){const e=M();if(!I(e)||!ae(e))return null;const n=t?X:Q,r=t?X:V,i=e.anchor,o=e.focus;if(i.is(o))return r;const s=ge(e);if(1!==s.length)return n;const l=s[0];let c,u;0===l.length&&ft(285),e.isBackward()?(c=o,u=i):(c=i,u=o);const a=dt(l[0]),g=pt(l[0]),f=tt(a.getKey(),0,"text"),h=tt(g.getKey(),g.getTextContentSize(),"text");return c.isBefore(f)||h.isBefore(u)?n:f.isBefore(c)||u.isBefore(h)?r:n}(e.shiftKey);return null!==n&&(e.preventDefault(),t.dispatchCommand(n),!0)},K),t.registerCommand(V,()=>!!ae(M())&&(G([a()]),!0),K),t.registerCommand(Q,()=>fe(Q),K),t.registerCommand(X,()=>fe(X,e),K),t.registerCommand(J,t=>{const e=M();if(!I(e))return!1;const{anchor:n}=e,r=n.getNode();if(!ae(e))return!1;const i=r.getParent();return e.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&Lt(i)&&null===i.getPreviousSibling()?(t.preventDefault(),!0):he(J,t)},K),t.registerCommand(R,t=>{const e=M();if(!I(e))return!1;const{anchor:n}=e,r=n.getNode();return!!ae(e)&&(e.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&Lt(r.getParentOrThrow())&&null===r.getParentOrThrow().getNextSibling()?(t.preventDefault(),!0):he(R,t))},K),t.registerCommand(Y,t=>de(Y,t),K),t.registerCommand(Z,t=>de(Z,t),K))}const me={build:(t,e)=>ct(e),config:{disabled:!1,escapeWithArrows:!1,tabSize:void 0},dependencies:[ce],name:"@lexical/code-indent",register:(t,e,n)=>{const r=n.getOutput();return lt(()=>{if(!r.disabled.value)return pe(t,r.tabSize.value,r.escapeWithArrows.value)})}};export{Ut as $createCodeHighlightNode,Bt as $createCodeNode,mt as $getCodeLineDirection,xt as $getEndOfCodeInLine,dt as $getFirstCodeNodeOfLine,pt as $getLastCodeNodeOfLine,_t as $getStartOfCodeInLine,Vt as $isCodeHighlightNode,Lt as $isCodeNode,St as $outdentLeadingSpaces,yt as $plainifyCodeContent,ce as CodeExtension,Jt as CodeHighlightNode,ue as CodeImportExtension,le as CodeImportRules,me as CodeIndentExtension,Ht as CodeNode,Pt as DEFAULT_CODE_LANGUAGE,Ft as getDefaultCodeLanguage,pe as registerCodeIndentation};
|
|
10
|
+
/*@__INLINE__*/function gt(t){return()=>{}}function ft(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.`)}function ht(t,e){let n=t;for(let r=f(t,e);r&&(Vt(r.origin)||l(r.origin));r=r.getAdjacentCaret())n=r.origin;return n}function dt(t){return ht(t,"previous")}function pt(t){return ht(t,"next")}function mt(t){const e=dt(t),n=pt(t);let r=e;for(;null!==r;){if(Vt(r)){const t=o(r.getTextContent());if(null!==t)return t}if(r===n)break;r=r.getNextSibling()}const i=e.getParent();if(s(i)){const t=i.getDirection();if("ltr"===t||"rtl"===t)return t}return null}function _t(t,e){let n=null,r=null,i=t,o=e,s=t.getTextContent();for(;;){if(0===o){const t=i.getPreviousSibling();if(null===t){i=null;break}if(Vt(t)||l(t)||c(t)||ft(167),i=t,c(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent()}else o--;const t=s[o];Vt(i)&&" "!==t&&(r={node:i,offset:o})}if(null!==r)return r;let u=null;if(e<t.getTextContentSize())Vt(t)&&(u=t.getTextContent()[e]);else{const e=t.getNextSibling();Vt(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(!Vt(n)||r===o){if(n=n.getNextSibling(),null===n||c(n))return null;Vt(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize())}if(Vt(n)){if(" "!==i[r])return{node:n,offset:r};r++}}}(t,e);return null!==r?r:n}}function xt(t){const e=pt(t);return c(e)&&ft(168),e}function yt(t){const e=[];return u(t,{linebreak:()=>e.push(g()),tab:()=>e.push(a()),text:t=>e.push(Ut(t))}),e}function St(t,e,n){if(!Number.isInteger(e)||e<=0)return!1;const r=t.getTextContent(),i=/^ +/.exec(r);if(!i)return!1;const o=Math.min(e,i[0].length),s=t.getKey(),l=n.anchor.key===s&&"text"===n.anchor.type?n.anchor.offset:null,c=n.focus.key===s&&"text"===n.focus.type?n.focus.offset:null;return t.spliceText(0,o,""),null!==l&&n.anchor.set(s,Math.max(0,l-o),"text"),null!==c&&n.focus.set(s,Math.max(0,c-o),"text"),!0}const bt=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function vt(t,e){if("number"==typeof t)return Number.isFinite(t)?t:e;if("string"!=typeof t||!bt.test(t))return e;const n=Number(t);return Number.isFinite(n)?n:e}const Ct=t=>{const e=h(t,"format"),n=d(t,"format"),r=p(t,"format");return{exportJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles();return{children:[],language:t.__language,theme:t.__theme,direction:t.__dir,format:e[t.__format],indent:t.__indent,textFormat:0!==n&&i?n:void 0,textStyle:""!==r&&i?r:void 0,type:t.__type,version:1}},exportCompactJSON:function(t){const n=t.__textFormat,r=t.__textStyle,i=(0!==n||""!==r)&&t.shouldSerializeTextStyles(),o={type:t.__type,children:[]},s=t.__language;void 0!==s&&(o.language=s);const l=t.__theme;void 0!==l&&(o.theme=l);const c=t.__dir;null!=c&&(o.direction=c);const u=e[t.__format];void 0!==u&&""!==u&&(o.format=u);const a=t.__indent;return void 0!==a&&0!==a&&(o.indent=a),void 0!==n&&0!==n&&i&&(o.textFormat=n),void 0!==r&&""!==r&&i&&(o.textStyle=r),o},updateFromJSON:function(t,e){const i=e.direction;t.__dir=null===i||"ltr"===i||"rtl"===i?i:null;const o=e.format;t.__format="string"==typeof o&&o in n?n[o]:r,t.__indent=function(t){const e=vt(t,0);return e>=0&&e<=Infinity&&Number.isInteger(e)?e:0}(e.indent),t.__textFormat=vt(e.textFormat,0);const s=e.textStyle;t.__textStyle="string"==typeof s?s:"";const l=e.language;t.setLanguage(null==l||"string"==typeof l?l:"");const c=e.theme;return t.setTheme(void 0===c?void 0:"string"==typeof c?c:""),t}}};function Tt(t,e){t.__highlightType=e.__highlightType}const Nt=t=>{const e=h(t,"mode"),n=m(t,"detail",0),r=m(t,"format",0),i=d(t,"mode"),o=p(t,"mode");return{exportJSON:function(t){return{highlightType:t.__highlightType,detail:t.__detail,format:t.__format,mode:e[t.__mode],style:t.__style,text:t.__text,type:t.__type,version:1}},exportCompactJSON:function(t){const n={type:t.__type},r=t.__highlightType;void 0!==r&&(n.highlightType=r);const i=t.__detail;void 0!==i&&0!==i&&(n.detail=i);const o=t.__format;void 0!==o&&0!==o&&(n.format=o);const s=e[t.__mode];void 0!==s&&"normal"!==s&&(n.mode=s);const l=t.__style;void 0!==l&&""!==l&&(n.style=l);const c=t.__text;return void 0!==c&&""!==c&&(n.text=c),n},updateFromJSON:function(t,e){const s=e.detail;t.__detail="string"==typeof s&&s in n?n[s]:vt(s,0);const l=e.format;t.setFormat("string"==typeof l&&l in r?r[l]:vt(l,0));const c=e.mode;t.__mode="string"==typeof c&&c in i?i[c]:o;const u=e.style;t.__style="string"==typeof u?u:"";const a=e.text;t.__text="string"==typeof a?a:"";const g=e.highlightType;return t.setHighlightType(null==g||"string"==typeof g?g:""),t},afterCloneFrom:Tt}},At=/* @__PURE__ */N()({language:/* @__PURE__ */A(/* @__PURE__ */P(/* @__PURE__ */w(/* @__PURE__ */F())),{getter:{field:"__language"}}),theme:/* @__PURE__ */A(/* @__PURE__ */P(/* @__PURE__ */F()),{getter:{field:"__theme"}})}),Pt="javascript",Ft=()=>Pt;function wt(t,e){for(const n of t.childNodes){if(O(n)&&n.tagName===e)return!0;if(wt(n,e))return!0}return!1}const Ot="data-language",$t="data-highlight-language",Dt="data-theme",Et=/* @__PURE__ */gt();class Ht extends x{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:x,generated:Ct,importDOM:{code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||wt(t,"BR"))?{conversion:kt,priority:1}:null,div:()=>({conversion:zt,priority:1}),pre:()=>({conversion:kt,priority:0}),table:t=>jt(t)?{conversion:Mt,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&jt(n)?{conversion:It,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&jt(e)?{conversion:It,priority:3}:null}},json:At})}constructor(t=void 0,e){super(e),this.__language=t||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(t){super.afterCloneFrom(t),function(t,e){t.__language=e.__language,t.__theme=e.__theme}(this,t),this.__isSyntaxHighlightSupported=t.__isSyntaxHighlightSupported}createDOM(t){const e=y().createElement("code");S(e,t.theme.code),e.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(e.setAttribute(Ot,n),this.getIsSyntaxHighlightSupported()&&e.setAttribute($t,n));const r=this.getTheme();r&&e.setAttribute(Dt,r);const i=this.getStyle();return i&&b(e.style,i),e}updateDOM(t,e,n){const r=this.__language,i=t.__language;r?r!==i&&e.setAttribute(Ot,r):i&&e.removeAttribute(Ot);const o=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&e.setAttribute($t,r):e.removeAttribute($t):o&&r&&e.setAttribute($t,r);const s=this.__theme,l=t.__theme;s?s!==l&&e.setAttribute(Dt,s):l&&e.removeAttribute(Dt);const c=this.__style,u=t.__style;return c!==u&&b(e.style,c,u),!1}exportDOM(t){const e=y().createElement("pre");S(e,t._config.theme.code),e.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(e.setAttribute(Ot,n),this.getIsSyntaxHighlightSupported()&&e.setAttribute($t,n));const r=this.getTheme();r&&e.setAttribute(Dt,r);const i=this.getStyle();return i&&b(e.style,i),{element:e}}insertNewAfter(t,e=!0){if(!st(v(),"@lexical/code")){Et();const e=Rt(t);if(e)return e}const{anchor:n,focus:r}=t,i=(n.isBefore(r)?n:r).getNode();if(C(i)){let t=dt(i);const e=[];for(;;)if(l(t))e.push(a()),t=t.getNextSibling();else{if(!Vt(t))break;{let n=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&e.push(Ut(" ".repeat(n))),n!==i)break;t=t.getNextSibling()}}const r=i.splitText(n.offset)[0],o=0===n.offset?0:1,s=r.getIndexWithinParent()+o,c=i.getParentOrThrow(),u=[g(),...e];c.splice(s,0,u);const f=e[e.length-1];f?f.select():0===n.offset?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(Lt(i)){const{offset:e}=t.anchor;i.splice(e,0,[g()]),i.select(e+1,e+1)}return null}canIndent(){return!1}collapseAtStart(){const t=T();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 Bt(t,e){return _(Ht).setLanguage(t).setTheme(e)}function Lt(t){return t instanceof Ht}function kt(t){return{node:Bt(t.getAttribute(Ot),t.getAttribute(Dt))}}function zt(t){const e=t,n=Kt(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(Kt(e))return!0;e=e.parentElement}return!1}(e)?{node:n?Bt():null}:{node:null}}function Mt(){return{node:Bt()}}function It(){return{node:null}}function Kt(t){return null!==t.style.fontFamily.match("monospace")}function jt(t){return t.classList.contains("js-file-line-container")}function Rt(t){const{anchor:e}=t;if(t.isCollapsed()&&"element"===e.type){const t=e.getNode();if(Lt(t)){const n=t.getChildrenSize();if(n>=2&&e.offset===n){const e=t.getLastChild();if(c(e)&&c(e.getPreviousSibling())){const e=T();return t.splice(n-2,2,[]).insertAfter(e,!1),e.select(),e}}}}return null}const Wt=/* @__PURE__ */N()({highlightType:/* @__PURE__ */A(/* @__PURE__ */P(/* @__PURE__ */w(/* @__PURE__ */F())),{getter:{field:"__highlightType"}})});class Jt extends D{__highlightType;constructor(t="",e,n){super(t,n),this.__highlightType=e}$config(){return this.config("code-highlight",{extends:D,generated:Nt,json:Wt})}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(t){const e=this.getWritable();return e.__highlightType=t||void 0,e}canHaveFormat(){return!1}createDOM(t){const e=super.createDOM(t),n=qt(t.theme,this.__highlightType);return S(e,n),e}updateDOM(t,e,n){const r=super.updateDOM(t,e,n),i=qt(n.theme,t.__highlightType),o=qt(n.theme,this.__highlightType);return i!==o&&(i&&E(e,i),o&&S(e,o)),r}setFormat(t){return this}isParentRequired(){return!0}createParentElementNode(){return Bt()}}function qt(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function Ut(t="",e){return $(new Jt(t,e))}function Vt(t){return t instanceof Jt}const Gt="data-language",Qt="data-theme";function Xt(t){return null!==t.style.fontFamily.match("monospace")}function Yt(t){let e=t.parentElement;for(;null!==e;){if(Xt(e))return!0;e=e.parentElement}return!1}const Zt=/* @__PURE__ */n([{$import:(t,e)=>t.$importChildren(e),match:/* @__PURE__ */t.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"}]),te={$import:(t,e)=>[Bt(e.getAttribute(Gt),e.getAttribute(Qt)).splice(0,0,t.$importChildren(e))],match:/* @__PURE__ */t.tag("pre"),name:"@lexical/code/pre"},ee={$import:(t,e,n)=>{const r=e.textContent||"";return/\r?\n/.test(r)||null!==e.querySelector("br")?[Bt(e.getAttribute(Gt),e.getAttribute(Qt)).splice(0,0,t.$importChildren(e))]:n()},match:/* @__PURE__ */t.tag("code"),name:"@lexical/code/code-multiline"};function ne(t){if(!O(t))return!1;const e=t.style.fontFamily,n=t.style.whiteSpace;return"string"==typeof e&&/monospace/i.test(e)&&"string"==typeof n&&n.startsWith("pre")}function re(t){let e=!1;const n=[];let r="",i=!1;const o=()=>{i&&(n.push(r),r="",i=!1)};for(const s of Array.from(t.childNodes))if(O(s))"DIV"===s.tagName?(o(),n.push(s.textContent||""),e=!0):"BR"===s.tagName?(o(),n.push(""),e=!0):(r+=s.textContent||"",i=!0);else if(B(s)){const t=s.textContent||"";t.length>0&&(r+=t,i=!0)}return o(),e?n:null}function ie(t){for(const e of Array.from(t.children)){if(O(e)&&ne(e)){if(null!==re(e))return!0;const t=e.nextElementSibling;if(t&&ne(t))return!0;continue}if(ie(e))return!0}return!1}const oe=/* @__PURE__ */n([{$import:(t,e,n)=>{if(!ne(e)||Yt(e))return n();const r=re(e);return null===r||0===r.length?n():[Bt().splice(0,0,L(r.join("\n")))]},match:/* @__PURE__ */t.tag("div"),name:"@lexical/code/vscode-wrapper"},{$import:(t,e,n)=>{if(!ne(e)||Yt(e))return n();const r=e.previousElementSibling;if(r&&ne(r))return[];const i=[];let o=e;for(;o&&ne(o);)i.push("BR"===o.tagName?"":o.textContent||""),o=o.nextElementSibling;return i.length<2?n():[Bt().splice(0,0,L(i.join("\n")))]},match:/* @__PURE__ */t.tag("div","br"),name:"@lexical/code/vscode-line-run"}]),se={$import:(t,e,n)=>Xt(e)?[Bt().splice(0,0,t.$importChildren(e))]:Yt(e)?t.$importChildren(e):n(),match:/* @__PURE__ */t.tag("div"),name:"@lexical/code/div"},le=[{$import:(t,e)=>[Bt().splice(0,0,t.$importChildren(e,{rules:Zt}))],match:/* @__PURE__ */t.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"},{$import:(t,e)=>t.$importChildren(e),match:/* @__PURE__ */t.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"},ee,te,se],ce={dependencies:[r,[i,{preprocess:[(t,n,r)=>{ie(H(t)?t.body:t)&&n.session.update(e,t=>[...t,oe]),r()}],rules:le}]],name:"@lexical/code",nodes:()=>[Ht,Jt],register:t=>k(t.registerCommand(z,t=>{const e=M();return!(!I(e)||!Rt(e)||(null!==t&&t.preventDefault(),0))},K),t.registerNodeTransform(j,t=>{0!==t.getFormat()&&Lt(t.getParent())&&t.setFormat(0)}))},ue={dependencies:[ce],name:"@lexical/code/Import"};function ae(t){if(!I(t))return!1;const e=t.anchor.getNode(),n=Lt(e)?e:e.getParent(),r=t.focus.getNode(),i=Lt(r)?r:r.getParent();return Lt(n)&&n.is(i)}function ge(t){const e=t.getNodes(),n=[];if(1===e.length&&Lt(e[0]))return n;let r=[];for(let t=0;t<e.length;t++){const i=e[t];Vt(i)||l(i)||c(i)||ft(169),c(i)?r.length>0&&(n.push(r),r=[]):r.push(i)}if(r.length>0){const e=t.isBackward()?t.anchor:t.focus,i=tt(r[0].getKey(),0,"text");e.is(i)||n.push(r)}return n}function fe(t,e){const n=M();if(!I(n)||!ae(n))return!1;const r=ge(n),i=r.length;if(0===i&&n.isCollapsed())return t===Q?n.insertNodes([a()]):function(t,e){const n=t.anchor.getNode();if(!Vt(n)&&!l(n))return;const r=dt(n);l(r)?r.remove():void 0!==e&&Vt(r)&&St(r,e,t)}(n,e),!0;if(0===i&&t===Q&&"\n"===n.getTextContent()){const t=a(),e=g(),r=n.isBackward()?"previous":"next";return n.insertNodes([t,e]),et(nt(rt(it(t,"next",0),ot(f(e,"next"))),r)),!0}for(let o=0;o<i;o++){const i=r[o];if(i.length>0){let r=i[0];if(0===o&&(r=dt(r)),t===Q){const t=a();if(r.insertBefore(t),0===o){const e=n.isBackward()?"focus":"anchor",i=tt(r.getKey(),0,"text");n[e].is(i)&&n[e].set(t.getKey(),0,"text")}}else l(r)?r.remove():void 0!==e&&Vt(r)&&St(r,e,n)}}return!0}function he(t,e){const n=M();if(!I(n))return!1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,u=r.getNode(),a=i.getNode(),g=t===J;if(!ae(n)||!Vt(u)&&!l(u)||!Vt(a)&&!l(a))return!1;if(!e.altKey){if(n.isCollapsed()){const t=u.getParentOrThrow();if(g&&0===o&&null===u.getPreviousSibling()){if(null===t.getPreviousSibling())return t.selectPrevious(),e.preventDefault(),!1}else if(!g&&o===u.getTextContentSize()&&null===u.getNextSibling()&&null===t.getNextSibling())return t.selectNext(),e.preventDefault(),!1}return!1}let f,h;if(u.isBefore(a)?(f=dt(u),h=pt(a)):(f=dt(a),h=pt(u)),null==f||null==h)return!1;const d=f.getNodesBetween(h);for(let t=0;t<d.length;t++){const e=d[t];if(!Vt(e)&&!l(e)&&!c(e))return!1}e.preventDefault(),e.stopPropagation();const p=g?f.getPreviousSibling():h.getNextSibling();if(!c(p))return!0;const m=g?p.getPreviousSibling():p.getNextSibling();if(null==m)return!0;const _=c(m),x=_||!Vt(m)&&!l(m)?null:g?dt(m):pt(m);let y=null!=x?x:m;return p.remove(),d.forEach(t=>t.remove()),_?(d.forEach(t=>{y.insertAfter(t),y=t}),y.insertAfter(p)):t===J?(d.forEach(t=>y.insertBefore(t)),y.insertBefore(p)):(y.insertAfter(p),y=p,d.forEach(t=>{y.insertAfter(t),y=t})),n.setTextNodeRange(u,o,a,s),!0}function de(t,e){const n=M();if(!I(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),u=t===Y;if(!ae(n)||!Vt(o)&&!l(o)||!Vt(s)&&!l(s))return!1;const a=s,g="rtl"===mt(a)?!u:u,f=r.key,h=r.offset,d=r.type;if(g){const t=_t(a,i.offset);if(null!==t){const{node:e,offset:r}=t;c(e)?e.selectNext(0,0):n.setTextNodeRange(e,r,e,r)}else a.getParentOrThrow().selectStart()}else xt(a).select();return e.shiftKey&&n.anchor.set(f,h,d),e.preventDefault(),e.stopPropagation(),!0}function pe(t,e,n){return k(...n?[t.registerCommand(R,t=>!t.altKey&&ut(Lt,t),K),t.registerCommand(W,t=>ut(Lt,t),K),t.registerCommand(J,t=>!t.altKey&&at(Lt,t),K),t.registerCommand(q,t=>at(Lt,t),K)]:[],t.registerCommand(U,e=>{const n=function(t){const e=M();if(!I(e)||!ae(e))return null;const n=t?X:Q,r=t?X:V,i=e.anchor,o=e.focus;if(i.is(o))return r;const s=ge(e);if(1!==s.length)return n;const l=s[0];let c,u;0===l.length&&ft(285),e.isBackward()?(c=o,u=i):(c=i,u=o);const a=dt(l[0]),g=pt(l[0]),f=tt(a.getKey(),0,"text"),h=tt(g.getKey(),g.getTextContentSize(),"text");return c.isBefore(f)||h.isBefore(u)?n:f.isBefore(c)||u.isBefore(h)?r:n}(e.shiftKey);return null!==n&&(e.preventDefault(),t.dispatchCommand(n),!0)},K),t.registerCommand(V,()=>!!ae(M())&&(G([a()]),!0),K),t.registerCommand(Q,()=>fe(Q),K),t.registerCommand(X,()=>fe(X,e),K),t.registerCommand(J,t=>{const e=M();if(!I(e))return!1;const{anchor:n}=e,r=n.getNode();if(!ae(e))return!1;const i=r.getParent();return e.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&Lt(i)&&null===i.getPreviousSibling()?(t.preventDefault(),!0):he(J,t)},K),t.registerCommand(R,t=>{const e=M();if(!I(e))return!1;const{anchor:n}=e,r=n.getNode();return!!ae(e)&&(e.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&Lt(r.getParentOrThrow())&&null===r.getParentOrThrow().getNextSibling()?(t.preventDefault(),!0):he(R,t))},K),t.registerCommand(Y,t=>de(Y,t),K),t.registerCommand(Z,t=>de(Z,t),K))}const me={build:(t,e)=>ct(e),config:{disabled:!1,escapeWithArrows:!1,tabSize:void 0},dependencies:[ce],name:"@lexical/code-indent",register:(t,e,n)=>{const r=n.getOutput();return lt(()=>{if(!r.disabled.value)return pe(t,r.tabSize.value,r.escapeWithArrows.value)})}};export{Ut as $createCodeHighlightNode,Bt as $createCodeNode,mt as $getCodeLineDirection,xt as $getEndOfCodeInLine,dt as $getFirstCodeNodeOfLine,pt as $getLastCodeNodeOfLine,_t as $getStartOfCodeInLine,Vt as $isCodeHighlightNode,Lt as $isCodeNode,St as $outdentLeadingSpaces,yt as $plainifyCodeContent,ce as CodeExtension,Jt as CodeHighlightNode,ue as CodeImportExtension,le as CodeImportRules,me as CodeIndentExtension,Ht as CodeNode,Pt as DEFAULT_CODE_LANGUAGE,Ft as getDefaultCodeLanguage,pe as registerCodeIndentation};
|
package/package.json
CHANGED
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
"code"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.51.0",
|
|
11
|
+
"version": "0.51.1-nightly.20260921.0",
|
|
12
12
|
"main": "./dist/LexicalCodeCore.js",
|
|
13
13
|
"types": "./dist/typescript-too-old.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@lexical/extension": "0.51.0",
|
|
16
|
-
"@lexical/html": "0.51.0",
|
|
17
|
-
"@lexical/internal": "0.51.0",
|
|
18
|
-
"@lexical/utils": "0.51.0",
|
|
19
|
-
"lexical": "0.51.0"
|
|
15
|
+
"@lexical/extension": "0.51.1-nightly.20260921.0",
|
|
16
|
+
"@lexical/html": "0.51.1-nightly.20260921.0",
|
|
17
|
+
"@lexical/internal": "0.51.1-nightly.20260921.0",
|
|
18
|
+
"@lexical/utils": "0.51.1-nightly.20260921.0",
|
|
19
|
+
"lexical": "0.51.1-nightly.20260921.0"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|