@lexical/markdown 0.44.1-nightly.20260519.0 → 0.45.1-dev.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.
Files changed (29) hide show
  1. package/{LexicalMarkdown.dev.js → dist/LexicalMarkdown.dev.js} +1 -1
  2. package/{LexicalMarkdown.dev.mjs → dist/LexicalMarkdown.dev.mjs} +1 -1
  3. package/dist/LexicalMarkdown.prod.js +9 -0
  4. package/dist/LexicalMarkdown.prod.mjs +9 -0
  5. package/package.json +37 -22
  6. package/src/MarkdownExport.ts +627 -0
  7. package/src/MarkdownImport.ts +363 -0
  8. package/src/MarkdownShortcuts.ts +677 -0
  9. package/src/MarkdownTransformers.ts +962 -0
  10. package/src/importTextFormatTransformer.ts +389 -0
  11. package/src/importTextMatchTransformer.ts +110 -0
  12. package/src/importTextTransformers.ts +141 -0
  13. package/src/index.ts +138 -0
  14. package/src/utils.ts +472 -0
  15. package/LexicalMarkdown.prod.js +0 -9
  16. package/LexicalMarkdown.prod.mjs +0 -9
  17. /package/{LexicalMarkdown.js → dist/LexicalMarkdown.js} +0 -0
  18. /package/{LexicalMarkdown.js.flow → dist/LexicalMarkdown.js.flow} +0 -0
  19. /package/{LexicalMarkdown.mjs → dist/LexicalMarkdown.mjs} +0 -0
  20. /package/{LexicalMarkdown.node.mjs → dist/LexicalMarkdown.node.mjs} +0 -0
  21. /package/{MarkdownExport.d.ts → dist/MarkdownExport.d.ts} +0 -0
  22. /package/{MarkdownImport.d.ts → dist/MarkdownImport.d.ts} +0 -0
  23. /package/{MarkdownShortcuts.d.ts → dist/MarkdownShortcuts.d.ts} +0 -0
  24. /package/{MarkdownTransformers.d.ts → dist/MarkdownTransformers.d.ts} +0 -0
  25. /package/{importTextFormatTransformer.d.ts → dist/importTextFormatTransformer.d.ts} +0 -0
  26. /package/{importTextMatchTransformer.d.ts → dist/importTextMatchTransformer.d.ts} +0 -0
  27. /package/{importTextTransformers.d.ts → dist/importTextTransformers.d.ts} +0 -0
  28. /package/{index.d.ts → dist/index.d.ts} +0 -0
  29. /package/{utils.d.ts → dist/utils.d.ts} +0 -0
@@ -49,7 +49,7 @@ function transformersByType(transformers) {
49
49
  };
50
50
  }
