@lexical/markdown 0.41.0 → 0.41.1-nightly.20260227.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.
@@ -168,12 +168,21 @@ unclosedTags, unclosableTags) {
168
168
  // If the node has no format, we use the original text.
169
169
  // Otherwise, we escape leading and trailing whitespaces to their corresponding code points,
170
170
  // ensuring the returned string maintains its original formatting, e.g., "**   foo   **".
171
- let output = node.getFormat() === 0 ? textContent : escapeLeadingAndTrailingWhitespaces(textContent);
171
+
172
+ let output = textContent;
172
173
  if (!node.hasFormat('code')) {
173
174
  // Escape any markdown characters in the text content
174
175
  output = output.replace(/([*_`~\\])/g, '\\$1');
175
176
  }
176
177
 
178
+ // Extract leading and trailing whitespaces.
179
+ // CommonMark flanking rules require formatting tags to be adjacent to non-whitespace characters.
180
+ const match = output.match(/^(\s*)(.*?)(\s*)$/s) || ['', '', output, ''];
181
+ const leadingSpace = match[1];
182
+ const trimmedOutput = match[2];
183
+ const trailingSpace = match[3];
184
+ const isWhitespaceOnly = trimmedOutput === '';
185
+
177
186
  // the opening tags to be added to the result
178
187
  let openingTags = '';
179
188
  // the closing tags to be added to the result
@@ -187,13 +196,12 @@ unclosedTags, unclosableTags) {
187
196
  const tag = transformer.tag;
188
197
 
189
198
  // dedup applied formats
190
- if (hasFormat(node, format) && !applied.has(format)) {
191
- // Multiple tags might be used for the same format (*, _)
199
+ if (checkHasFormat(node, format) && !applied.has(format)) {
192
200
  applied.add(format);
193
201
 
194
202
  // append the tag to openingTags, if it's not applied to the previous nodes,
195
203
  // or the nodes before that (which would result in an unclosed tag)
196
- if (!hasFormat(prevNode, format) || !unclosedTags.find(element => element.tag === tag)) {
204
+ if (!checkHasFormat(prevNode, format) || !unclosedTags.find(element => element.tag === tag)) {
197
205
  unclosedTags.push({
198
206
  format,
199
207
  tag
@@ -236,9 +244,14 @@ unclosedTags, unclosableTags) {
236
244
  }
237
245
  break;
238
246
  }
239
- output = openingTags + output + closingTagsAfter;
240
- // Replace trimmed version of textContent ensuring surrounding whitespace is not modified
241
- return closingTagsBefore + output;
247
+ // If the node is entirely whitespace, we don't apply opening/closing tags around it.
248
+ // However, it must still output closing tags from previous nodes.
249
+ if (isWhitespaceOnly && !node.hasFormat('code')) {
250
+ return closingTagsBefore + output;
251
+ }
252
+
253
+ // Flanking Compliance: Notice how openingTags and closingTagsAfter are placed INSIDE the whitespace boundaries!
254
+ return closingTagsBefore + leadingSpace + openingTags + trimmedOutput + closingTagsAfter + trailingSpace;
242
255
  }
243
256
  function getTextSibling(node, backward) {
244
257
  const sibling = backward ? node.getPreviousSibling() : node.getNextSibling();
@@ -250,10 +263,17 @@ function getTextSibling(node, backward) {
250
263
  function hasFormat(node, format) {
251
264
  return lexical.$isTextNode(node) && node.hasFormat(format);
252
265
  }
253
- function escapeLeadingAndTrailingWhitespaces(textContent) {
254
- return textContent.replace(/^\s+|\s+$/g, match => {
255
- return [...match].map(char => '&#' + char.codePointAt(0) + ';').join('');
256
- });
266
+ function checkHasFormat(n, f) {
267
+ if (!hasFormat(n, f)) {
268
+ return false;
269
+ }
270
+ if (f === 'code') {
271
+ return true;
272
+ }
273
+ if (n && /^\s*$/.test(n.getTextContent())) {
274
+ return false;
275
+ }
276
+ return true;
257
277
  }
258
278
 
259
279
  /**
@@ -8,7 +8,7 @@
8
8
 
9
9
  import { $isParagraphNode, $isTextNode, $getRoot, $isElementNode, $isDecoratorNode, $isLineBreakNode, $getSelection, $createTextNode, $createParagraphNode, $createLineBreakNode, createState, $setState, $getState, $findMatchingParent as $findMatchingParent$1, mergeRegister, COLLABORATION_TAG, HISTORIC_TAG, $isRangeSelection, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $isRootOrShadowRoot, $createRangeSelection, $setSelection } from 'lexical';
10
10
  import { $isListNode, $isListItemNode, ListNode, ListItemNode, $createListItemNode, $createListNode } from '@lexical/list';
11
- import { $isQuoteNode, HeadingNode, QuoteNode, $createHeadingNode, $isHeadingNode, $createQuoteNode } from '@lexical/rich-text';
11
+ import { $isQuoteNode, HeadingNode, QuoteNode, $isHeadingNode, $createQuoteNode, $createHeadingNode } from '@lexical/rich-text';
12
12
  import { $findMatchingParent } from '@lexical/utils';
13
13
  import { CodeNode, $createCodeNode, $isCodeNode } from '@lexical/code';
14
14
  import { LinkNode, $isLinkNode, $createLinkNode, $isAutoLinkNode } from '@lexical/link';
@@ -166,12 +166,21 @@ unclosedTags, unclosableTags) {
166
166
  // If the node has no format, we use the original text.
167
167
  // Otherwise, we escape leading and trailing whitespaces to their corresponding code points,
168
168
  // ensuring the returned string maintains its original formatting, e.g., "**   foo   **".
169
- let output = node.getFormat() === 0 ? textContent : escapeLeadingAndTrailingWhitespaces(textContent);
169
+
170
+ let output = textContent;
170
171
  if (!node.hasFormat('code')) {
171
172
  // Escape any markdown characters in the text content
172
173
  output = output.replace(/([*_`~\\])/g, '\\$1');
173
174
  }
174
175
 
176
+ // Extract leading and trailing whitespaces.
177
+ // CommonMark flanking rules require formatting tags to be adjacent to non-whitespace characters.
178
+ const match = output.match(/^(\s*)(.*?)(\s*)$/s) || ['', '', output, ''];
179
+ const leadingSpace = match[1];
180
+ const trimmedOutput = match[2];
181
+ const trailingSpace = match[3];
182
+ const isWhitespaceOnly = trimmedOutput === '';
183
+
175
184
  // the opening tags to be added to the result
176
185
  let openingTags = '';
177
186
  // the closing tags to be added to the result
@@ -185,13 +194,12 @@ unclosedTags, unclosableTags) {
185
194
  const tag = transformer.tag;
186
195
 
187
196
  // dedup applied formats
188
- if (hasFormat(node, format) && !applied.has(format)) {
189
- // Multiple tags might be used for the same format (*, _)
197
+ if (checkHasFormat(node, format) && !applied.has(format)) {
190
198
  applied.add(format);
191
199
 
192
200
  // append the tag to openingTags, if it's not applied to the previous nodes,
193
201
  // or the nodes before that (which would result in an unclosed tag)
194
- if (!hasFormat(prevNode, format) || !unclosedTags.find(element => element.tag === tag)) {
202
+ if (!checkHasFormat(prevNode, format) || !unclosedTags.find(element => element.tag === tag)) {
195
203
  unclosedTags.push({
196
204
  format,
197
205
  tag
@@ -234,9 +242,14 @@ unclosedTags, unclosableTags) {
234
242
  }
235
243
  break;
236
244
  }
237
- output = openingTags + output + closingTagsAfter;
238
- // Replace trimmed version of textContent ensuring surrounding whitespace is not modified
239
- return closingTagsBefore + output;
245
+ // If the node is entirely whitespace, we don't apply opening/closing tags around it.
246
+ // However, it must still output closing tags from previous nodes.
247
+ if (isWhitespaceOnly && !node.hasFormat('code')) {
248
+ return closingTagsBefore + output;
249
+ }
250
+
251
+ // Flanking Compliance: Notice how openingTags and closingTagsAfter are placed INSIDE the whitespace boundaries!
252
+ return closingTagsBefore + leadingSpace + openingTags + trimmedOutput + closingTagsAfter + trailingSpace;
240
253
  }
241
254
  function getTextSibling(node, backward) {
242
255
  const sibling = backward ? node.getPreviousSibling() : node.getNextSibling();
@@ -248,10 +261,17 @@ function getTextSibling(node, backward) {
248
261
  function hasFormat(node, format) {
249
262
  return $isTextNode(node) && node.hasFormat(format);
250
263
  }
251
- function escapeLeadingAndTrailingWhitespaces(textContent) {
252
- return textContent.replace(/^\s+|\s+$/g, match => {
253
- return [...match].map(char => '&#' + char.codePointAt(0) + ';').join('');
254
- });
264
+ function checkHasFormat(n, f) {
265
+ if (!hasFormat(n, f)) {
266
+ return false;
267
+ }
268
+ if (f === 'code') {
269
+ return true;
270
+ }
271
+ if (n && /^\s*$/.test(n.getTextContent())) {
272
+ return false;
273
+ }
274
+ return true;
255
275
  }
256
276
 
257
277
  /**
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("lexical"),t=require("@lexical/list"),n=require("@lexical/rich-text"),o=require("@lexical/utils"),r=require("@lexical/code"),s=require("@lexical/link");function i(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=i(e,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}const l=/[!-/:-@[-`{-~\s]/,a=/[ \t\n\r\f]/,f=/[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~]/,d=/^\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)&&d.test(n.getTextContent())}function u(t,n,o,r){for(const e of n){if(!e.export)continue;const n=e.export(t,e=>p(e,o,r));if(null!=n)return n}return e.$isElementNode(t)?p(t,o,r):e.$isDecoratorNode(t)?t.getTextContent():null}function p(t,n,o,r,s){const i=[],c=t.getChildren();r||(r=[]),s||(s=[]);e:for(const t of c){for(const e of o){if(!e.export)continue;const c=e.export(t,e=>p(e,n,o,r,[...s,...r]),(e,t)=>x(e,t,n,r,s));if(null!=c){i.push(c);continue e}}e.$isLineBreakNode(t)?i.push("\n"):e.$isTextNode(t)?i.push(x(t,t.getTextContent(),n,r,s)):e.$isElementNode(t)?i.push(p(t,n,o,r,s)):e.$isDecoratorNode(t)&&i.push(t.getTextContent())}return i.join("")}function x(e,t,n,o,r){let s=0===e.getFormat()?t:function(e){return e.replace(/^\s+|\s+$/g,e=>[...e].map(e=>"&#"+e.codePointAt(0)+";").join(""))}(t);e.hasFormat("code")||(s=s.replace(/([*_`~\\])/g,"\\$1"));let i="",c="",l="";const a=h(e,!0),f=h(e,!1),d=new Set;for(const t of n){const n=t.format[0],r=t.tag;m(e,n)&&!d.has(n)&&(d.add(n),m(a,n)&&o.find(e=>e.tag===r)||(o.push({format:n,tag:r}),i+=r))}for(let t=0;t<o.length;t++){const n=m(e,o[t].format),s=m(f,o[t].format);if(n&&s)continue;const i=[...o];for(;i.length>t;){const e=i.pop();r&&e&&r.find(t=>t.tag===e.tag)||(e&&"string"==typeof e.tag&&(n?s||(l+=e.tag):c+=e.tag),o.pop())}break}return s=i+s+l,c+s}function h(t,n){const o=n?t.getPreviousSibling():t.getNextSibling();return e.$isTextNode(o)?o:null}function m(t,n){return e.$isTextNode(t)&&t.hasFormat(n)}function $(e,t){const n=e.getTextContent(),o=t.fullMatchRegExpByTag["`"],r=t.transformersByTag["`"],s=[];let i=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,n=t+e[0].length;i||(i={content:e[2],endIndex:n,startIndex:t,tag:"`"}),s.push({end:n,start:t})}}const c=function(e,t,n=[]){const o=[],r=new Set(Object.keys(t.transformersByTag).filter(e=>"`"!==e[0]).map(e=>e[0])),s=t=>{let n=0;for(let o=t-1;o>=0&&"\\"===e[o];o--)n++;return n%2==1},i=e=>n.some(t=>e>=t.start&&e<t.end);let c=0;for(;c<e.length;){const t=e[c];if(!r.has(t)||s(c)||i(c)){c++;continue}let n=1;for(;c+n<e.length&&e[c+n]===t;)n++;const l=N(t,e,c,n,!0),a=N(t,e,c,n,!1);(l||a)&&o.push({active:!0,canClose:a,canOpen:l,char:t,index:c,length:n,originalLength:n}),c+=n}return o}(n,t,s),l=c.length>0?function(e,t,n){const o={};let r=0,s=null;for(;r<t.length;){const i=t[r];if(!i.active||!i.canClose||0===i.length){r++;continue}const c=`${i.char}${i.canOpen}`,l=o[c]??-1;let a=!1;for(let o=r-1;o>l;o--){const c=t[o];if(!c.active||!c.canOpen||0===c.length||c.char!==i.char)continue;if(c.canClose||i.canOpen){if((c.originalLength+i.originalLength)%3==0&&c.originalLength%3!=0&&i.originalLength%3!=0)continue}const l=Math.min(c.length,i.length),f=Object.keys(n.transformersByTag).filter(e=>e[0]===c.char&&e.length<=l).sort((e,t)=>t.length-e.length)[0];if(!f)continue;a=!0;const d=f.length,g={content:e.slice(c.index+c.length,i.index),endIndex:i.index+d,startIndex:c.index+(c.length-d),tag:f};(!s||g.startIndex<s.startIndex||g.startIndex===s.startIndex&&g.endIndex>s.endIndex)&&(s=g);for(let e=o+1;e<r;e++)t[e].active=!1;c.length-=d,i.length-=d,c.active=c.length>0,i.length>0?i.index+=d:(i.active=!1,r++);break}a||(o[c]=r-1,i.canOpen||(i.active=!1),r++)}return s}(n,c,t):null;let a=null,f=null;if(i&&l?l.startIndex<=i.startIndex&&l.endIndex>=i.endIndex?(a=l,f=t.transformersByTag[l.tag]):(a=i,f=r):i?(a=i,f=r):l&&(a=l,f=t.transformersByTag[l.tag]),!a||!f)return null;const d=[n.slice(a.startIndex,a.endIndex),a.tag,a.content];return d.index=a.startIndex,d.input=n,{endIndex:a.endIndex,match:d,startIndex:a.startIndex,transformer:f}}function N(e,t,n,o,r){if(!T(t,n,o,r))return!1;if("*"===e)return!0;if("_"===e){if(!T(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 T(e,t,n,o){const r=e[t-1],s=e[t+n],[i,c]=o?[s,r]:[r,s];return void 0!==i&&!a.test(i)&&(!f.test(i)||(void 0===c||a.test(c)||f.test(c)))}function E(t){return e.$isTextNode(t)&&!t.hasFormat("code")}function S(e,t,n){let o=$(e,t),r=function(e,t){const n=e;let o,r,s,i;for(const e of t){if(!e.replace||!e.importRegExp)continue;const t=n.getTextContent().match(e.importRegExp);if(!t)continue;const c=t.index||0,l=e.getEndIndex?e.getEndIndex(n,t):c+t[0].length;!1!==l&&(void 0===o||void 0===r||c<o&&(l>r||l<=o))&&(o=c,r=l,s=e,i=t)}return void 0===o||void 0===r||void 0===s||void 0===i?null:{endIndex:r,match:i,startIndex:o,transformer:s}}(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 s=e.getTextContent();let i,c,l;if(r[0]===s?i=e:0===t?[i,c]=e.splitText(n):[l,i,c]=e.splitText(t,n),i.setTextContent(r[2]),o)for(const e of o.format)i.hasFormat(e)||i.toggleFormat(e);return{nodeAfter:c,nodeBefore:l,transformedNode:i}}(e,o.startIndex,o.endIndex,o.transformer,o.match);E(r.nodeAfter)&&S(r.nodeAfter,t,n),E(r.nodeBefore)&&S(r.nodeBefore,t,n),E(r.transformedNode)&&S(r.transformedNode,t,n)}else if(r){const o=function(e,t,n,o,r){let s,i,c;return 0===t?[s,i]=e.splitText(n):[c,s,i]=e.splitText(t,n),o.replace?{nodeAfter:i,nodeBefore:c,transformedNode:o.replace(s,r)||void 0}:null}(e,r.startIndex,r.endIndex,r.transformer,r.match);if(!o)return;E(o.nodeAfter)&&S(o.nodeAfter,t,n),E(o.nodeBefore)&&S(o.nodeBefore,t,n),E(o.transformedNode)&&S(o.transformedNode,t,n)}const s=e.getTextContent().replace(/\\([*_`~\\])/g,"$1").replace(/&#(\d+);/g,(e,t)=>String.fromCodePoint(t));e.setTextContent(s)}function C(t,n=!1){const o=c(t),r=function(e){const t={},n={},o=[],r="(?<![\\\\])";for(const r of e){const{tag:e}=r;t[e]=r;const s=e.replace(/(\*|\^|\+)/g,"\\$1");o.push(s),1===e.length?n[e]="`"===e?new RegExp("(?<![\\\\`])(`)((?:\\\\`|[^`])+?)(`)(?!`)"):new RegExp(`(?<![\\\\${s}])(${s})((\\\\${s})?.*?[^${s}\\s](\\\\${s})?)((?<!\\\\)|(?<=\\\\\\\\))(${s})(?![\\\\${s}])`):n[e]=new RegExp(`(?<!\\\\)(${s})((\\\\${s})?.*?[^\\s](\\\\${s})?)((?<!\\\\)|(?<=\\\\\\\\))(${s})(?!\\\\)`)}return{fullMatchRegExpByTag:n,openTagsRegExp:new RegExp(`${r}(${o.join("|")})`,"g"),transformersByTag:t}}(o.textFormat);return(t,s)=>{const i=t.split("\n"),c=i.length,l=s||e.$getRoot();l.clear();for(let e=0;e<c;e++){const t=i[e],[s,c]=I(i,e,o.multilineElement,l);s?e=c:L(t,l,o.element,r,o.textMatch,n)}const a=l.getChildren();for(const e of a)!n&&g(e)&&l.getChildrenSize()>1&&e.remove();null!==e.$getSelection()&&l.selectStart()}}function I(e,t,n,o){for(const r of n){const{handleImportAfterStartMatch:n,regExpEnd:s,regExpStart:i,replace:c}=r,l=e[t].match(i);if(!l)continue;if(n){const s=n({lines:e,rootNode:o,startLineIndex:t,startMatch:l,transformer:r});if(null===s)continue;if(s)return s}const a="object"==typeof s&&"regExp"in s?s.regExp:s,f=s&&"object"==typeof s&&"optional"in s?s.optional:!s;let d=t;const g=e.length;for(;d<g;){const n=a?e[d].match(a):null;if(!n&&(!f||f&&d<g-1)){d++;continue}if(n&&t===d&&n.index===l.index){d++;continue}const r=[];if(n&&t===d)r.push(e[t].slice(l[0].length,-n[0].length));else for(let o=t;o<=d;o++)if(o===t){const t=e[o].slice(l[0].length);r.push(t)}else if(o===d&&n){const t=e[o].slice(0,-n[0].length);r.push(t)}else r.push(e[o]);if(!1!==c(o,null,l,n,r,!0))return[!0,d];break}}return[!1,t]}function L(r,s,i,c,l,a){const f=e.$createTextNode(r),d=e.$createParagraphNode();d.append(f),s.append(d);for(const{regExp:e,replace:t}of i){const n=r.match(e);if(n&&(f.setTextContent(r.slice(n[0].length)),!1!==t(d,[f],n,!0)))break}if(S(f,c,l),d.isAttached()&&r.length>0){const r=d.getPreviousSibling();if(!a&&(e.$isParagraphNode(r)||n.$isQuoteNode(r)||t.$isListNode(r))){let n=r;if(t.$isListNode(r)){const e=r.getLastDescendant();n=null==e?null:o.$findMatchingParent(e,t.$isListItemNode)}null!=n&&n.getTextContentSize()>0&&(n.splice(n.getChildrenSize(),0,[e.$createLineBreakNode(),...d.getChildren()]),d.remove())}}}function R(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.`)}const v=/^(\s*)(\d{1,})\.\s/,y=/^(\s*)[-*+]\s/,_=/^(\s*)(?:[-*+]\s)?\s?(\[(\s|x)?\])\s/i,O=/^(#{1,6})\s/,M=/^>\s/,A=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,b=/^[ \t]*`{3,}$/,k=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,F=/^(?:\|)(.+)(?:\|)\s?$/,w=/^(\| ?:?-*:? ?)+\|\s?$/,B=/^<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,D=/^<\/[a-z_][\w-]*\s*>/i,P=e=>new RegExp(`(?:${e.source})$`,e.flags),j=e.createState("mdListMarker",{parse:e=>"string"==typeof e&&/^[-*+]$/.test(e)?e:"-"}),H=e.createState("mdCodeFence",{parse:e=>"string"==typeof e&&/^`{3,}$/.test(e)?e:"```"}),U=e=>(t,n,o,r)=>{const s=e(o);s.append(...n),t.replace(s),r||s.select(0,0)};const z=n=>(o,r,s,i)=>{const c=o.getPreviousSibling(),l=o.getNextSibling(),a=t.$createListItemNode("check"===n?"x"===s[3]:void 0),f=s[0].trim()[0],d="bullet"!==n&&"check"!==n||f!==j.parse(f)?void 0:f;if(t.$isListNode(l)&&l.getListType()===n){d&&e.$setState(l,j,d);const t=l.getFirstChild();null!==t?t.insertBefore(a):l.append(a),o.remove()}else if(t.$isListNode(c)&&c.getListType()===n)d&&e.$setState(c,j,d),c.append(a),o.remove();else{const r=t.$createListNode(n,"number"===n?Number(s[2]):void 0);d&&e.$setState(r,j,d),r.append(a),o.replace(r)}a.append(...r),i||a.select(0,0);const g=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}(s[1]);g&&a.setIndent(g)},q=(n,o,r)=>{const s=[],i=n.getChildren();let c=0;for(const l of i)if(t.$isListItemNode(l)){if(1===l.getChildrenSize()){const e=l.getFirstChild();if(t.$isListNode(e)){s.push(q(e,o,r+1));continue}}const i=" ".repeat(4*r),a=n.getListType(),f=e.$getState(n,j),d="number"===a?`${n.getStart()+c}. `:"check"===a?`${f} [${l.getChecked()?"x":" "}] `:f+" ";s.push(i+d+o(l)),c++}return s.join("\n")},G={dependencies:[n.HeadingNode],export:(e,t)=>{if(!n.$isHeadingNode(e))return null;const o=Number(e.getTag().slice(1));return"#".repeat(o)+" "+t(e)},regExp:O,replace:U(e=>{const t="h"+e[1].length;return n.$createHeadingNode(t)}),type:"element"},Q={dependencies:[n.QuoteNode],export:(e,t)=>{if(!n.$isQuoteNode(e))return null;const o=t(e).split("\n"),r=[];for(const e of o)r.push("> "+e);return r.join("\n")},regExp:M,replace:(t,o,r,s)=>{if(s){const r=t.getPreviousSibling();if(n.$isQuoteNode(r))return r.splice(r.getChildrenSize(),0,[e.$createLineBreakNode(),...o]),void t.remove()}const i=n.$createQuoteNode();i.append(...o),t.replace(i),s||i.select(0,0)},type:"element"},K={dependencies:[r.CodeNode],export:t=>{if(!r.$isCodeNode(t))return null;const n=t.getTextContent();let o=e.$getState(t,H);if(n.indexOf(o)>-1){const e=n.match(/`{3,}/g);if(e){const t=Math.max(...e.map(e=>e.length));o="`".repeat(t+1)}}return o+(t.getLanguage()||"")+(n?"\n"+n:"")+"\n"+o},handleImportAfterStartMatch:({lines:e,rootNode:t,startLineIndex:n,startMatch:o})=>{const r=o[1],s=r.trim().length,i=e[n],c=o.index+r.length,l=i.slice(c),a=new RegExp(`\`{${s},}$`);if(a.test(l)){const e=l.match(a),r=l.slice(0,l.lastIndexOf(e[0])),s=[...o];return s[2]="",K.replace(t,null,s,e,[r],!0),[!0,n]}const f=new RegExp(`^[ \\t]*\`{${s},}$`);for(let r=n+1;r<e.length;r++){const s=e[r];if(f.test(s)){const c=s.match(f),l=e.slice(n+1,r),a=i.slice(o[0].length);return a.length>0&&l.unshift(a),K.replace(t,null,o,c,l,!0),[!0,r]}}const d=e.slice(n+1),g=i.slice(o[0].length);return g.length>0&&d.unshift(g),K.replace(t,null,o,null,d,!0),[!0,e.length-1]},regExpEnd:{optional:!0,regExp:b},regExpStart:A,replace:(t,n,o,s,i,c)=>{let l,a;const f=o[1]?o[1].trim():"```",d=o[2]||void 0;if(!n&&i){if(1===i.length)s?(l=r.$createCodeNode(d),a=i[0]):(l=r.$createCodeNode(d),a=i[0].startsWith(" ")?i[0].slice(1):i[0]);else{for(l=r.$createCodeNode(d),i.length>0&&(0===i[0].trim().length?i.shift():i[0].startsWith(" ")&&(i[0]=i[0].slice(1)));i.length>0&&!i[i.length-1].length;)i.pop();a=i.join("\n")}e.$setState(l,H,f);const n=e.$createTextNode(a);l.append(n),t.append(l)}else n&&U(e=>r.$createCodeNode(e?e[2]:void 0))(t,n,o,c)},type:"multiline-element"},W={dependencies:[t.ListNode,t.ListItemNode],export:(e,n)=>t.$isListNode(e)?q(e,n,0):null,regExp:y,replace:z("bullet"),type:"element"},X={dependencies:[t.ListNode,t.ListItemNode],export:(e,n)=>t.$isListNode(e)?q(e,n,0):null,regExp:_,replace:z("check"),type:"element"},Y={dependencies:[t.ListNode,t.ListItemNode],export:(e,n)=>t.$isListNode(e)?q(e,n,0):null,regExp:v,replace:z("number"),type:"element"},J={format:["code"],tag:"`",type:"text-format"},V={format:["highlight"],tag:"==",type:"text-format"},Z={format:["bold","italic"],tag:"***",type:"text-format"},ee={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},te={format:["bold"],tag:"**",type:"text-format"},ne={format:["bold"],intraword:!1,tag:"__",type:"text-format"},oe={format:["strikethrough"],tag:"~~",type:"text-format"},re={format:["italic"],tag:"*",type:"text-format"},se={format:["italic"],intraword:!1,tag:"_",type:"text-format"},ie={dependencies:[s.LinkNode],export:(e,t,n)=>{if(!s.$isLinkNode(e)||s.$isAutoLinkNode(e))return null;const o=e.getTitle(),r=t(e);return o?`[${r}](${e.getURL()} "${o}")`:`[${r}](${e.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[\]]*(?:\[[^[\]]*\][^[\]]*)*)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,n)=>{if(e.$findMatchingParent(t,s.$isLinkNode))return;const[,o,r,i]=n,c=s.$createLinkNode(r,{title:i}),l=o.split("[").length-1,a=o.split("]").length-1;let f=o,d="";if(l<a)return;if(l>a){const e=o.split("[");d="["+e[0],f=e.slice(1).join("[")}const g=e.$createTextNode(f);return g.setFormat(t.getFormat()),c.append(g),t.replace(c),d&&c.insertBefore(e.$createTextNode(d)),g},trigger:")",type:"text-match"},ce=[G,Q,W,Y],le=[K],ae=[J,Z,ee,te,ne,V,re,se,oe],fe=[ie],de=[...ce,...le,...ae,...fe];function ge(t,n,o,r,s){const i=t.getParent();if(!e.$isRootOrShadowRoot(i)||t.getFirstChild()!==n)return!1;const c=n.getTextContent();if(!s&&" "!==c[o-1])return!1;for(const{regExpStart:e,replace:i,regExpEnd:l}of r){if(l&&!("optional"in l)||l&&"optional"in l&&!l.optional)continue;const r=c.match(e);if(r){const e=s||r[0].endsWith(" ")?o:o-1;if(r[0].length!==e)continue;const c=n.getNextSiblings(),[l,a]=n.splitText(o);if(!1!==i(t,a?[a,...c]:c,r,null,null,!1))return l.remove(),!0}}return!1}function ue(e,t,n){const o=n.length;for(let r=t;r>=o;r--){const t=r-o;if(pe(e,t,n,0,o)&&" "!==e[t+o])return t}return-1}function pe(e,t,n,o,r){for(let s=0;s<r;s++)if(e[t+s]!==n[o+s])return!1;return!0}exports.$convertFromMarkdownString=function(e,t=de,n,o=!1,r=!1){const s=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 s=n[e].trimEnd(),i=r[r.length-1];k.test(s)?r.push(s):A.test(s)||b.test(s)?(o=!o,r.push(s)):o||""===s||""===i||!i||O.test(i)||O.test(s)||M.test(s)||v.test(s)||y.test(s)||_.test(s)||F.test(s)||w.test(s)||!t||B.test(s)||D.test(s)||P(D).test(i)||P(B).test(i)||b.test(i)?r.push(s):r[r.length-1]=i+" "+s.trimStart()}return r.join("\n")}(e,r);return C(t,o)(s,n)},exports.$convertToMarkdownString=function(t=de,n,o=!1){return function(t,n=!1){const o=c(t),r=[...o.multilineElement,...o.element],s=!n,i=o.textFormat.filter(e=>1===e.format.length).sort((e,t)=>Number(e.format.includes("code"))-Number(t.format.includes("code")));return t=>{const n=[],c=(t||e.$getRoot()).getChildren();for(let e=0;e<c.length;e++){const t=c[e],l=u(t,r,i,o.textMatch);null!=l&&n.push(s&&e>0&&!g(t)&&!g(c[e-1])?"\n".concat(l):l)}return n.join("\n")}}(t,o)(n)},exports.BOLD_ITALIC_STAR=Z,exports.BOLD_ITALIC_UNDERSCORE=ee,exports.BOLD_STAR=te,exports.BOLD_UNDERSCORE=ne,exports.CHECK_LIST=X,exports.CODE=K,exports.ELEMENT_TRANSFORMERS=ce,exports.HEADING=G,exports.HIGHLIGHT=V,exports.INLINE_CODE=J,exports.ITALIC_STAR=re,exports.ITALIC_UNDERSCORE=se,exports.LINK=ie,exports.MULTILINE_ELEMENT_TRANSFORMERS=le,exports.ORDERED_LIST=Y,exports.QUOTE=Q,exports.STRIKETHROUGH=oe,exports.TEXT_FORMAT_TRANSFORMERS=ae,exports.TEXT_MATCH_TRANSFORMERS=fe,exports.TRANSFORMERS=de,exports.UNORDERED_LIST=W,exports.registerMarkdownShortcuts=function(t,n=de){const o=c(n),s=i(o.textFormat,({tag:e})=>e[e.length-1]),a=i(o.textMatch,({trigger:e})=>e);for(const e of n){const n=e.type;if("element"===n||"text-match"===n||"multiline-element"===n){const n=e.dependencies;for(const e of n)t.hasNode(e)||R(173,e.getType())}}const f=(t,n,r)=>{(function(t,n,o,r){const s=t.getParent();if(!e.$isRootOrShadowRoot(s)||t.getFirstChild()!==n)return!1;const i=n.getTextContent();if(" "!==i[o-1])return!1;for(const{regExp:e,replace:s}of r){const r=i.match(e);if(r&&r[0].length===(r[0].endsWith(" ")?o:o-1)){const e=n.getNextSiblings(),[i,c]=n.splitText(o);if(!1!==s(t,c?[c,...e]:e,r,!1))return i.remove(),!0}}return!1})(t,n,r,o.element)||ge(t,n,r,o.multilineElement)||function(e,t,n){let o=e.getTextContent();const r=n[o[t-1]];if(null==r)return!1;t<o.length&&(o=o.slice(0,t));for(const t of r){if(!t.replace||!t.regExp)continue;const n=o.match(t.regExp);if(null===n)continue;const r=n.index||0,s=r+n[0].length;let i;return 0===r?[i]=e.splitText(s):[,i]=e.splitText(r,s),i.selectNext(0,0),t.replace(i,n),!0}return!1}(n,r,a)||function(t,n,o){const r=t.getTextContent(),s=n-1,i=r[s],c=o[i];if(!c)return!1;for(const n of c){const{tag:o}=n,c=o.length,a=s-c+1;if(c>1&&!pe(r,a,o,0,c))continue;if(" "===r[a-1])continue;const f=r[s+1];if(!1===n.intraword&&f&&!l.test(f))continue;const d=t;let g=d,u=ue(r,a,o),p=g;for(;u<0&&(p=p.getPreviousSibling())&&!e.$isLineBreakNode(p);)if(e.$isTextNode(p)){if(p.hasFormat("code"))continue;const e=p.getTextContent();g=p,u=ue(e,e.length,o)}if(u<0)continue;if(g===d&&u+c===a)continue;const x=g.getTextContent();if(u>0&&x[u-1]===i)continue;const h=x[u-1];if(!1===n.intraword&&h&&!l.test(h))continue;const m=d.getTextContent(),$=m.slice(0,a)+m.slice(s+1);d.setTextContent($);const N=g===d?$:x;g.setTextContent(N.slice(0,u)+N.slice(u+c));const T=e.$getSelection(),E=e.$createRangeSelection();e.$setSelection(E);const S=s-c*(g===d?2:1)+1;E.anchor.set(g.__key,u,"text"),E.focus.set(d.__key,S,"text");for(const e of n.format)E.hasFormat(e)||E.formatText(e);E.anchor.set(E.focus.key,E.focus.offset,E.focus.type);for(const e of n.format)E.hasFormat(e)&&E.toggleFormat(e);return e.$isRangeSelection(T)&&(E.format=T.format),!0}}(n,r,s)};return e.mergeRegister(t.registerUpdateListener(({tags:n,dirtyLeaves:o,editorState:s,prevEditorState:i})=>{if(n.has(e.COLLABORATION_TAG)||n.has(e.HISTORIC_TAG))return;if(t.isComposing())return;const c=s.read(e.$getSelection),l=i.read(e.$getSelection);if(!e.$isRangeSelection(l)||!e.$isRangeSelection(c)||!c.isCollapsed()||c.is(l))return;const a=c.anchor.key,d=c.anchor.offset,g=s._nodeMap.get(a);!e.$isTextNode(g)||!o.has(a)||1!==d&&d>l.anchor.offset+1||t.update(()=>{if(!E(g))return;const e=g.getParent();null===e||r.$isCodeNode(e)||f(e,g,c.anchor.offset)})}),t.registerCommand(e.KEY_ENTER_COMMAND,t=>{if(null!==t&&t.shiftKey)return!1;const n=e.$getSelection();if(!e.$isRangeSelection(n)||!n.isCollapsed())return!1;const s=n.anchor.offset,i=n.anchor.getNode();if(!e.$isTextNode(i)||!E(i))return!1;const c=i.getParent();if(null===c||r.$isCodeNode(c))return!1;return s===i.getTextContent().length&&(!!ge(c,i,s,o.multilineElement,!0)&&(null!==t&&t.preventDefault(),!0))},e.COMMAND_PRIORITY_LOW))};
9
+ "use strict";var e=require("lexical"),t=require("@lexical/list"),n=require("@lexical/rich-text"),o=require("@lexical/utils"),r=require("@lexical/code"),s=require("@lexical/link");function i(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=i(e,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}const l=/[!-/:-@[-`{-~\s]/,a=/[ \t\n\r\f]/,f=/[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~]/,d=/^\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)&&d.test(n.getTextContent())}function u(t,n,o,r){for(const e of n){if(!e.export)continue;const n=e.export(t,e=>p(e,o,r));if(null!=n)return n}return e.$isElementNode(t)?p(t,o,r):e.$isDecoratorNode(t)?t.getTextContent():null}function p(t,n,o,r,s){const i=[],c=t.getChildren();r||(r=[]),s||(s=[]);e:for(const t of c){for(const e of o){if(!e.export)continue;const c=e.export(t,e=>p(e,n,o,r,[...s,...r]),(e,t)=>h(e,t,n,r,s));if(null!=c){i.push(c);continue e}}e.$isLineBreakNode(t)?i.push("\n"):e.$isTextNode(t)?i.push(h(t,t.getTextContent(),n,r,s)):e.$isElementNode(t)?i.push(p(t,n,o,r,s)):e.$isDecoratorNode(t)&&i.push(t.getTextContent())}return i.join("")}function h(e,t,n,o,r){let s=t;e.hasFormat("code")||(s=s.replace(/([*_`~\\])/g,"\\$1"));const i=s.match(/^(\s*)(.*?)(\s*)$/s)||["","",s,""],c=i[1],l=i[2],a=i[3],f=""===l;let d="",g="",u="";const p=x(e,!0),h=x(e,!1),N=new Set;for(const t of n){const n=t.format[0],r=t.tag;$(e,n)&&!N.has(n)&&(N.add(n),$(p,n)&&o.find(e=>e.tag===r)||(o.push({format:n,tag:r}),d+=r))}for(let t=0;t<o.length;t++){const n=m(e,o[t].format),s=m(h,o[t].format);if(n&&s)continue;const i=[...o];for(;i.length>t;){const e=i.pop();r&&e&&r.find(t=>t.tag===e.tag)||(e&&"string"==typeof e.tag&&(n?s||(u+=e.tag):g+=e.tag),o.pop())}break}return f&&!e.hasFormat("code")?g+s:g+c+d+l+u+a}function x(t,n){const o=n?t.getPreviousSibling():t.getNextSibling();return e.$isTextNode(o)?o:null}function m(t,n){return e.$isTextNode(t)&&t.hasFormat(n)}function $(e,t){return!!m(e,t)&&("code"===t||(!e||!/^\s*$/.test(e.getTextContent())))}function N(e,t){const n=e.getTextContent(),o=t.fullMatchRegExpByTag["`"],r=t.transformersByTag["`"],s=[];let i=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,n=t+e[0].length;i||(i={content:e[2],endIndex:n,startIndex:t,tag:"`"}),s.push({end:n,start:t})}}const c=function(e,t,n=[]){const o=[],r=new Set(Object.keys(t.transformersByTag).filter(e=>"`"!==e[0]).map(e=>e[0])),s=t=>{let n=0;for(let o=t-1;o>=0&&"\\"===e[o];o--)n++;return n%2==1},i=e=>n.some(t=>e>=t.start&&e<t.end);let c=0;for(;c<e.length;){const t=e[c];if(!r.has(t)||s(c)||i(c)){c++;continue}let n=1;for(;c+n<e.length&&e[c+n]===t;)n++;const l=T(t,e,c,n,!0),a=T(t,e,c,n,!1);(l||a)&&o.push({active:!0,canClose:a,canOpen:l,char:t,index:c,length:n,originalLength:n}),c+=n}return o}(n,t,s),l=c.length>0?function(e,t,n){const o={};let r=0,s=null;for(;r<t.length;){const i=t[r];if(!i.active||!i.canClose||0===i.length){r++;continue}const c=`${i.char}${i.canOpen}`,l=o[c]??-1;let a=!1;for(let o=r-1;o>l;o--){const c=t[o];if(!c.active||!c.canOpen||0===c.length||c.char!==i.char)continue;if(c.canClose||i.canOpen){if((c.originalLength+i.originalLength)%3==0&&c.originalLength%3!=0&&i.originalLength%3!=0)continue}const l=Math.min(c.length,i.length),f=Object.keys(n.transformersByTag).filter(e=>e[0]===c.char&&e.length<=l).sort((e,t)=>t.length-e.length)[0];if(!f)continue;a=!0;const d=f.length,g={content:e.slice(c.index+c.length,i.index),endIndex:i.index+d,startIndex:c.index+(c.length-d),tag:f};(!s||g.startIndex<s.startIndex||g.startIndex===s.startIndex&&g.endIndex>s.endIndex)&&(s=g);for(let e=o+1;e<r;e++)t[e].active=!1;c.length-=d,i.length-=d,c.active=c.length>0,i.length>0?i.index+=d:(i.active=!1,r++);break}a||(o[c]=r-1,i.canOpen||(i.active=!1),r++)}return s}(n,c,t):null;let a=null,f=null;if(i&&l?l.startIndex<=i.startIndex&&l.endIndex>=i.endIndex?(a=l,f=t.transformersByTag[l.tag]):(a=i,f=r):i?(a=i,f=r):l&&(a=l,f=t.transformersByTag[l.tag]),!a||!f)return null;const d=[n.slice(a.startIndex,a.endIndex),a.tag,a.content];return d.index=a.startIndex,d.input=n,{endIndex:a.endIndex,match:d,startIndex:a.startIndex,transformer:f}}function T(e,t,n,o,r){if(!E(t,n,o,r))return!1;if("*"===e)return!0;if("_"===e){if(!E(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 E(e,t,n,o){const r=e[t-1],s=e[t+n],[i,c]=o?[s,r]:[r,s];return void 0!==i&&!a.test(i)&&(!f.test(i)||(void 0===c||a.test(c)||f.test(c)))}function S(t){return e.$isTextNode(t)&&!t.hasFormat("code")}function C(e,t,n){let o=N(e,t),r=function(e,t){const n=e;let o,r,s,i;for(const e of t){if(!e.replace||!e.importRegExp)continue;const t=n.getTextContent().match(e.importRegExp);if(!t)continue;const c=t.index||0,l=e.getEndIndex?e.getEndIndex(n,t):c+t[0].length;!1!==l&&(void 0===o||void 0===r||c<o&&(l>r||l<=o))&&(o=c,r=l,s=e,i=t)}return void 0===o||void 0===r||void 0===s||void 0===i?null:{endIndex:r,match:i,startIndex:o,transformer:s}}(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 s=e.getTextContent();let i,c,l;if(r[0]===s?i=e:0===t?[i,c]=e.splitText(n):[l,i,c]=e.splitText(t,n),i.setTextContent(r[2]),o)for(const e of o.format)i.hasFormat(e)||i.toggleFormat(e);return{nodeAfter:c,nodeBefore:l,transformedNode:i}}(e,o.startIndex,o.endIndex,o.transformer,o.match);S(r.nodeAfter)&&C(r.nodeAfter,t,n),S(r.nodeBefore)&&C(r.nodeBefore,t,n),S(r.transformedNode)&&C(r.transformedNode,t,n)}else if(r){const o=function(e,t,n,o,r){let s,i,c;return 0===t?[s,i]=e.splitText(n):[c,s,i]=e.splitText(t,n),o.replace?{nodeAfter:i,nodeBefore:c,transformedNode:o.replace(s,r)||void 0}:null}(e,r.startIndex,r.endIndex,r.transformer,r.match);if(!o)return;S(o.nodeAfter)&&C(o.nodeAfter,t,n),S(o.nodeBefore)&&C(o.nodeBefore,t,n),S(o.transformedNode)&&C(o.transformedNode,t,n)}const s=e.getTextContent().replace(/\\([*_`~\\])/g,"$1").replace(/&#(\d+);/g,(e,t)=>String.fromCodePoint(t));e.setTextContent(s)}function I(t,n=!1){const o=c(t),r=function(e){const t={},n={},o=[],r="(?<![\\\\])";for(const r of e){const{tag:e}=r;t[e]=r;const s=e.replace(/(\*|\^|\+)/g,"\\$1");o.push(s),1===e.length?n[e]="`"===e?new RegExp("(?<![\\\\`])(`)((?:\\\\`|[^`])+?)(`)(?!`)"):new RegExp(`(?<![\\\\${s}])(${s})((\\\\${s})?.*?[^${s}\\s](\\\\${s})?)((?<!\\\\)|(?<=\\\\\\\\))(${s})(?![\\\\${s}])`):n[e]=new RegExp(`(?<!\\\\)(${s})((\\\\${s})?.*?[^\\s](\\\\${s})?)((?<!\\\\)|(?<=\\\\\\\\))(${s})(?!\\\\)`)}return{fullMatchRegExpByTag:n,openTagsRegExp:new RegExp(`${r}(${o.join("|")})`,"g"),transformersByTag:t}}(o.textFormat);return(t,s)=>{const i=t.split("\n"),c=i.length,l=s||e.$getRoot();l.clear();for(let e=0;e<c;e++){const t=i[e],[s,c]=L(i,e,o.multilineElement,l);s?e=c:R(t,l,o.element,r,o.textMatch,n)}const a=l.getChildren();for(const e of a)!n&&g(e)&&l.getChildrenSize()>1&&e.remove();null!==e.$getSelection()&&l.selectStart()}}function L(e,t,n,o){for(const r of n){const{handleImportAfterStartMatch:n,regExpEnd:s,regExpStart:i,replace:c}=r,l=e[t].match(i);if(!l)continue;if(n){const s=n({lines:e,rootNode:o,startLineIndex:t,startMatch:l,transformer:r});if(null===s)continue;if(s)return s}const a="object"==typeof s&&"regExp"in s?s.regExp:s,f=s&&"object"==typeof s&&"optional"in s?s.optional:!s;let d=t;const g=e.length;for(;d<g;){const n=a?e[d].match(a):null;if(!n&&(!f||f&&d<g-1)){d++;continue}if(n&&t===d&&n.index===l.index){d++;continue}const r=[];if(n&&t===d)r.push(e[t].slice(l[0].length,-n[0].length));else for(let o=t;o<=d;o++)if(o===t){const t=e[o].slice(l[0].length);r.push(t)}else if(o===d&&n){const t=e[o].slice(0,-n[0].length);r.push(t)}else r.push(e[o]);if(!1!==c(o,null,l,n,r,!0))return[!0,d];break}}return[!1,t]}function R(r,s,i,c,l,a){const f=e.$createTextNode(r),d=e.$createParagraphNode();d.append(f),s.append(d);for(const{regExp:e,replace:t}of i){const n=r.match(e);if(n&&(f.setTextContent(r.slice(n[0].length)),!1!==t(d,[f],n,!0)))break}if(C(f,c,l),d.isAttached()&&r.length>0){const r=d.getPreviousSibling();if(!a&&(e.$isParagraphNode(r)||n.$isQuoteNode(r)||t.$isListNode(r))){let n=r;if(t.$isListNode(r)){const e=r.getLastDescendant();n=null==e?null:o.$findMatchingParent(e,t.$isListItemNode)}null!=n&&n.getTextContentSize()>0&&(n.splice(n.getChildrenSize(),0,[e.$createLineBreakNode(),...d.getChildren()]),d.remove())}}}function v(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.`)}const y=/^(\s*)(\d{1,})\.\s/,_=/^(\s*)[-*+]\s/,O=/^(\s*)(?:[-*+]\s)?\s?(\[(\s|x)?\])\s/i,M=/^(#{1,6})\s/,A=/^>\s/,b=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,k=/^[ \t]*`{3,}$/,F=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,w=/^(?:\|)(.+)(?:\|)\s?$/,B=/^(\| ?:?-*:? ?)+\|\s?$/,D=/^<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,P=/^<\/[a-z_][\w-]*\s*>/i,j=e=>new RegExp(`(?:${e.source})$`,e.flags),H=e.createState("mdListMarker",{parse:e=>"string"==typeof e&&/^[-*+]$/.test(e)?e:"-"}),U=e.createState("mdCodeFence",{parse:e=>"string"==typeof e&&/^`{3,}$/.test(e)?e:"```"}),z=e=>(t,n,o,r)=>{const s=e(o);s.append(...n),t.replace(s),r||s.select(0,0)};const q=n=>(o,r,s,i)=>{const c=o.getPreviousSibling(),l=o.getNextSibling(),a=t.$createListItemNode("check"===n?"x"===s[3]:void 0),f=s[0].trim()[0],d="bullet"!==n&&"check"!==n||f!==H.parse(f)?void 0:f;if(t.$isListNode(l)&&l.getListType()===n){d&&e.$setState(l,H,d);const t=l.getFirstChild();null!==t?t.insertBefore(a):l.append(a),o.remove()}else if(t.$isListNode(c)&&c.getListType()===n)d&&e.$setState(c,H,d),c.append(a),o.remove();else{const r=t.$createListNode(n,"number"===n?Number(s[2]):void 0);d&&e.$setState(r,H,d),r.append(a),o.replace(r)}a.append(...r),i||a.select(0,0);const g=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}(s[1]);g&&a.setIndent(g)},G=(n,o,r)=>{const s=[],i=n.getChildren();let c=0;for(const l of i)if(t.$isListItemNode(l)){if(1===l.getChildrenSize()){const e=l.getFirstChild();if(t.$isListNode(e)){s.push(G(e,o,r+1));continue}}const i=" ".repeat(4*r),a=n.getListType(),f=e.$getState(n,H),d="number"===a?`${n.getStart()+c}. `:"check"===a?`${f} [${l.getChecked()?"x":" "}] `:f+" ";s.push(i+d+o(l)),c++}return s.join("\n")},Q={dependencies:[n.HeadingNode],export:(e,t)=>{if(!n.$isHeadingNode(e))return null;const o=Number(e.getTag().slice(1));return"#".repeat(o)+" "+t(e)},regExp:M,replace:z(e=>{const t="h"+e[1].length;return n.$createHeadingNode(t)}),type:"element"},K={dependencies:[n.QuoteNode],export:(e,t)=>{if(!n.$isQuoteNode(e))return null;const o=t(e).split("\n"),r=[];for(const e of o)r.push("> "+e);return r.join("\n")},regExp:A,replace:(t,o,r,s)=>{if(s){const r=t.getPreviousSibling();if(n.$isQuoteNode(r))return r.splice(r.getChildrenSize(),0,[e.$createLineBreakNode(),...o]),void t.remove()}const i=n.$createQuoteNode();i.append(...o),t.replace(i),s||i.select(0,0)},type:"element"},W={dependencies:[r.CodeNode],export:t=>{if(!r.$isCodeNode(t))return null;const n=t.getTextContent();let o=e.$getState(t,U);if(n.indexOf(o)>-1){const e=n.match(/`{3,}/g);if(e){const t=Math.max(...e.map(e=>e.length));o="`".repeat(t+1)}}return o+(t.getLanguage()||"")+(n?"\n"+n:"")+"\n"+o},handleImportAfterStartMatch:({lines:e,rootNode:t,startLineIndex:n,startMatch:o})=>{const r=o[1],s=r.trim().length,i=e[n],c=o.index+r.length,l=i.slice(c),a=new RegExp(`\`{${s},}$`);if(a.test(l)){const e=l.match(a),r=l.slice(0,l.lastIndexOf(e[0])),s=[...o];return s[2]="",W.replace(t,null,s,e,[r],!0),[!0,n]}const f=new RegExp(`^[ \\t]*\`{${s},}$`);for(let r=n+1;r<e.length;r++){const s=e[r];if(f.test(s)){const c=s.match(f),l=e.slice(n+1,r),a=i.slice(o[0].length);return a.length>0&&l.unshift(a),W.replace(t,null,o,c,l,!0),[!0,r]}}const d=e.slice(n+1),g=i.slice(o[0].length);return g.length>0&&d.unshift(g),W.replace(t,null,o,null,d,!0),[!0,e.length-1]},regExpEnd:{optional:!0,regExp:k},regExpStart:b,replace:(t,n,o,s,i,c)=>{let l,a;const f=o[1]?o[1].trim():"```",d=o[2]||void 0;if(!n&&i){if(1===i.length)s?(l=r.$createCodeNode(d),a=i[0]):(l=r.$createCodeNode(d),a=i[0].startsWith(" ")?i[0].slice(1):i[0]);else{for(l=r.$createCodeNode(d),i.length>0&&(0===i[0].trim().length?i.shift():i[0].startsWith(" ")&&(i[0]=i[0].slice(1)));i.length>0&&!i[i.length-1].length;)i.pop();a=i.join("\n")}e.$setState(l,U,f);const n=e.$createTextNode(a);l.append(n),t.append(l)}else n&&z(e=>r.$createCodeNode(e?e[2]:void 0))(t,n,o,c)},type:"multiline-element"},X={dependencies:[t.ListNode,t.ListItemNode],export:(e,n)=>t.$isListNode(e)?G(e,n,0):null,regExp:_,replace:q("bullet"),type:"element"},Y={dependencies:[t.ListNode,t.ListItemNode],export:(e,n)=>t.$isListNode(e)?G(e,n,0):null,regExp:O,replace:q("check"),type:"element"},J={dependencies:[t.ListNode,t.ListItemNode],export:(e,n)=>t.$isListNode(e)?G(e,n,0):null,regExp:y,replace:q("number"),type:"element"},V={format:["code"],tag:"`",type:"text-format"},Z={format:["highlight"],tag:"==",type:"text-format"},ee={format:["bold","italic"],tag:"***",type:"text-format"},te={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},ne={format:["bold"],tag:"**",type:"text-format"},oe={format:["bold"],intraword:!1,tag:"__",type:"text-format"},re={format:["strikethrough"],tag:"~~",type:"text-format"},se={format:["italic"],tag:"*",type:"text-format"},ie={format:["italic"],intraword:!1,tag:"_",type:"text-format"},ce={dependencies:[s.LinkNode],export:(e,t,n)=>{if(!s.$isLinkNode(e)||s.$isAutoLinkNode(e))return null;const o=e.getTitle(),r=t(e);return o?`[${r}](${e.getURL()} "${o}")`:`[${r}](${e.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[\]]*(?:\[[^[\]]*\][^[\]]*)*)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,n)=>{if(e.$findMatchingParent(t,s.$isLinkNode))return;const[,o,r,i]=n,c=s.$createLinkNode(r,{title:i}),l=o.split("[").length-1,a=o.split("]").length-1;let f=o,d="";if(l<a)return;if(l>a){const e=o.split("[");d="["+e[0],f=e.slice(1).join("[")}const g=e.$createTextNode(f);return g.setFormat(t.getFormat()),c.append(g),t.replace(c),d&&c.insertBefore(e.$createTextNode(d)),g},trigger:")",type:"text-match"},le=[Q,K,X,J],ae=[W],fe=[V,ee,te,ne,oe,Z,se,ie,re],de=[ce],ge=[...le,...ae,...fe,...de];function ue(t,n,o,r,s){const i=t.getParent();if(!e.$isRootOrShadowRoot(i)||t.getFirstChild()!==n)return!1;const c=n.getTextContent();if(!s&&" "!==c[o-1])return!1;for(const{regExpStart:e,replace:i,regExpEnd:l}of r){if(l&&!("optional"in l)||l&&"optional"in l&&!l.optional)continue;const r=c.match(e);if(r){const e=s||r[0].endsWith(" ")?o:o-1;if(r[0].length!==e)continue;const c=n.getNextSiblings(),[l,a]=n.splitText(o);if(!1!==i(t,a?[a,...c]:c,r,null,null,!1))return l.remove(),!0}}return!1}function pe(e,t,n){const o=n.length;for(let r=t;r>=o;r--){const t=r-o;if(he(e,t,n,0,o)&&" "!==e[t+o])return t}return-1}function he(e,t,n,o,r){for(let s=0;s<r;s++)if(e[t+s]!==n[o+s])return!1;return!0}exports.$convertFromMarkdownString=function(e,t=ge,n,o=!1,r=!1){const s=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 s=n[e].trimEnd(),i=r[r.length-1];F.test(s)?r.push(s):b.test(s)||k.test(s)?(o=!o,r.push(s)):o||""===s||""===i||!i||M.test(i)||M.test(s)||A.test(s)||y.test(s)||_.test(s)||O.test(s)||w.test(s)||B.test(s)||!t||D.test(s)||P.test(s)||j(P).test(i)||j(D).test(i)||k.test(i)?r.push(s):r[r.length-1]=i+" "+s.trimStart()}return r.join("\n")}(e,r);return I(t,o)(s,n)},exports.$convertToMarkdownString=function(t=ge,n,o=!1){return function(t,n=!1){const o=c(t),r=[...o.multilineElement,...o.element],s=!n,i=o.textFormat.filter(e=>1===e.format.length).sort((e,t)=>Number(e.format.includes("code"))-Number(t.format.includes("code")));return t=>{const n=[],c=(t||e.$getRoot()).getChildren();for(let e=0;e<c.length;e++){const t=c[e],l=u(t,r,i,o.textMatch);null!=l&&n.push(s&&e>0&&!g(t)&&!g(c[e-1])?"\n".concat(l):l)}return n.join("\n")}}(t,o)(n)},exports.BOLD_ITALIC_STAR=ee,exports.BOLD_ITALIC_UNDERSCORE=te,exports.BOLD_STAR=ne,exports.BOLD_UNDERSCORE=oe,exports.CHECK_LIST=Y,exports.CODE=W,exports.ELEMENT_TRANSFORMERS=le,exports.HEADING=Q,exports.HIGHLIGHT=Z,exports.INLINE_CODE=V,exports.ITALIC_STAR=se,exports.ITALIC_UNDERSCORE=ie,exports.LINK=ce,exports.MULTILINE_ELEMENT_TRANSFORMERS=ae,exports.ORDERED_LIST=J,exports.QUOTE=K,exports.STRIKETHROUGH=re,exports.TEXT_FORMAT_TRANSFORMERS=fe,exports.TEXT_MATCH_TRANSFORMERS=de,exports.TRANSFORMERS=ge,exports.UNORDERED_LIST=X,exports.registerMarkdownShortcuts=function(t,n=ge){const o=c(n),s=i(o.textFormat,({tag:e})=>e[e.length-1]),a=i(o.textMatch,({trigger:e})=>e);for(const e of n){const n=e.type;if("element"===n||"text-match"===n||"multiline-element"===n){const n=e.dependencies;for(const e of n)t.hasNode(e)||v(173,e.getType())}}const f=(t,n,r)=>{(function(t,n,o,r){const s=t.getParent();if(!e.$isRootOrShadowRoot(s)||t.getFirstChild()!==n)return!1;const i=n.getTextContent();if(" "!==i[o-1])return!1;for(const{regExp:e,replace:s}of r){const r=i.match(e);if(r&&r[0].length===(r[0].endsWith(" ")?o:o-1)){const e=n.getNextSiblings(),[i,c]=n.splitText(o);if(!1!==s(t,c?[c,...e]:e,r,!1))return i.remove(),!0}}return!1})(t,n,r,o.element)||ue(t,n,r,o.multilineElement)||function(e,t,n){let o=e.getTextContent();const r=n[o[t-1]];if(null==r)return!1;t<o.length&&(o=o.slice(0,t));for(const t of r){if(!t.replace||!t.regExp)continue;const n=o.match(t.regExp);if(null===n)continue;const r=n.index||0,s=r+n[0].length;let i;return 0===r?[i]=e.splitText(s):[,i]=e.splitText(r,s),i.selectNext(0,0),t.replace(i,n),!0}return!1}(n,r,a)||function(t,n,o){const r=t.getTextContent(),s=n-1,i=r[s],c=o[i];if(!c)return!1;for(const n of c){const{tag:o}=n,c=o.length,a=s-c+1;if(c>1&&!he(r,a,o,0,c))continue;if(" "===r[a-1])continue;const f=r[s+1];if(!1===n.intraword&&f&&!l.test(f))continue;const d=t;let g=d,u=pe(r,a,o),p=g;for(;u<0&&(p=p.getPreviousSibling())&&!e.$isLineBreakNode(p);)if(e.$isTextNode(p)){if(p.hasFormat("code"))continue;const e=p.getTextContent();g=p,u=pe(e,e.length,o)}if(u<0)continue;if(g===d&&u+c===a)continue;const h=g.getTextContent();if(u>0&&h[u-1]===i)continue;const x=h[u-1];if(!1===n.intraword&&x&&!l.test(x))continue;const m=d.getTextContent(),$=m.slice(0,a)+m.slice(s+1);d.setTextContent($);const N=g===d?$:h;g.setTextContent(N.slice(0,u)+N.slice(u+c));const T=e.$getSelection(),E=e.$createRangeSelection();e.$setSelection(E);const S=s-c*(g===d?2:1)+1;E.anchor.set(g.__key,u,"text"),E.focus.set(d.__key,S,"text");for(const e of n.format)E.hasFormat(e)||E.formatText(e);E.anchor.set(E.focus.key,E.focus.offset,E.focus.type);for(const e of n.format)E.hasFormat(e)&&E.toggleFormat(e);return e.$isRangeSelection(T)&&(E.format=T.format),!0}}(n,r,s)};return e.mergeRegister(t.registerUpdateListener(({tags:n,dirtyLeaves:o,editorState:s,prevEditorState:i})=>{if(n.has(e.COLLABORATION_TAG)||n.has(e.HISTORIC_TAG))return;if(t.isComposing())return;const c=s.read(e.$getSelection),l=i.read(e.$getSelection);if(!e.$isRangeSelection(l)||!e.$isRangeSelection(c)||!c.isCollapsed()||c.is(l))return;const a=c.anchor.key,d=c.anchor.offset,g=s._nodeMap.get(a);!e.$isTextNode(g)||!o.has(a)||1!==d&&d>l.anchor.offset+1||t.update(()=>{if(!S(g))return;const e=g.getParent();null===e||r.$isCodeNode(e)||f(e,g,c.anchor.offset)})}),t.registerCommand(e.KEY_ENTER_COMMAND,t=>{if(null!==t&&t.shiftKey)return!1;const n=e.$getSelection();if(!e.$isRangeSelection(n)||!n.isCollapsed())return!1;const s=n.anchor.offset,i=n.anchor.getNode();if(!e.$isTextNode(i)||!S(i))return!1;const c=i.getParent();if(null===c||r.$isCodeNode(c))return!1;return s===i.getTextContent().length&&(!!ue(c,i,s,o.multilineElement,!0)&&(null!==t&&t.preventDefault(),!0))},e.COMMAND_PRIORITY_LOW))};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{$isParagraphNode as t,$isTextNode as e,$getRoot as n,$isElementNode as o,$isDecoratorNode as r,$isLineBreakNode as s,$getSelection as i,$createTextNode as l,$createParagraphNode as c,$createLineBreakNode as a,createState as f,$setState as g,$getState as u,$findMatchingParent as d,mergeRegister as p,COLLABORATION_TAG as h,HISTORIC_TAG as x,$isRangeSelection as m,KEY_ENTER_COMMAND as C,COMMAND_PRIORITY_LOW as T,$isRootOrShadowRoot as E,$createRangeSelection as y,$setSelection as $}from"lexical";import{$isListNode as v,$isListItemNode as I,ListNode as S,ListItemNode as b,$createListItemNode as w,$createListNode as F}from"@lexical/list";import{$isQuoteNode as L,HeadingNode as N,QuoteNode as k,$createHeadingNode as R,$isHeadingNode as M,$createQuoteNode as _}from"@lexical/rich-text";import{$findMatchingParent as B}from"@lexical/utils";import{CodeNode as j,$createCodeNode as P,$isCodeNode as A}from"@lexical/code";import{LinkNode as O,$isLinkNode as z,$createLinkNode as U,$isAutoLinkNode as W}from"@lexical/link";function D(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 K(t){const e=D(t,t=>t.type);return{element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const q=/[!-/:-@[-`{-~\s]/,G=/[ \t\n\r\f]/,H=/[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~]/,J=/^\s{0,3}$/;function Q(n){if(!t(n))return!1;const o=n.getFirstChild();return null==o||1===n.getChildrenSize()&&e(o)&&J.test(o.getTextContent())}function V(t,e,n,s){for(const o of e){if(!o.export)continue;const e=o.export(t,t=>X(t,n,s));if(null!=e)return e}return o(t)?X(t,n,s):r(t)?t.getTextContent():null}function X(t,n,i,l,c){const a=[],f=t.getChildren();l||(l=[]),c||(c=[]);t:for(const t of f){for(const e of i){if(!e.export)continue;const o=e.export(t,t=>X(t,n,i,l,[...c,...l]),(t,e)=>Y(t,e,n,l,c));if(null!=o){a.push(o);continue t}}s(t)?a.push("\n"):e(t)?a.push(Y(t,t.getTextContent(),n,l,c)):o(t)?a.push(X(t,n,i,l,c)):r(t)&&a.push(t.getTextContent())}return a.join("")}function Y(t,e,n,o,r){let s=0===t.getFormat()?e:function(t){return t.replace(/^\s+|\s+$/g,t=>[...t].map(t=>"&#"+t.codePointAt(0)+";").join(""))}(e);t.hasFormat("code")||(s=s.replace(/([*_`~\\])/g,"\\$1"));let i="",l="",c="";const a=Z(t,!0),f=Z(t,!1),g=new Set;for(const e of n){const n=e.format[0],r=e.tag;tt(t,n)&&!g.has(n)&&(g.add(n),tt(a,n)&&o.find(t=>t.tag===r)||(o.push({format:n,tag:r}),i+=r))}for(let e=0;e<o.length;e++){const n=tt(t,o[e].format),s=tt(f,o[e].format);if(n&&s)continue;const i=[...o];for(;i.length>e;){const t=i.pop();r&&t&&r.find(e=>e.tag===t.tag)||(t&&"string"==typeof t.tag&&(n?s||(c+=t.tag):l+=t.tag),o.pop())}break}return s=i+s+c,l+s}function Z(t,n){const o=n?t.getPreviousSibling():t.getNextSibling();return e(o)?o:null}function tt(t,n){return e(t)&&t.hasFormat(n)}function et(t,e){const n=t.getTextContent(),o=e.fullMatchRegExpByTag["`"],r=e.transformersByTag["`"],s=[];let i=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,n=e+t[0].length;i||(i={content:t[2],endIndex:n,startIndex:e,tag:"`"}),s.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])),s=e=>{let n=0;for(let o=e-1;o>=0&&"\\"===t[o];o--)n++;return n%2==1},i=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)||s(l)||i(l)){l++;continue}let n=1;for(;l+n<t.length&&t[l+n]===e;)n++;const c=nt(e,t,l,n,!0),a=nt(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,s),c=l.length>0?function(t,e,n){const o={};let r=0,s=null;for(;r<e.length;){const i=e[r];if(!i.active||!i.canClose||0===i.length){r++;continue}const l=`${i.char}${i.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!==i.char)continue;if(l.canClose||i.canOpen){if((l.originalLength+i.originalLength)%3==0&&l.originalLength%3!=0&&i.originalLength%3!=0)continue}const c=Math.min(l.length,i.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 g=f.length,u={content:t.slice(l.index+l.length,i.index),endIndex:i.index+g,startIndex:l.index+(l.length-g),tag:f};(!s||u.startIndex<s.startIndex||u.startIndex===s.startIndex&&u.endIndex>s.endIndex)&&(s=u);for(let t=o+1;t<r;t++)e[t].active=!1;l.length-=g,i.length-=g,l.active=l.length>0,i.length>0?i.index+=g:(i.active=!1,r++);break}a||(o[l]=r-1,i.canOpen||(i.active=!1),r++)}return s}(n,l,e):null;let a=null,f=null;if(i&&c?c.startIndex<=i.startIndex&&c.endIndex>=i.endIndex?(a=c,f=e.transformersByTag[c.tag]):(a=i,f=r):i?(a=i,f=r):c&&(a=c,f=e.transformersByTag[c.tag]),!a||!f)return null;const g=[n.slice(a.startIndex,a.endIndex),a.tag,a.content];return g.index=a.startIndex,g.input=n,{endIndex:a.endIndex,match:g,startIndex:a.startIndex,transformer:f}}function nt(t,e,n,o,r){if(!ot(e,n,o,r))return!1;if("*"===t)return!0;if("_"===t){if(!ot(e,n,o,!r))return!0;const t=r?e[n-1]:e[n+o];return void 0!==t&&H.test(t)}return!0}function ot(t,e,n,o){const r=t[e-1],s=t[e+n],[i,l]=o?[s,r]:[r,s];return void 0!==i&&!G.test(i)&&(!H.test(i)||(void 0===l||G.test(l)||H.test(l)))}function rt(t){return e(t)&&!t.hasFormat("code")}function st(t,e,n){let o=et(t,e),r=function(t,e){const n=t;let o,r,s,i;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,s=t,i=e)}return void 0===o||void 0===r||void 0===s||void 0===i?null:{endIndex:r,match:i,startIndex:o,transformer:s}}(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 s=t.getTextContent();let i,l,c;if(r[0]===s?i=t:0===e?[i,l]=t.splitText(n):[c,i,l]=t.splitText(e,n),i.setTextContent(r[2]),o)for(const t of o.format)i.hasFormat(t)||i.toggleFormat(t);return{nodeAfter:l,nodeBefore:c,transformedNode:i}}(t,o.startIndex,o.endIndex,o.transformer,o.match);rt(r.nodeAfter)&&st(r.nodeAfter,e,n),rt(r.nodeBefore)&&st(r.nodeBefore,e,n),rt(r.transformedNode)&&st(r.transformedNode,e,n)}else if(r){const o=function(t,e,n,o,r){let s,i,l;return 0===e?[s,i]=t.splitText(n):[l,s,i]=t.splitText(e,n),o.replace?{nodeAfter:i,nodeBefore:l,transformedNode:o.replace(s,r)||void 0}:null}(t,r.startIndex,r.endIndex,r.transformer,r.match);if(!o)return;rt(o.nodeAfter)&&st(o.nodeAfter,e,n),rt(o.nodeBefore)&&st(o.nodeBefore,e,n),rt(o.transformedNode)&&st(o.transformedNode,e,n)}const s=t.getTextContent().replace(/\\([*_`~\\])/g,"$1").replace(/&#(\d+);/g,(t,e)=>String.fromCodePoint(e));t.setTextContent(s)}function it(t,e=!1){const o=K(t),r=function(t){const e={},n={},o=[],r="(?<![\\\\])";for(const r of t){const{tag:t}=r;e[t]=r;const s=t.replace(/(\*|\^|\+)/g,"\\$1");o.push(s),1===t.length?n[t]="`"===t?new RegExp("(?<![\\\\`])(`)((?:\\\\`|[^`])+?)(`)(?!`)"):new RegExp(`(?<![\\\\${s}])(${s})((\\\\${s})?.*?[^${s}\\s](\\\\${s})?)((?<!\\\\)|(?<=\\\\\\\\))(${s})(?![\\\\${s}])`):n[t]=new RegExp(`(?<!\\\\)(${s})((\\\\${s})?.*?[^\\s](\\\\${s})?)((?<!\\\\)|(?<=\\\\\\\\))(${s})(?!\\\\)`)}return{fullMatchRegExpByTag:n,openTagsRegExp:new RegExp(`${r}(${o.join("|")})`,"g"),transformersByTag:e}}(o.textFormat);return(t,s)=>{const l=t.split("\n"),c=l.length,a=s||n();a.clear();for(let t=0;t<c;t++){const n=l[t],[s,i]=lt(l,t,o.multilineElement,a);s?t=i:ct(n,a,o.element,r,o.textMatch,e)}const f=a.getChildren();for(const t of f)!e&&Q(t)&&a.getChildrenSize()>1&&t.remove();null!==i()&&a.selectStart()}}function lt(t,e,n,o){for(const r of n){const{handleImportAfterStartMatch:n,regExpEnd:s,regExpStart:i,replace:l}=r,c=t[e].match(i);if(!c)continue;if(n){const s=n({lines:t,rootNode:o,startLineIndex:e,startMatch:c,transformer:r});if(null===s)continue;if(s)return s}const a="object"==typeof s&&"regExp"in s?s.regExp:s,f=s&&"object"==typeof s&&"optional"in s?s.optional:!s;let g=e;const u=t.length;for(;g<u;){const n=a?t[g].match(a):null;if(!n&&(!f||f&&g<u-1)){g++;continue}if(n&&e===g&&n.index===c.index){g++;continue}const r=[];if(n&&e===g)r.push(t[e].slice(c[0].length,-n[0].length));else for(let o=e;o<=g;o++)if(o===e){const e=t[o].slice(c[0].length);r.push(e)}else if(o===g&&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,g];break}}return[!1,e]}function ct(e,n,o,r,s,i){const f=l(e),g=c();g.append(f),n.append(g);for(const{regExp:t,replace:n}of o){const o=e.match(t);if(o&&(f.setTextContent(e.slice(o[0].length)),!1!==n(g,[f],o,!0)))break}if(st(f,r,s),g.isAttached()&&e.length>0){const e=g.getPreviousSibling();if(!i&&(t(e)||L(e)||v(e))){let t=e;if(v(e)){const n=e.getLastDescendant();t=null==n?null:B(n,I)}null!=t&&t.getTextContentSize()>0&&(t.splice(t.getChildrenSize(),0,[a(),...g.getChildren()]),g.remove())}}}function at(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.`)}const ft=/^(\s*)(\d{1,})\.\s/,gt=/^(\s*)[-*+]\s/,ut=/^(\s*)(?:[-*+]\s)?\s?(\[(\s|x)?\])\s/i,dt=/^(#{1,6})\s/,pt=/^>\s/,ht=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,xt=/^[ \t]*`{3,}$/,mt=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,Ct=/^(?:\|)(.+)(?:\|)\s?$/,Tt=/^(\| ?:?-*:? ?)+\|\s?$/,Et=/^<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,yt=/^<\/[a-z_][\w-]*\s*>/i,$t=t=>new RegExp(`(?:${t.source})$`,t.flags),vt=f("mdListMarker",{parse:t=>"string"==typeof t&&/^[-*+]$/.test(t)?t:"-"}),It=f("mdCodeFence",{parse:t=>"string"==typeof t&&/^`{3,}$/.test(t)?t:"```"}),St=t=>(e,n,o,r)=>{const s=t(o);s.append(...n),e.replace(s),r||s.select(0,0)};const bt=t=>(e,n,o,r)=>{const s=e.getPreviousSibling(),i=e.getNextSibling(),l=w("check"===t?"x"===o[3]:void 0),c=o[0].trim()[0],a="bullet"!==t&&"check"!==t||c!==vt.parse(c)?void 0:c;if(v(i)&&i.getListType()===t){a&&g(i,vt,a);const t=i.getFirstChild();null!==t?t.insertBefore(l):i.append(l),e.remove()}else if(v(s)&&s.getListType()===t)a&&g(s,vt,a),s.append(l),e.remove();else{const n=F(t,"number"===t?Number(o[2]):void 0);a&&g(n,vt,a),n.append(l),e.replace(n)}l.append(...n),r||l.select(0,0);const f=function(t){const e=t.match(/\t/g),n=t.match(/ /g);let o=0;return e&&(o+=e.length),n&&(o+=Math.floor(n.length/4)),o}(o[1]);f&&l.setIndent(f)},wt=(t,e,n)=>{const o=[],r=t.getChildren();let s=0;for(const i of r)if(I(i)){if(1===i.getChildrenSize()){const t=i.getFirstChild();if(v(t)){o.push(wt(t,e,n+1));continue}}const r=" ".repeat(4*n),l=t.getListType(),c=u(t,vt),a="number"===l?`${t.getStart()+s}. `:"check"===l?`${c} [${i.getChecked()?"x":" "}] `:c+" ";o.push(r+a+e(i)),s++}return o.join("\n")},Ft={dependencies:[N],export:(t,e)=>{if(!M(t))return null;const n=Number(t.getTag().slice(1));return"#".repeat(n)+" "+e(t)},regExp:dt,replace:St(t=>{const e="h"+t[1].length;return R(e)}),type:"element"},Lt={dependencies:[k],export:(t,e)=>{if(!L(t))return null;const n=e(t).split("\n"),o=[];for(const t of n)o.push("> "+t);return o.join("\n")},regExp:pt,replace:(t,e,n,o)=>{if(o){const n=t.getPreviousSibling();if(L(n))return n.splice(n.getChildrenSize(),0,[a(),...e]),void t.remove()}const r=_();r.append(...e),t.replace(r),o||r.select(0,0)},type:"element"},Nt={dependencies:[j],export:t=>{if(!A(t))return null;const e=t.getTextContent();let n=u(t,It);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],s=r.trim().length,i=t[n],l=o.index+r.length,c=i.slice(l),a=new RegExp(`\`{${s},}$`);if(a.test(c)){const t=c.match(a),r=c.slice(0,c.lastIndexOf(t[0])),s=[...o];return s[2]="",Nt.replace(e,null,s,t,[r],!0),[!0,n]}const f=new RegExp(`^[ \\t]*\`{${s},}$`);for(let r=n+1;r<t.length;r++){const s=t[r];if(f.test(s)){const l=s.match(f),c=t.slice(n+1,r),a=i.slice(o[0].length);return a.length>0&&c.unshift(a),Nt.replace(e,null,o,l,c,!0),[!0,r]}}const g=t.slice(n+1),u=i.slice(o[0].length);return u.length>0&&g.unshift(u),Nt.replace(e,null,o,null,g,!0),[!0,t.length-1]},regExpEnd:{optional:!0,regExp:xt},regExpStart:ht,replace:(t,e,n,o,r,s)=>{let i,c;const a=n[1]?n[1].trim():"```",f=n[2]||void 0;if(!e&&r){if(1===r.length)o?(i=P(f),c=r[0]):(i=P(f),c=r[0].startsWith(" ")?r[0].slice(1):r[0]);else{for(i=P(f),r.length>0&&(0===r[0].trim().length?r.shift():r[0].startsWith(" ")&&(r[0]=r[0].slice(1)));r.length>0&&!r[r.length-1].length;)r.pop();c=r.join("\n")}g(i,It,a);const e=l(c);i.append(e),t.append(i)}else e&&St(t=>P(t?t[2]:void 0))(t,e,n,s)},type:"multiline-element"},kt={dependencies:[S,b],export:(t,e)=>v(t)?wt(t,e,0):null,regExp:gt,replace:bt("bullet"),type:"element"},Rt={dependencies:[S,b],export:(t,e)=>v(t)?wt(t,e,0):null,regExp:ut,replace:bt("check"),type:"element"},Mt={dependencies:[S,b],export:(t,e)=>v(t)?wt(t,e,0):null,regExp:ft,replace:bt("number"),type:"element"},_t={format:["code"],tag:"`",type:"text-format"},Bt={format:["highlight"],tag:"==",type:"text-format"},jt={format:["bold","italic"],tag:"***",type:"text-format"},Pt={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},At={format:["bold"],tag:"**",type:"text-format"},Ot={format:["bold"],intraword:!1,tag:"__",type:"text-format"},zt={format:["strikethrough"],tag:"~~",type:"text-format"},Ut={format:["italic"],tag:"*",type:"text-format"},Wt={format:["italic"],intraword:!1,tag:"_",type:"text-format"},Dt={dependencies:[O],export:(t,e,n)=>{if(!z(t)||W(t))return null;const o=t.getTitle(),r=e(t);return o?`[${r}](${t.getURL()} "${o}")`:`[${r}](${t.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[\]]*(?:\[[^[\]]*\][^[\]]*)*)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,e)=>{if(d(t,z))return;const[,n,o,r]=e,s=U(o,{title:r}),i=n.split("[").length-1,c=n.split("]").length-1;let a=n,f="";if(i<c)return;if(i>c){const t=n.split("[");f="["+t[0],a=t.slice(1).join("[")}const g=l(a);return g.setFormat(t.getFormat()),s.append(g),t.replace(s),f&&s.insertBefore(l(f)),g},trigger:")",type:"text-match"},Kt=[Ft,Lt,kt,Mt],qt=[Nt],Gt=[_t,jt,Pt,At,Ot,Bt,Ut,Wt,zt],Ht=[Dt],Jt=[...Kt,...qt,...Gt,...Ht];function Qt(t,e,n,o,r){const s=t.getParent();if(!E(s)||t.getFirstChild()!==e)return!1;const i=e.getTextContent();if(!r&&" "!==i[n-1])return!1;for(const{regExpStart:s,replace:l,regExpEnd:c}of o){if(c&&!("optional"in c)||c&&"optional"in c&&!c.optional)continue;const o=i.match(s);if(o){const s=r||o[0].endsWith(" ")?n:n-1;if(o[0].length!==s)continue;const i=e.getNextSiblings(),[c,a]=e.splitText(n);if(!1!==l(t,a?[a,...i]:i,o,null,null,!1))return c.remove(),!0}}return!1}function Vt(t,e,n){const o=n.length;for(let r=e;r>=o;r--){const e=r-o;if(Xt(t,e,n,0,o)&&" "!==t[e+o])return e}return-1}function Xt(t,e,n,o,r){for(let s=0;s<r;s++)if(t[e+s]!==n[o+s])return!1;return!0}function Yt(t,n=Jt){const o=K(n),r=D(o.textFormat,({tag:t})=>t[t.length-1]),l=D(o.textMatch,({trigger:t})=>t);for(const e of n){const n=e.type;if("element"===n||"text-match"===n||"multiline-element"===n){const n=e.dependencies;for(const e of n)t.hasNode(e)||at(173,e.getType())}}const c=(t,n,c)=>{(function(t,e,n,o){const r=t.getParent();if(!E(r)||t.getFirstChild()!==e)return!1;const s=e.getTextContent();if(" "!==s[n-1])return!1;for(const{regExp:r,replace:i}of o){const o=s.match(r);if(o&&o[0].length===(o[0].endsWith(" ")?n:n-1)){const r=e.getNextSiblings(),[s,l]=e.splitText(n);if(!1!==i(t,l?[l,...r]:r,o,!1))return s.remove(),!0}}return!1})(t,n,c,o.element)||Qt(t,n,c,o.multilineElement)||function(t,e,n){let o=t.getTextContent();const r=n[o[e-1]];if(null==r)return!1;e<o.length&&(o=o.slice(0,e));for(const e of r){if(!e.replace||!e.regExp)continue;const n=o.match(e.regExp);if(null===n)continue;const r=n.index||0,s=r+n[0].length;let i;return 0===r?[i]=t.splitText(s):[,i]=t.splitText(r,s),i.selectNext(0,0),e.replace(i,n),!0}return!1}(n,c,l)||function(t,n,o){const r=t.getTextContent(),l=n-1,c=r[l],a=o[c];if(!a)return!1;for(const n of a){const{tag:o}=n,a=o.length,f=l-a+1;if(a>1&&!Xt(r,f,o,0,a))continue;if(" "===r[f-1])continue;const g=r[l+1];if(!1===n.intraword&&g&&!q.test(g))continue;const u=t;let d=u,p=Vt(r,f,o),h=d;for(;p<0&&(h=h.getPreviousSibling())&&!s(h);)if(e(h)){if(h.hasFormat("code"))continue;const t=h.getTextContent();d=h,p=Vt(t,t.length,o)}if(p<0)continue;if(d===u&&p+a===f)continue;const x=d.getTextContent();if(p>0&&x[p-1]===c)continue;const C=x[p-1];if(!1===n.intraword&&C&&!q.test(C))continue;const T=u.getTextContent(),E=T.slice(0,f)+T.slice(l+1);u.setTextContent(E);const v=d===u?E:x;d.setTextContent(v.slice(0,p)+v.slice(p+a));const I=i(),S=y();$(S);const b=l-a*(d===u?2:1)+1;S.anchor.set(d.__key,p,"text"),S.focus.set(u.__key,b,"text");for(const t of n.format)S.hasFormat(t)||S.formatText(t);S.anchor.set(S.focus.key,S.focus.offset,S.focus.type);for(const t of n.format)S.hasFormat(t)&&S.toggleFormat(t);return m(I)&&(S.format=I.format),!0}}(n,c,r)};return p(t.registerUpdateListener(({tags:n,dirtyLeaves:o,editorState:r,prevEditorState:s})=>{if(n.has(h)||n.has(x))return;if(t.isComposing())return;const l=r.read(i),a=s.read(i);if(!m(a)||!m(l)||!l.isCollapsed()||l.is(a))return;const f=l.anchor.key,g=l.anchor.offset,u=r._nodeMap.get(f);!e(u)||!o.has(f)||1!==g&&g>a.anchor.offset+1||t.update(()=>{if(!rt(u))return;const t=u.getParent();null===t||A(t)||c(t,u,l.anchor.offset)})}),t.registerCommand(C,t=>{if(null!==t&&t.shiftKey)return!1;const n=i();if(!m(n)||!n.isCollapsed())return!1;const r=n.anchor.offset,s=n.anchor.getNode();if(!e(s)||!rt(s))return!1;const l=s.getParent();if(null===l||A(l))return!1;return r===s.getTextContent().length&&(!!Qt(l,s,r,o.multilineElement,!0)&&(null!==t&&t.preventDefault(),!0))},T))}function Zt(t,e=Jt,n,o=!1,r=!1){const s=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 s=n[t].trimEnd(),i=r[r.length-1];mt.test(s)?r.push(s):ht.test(s)||xt.test(s)?(o=!o,r.push(s)):o||""===s||""===i||!i||dt.test(i)||dt.test(s)||pt.test(s)||ft.test(s)||gt.test(s)||ut.test(s)||Ct.test(s)||Tt.test(s)||!e||Et.test(s)||yt.test(s)||$t(yt).test(i)||$t(Et).test(i)||xt.test(i)?r.push(s):r[r.length-1]=i+" "+s.trimStart()}return r.join("\n")}(t,r);return it(e,o)(s,n)}function te(t=Jt,e,o=!1){const r=function(t,e=!1){const o=K(t),r=[...o.multilineElement,...o.element],s=!e,i=o.textFormat.filter(t=>1===t.format.length).sort((t,e)=>Number(t.format.includes("code"))-Number(e.format.includes("code")));return t=>{const e=[],l=(t||n()).getChildren();for(let t=0;t<l.length;t++){const n=l[t],c=V(n,r,i,o.textMatch);null!=c&&e.push(s&&t>0&&!Q(n)&&!Q(l[t-1])?"\n".concat(c):c)}return e.join("\n")}}(t,o);return r(e)}export{Zt as $convertFromMarkdownString,te as $convertToMarkdownString,jt as BOLD_ITALIC_STAR,Pt as BOLD_ITALIC_UNDERSCORE,At as BOLD_STAR,Ot as BOLD_UNDERSCORE,Rt as CHECK_LIST,Nt as CODE,Kt as ELEMENT_TRANSFORMERS,Ft as HEADING,Bt as HIGHLIGHT,_t as INLINE_CODE,Ut as ITALIC_STAR,Wt as ITALIC_UNDERSCORE,Dt as LINK,qt as MULTILINE_ELEMENT_TRANSFORMERS,Mt as ORDERED_LIST,Lt as QUOTE,zt as STRIKETHROUGH,Gt as TEXT_FORMAT_TRANSFORMERS,Ht as TEXT_MATCH_TRANSFORMERS,Jt as TRANSFORMERS,kt as UNORDERED_LIST,Yt as registerMarkdownShortcuts};
9
+ import{$isParagraphNode as t,$isTextNode as e,$getRoot as n,$isElementNode as o,$isDecoratorNode as r,$isLineBreakNode as s,$getSelection as i,$createTextNode as l,$createParagraphNode as c,$createLineBreakNode as a,createState as f,$setState as u,$getState as g,$findMatchingParent as d,mergeRegister as p,COLLABORATION_TAG as h,HISTORIC_TAG as x,$isRangeSelection as m,KEY_ENTER_COMMAND as C,COMMAND_PRIORITY_LOW as T,$isRootOrShadowRoot as E,$createRangeSelection as $,$setSelection as y}from"lexical";import{$isListNode as v,$isListItemNode as I,ListNode as S,ListItemNode as b,$createListItemNode as w,$createListNode as F}from"@lexical/list";import{$isQuoteNode as L,HeadingNode as N,QuoteNode as k,$isHeadingNode as R,$createQuoteNode as M,$createHeadingNode as _}from"@lexical/rich-text";import{$findMatchingParent as B}from"@lexical/utils";import{CodeNode as j,$createCodeNode as P,$isCodeNode as A}from"@lexical/code";import{LinkNode as O,$isLinkNode as z,$createLinkNode as U,$isAutoLinkNode as W}from"@lexical/link";function D(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 K(t){const e=D(t,t=>t.type);return{element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const q=/[!-/:-@[-`{-~\s]/,G=/[ \t\n\r\f]/,H=/[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~]/,J=/^\s{0,3}$/;function Q(n){if(!t(n))return!1;const o=n.getFirstChild();return null==o||1===n.getChildrenSize()&&e(o)&&J.test(o.getTextContent())}function V(t,e,n,s){for(const o of e){if(!o.export)continue;const e=o.export(t,t=>X(t,n,s));if(null!=e)return e}return o(t)?X(t,n,s):r(t)?t.getTextContent():null}function X(t,n,i,l,c){const a=[],f=t.getChildren();l||(l=[]),c||(c=[]);t:for(const t of f){for(const e of i){if(!e.export)continue;const o=e.export(t,t=>X(t,n,i,l,[...c,...l]),(t,e)=>Y(t,e,n,l,c));if(null!=o){a.push(o);continue t}}s(t)?a.push("\n"):e(t)?a.push(Y(t,t.getTextContent(),n,l,c)):o(t)?a.push(X(t,n,i,l,c)):r(t)&&a.push(t.getTextContent())}return a.join("")}function Y(t,e,n,o,r){let s=e;t.hasFormat("code")||(s=s.replace(/([*_`~\\])/g,"\\$1"));const i=s.match(/^(\s*)(.*?)(\s*)$/s)||["","",s,""],l=i[1],c=i[2],a=i[3],f=""===c;let u="",g="",d="";const p=Z(t,!0),h=Z(t,!1),x=new Set;for(const e of n){const n=e.format[0],r=e.tag;et(t,n)&&!x.has(n)&&(x.add(n),et(p,n)&&o.find(t=>t.tag===r)||(o.push({format:n,tag:r}),u+=r))}for(let e=0;e<o.length;e++){const n=tt(t,o[e].format),s=tt(h,o[e].format);if(n&&s)continue;const i=[...o];for(;i.length>e;){const t=i.pop();r&&t&&r.find(e=>e.tag===t.tag)||(t&&"string"==typeof t.tag&&(n?s||(d+=t.tag):g+=t.tag),o.pop())}break}return f&&!t.hasFormat("code")?g+s:g+l+u+c+d+a}function Z(t,n){const o=n?t.getPreviousSibling():t.getNextSibling();return e(o)?o:null}function tt(t,n){return e(t)&&t.hasFormat(n)}function et(t,e){return!!tt(t,e)&&("code"===e||(!t||!/^\s*$/.test(t.getTextContent())))}function nt(t,e){const n=t.getTextContent(),o=e.fullMatchRegExpByTag["`"],r=e.transformersByTag["`"],s=[];let i=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,n=e+t[0].length;i||(i={content:t[2],endIndex:n,startIndex:e,tag:"`"}),s.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])),s=e=>{let n=0;for(let o=e-1;o>=0&&"\\"===t[o];o--)n++;return n%2==1},i=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)||s(l)||i(l)){l++;continue}let n=1;for(;l+n<t.length&&t[l+n]===e;)n++;const c=ot(e,t,l,n,!0),a=ot(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,s),c=l.length>0?function(t,e,n){const o={};let r=0,s=null;for(;r<e.length;){const i=e[r];if(!i.active||!i.canClose||0===i.length){r++;continue}const l=`${i.char}${i.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!==i.char)continue;if(l.canClose||i.canOpen){if((l.originalLength+i.originalLength)%3==0&&l.originalLength%3!=0&&i.originalLength%3!=0)continue}const c=Math.min(l.length,i.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,g={content:t.slice(l.index+l.length,i.index),endIndex:i.index+u,startIndex:l.index+(l.length-u),tag:f};(!s||g.startIndex<s.startIndex||g.startIndex===s.startIndex&&g.endIndex>s.endIndex)&&(s=g);for(let t=o+1;t<r;t++)e[t].active=!1;l.length-=u,i.length-=u,l.active=l.length>0,i.length>0?i.index+=u:(i.active=!1,r++);break}a||(o[l]=r-1,i.canOpen||(i.active=!1),r++)}return s}(n,l,e):null;let a=null,f=null;if(i&&c?c.startIndex<=i.startIndex&&c.endIndex>=i.endIndex?(a=c,f=e.transformersByTag[c.tag]):(a=i,f=r):i?(a=i,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 ot(t,e,n,o,r){if(!rt(e,n,o,r))return!1;if("*"===t)return!0;if("_"===t){if(!rt(e,n,o,!r))return!0;const t=r?e[n-1]:e[n+o];return void 0!==t&&H.test(t)}return!0}function rt(t,e,n,o){const r=t[e-1],s=t[e+n],[i,l]=o?[s,r]:[r,s];return void 0!==i&&!G.test(i)&&(!H.test(i)||(void 0===l||G.test(l)||H.test(l)))}function st(t){return e(t)&&!t.hasFormat("code")}function it(t,e,n){let o=nt(t,e),r=function(t,e){const n=t;let o,r,s,i;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,s=t,i=e)}return void 0===o||void 0===r||void 0===s||void 0===i?null:{endIndex:r,match:i,startIndex:o,transformer:s}}(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 s=t.getTextContent();let i,l,c;if(r[0]===s?i=t:0===e?[i,l]=t.splitText(n):[c,i,l]=t.splitText(e,n),i.setTextContent(r[2]),o)for(const t of o.format)i.hasFormat(t)||i.toggleFormat(t);return{nodeAfter:l,nodeBefore:c,transformedNode:i}}(t,o.startIndex,o.endIndex,o.transformer,o.match);st(r.nodeAfter)&&it(r.nodeAfter,e,n),st(r.nodeBefore)&&it(r.nodeBefore,e,n),st(r.transformedNode)&&it(r.transformedNode,e,n)}else if(r){const o=function(t,e,n,o,r){let s,i,l;return 0===e?[s,i]=t.splitText(n):[l,s,i]=t.splitText(e,n),o.replace?{nodeAfter:i,nodeBefore:l,transformedNode:o.replace(s,r)||void 0}:null}(t,r.startIndex,r.endIndex,r.transformer,r.match);if(!o)return;st(o.nodeAfter)&&it(o.nodeAfter,e,n),st(o.nodeBefore)&&it(o.nodeBefore,e,n),st(o.transformedNode)&&it(o.transformedNode,e,n)}const s=t.getTextContent().replace(/\\([*_`~\\])/g,"$1").replace(/&#(\d+);/g,(t,e)=>String.fromCodePoint(e));t.setTextContent(s)}function lt(t,e=!1){const o=K(t),r=function(t){const e={},n={},o=[],r="(?<![\\\\])";for(const r of t){const{tag:t}=r;e[t]=r;const s=t.replace(/(\*|\^|\+)/g,"\\$1");o.push(s),1===t.length?n[t]="`"===t?new RegExp("(?<![\\\\`])(`)((?:\\\\`|[^`])+?)(`)(?!`)"):new RegExp(`(?<![\\\\${s}])(${s})((\\\\${s})?.*?[^${s}\\s](\\\\${s})?)((?<!\\\\)|(?<=\\\\\\\\))(${s})(?![\\\\${s}])`):n[t]=new RegExp(`(?<!\\\\)(${s})((\\\\${s})?.*?[^\\s](\\\\${s})?)((?<!\\\\)|(?<=\\\\\\\\))(${s})(?!\\\\)`)}return{fullMatchRegExpByTag:n,openTagsRegExp:new RegExp(`${r}(${o.join("|")})`,"g"),transformersByTag:e}}(o.textFormat);return(t,s)=>{const l=t.split("\n"),c=l.length,a=s||n();a.clear();for(let t=0;t<c;t++){const n=l[t],[s,i]=ct(l,t,o.multilineElement,a);s?t=i:at(n,a,o.element,r,o.textMatch,e)}const f=a.getChildren();for(const t of f)!e&&Q(t)&&a.getChildrenSize()>1&&t.remove();null!==i()&&a.selectStart()}}function ct(t,e,n,o){for(const r of n){const{handleImportAfterStartMatch:n,regExpEnd:s,regExpStart:i,replace:l}=r,c=t[e].match(i);if(!c)continue;if(n){const s=n({lines:t,rootNode:o,startLineIndex:e,startMatch:c,transformer:r});if(null===s)continue;if(s)return s}const a="object"==typeof s&&"regExp"in s?s.regExp:s,f=s&&"object"==typeof s&&"optional"in s?s.optional:!s;let u=e;const g=t.length;for(;u<g;){const n=a?t[u].match(a):null;if(!n&&(!f||f&&u<g-1)){u++;continue}if(n&&e===u&&n.index===c.index){u++;continue}const r=[];if(n&&e===u)r.push(t[e].slice(c[0].length,-n[0].length));else for(let o=e;o<=u;o++)if(o===e){const e=t[o].slice(c[0].length);r.push(e)}else if(o===u&&n){const e=t[o].slice(0,-n[0].length);r.push(e)}else r.push(t[o]);if(!1!==l(o,null,c,n,r,!0))return[!0,u];break}}return[!1,e]}function at(e,n,o,r,s,i){const f=l(e),u=c();u.append(f),n.append(u);for(const{regExp:t,replace:n}of o){const o=e.match(t);if(o&&(f.setTextContent(e.slice(o[0].length)),!1!==n(u,[f],o,!0)))break}if(it(f,r,s),u.isAttached()&&e.length>0){const e=u.getPreviousSibling();if(!i&&(t(e)||L(e)||v(e))){let t=e;if(v(e)){const n=e.getLastDescendant();t=null==n?null:B(n,I)}null!=t&&t.getTextContentSize()>0&&(t.splice(t.getChildrenSize(),0,[a(),...u.getChildren()]),u.remove())}}}function ft(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.`)}const ut=/^(\s*)(\d{1,})\.\s/,gt=/^(\s*)[-*+]\s/,dt=/^(\s*)(?:[-*+]\s)?\s?(\[(\s|x)?\])\s/i,pt=/^(#{1,6})\s/,ht=/^>\s/,xt=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,mt=/^[ \t]*`{3,}$/,Ct=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,Tt=/^(?:\|)(.+)(?:\|)\s?$/,Et=/^(\| ?:?-*:? ?)+\|\s?$/,$t=/^<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,yt=/^<\/[a-z_][\w-]*\s*>/i,vt=t=>new RegExp(`(?:${t.source})$`,t.flags),It=f("mdListMarker",{parse:t=>"string"==typeof t&&/^[-*+]$/.test(t)?t:"-"}),St=f("mdCodeFence",{parse:t=>"string"==typeof t&&/^`{3,}$/.test(t)?t:"```"}),bt=t=>(e,n,o,r)=>{const s=t(o);s.append(...n),e.replace(s),r||s.select(0,0)};const wt=t=>(e,n,o,r)=>{const s=e.getPreviousSibling(),i=e.getNextSibling(),l=w("check"===t?"x"===o[3]:void 0),c=o[0].trim()[0],a="bullet"!==t&&"check"!==t||c!==It.parse(c)?void 0:c;if(v(i)&&i.getListType()===t){a&&u(i,It,a);const t=i.getFirstChild();null!==t?t.insertBefore(l):i.append(l),e.remove()}else if(v(s)&&s.getListType()===t)a&&u(s,It,a),s.append(l),e.remove();else{const n=F(t,"number"===t?Number(o[2]):void 0);a&&u(n,It,a),n.append(l),e.replace(n)}l.append(...n),r||l.select(0,0);const f=function(t){const e=t.match(/\t/g),n=t.match(/ /g);let o=0;return e&&(o+=e.length),n&&(o+=Math.floor(n.length/4)),o}(o[1]);f&&l.setIndent(f)},Ft=(t,e,n)=>{const o=[],r=t.getChildren();let s=0;for(const i of r)if(I(i)){if(1===i.getChildrenSize()){const t=i.getFirstChild();if(v(t)){o.push(Ft(t,e,n+1));continue}}const r=" ".repeat(4*n),l=t.getListType(),c=g(t,It),a="number"===l?`${t.getStart()+s}. `:"check"===l?`${c} [${i.getChecked()?"x":" "}] `:c+" ";o.push(r+a+e(i)),s++}return o.join("\n")},Lt={dependencies:[N],export:(t,e)=>{if(!R(t))return null;const n=Number(t.getTag().slice(1));return"#".repeat(n)+" "+e(t)},regExp:pt,replace:bt(t=>{const e="h"+t[1].length;return _(e)}),type:"element"},Nt={dependencies:[k],export:(t,e)=>{if(!L(t))return null;const n=e(t).split("\n"),o=[];for(const t of n)o.push("> "+t);return o.join("\n")},regExp:ht,replace:(t,e,n,o)=>{if(o){const n=t.getPreviousSibling();if(L(n))return n.splice(n.getChildrenSize(),0,[a(),...e]),void t.remove()}const r=M();r.append(...e),t.replace(r),o||r.select(0,0)},type:"element"},kt={dependencies:[j],export:t=>{if(!A(t))return null;const e=t.getTextContent();let n=g(t,St);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],s=r.trim().length,i=t[n],l=o.index+r.length,c=i.slice(l),a=new RegExp(`\`{${s},}$`);if(a.test(c)){const t=c.match(a),r=c.slice(0,c.lastIndexOf(t[0])),s=[...o];return s[2]="",kt.replace(e,null,s,t,[r],!0),[!0,n]}const f=new RegExp(`^[ \\t]*\`{${s},}$`);for(let r=n+1;r<t.length;r++){const s=t[r];if(f.test(s)){const l=s.match(f),c=t.slice(n+1,r),a=i.slice(o[0].length);return a.length>0&&c.unshift(a),kt.replace(e,null,o,l,c,!0),[!0,r]}}const u=t.slice(n+1),g=i.slice(o[0].length);return g.length>0&&u.unshift(g),kt.replace(e,null,o,null,u,!0),[!0,t.length-1]},regExpEnd:{optional:!0,regExp:mt},regExpStart:xt,replace:(t,e,n,o,r,s)=>{let i,c;const a=n[1]?n[1].trim():"```",f=n[2]||void 0;if(!e&&r){if(1===r.length)o?(i=P(f),c=r[0]):(i=P(f),c=r[0].startsWith(" ")?r[0].slice(1):r[0]);else{for(i=P(f),r.length>0&&(0===r[0].trim().length?r.shift():r[0].startsWith(" ")&&(r[0]=r[0].slice(1)));r.length>0&&!r[r.length-1].length;)r.pop();c=r.join("\n")}u(i,St,a);const e=l(c);i.append(e),t.append(i)}else e&&bt(t=>P(t?t[2]:void 0))(t,e,n,s)},type:"multiline-element"},Rt={dependencies:[S,b],export:(t,e)=>v(t)?Ft(t,e,0):null,regExp:gt,replace:wt("bullet"),type:"element"},Mt={dependencies:[S,b],export:(t,e)=>v(t)?Ft(t,e,0):null,regExp:dt,replace:wt("check"),type:"element"},_t={dependencies:[S,b],export:(t,e)=>v(t)?Ft(t,e,0):null,regExp:ut,replace:wt("number"),type:"element"},Bt={format:["code"],tag:"`",type:"text-format"},jt={format:["highlight"],tag:"==",type:"text-format"},Pt={format:["bold","italic"],tag:"***",type:"text-format"},At={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},Ot={format:["bold"],tag:"**",type:"text-format"},zt={format:["bold"],intraword:!1,tag:"__",type:"text-format"},Ut={format:["strikethrough"],tag:"~~",type:"text-format"},Wt={format:["italic"],tag:"*",type:"text-format"},Dt={format:["italic"],intraword:!1,tag:"_",type:"text-format"},Kt={dependencies:[O],export:(t,e,n)=>{if(!z(t)||W(t))return null;const o=t.getTitle(),r=e(t);return o?`[${r}](${t.getURL()} "${o}")`:`[${r}](${t.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[\]]*(?:\[[^[\]]*\][^[\]]*)*)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,e)=>{if(d(t,z))return;const[,n,o,r]=e,s=U(o,{title:r}),i=n.split("[").length-1,c=n.split("]").length-1;let a=n,f="";if(i<c)return;if(i>c){const t=n.split("[");f="["+t[0],a=t.slice(1).join("[")}const u=l(a);return u.setFormat(t.getFormat()),s.append(u),t.replace(s),f&&s.insertBefore(l(f)),u},trigger:")",type:"text-match"},qt=[Lt,Nt,Rt,_t],Gt=[kt],Ht=[Bt,Pt,At,Ot,zt,jt,Wt,Dt,Ut],Jt=[Kt],Qt=[...qt,...Gt,...Ht,...Jt];function Vt(t,e,n,o,r){const s=t.getParent();if(!E(s)||t.getFirstChild()!==e)return!1;const i=e.getTextContent();if(!r&&" "!==i[n-1])return!1;for(const{regExpStart:s,replace:l,regExpEnd:c}of o){if(c&&!("optional"in c)||c&&"optional"in c&&!c.optional)continue;const o=i.match(s);if(o){const s=r||o[0].endsWith(" ")?n:n-1;if(o[0].length!==s)continue;const i=e.getNextSiblings(),[c,a]=e.splitText(n);if(!1!==l(t,a?[a,...i]:i,o,null,null,!1))return c.remove(),!0}}return!1}function Xt(t,e,n){const o=n.length;for(let r=e;r>=o;r--){const e=r-o;if(Yt(t,e,n,0,o)&&" "!==t[e+o])return e}return-1}function Yt(t,e,n,o,r){for(let s=0;s<r;s++)if(t[e+s]!==n[o+s])return!1;return!0}function Zt(t,n=Qt){const o=K(n),r=D(o.textFormat,({tag:t})=>t[t.length-1]),l=D(o.textMatch,({trigger:t})=>t);for(const e of n){const n=e.type;if("element"===n||"text-match"===n||"multiline-element"===n){const n=e.dependencies;for(const e of n)t.hasNode(e)||ft(173,e.getType())}}const c=(t,n,c)=>{(function(t,e,n,o){const r=t.getParent();if(!E(r)||t.getFirstChild()!==e)return!1;const s=e.getTextContent();if(" "!==s[n-1])return!1;for(const{regExp:r,replace:i}of o){const o=s.match(r);if(o&&o[0].length===(o[0].endsWith(" ")?n:n-1)){const r=e.getNextSiblings(),[s,l]=e.splitText(n);if(!1!==i(t,l?[l,...r]:r,o,!1))return s.remove(),!0}}return!1})(t,n,c,o.element)||Vt(t,n,c,o.multilineElement)||function(t,e,n){let o=t.getTextContent();const r=n[o[e-1]];if(null==r)return!1;e<o.length&&(o=o.slice(0,e));for(const e of r){if(!e.replace||!e.regExp)continue;const n=o.match(e.regExp);if(null===n)continue;const r=n.index||0,s=r+n[0].length;let i;return 0===r?[i]=t.splitText(s):[,i]=t.splitText(r,s),i.selectNext(0,0),e.replace(i,n),!0}return!1}(n,c,l)||function(t,n,o){const r=t.getTextContent(),l=n-1,c=r[l],a=o[c];if(!a)return!1;for(const n of a){const{tag:o}=n,a=o.length,f=l-a+1;if(a>1&&!Yt(r,f,o,0,a))continue;if(" "===r[f-1])continue;const u=r[l+1];if(!1===n.intraword&&u&&!q.test(u))continue;const g=t;let d=g,p=Xt(r,f,o),h=d;for(;p<0&&(h=h.getPreviousSibling())&&!s(h);)if(e(h)){if(h.hasFormat("code"))continue;const t=h.getTextContent();d=h,p=Xt(t,t.length,o)}if(p<0)continue;if(d===g&&p+a===f)continue;const x=d.getTextContent();if(p>0&&x[p-1]===c)continue;const C=x[p-1];if(!1===n.intraword&&C&&!q.test(C))continue;const T=g.getTextContent(),E=T.slice(0,f)+T.slice(l+1);g.setTextContent(E);const v=d===g?E:x;d.setTextContent(v.slice(0,p)+v.slice(p+a));const I=i(),S=$();y(S);const b=l-a*(d===g?2:1)+1;S.anchor.set(d.__key,p,"text"),S.focus.set(g.__key,b,"text");for(const t of n.format)S.hasFormat(t)||S.formatText(t);S.anchor.set(S.focus.key,S.focus.offset,S.focus.type);for(const t of n.format)S.hasFormat(t)&&S.toggleFormat(t);return m(I)&&(S.format=I.format),!0}}(n,c,r)};return p(t.registerUpdateListener(({tags:n,dirtyLeaves:o,editorState:r,prevEditorState:s})=>{if(n.has(h)||n.has(x))return;if(t.isComposing())return;const l=r.read(i),a=s.read(i);if(!m(a)||!m(l)||!l.isCollapsed()||l.is(a))return;const f=l.anchor.key,u=l.anchor.offset,g=r._nodeMap.get(f);!e(g)||!o.has(f)||1!==u&&u>a.anchor.offset+1||t.update(()=>{if(!st(g))return;const t=g.getParent();null===t||A(t)||c(t,g,l.anchor.offset)})}),t.registerCommand(C,t=>{if(null!==t&&t.shiftKey)return!1;const n=i();if(!m(n)||!n.isCollapsed())return!1;const r=n.anchor.offset,s=n.anchor.getNode();if(!e(s)||!st(s))return!1;const l=s.getParent();if(null===l||A(l))return!1;return r===s.getTextContent().length&&(!!Vt(l,s,r,o.multilineElement,!0)&&(null!==t&&t.preventDefault(),!0))},T))}function te(t,e=Qt,n,o=!1,r=!1){const s=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 s=n[t].trimEnd(),i=r[r.length-1];Ct.test(s)?r.push(s):xt.test(s)||mt.test(s)?(o=!o,r.push(s)):o||""===s||""===i||!i||pt.test(i)||pt.test(s)||ht.test(s)||ut.test(s)||gt.test(s)||dt.test(s)||Tt.test(s)||Et.test(s)||!e||$t.test(s)||yt.test(s)||vt(yt).test(i)||vt($t).test(i)||mt.test(i)?r.push(s):r[r.length-1]=i+" "+s.trimStart()}return r.join("\n")}(t,r);return lt(e,o)(s,n)}function ee(t=Qt,e,o=!1){const r=function(t,e=!1){const o=K(t),r=[...o.multilineElement,...o.element],s=!e,i=o.textFormat.filter(t=>1===t.format.length).sort((t,e)=>Number(t.format.includes("code"))-Number(e.format.includes("code")));return t=>{const e=[],l=(t||n()).getChildren();for(let t=0;t<l.length;t++){const n=l[t],c=V(n,r,i,o.textMatch);null!=c&&e.push(s&&t>0&&!Q(n)&&!Q(l[t-1])?"\n".concat(c):c)}return e.join("\n")}}(t,o);return r(e)}export{te as $convertFromMarkdownString,ee as $convertToMarkdownString,Pt as BOLD_ITALIC_STAR,At as BOLD_ITALIC_UNDERSCORE,Ot as BOLD_STAR,zt as BOLD_UNDERSCORE,Mt as CHECK_LIST,kt as CODE,qt as ELEMENT_TRANSFORMERS,Lt as HEADING,jt as HIGHLIGHT,Bt as INLINE_CODE,Wt as ITALIC_STAR,Dt as ITALIC_UNDERSCORE,Kt as LINK,Gt as MULTILINE_ELEMENT_TRANSFORMERS,_t as ORDERED_LIST,Nt as QUOTE,Ut as STRIKETHROUGH,Ht as TEXT_FORMAT_TRANSFORMERS,Jt as TEXT_MATCH_TRANSFORMERS,Qt as TRANSFORMERS,Rt as UNORDERED_LIST,Zt as registerMarkdownShortcuts};
package/package.json CHANGED
@@ -8,17 +8,17 @@
8
8
  "markdown"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.41.0",
11
+ "version": "0.41.1-nightly.20260227.0",
12
12
  "main": "LexicalMarkdown.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/code": "0.41.0",
16
- "@lexical/link": "0.41.0",
17
- "@lexical/list": "0.41.0",
18
- "@lexical/rich-text": "0.41.0",
19
- "@lexical/text": "0.41.0",
20
- "@lexical/utils": "0.41.0",
21
- "lexical": "0.41.0"
15
+ "@lexical/code": "0.41.1-nightly.20260227.0",
16
+ "@lexical/link": "0.41.1-nightly.20260227.0",
17
+ "@lexical/list": "0.41.1-nightly.20260227.0",
18
+ "@lexical/rich-text": "0.41.1-nightly.20260227.0",
19
+ "@lexical/text": "0.41.1-nightly.20260227.0",
20
+ "@lexical/utils": "0.41.1-nightly.20260227.0",
21
+ "lexical": "0.41.1-nightly.20260227.0"
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",