@lexical/code
Version:
This package contains the functionality for the code blocks and code highlighting for Lexical.
10 lines (8 loc) • 20.1 kB
JavaScript
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
"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 l extends t.ElementNode{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(e){return new l(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 l=this.getStyle();return l&&n.setAttribute("style",l),n}updateDOM(e,t,n){const r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(o,r):i&&t.removeAttribute(o);const l=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?l&&r?r!==i&&t.setAttribute(s,r):t.removeAttribute(s):l&&r&&t.setAttribute(s,r);const g=this.__theme,c=e.__theme;g?g!==c&&t.setAttribute(a,g):c&&t.removeAttribute(a);const u=this.__style,d=e.__style;return u?u!==d&&t.setAttribute("style",u):d&&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 l=this.getStyle();return l&&n.setAttribute("style",l),{element:n}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||i(e,"BR"))?{conversion:u,priority:1}:null,div:()=>({conversion:d,priority:1}),pre:()=>({conversion:u,priority:0}),table:e=>N(e)?{conversion:p,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 g().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,l=a.getParentOrThrow(),g=[t.$createLineBreakNode(),...n];l.splice(s,0,g);const c=n[n.length-1];c?c.select():0===o.offset?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(c(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 g(e,n){return t.$create(l).setLanguage(e).setTheme(n)}function c(e){return e instanceof l}function u(e){return{node:g(e.getAttribute(o))}}function d(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?g():null}:{node:null}}function p(){return{node:g()}}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 g()}}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){const n=O(e),r=S(e);let i=n;for(;null!==i;){if(x(i)){const e=t.getTextDirection(i.getTextContent());if(null!==e)return e}if(i===r)break;i=i.getNextSibling()}const o=n.getParent();if(t.$isElementNode(o)){const e=o.getDirection();if("ltr"===e||"rtl"===e)return e}return null}function $(e,r){let i=null,o=null,s=e,a=r,l=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),l=s.getTextContent()}else a--;const e=l[a];x(s)&&" "!==e&&(o={node:s,offset:a})}if(null!==o)return o;let g=null;if(r<e.getTextContentSize())x(e)&&(g=e.getTextContent()[r]);else{const t=e.getNextSibling();x(t)&&(g=t.getTextContent()[0])}if(null!==g&&" "!==g)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 A(e){const r=S(e);return t.$isLineBreakNode(r)&&n(168),r}const b=t.defineExtension({name:"@lexical/code",nodes:[l,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 L=globalThis.Prism||window.Prism,M={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"},E={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function v(e){return E[e]||e}function D(e){return"string"==typeof e?e:Array.isArray(e)?e.map(D).join(""):D(e.content)}function k(e,t){const n=/^diff-([\w-]+)/i.exec(t),r=e.getTextContent();let i=L.tokenize(r,L.languages[n?"diff":t]);return n&&(i=function(e,t){const n=t,r=L.languages[n],i={tokens:e},o=L.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 L.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,l=L.tokenize(D(s),r);l.unshift(i());const g=/\r\n|\n/g,c=e=>{const t=[];g.lastIndex=0;let r,o=0;for(;n<a&&(r=g.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},u=e=>{for(let t=0;t<e.length&&n<a;t++){const n=e[t];if("string"==typeof n){const r=c(n);r&&(e.splice(t,1,...r),t+=r.length-1)}else if("string"==typeof n.content){const e=c(n.content);e&&(n.content=e)}else Array.isArray(n.content)?u(n.content):u([n.content])}};u(l),n<a&&l.push(i()),e.content=l}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 P={$tokenize(e,t){return k(e,t||this.defaultLanguage)},defaultLanguage:r,tokenize(e,t){return L.tokenize(e,L.languages[t||""]||L.languages[this.defaultLanguage])}};function I(e,n,r){const i=e.getParent();c(i)?j(i,n,r):x(e)&&e.replace(t.$createTextNode(e.__text))}function w(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 B=new Set;function j(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&&L.languages.hasOwnProperty(n)}catch(e){return!1}}(o))return e.getIsSyntaxHighlightSupported()&&e.setIsSyntaxHighlightSupported(!1),void async function(){}();e.getIsSyntaxHighlightSupported()||e.setIsSyntaxHighlightSupported(!0),B.has(i)||(B.add(i),n.update(()=>{!function(e,n){const r=t.$getNodeByKey(e);if(!c(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 l=0;if(!a){const e=o.getNode();l=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>=l)return e.select(l,l),!0;l-=t}return!1})}(i,()=>{const n=t.$getNodeByKey(i);if(!c(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&&H(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++,!H(e[r-s],t[i-s])){s--;break}const a=n,l=r-s,g=t.slice(n,i-s);return{from:a,nodesForReplacement:g,to:l}}(n.getChildren(),s),{from:l,to:g,nodesForReplacement:u}=a;return!(l===g&&!u.length)&&(e.splice(l,g-l,u),!0)})},{onUpdate:()=>{B.delete(i)},skipTransforms:!0}))}function H(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 F(e){if(!t.$isRangeSelection(e))return!1;const n=e.anchor.getNode(),r=c(n)?n:n.getParent(),i=e.focus.getNode(),o=c(i)?i:i.getParent();return c(r)&&r.is(o)}function q(e){const r=e.getNodes(),i=[];if(1===r.length&&c(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 z(e){const n=t.$getSelection();if(!t.$isRangeSelection(n)||!F(n))return!1;const r=q(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 W(e,n){const r=t.$getSelection();if(!t.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,s=i.offset,a=o.offset,l=i.getNode(),g=o.getNode(),c=e===t.KEY_ARROW_UP_COMMAND;if(!F(r)||!x(l)&&!t.$isTabNode(l)||!x(g)&&!t.$isTabNode(g))return!1;if(!n.altKey){if(r.isCollapsed()){const e=l.getParentOrThrow();if(c&&0===s&&null===l.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),n.preventDefault(),!0}else if(!c&&s===l.getTextContentSize()&&null===l.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),n.preventDefault(),!0}}return!1}let u,d;if(l.isBefore(g)?(u=O(l),d=S(g)):(u=O(g),d=S(l)),null==u||null==d)return!1;const p=u.getNodesBetween(d);for(let e=0;e<p.length;e++){const n=p[e];if(!x(n)&&!t.$isTabNode(n)&&!t.$isLineBreakNode(n))return!1}n.preventDefault(),n.stopPropagation();const f=c?u.getPreviousSibling():d.getNextSibling();if(!t.$isLineBreakNode(f))return!0;const h=c?f.getPreviousSibling():f.getNextSibling();if(null==h)return!0;const N=x(h)||t.$isTabNode(h)||t.$isLineBreakNode(h)?c?O(h):S(h):null;let m=null!=N?N:h;return f.remove(),p.forEach(e=>e.remove()),e===t.KEY_ARROW_UP_COMMAND?(p.forEach(e=>m.insertBefore(e)),m.insertBefore(f)):(m.insertAfter(f),m=f,p.forEach(e=>{m.insertAfter(e),m=e})),r.setTextNodeRange(l,s,g,a),!0}function K(e,n){const r=t.$getSelection();if(!t.$isRangeSelection(r))return!1;const{anchor:i,focus:o}=r,s=i.getNode(),a=o.getNode(),l=e===t.MOVE_TO_START;if(!F(r)||!x(s)&&!t.$isTabNode(s)||!x(a)&&!t.$isTabNode(a))return!1;const g=a;if("rtl"===y(g)?!l:l){const e=$(g,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 g.getParentOrThrow().selectStart()}else{A(g).select()}return n.preventDefault(),n.stopPropagation(),!0}const Y=O,U=S,J=A,G=$;exports.$createCodeHighlightNode=T,exports.$createCodeNode=g,exports.$getCodeLineDirection=y,exports.$getEndOfCodeInLine=A,exports.$getFirstCodeNodeOfLine=O,exports.$getLastCodeNodeOfLine=S,exports.$getStartOfCodeInLine=$,exports.$isCodeHighlightNode=x,exports.$isCodeNode=c,exports.CODE_LANGUAGE_FRIENDLY_NAME_MAP=M,exports.CODE_LANGUAGE_MAP=E,exports.CodeExtension=b,exports.CodeHighlightNode=m,exports.CodeNode=l,exports.DEFAULT_CODE_LANGUAGE=r,exports.PrismTokenizer=P,exports.getCodeLanguageOptions=function(){const e=[];for(const[t,n]of Object.entries(M))e.push([t,n]);return e},exports.getCodeLanguages=()=>Object.keys(L.languages).filter(e=>"function"!=typeof L.languages[e]).sort(),exports.getCodeThemeOptions=function(){return[]},exports.getDefaultCodeLanguage=()=>r,exports.getEndOfCodeInLine=J,exports.getFirstCodeNodeOfLine=Y,exports.getLanguageFriendlyName=function(e){const t=v(e);return M[t]||t},exports.getLastCodeNodeOfLine=U,exports.getStartOfCodeInLine=G,exports.normalizeCodeLang=v,exports.normalizeCodeLanguage=v,exports.registerCodeHighlighting=function(r,i){if(!r.hasNodes([l,m]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==i&&(i=P);const o=[];return!0!==r._headless&&o.push(r.registerMutationListener(l,e=>{r.getEditorState().read(()=>{for(const[n,i]of e)if("destroyed"!==i){const e=t.$getNodeByKey(n);null!==e&&w(e,r)}})},{skipInitialization:!1})),o.push(r.registerNodeTransform(l,e=>j(e,r,i)),r.registerNodeTransform(t.TextNode,e=>I(e,r,i)),r.registerNodeTransform(m,e=>I(e,r,i)),r.registerCommand(t.KEY_TAB_COMMAND,e=>{const i=function(e){const r=t.$getSelection();if(!t.$isRangeSelection(r)||!F(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 l=q(r);if(1!==l.length)return i;const g=l[0];let c,u;0===g.length&&n(285),r.isBackward()?(c=a,u=s):(c=s,u=a);const d=O(g[0]),p=S(g[0]),f=t.$createPoint(d.getKey(),0,"text"),h=t.$createPoint(p.getKey(),p.getTextContentSize(),"text");return c.isBefore(f)||h.isBefore(u)?i:f.isBefore(c)||u.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,()=>!!F(t.$getSelection())&&(t.$insertNodes([t.$createTabNode()]),!0),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.INDENT_CONTENT_COMMAND,e=>z(t.INDENT_CONTENT_COMMAND),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.OUTDENT_CONTENT_COMMAND,e=>z(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!!F(n)&&(n.isCollapsed()&&0===r.offset&&null===i.getPreviousSibling()&&c(i.getParentOrThrow())?(e.preventDefault(),!0):W(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!!F(n)&&(n.isCollapsed()&&r.offset===i.getTextContentSize()&&null===i.getNextSibling()&&c(i.getParentOrThrow())?(e.preventDefault(),!0):W(t.KEY_ARROW_DOWN_COMMAND,e))},t.COMMAND_PRIORITY_LOW),r.registerCommand(t.MOVE_TO_START,e=>K(t.MOVE_TO_START,e),t.COMMAND_PRIORITY_LOW),r.registerCommand(t.MOVE_TO_END,e=>K(t.MOVE_TO_END,e),t.COMMAND_PRIORITY_LOW)),e.mergeRegister(...o)};