@lexical/markdown 0.4.1 → 0.5.1-next.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.
- package/LexicalMarkdown.dev.js +38 -6
- package/LexicalMarkdown.prod.js +21 -18
- package/MarkdownTransformers.d.ts +1 -1
- package/package.json +8 -8
package/LexicalMarkdown.dev.js
CHANGED
|
@@ -192,6 +192,32 @@ function hasFormat(node, format) {
|
|
|
192
192
|
return lexical.$isTextNode(node) && node.hasFormat(format);
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
197
|
+
*
|
|
198
|
+
* This source code is licensed under the MIT license found in the
|
|
199
|
+
* LICENSE file in the root directory of this source tree.
|
|
200
|
+
*
|
|
201
|
+
*/
|
|
202
|
+
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
206
|
+
*
|
|
207
|
+
* This source code is licensed under the MIT license found in the
|
|
208
|
+
* LICENSE file in the root directory of this source tree.
|
|
209
|
+
*
|
|
210
|
+
*/
|
|
211
|
+
const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
|
|
212
|
+
CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
213
|
+
CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
|
|
214
|
+
CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
|
|
215
|
+
const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
|
|
216
|
+
const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; // Keep these in case we need to use them in the future.
|
|
217
|
+
// export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
|
|
218
|
+
// export const IS_CHROME: boolean = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
|
|
219
|
+
// export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
|
|
220
|
+
|
|
195
221
|
/**
|
|
196
222
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
197
223
|
*
|
|
@@ -457,6 +483,7 @@ function createTextFormatTransformersIndex(textTransformers) {
|
|
|
457
483
|
const transformersByTag = {};
|
|
458
484
|
const fullMatchRegExpByTag = {};
|
|
459
485
|
const openTagsRegExp = [];
|
|
486
|
+
const escapeRegExp = `(?<![\\\\])`;
|
|
460
487
|
|
|
461
488
|
for (const transformer of textTransformers) {
|
|
462
489
|
const {
|
|
@@ -465,14 +492,19 @@ function createTextFormatTransformersIndex(textTransformers) {
|
|
|
465
492
|
transformersByTag[tag] = transformer;
|
|
466
493
|
const tagRegExp = tag.replace(/(\*|\^)/g, '\\$1');
|
|
467
494
|
openTagsRegExp.push(tagRegExp);
|
|
468
|
-
|
|
495
|
+
|
|
496
|
+
if (IS_SAFARI || IS_IOS) {
|
|
497
|
+
fullMatchRegExpByTag[tag] = new RegExp(`(${tagRegExp})(?![${tagRegExp}\\s])(.*?[^${tagRegExp}\\s])${tagRegExp}(?!${tagRegExp})`);
|
|
498
|
+
} else {
|
|
499
|
+
fullMatchRegExpByTag[tag] = new RegExp(`(?<![\\\\${tagRegExp}])(${tagRegExp})((\\\\${tagRegExp})?.*?[^${tagRegExp}\\s](\\\\${tagRegExp})?)((?<!\\\\)|(?<=\\\\\\\\))(${tagRegExp})(?![\\\\${tagRegExp}])`);
|
|
500
|
+
}
|
|
469
501
|
}
|
|
470
502
|
|
|
471
503
|
return {
|
|
472
504
|
// Reg exp to find open tag + content + close tag
|
|
473
505
|
fullMatchRegExpByTag,
|
|
474
506
|
// Reg exp to find opening tags
|
|
475
|
-
openTagsRegExp: new RegExp('(' + openTagsRegExp.join('|') + ')', 'g'),
|
|
507
|
+
openTagsRegExp: new RegExp((IS_SAFARI || IS_IOS ? '' : `${escapeRegExp}`) + '(' + openTagsRegExp.join('|') + ')', 'g'),
|
|
476
508
|
transformersByTag
|
|
477
509
|
};
|
|
478
510
|
}
|
|
@@ -488,7 +520,7 @@ function createTextFormatTransformersIndex(textTransformers) {
|
|
|
488
520
|
function runElementTransformers(parentNode, anchorNode, anchorOffset, elementTransformers) {
|
|
489
521
|
const grandParentNode = parentNode.getParent();
|
|
490
522
|
|
|
491
|
-
if (!lexical.$
|
|
523
|
+
if (!lexical.$isRootOrShadowRoot(grandParentNode) || parentNode.getFirstChild() !== anchorNode) {
|
|
492
524
|
return false;
|
|
493
525
|
}
|
|
494
526
|
|
|
@@ -793,7 +825,7 @@ function registerMarkdownShortcuts(editor, transformers = TRANSFORMERS) {
|
|
|
793
825
|
*
|
|
794
826
|
*/
|
|
795
827
|
|
|
796
|
-
const
|
|
828
|
+
const createBlockNode = createNode => {
|
|
797
829
|
return (parentNode, children, match) => {
|
|
798
830
|
const node = createNode(match);
|
|
799
831
|
node.append(...children);
|
|
@@ -868,7 +900,7 @@ const HEADING = {
|
|
|
868
900
|
return '#'.repeat(level) + ' ' + exportChildren(node);
|
|
869
901
|
},
|
|
870
902
|
regExp: /^(#{1,6})\s/,
|
|
871
|
-
replace:
|
|
903
|
+
replace: createBlockNode(match => {
|
|
872
904
|
const tag = 'h' + match[1].length;
|
|
873
905
|
return richText.$createHeadingNode(tag);
|
|
874
906
|
}),
|
|
@@ -921,7 +953,7 @@ const CODE = {
|
|
|
921
953
|
return '```' + (node.getLanguage() || '') + (textContent ? '\n' + textContent : '') + '\n' + '```';
|
|
922
954
|
},
|
|
923
955
|
regExp: /^```(\w{1,10})?\s/,
|
|
924
|
-
replace:
|
|
956
|
+
replace: createBlockNode(match => {
|
|
925
957
|
return code.$createCodeNode(match ? match[1] : undefined);
|
|
926
958
|
}),
|
|
927
959
|
type: 'element'
|
package/LexicalMarkdown.prod.js
CHANGED
|
@@ -7,23 +7,26 @@
|
|
|
7
7
|
'use strict';var h=require("lexical"),t=require("@lexical/code"),A=require("@lexical/list"),F=require("@lexical/rich-text"),aa=require("@lexical/utils"),G=require("@lexical/link");function H(a,b){let c={};for(let d of a)a=b(d),c[a]?c[a].push(d):c[a]=[d];return c}function I(a){a=H(a,b=>b.type);return{element:a.element||[],textFormat:a["text-format"]||[],textMatch:a["text-match"]||[]}}let J=/[!-/:-@[-`{-~\s]/;
|
|
8
8
|
function ba(a){let b=I(a),c=b.textFormat.filter(d=>1===d.format.length);return()=>{let d=[];var e=h.$getRoot().getChildren();for(let f of e)e=ca(f,b.element,c,b.textMatch),null!=e&&d.push(e);return d.join("\n\n")}}function ca(a,b,c,d){for(let e of b)if(b=e.export(a,f=>K(f,c,d)),null!=b)return b;return h.$isElementNode(a)?K(a,c,d):null}
|
|
9
9
|
function K(a,b,c){let d=[];a=a.getChildren();a:for(let e of a){for(let f of c)if(a=f.export(e,k=>K(k,b,c),(k,p)=>L(k,p,b)),null!=a){d.push(a);continue a}h.$isLineBreakNode(e)?d.push("\n"):h.$isTextNode(e)?d.push(L(e,e.getTextContent(),b)):h.$isElementNode(e)&&d.push(K(e,b,c))}return d.join("")}function L(a,b,c){let d=b.trim(),e=d,f=new Set;for(let p of c){c=p.format[0];let r=p.tag;if(M(a,c)&&!f.has(c)){f.add(c);var k=N(a,!0);M(k,c)||(e=r+e);k=N(a,!1);M(k,c)||(e+=r)}}return b.replace(d,e)}
|
|
10
|
-
function N(a,b){let c=b?a.getPreviousSibling():a.getNextSibling();c||(a=a.getParentOrThrow(),a.isInline()&&(c=b?a.getPreviousSibling():a.getNextSibling()));for(;c;){if(h.$isElementNode(c)){if(!c.isInline())break;a=b?c.getLastDescendant():c.getFirstDescendant();if(h.$isTextNode(a))return a;c=b?c.getPreviousSibling():c.getNextSibling()}if(h.$isTextNode(c))return c;if(!h.$isElementNode(c))break}return null}function M(a,b){return h.$isTextNode(a)&&a.hasFormat(b)}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
(a.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
function N(a,b){let c=b?a.getPreviousSibling():a.getNextSibling();c||(a=a.getParentOrThrow(),a.isInline()&&(c=b?a.getPreviousSibling():a.getNextSibling()));for(;c;){if(h.$isElementNode(c)){if(!c.isInline())break;a=b?c.getLastDescendant():c.getFirstDescendant();if(h.$isTextNode(a))return a;c=b?c.getPreviousSibling():c.getNextSibling()}if(h.$isTextNode(c))return c;if(!h.$isElementNode(c))break}return null}function M(a,b){return h.$isTextNode(a)&&a.hasFormat(b)}
|
|
11
|
+
let O="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,da=O&&"documentMode"in document?document.documentMode:null;O&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);O&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);O&&"InputEvent"in window&&!da?"getTargetRanges"in new window.InputEvent("input"):!1;
|
|
12
|
+
let P=O&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Q=O&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,ea=/^\s{0,3}$/,R=/^```(\w{1,10})?\s?$/;
|
|
13
|
+
function fa(a){let b=I(a),c=ha(b.textFormat);return d=>{var e=d.split("\n"),f=e.length;d=h.$getRoot();d.clear();for(let g=0;g<f;g++){var k=e[g];a:{var p=e,r=g;var n=d;var u=p[r].match(R);if(u)for(var q=r,l=p.length;++q<l;)if(p[q].match(R)){u=t.$createCodeNode(u[1]);p=h.$createTextNode(p.slice(r+1,q).join("\n"));u.append(p);n.append(u);n=[u,q];break a}n=[null,r]}let [m,w]=n;if(null!=m)g=w;else{n=k;l=d;var x=b.element;q=c;p=b.textMatch;r=n.trim();u=h.$createTextNode(r);k=h.$createParagraphNode();k.append(u);
|
|
14
|
+
l.append(k);for(let {regExp:y,replace:v}of x)if(l=n.match(y)){u.setTextContent(n.slice(l[0].length));v(k,[u],l,!0);break}S(u,q,p);k.isAttached()&&0<r.length&&(n=k.getPreviousSibling(),h.$isParagraphNode(n)||F.$isQuoteNode(n)||A.$isListNode(n))&&(q=n,A.$isListNode(n)&&(n=n.getLastDescendant(),q=null==n?null:aa.$findMatchingParent(n,A.$isListItemNode)),null!=q&&0<q.getTextContentSize()&&(q.splice(q.getChildrenSize(),0,[h.$createLineBreakNode(),...k.getChildren()]),k.remove()))}}e=d.getChildren();for(let g of e)e=
|
|
15
|
+
g,h.$isParagraphNode(e)?(f=e.getFirstChild(),e=null==f||1===e.getChildrenSize()&&h.$isTextNode(f)&&ea.test(f.getTextContent())):e=!1,e&&g.remove();d.selectEnd()}}
|
|
16
|
+
function S(a,b,c){let d=a.getTextContent(),e=ia(d,b);if(e){if(e[0]===d)var f=a;else{var k=e.index||0,p=k+e[0].length;0===k?[f,r]=a.splitText(p):[n,f,r]=a.splitText(k,p)}f.setTextContent(e[2]);if(k=b.transformersByTag[e[1]])for(let u of k.format)f.hasFormat(u)||f.toggleFormat(u);f.hasFormat("code")||S(f,b,c);n&&S(n,b,c);r&&S(r,b,c)}else a:for(b=a;b;){for(k of c)if(f=b.getTextContent().match(k.importRegExp)){var r=f.index||0;var n=r+f[0].length;0===r?[p,b]=b.splitText(n):[,p,b]=b.splitText(r,n);k.replace(p,
|
|
17
|
+
f);continue a}break}}function ia(a,b){var c=a.match(b.openTagsRegExp);if(null==c)return null;for(let f of c){var d=f.replace(/^\s/,"");c=b.fullMatchRegExpByTag[d];if(null!=c&&(c=a.match(c),d=b.transformersByTag[d],null!=c&&null!=d)){if(!1!==d.intraword)return c;var {index:e=0}=c;d=a[e-1];e=a[e+c[0].length];if(!(d&&!J.test(d)||e&&!J.test(e)))return c}}return null}
|
|
18
|
+
function ha(a){let b={},c={},d=[];for(let e of a){({tag:a}=e);b[a]=e;let f=a.replace(/(\*|\^)/g,"\\$1");d.push(f);c[a]=P||Q?new RegExp(`(${f})(?![${f}\\s])(.*?[^${f}\\s])${f}(?!${f})`):new RegExp(`(?<![\\\\${f}])(${f})((\\\\${f})?.*?[^${f}\\s](\\\\${f})?)((?<!\\\\)|(?<=\\\\\\\\))(${f})(?![\\\\${f}])`)}return{fullMatchRegExpByTag:c,openTagsRegExp:new RegExp((P||Q?"":"(?<![\\\\])")+"("+d.join("|")+")","g"),transformersByTag:b}}
|
|
19
|
+
function T(a,b,c){let d=c.length;for(;b>=d;b--){let e=b-d;if(U(a,e,c,0,d)&&" "!==a[e+d])return e}return-1}function U(a,b,c,d,e){for(let f=0;f<e;f++)if(a[b+f]!==c[d+f])return!1;return!0}
|
|
20
|
+
let V=a=>(b,c,d)=>{d=a(d);d.append(...c);b.replace(d);d.select(0,0)},W=a=>(b,c,d)=>{var e=b.getPreviousSibling();const f=A.$createListItemNode("check"===a?"x"===d[3]:void 0);A.$isListNode(e)&&e.getListType()===a?(e.append(f),b.remove()):(e=A.$createListNode(a,"number"===a?Number(d[2]):void 0),e.append(f),b.replace(e));f.append(...c);f.select(0,0);(b=Math.floor(d[1].length/4))&&f.setIndent(b)},X=(a,b,c)=>{const d=[];var e=a.getChildren();let f=0;for(const p of e)if(A.$isListItemNode(p)){if(1===p.getChildrenSize()&&
|
|
21
|
+
(e=p.getFirstChild(),A.$isListNode(e))){d.push(X(e,b,c+1));continue}e=" ".repeat(4*c);var k=a.getListType();k="number"===k?`${a.getStart()+f}. `:"check"===k?`- [${p.getChecked()?"x":" "}] `:"- ";d.push(e+k+b(p));f++}return d.join("\n")},Y={dependencies:[F.HeadingNode],export:(a,b)=>{if(!F.$isHeadingNode(a))return null;const c=Number(a.getTag().slice(1));return"#".repeat(c)+" "+b(a)},regExp:/^(#{1,6})\s/,replace:V(a=>F.$createHeadingNode("h"+a[1].length)),type:"element"},ja={dependencies:[F.QuoteNode],
|
|
22
|
+
export:(a,b)=>{if(!F.$isQuoteNode(a))return null;a=b(a).split("\n");b=[];for(const c of a)b.push("> "+c);return b.join("\n")},regExp:/^>\s/,replace:(a,b,c,d)=>{if(d&&(c=a.getPreviousSibling(),F.$isQuoteNode(c))){c.splice(c.getChildrenSize(),0,[h.$createLineBreakNode(),...b]);c.select(0,0);a.remove();return}c=F.$createQuoteNode();c.append(...b);a.replace(c);c.select(0,0)},type:"element"},ka={dependencies:[t.CodeNode],export:a=>{if(!t.$isCodeNode(a))return null;const b=a.getTextContent();return"```"+
|
|
23
|
+
(a.getLanguage()||"")+(b?"\n"+b:"")+"\n```"},regExp:/^```(\w{1,10})?\s/,replace:V(a=>t.$createCodeNode(a?a[1]:void 0)),type:"element"},la={dependencies:[A.ListNode,A.ListItemNode],export:(a,b)=>A.$isListNode(a)?X(a,b,0):null,regExp:/^(\s*)[-*+]\s/,replace:W("bullet"),type:"element"},ma={dependencies:[A.ListNode,A.ListItemNode],export:(a,b)=>A.$isListNode(a)?X(a,b,0):null,regExp:/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,replace:W("check"),type:"element"},na={dependencies:[A.ListNode,A.ListItemNode],export:(a,
|
|
24
|
+
b)=>A.$isListNode(a)?X(a,b,0):null,regExp:/^(\s*)(\d{1,})\.\s/,replace:W("number"),type:"element"},oa={format:["code"],tag:"`",type:"text-format"},pa={format:["bold","italic"],tag:"***",type:"text-format"},qa={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},sa={format:["bold"],tag:"**",type:"text-format"},ta={format:["bold"],intraword:!1,tag:"__",type:"text-format"},ua={format:["strikethrough"],tag:"~~",type:"text-format"},va={format:["italic"],tag:"*",type:"text-format"},wa={format:["italic"],
|
|
25
|
+
intraword:!1,tag:"_",type:"text-format"},xa={dependencies:[G.LinkNode],export:(a,b,c)=>{if(!G.$isLinkNode(a))return null;b=`[${a.getTextContent()}](${a.getURL()})`;const d=a.getFirstChild();return 1===a.getChildrenSize()&&h.$isTextNode(d)?c(d,b):b},importRegExp:/(?:\[([^[]+)\])(?:\(([^(]+)\))/,regExp:/(?:\[([^[]+)\])(?:\(([^(]+)\))$/,replace:(a,b)=>{const [,c,d]=b;b=G.$createLinkNode(d);const e=h.$createTextNode(c);e.setFormat(a.getFormat());b.append(e);a.replace(b)},trigger:")",type:"text-match"},
|
|
26
|
+
ya=[Y,ja,ka,la,na],za=[oa,pa,qa,sa,ta,va,wa,ua],Aa=[xa],Z=[...ya,...za,...Aa];exports.$convertFromMarkdownString=function(a,b=Z){return fa(b)(a)};exports.$convertToMarkdownString=function(a=Z){return ba(a)()};exports.BOLD_ITALIC_STAR=pa;exports.BOLD_ITALIC_UNDERSCORE=qa;exports.BOLD_STAR=sa;exports.BOLD_UNDERSCORE=ta;exports.CHECK_LIST=ma;exports.CODE=ka;exports.ELEMENT_TRANSFORMERS=ya;exports.HEADING=Y;exports.INLINE_CODE=oa;exports.ITALIC_STAR=va;exports.ITALIC_UNDERSCORE=wa;exports.LINK=xa;
|
|
27
|
+
exports.ORDERED_LIST=na;exports.QUOTE=ja;exports.STRIKETHROUGH=ua;exports.TEXT_FORMAT_TRANSFORMERS=za;exports.TEXT_MATCH_TRANSFORMERS=Aa;exports.TRANSFORMERS=Z;exports.UNORDERED_LIST=la;
|
|
25
28
|
exports.registerMarkdownShortcuts=function(a,b=Z){let c=I(b),d=H(c.textFormat,({tag:f})=>f[f.length-1]),e=H(c.textMatch,({trigger:f})=>f);for(let f of b)if(b=f.type,("element"===b||"text-match"===b)&&!a.hasNodes(f.dependencies))throw Error("Minified Lexical error #79; visit https://lexical.dev/docs/error?code=79 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return a.registerUpdateListener(({tags:f,dirtyLeaves:k,editorState:p,prevEditorState:r})=>
|
|
26
|
-
{if(!f.has("historic")){var n=p.read(h.$getSelection);f=r.read(h.$getSelection);if(h.$isRangeSelection(f)&&h.$isRangeSelection(n)&&n.isCollapsed()){r=n.anchor.key;var u=n.anchor.offset,q=p._nodeMap.get(r);h.$isTextNode(q)&&k.has(r)&&(1===u||u===f.anchor.offset+1)&&a.update(()=>{if(!q.hasFormat("code")){var l=q.getParent();if(null!==l&&!t.$isCodeNode(l)){var x=n.anchor.offset;b:{var g=c.element,m=l.getParent();if(h.$
|
|
27
|
-
replace:D}of g)if((g=m.match(C))&&g[0].length===x){m=q.getNextSiblings();let [E,
|
|
28
|
-
C;y=B.length;let D=x-y+1;if(!(1<y&&!
|
|
29
|
+
{if(!f.has("historic")){var n=p.read(h.$getSelection);f=r.read(h.$getSelection);if(h.$isRangeSelection(f)&&h.$isRangeSelection(n)&&n.isCollapsed()){r=n.anchor.key;var u=n.anchor.offset,q=p._nodeMap.get(r);h.$isTextNode(q)&&k.has(r)&&(1===u||u===f.anchor.offset+1)&&a.update(()=>{if(!q.hasFormat("code")){var l=q.getParent();if(null!==l&&!t.$isCodeNode(l)){var x=n.anchor.offset;b:{var g=c.element,m=l.getParent();if(h.$isRootOrShadowRoot(m)&&l.getFirstChild()===q&&(m=q.getTextContent()," "===m[x-1]))for(let {regExp:C,
|
|
30
|
+
replace:D}of g)if((g=m.match(C))&&g[0].length===x){m=q.getNextSiblings();let [E,ra]=q.splitText(x);E.remove();m=ra?[ra,...m]:m;D(l,m,g,!1);l=!0;break b}l=!1}if(!l){b:{g=q.getTextContent();l=e[g[x-1]];if(null!=l){x<g.length&&(g=g.slice(0,x));for(y of l)if(l=g.match(y.regExp),null!==l){g=l.index||0;m=g+l[0].length;var w=void 0;0===g?[w]=q.splitText(m):[,w]=q.splitText(g,m);w.selectNext(0,0);y.replace(w,l);var y=!0;break b}}y=!1}if(!y)b:{m=q.getTextContent();--x;var v=m[x];if(y=d[v])for(let C of y){var {tag:B}=
|
|
31
|
+
C;y=B.length;let D=x-y+1;if(!(1<y&&!U(m,D,B,0,y)||" "===m[D-1])&&(w=m[x+1],!1!==C.intraword||!w||J.test(w))){l=w=q;g=T(m,D,B);for(var z=l;0>g&&(z=z.getPreviousSibling())&&!h.$isLineBreakNode(z);)h.$isTextNode(z)&&(g=z.getTextContent(),l=z,g=T(g,g.length,B));if(!(0>g||l===w&&g+y===D||(B=l.getTextContent(),0<g&&B[g-1]===v||(z=B[g-1],!1===C.intraword&&z&&!J.test(z))))){m=w.getTextContent();m=m.slice(0,D)+m.slice(x+1);w.setTextContent(m);m=l===w?m:B;l.setTextContent(m.slice(0,g)+m.slice(g+y));m=h.$getSelection();
|
|
29
32
|
v=h.$createRangeSelection();h.$setSelection(v);x=x-y*(l===w?2:1)+1;v.anchor.set(l.__key,g,"text");v.focus.set(w.__key,x,"text");for(let E of C.format)v.hasFormat(E)||v.formatText(E);v.anchor.set(v.focus.key,v.focus.offset,v.focus.type);for(let E of C.format)v.hasFormat(E)&&v.toggleFormat(E);h.$isRangeSelection(m)&&(v.format=m.format);break b}}}}}}}})}}})}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import { ElementNode, Klass, LexicalNode, TextFormatType, TextNode } from 'lexical';
|
|
9
9
|
export declare type Transformer = ElementTransformer | TextFormatTransformer | TextMatchTransformer;
|
|
10
10
|
export declare type ElementTransformer = {
|
|
11
11
|
dependencies: Array<Klass<LexicalNode>>;
|
package/package.json
CHANGED
|
@@ -8,18 +8,18 @@
|
|
|
8
8
|
"markdown"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.5.1-next.0",
|
|
12
12
|
"main": "LexicalMarkdown.js",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"lexical": "0.
|
|
14
|
+
"lexical": "0.5.1-next.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lexical/utils": "0.
|
|
18
|
-
"@lexical/code": "0.
|
|
19
|
-
"@lexical/text": "0.
|
|
20
|
-
"@lexical/rich-text": "0.
|
|
21
|
-
"@lexical/list": "0.
|
|
22
|
-
"@lexical/link": "0.
|
|
17
|
+
"@lexical/utils": "0.5.1-next.0",
|
|
18
|
+
"@lexical/code": "0.5.1-next.0",
|
|
19
|
+
"@lexical/text": "0.5.1-next.0",
|
|
20
|
+
"@lexical/rich-text": "0.5.1-next.0",
|
|
21
|
+
"@lexical/list": "0.5.1-next.0",
|
|
22
|
+
"@lexical/link": "0.5.1-next.0"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|