@react-fabric/lexical 1.0.0-beta.56 → 1.0.0-beta.58
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.
- package/css/_lexical.css +4 -0
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +33 -1
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +11 -11
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +525 -194
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +26 -23
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +3 -3
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +95 -38
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +11 -10
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +387 -124
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +22 -18
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +54 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +10 -10
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +107 -8
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +4 -0
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +23 -20
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +420 -137
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +50 -45
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +61 -65
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +2 -0
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +47 -46
- package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +3 -1
- package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +20 -10
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +34 -2
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +524 -196
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +4 -4
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +96 -40
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +387 -127
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +5 -4
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +56 -31
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +106 -10
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +3 -1
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +417 -139
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +62 -67
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +2 -1
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +3 -3
- package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +3 -1
- package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +20 -10
- package/package.json +12 -12
- package/src/hooks/useFormatWatcher.ts +3 -1
- package/src/plugins/ToolbarPlugin.tsx +5 -10
|
@@ -27,28 +27,31 @@ require('../../prismjs/components/prism-cpp.js');
|
|
|
27
27
|
*
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
function O(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 k=globalThis.Prism||window.Prism,L=t=>{try{return !!t&&k.languages.hasOwnProperty(t)}catch(t){return !1}};function A(e,n){for(const r of e.childNodes){if(LexicalUtils.isHTMLElement(r)&&r.tagName===n)return !0;A(r,n);}return !1}const H="data-language",D="data-highlight-language";class M extends lexical.ElementNode{static getType(){return "code"}static clone(t){return new M(t.__language,t.__key)}constructor(t,e){super(e),this.__language=t||void 0,this.__isSyntaxHighlightSupported=L(t);}createDOM(t){const n=document.createElement("code");LexicalUtils.addClassNamesToElement(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();return r&&(n.setAttribute(H,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(D,r)),n}updateDOM(t,e,n){const r=this.__language,o=t.__language;return r?r!==o&&(e.setAttribute(H,r),this.__isSyntaxHighlightSupported&&e.setAttribute(D,r)):o&&(e.removeAttribute(H),t.__isSyntaxHighlightSupported&&e.removeAttribute(D)),!1}exportDOM(t){const n=document.createElement("pre");LexicalUtils.addClassNamesToElement(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();return r&&(n.setAttribute(H,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(D,r)),{element:n}}static importDOM(){return {code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||A(t,"BR"))?{conversion:E,priority:1}:null,div:()=>({conversion:F,priority:1}),pre:()=>({conversion:E,priority:0}),table:t=>K(t)?{conversion:B,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&K(n)?{conversion:R,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&K(e)?{conversion:R,priority:3}:null}}}static importJSON(t){return z().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setLanguage(t.language)}exportJSON(){return {...super.exportJSON(),language:this.getLanguage()}}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=lexical.$createParagraphNode();return this.insertAfter(t,e),t}const{anchor:o,focus:i}=t,a=(o.isBefore(i)?o:i).getNode();if(lexical.$isTextNode(a)){let t=nt(a);const e=[];for(;;)if(lexical.$isTabNode(t))e.push(lexical.$createTabNode()),t=t.getNextSibling();else {if(!tt(t))break;{let n=0;const r=t.getTextContent(),o=t.getTextContentSize();for(;n<o&&" "===r[n];)n++;if(0!==n&&e.push(Z(" ".repeat(n))),n!==o)break;t=t.getNextSibling();}}const n=a.splitText(o.offset)[0],r=0===o.offset?0:1,i=n.getIndexWithinParent()+r,s=a.getParentOrThrow(),l=[lexical.$createLineBreakNode(),...e];s.splice(i,0,l);const p=e[e.length-1];p?p.select():0===o.offset?n.selectPrevious():n.getNextSibling().selectNext(0,0);}if(J(a)){const{offset:e}=t.anchor;a.splice(e,0,[lexical.$createLineBreakNode()]),a.select(e+1,e+1);}return null}canIndent(){return !1}collapseAtStart(){const t=lexical.$createParagraphNode();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.__isSyntaxHighlightSupported=L(t),e}getLanguage(){return this.getLatest().__language}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}}function z(t){return lexical.$applyNodeReplacement(new M(t))}function J(t){return t instanceof M}function E(t){return {node:z(t.getAttribute(H))}}function F(t){const e=t,n=I(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(I(e))return !0;e=e.parentElement;}return !1}(e)?{node:n?z():null}:{node:null}}function B(){return {node:z()}}function R(){return {node:null}}function I(t){return null!==t.style.fontFamily.match("monospace")}function K(t){return t.classList.contains("js-file-line-container")}const q="javascript",U={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"},W={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function $(t){return W[t]||t}function Q(t){const e=$(t);return U[e]||e}const X=()=>q,G=()=>Object.keys(k.languages).filter((t=>"function"!=typeof k.languages[t])).sort();class V extends lexical.TextNode{constructor(t="",e,n){super(t,n),this.__highlightType=e;}static getType(){return "code-highlight"}static clone(t){return new V(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=Y(t.theme,this.__highlightType);return LexicalUtils.addClassNamesToElement(n,r),n}updateDOM(t,r,o){const i=super.updateDOM(t,r,o),s=Y(o.theme,t.__highlightType),l=Y(o.theme,this.__highlightType);return s!==l&&(s&&LexicalUtils.removeClassNamesFromElement(r,s),l&&LexicalUtils.addClassNamesToElement(r,l)),i}static importJSON(t){return Z().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 z()}}function Y(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function Z(t="",e){return lexical.$applyNodeReplacement(new V(t,e))}function tt(t){return t instanceof V}function et(t,e){let n=t;for(let o=lexical.$getSiblingCaret(t,e);o&&(tt(o.origin)||lexical.$isTabNode(o.origin));o=LexicalUtils.$getAdjacentCaret(o))n=o.origin;return n}function nt(t){return et(t,"previous")}function rt(t){return et(t,"next")}const ot={defaultLanguage:q,tokenize(t,e){return k.tokenize(t,k.languages[e||""]||k.languages[this.defaultLanguage])}};function it(t,e){let n=null,r=null,o=t,i=e,s=t.getTextContent();for(;;){if(0===i){if(o=o.getPreviousSibling(),null===o)break;if(tt(o)||lexical.$isTabNode(o)||lexical.$isLineBreakNode(o)||O(167),lexical.$isLineBreakNode(o)){n={node:o,offset:1};break}i=Math.max(0,o.getTextContentSize()-1),s=o.getTextContent();}else i--;const t=s[i];tt(o)&&" "!==t&&(r={node:o,offset:i});}if(null!==r)return r;let l=null;if(e<t.getTextContentSize())tt(t)&&(l=t.getTextContent()[e]);else {const e=t.getNextSibling();tt(e)&&(l=e.getTextContent()[0]);}if(null!==l&&" "!==l)return n;{const r=function(t,e){let n=t,r=e,o=t.getTextContent(),i=t.getTextContentSize();for(;;){if(!tt(n)||r===i){if(n=n.getNextSibling(),null===n||lexical.$isLineBreakNode(n))return null;tt(n)&&(r=0,o=n.getTextContent(),i=n.getTextContentSize());}if(tt(n)){if(" "!==o[r])return {node:n,offset:r};r++;}}}(t,e);return null!==r?r:n}}function st(t){const e=rt(t);return lexical.$isLineBreakNode(e)&&O(168),e}function lt(t,e,n){const r=t.getParent();J(r)?gt(r,e,n):tt(t)&&t.replace(lexical.$createTextNode(t.__text));}function ut(t,e){const n=e.getElementByKey(t.getKey());if(null===n)return;const r=t.getChildren(),o=r.length;if(o===n.__cachedChildrenLength)return;n.__cachedChildrenLength=o;let i="1",s=1;for(let t=0;t<o;t++)lexical.$isLineBreakNode(r[t])&&(i+="\n"+ ++s);n.setAttribute("data-gutter",i);}const ct=new Set;function gt(t,e,n){const r=t.getKey();ct.has(r)||(ct.add(r),void 0===t.getLanguage()&&t.setLanguage(n.defaultLanguage),e.update((()=>{!function(t,e){const n=lexical.$getNodeByKey(t);if(!J(n)||!n.isAttached())return;const r=lexical.$getSelection();if(!lexical.$isRangeSelection(r))return void e();const o=r.anchor,i=o.offset,s="element"===o.type&&lexical.$isLineBreakNode(n.getChildAtIndex(o.offset-1));let u=0;if(!s){const t=o.getNode();u=i+t.getPreviousSiblings().reduce(((t,e)=>t+e.getTextContentSize()),0);}if(!e())return;if(s)return void o.getNode().select(i,i);n.getChildren().some((t=>{const e=lexical.$isTextNode(t);if(e||lexical.$isLineBreakNode(t)){const n=t.getTextContentSize();if(e&&n>=u)return t.select(u,u),!0;u-=n;}return !1}));}(r,(()=>{const e=lexical.$getNodeByKey(r);if(!J(e)||!e.isAttached())return !1;const o=e.getTextContent(),i=at(n.tokenize(o,e.getLanguage()||n.defaultLanguage)),s=function(t,e){let n=0;for(;n<t.length&&pt(t[n],e[n]);)n++;const r=t.length,o=e.length,i=Math.min(r,o)-n;let s=0;for(;s<i;)if(s++,!pt(t[r-s],e[o-s])){s--;break}const l=n,u=r-s,c=e.slice(n,o-s);return {from:l,nodesForReplacement:c,to:u}}(e.getChildren(),i),{from:l,to:u,nodesForReplacement:c}=s;return !(l===u&&!c.length)&&(t.splice(l,u-l,c),!0)}));}),{onUpdate:()=>{ct.delete(r);},skipTransforms:!0}));}function at(t,e){const n=[];for(const r of t)if("string"==typeof r){const t=r.split(/(\n|\t)/),o=t.length;for(let r=0;r<o;r++){const o=t[r];"\n"===o||"\r\n"===o?n.push(lexical.$createLineBreakNode()):"\t"===o?n.push(lexical.$createTabNode()):o.length>0&&n.push(Z(o,e));}}else {const{content:t}=r;"string"==typeof t?n.push(...at([t],r.type)):Array.isArray(t)&&n.push(...at(t,r.type));}return n}function pt(t,e){return tt(t)&&tt(e)&&t.__text===e.__text&&t.__highlightType===e.__highlightType||lexical.$isTabNode(t)&&lexical.$isTabNode(e)||lexical.$isLineBreakNode(t)&&lexical.$isLineBreakNode(e)}function ft(t){if(!lexical.$isRangeSelection(t))return !1;const e=t.anchor.getNode(),n=t.focus.getNode();if(e.is(n)&&J(e))return !0;const r=e.getParent();return J(r)&&r.is(n.getParent())}function ht(t){const e=t.getNodes(),n=[[]];if(1===e.length&&J(e[0]))return n;let r=n[0];for(let t=0;t<e.length;t++){const o=e[t];tt(o)||lexical.$isTabNode(o)||lexical.$isLineBreakNode(o)||O(169),lexical.$isLineBreakNode(o)?0!==t&&r.length>0&&(r=[],n.push(r)):r.push(o);}return n}function dt(t){const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e)||!ft(e))return !1;const n=ht(e),r=n.length;if(n.length>1){for(let e=0;e<r;e++){const r=n[e];if(r.length>0){let n=r[0];0===e&&(n=nt(n)),null!==n&&(t===lexical.INDENT_CONTENT_COMMAND?n.insertBefore(lexical.$createTabNode()):lexical.$isTabNode(n)&&n.remove());}}return !0}const o=e.getNodes()[0];if(J(o)||tt(o)||lexical.$isTabNode(o)||lexical.$isLineBreakNode(o)||O(171),J(o))return t===lexical.INDENT_CONTENT_COMMAND&&e.insertNodes([lexical.$createTabNode()]),!0;const i=nt(o);return t===lexical.INDENT_CONTENT_COMMAND?lexical.$isLineBreakNode(i)?i.insertAfter(lexical.$createTabNode()):i.insertBefore(lexical.$createTabNode()):lexical.$isTabNode(i)&&i.remove(),!0}function mt(t,e){const n=lexical.$getSelection();if(!lexical.$isRangeSelection(n))return !1;const{anchor:r,focus:o}=n,i=r.offset,s=o.offset,l=r.getNode(),c=o.getNode(),g=t===lexical.KEY_ARROW_UP_COMMAND;if(!ft(n)||!tt(l)&&!lexical.$isTabNode(l)||!tt(c)&&!lexical.$isTabNode(c))return !1;if(!e.altKey){if(n.isCollapsed()){const t=l.getParentOrThrow();if(g&&0===i&&null===l.getPreviousSibling()){if(null===t.getPreviousSibling())return t.selectPrevious(),e.preventDefault(),!0}else if(!g&&i===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=nt(l),p=rt(c)):(a=nt(c),p=rt(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(!tt(e)&&!lexical.$isTabNode(e)&&!lexical.$isLineBreakNode(e))return !1}e.preventDefault(),e.stopPropagation();const d=g?a.getPreviousSibling():p.getNextSibling();if(!lexical.$isLineBreakNode(d))return !0;const m=g?d.getPreviousSibling():d.getNextSibling();if(null==m)return !0;const S=tt(m)||lexical.$isTabNode(m)||lexical.$isLineBreakNode(m)?g?nt(m):rt(m):null;let _=null!=S?S:m;return d.remove(),f.forEach((t=>t.remove())),t===lexical.KEY_ARROW_UP_COMMAND?(f.forEach((t=>_.insertBefore(t))),_.insertBefore(d)):(_.insertAfter(d),_=d,f.forEach((t=>{_.insertAfter(t),_=t;}))),n.setTextNodeRange(l,i,c,s),!0}function xt(t,e){const n=lexical.$getSelection();if(!lexical.$isRangeSelection(n))return !1;const{anchor:r,focus:o}=n,i=r.getNode(),s=o.getNode(),l=t===lexical.MOVE_TO_START;if(!ft(n)||!tt(i)&&!lexical.$isTabNode(i)||!tt(s)&&!lexical.$isTabNode(s))return !1;if(l){const t=it(s,o.offset);if(null!==t){const{node:e,offset:r}=t;lexical.$isLineBreakNode(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 yt(t,e){if(!t.hasNodes([M,V]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");return null==e&&(e=ot),LexicalUtils.mergeRegister(t.registerMutationListener(M,(e=>{t.update((()=>{for(const[n,r]of e)if("destroyed"!==r){const e=lexical.$getNodeByKey(n);null!==e&&ut(e,t);}}));}),{skipInitialization:!1}),t.registerNodeTransform(M,(n=>gt(n,t,e))),t.registerNodeTransform(lexical.TextNode,(n=>lt(n,t,e))),t.registerNodeTransform(V,(n=>lt(n,t,e))),t.registerCommand(lexical.KEY_TAB_COMMAND,(e=>{const n=function(t){const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e)||!ft(e))return null;const n=t?lexical.OUTDENT_CONTENT_COMMAND:lexical.INDENT_CONTENT_COMMAND,r=t?lexical.OUTDENT_CONTENT_COMMAND:lexical.INSERT_TAB_COMMAND;if(ht(e).length>1)return n;const o=e.getNodes()[0];if(J(o)||tt(o)||lexical.$isTabNode(o)||lexical.$isLineBreakNode(o)||O(170),J(o))return n;const i=nt(o),s=rt(o),l=e.anchor,c=e.focus;let g,a;return c.isBefore(l)?(g=c,a=l):(g=l,a=c),null!==i&&null!==s&&g.key===i.getKey()&&0===g.offset&&a.key===s.getKey()&&a.offset===s.getTextContentSize()?n:r}(e.shiftKey);return null!==n&&(e.preventDefault(),t.dispatchCommand(n,void 0),!0)}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.INSERT_TAB_COMMAND,(()=>!!ft(lexical.$getSelection())&&(lexical.$insertNodes([lexical.$createTabNode()]),!0)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.INDENT_CONTENT_COMMAND,(t=>dt(lexical.INDENT_CONTENT_COMMAND)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.OUTDENT_CONTENT_COMMAND,(t=>dt(lexical.OUTDENT_CONTENT_COMMAND)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_ARROW_UP_COMMAND,(t=>{const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e))return !1;const{anchor:n}=e,r=n.getNode();return !!ft(e)&&(e.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&J(r.getParentOrThrow())?(t.preventDefault(),!0):mt(lexical.KEY_ARROW_UP_COMMAND,t))}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND,(t=>{const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e))return !1;const{anchor:n}=e,r=n.getNode();return !!ft(e)&&(e.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&J(r.getParentOrThrow())?(t.preventDefault(),!0):mt(lexical.KEY_ARROW_DOWN_COMMAND,t))}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.MOVE_TO_START,(t=>xt(lexical.MOVE_TO_START,t)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.MOVE_TO_END,(t=>xt(lexical.MOVE_TO_END,t)),lexical.COMMAND_PRIORITY_LOW))}const St=nt,_t=rt,vt=st,Nt=it;
|
|
30
|
+
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(LexicalUtils.isHTMLElement(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 lexical.ElementNode{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");LexicalUtils.addClassNamesToElement(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");LexicalUtils.addClassNamesToElement(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=lexical.$createParagraphNode();return this.insertAfter(t,e),t}const{anchor:i,focus:o}=t,g=(i.isBefore(o)?i:o).getNode();if(lexical.$isTextNode(g)){let t=rt(g);const e=[];for(;;)if(lexical.$isTabNode(t))e.push(lexical.$createTabNode()),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=[lexical.$createLineBreakNode(),...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,[lexical.$createLineBreakNode()]),g.select(e+1,e+1);}return null}canIndent(){return !1}collapseAtStart(){const t=lexical.$createParagraphNode();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 lexical.$create(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 lexical.TextNode{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 LexicalUtils.addClassNamesToElement(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&&LexicalUtils.removeClassNamesFromElement(r,s),u&&LexicalUtils.addClassNamesToElement(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 lexical.$applyNodeReplacement(new Y(t,e))}function et(t){return t instanceof Y}function nt(t,e){let n=t;for(let i=lexical.$getSiblingCaret(t,e);i&&(et(i.origin)||lexical.$isTabNode(i.origin));i=LexicalUtils.$getAdjacentCaret(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)||lexical.$isTabNode(i)||lexical.$isLineBreakNode(i)||B(167),lexical.$isLineBreakNode(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||lexical.$isLineBreakNode(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 lexical.$isLineBreakNode(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(lexical.$createLineBreakNode()):"\t"===i?n.push(lexical.$createTabNode()):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(lexical.$createTextNode(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++)lexical.$isLineBreakNode(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=lexical.$getNodeByKey(t);if(!W(n)||!n.isAttached())return;const r=lexical.$getSelection();if(!lexical.$isRangeSelection(r))return void e();const i=r.anchor,o=i.offset,s="element"===i.type&&lexical.$isLineBreakNode(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=lexical.$isTextNode(t);if(e||lexical.$isLineBreakNode(t)){const n=t.getTextContentSize();if(e&&n>=l)return t.select(l,l),!0;l-=n;}return !1}));}(r,(()=>{const e=lexical.$getNodeByKey(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||lexical.$isTabNode(t)&&lexical.$isTabNode(e)||lexical.$isLineBreakNode(t)&&lexical.$isLineBreakNode(e)}function Ct(t){if(!lexical.$isRangeSelection(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)||lexical.$isTabNode(i)||lexical.$isLineBreakNode(i)||B(169),lexical.$isLineBreakNode(i)?r.length>0&&(n.push(r),r=[]):r.push(i);}if(r.length>0){const e=t.isBackward()?t.anchor:t.focus,i=lexical.$createPoint(r[0].getKey(),0,"text");e.is(i)||n.push(r);}return n}function jt(t){const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e)||!Ct(e))return !1;const n=Nt(e),r=n.length;if(0===r&&e.isCollapsed())return t===lexical.INDENT_CONTENT_COMMAND&&e.insertNodes([lexical.$createTabNode()]),!0;if(0===r&&t===lexical.INDENT_CONTENT_COMMAND&&"\n"===e.getTextContent()){const t=lexical.$createTabNode(),n=lexical.$createLineBreakNode(),r=e.isBackward()?"previous":"next";return e.insertNodes([t,n]),lexical.$setSelectionFromCaretRange(lexical.$getCaretRangeInDirection(lexical.$getCaretRange(lexical.$getTextPointCaret(t,"next",0),lexical.$normalizeCaret(lexical.$getSiblingCaret(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===lexical.INDENT_CONTENT_COMMAND){const t=lexical.$createTabNode();if(n.insertBefore(t),0===i){const r=e.isBackward()?"focus":"anchor",i=lexical.$createPoint(n.getKey(),0,"text");e[r].is(i)&&e[r].set(t.getKey(),0,"text");}}else lexical.$isTabNode(n)&&n.remove();}}return !0}function wt(t,e){const n=lexical.$getSelection();if(!lexical.$isRangeSelection(n))return !1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,u=r.getNode(),c=i.getNode(),a=t===lexical.KEY_ARROW_UP_COMMAND;if(!Ct(n)||!et(u)&&!lexical.$isTabNode(u)||!et(c)&&!lexical.$isTabNode(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)&&!lexical.$isTabNode(e)&&!lexical.$isLineBreakNode(e))return !1}e.preventDefault(),e.stopPropagation();const h=a?g.getPreviousSibling():f.getNextSibling();if(!lexical.$isLineBreakNode(h))return !0;const m=a?h.getPreviousSibling():h.getNextSibling();if(null==m)return !0;const y=et(m)||lexical.$isTabNode(m)||lexical.$isLineBreakNode(m)?a?rt(m):it(m):null;let _=null!=y?y:m;return h.remove(),p.forEach((t=>t.remove())),t===lexical.KEY_ARROW_UP_COMMAND?(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=lexical.$getSelection();if(!lexical.$isRangeSelection(n))return !1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),u=t===lexical.MOVE_TO_START;if(!Ct(n)||!et(o)&&!lexical.$isTabNode(o)||!et(s)&&!lexical.$isTabNode(s))return !1;if(u){const t=ot(s,i.offset);if(null!==t){const{node:e,offset:r}=t;lexical.$isLineBreakNode(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=lexical.$getNodeByKey(n);null!==e&&_t(e,t);}}));}),{skipInitialization:!1})),n.push(t.registerNodeTransform(K,(n=>Tt(n,t,e))),t.registerNodeTransform(lexical.TextNode,(n=>St(n,t,e))),t.registerNodeTransform(Y,(n=>St(n,t,e))),t.registerCommand(lexical.KEY_TAB_COMMAND,(e=>{const n=function(t){const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e)||!Ct(e))return null;const n=t?lexical.OUTDENT_CONTENT_COMMAND:lexical.INDENT_CONTENT_COMMAND,r=t?lexical.OUTDENT_CONTENT_COMMAND:lexical.INSERT_TAB_COMMAND,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=lexical.$createPoint(a.getKey(),0,"text"),p=lexical.$createPoint(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)}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.INSERT_TAB_COMMAND,(()=>!!Ct(lexical.$getSelection())&&(lexical.$insertNodes([lexical.$createTabNode()]),!0)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.INDENT_CONTENT_COMMAND,(t=>jt(lexical.INDENT_CONTENT_COMMAND)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.OUTDENT_CONTENT_COMMAND,(t=>jt(lexical.OUTDENT_CONTENT_COMMAND)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_ARROW_UP_COMMAND,(t=>{const e=lexical.$getSelection();if(!lexical.$isRangeSelection(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(lexical.KEY_ARROW_UP_COMMAND,t))}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND,(t=>{const e=lexical.$getSelection();if(!lexical.$isRangeSelection(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(lexical.KEY_ARROW_DOWN_COMMAND,t))}),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.MOVE_TO_START,(t=>kt(lexical.MOVE_TO_START,t)),lexical.COMMAND_PRIORITY_LOW),t.registerCommand(lexical.MOVE_TO_END,(t=>kt(lexical.MOVE_TO_END,t)),lexical.COMMAND_PRIORITY_LOW)),LexicalUtils.mergeRegister(...n)}const Pt=rt,Lt=it,Ot=st,Ht=ot;
|
|
31
31
|
|
|
32
|
-
exports.$createCodeHighlightNode =
|
|
33
|
-
exports.$createCodeNode =
|
|
32
|
+
exports.$createCodeHighlightNode = tt;
|
|
33
|
+
exports.$createCodeNode = $;
|
|
34
34
|
exports.$getEndOfCodeInLine = st;
|
|
35
|
-
exports.$getFirstCodeNodeOfLine =
|
|
36
|
-
exports.$getLastCodeNodeOfLine =
|
|
37
|
-
exports.$getStartOfCodeInLine =
|
|
38
|
-
exports.$isCodeHighlightNode =
|
|
39
|
-
exports.$isCodeNode =
|
|
40
|
-
exports.CODE_LANGUAGE_FRIENDLY_NAME_MAP =
|
|
41
|
-
exports.CODE_LANGUAGE_MAP =
|
|
42
|
-
exports.CodeHighlightNode =
|
|
43
|
-
exports.CodeNode =
|
|
44
|
-
exports.DEFAULT_CODE_LANGUAGE =
|
|
45
|
-
exports.PrismTokenizer =
|
|
46
|
-
exports.
|
|
47
|
-
exports.
|
|
48
|
-
exports.
|
|
49
|
-
exports.
|
|
50
|
-
exports.
|
|
51
|
-
exports.
|
|
52
|
-
exports.
|
|
53
|
-
exports.
|
|
54
|
-
exports.
|
|
35
|
+
exports.$getFirstCodeNodeOfLine = rt;
|
|
36
|
+
exports.$getLastCodeNodeOfLine = it;
|
|
37
|
+
exports.$getStartOfCodeInLine = ot;
|
|
38
|
+
exports.$isCodeHighlightNode = et;
|
|
39
|
+
exports.$isCodeNode = W;
|
|
40
|
+
exports.CODE_LANGUAGE_FRIENDLY_NAME_MAP = lt;
|
|
41
|
+
exports.CODE_LANGUAGE_MAP = ct;
|
|
42
|
+
exports.CodeHighlightNode = Y;
|
|
43
|
+
exports.CodeNode = K;
|
|
44
|
+
exports.DEFAULT_CODE_LANGUAGE = D;
|
|
45
|
+
exports.PrismTokenizer = xt;
|
|
46
|
+
exports.getCodeLanguageOptions = pt;
|
|
47
|
+
exports.getCodeLanguages = ft;
|
|
48
|
+
exports.getCodeThemeOptions = ht;
|
|
49
|
+
exports.getDefaultCodeLanguage = F;
|
|
50
|
+
exports.getEndOfCodeInLine = Ot;
|
|
51
|
+
exports.getFirstCodeNodeOfLine = Pt;
|
|
52
|
+
exports.getLanguageFriendlyName = gt;
|
|
53
|
+
exports.getLastCodeNodeOfLine = Lt;
|
|
54
|
+
exports.getStartOfCodeInLine = Ht;
|
|
55
|
+
exports.normalizeCodeLang = at;
|
|
56
|
+
exports.normalizeCodeLanguage = at;
|
|
57
|
+
exports.registerCodeHighlighting = At;
|
|
@@ -40,7 +40,7 @@ function $generateNodesFromDOM(editor, dom) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
$
|
|
43
|
+
$unwrapArtificialNodes(allArtificialNodes);
|
|
44
44
|
return lexicalNodes;
|
|
45
45
|
}
|
|
46
46
|
function $generateHtmlFromNodes(editor, selection) {
|
|
@@ -66,7 +66,7 @@ function $appendNodesToHTML(editor, currentNode, parentElement, selection = null
|
|
|
66
66
|
target = clone;
|
|
67
67
|
}
|
|
68
68
|
const children = lexical.$isElementNode(target) ? target.getChildren() : [];
|
|
69
|
-
const registeredNode =
|
|
69
|
+
const registeredNode = lexical.getRegisteredNode(editor, target.getType());
|
|
70
70
|
let exportOutput;
|
|
71
71
|
|
|
72
72
|
// Use HTMLConfig overrides, if available.
|
|
@@ -226,7 +226,7 @@ function wrapContinuousInlines(domNode, nodes, createWrapperFn) {
|
|
|
226
226
|
}
|
|
227
227
|
return out;
|
|
228
228
|
}
|
|
229
|
-
function $
|
|
229
|
+
function $unwrapArtificialNodes(allArtificialNodes) {
|
|
230
230
|
for (const node of allArtificialNodes) {
|
|
231
231
|
if (node.getNextSibling() instanceof lexical.ArtificialNode__DO_NOT_USE) {
|
|
232
232
|
node.insertAfter(lexical.$createLineBreakNode());
|
|
@@ -12,7 +12,7 @@ var lexical = require('lexical');
|
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
function
|
|
15
|
+
function m(e,n){const t=n.body?n.body.childNodes:[];let o=[];const l=[];for(let n=0;n<t.length;n++){const r=t[n];if(!y.has(r.nodeName)){const n=w(r,e,l,!1);null!==n&&(o=o.concat(n));}}return function(e){for(const n of e)n.getNextSibling()instanceof lexical.ArtificialNode__DO_NOT_USE&&n.insertAfter(lexical.$createLineBreakNode());for(const n of e){const e=n.getChildren();for(const t of e)n.insertBefore(t);n.remove();}}(l),o}function g(e,n){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),l=lexical.$getRoot().getChildren();for(let o=0;o<l.length;o++){x(e,l[o],t,n);}return t.innerHTML}function x(t,o,u,f=null){let a=null===f||o.isSelected(f);const d=lexical.$isElementNode(o)&&o.excludeFromCopy("html");let p=o;if(null!==f){let n=lexical.$cloneWithProperties(o);n=lexical.$isTextNode(n)&&null!==f?LexicalSelection.$sliceSelectedTextNodeContent(f,n):n,p=n;}const h=lexical.$isElementNode(p)?p.getChildren():[],m=lexical.getRegisteredNode(t,p.getType());let g;g=m&&void 0!==m.exportDOM?m.exportDOM(t,p):p.exportDOM(t);const{element:y,after:w}=g;if(!y)return !1;const b=document.createDocumentFragment();for(let e=0;e<h.length;e++){const n=h[e],r=x(t,n,b,f);!a&&lexical.$isElementNode(o)&&r&&o.extractWithChild(n,f,"html")&&(a=!0);}if(a&&!d){if((LexicalUtils.isHTMLElement(y)||lexical.isDocumentFragment(y))&&y.append(b),u.append(y),w){const e=w.call(p,y);e&&(lexical.isDocumentFragment(y)?y.replaceChildren(e):y.replaceWith(e));}}else u.append(b);return a}const y=new Set(["STYLE","SCRIPT"]);function w(e,n,o,r,i=new Map,s){let c=[];if(y.has(e.nodeName))return c;let m=null;const g=function(e,n){const{nodeName:t}=e,o=n._htmlConversions.get(t.toLowerCase());let l=null;if(void 0!==o)for(const n of o){const t=n(e);null!==t&&(null===l||(l.priority||0)<=(t.priority||0))&&(l=t);}return null!==l?l.conversion:null}(e,n),x=g?g(e):null;let C=null;if(null!==x){C=x.after;const n=x.node;if(m=Array.isArray(n)?n[n.length-1]:n,null!==m){for(const[,e]of i)if(m=e(m,s),!m)break;m&&c.push(...Array.isArray(n)?n:[m]);}null!=x.forChild&&i.set(e.nodeName,x.forChild);}const S=e.childNodes;let v=[];const N=(null==m||!lexical.$isRootOrShadowRoot(m))&&(null!=m&&lexical.$isBlockElementNode(m)||r);for(let e=0;e<S.length;e++)v.push(...w(S[e],n,o,N,new Map(i),m));return null!=C&&(v=C(v)),LexicalUtils.isBlockDomNode(e)&&(v=b(e,v,N?()=>{const e=new lexical.ArtificialNode__DO_NOT_USE;return o.push(e),e}:lexical.$createParagraphNode)),null==m?v.length>0?c=c.concat(v):LexicalUtils.isBlockDomNode(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return !1;return lexical.isInlineDomNode(e.nextSibling)&&lexical.isInlineDomNode(e.previousSibling)}(e)&&(c=c.concat(lexical.$createLineBreakNode())):lexical.$isElementNode(m)&&m.append(...v),c}function b(e,n,t){const o=e.style.textAlign,l=[];let r=[];for(let e=0;e<n.length;e++){const i=n[e];if(lexical.$isBlockElementNode(i))o&&!i.getFormat()&&i.setFormat(o),l.push(i);else if(r.push(i),e===n.length-1||e<n.length-1&&lexical.$isBlockElementNode(n[e+1])){const e=t();e.setFormat(o),e.append(...r),l.push(e),r=[];}}return l}
|
|
16
16
|
|
|
17
|
-
exports.$generateHtmlFromNodes =
|
|
18
|
-
exports.$generateNodesFromDOM =
|
|
17
|
+
exports.$generateHtmlFromNodes = g;
|
|
18
|
+
exports.$generateNodesFromDOM = m;
|
|
@@ -62,50 +62,30 @@ class LinkNode extends lexical.ElementNode {
|
|
|
62
62
|
}
|
|
63
63
|
createDOM(config) {
|
|
64
64
|
const element = document.createElement('a');
|
|
65
|
-
|
|
66
|
-
if (this.__target !== null) {
|
|
67
|
-
element.target = this.__target;
|
|
68
|
-
}
|
|
69
|
-
if (this.__rel !== null) {
|
|
70
|
-
element.rel = this.__rel;
|
|
71
|
-
}
|
|
72
|
-
if (this.__title !== null) {
|
|
73
|
-
element.title = this.__title;
|
|
74
|
-
}
|
|
65
|
+
this.updateLinkDOM(null, element, config);
|
|
75
66
|
LexicalUtils.addClassNamesToElement(element, config.theme.link);
|
|
76
67
|
return element;
|
|
77
68
|
}
|
|
78
|
-
|
|
69
|
+
updateLinkDOM(prevNode, anchor, config) {
|
|
79
70
|
if (LexicalUtils.isHTMLAnchorElement(anchor)) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const rel = this.__rel;
|
|
83
|
-
const title = this.__title;
|
|
84
|
-
if (url !== prevNode.__url) {
|
|
85
|
-
anchor.href = url;
|
|
71
|
+
if (!prevNode || prevNode.__url !== this.__url) {
|
|
72
|
+
anchor.href = this.sanitizeUrl(this.__url);
|
|
86
73
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
anchor.rel = rel;
|
|
97
|
-
} else {
|
|
98
|
-
anchor.removeAttribute('rel');
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (title !== prevNode.__title) {
|
|
102
|
-
if (title) {
|
|
103
|
-
anchor.title = title;
|
|
104
|
-
} else {
|
|
105
|
-
anchor.removeAttribute('title');
|
|
74
|
+
for (const attr of ['target', 'rel', 'title']) {
|
|
75
|
+
const key = `__${attr}`;
|
|
76
|
+
const value = this[key];
|
|
77
|
+
if (!prevNode || prevNode[key] !== value) {
|
|
78
|
+
if (value) {
|
|
79
|
+
anchor[attr] = value;
|
|
80
|
+
} else {
|
|
81
|
+
anchor.removeAttribute(attr);
|
|
82
|
+
}
|
|
106
83
|
}
|
|
107
84
|
}
|
|
108
85
|
}
|
|
86
|
+
}
|
|
87
|
+
updateDOM(prevNode, anchor, config) {
|
|
88
|
+
this.updateLinkDOM(prevNode, anchor, config);
|
|
109
89
|
return false;
|
|
110
90
|
}
|
|
111
91
|
static importDOM() {
|
|
@@ -123,8 +103,9 @@ class LinkNode extends lexical.ElementNode {
|
|
|
123
103
|
return super.updateFromJSON(serializedNode).setURL(serializedNode.url).setRel(serializedNode.rel || null).setTarget(serializedNode.target || null).setTitle(serializedNode.title || null);
|
|
124
104
|
}
|
|
125
105
|
sanitizeUrl(url) {
|
|
106
|
+
url = formatUrl(url);
|
|
126
107
|
try {
|
|
127
|
-
const parsedUrl = new URL(url);
|
|
108
|
+
const parsedUrl = new URL(formatUrl(url));
|
|
128
109
|
// eslint-disable-next-line no-script-url
|
|
129
110
|
if (!SUPPORTED_URL_PROTOCOLS.has(parsedUrl.protocol)) {
|
|
130
111
|
return 'about:blank';
|
|
@@ -401,9 +382,51 @@ function $toggleLink(url, attributes = {}) {
|
|
|
401
382
|
} = attributes;
|
|
402
383
|
const rel = attributes.rel === undefined ? 'noreferrer' : attributes.rel;
|
|
403
384
|
const selection = lexical.$getSelection();
|
|
404
|
-
if (!lexical.$isRangeSelection(selection)) {
|
|
385
|
+
if (selection === null || !lexical.$isRangeSelection(selection) && !lexical.$isNodeSelection(selection)) {
|
|
405
386
|
return;
|
|
406
387
|
}
|
|
388
|
+
if (lexical.$isNodeSelection(selection)) {
|
|
389
|
+
const nodes = selection.getNodes();
|
|
390
|
+
if (nodes.length === 0) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Handle all selected nodes
|
|
395
|
+
nodes.forEach(node => {
|
|
396
|
+
if (url === null) {
|
|
397
|
+
// Remove link
|
|
398
|
+
const linkParent = LexicalUtils.$findMatchingParent(node, parent => !$isAutoLinkNode(parent) && $isLinkNode(parent));
|
|
399
|
+
if (linkParent) {
|
|
400
|
+
linkParent.insertBefore(node);
|
|
401
|
+
if (linkParent.getChildren().length === 0) {
|
|
402
|
+
linkParent.remove();
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
} else {
|
|
406
|
+
// Add/Update link
|
|
407
|
+
const existingLink = LexicalUtils.$findMatchingParent(node, parent => !$isAutoLinkNode(parent) && $isLinkNode(parent));
|
|
408
|
+
if (existingLink) {
|
|
409
|
+
existingLink.setURL(url);
|
|
410
|
+
if (target !== undefined) {
|
|
411
|
+
existingLink.setTarget(target);
|
|
412
|
+
}
|
|
413
|
+
if (rel !== undefined) {
|
|
414
|
+
existingLink.setRel(rel);
|
|
415
|
+
}
|
|
416
|
+
} else {
|
|
417
|
+
const linkNode = $createLinkNode(url, {
|
|
418
|
+
rel,
|
|
419
|
+
target
|
|
420
|
+
});
|
|
421
|
+
node.insertBefore(linkNode);
|
|
422
|
+
linkNode.append(node);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Handle RangeSelection
|
|
407
430
|
const nodes = selection.extract();
|
|
408
431
|
if (url === null) {
|
|
409
432
|
// Remove LinkNodes
|
|
@@ -503,6 +526,39 @@ function $getAncestor(node, predicate) {
|
|
|
503
526
|
}
|
|
504
527
|
return predicate(parent) ? parent : null;
|
|
505
528
|
}
|
|
529
|
+
const PHONE_NUMBER_REGEX = /^\+?[0-9\s()-]{5,}$/;
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Formats a URL string by adding appropriate protocol if missing
|
|
533
|
+
*
|
|
534
|
+
* @param url - URL to format
|
|
535
|
+
* @returns Formatted URL with appropriate protocol
|
|
536
|
+
*/
|
|
537
|
+
function formatUrl(url) {
|
|
538
|
+
// Check if URL already has a protocol
|
|
539
|
+
if (url.match(/^[a-z][a-z0-9+.-]*:/i)) {
|
|
540
|
+
// URL already has a protocol, leave it as is
|
|
541
|
+
return url;
|
|
542
|
+
}
|
|
543
|
+
// Check if it's a relative path (starting with '/', '.', or '#')
|
|
544
|
+
else if (url.match(/^[/#.]/)) {
|
|
545
|
+
// Relative path, leave it as is
|
|
546
|
+
return url;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// Check for email address
|
|
550
|
+
else if (url.includes('@')) {
|
|
551
|
+
return `mailto:${url}`;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// Check for phone number
|
|
555
|
+
else if (PHONE_NUMBER_REGEX.test(url)) {
|
|
556
|
+
return `tel:${url}`;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// For everything else, return with https:// prefix
|
|
560
|
+
return `https://${url}`;
|
|
561
|
+
}
|
|
506
562
|
|
|
507
563
|
exports.$createAutoLinkNode = $createAutoLinkNode;
|
|
508
564
|
exports.$createLinkNode = $createLinkNode;
|
|
@@ -512,4 +568,5 @@ exports.$toggleLink = $toggleLink;
|
|
|
512
568
|
exports.AutoLinkNode = AutoLinkNode;
|
|
513
569
|
exports.LinkNode = LinkNode;
|
|
514
570
|
exports.TOGGLE_LINK_COMMAND = TOGGLE_LINK_COMMAND;
|
|
571
|
+
exports.formatUrl = formatUrl;
|
|
515
572
|
exports.toggleLink = toggleLink;
|
|
@@ -11,14 +11,15 @@ var lexical = require('lexical');
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const h=new Set(["http:","https:","mailto:","sms:","tel:"]);class g extends lexical.ElementNode{static getType(){return "link"}static clone(t){return new g(t.__url,{rel:t.__rel,target:t.__target,title:t.__title},t.__key)}constructor(t="",e={},r){super(r);const{target:n=null,rel:i=null,title:s=null}=e;this.__url=t,this.__target=n,this.__rel=i,this.__title=s;}createDOM(e){const r=document.createElement("a");return this.updateLinkDOM(null,r,e),LexicalUtils.addClassNamesToElement(r,e.theme.link),r}updateLinkDOM(t,r,n){if(LexicalUtils.isHTMLAnchorElement(r)){t&&t.__url===this.__url||(r.href=this.sanitizeUrl(this.__url));for(const e of ["target","rel","title"]){const n=`__${e}`,i=this[n];t&&t[n]===i||(i?r[e]=i:r.removeAttribute(e));}}}updateDOM(t,e,r){return this.updateLinkDOM(t,e,r),!1}static importDOM(){return {a:t=>({conversion:f,priority:1})}}static importJSON(t){return d().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setURL(t.url).setRel(t.rel||null).setTarget(t.target||null).setTitle(t.title||null)}sanitizeUrl(t){t=S(t);try{const e=new URL(S(t));if(!h.has(e.protocol))return "about:blank"}catch(e){return t}return t}exportJSON(){return {...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(t){const e=this.getWritable();return e.__url=t,e}getTarget(){return this.getLatest().__target}setTarget(t){const e=this.getWritable();return e.__target=t,e}getRel(){return this.getLatest().__rel}setRel(t){const e=this.getWritable();return e.__rel=t,e}getTitle(){return this.getLatest().__title}setTitle(t){const e=this.getWritable();return e.__title=t,e}insertNewAfter(t,e=!0){const r=d(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(r,e),r}canInsertTextBefore(){return !1}canInsertTextAfter(){return !1}canBeEmpty(){return !1}isInline(){return !0}extractWithChild(t,e,r){if(!lexical.$isRangeSelection(e))return !1;const n=e.anchor.getNode(),i=e.focus.getNode();return this.isParentOf(n)&&this.isParentOf(i)&&e.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function f(t){let r=null;if(LexicalUtils.isHTMLAnchorElement(t)){const e=t.textContent;(null!==e&&""!==e||t.children.length>0)&&(r=d(t.getAttribute("href")||"",{rel:t.getAttribute("rel"),target:t.getAttribute("target"),title:t.getAttribute("title")}));}return {node:r}}function d(t="",e){return lexical.$applyNodeReplacement(new g(t,e))}function p(t){return t instanceof g}class m extends g{constructor(t="",e={},r){super(t,e,r),this.__isUnlinked=void 0!==e.isUnlinked&&null!==e.isUnlinked&&e.isUnlinked;}static getType(){return "autolink"}static clone(t){return new m(t.__url,{isUnlinked:t.__isUnlinked,rel:t.__rel,target:t.__target,title:t.__title},t.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(t){const e=this.getWritable();return e.__isUnlinked=t,e}createDOM(t){return this.__isUnlinked?document.createElement("span"):super.createDOM(t)}updateDOM(t,e,r){return super.updateDOM(t,e,r)||t.__isUnlinked!==this.__isUnlinked}static importJSON(t){return U().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setIsUnlinked(t.isUnlinked||!1)}static importDOM(){return null}exportJSON(){return {...super.exportJSON(),isUnlinked:this.__isUnlinked}}insertNewAfter(t,e=!0){const r=this.getParentOrThrow().insertNewAfter(t,e);if(lexical.$isElementNode(r)){const t=U(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return r.append(t),t}return null}}function U(t="",e){return lexical.$applyNodeReplacement(new m(t,e))}function O(t){return t instanceof m}const k=lexical.createCommand("TOGGLE_LINK_COMMAND");function N(t,e){if("element"===t.type){const r=t.getNode();lexical.$isElementNode(r)||function(t,...e){const r=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",t);for(const t of e)n.append("v",t);throw r.search=n.toString(),Error(`Minified Lexical error #${t}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(252);return r.getChildren()[t.offset+e]||null}return null}function v(t,e={}){const{target:n,title:i}=e,l=void 0===e.rel?"noreferrer":e.rel,h=lexical.$getSelection();if(null===h||!lexical.$isRangeSelection(h)&&!lexical.$isNodeSelection(h))return;if(lexical.$isNodeSelection(h)){const e=h.getNodes();if(0===e.length)return;return void e.forEach((e=>{if(null===t){const t=LexicalUtils.$findMatchingParent(e,(t=>!O(t)&&p(t)));t&&(t.insertBefore(e),0===t.getChildren().length&&t.remove());}else {const i=LexicalUtils.$findMatchingParent(e,(t=>!O(t)&&p(t)));if(i)i.setURL(t),void 0!==n&&i.setTarget(n),void 0!==l&&i.setRel(l);else {const r=d(t,{rel:l,target:n});e.insertBefore(r),r.append(e);}}}))}const g=h.extract();if(null===t)return void g.forEach((t=>{const e=LexicalUtils.$findMatchingParent(t,(t=>!O(t)&&p(t)));if(e){const t=e.getChildren();for(let r=0;r<t.length;r++)e.insertBefore(t[r]);e.remove();}}));const f=new Set,m=e=>{f.has(e.getKey())||(f.add(e.getKey()),e.setURL(t),void 0!==n&&e.setTarget(n),void 0!==l&&e.setRel(l),void 0!==i&&e.setTitle(i));};if(1===g.length){const t=x(g[0],p);if(null!==t)return m(t)}!function(t){const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e))return t();const r=lexical.$normalizeSelection__EXPERIMENTAL(e),n=r.isBackward(),i=N(r.anchor,n?-1:0),l=N(r.focus,n?0:-1);t();if(i||l){const t=lexical.$getSelection();if(lexical.$isRangeSelection(t)){const e=t.clone();if(i){const t=i.getParent();t&&e.anchor.set(t.getKey(),i.getIndexWithinParent()+(n?1:0),"element");}if(l){const t=l.getParent();t&&e.focus.set(t.getKey(),l.getIndexWithinParent()+(n?0:1),"element");}lexical.$setSelection(lexical.$normalizeSelection__EXPERIMENTAL(e));}}}((()=>{let e=null;for(const r of g){if(!r.isAttached())continue;const s=x(r,p);if(s){m(s);continue}if(lexical.$isElementNode(r)){if(!r.isInline())continue;if(p(r)){if(!(O(r)||null!==e&&e.getParentOrThrow().isParentOf(r))){m(r),e=r;continue}for(const t of r.getChildren())r.insertBefore(t);r.remove();continue}}const u=r.getPreviousSibling();p(u)&&u.is(e)?u.append(r):(e=d(t,{rel:l,target:n,title:i}),r.insertAfter(e),e.append(r));}}));}const T=v;function x(t,e){let r=t;for(;null!==r&&null!==r.getParent()&&!e(r);)r=r.getParentOrThrow();return e(r)?r:null}const L=/^\+?[0-9\s()-]{5,}$/;function S(t){return t.match(/^[a-z][a-z0-9+.-]*:/i)||t.match(/^[/#.]/)?t:t.includes("@")?`mailto:${t}`:L.test(t)?`tel:${t}`:`https://${t}`}
|
|
15
15
|
|
|
16
|
-
exports.$createAutoLinkNode =
|
|
17
|
-
exports.$createLinkNode =
|
|
18
|
-
exports.$isAutoLinkNode =
|
|
19
|
-
exports.$isLinkNode =
|
|
20
|
-
exports.$toggleLink =
|
|
21
|
-
exports.AutoLinkNode =
|
|
22
|
-
exports.LinkNode =
|
|
23
|
-
exports.TOGGLE_LINK_COMMAND =
|
|
24
|
-
exports.
|
|
16
|
+
exports.$createAutoLinkNode = U;
|
|
17
|
+
exports.$createLinkNode = d;
|
|
18
|
+
exports.$isAutoLinkNode = O;
|
|
19
|
+
exports.$isLinkNode = p;
|
|
20
|
+
exports.$toggleLink = v;
|
|
21
|
+
exports.AutoLinkNode = m;
|
|
22
|
+
exports.LinkNode = g;
|
|
23
|
+
exports.TOGGLE_LINK_COMMAND = k;
|
|
24
|
+
exports.formatUrl = S;
|
|
25
|
+
exports.toggleLink = T;
|