@lexical/markdown 0.31.3-nightly.20250522.0 → 0.31.3-nightly.20250523.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.
- package/LexicalMarkdown.dev.js +1 -35
- package/LexicalMarkdown.dev.mjs +1 -35
- package/LexicalMarkdown.prod.js +1 -1
- package/LexicalMarkdown.prod.mjs +1 -1
- package/package.json +8 -8
- package/utils.d.ts +0 -8
package/LexicalMarkdown.dev.js
CHANGED
|
@@ -56,39 +56,6 @@ function isEmptyParagraph(node) {
|
|
|
56
56
|
const firstChild = node.getFirstChild();
|
|
57
57
|
return firstChild == null || node.getChildrenSize() === 1 && lexical.$isTextNode(firstChild) && MARKDOWN_EMPTY_LINE_REG_EXP.test(firstChild.getTextContent());
|
|
58
58
|
}
|
|
59
|
-
const PHONE_NUMBER_REGEX = /^\+?[0-9\s()-]{5,}$/;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Formats a URL string by adding appropriate protocol if missing
|
|
63
|
-
*
|
|
64
|
-
* @param url - URL to format
|
|
65
|
-
* @returns Formatted URL with appropriate protocol
|
|
66
|
-
*/
|
|
67
|
-
function formatUrl(url) {
|
|
68
|
-
// Check if URL already has a protocol
|
|
69
|
-
if (url.match(/^[a-z][a-z0-9+.-]*:/i)) {
|
|
70
|
-
// URL already has a protocol, leave it as is
|
|
71
|
-
return url;
|
|
72
|
-
}
|
|
73
|
-
// Check if it's a relative path (starting with '/', '.', or '#')
|
|
74
|
-
else if (url.match(/^[/#.]/)) {
|
|
75
|
-
// Relative path, leave it as is
|
|
76
|
-
return url;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Check for email address
|
|
80
|
-
else if (url.includes('@')) {
|
|
81
|
-
return `mailto:${url}`;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Check for phone number
|
|
85
|
-
else if (PHONE_NUMBER_REGEX.test(url)) {
|
|
86
|
-
return `tel:${url}`;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// For everything else, return with https:// prefix
|
|
90
|
-
return `https://${url}`;
|
|
91
|
-
}
|
|
92
59
|
|
|
93
60
|
/**
|
|
94
61
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -1369,8 +1336,7 @@ const LINK = {
|
|
|
1369
1336
|
regExp: /(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,
|
|
1370
1337
|
replace: (textNode, match) => {
|
|
1371
1338
|
const [, linkText, linkUrl, linkTitle] = match;
|
|
1372
|
-
const
|
|
1373
|
-
const linkNode = link.$createLinkNode(formattedUrl, {
|
|
1339
|
+
const linkNode = link.$createLinkNode(linkUrl, {
|
|
1374
1340
|
title: linkTitle
|
|
1375
1341
|
});
|
|
1376
1342
|
const linkTextNode = lexical.$createTextNode(linkText);
|
package/LexicalMarkdown.dev.mjs
CHANGED
|
@@ -54,39 +54,6 @@ function isEmptyParagraph(node) {
|
|
|
54
54
|
const firstChild = node.getFirstChild();
|
|
55
55
|
return firstChild == null || node.getChildrenSize() === 1 && $isTextNode(firstChild) && MARKDOWN_EMPTY_LINE_REG_EXP.test(firstChild.getTextContent());
|
|
56
56
|
}
|
|
57
|
-
const PHONE_NUMBER_REGEX = /^\+?[0-9\s()-]{5,}$/;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Formats a URL string by adding appropriate protocol if missing
|
|
61
|
-
*
|
|
62
|
-
* @param url - URL to format
|
|
63
|
-
* @returns Formatted URL with appropriate protocol
|
|
64
|
-
*/
|
|
65
|
-
function formatUrl(url) {
|
|
66
|
-
// Check if URL already has a protocol
|
|
67
|
-
if (url.match(/^[a-z][a-z0-9+.-]*:/i)) {
|
|
68
|
-
// URL already has a protocol, leave it as is
|
|
69
|
-
return url;
|
|
70
|
-
}
|
|
71
|
-
// Check if it's a relative path (starting with '/', '.', or '#')
|
|
72
|
-
else if (url.match(/^[/#.]/)) {
|
|
73
|
-
// Relative path, leave it as is
|
|
74
|
-
return url;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Check for email address
|
|
78
|
-
else if (url.includes('@')) {
|
|
79
|
-
return `mailto:${url}`;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Check for phone number
|
|
83
|
-
else if (PHONE_NUMBER_REGEX.test(url)) {
|
|
84
|
-
return `tel:${url}`;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// For everything else, return with https:// prefix
|
|
88
|
-
return `https://${url}`;
|
|
89
|
-
}
|
|
90
57
|
|
|
91
58
|
/**
|
|
92
59
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -1367,8 +1334,7 @@ const LINK = {
|
|
|
1367
1334
|
regExp: /(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,
|
|
1368
1335
|
replace: (textNode, match) => {
|
|
1369
1336
|
const [, linkText, linkUrl, linkTitle] = match;
|
|
1370
|
-
const
|
|
1371
|
-
const linkNode = $createLinkNode(formattedUrl, {
|
|
1337
|
+
const linkNode = $createLinkNode(linkUrl, {
|
|
1372
1338
|
title: linkTitle
|
|
1373
1339
|
});
|
|
1374
1340
|
const linkTextNode = $createTextNode(linkText);
|
package/LexicalMarkdown.prod.js
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("lexical"),t=require("@lexical/list"),n=require("@lexical/rich-text"),o=require("@lexical/utils"),r=require("@lexical/code"),i=require("@lexical/link");function s(e,t){const n={};for(const o of e){const e=t(o);e&&(n[e]?n[e].push(o):n[e]=[o])}return n}function c(e){const t=s(e,(e=>e.type));return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}const l=/[!-/:-@[-`{-~\s]/,a=/^\s{0,3}$/;function f(t){if(!e.$isParagraphNode(t))return!1;const n=t.getFirstChild();return null==n||1===t.getChildrenSize()&&e.$isTextNode(n)&&a.test(n.getTextContent())}const d=/^\+?[0-9\s()-]{5,}$/;function u(t,n,o,r){for(const e of n){if(!e.export)continue;const n=e.export(t,(e=>g(e,o,r)));if(null!=n)return n}return e.$isElementNode(t)?g(t,o,r):e.$isDecoratorNode(t)?t.getTextContent():null}function g(t,n,o,r,i){const s=[],c=t.getChildren();r||(r=[]),i||(i=[]);e:for(const t of c){for(const e of o){if(!e.export)continue;const c=e.export(t,(e=>g(e,n,o,r,[...i,...r])),((e,t)=>p(e,t,n,r,i)));if(null!=c){s.push(c);continue e}}e.$isLineBreakNode(t)?s.push("\n"):e.$isTextNode(t)?s.push(p(t,t.getTextContent(),n,r,i)):e.$isElementNode(t)?s.push(g(t,n,o,r,i)):e.$isDecoratorNode(t)&&s.push(t.getTextContent())}return s.join("")}function p(e,t,n,o,r){let i=0===e.getFormat()?t:function(e){return e.replace(/^\s+|\s+$/g,(e=>[...e].map((e=>"&#"+e.codePointAt(0)+";")).join("")))}(t);e.hasFormat("code")||(i=i.replace(/([*_`~\\])/g,"\\$1"));let s="",c="",l="";const a=x(e,!0),f=x(e,!1),d=new Set;for(const t of n){const n=t.format[0],r=t.tag;h(e,n)&&!d.has(n)&&(d.add(n),h(a,n)&&o.find((e=>e.tag===r))||(o.push({format:n,tag:r}),s+=r))}for(let t=0;t<o.length;t++){const n=h(e,o[t].format),i=h(f,o[t].format);if(n&&i)continue;const s=[...o];for(;s.length>t;){const e=s.pop();r&&e&&r.find((t=>t.tag===e.tag))||(e&&"string"==typeof e.tag&&(n?i||(l+=e.tag):c+=e.tag),o.pop())}break}return i=s+i+l,c+i}function x(t,n){let o=n?t.getPreviousSibling():t.getNextSibling();if(!o){const e=t.getParentOrThrow();e.isInline()&&(o=n?e.getPreviousSibling():e.getNextSibling())}for(;o;){if(e.$isElementNode(o)){if(!o.isInline())break;const t=n?o.getLastDescendant():o.getFirstDescendant();if(e.$isTextNode(t))return t;o=n?o.getPreviousSibling():o.getNextSibling()}if(e.$isTextNode(o))return o;if(!e.$isElementNode(o))return null}return null}function h(t,n){return e.$isTextNode(t)&&t.hasFormat(n)}function m(e,t){const n=function(e,t){const n=e.match(t.openTagsRegExp);if(null==n)return null;for(const o of n){const n=o.replace(/^\s/,""),r=t.fullMatchRegExpByTag[n];if(null==r)continue;const i=e.match(r),s=t.transformersByTag[n];if(null!=i&&null!=s){if(!1!==s.intraword)return i;const{index:t=0}=i,n=e[t-1],o=e[t+i[0].length];if((!n||l.test(n))&&(!o||l.test(o)))return i}}return null}(e.getTextContent(),t);if(!n)return null;const o=n.index||0;return{endIndex:o+n[0].length,match:n,startIndex:o,transformer:t.transformersByTag[n[1]]}}function $(t){return e.$isTextNode(t)&&!t.hasFormat("code")}function N(e,t,n){let o=m(e,t),r=function(e,t){const n=e;let o,r,i,s;for(const e of t){if(!e.replace||!e.importRegExp)continue;const t=n.getTextContent().match(e.importRegExp);if(!t)continue;const c=t.index||0,l=e.getEndIndex?e.getEndIndex(n,t):c+t[0].length;!1!==l&&(void 0===o||void 0===r||c<o&&l>r)&&(o=c,r=l,i=e,s=t)}return void 0===o||void 0===r||void 0===i||void 0===s?null:{endIndex:r,match:s,startIndex:o,transformer:i}}(e,n);if(o&&r&&(o.startIndex<=r.startIndex&&o.endIndex>=r.endIndex?r=null:o=null),o){const r=function(e,t,n,o,r){const i=e.getTextContent();let s,c,l;if(r[0]===i?s=e:0===t?[s,c]=e.splitText(n):[l,s,c]=e.splitText(t,n),s.setTextContent(r[2]),o)for(const e of o.format)s.hasFormat(e)||s.toggleFormat(e);return{nodeAfter:c,nodeBefore:l,transformedNode:s}}(e,o.startIndex,o.endIndex,o.transformer,o.match);$(r.nodeAfter)&&N(r.nodeAfter,t,n),$(r.nodeBefore)&&N(r.nodeBefore,t,n),$(r.transformedNode)&&N(r.transformedNode,t,n)}else if(r){const o=function(e,t,n,o,r){let i,s,c;return 0===t?[i,s]=e.splitText(n):[c,i,s]=e.splitText(t,n),o.replace?{nodeAfter:s,nodeBefore:c,transformedNode:o.replace(i,r)||void 0}:null}(e,r.startIndex,r.endIndex,r.transformer,r.match);if(!o)return;$(o.nodeAfter)&&N(o.nodeAfter,t,n),$(o.nodeBefore)&&N(o.nodeBefore,t,n),$(o.transformedNode)&&N(o.transformedNode,t,n)}const i=e.getTextContent().replace(/\\([*_`~\\])/g,"$1").replace(/&#(\d+);/g,((e,t)=>String.fromCodePoint(t)));e.setTextContent(i)}function T(t,n=!1){const o=c(t),r=function(e){const t={},n={},o=[],r="(?<![\\\\])";for(const r of e){const{tag:e}=r;t[e]=r;const i=e.replace(/(\*|\^|\+)/g,"\\$1");o.push(i),1===e.length?n[e]=new RegExp(`(?<![\\\\${i}])(${i})((\\\\${i})?.*?[^${i}\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?![\\\\${i}])`):n[e]=new RegExp(`(?<!\\\\)(${i})((\\\\${i})?.*?[^\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?!\\\\)`)}return{fullMatchRegExpByTag:n,openTagsRegExp:new RegExp(`${r}(${o.join("|")})`,"g"),transformersByTag:t}}(o.textFormat);return(t,i)=>{const s=t.split("\n"),c=s.length,l=i||e.$getRoot();l.clear();for(let e=0;e<c;e++){const t=s[e],[i,c]=E(s,e,o.multilineElement,l);i?e=c:S(t,l,o.element,r,o.textMatch,n)}const a=l.getChildren();for(const e of a)!n&&f(e)&&l.getChildrenSize()>1&&e.remove();null!==e.$getSelection()&&l.selectStart()}}function E(e,t,n,o){for(const r of n){const{handleImportAfterStartMatch:n,regExpEnd:i,regExpStart:s,replace:c}=r,l=e[t].match(s);if(!l)continue;if(n){const i=n({lines:e,rootNode:o,startLineIndex:t,startMatch:l,transformer:r});if(null===i)continue;if(i)return i}const a="object"==typeof i&&"regExp"in i?i.regExp:i,f=i&&"object"==typeof i&&"optional"in i?i.optional:!i;let d=t;const u=e.length;for(;d<u;){const n=a?e[d].match(a):null;if(!n&&(!f||f&&d<u-1)){d++;continue}if(n&&t===d&&n.index===l.index){d++;continue}const r=[];if(n&&t===d)r.push(e[t].slice(l[0].length,-n[0].length));else for(let o=t;o<=d;o++)if(o===t){const t=e[o].slice(l[0].length);r.push(t)}else if(o===d&&n){const t=e[o].slice(0,-n[0].length);r.push(t)}else r.push(e[o]);if(!1!==c(o,null,l,n,r,!0))return[!0,d];break}}return[!1,t]}function S(r,i,s,c,l,a){const f=e.$createTextNode(r),d=e.$createParagraphNode();d.append(f),i.append(d);for(const{regExp:e,replace:t}of s){const n=r.match(e);if(n&&(f.setTextContent(r.slice(n[0].length)),!1!==t(d,[f],n,!0)))break}if(N(f,c,l),d.isAttached()&&r.length>0){const r=d.getPreviousSibling();if(!a&&(e.$isParagraphNode(r)||n.$isQuoteNode(r)||t.$isListNode(r))){let n=r;if(t.$isListNode(r)){const e=r.getLastDescendant();n=null==e?null:o.$findMatchingParent(e,t.$isListItemNode)}null!=n&&n.getTextContentSize()>0&&(n.splice(n.getChildrenSize(),0,[e.$createLineBreakNode(),...d.getChildren()]),d.remove())}}}function C(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function L(e,t,n){const o=n.length;for(let r=t;r>=o;r--){const t=r-o;if(R(e,t,n,0,o)&&" "!==e[t+o])return t}return-1}function R(e,t,n,o,r){for(let i=0;i<r;i++)if(e[t+i]!==n[o+i])return!1;return!0}const I=/^(\s*)(\d{1,})\.\s/,v=/^(\s*)[-*+]\s/,y=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,_=/^(#{1,6})\s/,b=/^>\s/,A=/^[ \t]*```(\w+)?/,F=/[ \t]*```$/,O=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,k=/^(?:\|)(.+)(?:\|)\s?$/,M=/^(\| ?:?-*:? ?)+\|\s?$/,w=e=>(t,n,o)=>{const r=e(o);r.append(...n),t.replace(r),r.select(0,0)};const B=e=>(n,o,r)=>{const i=n.getPreviousSibling(),s=n.getNextSibling(),c=t.$createListItemNode("check"===e?"x"===r[3]:void 0);if(t.$isListNode(s)&&s.getListType()===e){const e=s.getFirstChild();null!==e?e.insertBefore(c):s.append(c),n.remove()}else if(t.$isListNode(i)&&i.getListType()===e)i.append(c),n.remove();else{const o=t.$createListNode(e,"number"===e?Number(r[2]):void 0);o.append(c),n.replace(o)}c.append(...o),c.select(0,0);const l=function(e){const t=e.match(/\t/g),n=e.match(/ /g);let o=0;return t&&(o+=t.length),n&&(o+=Math.floor(n.length/4)),o}(r[1]);l&&c.setIndent(l)},D=(e,n,o)=>{const r=[],i=e.getChildren();let s=0;for(const c of i)if(t.$isListItemNode(c)){if(1===c.getChildrenSize()){const e=c.getFirstChild();if(t.$isListNode(e)){r.push(D(e,n,o+1));continue}}const i=" ".repeat(4*o),l=e.getListType(),a="number"===l?`${e.getStart()+s}. `:"check"===l?`- [${c.getChecked()?"x":" "}] `:"- ";r.push(i+a+n(c)),s++}return r.join("\n")},P={dependencies:[n.HeadingNode],export:(e,t)=>{if(!n.$isHeadingNode(e))return null;const o=Number(e.getTag().slice(1));return"#".repeat(o)+" "+t(e)},regExp:_,replace:w((e=>{const t="h"+e[1].length;return n.$createHeadingNode(t)})),type:"element"},H={dependencies:[n.QuoteNode],export:(e,t)=>{if(!n.$isQuoteNode(e))return null;const o=t(e).split("\n"),r=[];for(const e of o)r.push("> "+e);return r.join("\n")},regExp:b,replace:(t,o,r,i)=>{if(i){const r=t.getPreviousSibling();if(n.$isQuoteNode(r))return r.splice(r.getChildrenSize(),0,[e.$createLineBreakNode(),...o]),r.select(0,0),void t.remove()}const s=n.$createQuoteNode();s.append(...o),t.replace(s),s.select(0,0)},type:"element"},U={dependencies:[r.CodeNode],export:e=>{if(!r.$isCodeNode(e))return null;const t=e.getTextContent();return"```"+(e.getLanguage()||"")+(t?"\n"+t:"")+"\n```"},regExpEnd:{optional:!0,regExp:F},regExpStart:A,replace:(t,n,o,i,s,c)=>{let l,a;if(!n&&s){if(1===s.length)i?(l=r.$createCodeNode(),a=o[1]+s[0]):(l=r.$createCodeNode(o[1]),a=s[0].startsWith(" ")?s[0].slice(1):s[0]);else{if(l=r.$createCodeNode(o[1]),0===s[0].trim().length)for(;s.length>0&&!s[0].length;)s.shift();else s[0]=s[0].startsWith(" ")?s[0].slice(1):s[0];for(;s.length>0&&!s[s.length-1].length;)s.pop();a=s.join("\n")}const n=e.$createTextNode(a);l.append(n),t.append(l)}else n&&w((e=>r.$createCodeNode(e?e[1]:void 0)))(t,n,o,c)},type:"multiline-element"},j={dependencies:[t.ListNode,t.ListItemNode],export:(e,n)=>t.$isListNode(e)?D(e,n,0):null,regExp:v,replace:B("bullet"),type:"element"},z={dependencies:[t.ListNode,t.ListItemNode],export:(e,n)=>t.$isListNode(e)?D(e,n,0):null,regExp:y,replace:B("check"),type:"element"},q={dependencies:[t.ListNode,t.ListItemNode],export:(e,n)=>t.$isListNode(e)?D(e,n,0):null,regExp:I,replace:B("number"),type:"element"},G={format:["code"],tag:"`",type:"text-format"},Q={format:["highlight"],tag:"==",type:"text-format"},W={format:["bold","italic"],tag:"***",type:"text-format"},K={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},X={format:["bold"],tag:"**",type:"text-format"},J={format:["bold"],intraword:!1,tag:"__",type:"text-format"},V={format:["strikethrough"],tag:"~~",type:"text-format"},Y={format:["italic"],tag:"*",type:"text-format"},Z={format:["italic"],intraword:!1,tag:"_",type:"text-format"},ee={dependencies:[i.LinkNode],export:(e,t,n)=>{if(!i.$isLinkNode(e)||i.$isAutoLinkNode(e))return null;const o=e.getTitle(),r=t(e);return o?`[${r}](${e.getURL()} "${o}")`:`[${r}](${e.getURL()})`},importRegExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,n)=>{const[,o,r,s]=n,c=(l=r).match(/^[a-z][a-z0-9+.-]*:/i)||l.match(/^[/#.]/)?l:l.includes("@")?`mailto:${l}`:d.test(l)?`tel:${l}`:`https://${l}`;var l;const a=i.$createLinkNode(c,{title:s}),f=e.$createTextNode(o);return f.setFormat(t.getFormat()),a.append(f),t.replace(a),f},trigger:")",type:"text-match"};const te=[P,H,j,q],ne=[U],oe=[G,W,K,X,J,Q,Y,Z,V],re=[ee],ie=[...te,...ne,...oe,...re];exports.$convertFromMarkdownString=function(e,t=ie,n,o=!1,r=!1){const i=o?e:function(e,t=!1){const n=e.split("\n");let o=!1;const r=[];for(let e=0;e<n.length;e++){const i=n[e],s=r[r.length-1];O.test(i)?r.push(i):A.test(i)||F.test(i)?(o=!o,r.push(i)):o||""===i||""===s||!s||_.test(s)||_.test(i)||b.test(i)||I.test(i)||v.test(i)||y.test(i)||k.test(i)||M.test(i)||!t?r.push(i):r[r.length-1]=s+i}return r.join("\n")}(e,r);return T(t,o)(i,n)},exports.$convertToMarkdownString=function(t=ie,n,o=!1){return function(t,n=!1){const o=c(t),r=[...o.multilineElement,...o.element],i=!n,s=o.textFormat.filter((e=>1===e.format.length)).sort(((e,t)=>Number(e.format.includes("code"))-Number(t.format.includes("code"))));return t=>{const n=[],c=(t||e.$getRoot()).getChildren();for(let e=0;e<c.length;e++){const t=c[e],l=u(t,r,s,o.textMatch);null!=l&&n.push(i&&e>0&&!f(t)&&!f(c[e-1])?"\n".concat(l):l)}return n.join("\n")}}(t,o)(n)},exports.BOLD_ITALIC_STAR=W,exports.BOLD_ITALIC_UNDERSCORE=K,exports.BOLD_STAR=X,exports.BOLD_UNDERSCORE=J,exports.CHECK_LIST=z,exports.CODE=U,exports.ELEMENT_TRANSFORMERS=te,exports.HEADING=P,exports.HIGHLIGHT=Q,exports.INLINE_CODE=G,exports.ITALIC_STAR=Y,exports.ITALIC_UNDERSCORE=Z,exports.LINK=ee,exports.MULTILINE_ELEMENT_TRANSFORMERS=ne,exports.ORDERED_LIST=q,exports.QUOTE=H,exports.STRIKETHROUGH=V,exports.TEXT_FORMAT_TRANSFORMERS=oe,exports.TEXT_MATCH_TRANSFORMERS=re,exports.TRANSFORMERS=ie,exports.UNORDERED_LIST=j,exports.registerMarkdownShortcuts=function(t,n=ie){const o=c(n),i=s(o.textFormat,(({tag:e})=>e[e.length-1])),a=s(o.textMatch,(({trigger:e})=>e));for(const e of n){const n=e.type;if("element"===n||"text-match"===n||"multiline-element"===n){const n=e.dependencies;for(const e of n)t.hasNode(e)||C(173,e.getType())}}const f=(t,n,r)=>{(function(t,n,o,r){const i=t.getParent();if(!e.$isRootOrShadowRoot(i)||t.getFirstChild()!==n)return!1;const s=n.getTextContent();if(" "!==s[o-1])return!1;for(const{regExp:e,replace:i}of r){const r=s.match(e);if(r&&r[0].length===(r[0].endsWith(" ")?o:o-1)){const e=n.getNextSiblings(),[s,c]=n.splitText(o);if(s.remove(),!1!==i(t,c?[c,...e]:e,r,!1))return!0}}return!1})(t,n,r,o.element)||function(t,n,o,r){const i=t.getParent();if(!e.$isRootOrShadowRoot(i)||t.getFirstChild()!==n)return!1;const s=n.getTextContent();if(" "!==s[o-1])return!1;for(const{regExpStart:e,replace:i,regExpEnd:c}of r){if(c&&!("optional"in c)||c&&"optional"in c&&!c.optional)continue;const r=s.match(e);if(r&&r[0].length===(r[0].endsWith(" ")?o:o-1)){const e=n.getNextSiblings(),[s,c]=n.splitText(o);if(s.remove(),!1!==i(t,c?[c,...e]:e,r,null,null,!1))return!0}}return!1}(t,n,r,o.multilineElement)||function(e,t,n){let o=e.getTextContent();const r=n[o[t-1]];if(null==r)return!1;t<o.length&&(o=o.slice(0,t));for(const t of r){if(!t.replace||!t.regExp)continue;const n=o.match(t.regExp);if(null===n)continue;const r=n.index||0,i=r+n[0].length;let s;return 0===r?[s]=e.splitText(i):[,s]=e.splitText(r,i),s.selectNext(0,0),t.replace(s,n),!0}return!1}(n,r,a)||function(t,n,o){const r=t.getTextContent(),i=n-1,s=r[i],c=o[s];if(!c)return!1;for(const n of c){const{tag:o}=n,c=o.length,a=i-c+1;if(c>1&&!R(r,a,o,0,c))continue;if(" "===r[a-1])continue;const f=r[i+1];if(!1===n.intraword&&f&&!l.test(f))continue;const d=t;let u=d,g=L(r,a,o),p=u;for(;g<0&&(p=p.getPreviousSibling())&&!e.$isLineBreakNode(p);)if(e.$isTextNode(p)){if(p.hasFormat("code"))continue;const e=p.getTextContent();u=p,g=L(e,e.length,o)}if(g<0)continue;if(u===d&&g+c===a)continue;const x=u.getTextContent();if(g>0&&x[g-1]===s)continue;const h=x[g-1];if(!1===n.intraword&&h&&!l.test(h))continue;const m=d.getTextContent(),$=m.slice(0,a)+m.slice(i+1);d.setTextContent($);const N=u===d?$:x;u.setTextContent(N.slice(0,g)+N.slice(g+c));const T=e.$getSelection(),E=e.$createRangeSelection();e.$setSelection(E);const S=i-c*(u===d?2:1)+1;E.anchor.set(u.__key,g,"text"),E.focus.set(d.__key,S,"text");for(const e of n.format)E.hasFormat(e)||E.formatText(e);E.anchor.set(E.focus.key,E.focus.offset,E.focus.type);for(const e of n.format)E.hasFormat(e)&&E.toggleFormat(e);return e.$isRangeSelection(T)&&(E.format=T.format),!0}}(n,r,i)};return t.registerUpdateListener((({tags:n,dirtyLeaves:o,editorState:i,prevEditorState:s})=>{if(n.has(e.COLLABORATION_TAG)||n.has(e.HISTORIC_TAG))return;if(t.isComposing())return;const c=i.read(e.$getSelection),l=s.read(e.$getSelection);if(!e.$isRangeSelection(l)||!e.$isRangeSelection(c)||!c.isCollapsed()||c.is(l))return;const a=c.anchor.key,d=c.anchor.offset,u=i._nodeMap.get(a);!e.$isTextNode(u)||!o.has(a)||1!==d&&d>l.anchor.offset+1||t.update((()=>{if(!$(u))return;const e=u.getParent();null===e||r.$isCodeNode(e)||f(e,u,c.anchor.offset)}))}))};
|
|
9
|
+
"use strict";var e=require("lexical"),t=require("@lexical/list"),n=require("@lexical/rich-text"),o=require("@lexical/utils"),r=require("@lexical/code"),i=require("@lexical/link");function s(e,t){const n={};for(const o of e){const e=t(o);e&&(n[e]?n[e].push(o):n[e]=[o])}return n}function c(e){const t=s(e,(e=>e.type));return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}const l=/[!-/:-@[-`{-~\s]/,a=/^\s{0,3}$/;function f(t){if(!e.$isParagraphNode(t))return!1;const n=t.getFirstChild();return null==n||1===t.getChildrenSize()&&e.$isTextNode(n)&&a.test(n.getTextContent())}function d(t,n,o,r){for(const e of n){if(!e.export)continue;const n=e.export(t,(e=>u(e,o,r)));if(null!=n)return n}return e.$isElementNode(t)?u(t,o,r):e.$isDecoratorNode(t)?t.getTextContent():null}function u(t,n,o,r,i){const s=[],c=t.getChildren();r||(r=[]),i||(i=[]);e:for(const t of c){for(const e of o){if(!e.export)continue;const c=e.export(t,(e=>u(e,n,o,r,[...i,...r])),((e,t)=>g(e,t,n,r,i)));if(null!=c){s.push(c);continue e}}e.$isLineBreakNode(t)?s.push("\n"):e.$isTextNode(t)?s.push(g(t,t.getTextContent(),n,r,i)):e.$isElementNode(t)?s.push(u(t,n,o,r,i)):e.$isDecoratorNode(t)&&s.push(t.getTextContent())}return s.join("")}function g(e,t,n,o,r){let i=0===e.getFormat()?t:function(e){return e.replace(/^\s+|\s+$/g,(e=>[...e].map((e=>"&#"+e.codePointAt(0)+";")).join("")))}(t);e.hasFormat("code")||(i=i.replace(/([*_`~\\])/g,"\\$1"));let s="",c="",l="";const a=p(e,!0),f=p(e,!1),d=new Set;for(const t of n){const n=t.format[0],r=t.tag;x(e,n)&&!d.has(n)&&(d.add(n),x(a,n)&&o.find((e=>e.tag===r))||(o.push({format:n,tag:r}),s+=r))}for(let t=0;t<o.length;t++){const n=x(e,o[t].format),i=x(f,o[t].format);if(n&&i)continue;const s=[...o];for(;s.length>t;){const e=s.pop();r&&e&&r.find((t=>t.tag===e.tag))||(e&&"string"==typeof e.tag&&(n?i||(l+=e.tag):c+=e.tag),o.pop())}break}return i=s+i+l,c+i}function p(t,n){let o=n?t.getPreviousSibling():t.getNextSibling();if(!o){const e=t.getParentOrThrow();e.isInline()&&(o=n?e.getPreviousSibling():e.getNextSibling())}for(;o;){if(e.$isElementNode(o)){if(!o.isInline())break;const t=n?o.getLastDescendant():o.getFirstDescendant();if(e.$isTextNode(t))return t;o=n?o.getPreviousSibling():o.getNextSibling()}if(e.$isTextNode(o))return o;if(!e.$isElementNode(o))return null}return null}function x(t,n){return e.$isTextNode(t)&&t.hasFormat(n)}function h(e,t){const n=function(e,t){const n=e.match(t.openTagsRegExp);if(null==n)return null;for(const o of n){const n=o.replace(/^\s/,""),r=t.fullMatchRegExpByTag[n];if(null==r)continue;const i=e.match(r),s=t.transformersByTag[n];if(null!=i&&null!=s){if(!1!==s.intraword)return i;const{index:t=0}=i,n=e[t-1],o=e[t+i[0].length];if((!n||l.test(n))&&(!o||l.test(o)))return i}}return null}(e.getTextContent(),t);if(!n)return null;const o=n.index||0;return{endIndex:o+n[0].length,match:n,startIndex:o,transformer:t.transformersByTag[n[1]]}}function m(t){return e.$isTextNode(t)&&!t.hasFormat("code")}function $(e,t,n){let o=h(e,t),r=function(e,t){const n=e;let o,r,i,s;for(const e of t){if(!e.replace||!e.importRegExp)continue;const t=n.getTextContent().match(e.importRegExp);if(!t)continue;const c=t.index||0,l=e.getEndIndex?e.getEndIndex(n,t):c+t[0].length;!1!==l&&(void 0===o||void 0===r||c<o&&l>r)&&(o=c,r=l,i=e,s=t)}return void 0===o||void 0===r||void 0===i||void 0===s?null:{endIndex:r,match:s,startIndex:o,transformer:i}}(e,n);if(o&&r&&(o.startIndex<=r.startIndex&&o.endIndex>=r.endIndex?r=null:o=null),o){const r=function(e,t,n,o,r){const i=e.getTextContent();let s,c,l;if(r[0]===i?s=e:0===t?[s,c]=e.splitText(n):[l,s,c]=e.splitText(t,n),s.setTextContent(r[2]),o)for(const e of o.format)s.hasFormat(e)||s.toggleFormat(e);return{nodeAfter:c,nodeBefore:l,transformedNode:s}}(e,o.startIndex,o.endIndex,o.transformer,o.match);m(r.nodeAfter)&&$(r.nodeAfter,t,n),m(r.nodeBefore)&&$(r.nodeBefore,t,n),m(r.transformedNode)&&$(r.transformedNode,t,n)}else if(r){const o=function(e,t,n,o,r){let i,s,c;return 0===t?[i,s]=e.splitText(n):[c,i,s]=e.splitText(t,n),o.replace?{nodeAfter:s,nodeBefore:c,transformedNode:o.replace(i,r)||void 0}:null}(e,r.startIndex,r.endIndex,r.transformer,r.match);if(!o)return;m(o.nodeAfter)&&$(o.nodeAfter,t,n),m(o.nodeBefore)&&$(o.nodeBefore,t,n),m(o.transformedNode)&&$(o.transformedNode,t,n)}const i=e.getTextContent().replace(/\\([*_`~\\])/g,"$1").replace(/&#(\d+);/g,((e,t)=>String.fromCodePoint(t)));e.setTextContent(i)}function N(t,n=!1){const o=c(t),r=function(e){const t={},n={},o=[],r="(?<![\\\\])";for(const r of e){const{tag:e}=r;t[e]=r;const i=e.replace(/(\*|\^|\+)/g,"\\$1");o.push(i),1===e.length?n[e]=new RegExp(`(?<![\\\\${i}])(${i})((\\\\${i})?.*?[^${i}\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?![\\\\${i}])`):n[e]=new RegExp(`(?<!\\\\)(${i})((\\\\${i})?.*?[^\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?!\\\\)`)}return{fullMatchRegExpByTag:n,openTagsRegExp:new RegExp(`${r}(${o.join("|")})`,"g"),transformersByTag:t}}(o.textFormat);return(t,i)=>{const s=t.split("\n"),c=s.length,l=i||e.$getRoot();l.clear();for(let e=0;e<c;e++){const t=s[e],[i,c]=T(s,e,o.multilineElement,l);i?e=c:E(t,l,o.element,r,o.textMatch,n)}const a=l.getChildren();for(const e of a)!n&&f(e)&&l.getChildrenSize()>1&&e.remove();null!==e.$getSelection()&&l.selectStart()}}function T(e,t,n,o){for(const r of n){const{handleImportAfterStartMatch:n,regExpEnd:i,regExpStart:s,replace:c}=r,l=e[t].match(s);if(!l)continue;if(n){const i=n({lines:e,rootNode:o,startLineIndex:t,startMatch:l,transformer:r});if(null===i)continue;if(i)return i}const a="object"==typeof i&&"regExp"in i?i.regExp:i,f=i&&"object"==typeof i&&"optional"in i?i.optional:!i;let d=t;const u=e.length;for(;d<u;){const n=a?e[d].match(a):null;if(!n&&(!f||f&&d<u-1)){d++;continue}if(n&&t===d&&n.index===l.index){d++;continue}const r=[];if(n&&t===d)r.push(e[t].slice(l[0].length,-n[0].length));else for(let o=t;o<=d;o++)if(o===t){const t=e[o].slice(l[0].length);r.push(t)}else if(o===d&&n){const t=e[o].slice(0,-n[0].length);r.push(t)}else r.push(e[o]);if(!1!==c(o,null,l,n,r,!0))return[!0,d];break}}return[!1,t]}function E(r,i,s,c,l,a){const f=e.$createTextNode(r),d=e.$createParagraphNode();d.append(f),i.append(d);for(const{regExp:e,replace:t}of s){const n=r.match(e);if(n&&(f.setTextContent(r.slice(n[0].length)),!1!==t(d,[f],n,!0)))break}if($(f,c,l),d.isAttached()&&r.length>0){const r=d.getPreviousSibling();if(!a&&(e.$isParagraphNode(r)||n.$isQuoteNode(r)||t.$isListNode(r))){let n=r;if(t.$isListNode(r)){const e=r.getLastDescendant();n=null==e?null:o.$findMatchingParent(e,t.$isListItemNode)}null!=n&&n.getTextContentSize()>0&&(n.splice(n.getChildrenSize(),0,[e.$createLineBreakNode(),...d.getChildren()]),d.remove())}}}function S(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function C(e,t,n){const o=n.length;for(let r=t;r>=o;r--){const t=r-o;if(L(e,t,n,0,o)&&" "!==e[t+o])return t}return-1}function L(e,t,n,o,r){for(let i=0;i<r;i++)if(e[t+i]!==n[o+i])return!1;return!0}const R=/^(\s*)(\d{1,})\.\s/,I=/^(\s*)[-*+]\s/,y=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,v=/^(#{1,6})\s/,_=/^>\s/,b=/^[ \t]*```(\w+)?/,A=/[ \t]*```$/,F=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,O=/^(?:\|)(.+)(?:\|)\s?$/,k=/^(\| ?:?-*:? ?)+\|\s?$/,M=e=>(t,n,o)=>{const r=e(o);r.append(...n),t.replace(r),r.select(0,0)};const w=e=>(n,o,r)=>{const i=n.getPreviousSibling(),s=n.getNextSibling(),c=t.$createListItemNode("check"===e?"x"===r[3]:void 0);if(t.$isListNode(s)&&s.getListType()===e){const e=s.getFirstChild();null!==e?e.insertBefore(c):s.append(c),n.remove()}else if(t.$isListNode(i)&&i.getListType()===e)i.append(c),n.remove();else{const o=t.$createListNode(e,"number"===e?Number(r[2]):void 0);o.append(c),n.replace(o)}c.append(...o),c.select(0,0);const l=function(e){const t=e.match(/\t/g),n=e.match(/ /g);let o=0;return t&&(o+=t.length),n&&(o+=Math.floor(n.length/4)),o}(r[1]);l&&c.setIndent(l)},B=(e,n,o)=>{const r=[],i=e.getChildren();let s=0;for(const c of i)if(t.$isListItemNode(c)){if(1===c.getChildrenSize()){const e=c.getFirstChild();if(t.$isListNode(e)){r.push(B(e,n,o+1));continue}}const i=" ".repeat(4*o),l=e.getListType(),a="number"===l?`${e.getStart()+s}. `:"check"===l?`- [${c.getChecked()?"x":" "}] `:"- ";r.push(i+a+n(c)),s++}return r.join("\n")},D={dependencies:[n.HeadingNode],export:(e,t)=>{if(!n.$isHeadingNode(e))return null;const o=Number(e.getTag().slice(1));return"#".repeat(o)+" "+t(e)},regExp:v,replace:M((e=>{const t="h"+e[1].length;return n.$createHeadingNode(t)})),type:"element"},P={dependencies:[n.QuoteNode],export:(e,t)=>{if(!n.$isQuoteNode(e))return null;const o=t(e).split("\n"),r=[];for(const e of o)r.push("> "+e);return r.join("\n")},regExp:_,replace:(t,o,r,i)=>{if(i){const r=t.getPreviousSibling();if(n.$isQuoteNode(r))return r.splice(r.getChildrenSize(),0,[e.$createLineBreakNode(),...o]),r.select(0,0),void t.remove()}const s=n.$createQuoteNode();s.append(...o),t.replace(s),s.select(0,0)},type:"element"},H={dependencies:[r.CodeNode],export:e=>{if(!r.$isCodeNode(e))return null;const t=e.getTextContent();return"```"+(e.getLanguage()||"")+(t?"\n"+t:"")+"\n```"},regExpEnd:{optional:!0,regExp:A},regExpStart:b,replace:(t,n,o,i,s,c)=>{let l,a;if(!n&&s){if(1===s.length)i?(l=r.$createCodeNode(),a=o[1]+s[0]):(l=r.$createCodeNode(o[1]),a=s[0].startsWith(" ")?s[0].slice(1):s[0]);else{if(l=r.$createCodeNode(o[1]),0===s[0].trim().length)for(;s.length>0&&!s[0].length;)s.shift();else s[0]=s[0].startsWith(" ")?s[0].slice(1):s[0];for(;s.length>0&&!s[s.length-1].length;)s.pop();a=s.join("\n")}const n=e.$createTextNode(a);l.append(n),t.append(l)}else n&&M((e=>r.$createCodeNode(e?e[1]:void 0)))(t,n,o,c)},type:"multiline-element"},U={dependencies:[t.ListNode,t.ListItemNode],export:(e,n)=>t.$isListNode(e)?B(e,n,0):null,regExp:I,replace:w("bullet"),type:"element"},j={dependencies:[t.ListNode,t.ListItemNode],export:(e,n)=>t.$isListNode(e)?B(e,n,0):null,regExp:y,replace:w("check"),type:"element"},q={dependencies:[t.ListNode,t.ListItemNode],export:(e,n)=>t.$isListNode(e)?B(e,n,0):null,regExp:R,replace:w("number"),type:"element"},z={format:["code"],tag:"`",type:"text-format"},G={format:["highlight"],tag:"==",type:"text-format"},Q={format:["bold","italic"],tag:"***",type:"text-format"},W={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},K={format:["bold"],tag:"**",type:"text-format"},X={format:["bold"],intraword:!1,tag:"__",type:"text-format"},J={format:["strikethrough"],tag:"~~",type:"text-format"},V={format:["italic"],tag:"*",type:"text-format"},Y={format:["italic"],intraword:!1,tag:"_",type:"text-format"},Z={dependencies:[i.LinkNode],export:(e,t,n)=>{if(!i.$isLinkNode(e)||i.$isAutoLinkNode(e))return null;const o=e.getTitle(),r=t(e);return o?`[${r}](${e.getURL()} "${o}")`:`[${r}](${e.getURL()})`},importRegExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,n)=>{const[,o,r,s]=n,c=i.$createLinkNode(r,{title:s}),l=e.$createTextNode(o);return l.setFormat(t.getFormat()),c.append(l),t.replace(c),l},trigger:")",type:"text-match"};const ee=[D,P,U,q],te=[H],ne=[z,Q,W,K,X,G,V,Y,J],oe=[Z],re=[...ee,...te,...ne,...oe];exports.$convertFromMarkdownString=function(e,t=re,n,o=!1,r=!1){const i=o?e:function(e,t=!1){const n=e.split("\n");let o=!1;const r=[];for(let e=0;e<n.length;e++){const i=n[e],s=r[r.length-1];F.test(i)?r.push(i):b.test(i)||A.test(i)?(o=!o,r.push(i)):o||""===i||""===s||!s||v.test(s)||v.test(i)||_.test(i)||R.test(i)||I.test(i)||y.test(i)||O.test(i)||k.test(i)||!t?r.push(i):r[r.length-1]=s+i}return r.join("\n")}(e,r);return N(t,o)(i,n)},exports.$convertToMarkdownString=function(t=re,n,o=!1){return function(t,n=!1){const o=c(t),r=[...o.multilineElement,...o.element],i=!n,s=o.textFormat.filter((e=>1===e.format.length)).sort(((e,t)=>Number(e.format.includes("code"))-Number(t.format.includes("code"))));return t=>{const n=[],c=(t||e.$getRoot()).getChildren();for(let e=0;e<c.length;e++){const t=c[e],l=d(t,r,s,o.textMatch);null!=l&&n.push(i&&e>0&&!f(t)&&!f(c[e-1])?"\n".concat(l):l)}return n.join("\n")}}(t,o)(n)},exports.BOLD_ITALIC_STAR=Q,exports.BOLD_ITALIC_UNDERSCORE=W,exports.BOLD_STAR=K,exports.BOLD_UNDERSCORE=X,exports.CHECK_LIST=j,exports.CODE=H,exports.ELEMENT_TRANSFORMERS=ee,exports.HEADING=D,exports.HIGHLIGHT=G,exports.INLINE_CODE=z,exports.ITALIC_STAR=V,exports.ITALIC_UNDERSCORE=Y,exports.LINK=Z,exports.MULTILINE_ELEMENT_TRANSFORMERS=te,exports.ORDERED_LIST=q,exports.QUOTE=P,exports.STRIKETHROUGH=J,exports.TEXT_FORMAT_TRANSFORMERS=ne,exports.TEXT_MATCH_TRANSFORMERS=oe,exports.TRANSFORMERS=re,exports.UNORDERED_LIST=U,exports.registerMarkdownShortcuts=function(t,n=re){const o=c(n),i=s(o.textFormat,(({tag:e})=>e[e.length-1])),a=s(o.textMatch,(({trigger:e})=>e));for(const e of n){const n=e.type;if("element"===n||"text-match"===n||"multiline-element"===n){const n=e.dependencies;for(const e of n)t.hasNode(e)||S(173,e.getType())}}const f=(t,n,r)=>{(function(t,n,o,r){const i=t.getParent();if(!e.$isRootOrShadowRoot(i)||t.getFirstChild()!==n)return!1;const s=n.getTextContent();if(" "!==s[o-1])return!1;for(const{regExp:e,replace:i}of r){const r=s.match(e);if(r&&r[0].length===(r[0].endsWith(" ")?o:o-1)){const e=n.getNextSiblings(),[s,c]=n.splitText(o);if(s.remove(),!1!==i(t,c?[c,...e]:e,r,!1))return!0}}return!1})(t,n,r,o.element)||function(t,n,o,r){const i=t.getParent();if(!e.$isRootOrShadowRoot(i)||t.getFirstChild()!==n)return!1;const s=n.getTextContent();if(" "!==s[o-1])return!1;for(const{regExpStart:e,replace:i,regExpEnd:c}of r){if(c&&!("optional"in c)||c&&"optional"in c&&!c.optional)continue;const r=s.match(e);if(r&&r[0].length===(r[0].endsWith(" ")?o:o-1)){const e=n.getNextSiblings(),[s,c]=n.splitText(o);if(s.remove(),!1!==i(t,c?[c,...e]:e,r,null,null,!1))return!0}}return!1}(t,n,r,o.multilineElement)||function(e,t,n){let o=e.getTextContent();const r=n[o[t-1]];if(null==r)return!1;t<o.length&&(o=o.slice(0,t));for(const t of r){if(!t.replace||!t.regExp)continue;const n=o.match(t.regExp);if(null===n)continue;const r=n.index||0,i=r+n[0].length;let s;return 0===r?[s]=e.splitText(i):[,s]=e.splitText(r,i),s.selectNext(0,0),t.replace(s,n),!0}return!1}(n,r,a)||function(t,n,o){const r=t.getTextContent(),i=n-1,s=r[i],c=o[s];if(!c)return!1;for(const n of c){const{tag:o}=n,c=o.length,a=i-c+1;if(c>1&&!L(r,a,o,0,c))continue;if(" "===r[a-1])continue;const f=r[i+1];if(!1===n.intraword&&f&&!l.test(f))continue;const d=t;let u=d,g=C(r,a,o),p=u;for(;g<0&&(p=p.getPreviousSibling())&&!e.$isLineBreakNode(p);)if(e.$isTextNode(p)){if(p.hasFormat("code"))continue;const e=p.getTextContent();u=p,g=C(e,e.length,o)}if(g<0)continue;if(u===d&&g+c===a)continue;const x=u.getTextContent();if(g>0&&x[g-1]===s)continue;const h=x[g-1];if(!1===n.intraword&&h&&!l.test(h))continue;const m=d.getTextContent(),$=m.slice(0,a)+m.slice(i+1);d.setTextContent($);const N=u===d?$:x;u.setTextContent(N.slice(0,g)+N.slice(g+c));const T=e.$getSelection(),E=e.$createRangeSelection();e.$setSelection(E);const S=i-c*(u===d?2:1)+1;E.anchor.set(u.__key,g,"text"),E.focus.set(d.__key,S,"text");for(const e of n.format)E.hasFormat(e)||E.formatText(e);E.anchor.set(E.focus.key,E.focus.offset,E.focus.type);for(const e of n.format)E.hasFormat(e)&&E.toggleFormat(e);return e.$isRangeSelection(T)&&(E.format=T.format),!0}}(n,r,i)};return t.registerUpdateListener((({tags:n,dirtyLeaves:o,editorState:i,prevEditorState:s})=>{if(n.has(e.COLLABORATION_TAG)||n.has(e.HISTORIC_TAG))return;if(t.isComposing())return;const c=i.read(e.$getSelection),l=s.read(e.$getSelection);if(!e.$isRangeSelection(l)||!e.$isRangeSelection(c)||!c.isCollapsed()||c.is(l))return;const a=c.anchor.key,d=c.anchor.offset,u=i._nodeMap.get(a);!e.$isTextNode(u)||!o.has(a)||1!==d&&d>l.anchor.offset+1||t.update((()=>{if(!m(u))return;const e=u.getParent();null===e||r.$isCodeNode(e)||f(e,u,c.anchor.offset)}))}))};
|
package/LexicalMarkdown.prod.mjs
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{$isParagraphNode as t,$isTextNode as e,$getRoot as n,$isElementNode as o,$isDecoratorNode as r,$isLineBreakNode as i,$getSelection as s,$createTextNode as l,$createParagraphNode as c,$createLineBreakNode as f,COLLABORATION_TAG as a,HISTORIC_TAG as u,$isRangeSelection as g,$isRootOrShadowRoot as p,$createRangeSelection as d,$setSelection as m}from"lexical";import{$isListNode as h,$isListItemNode as x,ListNode as T,ListItemNode as C,$createListItemNode as E,$createListNode as y}from"@lexical/list";import{$isQuoteNode as $,HeadingNode as v,$isHeadingNode as S,QuoteNode as b,$createQuoteNode as F,$createHeadingNode as I}from"@lexical/rich-text";import{$findMatchingParent as N}from"@lexical/utils";import{$isCodeNode as w,CodeNode as k,$createCodeNode as L}from"@lexical/code";import{LinkNode as P,$isLinkNode as R,$isAutoLinkNode as _,$createLinkNode as B}from"@lexical/link";function M(t,e){const n={};for(const o of t){const t=e(o);t&&(n[t]?n[t].push(o):n[t]=[o])}return n}function j(t){const e=M(t,(t=>t.type));return{element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const A=/[!-/:-@[-`{-~\s]/,z=/^\s{0,3}$/;function U(n){if(!t(n))return!1;const o=n.getFirstChild();return null==o||1===n.getChildrenSize()&&e(o)&&z.test(o.getTextContent())}const W=/^\+?[0-9\s()-]{5,}$/;function D(t,e,n,i){for(const o of e){if(!o.export)continue;const e=o.export(t,(t=>O(t,n,i)));if(null!=e)return e}return o(t)?O(t,n,i):r(t)?t.getTextContent():null}function O(t,n,s,l,c){const f=[],a=t.getChildren();l||(l=[]),c||(c=[]);t:for(const t of a){for(const e of s){if(!e.export)continue;const o=e.export(t,(t=>O(t,n,s,l,[...c,...l])),((t,e)=>q(t,e,n,l,c)));if(null!=o){f.push(o);continue t}}i(t)?f.push("\n"):e(t)?f.push(q(t,t.getTextContent(),n,l,c)):o(t)?f.push(O(t,n,s,l,c)):r(t)&&f.push(t.getTextContent())}return f.join("")}function q(t,e,n,o,r){let i=0===t.getFormat()?e:function(t){return t.replace(/^\s+|\s+$/g,(t=>[...t].map((t=>"&#"+t.codePointAt(0)+";")).join("")))}(e);t.hasFormat("code")||(i=i.replace(/([*_`~\\])/g,"\\$1"));let s="",l="",c="";const f=G(t,!0),a=G(t,!1),u=new Set;for(const e of n){const n=e.format[0],r=e.tag;H(t,n)&&!u.has(n)&&(u.add(n),H(f,n)&&o.find((t=>t.tag===r))||(o.push({format:n,tag:r}),s+=r))}for(let e=0;e<o.length;e++){const n=H(t,o[e].format),i=H(a,o[e].format);if(n&&i)continue;const s=[...o];for(;s.length>e;){const t=s.pop();r&&t&&r.find((e=>e.tag===t.tag))||(t&&"string"==typeof t.tag&&(n?i||(c+=t.tag):l+=t.tag),o.pop())}break}return i=s+i+c,l+i}function G(t,n){let r=n?t.getPreviousSibling():t.getNextSibling();if(!r){const e=t.getParentOrThrow();e.isInline()&&(r=n?e.getPreviousSibling():e.getNextSibling())}for(;r;){if(o(r)){if(!r.isInline())break;const t=n?r.getLastDescendant():r.getFirstDescendant();if(e(t))return t;r=n?r.getPreviousSibling():r.getNextSibling()}if(e(r))return r;if(!o(r))return null}return null}function H(t,n){return e(t)&&t.hasFormat(n)}function J(t,e){const n=function(t,e){const n=t.match(e.openTagsRegExp);if(null==n)return null;for(const o of n){const n=o.replace(/^\s/,""),r=e.fullMatchRegExpByTag[n];if(null==r)continue;const i=t.match(r),s=e.transformersByTag[n];if(null!=i&&null!=s){if(!1!==s.intraword)return i;const{index:e=0}=i,n=t[e-1],o=t[e+i[0].length];if((!n||A.test(n))&&(!o||A.test(o)))return i}}return null}(t.getTextContent(),e);if(!n)return null;const o=n.index||0;return{endIndex:o+n[0].length,match:n,startIndex:o,transformer:e.transformersByTag[n[1]]}}function K(t){return e(t)&&!t.hasFormat("code")}function Q(t,e,n){let o=J(t,e),r=function(t,e){const n=t;let o,r,i,s;for(const t of e){if(!t.replace||!t.importRegExp)continue;const e=n.getTextContent().match(t.importRegExp);if(!e)continue;const l=e.index||0,c=t.getEndIndex?t.getEndIndex(n,e):l+e[0].length;!1!==c&&(void 0===o||void 0===r||l<o&&c>r)&&(o=l,r=c,i=t,s=e)}return void 0===o||void 0===r||void 0===i||void 0===s?null:{endIndex:r,match:s,startIndex:o,transformer:i}}(t,n);if(o&&r&&(o.startIndex<=r.startIndex&&o.endIndex>=r.endIndex?r=null:o=null),o){const r=function(t,e,n,o,r){const i=t.getTextContent();let s,l,c;if(r[0]===i?s=t:0===e?[s,l]=t.splitText(n):[c,s,l]=t.splitText(e,n),s.setTextContent(r[2]),o)for(const t of o.format)s.hasFormat(t)||s.toggleFormat(t);return{nodeAfter:l,nodeBefore:c,transformedNode:s}}(t,o.startIndex,o.endIndex,o.transformer,o.match);K(r.nodeAfter)&&Q(r.nodeAfter,e,n),K(r.nodeBefore)&&Q(r.nodeBefore,e,n),K(r.transformedNode)&&Q(r.transformedNode,e,n)}else if(r){const o=function(t,e,n,o,r){let i,s,l;return 0===e?[i,s]=t.splitText(n):[l,i,s]=t.splitText(e,n),o.replace?{nodeAfter:s,nodeBefore:l,transformedNode:o.replace(i,r)||void 0}:null}(t,r.startIndex,r.endIndex,r.transformer,r.match);if(!o)return;K(o.nodeAfter)&&Q(o.nodeAfter,e,n),K(o.nodeBefore)&&Q(o.nodeBefore,e,n),K(o.transformedNode)&&Q(o.transformedNode,e,n)}const i=t.getTextContent().replace(/\\([*_`~\\])/g,"$1").replace(/&#(\d+);/g,((t,e)=>String.fromCodePoint(e)));t.setTextContent(i)}function V(t,e=!1){const o=j(t),r=function(t){const e={},n={},o=[],r="(?<![\\\\])";for(const r of t){const{tag:t}=r;e[t]=r;const i=t.replace(/(\*|\^|\+)/g,"\\$1");o.push(i),1===t.length?n[t]=new RegExp(`(?<![\\\\${i}])(${i})((\\\\${i})?.*?[^${i}\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?![\\\\${i}])`):n[t]=new RegExp(`(?<!\\\\)(${i})((\\\\${i})?.*?[^\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?!\\\\)`)}return{fullMatchRegExpByTag:n,openTagsRegExp:new RegExp(`${r}(${o.join("|")})`,"g"),transformersByTag:e}}(o.textFormat);return(t,i)=>{const l=t.split("\n"),c=l.length,f=i||n();f.clear();for(let t=0;t<c;t++){const n=l[t],[i,s]=X(l,t,o.multilineElement,f);i?t=s:Y(n,f,o.element,r,o.textMatch,e)}const a=f.getChildren();for(const t of a)!e&&U(t)&&f.getChildrenSize()>1&&t.remove();null!==s()&&f.selectStart()}}function X(t,e,n,o){for(const r of n){const{handleImportAfterStartMatch:n,regExpEnd:i,regExpStart:s,replace:l}=r,c=t[e].match(s);if(!c)continue;if(n){const i=n({lines:t,rootNode:o,startLineIndex:e,startMatch:c,transformer:r});if(null===i)continue;if(i)return i}const f="object"==typeof i&&"regExp"in i?i.regExp:i,a=i&&"object"==typeof i&&"optional"in i?i.optional:!i;let u=e;const g=t.length;for(;u<g;){const n=f?t[u].match(f):null;if(!n&&(!a||a&&u<g-1)){u++;continue}if(n&&e===u&&n.index===c.index){u++;continue}const r=[];if(n&&e===u)r.push(t[e].slice(c[0].length,-n[0].length));else for(let o=e;o<=u;o++)if(o===e){const e=t[o].slice(c[0].length);r.push(e)}else if(o===u&&n){const e=t[o].slice(0,-n[0].length);r.push(e)}else r.push(t[o]);if(!1!==l(o,null,c,n,r,!0))return[!0,u];break}}return[!1,e]}function Y(e,n,o,r,i,s){const a=l(e),u=c();u.append(a),n.append(u);for(const{regExp:t,replace:n}of o){const o=e.match(t);if(o&&(a.setTextContent(e.slice(o[0].length)),!1!==n(u,[a],o,!0)))break}if(Q(a,r,i),u.isAttached()&&e.length>0){const e=u.getPreviousSibling();if(!s&&(t(e)||$(e)||h(e))){let t=e;if(h(e)){const n=e.getLastDescendant();t=null==n?null:N(n,x)}null!=t&&t.getTextContentSize()>0&&(t.splice(t.getChildrenSize(),0,[f(),...u.getChildren()]),u.remove())}}}function Z(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.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 tt(t,e,n){const o=n.length;for(let r=e;r>=o;r--){const e=r-o;if(et(t,e,n,0,o)&&" "!==t[e+o])return e}return-1}function et(t,e,n,o,r){for(let i=0;i<r;i++)if(t[e+i]!==n[o+i])return!1;return!0}function nt(t,n=Mt){const o=j(n),r=M(o.textFormat,(({tag:t})=>t[t.length-1])),l=M(o.textMatch,(({trigger:t})=>t));for(const e of n){const n=e.type;if("element"===n||"text-match"===n||"multiline-element"===n){const n=e.dependencies;for(const e of n)t.hasNode(e)||Z(173,e.getType())}}const c=(t,n,c)=>{(function(t,e,n,o){const r=t.getParent();if(!p(r)||t.getFirstChild()!==e)return!1;const i=e.getTextContent();if(" "!==i[n-1])return!1;for(const{regExp:r,replace:s}of o){const o=i.match(r);if(o&&o[0].length===(o[0].endsWith(" ")?n:n-1)){const r=e.getNextSiblings(),[i,l]=e.splitText(n);if(i.remove(),!1!==s(t,l?[l,...r]:r,o,!1))return!0}}return!1})(t,n,c,o.element)||function(t,e,n,o){const r=t.getParent();if(!p(r)||t.getFirstChild()!==e)return!1;const i=e.getTextContent();if(" "!==i[n-1])return!1;for(const{regExpStart:r,replace:s,regExpEnd:l}of o){if(l&&!("optional"in l)||l&&"optional"in l&&!l.optional)continue;const o=i.match(r);if(o&&o[0].length===(o[0].endsWith(" ")?n:n-1)){const r=e.getNextSiblings(),[i,l]=e.splitText(n);if(i.remove(),!1!==s(t,l?[l,...r]:r,o,null,null,!1))return!0}}return!1}(t,n,c,o.multilineElement)||function(t,e,n){let o=t.getTextContent();const r=n[o[e-1]];if(null==r)return!1;e<o.length&&(o=o.slice(0,e));for(const e of r){if(!e.replace||!e.regExp)continue;const n=o.match(e.regExp);if(null===n)continue;const r=n.index||0,i=r+n[0].length;let s;return 0===r?[s]=t.splitText(i):[,s]=t.splitText(r,i),s.selectNext(0,0),e.replace(s,n),!0}return!1}(n,c,l)||function(t,n,o){const r=t.getTextContent(),l=n-1,c=r[l],f=o[c];if(!f)return!1;for(const n of f){const{tag:o}=n,f=o.length,a=l-f+1;if(f>1&&!et(r,a,o,0,f))continue;if(" "===r[a-1])continue;const u=r[l+1];if(!1===n.intraword&&u&&!A.test(u))continue;const p=t;let h=p,x=tt(r,a,o),T=h;for(;x<0&&(T=T.getPreviousSibling())&&!i(T);)if(e(T)){if(T.hasFormat("code"))continue;const t=T.getTextContent();h=T,x=tt(t,t.length,o)}if(x<0)continue;if(h===p&&x+f===a)continue;const C=h.getTextContent();if(x>0&&C[x-1]===c)continue;const E=C[x-1];if(!1===n.intraword&&E&&!A.test(E))continue;const y=p.getTextContent(),$=y.slice(0,a)+y.slice(l+1);p.setTextContent($);const v=h===p?$:C;h.setTextContent(v.slice(0,x)+v.slice(x+f));const S=s(),b=d();m(b);const F=l-f*(h===p?2:1)+1;b.anchor.set(h.__key,x,"text"),b.focus.set(p.__key,F,"text");for(const t of n.format)b.hasFormat(t)||b.formatText(t);b.anchor.set(b.focus.key,b.focus.offset,b.focus.type);for(const t of n.format)b.hasFormat(t)&&b.toggleFormat(t);return g(S)&&(b.format=S.format),!0}}(n,c,r)};return t.registerUpdateListener((({tags:n,dirtyLeaves:o,editorState:r,prevEditorState:i})=>{if(n.has(a)||n.has(u))return;if(t.isComposing())return;const l=r.read(s),f=i.read(s);if(!g(f)||!g(l)||!l.isCollapsed()||l.is(f))return;const p=l.anchor.key,d=l.anchor.offset,m=r._nodeMap.get(p);!e(m)||!o.has(p)||1!==d&&d>f.anchor.offset+1||t.update((()=>{if(!K(m))return;const t=m.getParent();null===t||w(t)||c(t,m,l.anchor.offset)}))}))}const ot=/^(\s*)(\d{1,})\.\s/,rt=/^(\s*)[-*+]\s/,it=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,st=/^(#{1,6})\s/,lt=/^>\s/,ct=/^[ \t]*```(\w+)?/,ft=/[ \t]*```$/,at=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,ut=/^(?:\|)(.+)(?:\|)\s?$/,gt=/^(\| ?:?-*:? ?)+\|\s?$/,pt=t=>(e,n,o)=>{const r=t(o);r.append(...n),e.replace(r),r.select(0,0)};const dt=t=>(e,n,o)=>{const r=e.getPreviousSibling(),i=e.getNextSibling(),s=E("check"===t?"x"===o[3]:void 0);if(h(i)&&i.getListType()===t){const t=i.getFirstChild();null!==t?t.insertBefore(s):i.append(s),e.remove()}else if(h(r)&&r.getListType()===t)r.append(s),e.remove();else{const n=y(t,"number"===t?Number(o[2]):void 0);n.append(s),e.replace(n)}s.append(...n),s.select(0,0);const l=function(t){const e=t.match(/\t/g),n=t.match(/ /g);let o=0;return e&&(o+=e.length),n&&(o+=Math.floor(n.length/4)),o}(o[1]);l&&s.setIndent(l)},mt=(t,e,n)=>{const o=[],r=t.getChildren();let i=0;for(const s of r)if(x(s)){if(1===s.getChildrenSize()){const t=s.getFirstChild();if(h(t)){o.push(mt(t,e,n+1));continue}}const r=" ".repeat(4*n),l=t.getListType(),c="number"===l?`${t.getStart()+i}. `:"check"===l?`- [${s.getChecked()?"x":" "}] `:"- ";o.push(r+c+e(s)),i++}return o.join("\n")},ht={dependencies:[v],export:(t,e)=>{if(!S(t))return null;const n=Number(t.getTag().slice(1));return"#".repeat(n)+" "+e(t)},regExp:st,replace:pt((t=>{const e="h"+t[1].length;return I(e)})),type:"element"},xt={dependencies:[b],export:(t,e)=>{if(!$(t))return null;const n=e(t).split("\n"),o=[];for(const t of n)o.push("> "+t);return o.join("\n")},regExp:lt,replace:(t,e,n,o)=>{if(o){const n=t.getPreviousSibling();if($(n))return n.splice(n.getChildrenSize(),0,[f(),...e]),n.select(0,0),void t.remove()}const r=F();r.append(...e),t.replace(r),r.select(0,0)},type:"element"},Tt={dependencies:[k],export:t=>{if(!w(t))return null;const e=t.getTextContent();return"```"+(t.getLanguage()||"")+(e?"\n"+e:"")+"\n```"},regExpEnd:{optional:!0,regExp:ft},regExpStart:ct,replace:(t,e,n,o,r,i)=>{let s,c;if(!e&&r){if(1===r.length)o?(s=L(),c=n[1]+r[0]):(s=L(n[1]),c=r[0].startsWith(" ")?r[0].slice(1):r[0]);else{if(s=L(n[1]),0===r[0].trim().length)for(;r.length>0&&!r[0].length;)r.shift();else r[0]=r[0].startsWith(" ")?r[0].slice(1):r[0];for(;r.length>0&&!r[r.length-1].length;)r.pop();c=r.join("\n")}const e=l(c);s.append(e),t.append(s)}else e&&pt((t=>L(t?t[1]:void 0)))(t,e,n,i)},type:"multiline-element"},Ct={dependencies:[T,C],export:(t,e)=>h(t)?mt(t,e,0):null,regExp:rt,replace:dt("bullet"),type:"element"},Et={dependencies:[T,C],export:(t,e)=>h(t)?mt(t,e,0):null,regExp:it,replace:dt("check"),type:"element"},yt={dependencies:[T,C],export:(t,e)=>h(t)?mt(t,e,0):null,regExp:ot,replace:dt("number"),type:"element"},$t={format:["code"],tag:"`",type:"text-format"},vt={format:["highlight"],tag:"==",type:"text-format"},St={format:["bold","italic"],tag:"***",type:"text-format"},bt={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},Ft={format:["bold"],tag:"**",type:"text-format"},It={format:["bold"],intraword:!1,tag:"__",type:"text-format"},Nt={format:["strikethrough"],tag:"~~",type:"text-format"},wt={format:["italic"],tag:"*",type:"text-format"},kt={format:["italic"],intraword:!1,tag:"_",type:"text-format"},Lt={dependencies:[P],export:(t,e,n)=>{if(!R(t)||_(t))return null;const o=t.getTitle(),r=e(t);return o?`[${r}](${t.getURL()} "${o}")`:`[${r}](${t.getURL()})`},importRegExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,e)=>{const[,n,o,r]=e,i=(s=o).match(/^[a-z][a-z0-9+.-]*:/i)||s.match(/^[/#.]/)?s:s.includes("@")?`mailto:${s}`:W.test(s)?`tel:${s}`:`https://${s}`;var s;const c=B(i,{title:r}),f=l(n);return f.setFormat(t.getFormat()),c.append(f),t.replace(c),f},trigger:")",type:"text-match"};const Pt=[ht,xt,Ct,yt],Rt=[Tt],_t=[$t,St,bt,Ft,It,vt,wt,kt,Nt],Bt=[Lt],Mt=[...Pt,...Rt,..._t,...Bt];function jt(t,e=Mt,n,o=!1,r=!1){const i=o?t:function(t,e=!1){const n=t.split("\n");let o=!1;const r=[];for(let t=0;t<n.length;t++){const i=n[t],s=r[r.length-1];at.test(i)?r.push(i):ct.test(i)||ft.test(i)?(o=!o,r.push(i)):o||""===i||""===s||!s||st.test(s)||st.test(i)||lt.test(i)||ot.test(i)||rt.test(i)||it.test(i)||ut.test(i)||gt.test(i)||!e?r.push(i):r[r.length-1]=s+i}return r.join("\n")}(t,r);return V(e,o)(i,n)}function At(t=Mt,e,o=!1){const r=function(t,e=!1){const o=j(t),r=[...o.multilineElement,...o.element],i=!e,s=o.textFormat.filter((t=>1===t.format.length)).sort(((t,e)=>Number(t.format.includes("code"))-Number(e.format.includes("code"))));return t=>{const e=[],l=(t||n()).getChildren();for(let t=0;t<l.length;t++){const n=l[t],c=D(n,r,s,o.textMatch);null!=c&&e.push(i&&t>0&&!U(n)&&!U(l[t-1])?"\n".concat(c):c)}return e.join("\n")}}(t,o);return r(e)}export{jt as $convertFromMarkdownString,At as $convertToMarkdownString,St as BOLD_ITALIC_STAR,bt as BOLD_ITALIC_UNDERSCORE,Ft as BOLD_STAR,It as BOLD_UNDERSCORE,Et as CHECK_LIST,Tt as CODE,Pt as ELEMENT_TRANSFORMERS,ht as HEADING,vt as HIGHLIGHT,$t as INLINE_CODE,wt as ITALIC_STAR,kt as ITALIC_UNDERSCORE,Lt as LINK,Rt as MULTILINE_ELEMENT_TRANSFORMERS,yt as ORDERED_LIST,xt as QUOTE,Nt as STRIKETHROUGH,_t as TEXT_FORMAT_TRANSFORMERS,Bt as TEXT_MATCH_TRANSFORMERS,Mt as TRANSFORMERS,Ct as UNORDERED_LIST,nt as registerMarkdownShortcuts};
|
|
9
|
+
import{$isParagraphNode as t,$isTextNode as e,$getRoot as n,$isElementNode as o,$isDecoratorNode as r,$isLineBreakNode as i,$getSelection as s,$createTextNode as l,$createParagraphNode as c,$createLineBreakNode as f,COLLABORATION_TAG as a,HISTORIC_TAG as u,$isRangeSelection as g,$isRootOrShadowRoot as p,$createRangeSelection as d,$setSelection as m}from"lexical";import{$isListNode as h,$isListItemNode as x,ListNode as T,ListItemNode as C,$createListItemNode as E,$createListNode as y}from"@lexical/list";import{$isQuoteNode as v,HeadingNode as S,$isHeadingNode as $,QuoteNode as b,$createQuoteNode as F,$createHeadingNode as I}from"@lexical/rich-text";import{$findMatchingParent as N}from"@lexical/utils";import{$isCodeNode as w,CodeNode as k,$createCodeNode as L}from"@lexical/code";import{LinkNode as P,$isLinkNode as R,$isAutoLinkNode as _,$createLinkNode as B}from"@lexical/link";function M(t,e){const n={};for(const o of t){const t=e(o);t&&(n[t]?n[t].push(o):n[t]=[o])}return n}function j(t){const e=M(t,(t=>t.type));return{element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const A=/[!-/:-@[-`{-~\s]/,z=/^\s{0,3}$/;function U(n){if(!t(n))return!1;const o=n.getFirstChild();return null==o||1===n.getChildrenSize()&&e(o)&&z.test(o.getTextContent())}function W(t,e,n,i){for(const o of e){if(!o.export)continue;const e=o.export(t,(t=>D(t,n,i)));if(null!=e)return e}return o(t)?D(t,n,i):r(t)?t.getTextContent():null}function D(t,n,s,l,c){const f=[],a=t.getChildren();l||(l=[]),c||(c=[]);t:for(const t of a){for(const e of s){if(!e.export)continue;const o=e.export(t,(t=>D(t,n,s,l,[...c,...l])),((t,e)=>O(t,e,n,l,c)));if(null!=o){f.push(o);continue t}}i(t)?f.push("\n"):e(t)?f.push(O(t,t.getTextContent(),n,l,c)):o(t)?f.push(D(t,n,s,l,c)):r(t)&&f.push(t.getTextContent())}return f.join("")}function O(t,e,n,o,r){let i=0===t.getFormat()?e:function(t){return t.replace(/^\s+|\s+$/g,(t=>[...t].map((t=>"&#"+t.codePointAt(0)+";")).join("")))}(e);t.hasFormat("code")||(i=i.replace(/([*_`~\\])/g,"\\$1"));let s="",l="",c="";const f=q(t,!0),a=q(t,!1),u=new Set;for(const e of n){const n=e.format[0],r=e.tag;G(t,n)&&!u.has(n)&&(u.add(n),G(f,n)&&o.find((t=>t.tag===r))||(o.push({format:n,tag:r}),s+=r))}for(let e=0;e<o.length;e++){const n=G(t,o[e].format),i=G(a,o[e].format);if(n&&i)continue;const s=[...o];for(;s.length>e;){const t=s.pop();r&&t&&r.find((e=>e.tag===t.tag))||(t&&"string"==typeof t.tag&&(n?i||(c+=t.tag):l+=t.tag),o.pop())}break}return i=s+i+c,l+i}function q(t,n){let r=n?t.getPreviousSibling():t.getNextSibling();if(!r){const e=t.getParentOrThrow();e.isInline()&&(r=n?e.getPreviousSibling():e.getNextSibling())}for(;r;){if(o(r)){if(!r.isInline())break;const t=n?r.getLastDescendant():r.getFirstDescendant();if(e(t))return t;r=n?r.getPreviousSibling():r.getNextSibling()}if(e(r))return r;if(!o(r))return null}return null}function G(t,n){return e(t)&&t.hasFormat(n)}function H(t,e){const n=function(t,e){const n=t.match(e.openTagsRegExp);if(null==n)return null;for(const o of n){const n=o.replace(/^\s/,""),r=e.fullMatchRegExpByTag[n];if(null==r)continue;const i=t.match(r),s=e.transformersByTag[n];if(null!=i&&null!=s){if(!1!==s.intraword)return i;const{index:e=0}=i,n=t[e-1],o=t[e+i[0].length];if((!n||A.test(n))&&(!o||A.test(o)))return i}}return null}(t.getTextContent(),e);if(!n)return null;const o=n.index||0;return{endIndex:o+n[0].length,match:n,startIndex:o,transformer:e.transformersByTag[n[1]]}}function J(t){return e(t)&&!t.hasFormat("code")}function K(t,e,n){let o=H(t,e),r=function(t,e){const n=t;let o,r,i,s;for(const t of e){if(!t.replace||!t.importRegExp)continue;const e=n.getTextContent().match(t.importRegExp);if(!e)continue;const l=e.index||0,c=t.getEndIndex?t.getEndIndex(n,e):l+e[0].length;!1!==c&&(void 0===o||void 0===r||l<o&&c>r)&&(o=l,r=c,i=t,s=e)}return void 0===o||void 0===r||void 0===i||void 0===s?null:{endIndex:r,match:s,startIndex:o,transformer:i}}(t,n);if(o&&r&&(o.startIndex<=r.startIndex&&o.endIndex>=r.endIndex?r=null:o=null),o){const r=function(t,e,n,o,r){const i=t.getTextContent();let s,l,c;if(r[0]===i?s=t:0===e?[s,l]=t.splitText(n):[c,s,l]=t.splitText(e,n),s.setTextContent(r[2]),o)for(const t of o.format)s.hasFormat(t)||s.toggleFormat(t);return{nodeAfter:l,nodeBefore:c,transformedNode:s}}(t,o.startIndex,o.endIndex,o.transformer,o.match);J(r.nodeAfter)&&K(r.nodeAfter,e,n),J(r.nodeBefore)&&K(r.nodeBefore,e,n),J(r.transformedNode)&&K(r.transformedNode,e,n)}else if(r){const o=function(t,e,n,o,r){let i,s,l;return 0===e?[i,s]=t.splitText(n):[l,i,s]=t.splitText(e,n),o.replace?{nodeAfter:s,nodeBefore:l,transformedNode:o.replace(i,r)||void 0}:null}(t,r.startIndex,r.endIndex,r.transformer,r.match);if(!o)return;J(o.nodeAfter)&&K(o.nodeAfter,e,n),J(o.nodeBefore)&&K(o.nodeBefore,e,n),J(o.transformedNode)&&K(o.transformedNode,e,n)}const i=t.getTextContent().replace(/\\([*_`~\\])/g,"$1").replace(/&#(\d+);/g,((t,e)=>String.fromCodePoint(e)));t.setTextContent(i)}function Q(t,e=!1){const o=j(t),r=function(t){const e={},n={},o=[],r="(?<![\\\\])";for(const r of t){const{tag:t}=r;e[t]=r;const i=t.replace(/(\*|\^|\+)/g,"\\$1");o.push(i),1===t.length?n[t]=new RegExp(`(?<![\\\\${i}])(${i})((\\\\${i})?.*?[^${i}\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?![\\\\${i}])`):n[t]=new RegExp(`(?<!\\\\)(${i})((\\\\${i})?.*?[^\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?!\\\\)`)}return{fullMatchRegExpByTag:n,openTagsRegExp:new RegExp(`${r}(${o.join("|")})`,"g"),transformersByTag:e}}(o.textFormat);return(t,i)=>{const l=t.split("\n"),c=l.length,f=i||n();f.clear();for(let t=0;t<c;t++){const n=l[t],[i,s]=V(l,t,o.multilineElement,f);i?t=s:X(n,f,o.element,r,o.textMatch,e)}const a=f.getChildren();for(const t of a)!e&&U(t)&&f.getChildrenSize()>1&&t.remove();null!==s()&&f.selectStart()}}function V(t,e,n,o){for(const r of n){const{handleImportAfterStartMatch:n,regExpEnd:i,regExpStart:s,replace:l}=r,c=t[e].match(s);if(!c)continue;if(n){const i=n({lines:t,rootNode:o,startLineIndex:e,startMatch:c,transformer:r});if(null===i)continue;if(i)return i}const f="object"==typeof i&&"regExp"in i?i.regExp:i,a=i&&"object"==typeof i&&"optional"in i?i.optional:!i;let u=e;const g=t.length;for(;u<g;){const n=f?t[u].match(f):null;if(!n&&(!a||a&&u<g-1)){u++;continue}if(n&&e===u&&n.index===c.index){u++;continue}const r=[];if(n&&e===u)r.push(t[e].slice(c[0].length,-n[0].length));else for(let o=e;o<=u;o++)if(o===e){const e=t[o].slice(c[0].length);r.push(e)}else if(o===u&&n){const e=t[o].slice(0,-n[0].length);r.push(e)}else r.push(t[o]);if(!1!==l(o,null,c,n,r,!0))return[!0,u];break}}return[!1,e]}function X(e,n,o,r,i,s){const a=l(e),u=c();u.append(a),n.append(u);for(const{regExp:t,replace:n}of o){const o=e.match(t);if(o&&(a.setTextContent(e.slice(o[0].length)),!1!==n(u,[a],o,!0)))break}if(K(a,r,i),u.isAttached()&&e.length>0){const e=u.getPreviousSibling();if(!s&&(t(e)||v(e)||h(e))){let t=e;if(h(e)){const n=e.getLastDescendant();t=null==n?null:N(n,x)}null!=t&&t.getTextContentSize()>0&&(t.splice(t.getChildrenSize(),0,[f(),...u.getChildren()]),u.remove())}}}function Y(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.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 Z(t,e,n){const o=n.length;for(let r=e;r>=o;r--){const e=r-o;if(tt(t,e,n,0,o)&&" "!==t[e+o])return e}return-1}function tt(t,e,n,o,r){for(let i=0;i<r;i++)if(t[e+i]!==n[o+i])return!1;return!0}function et(t,n=Bt){const o=j(n),r=M(o.textFormat,(({tag:t})=>t[t.length-1])),l=M(o.textMatch,(({trigger:t})=>t));for(const e of n){const n=e.type;if("element"===n||"text-match"===n||"multiline-element"===n){const n=e.dependencies;for(const e of n)t.hasNode(e)||Y(173,e.getType())}}const c=(t,n,c)=>{(function(t,e,n,o){const r=t.getParent();if(!p(r)||t.getFirstChild()!==e)return!1;const i=e.getTextContent();if(" "!==i[n-1])return!1;for(const{regExp:r,replace:s}of o){const o=i.match(r);if(o&&o[0].length===(o[0].endsWith(" ")?n:n-1)){const r=e.getNextSiblings(),[i,l]=e.splitText(n);if(i.remove(),!1!==s(t,l?[l,...r]:r,o,!1))return!0}}return!1})(t,n,c,o.element)||function(t,e,n,o){const r=t.getParent();if(!p(r)||t.getFirstChild()!==e)return!1;const i=e.getTextContent();if(" "!==i[n-1])return!1;for(const{regExpStart:r,replace:s,regExpEnd:l}of o){if(l&&!("optional"in l)||l&&"optional"in l&&!l.optional)continue;const o=i.match(r);if(o&&o[0].length===(o[0].endsWith(" ")?n:n-1)){const r=e.getNextSiblings(),[i,l]=e.splitText(n);if(i.remove(),!1!==s(t,l?[l,...r]:r,o,null,null,!1))return!0}}return!1}(t,n,c,o.multilineElement)||function(t,e,n){let o=t.getTextContent();const r=n[o[e-1]];if(null==r)return!1;e<o.length&&(o=o.slice(0,e));for(const e of r){if(!e.replace||!e.regExp)continue;const n=o.match(e.regExp);if(null===n)continue;const r=n.index||0,i=r+n[0].length;let s;return 0===r?[s]=t.splitText(i):[,s]=t.splitText(r,i),s.selectNext(0,0),e.replace(s,n),!0}return!1}(n,c,l)||function(t,n,o){const r=t.getTextContent(),l=n-1,c=r[l],f=o[c];if(!f)return!1;for(const n of f){const{tag:o}=n,f=o.length,a=l-f+1;if(f>1&&!tt(r,a,o,0,f))continue;if(" "===r[a-1])continue;const u=r[l+1];if(!1===n.intraword&&u&&!A.test(u))continue;const p=t;let h=p,x=Z(r,a,o),T=h;for(;x<0&&(T=T.getPreviousSibling())&&!i(T);)if(e(T)){if(T.hasFormat("code"))continue;const t=T.getTextContent();h=T,x=Z(t,t.length,o)}if(x<0)continue;if(h===p&&x+f===a)continue;const C=h.getTextContent();if(x>0&&C[x-1]===c)continue;const E=C[x-1];if(!1===n.intraword&&E&&!A.test(E))continue;const y=p.getTextContent(),v=y.slice(0,a)+y.slice(l+1);p.setTextContent(v);const S=h===p?v:C;h.setTextContent(S.slice(0,x)+S.slice(x+f));const $=s(),b=d();m(b);const F=l-f*(h===p?2:1)+1;b.anchor.set(h.__key,x,"text"),b.focus.set(p.__key,F,"text");for(const t of n.format)b.hasFormat(t)||b.formatText(t);b.anchor.set(b.focus.key,b.focus.offset,b.focus.type);for(const t of n.format)b.hasFormat(t)&&b.toggleFormat(t);return g($)&&(b.format=$.format),!0}}(n,c,r)};return t.registerUpdateListener((({tags:n,dirtyLeaves:o,editorState:r,prevEditorState:i})=>{if(n.has(a)||n.has(u))return;if(t.isComposing())return;const l=r.read(s),f=i.read(s);if(!g(f)||!g(l)||!l.isCollapsed()||l.is(f))return;const p=l.anchor.key,d=l.anchor.offset,m=r._nodeMap.get(p);!e(m)||!o.has(p)||1!==d&&d>f.anchor.offset+1||t.update((()=>{if(!J(m))return;const t=m.getParent();null===t||w(t)||c(t,m,l.anchor.offset)}))}))}const nt=/^(\s*)(\d{1,})\.\s/,ot=/^(\s*)[-*+]\s/,rt=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,it=/^(#{1,6})\s/,st=/^>\s/,lt=/^[ \t]*```(\w+)?/,ct=/[ \t]*```$/,ft=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,at=/^(?:\|)(.+)(?:\|)\s?$/,ut=/^(\| ?:?-*:? ?)+\|\s?$/,gt=t=>(e,n,o)=>{const r=t(o);r.append(...n),e.replace(r),r.select(0,0)};const pt=t=>(e,n,o)=>{const r=e.getPreviousSibling(),i=e.getNextSibling(),s=E("check"===t?"x"===o[3]:void 0);if(h(i)&&i.getListType()===t){const t=i.getFirstChild();null!==t?t.insertBefore(s):i.append(s),e.remove()}else if(h(r)&&r.getListType()===t)r.append(s),e.remove();else{const n=y(t,"number"===t?Number(o[2]):void 0);n.append(s),e.replace(n)}s.append(...n),s.select(0,0);const l=function(t){const e=t.match(/\t/g),n=t.match(/ /g);let o=0;return e&&(o+=e.length),n&&(o+=Math.floor(n.length/4)),o}(o[1]);l&&s.setIndent(l)},dt=(t,e,n)=>{const o=[],r=t.getChildren();let i=0;for(const s of r)if(x(s)){if(1===s.getChildrenSize()){const t=s.getFirstChild();if(h(t)){o.push(dt(t,e,n+1));continue}}const r=" ".repeat(4*n),l=t.getListType(),c="number"===l?`${t.getStart()+i}. `:"check"===l?`- [${s.getChecked()?"x":" "}] `:"- ";o.push(r+c+e(s)),i++}return o.join("\n")},mt={dependencies:[S],export:(t,e)=>{if(!$(t))return null;const n=Number(t.getTag().slice(1));return"#".repeat(n)+" "+e(t)},regExp:it,replace:gt((t=>{const e="h"+t[1].length;return I(e)})),type:"element"},ht={dependencies:[b],export:(t,e)=>{if(!v(t))return null;const n=e(t).split("\n"),o=[];for(const t of n)o.push("> "+t);return o.join("\n")},regExp:st,replace:(t,e,n,o)=>{if(o){const n=t.getPreviousSibling();if(v(n))return n.splice(n.getChildrenSize(),0,[f(),...e]),n.select(0,0),void t.remove()}const r=F();r.append(...e),t.replace(r),r.select(0,0)},type:"element"},xt={dependencies:[k],export:t=>{if(!w(t))return null;const e=t.getTextContent();return"```"+(t.getLanguage()||"")+(e?"\n"+e:"")+"\n```"},regExpEnd:{optional:!0,regExp:ct},regExpStart:lt,replace:(t,e,n,o,r,i)=>{let s,c;if(!e&&r){if(1===r.length)o?(s=L(),c=n[1]+r[0]):(s=L(n[1]),c=r[0].startsWith(" ")?r[0].slice(1):r[0]);else{if(s=L(n[1]),0===r[0].trim().length)for(;r.length>0&&!r[0].length;)r.shift();else r[0]=r[0].startsWith(" ")?r[0].slice(1):r[0];for(;r.length>0&&!r[r.length-1].length;)r.pop();c=r.join("\n")}const e=l(c);s.append(e),t.append(s)}else e&>((t=>L(t?t[1]:void 0)))(t,e,n,i)},type:"multiline-element"},Tt={dependencies:[T,C],export:(t,e)=>h(t)?dt(t,e,0):null,regExp:ot,replace:pt("bullet"),type:"element"},Ct={dependencies:[T,C],export:(t,e)=>h(t)?dt(t,e,0):null,regExp:rt,replace:pt("check"),type:"element"},Et={dependencies:[T,C],export:(t,e)=>h(t)?dt(t,e,0):null,regExp:nt,replace:pt("number"),type:"element"},yt={format:["code"],tag:"`",type:"text-format"},vt={format:["highlight"],tag:"==",type:"text-format"},St={format:["bold","italic"],tag:"***",type:"text-format"},$t={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},bt={format:["bold"],tag:"**",type:"text-format"},Ft={format:["bold"],intraword:!1,tag:"__",type:"text-format"},It={format:["strikethrough"],tag:"~~",type:"text-format"},Nt={format:["italic"],tag:"*",type:"text-format"},wt={format:["italic"],intraword:!1,tag:"_",type:"text-format"},kt={dependencies:[P],export:(t,e,n)=>{if(!R(t)||_(t))return null;const o=t.getTitle(),r=e(t);return o?`[${r}](${t.getURL()} "${o}")`:`[${r}](${t.getURL()})`},importRegExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,e)=>{const[,n,o,r]=e,i=B(o,{title:r}),s=l(n);return s.setFormat(t.getFormat()),i.append(s),t.replace(i),s},trigger:")",type:"text-match"};const Lt=[mt,ht,Tt,Et],Pt=[xt],Rt=[yt,St,$t,bt,Ft,vt,Nt,wt,It],_t=[kt],Bt=[...Lt,...Pt,...Rt,..._t];function Mt(t,e=Bt,n,o=!1,r=!1){const i=o?t:function(t,e=!1){const n=t.split("\n");let o=!1;const r=[];for(let t=0;t<n.length;t++){const i=n[t],s=r[r.length-1];ft.test(i)?r.push(i):lt.test(i)||ct.test(i)?(o=!o,r.push(i)):o||""===i||""===s||!s||it.test(s)||it.test(i)||st.test(i)||nt.test(i)||ot.test(i)||rt.test(i)||at.test(i)||ut.test(i)||!e?r.push(i):r[r.length-1]=s+i}return r.join("\n")}(t,r);return Q(e,o)(i,n)}function jt(t=Bt,e,o=!1){const r=function(t,e=!1){const o=j(t),r=[...o.multilineElement,...o.element],i=!e,s=o.textFormat.filter((t=>1===t.format.length)).sort(((t,e)=>Number(t.format.includes("code"))-Number(e.format.includes("code"))));return t=>{const e=[],l=(t||n()).getChildren();for(let t=0;t<l.length;t++){const n=l[t],c=W(n,r,s,o.textMatch);null!=c&&e.push(i&&t>0&&!U(n)&&!U(l[t-1])?"\n".concat(c):c)}return e.join("\n")}}(t,o);return r(e)}export{Mt as $convertFromMarkdownString,jt as $convertToMarkdownString,St as BOLD_ITALIC_STAR,$t as BOLD_ITALIC_UNDERSCORE,bt as BOLD_STAR,Ft as BOLD_UNDERSCORE,Ct as CHECK_LIST,xt as CODE,Lt as ELEMENT_TRANSFORMERS,mt as HEADING,vt as HIGHLIGHT,yt as INLINE_CODE,Nt as ITALIC_STAR,wt as ITALIC_UNDERSCORE,kt as LINK,Pt as MULTILINE_ELEMENT_TRANSFORMERS,Et as ORDERED_LIST,ht as QUOTE,It as STRIKETHROUGH,Rt as TEXT_FORMAT_TRANSFORMERS,_t as TEXT_MATCH_TRANSFORMERS,Bt as TRANSFORMERS,Tt as UNORDERED_LIST,et as registerMarkdownShortcuts};
|
package/package.json
CHANGED
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
"markdown"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.31.3-nightly.
|
|
11
|
+
"version": "0.31.3-nightly.20250523.0",
|
|
12
12
|
"main": "LexicalMarkdown.js",
|
|
13
13
|
"types": "index.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@lexical/code": "0.31.3-nightly.
|
|
16
|
-
"@lexical/link": "0.31.3-nightly.
|
|
17
|
-
"@lexical/list": "0.31.3-nightly.
|
|
18
|
-
"@lexical/rich-text": "0.31.3-nightly.
|
|
19
|
-
"@lexical/text": "0.31.3-nightly.
|
|
20
|
-
"@lexical/utils": "0.31.3-nightly.
|
|
21
|
-
"lexical": "0.31.3-nightly.
|
|
15
|
+
"@lexical/code": "0.31.3-nightly.20250523.0",
|
|
16
|
+
"@lexical/link": "0.31.3-nightly.20250523.0",
|
|
17
|
+
"@lexical/list": "0.31.3-nightly.20250523.0",
|
|
18
|
+
"@lexical/rich-text": "0.31.3-nightly.20250523.0",
|
|
19
|
+
"@lexical/text": "0.31.3-nightly.20250523.0",
|
|
20
|
+
"@lexical/utils": "0.31.3-nightly.20250523.0",
|
|
21
|
+
"lexical": "0.31.3-nightly.20250523.0"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
package/utils.d.ts
CHANGED
|
@@ -30,12 +30,4 @@ export declare function transformersByType(transformers: Array<Transformer>): Re
|
|
|
30
30
|
}>;
|
|
31
31
|
export declare const PUNCTUATION_OR_SPACE: RegExp;
|
|
32
32
|
export declare function isEmptyParagraph(node: LexicalNode): boolean;
|
|
33
|
-
export declare const PHONE_NUMBER_REGEX: RegExp;
|
|
34
|
-
/**
|
|
35
|
-
* Formats a URL string by adding appropriate protocol if missing
|
|
36
|
-
*
|
|
37
|
-
* @param url - URL to format
|
|
38
|
-
* @returns Formatted URL with appropriate protocol
|
|
39
|
-
*/
|
|
40
|
-
export declare function formatUrl(url: string): string;
|
|
41
33
|
export {};
|