51
51
  const PUNCTUATION_OR_SPACE = /[!-/:-@[-`{-~\s]/;
52
- const WHITESPACE = /[ \t\n\r\f]/;
52
+ const WHITESPACE = /\s/;
53
53
  const PUNCTUATION = /[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~]/;
54
54
  const MARKDOWN_EMPTY_LINE_REG_EXP = /^\s{0,3}$/;
55
55
  function isEmptyParagraph(node) {
@@ -47,7 +47,7 @@ function transformersByType(transformers) {
47
47
  };
48
48
  }
49
49
  const PUNCTUATION_OR_SPACE = /[!-/:-@[-`{-~\s]/;
50
- const WHITESPACE = /[ \t\n\r\f]/;
50
+ const WHITESPACE = /\s/;
51
51
  const PUNCTUATION = /[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~]/;
52
52
  const MARKDOWN_EMPTY_LINE_REG_EXP = /^\s{0,3}$/;
53
53
  function isEmptyParagraph(node) {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ "use strict";var e=require("lexical"),t=require("@lexical/selection"),n=require("@lexical/code-core"),o=require("@lexical/link"),r=require("@lexical/list"),i=require("@lexical/rich-text"),s=require("@lexical/utils");function l(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=l(e,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}const a=/[!-/:-@[-`{-~\s]/,d=/\s/,f=/[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~]/,u=/^\s{0,3}$/;function g(t){if(!e.$isParagraphNode(t))return!1;const n=t.getFirstChild();return null==n||1===t.getChildrenSize()&&e.$isTextNode(n)&&u.test(n.getTextContent())}function p(e){return e.replace(/\\([!-/:-@[-`{-~])/g,"$1").replace(/&#(\d+);/g,(e,t)=>String.fromCodePoint(Number(t)))}const h=/^(\s*)(\d{1,})\.\s/,x=/^(\s*)[-*+]\s/,m=/^(\s*)(?:[-*+]\s)?\s?(\[(\s|x)?\])\s/i,$=/^(#{1,6})\s/,N=/^>\s/,T=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,C=/^[ \t]*`{3,}$/,E=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,S=/^(?:\|)(.+)(?:\|)\s?$/,I=/^(\| ?:?-*:? ?)+\|\s?$/,L=/^<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,R=/^<\/[a-z_][\w-]*\s*>/i,v=e=>new RegExp(`(?:${e.source})$`,e.flags),O=e.createState("mdListMarker",{parse:e=>"string"==typeof e&&/^[-*+]$/.test(e)?e:"-",resetOnCopyNode:!0}),y=e.createState("mdCodeFence",{parse:e=>"string"==typeof e&&/^`{3,}$/.test(e)?e:"```",resetOnCopyNode:!0}),_=e.createState("mdHardLineBreak",{parse:e=>"string"==typeof e&&/^(\\| {2,})$/.test(e)?e:"",resetOnCopyNode:!0});function k(e){if(e.endsWith("\\"))return[e.slice(0,-1),"\\"];const t=e.match(/^(.*?\S)( {2,})$/);return t?[t[1],t[2]]:null}function w(t){const n=t.getChildren(),o=n.length-1,r=n[o];if(!e.$isTextNode(r))return null;const i=r.getTextContent(),s=k(i);if(null!==s){const[e,t]=s;return r.setTextContent(e),t}return/^ {2,}$/.test(i)&&function(t,n){for(let o=n-1;o>=0;o--){if(e.$isLineBreakNode(t[o]))return!1;if(/\S/.test(t[o].getTextContent()))return!0}return!1}(n,o)?(r.setTextContent(""),i):null}function M(t){const n=e.$createLineBreakNode(),o=w(t);return null!==o&&e.$setState(n,_,o),n}const A=e=>(t,n,o,r)=>{const i=e(o);i.append(...n),t.replace(i),r||i.select(0,0)};const b=t=>(n,o,i,s)=>{const l=n.getPreviousSibling(),c=n.getNextSibling(),a=r.$createListItemNode("check"===t?"x"===i[3]:void 0),d=i[0].trim()[0],f="bullet"!==t&&"check"!==t||d!==O.parse(d)?void 0:d;if(r.$isListNode(c)&&c.getListType()===t){f&&e.$setState(c,O,f);const t=c.getFirstChild();null!==t?t.insertBefore(a):c.append(a),n.remove()}else if(r.$isListNode(l)&&l.getListType()===t)f&&e.$setState(l,O,f),l.append(a),n.remove();else{const o=r.$createListNode(t,"number"===t?Number(i[2]):void 0);f&&e.$setState(o,O,f),o.append(a),n.replace(o)}a.append(...o),s||a.select(0,0);const u=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}(i[1]);u&&a.setIndent(u)},F=(t,n,o,i)=>{const s=[],l=t.getChildren();let c=0;for(const a of l)if(r.$isListItemNode(a)){if(1===a.getChildrenSize()){const e=a.getFirstChild();if(r.$isListNode(e)){const t=F(e,n,o+1,i);t&&s.push(t);continue}}if(i&&!a.getChildren().some(e=>e.isSelected(i)))continue;const l=" ".repeat(4*o),d=t.getListType(),f=e.$getState(t,O),u="number"===d?`${t.getStart()+c}. `:"check"===d?`${f} [${a.getChecked()?"x":" "}] `:f+" ";let g=n(a);"number"!==d&&(g=g.replace(/^(\s{0,3}\d+)(\.\s)/,"$1\\$2")),s.push(l+u+g),c++}return s.join("\n")},B={dependencies:[i.HeadingNode],export:(e,t)=>{if(!i.$isHeadingNode(e))return null;const n=Number(e.getTag().slice(1));return"#".repeat(n)+" "+t(e)},regExp:$,replace:A(e=>{const t="h"+e[1].length;return i.$createHeadingNode(t)}),triggerOnEnter:!0,type:"element"},D={dependencies:[i.QuoteNode],export:(e,t)=>{if(!i.$isQuoteNode(e))return null;const n=t(e).split("\n"),o=[];for(const e of n)o.push("> "+e);return o.join("\n")},regExp:N,replace:(e,t,n,o)=>{if(o){const n=e.getPreviousSibling();if(i.$isQuoteNode(n))return n.splice(n.getChildrenSize(),0,[M(n),...t]),void e.remove()}const r=i.$createQuoteNode();r.append(...t),e.replace(r),o||r.select(0,0)},triggerOnEnter:!0,type:"element"},P={dependencies:[n.CodeNode],export:t=>{if(!n.$isCodeNode(t))return null;const o=t.getTextContent();let r=e.$getState(t,y);if(o.indexOf(r)>-1){const e=o.match(/`{3,}/g);if(e){const t=Math.max(...e.map(e=>e.length));r="`".repeat(t+1)}}return r+(t.getLanguage()||"")+(o?"\n"+o:"")+"\n"+r},handleImportAfterStartMatch:({lines:e,rootNode:t,startLineIndex:n,startMatch:o})=>{const r=o[1],i=r.trim().length,s=e[n],l=o.index+r.length,c=s.slice(l),a=new RegExp(`\`{${i},}$`);if(a.test(c)){const e=c.match(a),r=c.slice(0,c.lastIndexOf(e[0])),i=[...o];return i[2]="",P.replace(t,null,i,e,[r],!0),[!0,n]}const d=new RegExp(`^[ \\t]*\`{${i},}$`);for(let r=n+1;r<e.length;r++){const i=e[r];if(d.test(i)){const l=i.match(d),c=e.slice(n+1,r),a=s.slice(o[0].length);return a.length>0&&c.unshift(a),P.replace(t,null,o,l,c,!0),[!0,r]}}const f=e.slice(n+1),u=s.slice(o[0].length);return u.length>0&&f.unshift(u),P.replace(t,null,o,null,f,!0),[!0,e.length-1]},regExpEnd:{optional:!0,regExp:C},regExpStart:T,replace:(t,o,r,i,s,l)=>{let c,a;const d=r[1]?r[1].trim():"```",f=r[2]||void 0;if(!o&&s){if(1===s.length)i?(c=n.$createCodeNode(f),a=s[0]):(c=n.$createCodeNode(f),a=s[0].startsWith(" ")?s[0].slice(1):s[0]);else{for(c=n.$createCodeNode(f),s.length>0&&(0===s[0].trim().length?s.shift():s[0].startsWith(" ")&&(s[0]=s[0].slice(1)));s.length>0&&!s[s.length-1].length;)s.pop();a=s.join("\n")}e.$setState(c,y,d);const o=e.$createTextNode(a);c.append(o),t.append(c)}else o&&A(e=>n.$createCodeNode(e?e[2]:void 0))(t,o,r,l)},type:"multiline-element"},H={dependencies:[r.ListNode,r.ListItemNode],export:(e,t,n)=>r.$isListNode(e)?F(e,t,0,n):null,regExp:x,replace:b("bullet"),triggerOnEnter:!0,type:"element"},j={dependencies:[r.ListNode,r.ListItemNode],export:(e,t,n)=>r.$isListNode(e)?F(e,t,0,n):null,regExp:m,replace:b("check"),triggerOnEnter:!0,type:"element"},U={dependencies:[r.ListNode,r.ListItemNode],export:(e,t,n)=>r.$isListNode(e)?F(e,t,0,n):null,regExp:h,replace:b("number"),triggerOnEnter:!0,type:"element"},z={format:["code"],tag:"`",type:"text-format"},G={format:["highlight"],tag:"==",type:"text-format"},W={format:["bold","italic"],tag:"***",type:"text-format"},q={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},Q={format:["bold"],tag:"**",type:"text-format"},K={format:["bold"],intraword:!1,tag:"__",type:"text-format"},Y={format:["strikethrough"],tag:"~~",type:"text-format"},X={format:["italic"],tag:"*",type:"text-format"},J={format:["italic"],intraword:!1,tag:"_",type:"text-format"},V={dependencies:[o.LinkNode],export:(e,t,n)=>{if(!o.$isLinkNode(e)||o.$isAutoLinkNode(e))return null;const r=t(e);let i=e.getTitle();null!=i&&(i=i.replace(/([\\"])/g,"\\$1"));return i?`[${r}](${e.getURL()} "${i}")`:`[${r}](${e.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[\]]*(?:\[[^[\]]*\][^[\]]*)*)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,n)=>{if(e.$findMatchingParent(t,o.$isLinkNode))return;const[,r,i,s]=n,l=null!=i?p(i):void 0,c=null!=s?p(s):void 0,a=o.$createLinkNode(l,{title:c}),d=r.split("[").length-1,f=r.split("]").length-1;let u=r,g="";if(d<f)return;if(d>f){const e=r.split("[");g="["+e[0],u=e.slice(1).join("[")}const h=e.$createTextNode(u);return h.setFormat(t.getFormat()),a.append(h),t.replace(a),g&&a.insertBefore(e.$createTextNode(g)),h},trigger:")",type:"text-match"},Z=[B,D,H,U],ee=[P],te=[z,W,q,Q,K,G,X,J,Y],ne=[V],oe=[...Z,...ee,...te,...ne];function re(t,n,o,r,i,s){let l=t.isSelected(n);for(const c of o){if(!c.export)continue;const o=c.export(t,e=>ie(e,n,r,i,s).markdown,n);if(null!=o){if(!l&&e.$isElementNode(t)){ie(t,n,r,i,s).shouldInclude&&(l=!0)}return{markdown:o,shouldInclude:l}}}if(e.$isElementNode(t)){const e=ie(t,n,r,i,s);return{markdown:e.markdown,shouldInclude:l||e.shouldInclude}}return e.$isDecoratorNode(t)?{markdown:t.getTextContent(),shouldInclude:l}:{markdown:null,shouldInclude:l}}function ie(n,o,r,i,s,l,c){const a=[],d=n.getChildren();let f=!1;l||(l=[]),c||(c=[]);e:for(const n of d){let d=n.isSelected(o);for(const u of i){if(!u.export)continue;const g=u.export(n,e=>ie(e,o,r,i,s,l,[...c,...l]).markdown,(e,n)=>ae(e,t.$sliceSelectedTextNodeContent(o,e,"clone").getTextContent(),r,l,c,s));if(null!=g){!d&&e.$isElementNode(n)&&n.getChildren().some(e=>e.isSelected(o))&&n.extractWithChild(n,o,"html")&&(d=!0),d&&(a.push(g),f=!0);continue e}}if(e.$isLineBreakNode(n))d&&(a.push(ce(n)),f=!0);else if(e.$isTextNode(n)){if(d){const e=t.$sliceSelectedTextNodeContent(o,n,"clone");a.push(ae(n,e.getTextContent(),r,l,c,s)),f=!0}}else if(e.$isElementNode(n)){const e=ie(n,o,r,i,s,l,c);!d&&e.shouldInclude&&n.extractWithChild(n,o,"html")&&(d=!0),(d||e.shouldInclude)&&(a.push(e.markdown),f=!0)}else e.$isDecoratorNode(n)&&d&&(a.push(n.getTextContent()),f=!0)}return{markdown:a.join(""),shouldInclude:f}}function se(t,n,o,r,i){for(const e of n){if(!e.export)continue;const n=e.export(t,e=>le(e,o,r,void 0,void 0,i));if(null!=n)return n}return e.$isElementNode(t)?le(t,o,r,void 0,void 0,i):e.$isDecoratorNode(t)?t.getTextContent():null}function le(t,n,o,r,i,s=!1){const l=[],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=>le(e,n,o,r,[...i,...r],s),(e,t)=>ae(e,t,n,r,i,s));if(null!=c){l.push(c);continue e}}e.$isLineBreakNode(t)?l.push(ce(t)):e.$isTextNode(t)?l.push(ae(t,t.getTextContent(),n,r,i,s)):e.$isElementNode(t)?l.push(le(t,n,o,r,i,s)):e.$isDecoratorNode(t)&&l.push(t.getTextContent())}return l.join("")}function ce(t){return e.$getState(t,_)+"\n"}function ae(e,t,n,o,r,i=!1){let s=t;e.hasFormat("code")||(s=i?s.replace(/([*_`~])/g,"\\$1"):s.replace(/([*_`~\\])/g,"\\$1"));const l=s.match(/^(\s*)(.*?)(\s*)$/s)||["","",s,""],c=l[1],a=l[2],d=l[3],f=""===a;let u="",g="",p="";const h=de(e,!0),x=de(e,!1),m=new Set;for(const t of n){const n=t.format[0],r=t.tag;ue(e,n)&&!m.has(n)&&(m.add(n),ue(h,n)&&o.find(e=>e.tag===r)||(o.push({format:n,tag:r}),u+=r))}for(let t=0;t<o.length;t++){const n=fe(e,o[t].format),i=fe(x,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||(p+=e.tag):g+=e.tag),o.pop())}break}return f&&!e.hasFormat("code")?g+s:g+c+u+a+p+d}function de(t,n){const o=n?t.getPreviousSibling():t.getNextSibling();return e.$isTextNode(o)?o:null}function fe(t,n){return e.$isTextNode(t)&&t.hasFormat(n)}function ue(e,t){return!!fe(e,t)&&("code"===t||(!e||!/^\s*$/.test(e.getTextContent())))}function ge(e,t){const n=e.getTextContent(),o=t.fullMatchRegExpByTag["`"],r=t.transformersByTag["`"],i=[];let s=null;if(o&&r){const e=new RegExp(o.source,"g"),t=Array.from(n.matchAll(e));for(const e of t){const t=e.index+e[1].length,n=e.index+e[0].length;s||(s={content:e[3],endIndex:n,startIndex:t,tag:"`"}),i.push({end:n,start:t})}}const l=function(e,t,n=[]){const o=[],r=new Set(Object.keys(t.transformersByTag).filter(e=>"`"!==e[0]).map(e=>e[0])),i=t=>{let n=0;for(let o=t-1;o>=0&&"\\"===e[o];o--)n++;return n%2==1},s=e=>n.some(t=>e>=t.start&&e<t.end);let l=0;for(;l<e.length;){const t=e[l];if(!r.has(t)||i(l)||s(l)){l++;continue}let n=1;for(;l+n<e.length&&e[l+n]===t;)n++;const c=pe(t,e,l,n,!0),a=pe(t,e,l,n,!1);(c||a)&&o.push({active:!0,canClose:a,canOpen:c,char:t,index:l,length:n,originalLength:n}),l+=n}return o}(n,t,i),c=l.length>0?function(e,t,n){const o={};let r=0,i=null;for(;r<t.length;){const s=t[r];if(!s.active||!s.canClose||0===s.length){r++;continue}const l=`${s.char}${s.canOpen}`,c=o[l]??-1;let a=!1;for(let o=r-1;o>c;o--){const l=t[o];if(!l.active||!l.canOpen||0===l.length||l.char!==s.char)continue;if(l.canClose||s.canOpen){if((l.originalLength+s.originalLength)%3==0&&l.originalLength%3!=0&&s.originalLength%3!=0)continue}const c=Math.min(l.length,s.length),d=Object.keys(n.transformersByTag).filter(e=>e[0]===l.char&&e.length<=c).sort((e,t)=>t.length-e.length)[0];if(!d)continue;a=!0;const f=d.length,u={content:e.slice(l.index+l.length,s.index),endIndex:s.index+f,startIndex:l.index+(l.length-f),tag:d};(!i||u.startIndex<i.startIndex||u.startIndex===i.startIndex&&u.endIndex>i.endIndex)&&(i=u);for(let e=o+1;e<r;e++)t[e].active=!1;l.length-=f,s.length-=f,l.active=l.length>0,s.length>0?s.index+=f:(s.active=!1,r++);break}a||(o[l]=r-1,s.canOpen||(s.active=!1),r++)}return i}(n,l,t):null;let a=null,d=null;if(s&&c?c.startIndex<=s.startIndex&&c.endIndex>=s.endIndex?(a=c,d=t.transformersByTag[c.tag]):(a=s,d=r):s?(a=s,d=r):c&&(a=c,d=t.transformersByTag[c.tag]),!a||!d)return null;const f=[n.slice(a.startIndex,a.endIndex),a.tag,a.content];return f.index=a.startIndex,f.input=n,{endIndex:a.endIndex,match:f,startIndex:a.startIndex,transformer:d}}function pe(e,t,n,o,r){if(!he(t,n,o,r))return!1;if("*"===e)return!0;if("_"===e){if(!he(t,n,o,!r))return!0;const e=r?t[n-1]:t[n+o];return void 0!==e&&f.test(e)}return!0}function he(e,t,n,o){const r=e[t-1],i=e[t+n],[s,l]=o?[i,r]:[r,i];return void 0!==s&&!d.test(s)&&(!f.test(s)||(void 0===l||d.test(l)||f.test(l)))}function xe(t){return e.$isTextNode(t)&&!t.hasFormat("code")}function me(e,t,n){let o=ge(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 l=t.index||0,c=e.getEndIndex?e.getEndIndex(n,t):l+t[0].length;!1!==c&&(void 0===o||void 0===r||l<o&&(c>r||c<=o))&&(o=l,r=c,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.startIndex>o.endIndex?r=null:o=null),o){const r=function(e,t,n,o,r){const i=e.getTextContent();let s,l,c;if(r[0]===i?s=e:0===t?[s,l]=e.splitText(n):[c,s,l]=e.splitText(t,n),s.setTextContent(r[2]),o)for(const e of o.format)s.hasFormat(e)||s.toggleFormat(e);return{nodeAfter:l,nodeBefore:c,transformedNode:s}}(e,o.startIndex,o.endIndex,o.transformer,o.match);xe(r.nodeAfter)&&me(r.nodeAfter,t,n),xe(r.nodeBefore)&&me(r.nodeBefore,t,n),xe(r.transformedNode)&&me(r.transformedNode,t,n)}else if(r){const o=function(e,t,n,o,r){let i,s,l;return 0===t?[i,s]=e.splitText(n):[l,i,s]=e.splitText(t,n),o.replace?{nodeAfter:s,nodeBefore:l,transformedNode:o.replace(i,r)||void 0}:null}(e,r.startIndex,r.endIndex,r.transformer,r.match);if(!o)return;xe(o.nodeAfter)&&me(o.nodeAfter,t,n),xe(o.nodeBefore)&&me(o.nodeBefore,t,n),xe(o.transformedNode)&&me(o.transformedNode,t,n)}const i=p(e.getTextContent());e.setTextContent(i)}function $e(t,n=!1){const o=c(t),r=function(e){const t={},n={},o=[];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]="`"===e?new RegExp("(^|[^\\\\`])(`)((?:\\\\`|[^`])+?)(`)(?!`)"):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(`(${o.join("|")})`,"g"),transformersByTag:t}}(o.textFormat);return(t,i)=>{const s=t.split("\n"),l=s.length,c=i||e.$getRoot();c.clear();for(let e=0;e<l;e++){const t=s[e],[i,l]=Ne(s,e,o.multilineElement,c);i?e=l:Te(t,c,o.element,r,o.textMatch,n)}const a=c.getChildren();for(const t of a)if(!n&&g(t)&&c.getChildrenSize()>1)t.remove();else if(e.$isElementNode(t))for(const e of t.getAllTextNodes())Ce(e);null!==e.$getSelection()&&c.selectStart()}}function Ne(e,t,n,o){for(const r of n){const{handleImportAfterStartMatch:n,regExpEnd:i,regExpStart:s,replace:l}=r,c=e[t].match(s);if(!c)continue;if(n){const i=n({lines:e,rootNode:o,startLineIndex:t,startMatch:c,transformer:r});if(null===i)continue;if(i)return i}const a="object"==typeof i&&"regExp"in i?i.regExp:i,d=i&&"object"==typeof i&&"optional"in i?i.optional:!i;let f=t;const u=e.length;for(;f<u;){const n=a?e[f].match(a):null;if(!n&&(!d||d&&f<u-1)){f++;continue}if(n&&t===f&&n.index===c.index){f++;continue}const r=[];if(n&&t===f)r.push(e[t].slice(c[0].length,-n[0].length));else for(let o=t;o<=f;o++)if(o===t){const t=e[o].slice(c[0].length);r.push(t)}else if(o===f&&n){const t=e[o].slice(0,-n[0].length);r.push(t)}else r.push(e[o]);if(!1!==l(o,null,c,n,r,!0))return[!0,f];break}}return[!1,t]}function Te(t,n,o,l,c,a){const d=e.$createTextNode(t),f=e.$createParagraphNode();f.append(d),n.append(f);for(const{regExp:e,replace:n}of o){const o=t.match(e);if(o&&(d.setTextContent(t.slice(o[0].length)),!1!==n(f,[d],o,!0)))break}if(me(d,l,c),f.isAttached()&&t.length>0){const t=f.getPreviousSibling();if(!a&&(e.$isParagraphNode(t)||i.$isQuoteNode(t)||r.$isListNode(t))){let e=t;if(r.$isListNode(t)){const n=t.getLastDescendant();e=null==n?null:s.$findMatchingParent(n,r.$isListItemNode)}null!=e&&e.getTextContentSize()>0&&(e.splice(e.getChildrenSize(),0,[M(e),...f.getChildren()]),f.remove())}}}function Ce(t){const n=new Set,o=t.getTextContent();let r=o.indexOf("\t");for(;-1!==r;)n.add(r),n.add(r+1),r=o.indexOf("\t",r+1);t.splitText(...n).forEach(t=>{"\t"===t.getTextContent()&&t.replace(e.$createTabNode())})}function Ee(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 Se(t,n,o,r,i){const s=t.getParent();if(!e.$isRootOrShadowRoot(s)||t.getFirstChild()!==n)return!1;const l=n.getTextContent();if(!i&&" "!==l[o-1])return!1;for(const{regExp:e,replace:s}of r){const r=l.match(e),c=i||r&&r[0].endsWith(" ")?o:o-1;if(r&&r[0].length===c){const e=n.getNextSiblings(),[i,l]=n.splitText(o);if(!1!==s(t,l?[l,...e]:e,r,!1))return i.remove(),!0}}return!1}function Ie(t,n,o,r,i){const s=t.getParent();if(!e.$isRootOrShadowRoot(s)||t.getFirstChild()!==n)return!1;const l=n.getTextContent();if(!i&&" "!==l[o-1])return!1;for(const{regExpStart:e,replace:s,regExpEnd:c}of r){if(c&&!("optional"in c)||c&&"optional"in c&&!c.optional)continue;const r=l.match(e);if(r){const e=i||r[0].endsWith(" ")?o:o-1;if(r[0].length!==e)continue;const l=n.getNextSiblings(),[c,a]=n.splitText(o);if(!1!==s(t,a?[a,...l]:l,r,null,null,!1))return c.remove(),!0}}return!1}function Le(e,t){let n=0;const o=e.getTextContent();for(let e=0;e<t;e++)"`"===o[e]&&n++;return n%2!=0}function Re(e,t,n){const o=n.length;for(let r=t;r>=o;r--){const t=r-o;if(ve(e,t,n,0,o)&&" "!==e[t+o])return t}return-1}function ve(e,t,n,o,r){for(let i=0;i<r;i++)if(e[t+i]!==n[o+i])return!1;return!0}exports.$convertFromMarkdownString=function(e,t=oe,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=i.trimEnd(),l=r[r.length-1],c=e<n.length-1?k(i):null,a=void 0!==l&&null!==k(l);E.test(s)?r.push(s):T.test(s)||C.test(s)?(o=!o,r.push(s)):o?r.push(i):""===s||""===l||!l||$.test(l)||$.test(s)||N.test(s)||h.test(s)||x.test(s)||m.test(s)||S.test(s)||I.test(s)||a||!t||L.test(s)||R.test(s)||v(R).test(l)||v(L).test(l)||C.test(l)?r.push(!t&&""!==s||null!==c?i:s):r[r.length-1]=l+" "+(null===c?s:i).trimStart()}return r.join("\n")}(e,r);return $e(t,o)(i,n)},exports.$convertSelectionToMarkdownString=function(t=oe,n,o=!1){if(!n||e.$isRangeSelection(n)&&n.isCollapsed())return"";const r=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 l=[],c=e.$getRoot().getChildren();for(let e=0;e<c.length;e++){const a=c[e],{shouldInclude:d,markdown:f}=re(a,t,r,s,o.textMatch,n);d&&null!=f&&l.push(i&&e>0&&!g(a)&&!g(c[e-1])?"\n".concat(f):f)}return l.join("\n")}}(t,o);return r(n)},exports.$convertToMarkdownString=function(t=oe,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 l=[],c=(t||e.$getRoot()).getChildren();for(let e=0;e<c.length;e++){const t=c[e],a=se(t,r,s,o.textMatch,n);null!=a&&l.push(i&&e>0&&!g(t)&&!g(c[e-1])?"\n".concat(a):a)}return l.join("\n")}}(t,o)(n)},exports.BOLD_ITALIC_STAR=W,exports.BOLD_ITALIC_UNDERSCORE=q,exports.BOLD_STAR=Q,exports.BOLD_UNDERSCORE=K,exports.CHECK_LIST=j,exports.CODE=P,exports.ELEMENT_TRANSFORMERS=Z,exports.HEADING=B,exports.HIGHLIGHT=G,exports.INLINE_CODE=z,exports.ITALIC_STAR=X,exports.ITALIC_UNDERSCORE=J,exports.LINK=V,exports.MULTILINE_ELEMENT_TRANSFORMERS=ee,exports.ORDERED_LIST=U,exports.QUOTE=D,exports.STRIKETHROUGH=Y,exports.TEXT_FORMAT_TRANSFORMERS=te,exports.TEXT_MATCH_TRANSFORMERS=ne,exports.TRANSFORMERS=oe,exports.UNORDERED_LIST=H,exports.registerMarkdownShortcuts=function(t,o=oe){const r=c(o),i=r.element.filter(e=>e.triggerOnEnter),s=l(r.textFormat,({tag:e})=>e[e.length-1]),d=l(r.textMatch,({trigger:e})=>e),f=new Set([" "]);for(const e of r.textFormat)f.add(e.tag.slice(-1));for(const e of r.textMatch)void 0!==e.trigger&&f.add(e.trigger);for(const e of o){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)||Ee(173,e.getType())}}const u=(t,n,o)=>!!Se(t,n,o,r.element)||(!!Ie(t,n,o,r.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,o,d)||!!function(t,n,o){const r=t.getTextContent(),i=n-1,s=r[i],l=o[s];if(!l)return!1;for(const n of l){const{tag:o}=n,l=o.length,c=i-l+1;if(l>1&&!ve(r,c,o,0,l))continue;if(" "===r[c-1])continue;const d=r[i+1];if(!1===n.intraword&&d&&!a.test(d))continue;const f=t;let u=f,g=Re(r,c,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=Re(e,e.length,o)}if(g<0)continue;if(u===f&&g+l===c)continue;const h=u.getTextContent();if(g>0&&h[g-1]===s)continue;const x=h[g-1];if(!1===n.intraword&&x&&!a.test(x))continue;if(!n.format.includes("code")&&Le(u,g))continue;const m=f.getTextContent(),$=m.slice(0,c)+m.slice(i+1);f.setTextContent($);const N=u===f?$:h;u.setTextContent(N.slice(0,g)+N.slice(g+l));const T=e.$getSelection(),C=e.$createRangeSelection();e.$setSelection(C);const E=i-l*(u===f?2:1)+1;C.anchor.set(u.__key,g,"text"),C.focus.set(f.__key,E,"text");for(const e of n.format)C.hasFormat(e)||C.formatText(e);C.anchor.set(C.focus.key,C.focus.offset,C.focus.type);for(const e of n.format)C.hasFormat(e)&&C.toggleFormat(e);return e.$isRangeSelection(T)&&(C.format=T.format),!0}return!1}(n,o,s)));return e.mergeRegister(t.registerUpdateListener(({tags:o,dirtyLeaves:r,editorState:i,prevEditorState:s})=>{if(o.has(e.COLLABORATION_TAG)||o.has(e.HISTORIC_TAG))return;if(t.isComposing())return;const l=o.has(e.COMPOSITION_END_TAG),c=i.read(e.$getSelection),a=s.read(e.$getSelection);if(!e.$isRangeSelection(a)||!e.$isRangeSelection(c)||!c.isCollapsed()||c.is(a)&&!l)return;const d=c.anchor.key,g=c.anchor.offset,p=i._nodeMap.get(d);if(e.$isTextNode(p)&&r.has(d)&&(l||1===g||!(g>a.anchor.offset+1))){if(l){const e=i.read(()=>p.getTextContent())[g-1];if(!f.has(e))return}t.update(()=>{if(!xe(p))return;const t=p.getParent();null===t||n.$isCodeNode(t)||u(t,p,c.anchor.offset)&&e.$addUpdateTag(e.HISTORY_PUSH_TAG)})}}),t.registerCommand(e.KEY_ENTER_COMMAND,t=>{if(null!==t&&t.shiftKey)return!1;const o=e.$getSelection();if(!e.$isRangeSelection(o)||!o.isCollapsed())return!1;const s=o.anchor.offset,l=o.anchor.getNode();if(!e.$isTextNode(l)||!xe(l))return!1;const c=l.getParent();if(null===c||n.$isCodeNode(c))return!1;return s===l.getTextContent().length&&(!(!Ie(c,l,s,r.multilineElement,!0)&&!Se(c,l,s,i,!0))&&(null!==t&&t.preventDefault(),!0))},e.COMMAND_PRIORITY_LOW))};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import{$isParagraphNode as t,$isTextNode as e,createState as n,$setState as o,$createTextNode as r,$getState as i,$findMatchingParent as s,$createLineBreakNode as l,$isLineBreakNode as c,$getRoot as a,$isElementNode as f,$isDecoratorNode as u,$getSelection as d,$createParagraphNode as g,$createTabNode as p,mergeRegister as h,COLLABORATION_TAG as x,HISTORIC_TAG as m,COMPOSITION_END_TAG as C,$isRangeSelection as T,$addUpdateTag as E,HISTORY_PUSH_TAG as $,KEY_ENTER_COMMAND as v,COMMAND_PRIORITY_LOW as I,$isRootOrShadowRoot as y,$createRangeSelection as S,$setSelection as b}from"lexical";import{$sliceSelectedTextNodeContent as w}from"@lexical/selection";import{CodeNode as k,$createCodeNode as N,$isCodeNode as F}from"@lexical/code-core";import{LinkNode as L,$isLinkNode as O,$createLinkNode as M,$isAutoLinkNode as R}from"@lexical/link";import{ListNode as B,ListItemNode as _,$isListNode as j,$createListItemNode as A,$createListNode as P,$isListItemNode as z}from"@lexical/list";import{HeadingNode as W,QuoteNode as U,$isHeadingNode as D,$isQuoteNode as H,$createQuoteNode as K,$createHeadingNode as q}from"@lexical/rich-text";import{$findMatchingParent as G}from"@lexical/utils";function J(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 Q(t){const e=J(t,t=>t.type);return{element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const V=/[!-/:-@[-`{-~\s]/,X=/\s/,Y=/[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~]/,Z=/^\s{0,3}$/;function tt(n){if(!t(n))return!1;const o=n.getFirstChild();return null==o||1===n.getChildrenSize()&&e(o)&&Z.test(o.getTextContent())}function et(t){return t.replace(/\\([!-/:-@[-`{-~])/g,"$1").replace(/&#(\d+);/g,(t,e)=>String.fromCodePoint(Number(e)))}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]*`{3,})([\w-]+)?[ \t]?/,ct=/^[ \t]*`{3,}$/,at=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,ft=/^(?:\|)(.+)(?:\|)\s?$/,ut=/^(\| ?:?-*:? ?)+\|\s?$/,dt=/^<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,gt=/^<\/[a-z_][\w-]*\s*>/i,pt=t=>new RegExp(`(?:${t.source})$`,t.flags),ht=n("mdListMarker",{parse:t=>"string"==typeof t&&/^[-*+]$/.test(t)?t:"-",resetOnCopyNode:!0}),xt=n("mdCodeFence",{parse:t=>"string"==typeof t&&/^`{3,}$/.test(t)?t:"```",resetOnCopyNode:!0}),mt=n("mdHardLineBreak",{parse:t=>"string"==typeof t&&/^(\\| {2,})$/.test(t)?t:"",resetOnCopyNode:!0});function Ct(t){if(t.endsWith("\\"))return[t.slice(0,-1),"\\"];const e=t.match(/^(.*?\S)( {2,})$/);return e?[e[1],e[2]]:null}function Tt(t){const n=t.getChildren(),o=n.length-1,r=n[o];if(!e(r))return null;const i=r.getTextContent(),s=Ct(i);if(null!==s){const[t,e]=s;return r.setTextContent(t),e}return/^ {2,}$/.test(i)&&function(t,e){for(let n=e-1;n>=0;n--){if(c(t[n]))return!1;if(/\S/.test(t[n].getTextContent()))return!0}return!1}(n,o)?(r.setTextContent(""),i):null}function Et(t){const e=l(),n=Tt(t);return null!==n&&o(e,mt,n),e}const $t=t=>(e,n,o,r)=>{const i=t(o);i.append(...n),e.replace(i),r||i.select(0,0)};const vt=t=>(e,n,r,i)=>{const s=e.getPreviousSibling(),l=e.getNextSibling(),c=A("check"===t?"x"===r[3]:void 0),a=r[0].trim()[0],f="bullet"!==t&&"check"!==t||a!==ht.parse(a)?void 0:a;if(j(l)&&l.getListType()===t){f&&o(l,ht,f);const t=l.getFirstChild();null!==t?t.insertBefore(c):l.append(c),e.remove()}else if(j(s)&&s.getListType()===t)f&&o(s,ht,f),s.append(c),e.remove();else{const n=P(t,"number"===t?Number(r[2]):void 0);f&&o(n,ht,f),n.append(c),e.replace(n)}c.append(...n),i||c.select(0,0);const u=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}(r[1]);u&&c.setIndent(u)},It=(t,e,n,o)=>{const r=[],s=t.getChildren();let l=0;for(const c of s)if(z(c)){if(1===c.getChildrenSize()){const t=c.getFirstChild();if(j(t)){const i=It(t,e,n+1,o);i&&r.push(i);continue}}if(o&&!c.getChildren().some(t=>t.isSelected(o)))continue;const s=" ".repeat(4*n),a=t.getListType(),f=i(t,ht),u="number"===a?`${t.getStart()+l}. `:"check"===a?`${f} [${c.getChecked()?"x":" "}] `:f+" ";let d=e(c);"number"!==a&&(d=d.replace(/^(\s{0,3}\d+)(\.\s)/,"$1\\$2")),r.push(s+u+d),l++}return r.join("\n")},yt={dependencies:[W],export:(t,e)=>{if(!D(t))return null;const n=Number(t.getTag().slice(1));return"#".repeat(n)+" "+e(t)},regExp:it,replace:$t(t=>{const e="h"+t[1].length;return q(e)}),triggerOnEnter:!0,type:"element"},St={dependencies:[U],export:(t,e)=>{if(!H(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(H(n))return n.splice(n.getChildrenSize(),0,[Et(n),...e]),void t.remove()}const r=K();r.append(...e),t.replace(r),o||r.select(0,0)},triggerOnEnter:!0,type:"element"},bt={dependencies:[k],export:t=>{if(!F(t))return null;const e=t.getTextContent();let n=i(t,xt);if(e.indexOf(n)>-1){const t=e.match(/`{3,}/g);if(t){const e=Math.max(...t.map(t=>t.length));n="`".repeat(e+1)}}return n+(t.getLanguage()||"")+(e?"\n"+e:"")+"\n"+n},handleImportAfterStartMatch:({lines:t,rootNode:e,startLineIndex:n,startMatch:o})=>{const r=o[1],i=r.trim().length,s=t[n],l=o.index+r.length,c=s.slice(l),a=new RegExp(`\`{${i},}$`);if(a.test(c)){const t=c.match(a),r=c.slice(0,c.lastIndexOf(t[0])),i=[...o];return i[2]="",bt.replace(e,null,i,t,[r],!0),[!0,n]}const f=new RegExp(`^[ \\t]*\`{${i},}$`);for(let r=n+1;r<t.length;r++){const i=t[r];if(f.test(i)){const l=i.match(f),c=t.slice(n+1,r),a=s.slice(o[0].length);return a.length>0&&c.unshift(a),bt.replace(e,null,o,l,c,!0),[!0,r]}}const u=t.slice(n+1),d=s.slice(o[0].length);return d.length>0&&u.unshift(d),bt.replace(e,null,o,null,u,!0),[!0,t.length-1]},regExpEnd:{optional:!0,regExp:ct},regExpStart:lt,replace:(t,e,n,i,s,l)=>{let c,a;const f=n[1]?n[1].trim():"```",u=n[2]||void 0;if(!e&&s){if(1===s.length)i?(c=N(u),a=s[0]):(c=N(u),a=s[0].startsWith(" ")?s[0].slice(1):s[0]);else{for(c=N(u),s.length>0&&(0===s[0].trim().length?s.shift():s[0].startsWith(" ")&&(s[0]=s[0].slice(1)));s.length>0&&!s[s.length-1].length;)s.pop();a=s.join("\n")}o(c,xt,f);const e=r(a);c.append(e),t.append(c)}else e&&$t(t=>N(t?t[2]:void 0))(t,e,n,l)},type:"multiline-element"},wt={dependencies:[B,_],export:(t,e,n)=>j(t)?It(t,e,0,n):null,regExp:ot,replace:vt("bullet"),triggerOnEnter:!0,type:"element"},kt={dependencies:[B,_],export:(t,e,n)=>j(t)?It(t,e,0,n):null,regExp:rt,replace:vt("check"),triggerOnEnter:!0,type:"element"},Nt={dependencies:[B,_],export:(t,e,n)=>j(t)?It(t,e,0,n):null,regExp:nt,replace:vt("number"),triggerOnEnter:!0,type:"element"},Ft={format:["code"],tag:"`",type:"text-format"},Lt={format:["highlight"],tag:"==",type:"text-format"},Ot={format:["bold","italic"],tag:"***",type:"text-format"},Mt={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},Rt={format:["bold"],tag:"**",type:"text-format"},Bt={format:["bold"],intraword:!1,tag:"__",type:"text-format"},_t={format:["strikethrough"],tag:"~~",type:"text-format"},jt={format:["italic"],tag:"*",type:"text-format"},At={format:["italic"],intraword:!1,tag:"_",type:"text-format"},Pt={dependencies:[L],export:(t,e,n)=>{if(!O(t)||R(t))return null;const o=e(t);let r=t.getTitle();null!=r&&(r=r.replace(/([\\"])/g,"\\$1"));return r?`[${o}](${t.getURL()} "${r}")`:`[${o}](${t.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[\]]*(?:\[[^[\]]*\][^[\]]*)*)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,e)=>{if(s(t,O))return;const[,n,o,i]=e,l=null!=o?et(o):void 0,c=null!=i?et(i):void 0,a=M(l,{title:c}),f=n.split("[").length-1,u=n.split("]").length-1;let d=n,g="";if(f<u)return;if(f>u){const t=n.split("[");g="["+t[0],d=t.slice(1).join("[")}const p=r(d);return p.setFormat(t.getFormat()),a.append(p),t.replace(a),g&&a.insertBefore(r(g)),p},trigger:")",type:"text-match"},zt=[yt,St,wt,Nt],Wt=[bt],Ut=[Ft,Ot,Mt,Rt,Bt,Lt,jt,At,_t],Dt=[Pt],Ht=[...zt,...Wt,...Ut,...Dt];function Kt(t,e,n,o,r,i){let s=t.isSelected(e);for(const l of n){if(!l.export)continue;const n=l.export(t,t=>qt(t,e,o,r,i).markdown,e);if(null!=n){if(!s&&f(t)){qt(t,e,o,r,i).shouldInclude&&(s=!0)}return{markdown:n,shouldInclude:s}}}if(f(t)){const n=qt(t,e,o,r,i);return{markdown:n.markdown,shouldInclude:s||n.shouldInclude}}return u(t)?{markdown:t.getTextContent(),shouldInclude:s}:{markdown:null,shouldInclude:s}}function qt(t,n,o,r,i,s,l){const a=[],d=t.getChildren();let g=!1;s||(s=[]),l||(l=[]);t:for(const t of d){let d=t.isSelected(n);for(const e of r){if(!e.export)continue;const c=e.export(t,t=>qt(t,n,o,r,i,s,[...l,...s]).markdown,(t,e)=>Vt(t,w(n,t,"clone").getTextContent(),o,s,l,i));if(null!=c){!d&&f(t)&&t.getChildren().some(t=>t.isSelected(n))&&t.extractWithChild(t,n,"html")&&(d=!0),d&&(a.push(c),g=!0);continue t}}if(c(t))d&&(a.push(Qt(t)),g=!0);else if(e(t)){if(d){const e=w(n,t,"clone");a.push(Vt(t,e.getTextContent(),o,s,l,i)),g=!0}}else if(f(t)){const e=qt(t,n,o,r,i,s,l);!d&&e.shouldInclude&&t.extractWithChild(t,n,"html")&&(d=!0),(d||e.shouldInclude)&&(a.push(e.markdown),g=!0)}else u(t)&&d&&(a.push(t.getTextContent()),g=!0)}return{markdown:a.join(""),shouldInclude:g}}function Gt(t,e,n,o,r){for(const i of e){if(!i.export)continue;const e=i.export(t,t=>Jt(t,n,o,void 0,void 0,r));if(null!=e)return e}return f(t)?Jt(t,n,o,void 0,void 0,r):u(t)?t.getTextContent():null}function Jt(t,n,o,r,i,s=!1){const l=[],a=t.getChildren();r||(r=[]),i||(i=[]);t:for(const t of a){for(const e of o){if(!e.export)continue;const c=e.export(t,t=>Jt(t,n,o,r,[...i,...r],s),(t,e)=>Vt(t,e,n,r,i,s));if(null!=c){l.push(c);continue t}}c(t)?l.push(Qt(t)):e(t)?l.push(Vt(t,t.getTextContent(),n,r,i,s)):f(t)?l.push(Jt(t,n,o,r,i,s)):u(t)&&l.push(t.getTextContent())}return l.join("")}function Qt(t){return i(t,mt)+"\n"}function Vt(t,e,n,o,r,i=!1){let s=e;t.hasFormat("code")||(s=i?s.replace(/([*_`~])/g,"\\$1"):s.replace(/([*_`~\\])/g,"\\$1"));const l=s.match(/^(\s*)(.*?)(\s*)$/s)||["","",s,""],c=l[1],a=l[2],f=l[3],u=""===a;let d="",g="",p="";const h=Xt(t,!0),x=Xt(t,!1),m=new Set;for(const e of n){const n=e.format[0],r=e.tag;Zt(t,n)&&!m.has(n)&&(m.add(n),Zt(h,n)&&o.find(t=>t.tag===r)||(o.push({format:n,tag:r}),d+=r))}for(let e=0;e<o.length;e++){const n=Yt(t,o[e].format),i=Yt(x,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||(p+=t.tag):g+=t.tag),o.pop())}break}return u&&!t.hasFormat("code")?g+s:g+c+d+a+p+f}function Xt(t,n){const o=n?t.getPreviousSibling():t.getNextSibling();return e(o)?o:null}function Yt(t,n){return e(t)&&t.hasFormat(n)}function Zt(t,e){return!!Yt(t,e)&&("code"===e||(!t||!/^\s*$/.test(t.getTextContent())))}function te(t,e){const n=t.getTextContent(),o=e.fullMatchRegExpByTag["`"],r=e.transformersByTag["`"],i=[];let s=null;if(o&&r){const t=new RegExp(o.source,"g"),e=Array.from(n.matchAll(t));for(const t of e){const e=t.index+t[1].length,n=t.index+t[0].length;s||(s={content:t[3],endIndex:n,startIndex:e,tag:"`"}),i.push({end:n,start:e})}}const l=function(t,e,n=[]){const o=[],r=new Set(Object.keys(e.transformersByTag).filter(t=>"`"!==t[0]).map(t=>t[0])),i=e=>{let n=0;for(let o=e-1;o>=0&&"\\"===t[o];o--)n++;return n%2==1},s=t=>n.some(e=>t>=e.start&&t<e.end);let l=0;for(;l<t.length;){const e=t[l];if(!r.has(e)||i(l)||s(l)){l++;continue}let n=1;for(;l+n<t.length&&t[l+n]===e;)n++;const c=ee(e,t,l,n,!0),a=ee(e,t,l,n,!1);(c||a)&&o.push({active:!0,canClose:a,canOpen:c,char:e,index:l,length:n,originalLength:n}),l+=n}return o}(n,e,i),c=l.length>0?function(t,e,n){const o={};let r=0,i=null;for(;r<e.length;){const s=e[r];if(!s.active||!s.canClose||0===s.length){r++;continue}const l=`${s.char}${s.canOpen}`,c=o[l]??-1;let a=!1;for(let o=r-1;o>c;o--){const l=e[o];if(!l.active||!l.canOpen||0===l.length||l.char!==s.char)continue;if(l.canClose||s.canOpen){if((l.originalLength+s.originalLength)%3==0&&l.originalLength%3!=0&&s.originalLength%3!=0)continue}const c=Math.min(l.length,s.length),f=Object.keys(n.transformersByTag).filter(t=>t[0]===l.char&&t.length<=c).sort((t,e)=>e.length-t.length)[0];if(!f)continue;a=!0;const u=f.length,d={content:t.slice(l.index+l.length,s.index),endIndex:s.index+u,startIndex:l.index+(l.length-u),tag:f};(!i||d.startIndex<i.startIndex||d.startIndex===i.startIndex&&d.endIndex>i.endIndex)&&(i=d);for(let t=o+1;t<r;t++)e[t].active=!1;l.length-=u,s.length-=u,l.active=l.length>0,s.length>0?s.index+=u:(s.active=!1,r++);break}a||(o[l]=r-1,s.canOpen||(s.active=!1),r++)}return i}(n,l,e):null;let a=null,f=null;if(s&&c?c.startIndex<=s.startIndex&&c.endIndex>=s.endIndex?(a=c,f=e.transformersByTag[c.tag]):(a=s,f=r):s?(a=s,f=r):c&&(a=c,f=e.transformersByTag[c.tag]),!a||!f)return null;const u=[n.slice(a.startIndex,a.endIndex),a.tag,a.content];return u.index=a.startIndex,u.input=n,{endIndex:a.endIndex,match:u,startIndex:a.startIndex,transformer:f}}function ee(t,e,n,o,r){if(!ne(e,n,o,r))return!1;if("*"===t)return!0;if("_"===t){if(!ne(e,n,o,!r))return!0;const t=r?e[n-1]:e[n+o];return void 0!==t&&Y.test(t)}return!0}function ne(t,e,n,o){const r=t[e-1],i=t[e+n],[s,l]=o?[i,r]:[r,i];return void 0!==s&&!X.test(s)&&(!Y.test(s)||(void 0===l||X.test(l)||Y.test(l)))}function oe(t){return e(t)&&!t.hasFormat("code")}function re(t,e,n){let o=te(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||c<=o))&&(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.startIndex>o.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);oe(r.nodeAfter)&&re(r.nodeAfter,e,n),oe(r.nodeBefore)&&re(r.nodeBefore,e,n),oe(r.transformedNode)&&re(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;oe(o.nodeAfter)&&re(o.nodeAfter,e,n),oe(o.nodeBefore)&&re(o.nodeBefore,e,n),oe(o.transformedNode)&&re(o.transformedNode,e,n)}const i=et(t.getTextContent());t.setTextContent(i)}function ie(t,e=!1){const n=Q(t),o=function(t){const e={},n={},o=[];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]="`"===t?new RegExp("(^|[^\\\\`])(`)((?:\\\\`|[^`])+?)(`)(?!`)"):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(`(${o.join("|")})`,"g"),transformersByTag:e}}(n.textFormat);return(t,r)=>{const i=t.split("\n"),s=i.length,l=r||a();l.clear();for(let t=0;t<s;t++){const r=i[t],[s,c]=se(i,t,n.multilineElement,l);s?t=c:le(r,l,n.element,o,n.textMatch,e)}const c=l.getChildren();for(const t of c)if(!e&&tt(t)&&l.getChildrenSize()>1)t.remove();else if(f(t))for(const e of t.getAllTextNodes())ce(e);null!==d()&&l.selectStart()}}function se(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 a="object"==typeof i&&"regExp"in i?i.regExp:i,f=i&&"object"==typeof i&&"optional"in i?i.optional:!i;let u=e;const d=t.length;for(;u<d;){const n=a?t[u].match(a):null;if(!n&&(!f||f&&u<d-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 le(e,n,o,i,s,l){const c=r(e),a=g();a.append(c),n.append(a);for(const{regExp:t,replace:n}of o){const o=e.match(t);if(o&&(c.setTextContent(e.slice(o[0].length)),!1!==n(a,[c],o,!0)))break}if(re(c,i,s),a.isAttached()&&e.length>0){const e=a.getPreviousSibling();if(!l&&(t(e)||H(e)||j(e))){let t=e;if(j(e)){const n=e.getLastDescendant();t=null==n?null:G(n,z)}null!=t&&t.getTextContentSize()>0&&(t.splice(t.getChildrenSize(),0,[Et(t),...a.getChildren()]),a.remove())}}}function ce(t){const e=new Set,n=t.getTextContent();let o=n.indexOf("\t");for(;-1!==o;)e.add(o),e.add(o+1),o=n.indexOf("\t",o+1);t.splitText(...e).forEach(t=>{"\t"===t.getTextContent()&&t.replace(p())})}function ae(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 fe(t,e,n,o,r){const i=t.getParent();if(!y(i)||t.getFirstChild()!==e)return!1;const s=e.getTextContent();if(!r&&" "!==s[n-1])return!1;for(const{regExp:i,replace:l}of o){const o=s.match(i),c=r||o&&o[0].endsWith(" ")?n:n-1;if(o&&o[0].length===c){const r=e.getNextSiblings(),[i,s]=e.splitText(n);if(!1!==l(t,s?[s,...r]:r,o,!1))return i.remove(),!0}}return!1}function ue(t,e,n,o,r){const i=t.getParent();if(!y(i)||t.getFirstChild()!==e)return!1;const s=e.getTextContent();if(!r&&" "!==s[n-1])return!1;for(const{regExpStart:i,replace:l,regExpEnd:c}of o){if(c&&!("optional"in c)||c&&"optional"in c&&!c.optional)continue;const o=s.match(i);if(o){const i=r||o[0].endsWith(" ")?n:n-1;if(o[0].length!==i)continue;const s=e.getNextSiblings(),[c,a]=e.splitText(n);if(!1!==l(t,a?[a,...s]:s,o,null,null,!1))return c.remove(),!0}}return!1}function de(t,e){let n=0;const o=t.getTextContent();for(let t=0;t<e;t++)"`"===o[t]&&n++;return n%2!=0}function ge(t,e,n){const o=n.length;for(let r=e;r>=o;r--){const e=r-o;if(pe(t,e,n,0,o)&&" "!==t[e+o])return e}return-1}function pe(t,e,n,o,r){for(let i=0;i<r;i++)if(t[e+i]!==n[o+i])return!1;return!0}function he(t,n=Ht){const o=Q(n),r=o.element.filter(t=>t.triggerOnEnter),i=J(o.textFormat,({tag:t})=>t[t.length-1]),s=J(o.textMatch,({trigger:t})=>t),l=new Set([" "]);for(const t of o.textFormat)l.add(t.tag.slice(-1));for(const t of o.textMatch)void 0!==t.trigger&&l.add(t.trigger);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)||ae(173,e.getType())}}const a=(t,n,r)=>!!fe(t,n,r,o.element)||(!!ue(t,n,r,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,r,s)||!!function(t,n,o){const r=t.getTextContent(),i=n-1,s=r[i],l=o[s];if(!l)return!1;for(const n of l){const{tag:o}=n,l=o.length,a=i-l+1;if(l>1&&!pe(r,a,o,0,l))continue;if(" "===r[a-1])continue;const f=r[i+1];if(!1===n.intraword&&f&&!V.test(f))continue;const u=t;let g=u,p=ge(r,a,o),h=g;for(;p<0&&(h=h.getPreviousSibling())&&!c(h);)if(e(h)){if(h.hasFormat("code"))continue;const t=h.getTextContent();g=h,p=ge(t,t.length,o)}if(p<0)continue;if(g===u&&p+l===a)continue;const x=g.getTextContent();if(p>0&&x[p-1]===s)continue;const m=x[p-1];if(!1===n.intraword&&m&&!V.test(m))continue;if(!n.format.includes("code")&&de(g,p))continue;const C=u.getTextContent(),E=C.slice(0,a)+C.slice(i+1);u.setTextContent(E);const $=g===u?E:x;g.setTextContent($.slice(0,p)+$.slice(p+l));const v=d(),I=S();b(I);const y=i-l*(g===u?2:1)+1;I.anchor.set(g.__key,p,"text"),I.focus.set(u.__key,y,"text");for(const t of n.format)I.hasFormat(t)||I.formatText(t);I.anchor.set(I.focus.key,I.focus.offset,I.focus.type);for(const t of n.format)I.hasFormat(t)&&I.toggleFormat(t);return T(v)&&(I.format=v.format),!0}return!1}(n,r,i)));return h(t.registerUpdateListener(({tags:n,dirtyLeaves:o,editorState:r,prevEditorState:i})=>{if(n.has(x)||n.has(m))return;if(t.isComposing())return;const s=n.has(C),c=r.read(d),f=i.read(d);if(!T(f)||!T(c)||!c.isCollapsed()||c.is(f)&&!s)return;const u=c.anchor.key,g=c.anchor.offset,p=r._nodeMap.get(u);if(e(p)&&o.has(u)&&(s||1===g||!(g>f.anchor.offset+1))){if(s){const t=r.read(()=>p.getTextContent())[g-1];if(!l.has(t))return}t.update(()=>{if(!oe(p))return;const t=p.getParent();null===t||F(t)||a(t,p,c.anchor.offset)&&E($)})}}),t.registerCommand(v,t=>{if(null!==t&&t.shiftKey)return!1;const n=d();if(!T(n)||!n.isCollapsed())return!1;const i=n.anchor.offset,s=n.anchor.getNode();if(!e(s)||!oe(s))return!1;const l=s.getParent();if(null===l||F(l))return!1;return i===s.getTextContent().length&&(!(!ue(l,s,i,o.multilineElement,!0)&&!fe(l,s,i,r,!0))&&(null!==t&&t.preventDefault(),!0))},I))}function xe(t,e=Ht,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=i.trimEnd(),l=r[r.length-1],c=t<n.length-1?Ct(i):null,a=void 0!==l&&null!==Ct(l);at.test(s)?r.push(s):lt.test(s)||ct.test(s)?(o=!o,r.push(s)):o?r.push(i):""===s||""===l||!l||it.test(l)||it.test(s)||st.test(s)||nt.test(s)||ot.test(s)||rt.test(s)||ft.test(s)||ut.test(s)||a||!e||dt.test(s)||gt.test(s)||pt(gt).test(l)||pt(dt).test(l)||ct.test(l)?r.push(!e&&""!==s||null!==c?i:s):r[r.length-1]=l+" "+(null===c?s:i).trimStart()}return r.join("\n")}(t,r);return ie(e,o)(i,n)}function me(t=Ht,e,n=!1){const o=function(t,e=!1){const n=Q(t),o=[...n.multilineElement,...n.element],r=!e,i=n.textFormat.filter(t=>1===t.format.length).sort((t,e)=>Number(t.format.includes("code"))-Number(e.format.includes("code")));return t=>{const s=[],l=(t||a()).getChildren();for(let t=0;t<l.length;t++){const c=l[t],a=Gt(c,o,i,n.textMatch,e);null!=a&&s.push(r&&t>0&&!tt(c)&&!tt(l[t-1])?"\n".concat(a):a)}return s.join("\n")}}(t,n);return o(e)}function Ce(t=Ht,e,n=!1){if(!e||T(e)&&e.isCollapsed())return"";const o=function(t,e=!1){const n=Q(t),o=[...n.multilineElement,...n.element],r=!e,i=n.textFormat.filter(t=>1===t.format.length).sort((t,e)=>Number(t.format.includes("code"))-Number(e.format.includes("code")));return t=>{const s=[],l=a().getChildren();for(let c=0;c<l.length;c++){const a=l[c],{shouldInclude:f,markdown:u}=Kt(a,t,o,i,n.textMatch,e);f&&null!=u&&s.push(r&&c>0&&!tt(a)&&!tt(l[c-1])?"\n".concat(u):u)}return s.join("\n")}}(t,n);return o(e)}export{xe as $convertFromMarkdownString,Ce as $convertSelectionToMarkdownString,me as $convertToMarkdownString,Ot as BOLD_ITALIC_STAR,Mt as BOLD_ITALIC_UNDERSCORE,Rt as BOLD_STAR,Bt as BOLD_UNDERSCORE,kt as CHECK_LIST,bt as CODE,zt as ELEMENT_TRANSFORMERS,yt as HEADING,Lt as HIGHLIGHT,Ft as INLINE_CODE,jt as ITALIC_STAR,At as ITALIC_UNDERSCORE,Pt as LINK,Wt as MULTILINE_ELEMENT_TRANSFORMERS,Nt as ORDERED_LIST,St as QUOTE,_t as STRIKETHROUGH,Ut as TEXT_FORMAT_TRANSFORMERS,Dt as TEXT_MATCH_TRANSFORMERS,Ht as TRANSFORMERS,wt as UNORDERED_LIST,he as registerMarkdownShortcuts};
package/package.json CHANGED
@@ -8,41 +8,56 @@
8
8
  "markdown"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.44.1-nightly.20260519.0",
12
- "main": "LexicalMarkdown.js",
13
- "types": "index.d.ts",
11
+ "version": "0.45.1-dev.0",
12
+ "main": "./dist/LexicalMarkdown.js",
13
+ "types": "./dist/index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/code-core": "0.44.1-nightly.20260519.0",
16
- "@lexical/link": "0.44.1-nightly.20260519.0",
17
- "@lexical/list": "0.44.1-nightly.20260519.0",
18
- "@lexical/rich-text": "0.44.1-nightly.20260519.0",
19
- "@lexical/selection": "0.44.1-nightly.20260519.0",
20
- "@lexical/text": "0.44.1-nightly.20260519.0",
21
- "@lexical/utils": "0.44.1-nightly.20260519.0",
22
- "lexical": "0.44.1-nightly.20260519.0"
15
+ "@lexical/code-core": "0.45.1-dev.0",
16
+ "@lexical/internal": "0.45.1-dev.0",
17
+ "@lexical/link": "0.45.1-dev.0",
18
+ "@lexical/list": "0.45.1-dev.0",
19
+ "@lexical/rich-text": "0.45.1-dev.0",
20
+ "@lexical/selection": "0.45.1-dev.0",
21
+ "@lexical/text": "0.45.1-dev.0",
22
+ "@lexical/utils": "0.45.1-dev.0",
23
+ "lexical": "0.45.1-dev.0"
23
24
  },
24
25
  "repository": {
25
26
  "type": "git",
26
27
  "url": "git+https://github.com/facebook/lexical.git",
27
28
  "directory": "packages/lexical-markdown"
28
29
  },
29
- "module": "LexicalMarkdown.mjs",
30
+ "module": "./dist/LexicalMarkdown.mjs",
30
31
  "sideEffects": false,
31
32
  "exports": {
32
33
  ".": {
34
+ "source": "./src/index.ts",
33
35
  "import": {
34
- "types": "./index.d.ts",
35
- "development": "./LexicalMarkdown.dev.mjs",
36
- "production": "./LexicalMarkdown.prod.mjs",
37
- "node": "./LexicalMarkdown.node.mjs",
38
- "default": "./LexicalMarkdown.mjs"
36
+ "types": "./dist/index.d.ts",
37
+ "development": "./dist/LexicalMarkdown.dev.mjs",
38
+ "production": "./dist/LexicalMarkdown.prod.mjs",
39
+ "node": "./dist/LexicalMarkdown.node.mjs",
40
+ "default": "./dist/LexicalMarkdown.mjs"
39
41
  },
40
42
  "require": {
41
- "types": "./index.d.ts",
42
- "development": "./LexicalMarkdown.dev.js",
43
- "production": "./LexicalMarkdown.prod.js",
44
- "default": "./LexicalMarkdown.js"
43
+ "types": "./dist/index.d.ts",
44
+ "development": "./dist/LexicalMarkdown.dev.js",
45
+ "production": "./dist/LexicalMarkdown.prod.js",
46
+ "default": "./dist/LexicalMarkdown.js"
45
47
  }
46
48
  }
47
- }
49
+ },
50
+ "files": [
51
+ "dist",
52
+ "src",
53
+ "!src/__tests__",
54
+ "!src/__bench__",
55
+ "!src/__mocks__",
56
+ "!src/**/*.test.ts",
57
+ "!src/**/*.test.tsx",
58
+ "!src/**/*.bench.ts",
59
+ "!src/**/*.bench.tsx",
60
+ "README.md",
61
+ "LICENSE"
62
+ ]
48
63
  }