@lexical/markdown
Advanced tools
Comparing version 0.9.1 to 0.9.2
@@ -274,2 +274,6 @@ /** | ||
} | ||
if (lexical.$getSelection() !== null) { | ||
root.selectEnd(); | ||
} | ||
}; | ||
@@ -1064,3 +1068,4 @@ } | ||
const linkContent = `[${node.getTextContent()}](${node.getURL()})`; | ||
const title = node.getTitle(); | ||
const linkContent = title ? `[${node.getTextContent()}](${node.getURL()} "${title}")` : `[${node.getTextContent()}](${node.getURL()})`; | ||
const firstChild = node.getFirstChild(); // Add text styles only if link has single text node inside. If it's more | ||
@@ -1075,7 +1080,9 @@ // then one we ignore it as markdown does not support nested styles for links | ||
}, | ||
importRegExp: /(?:\[([^[]+)\])(?:\(([^()]+)\))/, | ||
regExp: /(?:\[([^[]+)\])(?:\(([^()]+)\))$/, | ||
importRegExp: /(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/, | ||
regExp: /(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/, | ||
replace: (textNode, match) => { | ||
const [, linkText, linkUrl] = match; | ||
const linkNode = link.$createLinkNode(linkUrl); | ||
const [, linkText, linkUrl, linkTitle] = match; | ||
const linkNode = link.$createLinkNode(linkUrl, { | ||
title: linkTitle | ||
}); | ||
const linkTextNode = lexical.$createTextNode(linkText); | ||
@@ -1082,0 +1089,0 @@ linkTextNode.setFormat(textNode.getFormat()); |
@@ -16,3 +16,3 @@ /** | ||
l.append(y);m.append(l);for(let {regExp:x,replace:u}of w)if(m=r.match(x)){y.setTextContent(r.slice(m[0].length));u(l,[y],m,!0);break}T(y,q,k);l.isAttached()&&0<p.length&&(r=l.getPreviousSibling(),h.$isParagraphNode(r)||B.$isQuoteNode(r)||A.$isListNode(r))&&(q=r,A.$isListNode(r)&&(r=r.getLastDescendant(),q=null==r?null:aa.$findMatchingParent(r,A.$isListItemNode)),null!=q&&0<q.getTextContentSize()&&(q.splice(q.getChildrenSize(),0,[h.$createLineBreakNode(),...l.getChildren()]),l.remove()))}}d=e.getChildren(); | ||
for(let g of d)d=g,h.$isParagraphNode(d)?(f=d.getFirstChild(),d=null==f||1===d.getChildrenSize()&&h.$isTextNode(f)&&fa.test(f.getTextContent())):d=!1,d&&g.remove()}} | ||
for(let g of d)d=g,h.$isParagraphNode(d)?(f=d.getFirstChild(),d=null==f||1===d.getChildrenSize()&&h.$isTextNode(f)&&fa.test(f.getTextContent())):d=!1,d&&g.remove();null!==h.$getSelection()&&e.selectEnd()}} | ||
function T(a,b,c){var d=a.getTextContent();let e=ja(d,b);if(e){var f,l;if(e[0]===d)var k=a;else{d=e.index||0;let p=d+e[0].length;0===d?[k,f]=a.splitText(p):[l,k,f]=a.splitText(d,p)}k.setTextContent(e[2]);if(a=b.transformersByTag[e[1]])for(let p of a.format)k.hasFormat(p)||k.toggleFormat(p);k.hasFormat("code")||T(k,b,c);l&&T(l,b,c);f&&T(f,b,c)}else U(a,c)} | ||
@@ -28,5 +28,5 @@ function U(a,b){a:for(;a;){for(let c of b){let d=a.getTextContent().match(c.importRegExp);if(!d)continue;let e=d.index||0,f=e+d[0].length,l,k,p;0===e?[l,a]=a.splitText(f):[k,l,p]=a.splitText(e,f);k&&U(k,b);p&&(a=p);c.replace(l,d);continue a}break}} | ||
b)=>A.$isListNode(a)?Y(a,b,0):null,regExp:/^(\s*)(\d{1,})\.\s/,replace:X("number"),type:"element"},ra={format:["code"],tag:"`",type:"text-format"},sa={format:["highlight"],tag:"==",type:"text-format"},ta={format:["bold","italic"],tag:"***",type:"text-format"},va={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},wa={format:["bold"],tag:"**",type:"text-format"},xa={format:["bold"],intraword:!1,tag:"__",type:"text-format"},ya={format:["strikethrough"],tag:"~~",type:"text-format"}, | ||
za={format:["italic"],tag:"*",type:"text-format"},Aa={format:["italic"],intraword:!1,tag:"_",type:"text-format"},Ba={dependencies:[G.LinkNode],export:(a,b,c)=>{if(!G.$isLinkNode(a))return null;b=`[${a.getTextContent()}](${a.getURL()})`;const d=a.getFirstChild();return 1===a.getChildrenSize()&&h.$isTextNode(d)?c(d,b):b},importRegExp:/(?:\[([^[]+)\])(?:\(([^()]+)\))/,regExp:/(?:\[([^[]+)\])(?:\(([^()]+)\))$/,replace:(a,b)=>{const [,c,d]=b;b=G.$createLinkNode(d);const e=h.$createTextNode(c);e.setFormat(a.getFormat()); | ||
b.append(e);a.replace(b)},trigger:")",type:"text-match"},Ca=[la,ma,na,oa,qa],Da=[ra,ta,va,wa,xa,sa,za,Aa,ya],Ea=[Ba],Z=[...Ca,...Da,...Ea];exports.$convertFromMarkdownString=function(a,b=Z,c){return ha(b)(a,c)};exports.$convertToMarkdownString=function(a=Z,b){return ba(a)(b)};exports.BOLD_ITALIC_STAR=ta;exports.BOLD_ITALIC_UNDERSCORE=va;exports.BOLD_STAR=wa;exports.BOLD_UNDERSCORE=xa;exports.CHECK_LIST=pa;exports.CODE=na;exports.ELEMENT_TRANSFORMERS=Ca;exports.HEADING=la;exports.HIGHLIGHT=sa; | ||
exports.INLINE_CODE=ra;exports.ITALIC_STAR=za;exports.ITALIC_UNDERSCORE=Aa;exports.LINK=Ba;exports.ORDERED_LIST=qa;exports.QUOTE=ma;exports.STRIKETHROUGH=ya;exports.TEXT_FORMAT_TRANSFORMERS=Da;exports.TEXT_MATCH_TRANSFORMERS=Ea;exports.TRANSFORMERS=Z;exports.UNORDERED_LIST=oa; | ||
za={format:["italic"],tag:"*",type:"text-format"},Aa={format:["italic"],intraword:!1,tag:"_",type:"text-format"},Ba={dependencies:[G.LinkNode],export:(a,b,c)=>{if(!G.$isLinkNode(a))return null;b=(b=a.getTitle())?`[${a.getTextContent()}](${a.getURL()} "${b}")`:`[${a.getTextContent()}](${a.getURL()})`;const d=a.getFirstChild();return 1===a.getChildrenSize()&&h.$isTextNode(d)?c(d,b):b},importRegExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/, | ||
replace:(a,b)=>{const [,c,d,e]=b;b=G.$createLinkNode(d,{title:e});const f=h.$createTextNode(c);f.setFormat(a.getFormat());b.append(f);a.replace(b)},trigger:")",type:"text-match"},Ca=[la,ma,na,oa,qa],Da=[ra,ta,va,wa,xa,sa,za,Aa,ya],Ea=[Ba],Z=[...Ca,...Da,...Ea];exports.$convertFromMarkdownString=function(a,b=Z,c){return ha(b)(a,c)};exports.$convertToMarkdownString=function(a=Z,b){return ba(a)(b)};exports.BOLD_ITALIC_STAR=ta;exports.BOLD_ITALIC_UNDERSCORE=va;exports.BOLD_STAR=wa; | ||
exports.BOLD_UNDERSCORE=xa;exports.CHECK_LIST=pa;exports.CODE=na;exports.ELEMENT_TRANSFORMERS=Ca;exports.HEADING=la;exports.HIGHLIGHT=sa;exports.INLINE_CODE=ra;exports.ITALIC_STAR=za;exports.ITALIC_UNDERSCORE=Aa;exports.LINK=Ba;exports.ORDERED_LIST=qa;exports.QUOTE=ma;exports.STRIKETHROUGH=ya;exports.TEXT_FORMAT_TRANSFORMERS=Da;exports.TEXT_MATCH_TRANSFORMERS=Ea;exports.TRANSFORMERS=Z;exports.UNORDERED_LIST=oa; | ||
exports.registerMarkdownShortcuts=function(a,b=Z){let c=I(b),d=H(c.textFormat,({tag:f})=>f[f.length-1]),e=H(c.textMatch,({trigger:f})=>f);for(let f of b)if(b=f.type,("element"===b||"text-match"===b)&&!a.hasNodes(f.dependencies))throw Error("Minified Lexical error #79; visit https://lexical.dev/docs/error?code=79 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return a.registerUpdateListener(({tags:f,dirtyLeaves:l,editorState:k,prevEditorState:p})=> | ||
@@ -33,0 +33,0 @@ {if(!f.has("historic")){var r=k.read(h.$getSelection);f=p.read(h.$getSelection);if(h.$isRangeSelection(f)&&h.$isRangeSelection(r)&&r.isCollapsed()){p=r.anchor.key;var y=r.anchor.offset,q=k._nodeMap.get(p);h.$isTextNode(q)&&l.has(p)&&(1===y||y===f.anchor.offset+1)&&a.update(()=>{if(!q.hasFormat("code")){var m=q.getParent();if(null!==m&&!t.$isCodeNode(m)){var w=r.anchor.offset;b:{var g=c.element,n=m.getParent();if(h.$isRootOrShadowRoot(n)&&m.getFirstChild()===q&&(n=q.getTextContent()," "===n[w-1]))for(let {regExp:D, |
@@ -11,14 +11,14 @@ { | ||
"license": "MIT", | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"main": "LexicalMarkdown.js", | ||
"peerDependencies": { | ||
"lexical": "0.9.1" | ||
"lexical": "0.9.2" | ||
}, | ||
"dependencies": { | ||
"@lexical/utils": "0.9.1", | ||
"@lexical/code": "0.9.1", | ||
"@lexical/text": "0.9.1", | ||
"@lexical/rich-text": "0.9.1", | ||
"@lexical/list": "0.9.1", | ||
"@lexical/link": "0.9.1" | ||
"@lexical/utils": "0.9.2", | ||
"@lexical/code": "0.9.2", | ||
"@lexical/text": "0.9.2", | ||
"@lexical/rich-text": "0.9.2", | ||
"@lexical/list": "0.9.2", | ||
"@lexical/link": "0.9.2" | ||
}, | ||
@@ -25,0 +25,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63255
1122
+ Added@lexical/clipboard@0.9.2(transitive)
+ Added@lexical/code@0.9.2(transitive)
+ Added@lexical/html@0.9.2(transitive)
+ Added@lexical/link@0.9.2(transitive)
+ Added@lexical/list@0.9.2(transitive)
+ Added@lexical/rich-text@0.9.2(transitive)
+ Added@lexical/selection@0.9.2(transitive)
+ Added@lexical/table@0.9.2(transitive)
+ Added@lexical/text@0.9.2(transitive)
+ Added@lexical/utils@0.9.2(transitive)
+ Addedlexical@0.9.2(transitive)
- Removed@lexical/clipboard@0.9.1(transitive)
- Removed@lexical/code@0.9.1(transitive)
- Removed@lexical/html@0.9.1(transitive)
- Removed@lexical/link@0.9.1(transitive)
- Removed@lexical/list@0.9.1(transitive)
- Removed@lexical/rich-text@0.9.1(transitive)
- Removed@lexical/selection@0.9.1(transitive)
- Removed@lexical/table@0.9.1(transitive)
- Removed@lexical/text@0.9.1(transitive)
- Removed@lexical/utils@0.9.1(transitive)
- Removedlexical@0.9.1(transitive)
Updated@lexical/code@0.9.2
Updated@lexical/link@0.9.2
Updated@lexical/list@0.9.2
Updated@lexical/rich-text@0.9.2
Updated@lexical/text@0.9.2
Updated@lexical/utils@0.9.2