Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/markdown

Package Overview
Dependencies
Maintainers
0
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/markdown - npm Package Compare versions

Comparing version 0.19.1-nightly.20241105.0 to 0.19.1-nightly.20241106.0

5

LexicalMarkdown.dev.js

@@ -479,3 +479,6 @@ /**

const startIndex = match.index || 0;
const endIndex = startIndex + match[0].length;
const endIndex = transformer.getEndIndex ? transformer.getEndIndex(textNode, match) : startIndex + match[0].length;
if (endIndex === false) {
continue;
}
let replaceNode, newTextNode;

@@ -482,0 +485,0 @@ if (startIndex === 0) {

42

LexicalMarkdown.prod.js

@@ -10,34 +10,34 @@ /**

'use strict';var p=require("lexical"),z=require("@lexical/list"),E=require("@lexical/rich-text"),aa=require("@lexical/utils"),F=require("@lexical/code"),G=require("@lexical/link");function I(a,c){let b={};for(let f of a)(a=c(f))&&(b[a]?b[a].push(f):b[a]=[f]);return b}function J(a){a=I(a,c=>c.type);return{element:a.element||[],multilineElement:a["multiline-element"]||[],textFormat:a["text-format"]||[],textMatch:a["text-match"]||[]}}let K=/[!-/:-@[-`{-~\s]/,ba=/^\s{0,3}$/;
function L(a){if(!p.$isParagraphNode(a))return!1;let c=a.getFirstChild();return null==c||1===a.getChildrenSize()&&p.$isTextNode(c)&&ba.test(c.getTextContent())}function ca(a,c=!1){let b=J(a),f=[...b.multilineElement,...b.element],d=!c,e=b.textFormat.filter(g=>1===g.format.length);return g=>{let n=[];g=(g||p.$getRoot()).getChildren();for(let h=0;h<g.length;h++){let t=g[h],y=da(t,f,e,b.textMatch);null!=y&&n.push(d&&0<h&&!L(t)&&!L(g[h-1])?"\n".concat(y):y)}return n.join("\n")}}
function da(a,c,b,f){for(let d of c)if(d.export&&(c=d.export(a,e=>M(e,b,f)),null!=c))return c;return p.$isElementNode(a)?M(a,b,f):p.$isDecoratorNode(a)?a.getTextContent():null}
function M(a,c,b){let f=[];a=a.getChildren();a:for(let d of a){for(let e of b)if(e.export&&(a=e.export(d,g=>M(g,c,b),(g,n)=>N(g,n,c)),null!=a)){f.push(a);continue a}p.$isLineBreakNode(d)?f.push("\n"):p.$isTextNode(d)?f.push(N(d,d.getTextContent(),c)):p.$isElementNode(d)?f.push(M(d,c,b)):p.$isDecoratorNode(d)&&f.push(d.getTextContent())}return f.join("")}
function N(a,c,b){let f=c.trim(),d=f,e=new Set;for(let n of b){b=n.format[0];let h=n.tag;if(O(a,b)&&!e.has(b)){e.add(b);var g=P(a,!0);O(g,b)||(d=h+d);g=P(a,!1);O(g,b)||(d+=h)}}return c.replace(f,()=>d)}
function L(a){if(!p.$isParagraphNode(a))return!1;let c=a.getFirstChild();return null==c||1===a.getChildrenSize()&&p.$isTextNode(c)&&ba.test(c.getTextContent())}function ca(a,c=!1){let b=J(a),f=[...b.multilineElement,...b.element],e=!c,d=b.textFormat.filter(g=>1===g.format.length);return g=>{let n=[];g=(g||p.$getRoot()).getChildren();for(let h=0;h<g.length;h++){let t=g[h],y=da(t,f,d,b.textMatch);null!=y&&n.push(e&&0<h&&!L(t)&&!L(g[h-1])?"\n".concat(y):y)}return n.join("\n")}}
function da(a,c,b,f){for(let e of c)if(e.export&&(c=e.export(a,d=>M(d,b,f)),null!=c))return c;return p.$isElementNode(a)?M(a,b,f):p.$isDecoratorNode(a)?a.getTextContent():null}
function M(a,c,b){let f=[];a=a.getChildren();a:for(let e of a){for(let d of b)if(d.export&&(a=d.export(e,g=>M(g,c,b),(g,n)=>N(g,n,c)),null!=a)){f.push(a);continue a}p.$isLineBreakNode(e)?f.push("\n"):p.$isTextNode(e)?f.push(N(e,e.getTextContent(),c)):p.$isElementNode(e)?f.push(M(e,c,b)):p.$isDecoratorNode(e)&&f.push(e.getTextContent())}return f.join("")}
function N(a,c,b){let f=c.trim(),e=f,d=new Set;for(let n of b){b=n.format[0];let h=n.tag;if(O(a,b)&&!d.has(b)){d.add(b);var g=P(a,!0);O(g,b)||(e=h+e);g=P(a,!1);O(g,b)||(e+=h)}}return c.replace(f,()=>e)}
function P(a,c){let b=c?a.getPreviousSibling():a.getNextSibling();b||(a=a.getParentOrThrow(),a.isInline()&&(b=c?a.getPreviousSibling():a.getNextSibling()));for(;b;){if(p.$isElementNode(b)){if(!b.isInline())break;a=c?b.getLastDescendant():b.getFirstDescendant();if(p.$isTextNode(a))return a;b=c?b.getPreviousSibling():b.getNextSibling()}if(p.$isTextNode(b))return b;if(!p.$isElementNode(b))break}return null}function O(a,c){return p.$isTextNode(a)&&a.hasFormat(c)}
let Q="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,ea=Q&&"documentMode"in document?document.documentMode:null;Q&&"InputEvent"in window&&!ea?"getTargetRanges"in new window.InputEvent("input"):!1;
let R=Q&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),S=Q&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,fa=Q&&/^(?=.*Chrome).*/i.test(navigator.userAgent),T=Q&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!fa;
function ha(a,c=!1){let b=J(a),f=ia(b.textFormat);return(d,e)=>{d=d.split("\n");let g=d.length;e=e||p.$getRoot();e.clear();for(let u=0;u<g;u++){var n=d[u];a:{var h=d;var t=u,y=b.multilineElement,w=e;for(var q of y){let {handleImportAfterStartMatch:B,regExpEnd:x,regExpStart:A,replace:H}=q;if(y=h[t].match(A)){if(B){var m=B({lines:h,rootNode:w,startLineIndex:t,startMatch:y,transformer:q});if(null===m)continue;else if(m){h=m;break a}}var l="object"===typeof x&&"regExp"in x?x.regExp:x,k=x&&"object"===
typeof x&&"optional"in x?x.optional:!x;m=t;for(var r=h.length;m<r;){var v=l?h[m].match(l):null;if(v||k&&!(k&&m<r-1))if(v&&t===m&&v.index===y.index)m++;else{l=[];if(v&&t===m)l.push(h[t].slice(y[0].length,-v[0].length));else for(k=t;k<=m;k++)k===t?(r=h[k].slice(y[0].length),l.push(r)):k===m&&v?(r=h[k].slice(0,-v[0].length),l.push(r)):l.push(h[k]);if(!1!==H(w,null,y,v,l,!0)){h=[!0,m];break a}break}else m++}}}h=[!1,t]}let [D,C]=h;if(D)u=C;else{h=n;m=e;v=b.element;t=f;w=b.textMatch;y=p.$createTextNode(h);
function ha(a,c=!1){let b=J(a),f=ia(b.textFormat);return(e,d)=>{e=e.split("\n");let g=e.length;d=d||p.$getRoot();d.clear();for(let u=0;u<g;u++){var n=e[u];a:{var h=e;var t=u,y=b.multilineElement,w=d;for(var q of y){let {handleImportAfterStartMatch:B,regExpEnd:x,regExpStart:A,replace:H}=q;if(y=h[t].match(A)){if(B){var m=B({lines:h,rootNode:w,startLineIndex:t,startMatch:y,transformer:q});if(null===m)continue;else if(m){h=m;break a}}var l="object"===typeof x&&"regExp"in x?x.regExp:x,k=x&&"object"===
typeof x&&"optional"in x?x.optional:!x;m=t;for(var r=h.length;m<r;){var v=l?h[m].match(l):null;if(v||k&&!(k&&m<r-1))if(v&&t===m&&v.index===y.index)m++;else{l=[];if(v&&t===m)l.push(h[t].slice(y[0].length,-v[0].length));else for(k=t;k<=m;k++)k===t?(r=h[k].slice(y[0].length),l.push(r)):k===m&&v?(r=h[k].slice(0,-v[0].length),l.push(r)):l.push(h[k]);if(!1!==H(w,null,y,v,l,!0)){h=[!0,m];break a}break}else m++}}}h=[!1,t]}let [D,C]=h;if(D)u=C;else{h=n;m=d;v=b.element;t=f;w=b.textMatch;y=p.$createTextNode(h);
n=p.$createParagraphNode();n.append(y);m.append(n);for(let {regExp:B,replace:x}of v)if(m=h.match(B))if(y.setTextContent(h.slice(m[0].length)),!1!==x(n,[y],m,!0))break;U(y,t,w);n.isAttached()&&0<h.length&&(h=n.getPreviousSibling(),p.$isParagraphNode(h)||E.$isQuoteNode(h)||z.$isListNode(h))&&(t=h,z.$isListNode(h)&&(h=h.getLastDescendant(),t=null==h?null:aa.$findMatchingParent(h,z.$isListItemNode)),null!=t&&0<t.getTextContentSize()&&(t.splice(t.getChildrenSize(),0,[p.$createLineBreakNode(),...n.getChildren()]),
n.remove()))}}q=e.getChildren();for(let u of q)!c&&L(u)&&1<e.getChildrenSize()&&u.remove();null!==p.$getSelection()&&e.selectStart()}}function U(a,c,b){var f=a.getTextContent();let d=ja(f,c);if(d){var e,g;if(d[0]===f)var n=a;else{f=d.index||0;let h=f+d[0].length;0===f?[n,e]=a.splitText(h):[g,n,e]=a.splitText(f,h)}n.setTextContent(d[2]);if(a=c.transformersByTag[d[1]])for(let h of a.format)n.hasFormat(h)||n.toggleFormat(h);n.hasFormat("code")||U(n,c,b);g&&U(g,c,b);e&&U(e,c,b)}else ka(a,b)}
function ka(a,c){a:for(;a;){for(let b of c){if(!b.replace||!b.importRegExp)continue;let f=a.getTextContent().match(b.importRegExp);if(!f)continue;let d=f.index||0,e=d+f[0].length,g,n;0===d?[g,a]=a.splitText(e):[,g,n]=a.splitText(d,e);n&&ka(n,c);b.replace(g,f);continue a}break}}
function ja(a,c){var b=a.match(c.openTagsRegExp);if(null==b)return null;for(let e of b){var f=e.replace(/^\s/,"");b=c.fullMatchRegExpByTag[f];if(null!=b&&(b=a.match(b),f=c.transformersByTag[f],null!=b&&null!=f)){if(!1!==f.intraword)return b;var {index:d=0}=b;f=a[d-1];d=a[d+b[0].length];if(!(f&&!K.test(f)||d&&!K.test(d)))return b}}return null}
function ia(a){let c={},b={},f=[];for(let d of a){({tag:a}=d);c[a]=d;let e=a.replace(/(\*|\^|\+)/g,"\\$1");f.push(e);b[a]=R||S||T?new RegExp(`(${e})(?![${e}\\s])(.*?[^${e}\\s])${e}(?!${e})`):new RegExp(`(?<![\\\\${e}])(${e})((\\\\${e})?.*?[^${e}\\s](\\\\${e})?)((?<!\\\\)|(?<=\\\\\\\\))(${e})(?![\\\\${e}])`)}return{fullMatchRegExpByTag:b,openTagsRegExp:new RegExp((R||S||T?"":"(?<![\\\\])")+"("+f.join("|")+")","g"),transformersByTag:c}}var la;
n.remove()))}}q=d.getChildren();for(let u of q)!c&&L(u)&&1<d.getChildrenSize()&&u.remove();null!==p.$getSelection()&&d.selectStart()}}function U(a,c,b){var f=a.getTextContent();let e=ja(f,c);if(e){var d,g;if(e[0]===f)var n=a;else{f=e.index||0;let h=f+e[0].length;0===f?[n,d]=a.splitText(h):[g,n,d]=a.splitText(f,h)}n.setTextContent(e[2]);if(a=c.transformersByTag[e[1]])for(let h of a.format)n.hasFormat(h)||n.toggleFormat(h);n.hasFormat("code")||U(n,c,b);g&&U(g,c,b);d&&U(d,c,b)}else ka(a,b)}
function ka(a,c){a:for(;a;){for(let b of c){if(!b.replace||!b.importRegExp)continue;let f=a.getTextContent().match(b.importRegExp);if(!f)continue;let e=f.index||0,d=b.getEndIndex?b.getEndIndex(a,f):e+f[0].length;if(!1===d)continue;let g,n;0===e?[g,a]=a.splitText(d):[,g,n]=a.splitText(e,d);n&&ka(n,c);b.replace(g,f);continue a}break}}
function ja(a,c){var b=a.match(c.openTagsRegExp);if(null==b)return null;for(let d of b){var f=d.replace(/^\s/,"");b=c.fullMatchRegExpByTag[f];if(null!=b&&(b=a.match(b),f=c.transformersByTag[f],null!=b&&null!=f)){if(!1!==f.intraword)return b;var {index:e=0}=b;f=a[e-1];e=a[e+b[0].length];if(!(f&&!K.test(f)||e&&!K.test(e)))return b}}return null}
function ia(a){let c={},b={},f=[];for(let e of a){({tag:a}=e);c[a]=e;let d=a.replace(/(\*|\^|\+)/g,"\\$1");f.push(d);b[a]=R||S||T?new RegExp(`(${d})(?![${d}\\s])(.*?[^${d}\\s])${d}(?!${d})`):new RegExp(`(?<![\\\\${d}])(${d})((\\\\${d})?.*?[^${d}\\s](\\\\${d})?)((?<!\\\\)|(?<=\\\\\\\\))(${d})(?![\\\\${d}])`)}return{fullMatchRegExpByTag:b,openTagsRegExp:new RegExp((R||S||T?"":"(?<![\\\\])")+"("+f.join("|")+")","g"),transformersByTag:c}}var la;
function V(a){let c=new URLSearchParams;c.append("code",a);for(let b=1;b<arguments.length;b++)c.append("v",arguments[b]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${c} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}la=V&&V.__esModule&&Object.prototype.hasOwnProperty.call(V,"default")?V["default"]:V;
function ma(a,c,b){let f=b.length;for(;c>=f;c--){let d=c-f;if(na(a,d,b,0,f)&&" "!==a[d+f])return d}return-1}function na(a,c,b,f,d){for(let e=0;e<d;e++)if(a[c+e]!==b[f+e])return!1;return!0}
let oa=/^(\s*)(\d{1,})\.\s/,pa=/^(\s*)[-*+]\s/,qa=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,W=/^(#{1,6})\s/,ra=/^>\s/,sa=/^[ \t]*```(\w+)?/,ta=/[ \t]*```$/,ua=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,va=/^(?:\|)(.+)(?:\|)\s?$/,wa=/^(\| ?:?-*:? ?)+\|\s?$/,xa=a=>(c,b,f)=>{f=a(f);f.append(...b);c.replace(f);f.select(0,0)},X=a=>(c,b,f)=>{var d=c.getPreviousSibling(),e=c.getNextSibling();const g=z.$createListItemNode("check"===a?"x"===f[3]:void 0);z.$isListNode(e)&&e.getListType()===a?(d=e.getFirstChild(),
null!==d?d.insertBefore(g):e.append(g),c.remove()):z.$isListNode(d)&&d.getListType()===a?(d.append(g),c.remove()):(e=z.$createListNode(a,"number"===a?Number(f[2]):void 0),e.append(g),c.replace(e));g.append(...b);g.select(0,0);b=f[1];c=b.match(/\t/g);b=b.match(/ /g);f=0;c&&(f+=c.length);b&&(f+=Math.floor(b.length/4));(c=f)&&g.setIndent(c)},Y=(a,c,b)=>{const f=[];var d=a.getChildren();let e=0;for(const n of d)if(z.$isListItemNode(n)){if(1===n.getChildrenSize()&&(d=n.getFirstChild(),z.$isListNode(d))){f.push(Y(d,
c,b+1));continue}d=" ".repeat(4*b);var g=a.getListType();g="number"===g?`${a.getStart()+e}. `:"check"===g?`- [${n.getChecked()?"x":" "}] `:"- ";f.push(d+g+c(n));e++}return f.join("\n")},ya={dependencies:[E.HeadingNode],export:(a,c)=>{if(!E.$isHeadingNode(a))return null;const b=Number(a.getTag().slice(1));return"#".repeat(b)+" "+c(a)},regExp:W,replace:xa(a=>E.$createHeadingNode("h"+a[1].length)),type:"element"},za={dependencies:[E.QuoteNode],export:(a,c)=>{if(!E.$isQuoteNode(a))return null;a=c(a).split("\n");
function ma(a,c,b){let f=b.length;for(;c>=f;c--){let e=c-f;if(na(a,e,b,0,f)&&" "!==a[e+f])return e}return-1}function na(a,c,b,f,e){for(let d=0;d<e;d++)if(a[c+d]!==b[f+d])return!1;return!0}
let oa=/^(\s*)(\d{1,})\.\s/,pa=/^(\s*)[-*+]\s/,qa=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,W=/^(#{1,6})\s/,ra=/^>\s/,sa=/^[ \t]*```(\w+)?/,ta=/[ \t]*```$/,ua=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,va=/^(?:\|)(.+)(?:\|)\s?$/,wa=/^(\| ?:?-*:? ?)+\|\s?$/,xa=a=>(c,b,f)=>{f=a(f);f.append(...b);c.replace(f);f.select(0,0)},X=a=>(c,b,f)=>{var e=c.getPreviousSibling(),d=c.getNextSibling();const g=z.$createListItemNode("check"===a?"x"===f[3]:void 0);z.$isListNode(d)&&d.getListType()===a?(e=d.getFirstChild(),
null!==e?e.insertBefore(g):d.append(g),c.remove()):z.$isListNode(e)&&e.getListType()===a?(e.append(g),c.remove()):(d=z.$createListNode(a,"number"===a?Number(f[2]):void 0),d.append(g),c.replace(d));g.append(...b);g.select(0,0);b=f[1];c=b.match(/\t/g);b=b.match(/ /g);f=0;c&&(f+=c.length);b&&(f+=Math.floor(b.length/4));(c=f)&&g.setIndent(c)},Y=(a,c,b)=>{const f=[];var e=a.getChildren();let d=0;for(const n of e)if(z.$isListItemNode(n)){if(1===n.getChildrenSize()&&(e=n.getFirstChild(),z.$isListNode(e))){f.push(Y(e,
c,b+1));continue}e=" ".repeat(4*b);var g=a.getListType();g="number"===g?`${a.getStart()+d}. `:"check"===g?`- [${n.getChecked()?"x":" "}] `:"- ";f.push(e+g+c(n));d++}return f.join("\n")},ya={dependencies:[E.HeadingNode],export:(a,c)=>{if(!E.$isHeadingNode(a))return null;const b=Number(a.getTag().slice(1));return"#".repeat(b)+" "+c(a)},regExp:W,replace:xa(a=>E.$createHeadingNode("h"+a[1].length)),type:"element"},za={dependencies:[E.QuoteNode],export:(a,c)=>{if(!E.$isQuoteNode(a))return null;a=c(a).split("\n");
c=[];for(const b of a)c.push("> "+b);return c.join("\n")},regExp:ra,replace:(a,c,b,f)=>{if(f&&(b=a.getPreviousSibling(),E.$isQuoteNode(b))){b.splice(b.getChildrenSize(),0,[p.$createLineBreakNode(),...c]);b.select(0,0);a.remove();return}b=E.$createQuoteNode();b.append(...c);a.replace(b);b.select(0,0)},type:"element"},Aa={dependencies:[F.CodeNode],export:a=>{if(!F.$isCodeNode(a))return null;const c=a.getTextContent();return"```"+(a.getLanguage()||"")+(c?"\n"+c:"")+"\n```"},regExpEnd:{optional:!0,regExp:ta},
regExpStart:sa,replace:(a,c,b,f,d,e)=>{if(!c&&d){if(1===d.length)f?(c=F.$createCodeNode(),b=b[1]+d[0]):(c=F.$createCodeNode(b[1]),b=d[0].startsWith(" ")?d[0].slice(1):d[0]);else{c=F.$createCodeNode(b[1]);if(0===d[0].trim().length)for(;0<d.length&&!d[0].length;)d.shift();else d[0]=d[0].startsWith(" ")?d[0].slice(1):d[0];for(;0<d.length&&!d[d.length-1].length;)d.pop();b=d.join("\n")}b=p.$createTextNode(b);c.append(b);a.append(c)}else c&&xa(g=>F.$createCodeNode(g?g[1]:void 0))(a,c,b,e)},type:"multiline-element"},
regExpStart:sa,replace:(a,c,b,f,e,d)=>{if(!c&&e){if(1===e.length)f?(c=F.$createCodeNode(),b=b[1]+e[0]):(c=F.$createCodeNode(b[1]),b=e[0].startsWith(" ")?e[0].slice(1):e[0]);else{c=F.$createCodeNode(b[1]);if(0===e[0].trim().length)for(;0<e.length&&!e[0].length;)e.shift();else e[0]=e[0].startsWith(" ")?e[0].slice(1):e[0];for(;0<e.length&&!e[e.length-1].length;)e.pop();b=e.join("\n")}b=p.$createTextNode(b);c.append(b);a.append(c)}else c&&xa(g=>F.$createCodeNode(g?g[1]:void 0))(a,c,b,d)},type:"multiline-element"},
Ba={dependencies:[z.ListNode,z.ListItemNode],export:(a,c)=>z.$isListNode(a)?Y(a,c,0):null,regExp:pa,replace:X("bullet"),type:"element"},Ca={dependencies:[z.ListNode,z.ListItemNode],export:(a,c)=>z.$isListNode(a)?Y(a,c,0):null,regExp:qa,replace:X("check"),type:"element"},Da={dependencies:[z.ListNode,z.ListItemNode],export:(a,c)=>z.$isListNode(a)?Y(a,c,0):null,regExp:oa,replace:X("number"),type:"element"},Ea={format:["code"],tag:"`",type:"text-format"},Ga={format:["highlight"],tag:"==",type:"text-format"},
Ha={format:["bold","italic"],tag:"***",type:"text-format"},Ia={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},Ja={format:["bold"],tag:"**",type:"text-format"},Ka={format:["bold"],intraword:!1,tag:"__",type:"text-format"},La={format:["strikethrough"],tag:"~~",type:"text-format"},Ma={format:["italic"],tag:"*",type:"text-format"},Na={format:["italic"],intraword:!1,tag:"_",type:"text-format"},Oa={dependencies:[G.LinkNode],export:(a,c,b)=>{if(!G.$isLinkNode(a))return null;c=(c=a.getTitle())?
`[${a.getTextContent()}](${a.getURL()} "${c}")`:`[${a.getTextContent()}](${a.getURL()})`;const f=a.getFirstChild();return 1===a.getChildrenSize()&&p.$isTextNode(f)?b(f,c):c},importRegExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(a,c)=>{const [,b,f,d]=c;c=G.$createLinkNode(f,{title:d});const e=p.$createTextNode(b);e.setFormat(a.getFormat());c.append(e);a.replace(c)},trigger:")",type:"text-match"};
function Pa(a,c=!1){a=a.split("\n");let b=!1,f=[];for(let d=0;d<a.length;d++){let e=a[d],g=f[f.length-1];ua.test(e)?f.push(e):sa.test(e)||ta.test(e)?(b=!b,f.push(e)):b?f.push(e):""===e||""===g||!g||W.test(g)||W.test(e)||ra.test(e)||oa.test(e)||pa.test(e)||qa.test(e)||va.test(e)||wa.test(e)||!c?f.push(e):f[f.length-1]=g+e}return f.join("\n")}let Qa=[ya,za,Ba,Da],Ra=[Aa],Sa=[Ea,Ha,Ia,Ja,Ka,Ga,Ma,Na,La],Ta=[Oa],Z=[...Qa,...Ra,...Sa,...Ta];
exports.$convertFromMarkdownString=function(a,c=Z,b,f=!1,d=!1){a=f?a:Pa(a,d);return ha(c,f)(a,b)};exports.$convertToMarkdownString=function(a=Z,c,b=!1){return ca(a,b)(c)};exports.BOLD_ITALIC_STAR=Ha;exports.BOLD_ITALIC_UNDERSCORE=Ia;exports.BOLD_STAR=Ja;exports.BOLD_UNDERSCORE=Ka;exports.CHECK_LIST=Ca;exports.CODE=Aa;exports.ELEMENT_TRANSFORMERS=Qa;exports.HEADING=ya;exports.HIGHLIGHT=Ga;exports.INLINE_CODE=Ea;exports.ITALIC_STAR=Ma;exports.ITALIC_UNDERSCORE=Na;exports.LINK=Oa;
`[${a.getTextContent()}](${a.getURL()} "${c}")`:`[${a.getTextContent()}](${a.getURL()})`;const f=a.getFirstChild();return 1===a.getChildrenSize()&&p.$isTextNode(f)?b(f,c):c},importRegExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(a,c)=>{const [,b,f,e]=c;c=G.$createLinkNode(f,{title:e});const d=p.$createTextNode(b);d.setFormat(a.getFormat());c.append(d);a.replace(c)},trigger:")",type:"text-match"};
function Pa(a,c=!1){a=a.split("\n");let b=!1,f=[];for(let e=0;e<a.length;e++){let d=a[e],g=f[f.length-1];ua.test(d)?f.push(d):sa.test(d)||ta.test(d)?(b=!b,f.push(d)):b?f.push(d):""===d||""===g||!g||W.test(g)||W.test(d)||ra.test(d)||oa.test(d)||pa.test(d)||qa.test(d)||va.test(d)||wa.test(d)||!c?f.push(d):f[f.length-1]=g+d}return f.join("\n")}let Qa=[ya,za,Ba,Da],Ra=[Aa],Sa=[Ea,Ha,Ia,Ja,Ka,Ga,Ma,Na,La],Ta=[Oa],Z=[...Qa,...Ra,...Sa,...Ta];
exports.$convertFromMarkdownString=function(a,c=Z,b,f=!1,e=!1){a=f?a:Pa(a,e);return ha(c,f)(a,b)};exports.$convertToMarkdownString=function(a=Z,c,b=!1){return ca(a,b)(c)};exports.BOLD_ITALIC_STAR=Ha;exports.BOLD_ITALIC_UNDERSCORE=Ia;exports.BOLD_STAR=Ja;exports.BOLD_UNDERSCORE=Ka;exports.CHECK_LIST=Ca;exports.CODE=Aa;exports.ELEMENT_TRANSFORMERS=Qa;exports.HEADING=ya;exports.HIGHLIGHT=Ga;exports.INLINE_CODE=Ea;exports.ITALIC_STAR=Ma;exports.ITALIC_UNDERSCORE=Na;exports.LINK=Oa;
exports.MULTILINE_ELEMENT_TRANSFORMERS=Ra;exports.ORDERED_LIST=Da;exports.QUOTE=za;exports.STRIKETHROUGH=La;exports.TEXT_FORMAT_TRANSFORMERS=Sa;exports.TEXT_MATCH_TRANSFORMERS=Ta;exports.TRANSFORMERS=Z;exports.UNORDERED_LIST=Ba;
exports.registerMarkdownShortcuts=function(a,c=Z){let b=J(c),f=I(b.textFormat,({tag:e})=>e[e.length-1]),d=I(b.textMatch,({trigger:e})=>e);for(let e of c)if(c=e.type,"element"===c||"text-match"===c||"multiline-element"===c){c=e.dependencies;for(let g of c)a.hasNode(g)||la(173,g.getType())}return a.registerUpdateListener(({tags:e,dirtyLeaves:g,editorState:n,prevEditorState:h})=>{if(!e.has("collaboration")&&!e.has("historic")&&!a.isComposing()){var t=n.read(p.$getSelection);e=h.read(p.$getSelection);
if(p.$isRangeSelection(e)&&p.$isRangeSelection(t)&&t.isCollapsed()&&!t.is(e)){h=t.anchor.key;var y=t.anchor.offset,w=n._nodeMap.get(h);!p.$isTextNode(w)||!g.has(h)||1!==y&&y>e.anchor.offset+1||a.update(()=>{if(!w.hasFormat("code")){var q=w.getParent();if(null!==q&&!F.$isCodeNode(q)){var m=t.anchor.offset;b:{var l=b.element;var k=q.getParent();if(p.$isRootOrShadowRoot(k)&&q.getFirstChild()===w&&(k=w.getTextContent()," "===k[m-1]))for(let {regExp:B,replace:x}of l)if((l=k.match(B))&&l[0].length===(l[0].endsWith(" ")?
exports.registerMarkdownShortcuts=function(a,c=Z){let b=J(c),f=I(b.textFormat,({tag:d})=>d[d.length-1]),e=I(b.textMatch,({trigger:d})=>d);for(let d of c)if(c=d.type,"element"===c||"text-match"===c||"multiline-element"===c){c=d.dependencies;for(let g of c)a.hasNode(g)||la(173,g.getType())}return a.registerUpdateListener(({tags:d,dirtyLeaves:g,editorState:n,prevEditorState:h})=>{if(!d.has("collaboration")&&!d.has("historic")&&!a.isComposing()){var t=n.read(p.$getSelection);d=h.read(p.$getSelection);
if(p.$isRangeSelection(d)&&p.$isRangeSelection(t)&&t.isCollapsed()&&!t.is(d)){h=t.anchor.key;var y=t.anchor.offset,w=n._nodeMap.get(h);!p.$isTextNode(w)||!g.has(h)||1!==y&&y>d.anchor.offset+1||a.update(()=>{if(!w.hasFormat("code")){var q=w.getParent();if(null!==q&&!F.$isCodeNode(q)){var m=t.anchor.offset;b:{var l=b.element;var k=q.getParent();if(p.$isRootOrShadowRoot(k)&&q.getFirstChild()===w&&(k=w.getTextContent()," "===k[m-1]))for(let {regExp:B,replace:x}of l)if((l=k.match(B))&&l[0].length===(l[0].endsWith(" ")?
m:m-1)){var r=w.getNextSiblings();let [A,H]=w.splitText(m);A.remove();r=H?[H,...r]:r;if(!1!==x(q,r,l,!1)){k=!0;break b}}k=!1}if(!k){b:{l=b.multilineElement;k=q.getParent();if(p.$isRootOrShadowRoot(k)&&q.getFirstChild()===w&&(k=w.getTextContent()," "===k[m-1]))for(let {regExpStart:B,replace:x,regExpEnd:A}of l)if(!(A&&!("optional"in A)||A&&"optional"in A&&!A.optional)&&(l=k.match(B))&&l[0].length===(l[0].endsWith(" ")?m:m-1)){r=w.getNextSiblings();let [H,Fa]=w.splitText(m);H.remove();r=Fa?[Fa,...r]:
r;if(!1!==x(q,r,l,null,null,!1)){q=!0;break b}}q=!1}if(!q){b:{k=w.getTextContent();q=d[k[m-1]];if(null!=q){m<k.length&&(k=k.slice(0,m));for(u of q)if(u.replace&&u.regExp&&(q=k.match(u.regExp),null!==q)){k=q.index||0;l=k+q[0].length;var v=void 0;0===k?[v]=w.splitText(l):[,v]=w.splitText(k,l);v.selectNext(0,0);u.replace(v,q);var u=!0;break b}}u=!1}if(!u)b:if(l=w.getTextContent(),--m,r=l[m],u=f[r])for(let B of u){var {tag:D}=B;u=D.length;let x=m-u+1;if(!(1<u&&!na(l,x,D,0,u)||" "===l[x-1])&&(v=l[m+1],
r;if(!1!==x(q,r,l,null,null,!1)){q=!0;break b}}q=!1}if(!q){b:{k=w.getTextContent();q=e[k[m-1]];if(null!=q){m<k.length&&(k=k.slice(0,m));for(u of q)if(u.replace&&u.regExp&&(q=k.match(u.regExp),null!==q)){k=q.index||0;l=k+q[0].length;var v=void 0;0===k?[v]=w.splitText(l):[,v]=w.splitText(k,l);v.selectNext(0,0);u.replace(v,q);var u=!0;break b}}u=!1}if(!u)b:if(l=w.getTextContent(),--m,r=l[m],u=f[r])for(let B of u){var {tag:D}=B;u=D.length;let x=m-u+1;if(!(1<u&&!na(l,x,D,0,u)||" "===l[x-1])&&(v=l[m+1],
!1!==B.intraword||!v||K.test(v))){q=v=w;k=ma(l,x,D);for(var C=q;0>k&&(C=C.getPreviousSibling())&&!p.$isLineBreakNode(C);)p.$isTextNode(C)&&(k=C.getTextContent(),q=C,k=ma(k,k.length,D));if(!(0>k||q===v&&k+u===x||(D=q.getTextContent(),0<k&&D[k-1]===r||(C=D[k-1],!1===B.intraword&&C&&!K.test(C))))){l=v.getTextContent();l=l.slice(0,x)+l.slice(m+1);v.setTextContent(l);l=q===v?l:D;q.setTextContent(l.slice(0,k)+l.slice(k+u));l=p.$getSelection();r=p.$createRangeSelection();p.$setSelection(r);m=m-u*(q===v?
2:1)+1;r.anchor.set(q.__key,k,"text");r.focus.set(v.__key,m,"text");for(let A of B.format)r.hasFormat(A)||r.formatText(A);r.anchor.set(r.focus.key,r.focus.offset,r.focus.type);for(let A of B.format)r.hasFormat(A)&&r.toggleFormat(A);p.$isRangeSelection(l)&&(r.format=l.format);break b}}}}}}}})}}})}

@@ -114,2 +114,11 @@ /**

/**
* For import operations, this function can be used to determine the end index of the match, after `importRegExp` has matched.
* Without this function, the end index will be determined by the length of the match from `importRegExp`. Manually determining the end index can be useful if
* the match from `importRegExp` is not the entire text content of the node. That way, `importRegExp` can be used to match only the start of the node, and `getEndIndex`
* can be used to match the end of the node.
*
* @returns The end index of the match, or false if the match was unsuccessful and a different transformer should be tried.
*/
getEndIndex?: (node: TextNode, match: RegExpMatchArray) => number | false;
/**
* Single character that allows the transformer to trigger when typed in the editor. This does not affect markdown imports outside of the markdown shortcut plugin.

@@ -116,0 +125,0 @@ * If the trigger is matched, the `regExp` will be used to match the text in the second step.

@@ -11,13 +11,13 @@ {

"license": "MIT",
"version": "0.19.1-nightly.20241105.0",
"version": "0.19.1-nightly.20241106.0",
"main": "LexicalMarkdown.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/code": "0.19.1-nightly.20241105.0",
"@lexical/link": "0.19.1-nightly.20241105.0",
"@lexical/list": "0.19.1-nightly.20241105.0",
"@lexical/rich-text": "0.19.1-nightly.20241105.0",
"@lexical/text": "0.19.1-nightly.20241105.0",
"@lexical/utils": "0.19.1-nightly.20241105.0",
"lexical": "0.19.1-nightly.20241105.0"
"@lexical/code": "0.19.1-nightly.20241106.0",
"@lexical/link": "0.19.1-nightly.20241106.0",
"@lexical/list": "0.19.1-nightly.20241106.0",
"@lexical/rich-text": "0.19.1-nightly.20241106.0",
"@lexical/text": "0.19.1-nightly.20241106.0",
"@lexical/utils": "0.19.1-nightly.20241106.0",
"lexical": "0.19.1-nightly.20241106.0"
},

@@ -24,0 +24,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc