@lexical/markdown
Advanced tools
Comparing version 0.7.7 to 0.7.8
@@ -11,3 +11,3 @@ /** @module @lexical/markdown */ | ||
import { registerMarkdownShortcuts } from './MarkdownShortcuts'; | ||
import { BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, CHECK_LIST, CODE, HEADING, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE, LINK, ORDERED_LIST, QUOTE, STRIKETHROUGH, UNORDERED_LIST } from './MarkdownTransformers'; | ||
import { BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, CHECK_LIST, CODE, HEADING, HIGHLIGHT, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE, LINK, ORDERED_LIST, QUOTE, STRIKETHROUGH, UNORDERED_LIST } from './MarkdownTransformers'; | ||
declare const ELEMENT_TRANSFORMERS: Array<ElementTransformer>; | ||
@@ -19,2 +19,2 @@ declare const TEXT_FORMAT_TRANSFORMERS: Array<TextFormatTransformer>; | ||
declare function $convertToMarkdownString(transformers?: Array<Transformer>): string; | ||
export { $convertFromMarkdownString, $convertToMarkdownString, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, CHECK_LIST, CODE, ELEMENT_TRANSFORMERS, ElementTransformer, HEADING, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE, LINK, ORDERED_LIST, QUOTE, registerMarkdownShortcuts, STRIKETHROUGH, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS, TextFormatTransformer, TextMatchTransformer, Transformer, TRANSFORMERS, UNORDERED_LIST, }; | ||
export { $convertFromMarkdownString, $convertToMarkdownString, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, CHECK_LIST, CODE, ELEMENT_TRANSFORMERS, ElementTransformer, HEADING, HIGHLIGHT, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE, LINK, ORDERED_LIST, QUOTE, registerMarkdownShortcuts, STRIKETHROUGH, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS, TextFormatTransformer, TextMatchTransformer, Transformer, TRANSFORMERS, UNORDERED_LIST, }; |
@@ -1009,2 +1009,7 @@ /** | ||
}; | ||
const HIGHLIGHT = { | ||
format: ['highlight'], | ||
tag: '==', | ||
type: 'text-format' | ||
}; | ||
const BOLD_ITALIC_STAR = { | ||
@@ -1089,3 +1094,3 @@ format: ['bold', 'italic'], | ||
const TEXT_FORMAT_TRANSFORMERS = [INLINE_CODE, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, ITALIC_STAR, ITALIC_UNDERSCORE, STRIKETHROUGH]; | ||
const TEXT_FORMAT_TRANSFORMERS = [INLINE_CODE, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, HIGHLIGHT, ITALIC_STAR, ITALIC_UNDERSCORE, STRIKETHROUGH]; | ||
const TEXT_MATCH_TRANSFORMERS = [LINK]; | ||
@@ -1114,2 +1119,3 @@ const TRANSFORMERS = [...ELEMENT_TRANSFORMERS, ...TEXT_FORMAT_TRANSFORMERS, ...TEXT_MATCH_TRANSFORMERS]; | ||
exports.HEADING = HEADING; | ||
exports.HIGHLIGHT = HIGHLIGHT; | ||
exports.INLINE_CODE = INLINE_CODE; | ||
@@ -1116,0 +1122,0 @@ exports.ITALIC_STAR = ITALIC_STAR; |
@@ -26,10 +26,10 @@ /** | ||
(a.getLanguage()||"")+(b?"\n"+b:"")+"\n```"},regExp:/^```(\w{1,10})?\s/,replace:W(a=>t.$createCodeNode(a?a[1]:void 0)),type:"element"},ma={dependencies:[A.ListNode,A.ListItemNode],export:(a,b)=>A.$isListNode(a)?Y(a,b,0):null,regExp:/^(\s*)[-*+]\s/,replace:X("bullet"),type:"element"},na={dependencies:[A.ListNode,A.ListItemNode],export:(a,b)=>A.$isListNode(a)?Y(a,b,0):null,regExp:/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,replace:X("check"),type:"element"},oa={dependencies:[A.ListNode,A.ListItemNode],export:(a, | ||
b)=>A.$isListNode(a)?Y(a,b,0):null,regExp:/^(\s*)(\d{1,})\.\s/,replace:X("number"),type:"element"},pa={format:["code"],tag:"`",type:"text-format"},qa={format:["bold","italic"],tag:"***",type:"text-format"},ra={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},ta={format:["bold"],tag:"**",type:"text-format"},ua={format:["bold"],intraword:!1,tag:"__",type:"text-format"},va={format:["strikethrough"],tag:"~~",type:"text-format"},wa={format:["italic"],tag:"*",type:"text-format"},xa={format:["italic"], | ||
intraword:!1,tag:"_",type:"text-format"},ya={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"}, | ||
za=[ja,ka,la,ma,oa],Aa=[pa,qa,ra,ta,ua,wa,xa,va],Ba=[ya],Z=[...za,...Aa,...Ba];exports.$convertFromMarkdownString=function(a,b=Z){return fa(b)(a)};exports.$convertToMarkdownString=function(a=Z){return ba(a)()};exports.BOLD_ITALIC_STAR=qa;exports.BOLD_ITALIC_UNDERSCORE=ra;exports.BOLD_STAR=ta;exports.BOLD_UNDERSCORE=ua;exports.CHECK_LIST=na;exports.CODE=la;exports.ELEMENT_TRANSFORMERS=za;exports.HEADING=ja;exports.INLINE_CODE=pa;exports.ITALIC_STAR=wa;exports.ITALIC_UNDERSCORE=xa;exports.LINK=ya; | ||
exports.ORDERED_LIST=oa;exports.QUOTE=ka;exports.STRIKETHROUGH=va;exports.TEXT_FORMAT_TRANSFORMERS=Aa;exports.TEXT_MATCH_TRANSFORMERS=Ba;exports.TRANSFORMERS=Z;exports.UNORDERED_LIST=ma; | ||
b)=>A.$isListNode(a)?Y(a,b,0):null,regExp:/^(\s*)(\d{1,})\.\s/,replace:X("number"),type:"element"},pa={format:["code"],tag:"`",type:"text-format"},qa={format:["highlight"],tag:"==",type:"text-format"},ra={format:["bold","italic"],tag:"***",type:"text-format"},sa={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},ua={format:["bold"],tag:"**",type:"text-format"},va={format:["bold"],intraword:!1,tag:"__",type:"text-format"},wa={format:["strikethrough"],tag:"~~",type:"text-format"}, | ||
xa={format:["italic"],tag:"*",type:"text-format"},ya={format:["italic"],intraword:!1,tag:"_",type:"text-format"},za={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"},Aa=[ja,ka,la,ma,oa],Ba=[pa,ra,sa,ua,va,qa,xa,ya,wa],Ca=[za],Z=[...Aa,...Ba,...Ca];exports.$convertFromMarkdownString=function(a,b=Z){return fa(b)(a)};exports.$convertToMarkdownString=function(a=Z){return ba(a)()};exports.BOLD_ITALIC_STAR=ra;exports.BOLD_ITALIC_UNDERSCORE=sa;exports.BOLD_STAR=ua;exports.BOLD_UNDERSCORE=va;exports.CHECK_LIST=na;exports.CODE=la;exports.ELEMENT_TRANSFORMERS=Aa;exports.HEADING=ja;exports.HIGHLIGHT=qa; | ||
exports.INLINE_CODE=pa;exports.ITALIC_STAR=xa;exports.ITALIC_UNDERSCORE=ya;exports.LINK=za;exports.ORDERED_LIST=oa;exports.QUOTE=ka;exports.STRIKETHROUGH=wa;exports.TEXT_FORMAT_TRANSFORMERS=Ba;exports.TEXT_MATCH_TRANSFORMERS=Ca;exports.TRANSFORMERS=Z;exports.UNORDERED_LIST=ma; | ||
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})=> | ||
{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, | ||
replace:E}of g)if((g=n.match(D))&&g[0].length===w){n=q.getNextSiblings();let [F,sa]=q.splitText(w);F.remove();n=sa?[sa,...n]:n;E(m,n,g,!1);m=!0;break b}m=!1}if(!m){b:{g=q.getTextContent();m=e[g[w-1]];if(null!=m){w<g.length&&(g=g.slice(0,w));for(x of m)if(m=g.match(x.regExp),null!==m){g=m.index||0;n=g+m[0].length;var v=void 0;0===g?[v]=q.splitText(n):[,v]=q.splitText(g,n);v.selectNext(0,0);x.replace(v,m);var x=!0;break b}}x=!1}if(!x)b:{n=q.getTextContent();--w;var u=n[w];if(x=d[u])for(let D of x){var {tag:B}= | ||
replace:E}of g)if((g=n.match(D))&&g[0].length===w){n=q.getNextSiblings();let [F,ta]=q.splitText(w);F.remove();n=ta?[ta,...n]:n;E(m,n,g,!1);m=!0;break b}m=!1}if(!m){b:{g=q.getTextContent();m=e[g[w-1]];if(null!=m){w<g.length&&(g=g.slice(0,w));for(x of m)if(m=g.match(x.regExp),null!==m){g=m.index||0;n=g+m[0].length;var v=void 0;0===g?[v]=q.splitText(n):[,v]=q.splitText(g,n);v.selectNext(0,0);x.replace(v,m);var x=!0;break b}}x=!1}if(!x)b:{n=q.getTextContent();--w;var u=n[w];if(x=d[u])for(let D of x){var {tag:B}= | ||
D;x=B.length;let E=w-x+1;if(!(1<x&&!V(n,E,B,0,x)||" "===n[E-1])&&(v=n[w+1],!1!==D.intraword||!v||J.test(v))){m=v=q;g=U(n,E,B);for(var z=m;0>g&&(z=z.getPreviousSibling())&&!h.$isLineBreakNode(z);)h.$isTextNode(z)&&(g=z.getTextContent(),m=z,g=U(g,g.length,B));if(!(0>g||m===v&&g+x===E||(B=m.getTextContent(),0<g&&B[g-1]===u||(z=B[g-1],!1===D.intraword&&z&&!J.test(z))))){n=v.getTextContent();n=n.slice(0,E)+n.slice(w+1);v.setTextContent(n);n=m===v?n:B;m.setTextContent(n.slice(0,g)+n.slice(g+x));n=h.$getSelection(); | ||
u=h.$createRangeSelection();h.$setSelection(u);w=w-x*(m===v?2:1)+1;u.anchor.set(m.__key,g,"text");u.focus.set(v.__key,w,"text");for(let F of D.format)u.hasFormat(F)||u.formatText(F);u.anchor.set(u.focus.key,u.focus.offset,u.focus.type);for(let F of D.format)u.hasFormat(F)&&u.toggleFormat(F);h.$isRangeSelection(n)&&(u.format=n.format);break b}}}}}}}})}}})} |
@@ -39,2 +39,3 @@ /** | ||
export declare const INLINE_CODE: TextFormatTransformer; | ||
export declare const HIGHLIGHT: TextFormatTransformer; | ||
export declare const BOLD_ITALIC_STAR: TextFormatTransformer; | ||
@@ -41,0 +42,0 @@ export declare const BOLD_ITALIC_UNDERSCORE: TextFormatTransformer; |
@@ -11,14 +11,14 @@ { | ||
"license": "MIT", | ||
"version": "0.7.7", | ||
"version": "0.7.8", | ||
"main": "LexicalMarkdown.js", | ||
"peerDependencies": { | ||
"lexical": "0.7.7" | ||
"lexical": "0.7.8" | ||
}, | ||
"dependencies": { | ||
"@lexical/utils": "0.7.7", | ||
"@lexical/code": "0.7.7", | ||
"@lexical/text": "0.7.7", | ||
"@lexical/rich-text": "0.7.7", | ||
"@lexical/list": "0.7.7", | ||
"@lexical/link": "0.7.7" | ||
"@lexical/utils": "0.7.8", | ||
"@lexical/code": "0.7.8", | ||
"@lexical/text": "0.7.8", | ||
"@lexical/rich-text": "0.7.8", | ||
"@lexical/list": "0.7.8", | ||
"@lexical/link": "0.7.8" | ||
}, | ||
@@ -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
62562
1120
25
50
+ Added@lexical/clipboard@0.7.8(transitive)
+ Added@lexical/code@0.7.8(transitive)
+ Added@lexical/html@0.7.8(transitive)
+ Added@lexical/link@0.7.8(transitive)
+ Added@lexical/list@0.7.8(transitive)
+ Added@lexical/rich-text@0.7.8(transitive)
+ Added@lexical/selection@0.7.8(transitive)
+ Added@lexical/table@0.7.8(transitive)
+ Added@lexical/text@0.7.8(transitive)
+ Added@lexical/utils@0.7.8(transitive)
+ Addedlexical@0.7.8(transitive)
- Removed@lexical/clipboard@0.7.7(transitive)
- Removed@lexical/code@0.7.7(transitive)
- Removed@lexical/html@0.7.7(transitive)
- Removed@lexical/link@0.7.7(transitive)
- Removed@lexical/list@0.7.7(transitive)
- Removed@lexical/rich-text@0.7.7(transitive)
- Removed@lexical/selection@0.7.7(transitive)
- Removed@lexical/table@0.7.7(transitive)
- Removed@lexical/text@0.7.7(transitive)
- Removed@lexical/utils@0.7.7(transitive)
- Removedlexical@0.7.7(transitive)
Updated@lexical/code@0.7.8
Updated@lexical/link@0.7.8
Updated@lexical/list@0.7.8
Updated@lexical/rich-text@0.7.8
Updated@lexical/text@0.7.8
Updated@lexical/utils@0.7.8