lexical 0.1.2 → 0.1.6

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/AutoLinkNode.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var b=require("lexical/LinkNode");class c extends b.LinkNode{static getType(){return"autolink"}static clone(a){return new c(a.__url,a.__key)}insertNewAfter(a){a=this.getParentOrThrow().insertNewAfter(a);if(null!==a){const d=e(this.__url);a.append(d);return d}return null}canInsertTextAfter(){return!0}}function e(a){return new c(a)}exports.$createAutoLinkNode=e;exports.$isAutoLinkNode=function(a){return a instanceof c};exports.AutoLinkNode=c;
1
+ 'use strict';var b=require("lexical/LinkNode"),c=require("lexical");class e extends b.LinkNode{static getType(){return"autolink"}static clone(a){return new e(a.__url,a.__key)}insertNewAfter(a){a=this.getParentOrThrow().insertNewAfter(a);if(c.$isElementNode(a)){const d=f(this.__url);a.append(d);return d}return null}canInsertTextAfter(){return!0}}function f(a){return new e(a)}exports.$createAutoLinkNode=f;exports.$isAutoLinkNode=function(a){return a instanceof e};exports.AutoLinkNode=e;
package/CodeNode.js CHANGED
@@ -1,3 +1,5 @@
1
- 'use strict';var d=require("lexical"),e=require("lexical/ParagraphNode");function f(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}
2
- class g extends d.ElementNode{static getType(){return"code"}static clone(a){return new g(a.__language,a.__key)}constructor(a,b){super(b);this.__language=a}createDOM(a){const b=document.createElement("code");f(b,a.theme.code);b.setAttribute("spellcheck","false");return b}updateDOM(){return!1}insertNewAfter(a){const b=this.getChildren(),c=b.length;return 2<=c&&"\n"===b[c-1].getTextContent()&&"\n"===b[c-2].getTextContent()&&a.isCollapsed()&&a.anchor.key===this.__key&&a.anchor.offset===c?(b[c-1].remove(),
3
- b[c-2].remove(),a=e.$createParagraphNode(),this.insertAfter(a),a):null}canInsertTab(){return!0}collapseAtStart(){const a=e.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}setLanguage(a){this.getWritable().__language=a}getLanguage(){return this.getLatest().__language}}exports.$createCodeNode=function(a){return new g(a)};exports.$isCodeNode=function(a){return a instanceof g};exports.CodeNode=g;
1
+ 'use strict';var d=require("lexical"),f=require("lexical/CodeHighlightNode");function g(a,...c){c.forEach(b=>{null!=b&&"string"===typeof b&&a.classList.add(...b.split(" "))})}
2
+ class h extends d.ElementNode{static getType(){return"code"}static clone(a){return new h(a.__language,a.__key)}constructor(a,c){super(c);this.__language=a}createDOM(a){const c=document.createElement("code");g(c,a.theme.code);c.setAttribute("spellcheck","false");return c}updateDOM(){return!1}insertNewAfter(a){var c=this.getChildren(),b=c.length;if(2<=b&&"\n"===c[b-1].getTextContent()&&"\n"===c[b-2].getTextContent()&&a.isCollapsed()&&a.anchor.key===this.__key&&a.anchor.offset===b)return c[b-1].remove(),
3
+ c[b-2].remove(),a=d.$createParagraphNode(),this.insertAfter(a),a;c=a.anchor.getNode();var e=k(c);if(null!=e){b=0;for(e=e.getTextContent();b<e.length&&/[\t ]/.test(e[b]);)b+=1;if(0<b)return b=e.substring(0,b),b=f.$createCodeHighlightNode(b),c.insertAfter(b),a.insertNodes([d.$createLineBreakNode()]),b.select(),b}return null}canInsertTab(){return!0}collapseAtStart(){const a=d.$createParagraphNode();this.getChildren().forEach(c=>a.append(c));this.replace(a);return!0}setLanguage(a){this.getWritable().__language=
4
+ a}getLanguage(){return this.getLatest().__language}}function k(a){let c=null;const b=a.getPreviousSiblings();for(b.push(a);0<b.length&&(a=b.pop(),f.$isCodeHighlightNode(a)&&(c=a),!d.$isLineBreakNode(a)););return c}exports.$createCodeNode=function(a){return new h(a)};exports.$isCodeNode=function(a){return a instanceof h};exports.CodeNode=h;exports.getFirstCodeHighlightNodeOfLine=k;
5
+ exports.getLastCodeHighlightNodeOfLine=function(a){let c=null;const b=a.getNextSiblings();for(b.unshift(a);0<b.length&&(a=b.shift(),f.$isCodeHighlightNode(a)&&(c=a),!d.$isLineBreakNode(a)););return c};
package/HeadingNode.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var d=require("lexical"),e=require("lexical/ParagraphNode");function f(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}
2
- class g extends d.ElementNode{static getType(){return"heading"}static clone(a){return new g(a.__tag,a.__key)}constructor(a,b){super(b);this.__tag=a}getTag(){return this.__tag}createDOM(a){const b=this.__tag,c=document.createElement(b);a=a.theme.heading;void 0!==a&&f(c,a[b]);return c}updateDOM(){return!1}insertNewAfter(){const a=e.$createParagraphNode(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=e.$createParagraphNode();this.getChildren().forEach(b=>
3
- a.append(b));this.replace(a);return!0}}exports.$createHeadingNode=function(a){return new g(a)};exports.$isHeadingNode=function(a){return a instanceof g};exports.HeadingNode=g;
1
+ 'use strict';var d=require("lexical");function e(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}
2
+ class f extends d.ElementNode{static getType(){return"heading"}static clone(a){return new f(a.__tag,a.__key)}constructor(a,b){super(b);this.__tag=a}getTag(){return this.__tag}createDOM(a){const b=this.__tag,c=document.createElement(b);a=a.theme.heading;void 0!==a&&e(c,a[b]);return c}updateDOM(){return!1}insertNewAfter(){const a=d.$createParagraphNode(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=d.$createParagraphNode();this.getChildren().forEach(b=>
3
+ a.append(b));this.replace(a);return!0}}exports.$createHeadingNode=function(a){return new f(a)};exports.$isHeadingNode=function(a){return a instanceof f};exports.HeadingNode=f;
package/Lexical.js CHANGED
@@ -1,120 +1,147 @@
1
- 'use strict';const aa=/^[^A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff]*[\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]/,ba=/^[^\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]*[A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff]/,p={bold:1,underline:8,strikethrough:4,italic:2,code:16,subscript:32,superscript:64},ca={left:1,right:3,center:2,justify:4},da={normal:0,token:1,segmented:2,
2
- inert:3};function q(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}let ea=!1,fa=0;function ha(a){fa=a.timeStamp}function ia(a){return a.getEditorState().read(()=>{const b=t();return null!==b?b.clone():null})}
3
- function la(a,b,c){ea=!0;const d=100<performance.now()-fa;try{ma(a,()=>{na("onMutation");var e=!1;for(var f=0;f<b.length;f++){var g=b[f],h=g.type,l=g.target,k=oa(l);if(!v(k))if("characterData"===h){if(d&&3===l.nodeType&&z(k)&&k.isAttached()){h=l;l=k;k=a;g=window.getSelection();var m=null,n=null;null!==g&&g.anchorNode===h&&(m=g.anchorOffset,n=g.focusOffset);A("textmutation",k,!1,{node:l,anchorOffset:m,focusOffset:n,text:h.nodeValue})}}else if("childList"===h){e=!0;h=g.addedNodes;k=g.removedNodes;g=
4
- g.nextSibling;for(m=0;m<k.length;m++){n=k[m];var r=pa(n);let w=g;if(null!==r&&r.isAttached()&&(r=r.getNextSibling(),null!==r)){var u=r.getKey();u=a.getElementByKey(u);null!==u&&null!==u.parentNode?w=u:null===r.getNextSibling()&&(w=null)}if(null!=w)for(;null!=w;){r=w.parentNode;if(r===l){l.insertBefore(n,w);break}w=r}else l.appendChild(n)}for(l=0;l<h.length;l++)k=h[l],g=pa(k),m=k.parentNode,null!=m&&null===g&&m.removeChild(k)}}f=c.takeRecords();if(0<f.length){for(h=0;h<f.length;h++)for(k=f[h],l=k.addedNodes,
5
- k=k.target,g=0;g<l.length;g++)m=l[g],n=m.parentNode,null!=n&&"BR"===m.nodeName&&k.__lexicalLineBreak!==m&&void 0===m.__lexicalInternalRef&&n.removeChild(m);c.takeRecords()}e&&(e=t()||ia(a),null!==e&&(e.dirty=!0,qa(e)))},!0)}finally{ea=!1}}function ra(a){const b=a._observer;if(null!==b){const c=b.takeRecords();la(a,c,b)}}function sa(a){0===fa&&window.addEventListener("textInput",ha,!0);a._observer=new MutationObserver((b,c)=>{la(a,b,c)})}let ta=0;
6
- const ua=window.Promise,va="function"===typeof queueMicrotask?queueMicrotask:a=>ua.resolve().then(a);function wa(a,b,c){a=a.getRootElement();try{return null!==a&&a.contains(b)&&a.contains(c)&&null!=b&&!v(oa(b))}catch(d){return!1}}function Aa(a){for(;null!=a;){if(3===a.nodeType)return a;a=a.firstChild}return null}function Ba(a,b,c){b=p[b];return a&b&&(null===c||0===(c&b))?a^b:null===c||c&b?a|b:a}function Ca(a){return z(a)||Da(a)||v(a)}
7
- function Ea(a){99<Fa&&q(26);var b=a.getLatest(),c=b.__parent,d=C();const e=D(),f=d._nodeMap;d=e._dirtyElements;if(null!==c)a:for(;null!==c;){if(d.has(c))break a;const g=f.get(c);if(void 0===g)break;d.set(c,!1);c=g.__parent}b=b.__key;e._dirtyType=1;E(a)?d.set(b,!0):e._dirtyLeaves.add(b)}function F(a){const b=a.getPreviousSibling();a=a.getNextSibling();null!==b&&Ea(b);null!==a&&Ea(a)}
8
- function G(a){H();var b=D();const c=b._compositionKey;b._compositionKey=a;null!==c&&(b=I(c),null!==b&&b.getWritable());null!==a&&(a=I(a),null!==a&&a.getWritable())}function J(){return D()._compositionKey}function I(a){a=C()._nodeMap.get(a);return void 0===a?null:a}function pa(a){const b=D();a=a["__lexicalKey_"+b._key];return void 0!==a?I(a):null}function oa(a){for(;null!=a;){const b=pa(a);if(null!==b)return b;a=a.parentNode}return null}
9
- function Ga(a){const b=Object.assign({},a._decorators);return a._pendingDecorators=b}function na(a){D()._log.push(a)}function Ha(a){return a.read(()=>Ia().getTextContent())}function Ja(a,b){ma(a,()=>{var c=C();if(!c.isEmpty())if("root"===b)Ia().markDirty();else{c=Array.from(c._nodeMap);for(let d=0;d<c.length;d++)c[d][1].markDirty()}},!0,null===a._pendingEditorState?{tag:"without-history"}:void 0)}function Ia(){return C()._nodeMap.get("root")}function qa(a){C()._selection=a}
10
- function Ka(a){var b=D(),c;a:{for(c=a;null!=c;){const d=c["__lexicalKey_"+b._key];if(void 0!==d){c=d;break a}c=c.parentNode}c=null}return null===c?(b=b.getRootElement(),a===b?I("root"):null):I(c)}function La(a){const b=[];for(;null!==a;)b.push(a),a=a._parentEditor;return b}function K(a){return a.isToken()||a.isInert()}
11
- class Ma{constructor(a,b,c){this.key=a;this.offset=b;this.type=c}is(a){return this.key===a.key&&this.offset===a.offset&&this.type===a.type}isBefore(a){let b=this.getNode(),c=a.getNode();const d=this.offset;a=a.offset;E(b)&&(b=b.getDescendantByIndex(d));E(c)&&(c=c.getDescendantByIndex(a));return b===c?d<a:b.isBefore(c)}getCharacterOffset(){return"text"===this.type?this.offset:0}getNode(){const a=I(this.key);null===a&&q(5);return a}set(a,b,c){const d=t(),e=this.key;this.key=a;this.offset=b;this.type=
12
- c;N||(J()===e&&G(a),null===d||d.anchor!==this&&d.focus!==this||(d.dirty=!0))}}function O(a,b,c){return new Ma(a,b,c)}function Na(a,b){const c=b.getKey();let d=a.offset,e="element";z(b)&&(e="text",b=b.getTextContentSize(),d>b&&(d=b));a.set(c,d,e)}function Oa(a,b){if(E(b)){const c=b.getLastDescendant();E(c)||z(c)?Na(a,c):Na(a,b)}else z(b)&&Na(a,b)}
13
- function Pa(a,b,c){b=a.getNode();const d=b.getChildAtIndex(a.offset),e=P();e.setFormat(c);null===d?b.append(e):d.insertBefore(e);a.set(e.getKey(),0,"text")}function Q(a,b,c,d){a.key=b;a.offset=c;a.type=d}
14
- class Qa{constructor(a,b,c){this.anchor=a;this.focus=b;this.dirty=!1;this.format=c}is(a){return null===a?!1:this.anchor.is(a.anchor)&&this.focus.is(a.focus)}isBackward(){return this.focus.isBefore(this.anchor)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const a=this.anchor,b=this.focus;let c=a.getNode(),d=b.getNode();E(c)&&(c=c.getDescendantByIndex(a.offset));E(d)&&(d=d.getDescendantByIndex(b.offset));return c.is(d)?E(c)?[]:[c]:c.getNodesBetween(d)}setTextNodeRange(a,b,c,d){Q(this.anchor,
15
- a.__key,b,"text");Q(this.focus,c.__key,d,"text");this.dirty=!0}getTextContent(){const a=this.getNodes();if(0===a.length)return"";const b=a[0],c=a[a.length-1];var d=this.anchor,e=this.focus;const f=d.isBefore(e);d=d.getCharacterOffset();e=e.getCharacterOffset();let g="",h=!0;for(let l=0;l<a.length;l++){const k=a[l];if(E(k))h||(g+="\n"),h=k.isEmpty()?!1:!0;else if(h=!1,z(k)){let m=k.getTextContent();k===b?m=k===c?d<e?m.slice(d,e):m.slice(e,d):f?m.slice(d):m.slice(e):k===c&&(m=f?m.slice(0,e):m.slice(0,
16
- d));g+=m}else!v(k)&&!Da(k)||k===c&&this.isCollapsed()||(g+=k.getTextContent())}return g}applyDOMRange(a){const b=D();a=Ra(a.startContainer,a.startOffset,a.endContainer,a.endOffset,b);if(null!==a){var [c,d]=a;Q(this.anchor,c.key,c.offset,c.type);Q(this.focus,d.key,d.offset,d.type)}}clone(){const a=this.anchor,b=this.focus;return new Qa(O(a.key,a.offset,a.type),O(b.key,b.offset,b.type),this.format)}toggleFormatType(a){this.format=Ba(this.format,a,null);this.dirty=!0}hasFormat(a){return 0!==(this.format&
17
- p[a])}insertText(a){var b=this.anchor,c=this.focus,d=this.isCollapsed()||b.isBefore(c),e=this.format;d&&"element"===b.type?Pa(b,c,e):d||"element"!==c.type||Pa(c,b,e);var f=this.getNodes(),g=f.length,h=d?c:b;b=(d?b:c).offset;var l=h.offset;c=f[0];z(c)||q(6);d=c.getTextContent().length;var k=c.getParentOrThrow();if(!this.isCollapsed()||b!==d||!c.isSegmented()&&!c.isToken()&&c.canInsertTextAfter()&&k.canInsertTextAfter())if(!this.isCollapsed()||0!==b||!c.isSegmented()&&!c.isToken()&&c.canInsertTextBefore()&&
18
- k.canInsertTextBefore())c.isSegmented()&&b!==d&&(k=P(c.getTextContent()),c.replace(k),c=k);else{m=c.getPreviousSibling();if(!z(m)||K(m)||m.isSegmented())m=P(),k.canInsertTextBefore()?c.insertBefore(m):k.insertBefore(m);m.select();c=m;if(""!==a){this.insertText(a);return}}else{var m=c.getNextSibling();if(!z(m)||K(m)||m.isSegmented())m=P(),k.canInsertTextAfter()?c.insertAfter(m):k.insertAfter(m);m.select(0,0);c=m;if(""!==a){this.insertText(a);return}}if(1===g)if(K(c))c.remove();else{f=c.getFormat();
19
- if(b===l&&f!==e)if(""===c.getTextContent())c.setFormat(e);else{f=P(a);f.setFormat(e);f.select();0===b?c.insertBefore(f):([g]=c.splitText(b),g.insertAfter(f));return}c=c.spliceText(b,l-b,a,!0);""===c.getTextContent()?c.remove():c.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=a.length)}else{k=f[g-1];e=new Set([...c.getParentKeys(),...k.getParentKeys()]);var n=E(c)?c:c.getParentOrThrow();m=E(k)?k:k.getParentOrThrow();"text"===h.type&&(0!==l||""===k.getTextContent())||"element"===h.type&&
20
- k.getIndexWithinParent()<l?z(k)&&!K(k)&&l!==k.getTextContentSize()?(k.isSegmented()&&(h=P(k.getTextContent()),k.replace(h),k=h),k=k.spliceText(0,l,""),e.add(k.getKey())):k.remove():e.add(k.getKey());h=m.getChildren();l=new Set(f);const r=n.is(m);if(m.canBeEmpty()){for(n=h.length-1;0<=n;n--){const u=h[n];if(u.is(c)||E(u)&&u.isParentOf(c))break;u.isAttached()&&(!l.has(u)||u.is(k)?r||c.insertAfter(u):u.remove())}if(!r)for(h=m,l=null;null!==h;){k=h.getChildren();m=k.length;if(0===m||k[m-1].is(l))e.delete(h.getKey()),
21
- l=h;h=h.getParent()}}else n.append(m);K(c)?b===d?c.select():c.remove():(c=c.spliceText(b,d-b,a,!0),""===c.getTextContent()?c.remove():c.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=a.length));for(a=1;a<g;a++)b=f[a],c=b.getKey(),e.has(c)||E(b)&&!b.canSelectionRemove()||b.remove()}}removeText(){this.insertText("")}formatText(a){const b=this.getNodes(),c=b.length-1;let d=b[0],e=b[c];if(this.isCollapsed())this.toggleFormatType(a);else{var f=this.anchor,g=this.focus,h=d.getTextContent().length,
22
- l=g.offset,k=0;for(var m=0;m<b.length;m++){var n=b[m];if(z(n)){k=n.getFormatFlags(a,null);break}}var r=f.offset;n=(m=f.isBefore(g))?r:l;m=m?l:r;if(n===d.getTextContentSize()){const u=d.getNextSibling();z(u)&&(n=r=0,d=u,k=d.getFormatFlags(a,null))}if(d.is(e))z(d)&&("element"===f.type&&"element"===g.type?(d.setFormat(k),d.select(n,m),this.format=k):(n=r>l?l:r,m=r>l?r:l,n!==m&&(0===n&&m===h?(d.setFormat(k),d.select(n,m)):(a=d.splitText(n,m),a=0===n?a[0]:a[1],a.setFormat(k),a.select(0,m-n)),this.format=
23
- k)));else for(z(d)&&(0!==n&&([,d]=d.splitText(n)),d.setFormat(k)),f=k,z(e)&&(f=e.getFormatFlags(a,k),k=e.getTextContent().length,0!==m&&(m!==k&&([e]=e.splitText(m)),e.setFormat(f))),k=1;k<c;k++)m=b[k],g=m.getKey(),z(m)&&g!==d.getKey()&&g!==e.getKey()&&!m.isToken()&&(g=m.getFormatFlags(a,f),m.setFormat(g))}}insertNodes(a,b){this.isCollapsed()||this.removeText();var c=this.anchor,d=c.offset,e=c.getNode(),f=e;"element"===c.type&&(f=c.getNode(),c=f.getChildAtIndex(d-1),f=null===c?f:c);c=[];var g=e.getNextSiblings(),
24
- h=e.getTopLevelElementOrThrow();if(z(e))if(f=e.getTextContent().length,0===d&&0!==f)f=e.getPreviousSibling(),f=null!==f?f:e.getParentOrThrow(),c.push(e);else if(d===f)f=e;else{if(K(e))return!1;[f,e]=e.splitText(d);c.push(e)}e=f;c.push(...g);d=a[0];var l=!1;for(g=0;g<a.length;g++){const n=a[g];if(E(n)){if(n.is(d)){if(E(f)&&f.isEmpty()&&f.canReplaceWith(n)){f.replace(n);f=n;l=!0;continue}var k=n.getFirstDescendant();if(Ca(k)){k=k.getParentOrThrow();l=k.getChildren();var m=l.length;if(E(f))for(let r=
25
- 0;r<m;r++)f.append(l[r]);else{for(--m;0<=m;m--)f.insertAfter(l[m]);f=f.getParentOrThrow()}k.remove();l=!0;if(k.is(n))continue}}z(f)&&(f=h)}else l&&R(f.getParent())&&q(7);l=!1;if(E(f))if(E(n)){if(n.canBeEmpty()||!n.isEmpty())f=f.insertAfter(n)}else k=f.getFirstChild(),null!==k?k.insertBefore(n):f.append(n),f=n;else E(n)?(f=n.getParentOrThrow(),g--):f=f.insertAfter(n)}b&&(z(e)?e.select():(a=f.getPreviousSibling(),z(a)?a.select():(a=f.getIndexWithinParent(),f.getParentOrThrow().select(a,a))));if(E(f)){if(a=
26
- f.getLastDescendant(),b||(null===a?f.select():z(a)?a.select():a.selectNext()),0!==c.length)for(b=c.length-1;0<=b;b--)a=c[b],h=a.getParentOrThrow(),E(f)&&!E(a)?(f.append(a),f=a):E(a)&&!a.canInsertAfter(f)?(e=h.constructor.clone(h),E(e)||q(8),e.append(a),f.insertAfter(e)):f.insertAfter(a),h.isEmpty()&&!h.canBeEmpty()&&h.remove()}else b||(z(f)?f.select():(c=f.getParentOrThrow(),f=f.getIndexWithinParent()+1,c.select(f,f)));return!0}insertParagraph(){this.isCollapsed()||this.removeText();var a=this.anchor,
27
- b=a.offset;if("text"===a.type){var c=a.getNode(),d=c.getTextContent().length;a=c.getNextSiblings().reverse();var e=c.getParentOrThrow();0===b?a.push(c):b!==d&&([,b]=c.splitText(b),a.push(b))}else e=a.getNode(),a=e.getChildren().slice(b).reverse();b=e.insertNewAfter(this);if(null===b)this.insertLineBreak();else if(E(b)){e=a.length;c=null;if(0!==e)for(d=0;d<e;d++){const f=a[d];null===c?b.append(f):c.insertBefore(f);c=f}b.canBeEmpty()||0!==b.getChildrenSize()?b.selectStart():(b.selectPrevious(),b.remove())}}insertLineBreak(a){const b=
28
- Sa();a?this.insertNodes([b],!0):this.insertNodes([b])&&b.selectNext(0,0)}extract(){var a=this.getNodes(),b=a.length,c=b-1,d=this.anchor;const e=this.focus;var f=a[0];let g=a[c];var h=d.getCharacterOffset();const l=e.getCharacterOffset();if(0===b)return[];if(1===b)return z(f)?(a=h>l?l:h,c=f.splitText(a,h>l?h:l),a=0===a?c[0]:c[1],null!=a?[a]:[]):[f];b=d.isBefore(e);z(f)&&(d=b?h:l,d===f.getTextContentSize()?a.shift():0!==d&&([,f]=f.splitText(d),a[0]=f));z(g)&&(f=g.getTextContent().length,h=b?l:h,0===
29
- h?a.pop():h!==f&&([g]=g.splitText(h),a[c]=g));return a}modify(a,b,c){var d=this.focus,e=this.anchor,f="move"===a;var g=d.offset;if("element"===d.type)g=d.getNode().getChildAtIndex(b?g-1:g);else{var h=d.getNode();g=b&&0===g||!b&&g===h.getTextContentSize()?b?h.getPreviousSibling():h.getNextSibling():null}if(v(g)&&(h=b?g.getPreviousSibling():g.getNextSibling(),!z(h))){a=g.getParentOrThrow().getKey();c=g.getIndexWithinParent();b||c++;d.set(a,c,"element");f&&e.set(a,c,"element");return}d=window.getSelection();
30
- d.modify(a,b?"backward":"forward",c);0<d.rangeCount&&(b=d.getRangeAt(0),this.applyDOMRange(b),f||d.anchorNode===b.startContainer&&d.anchorOffset===b.startOffset||(f=this.focus,b=this.anchor,d=b.key,e=b.offset,a=b.type,Q(b,f.key,f.offset,f.type),Q(f,d,e,a)))}deleteCharacter(a){if(this.isCollapsed()){var b=this.anchor,c=this.focus,d=b.getNode();if(E(d)&&!d.canSelectionRemove()||!a&&("element"===b.type&&b.offset===d.getChildrenSize()||"text"===b.type&&b.offset===d.getTextContentSize())&&(d=d.getNextSibling()||
31
- d.getParentOrThrow().getNextSibling(),E(d)&&!d.canExtractContents()))return;this.modify("extend",a,"character");if(!this.isCollapsed()){var e="text"===c.type?c.getNode():null;d="text"===b.type?b.getNode():null;if(null!==e&&e.isSegmented()){if(b=c.offset,c=e.getTextContentSize(),e.is(d)||a&&b!==c||!a&&0!==b){Ta(e,a);return}}else if(null!==d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(e)||a&&0!==b||!a&&b!==c)){Ta(d,a);return}d=this.anchor;e=this.focus;b=d.getNode();c=e.getNode();if(b===
32
- c&&"text"===d.type&&"text"===e.type){var f=d.offset,g=e.offset;const h=f<g;c=h?f:g;g=h?g:f;f=g-1;c!==f&&(b=b.getTextContent().slice(c,g),/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(b)||(a?e.offset=f:d.offset=f))}}else if(a&&0===b.offset&&("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).collapseAtStart(this))return}this.removeText();a=this.anchor;"text"===a.type&&(a=a.getNode(),d=a.getTextContent(),e=this.anchor.offset,0===e&&a.isSimpleText()?(e=a.getPreviousSibling(),z(e)&&"hashtag"===e.getType()&&
33
- (e.select(),b=e.getTextContent(),e.setTextContent(b+d),a.remove())):z(a)&&"hashtag"===a.getType()&&e===a.getTextContentSize()&&(e=a.getNextSibling(),z(e)&&e.isSimpleText()&&(b=e.getTextContent(),a.setTextContent(d+b),e.remove())))}deleteLine(a){this.isCollapsed()&&this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");this.removeText()}}
34
- function Ta(a,b){var c=a.getTextContent().split(/\s/g);b?c.pop():c.shift();c=c.join(" ");""===c?a.remove():(a=a.setTextContent(c),b?a.select():a.select(0,0))}
35
- function Ua(a,b){if(1===a.nodeType){let e=!1;var c=a.childNodes;var d=c.length;b===d&&(e=!0,b=d-1);c=Ka(c[b]);if(z(c))b=e?c.getTextContentSize():0;else{d=Ka(a);if(null===d)return null;E(d)?(a=d.getChildAtIndex(b),E(a)&&(d=e?a.getLastDescendant():a.getFirstDescendant(),null===d?(d=a,b=0):(a=d,d=a.getParentOrThrow())),z(a)?(c=a,d=null,b=e?c.getTextContentSize():0):a!==d&&e&&b++):(b=d.getIndexWithinParent()+1,d=d.getParentOrThrow());if(R(d))return null;if(E(d))return O(d.__key,b,"element")}}else c=Ka(a);
36
- return z(c)?O(c.__key,b,"text"):null}
37
- function Ra(a,b,c,d,e){if(null===a||null===c||!wa(e,a,c))return null;a=Ua(a,b);if(null===a)return null;c=Ua(c,d);if(null===c)return null;if("text"===a.type&&"text"===c.type){d=a.getNode();const f=c.getNode(),g=d.getTextContentSize(),h=a.offset,l=c.offset;d===f&&h===l?0===b&&(d=d.getPreviousSibling(),z(d)&&!d.isInert()&&(b=d.getTextContentSize(),d=d.__key,a.key=d,c.key=d,a.offset=b,c.offset=b)):h===g&&(b=d.getNextSibling(),z(b)&&!b.isInert()&&(a.key=b.__key,a.offset=0));b=e.getEditorState()._selection;
38
- e.isComposing()&&e._compositionKey!==a.key&&null!==b&&(e=b.anchor,b=b.focus,Q(a,e.key,e.offset,e.type),Q(c,b.key,b.offset,b.type))}return[a,c]}function Va(a,b,c,d,e,f){const g=C();a=new Qa(O(a,b,e),O(c,d,f),0);a.dirty=!0;return g._selection=a}
39
- function Wa(a){const b=a.getEditorState()._selection;var c=(c=window.event)&&c.type;c=!ea&&("selectionchange"===c||"beforeinput"===c||"compositionstart"===c||"compositionend"===c||"click"===c&&3===window.event.detail||void 0===c);let d,e;if(null===b||c){var f=window.getSelection();if(null===f)return null;c=f.anchorNode;d=f.focusNode;e=f.anchorOffset;f=f.focusOffset}else return a=b.anchor,c=b.focus,new Qa(O(a.key,a.offset,a.type),O(c.key,c.offset,c.type),b.format);a=Ra(c,e,d,f,a);if(null===a)return null;
40
- const [g,h]=a;return new Qa(g,h,null===b?0:b.format)}function t(){return C()._selection}
41
- function Xa(a,b,c,d=1){var e=a.anchor,f=a.focus,g=e.getNode(),h=f.getNode();if(b.is(g)||b.is(h))if(g=b.getKey(),a.isCollapsed())b=e.offset,c<=b&&(c=Math.max(0,b+d),e.set(g,c,"element"),f.set(g,c,"element"),Ya(a));else{var l=a.isBackward();h=l?f:e;var k=h.getNode();e=l?e:f;f=e.getNode();b.is(k)&&(k=h.offset,c<=k&&h.set(g,Math.max(0,k+d),"element"));b.is(f)&&(b=e.offset,c<=b&&e.set(g,Math.max(0,b+d),"element"));Ya(a)}}
42
- function Ya(a){var b=a.anchor,c=b.offset;const d=a.focus;var e=d.offset,f=b.getNode(),g=d.getNode();if(a.isCollapsed())E(f)&&(g=f.getChildrenSize(),g=(e=c>=g)?f.getChildAtIndex(g-1):f.getChildAtIndex(c),z(g)&&(c=0,e&&(c=g.getTextContentSize()),b.set(g.getKey(),c,"text"),d.set(g.getKey(),c,"text")));else{if(E(f)){const h=f.getChildrenSize();c=(a=c>=h)?f.getChildAtIndex(h-1):f.getChildAtIndex(c);z(c)&&(f=0,a&&(f=c.getTextContentSize()),b.set(c.getKey(),f,"text"))}E(g)&&(c=g.getChildrenSize(),e=(b=e>=
43
- c)?g.getChildAtIndex(c-1):g.getChildAtIndex(e),z(e)&&(g=0,b&&(g=e.getTextContentSize()),d.set(e.getKey(),g,"text")))}}function Za(a,b){b=b.getEditorState()._selection;a=a._selection;if(null!==a){var c=a.anchor;const d=a.focus;let e;"text"===c.type&&(e=c.getNode(),e.selectionTransform(b,a));"text"===d.type&&(c=d.getNode(),e!==c&&c.selectionTransform(b,a))}}
44
- function $a(a,b,c){let d=null,e=0,f=null;var g=b.getPreviousSibling();null!==g?(d=g.__key,z(g)?(e=g.getTextContentSize(),f="text"):E(g)&&(e=1,f="element")):(g=b.getNextSibling(),null!==g&&(d=g.__key,z(g)?f="text":E(g)&&(f="element")));null!==d&&null!==f?a.set(d,e,f):(e=b.getIndexWithinParent(),a.set(c.__key,e,"element"))}function ab(a,b,c,d,e){"text"===a.type?(a.key=c,b||(a.offset+=e)):a.offset>d.getIndexWithinParent()&&--a.offset}
45
- function bb(a,b){H();var c=a.__key;const d=a.getParent();if(null!==d){var e=t(),f=!1;if(null!==e&&b){var g=e.anchor;const h=e.focus;g.key===c&&($a(g,a,d),f=!0);h.key===c&&($a(h,a,d),f=!0)}g=d.getWritable().__children;c=g.indexOf(c);-1===c&&q(16);F(a);g.splice(c,1);a.getWritable().__parent=null;null!==e&&b&&!f&&Xa(e,d,c,-1);null===d||R(d)||d.canBeEmpty()||0!==d.getChildrenSize()||bb(d,b)}}
46
- class cb{static getType(){q(31,this.name)}static clone(){q(32,this.name)}constructor(a){this.__type=this.constructor.getType();if(!a){H();99<Fa&&q(26);a=D();const b=C(),c=""+ta++;b._nodeMap.set(c,this);E(this)?a._dirtyElements.set(c,!0):a._dirtyLeaves.add(c);a._cloneNotNeeded.add(c);a._dirtyType=1;a=c}this.__key=a;this.__parent=null}getType(){return this.__type}isAttached(){for(var a=this.__key;null!==a;){if("root"===a)return!0;a=I(a);if(null===a)break;a=a.__parent}return!1}isSelected(){const a=t();
47
- if(null==a)return!1;const b=(new Set(a.getNodes().map(c=>c.__key))).has(this.__key);return z(this)?b:"element"===a.anchor.type&&"element"===a.focus.type&&a.anchor.key===a.focus.key&&a.anchor.offset===a.focus.offset?!1:b}getKey(){return this.__key}getIndexWithinParent(){const a=this.getParent();return null===a?-1:a.__children.indexOf(this.__key)}getParent(){const a=this.getLatest().__parent;return null===a?null:I(a)}getParentOrThrow(){const a=this.getParent();null===a&&q(33,this.__key);return a}getTopLevelElement(){let a=
48
- this;for(;null!==a;){const b=a.getParent();if(R(b)&&E(a))return a;a=b}return null}getTopLevelElementOrThrow(){const a=this.getTopLevelElement();null===a&&q(34,this.__key);return a}getParents(){const a=[];let b=this.getParent();for(;null!==b;)a.push(b),b=b.getParent();return a}getParentKeys(){const a=[];let b=this.getParent();for(;null!==b;)a.push(b.__key),b=b.getParent();return a}getPreviousSibling(){var a=this.getParent();if(null===a)return null;a=a.__children;const b=a.indexOf(this.__key);return 0>=
49
- b?null:I(a[b-1])}getPreviousSiblings(){var a=this.getParent();if(null===a)return[];a=a.__children;const b=a.indexOf(this.__key);return a.slice(0,b).map(c=>db(c))}getNextSibling(){var a=this.getParent();if(null===a)return null;a=a.__children;const b=a.length,c=a.indexOf(this.__key);return c>=b-1?null:I(a[c+1])}getNextSiblings(){var a=this.getParent();if(null===a)return[];a=a.__children;const b=a.indexOf(this.__key);return a.slice(b+1).map(c=>db(c))}getCommonAncestor(a){const b=this.getParents();var c=
50
- a.getParents();E(this)&&b.unshift(this);E(a)&&c.unshift(a);a=b.length;var d=c.length;if(0===a||0===d||b[a-1]!==c[d-1])return null;c=new Set(c);for(d=0;d<a;d++){const e=b[d];if(c.has(e))return e}return null}is(a){return null==a?!1:this.getKey()===a.getKey()}isBefore(a){if(a.isParentOf(this))return!0;if(this.isParentOf(a))return!1;var b=this.getCommonAncestor(a);let c=this;for(;;){var d=c.getParentOrThrow();if(d===b){d=d.__children.indexOf(c.__key);break}c=d}for(c=a;;){a=c.getParentOrThrow();if(a===
51
- b){b=a.__children.indexOf(c.__key);break}c=a}return d<b}isParentOf(a){const b=this.__key;if(b===a.__key)return!1;for(;null!==a;){if(a.__key===b)return!0;a=a.getParent()}return!1}getNodesBetween(a){const b=this.isBefore(a),c=[],d=new Set;var e=this;let f=null;for(;;){var g=e.__key;d.has(g)||(d.add(g),c.push(e));if(e===a)break;g=E(e)?b?e.getFirstChild():e.getLastChild():null;if(null!==g)null===f&&(f=e),e=g;else if(g=b?e.getNextSibling():e.getPreviousSibling(),null!==g)e=g;else{g=e.getParentOrThrow();
52
- d.has(g.__key)||c.push(g);if(g===a)break;e=g;g.is(f)&&(f=null);do null===e&&q(35),g=b?e.getNextSibling():e.getPreviousSibling(),e=e.getParent(),null!==e&&(e.is(f)&&(f=null),null!==g||d.has(e.__key)||c.push(e));while(null===g);e=g}}b||c.reverse();return c}isDirty(){const a=D()._dirtyLeaves;return null!==a&&a.has(this.__key)}isComposing(){return this.__key===J()}getLatest(){const a=I(this.__key);null===a&&q(36);return a}getWritable(){H();var a=C(),b=D();a=a._nodeMap;const c=this.__key,d=this.getLatest(),
53
- e=d.__parent;b=b._cloneNotNeeded;if(b.has(c))return Ea(d),d;const f=d.constructor.clone(d);f.__parent=e;E(d)&&E(f)?(f.__children=Array.from(d.__children),f.__indent=d.__indent,f.__format=d.__format,f.__dir=d.__dir):z(d)&&z(f)?(f.__format=d.__format,f.__style=d.__style,f.__mode=d.__mode,f.__detail=d.__detail):v(d)&&v(f)&&(f.__state=d.__state);b.add(c);f.__key=c;Ea(f);a.set(c,f);return f}getTextContent(){return""}getTextContentSize(a,b){return this.getTextContent(a,b).length}createDOM(){q(37)}updateDOM(){q(38)}remove(){H();
54
- bb(this,!0)}replace(a){H();const b=this.__key;a=a.getWritable();var c=a.getParent();if(null!==c){c=c.getWritable().__children;var d=c.indexOf(a.__key);-1===d&&q(16);F(a);c.splice(d,1)}d=this.getParentOrThrow();var e=d.getWritable().__children;const f=e.indexOf(this.__key);c=a.__key;-1===f&&q(16);e.splice(f,0,c);a.__parent=d.__key;bb(this,!1);F(a);e=t();null!==e&&(d=e.anchor,e=e.focus,d.key===b&&Oa(d,a),e.key===b&&Oa(e,a));J()===b&&G(c);return a}insertAfter(a){H();var b=this.getWritable(),c=a.getWritable(),
55
- d=c.getParent();const e=t();var f=!1,g=!1;if(null!==d){var h=d.getWritable().__children,l=h.indexOf(c.__key);-1===l&&q(16);F(c);if(null!==e){g=d.getKey();d=a.getIndexWithinParent();f=e.anchor;const k=e.focus;f="element"===f.type&&f.key===g&&f.offset===d+1;g="element"===k.type&&k.key===g&&k.offset===d+1}h.splice(l,1)}h=this.getParentOrThrow().getWritable();l=c.__key;c.__parent=b.__parent;d=h.__children;b=d.indexOf(b.__key);-1===b&&q(16);d.splice(b+1,0,l);F(c);null!==e&&(Xa(e,h,b+1),c=h.getKey(),f&&
56
- e.anchor.set(c,b+2,"element"),g&&e.focus.set(c,b+2,"element"));return a}insertBefore(a){H();var b=this.getWritable(),c=a.getWritable(),d=c.getParent();if(null!==d){d=d.getWritable().__children;var e=d.indexOf(c.__key);-1===e&&q(16);F(c);d.splice(e,1)}d=this.getParentOrThrow().getWritable();e=c.__key;c.__parent=b.__parent;const f=d.__children;b=f.indexOf(b.__key);-1===b&&q(16);f.splice(b,0,e);F(c);c=t();null!==c&&Xa(c,d,b);return a}selectPrevious(a,b){H();const c=this.getPreviousSibling(),d=this.getParentOrThrow();
57
- return null===c?d.select(0,0):E(c)?c.select():z(c)?c.select(a,b):(a=c.getIndexWithinParent()+1,d.select(a,a))}selectNext(a,b){H();const c=this.getNextSibling(),d=this.getParentOrThrow();return null===c?d.select():E(c)?c.select(0,0):z(c)?c.select(a,b):(a=c.getIndexWithinParent(),d.select(a,a))}markDirty(){this.getWritable()}}function db(a){const b=I(a);null===b&&q(39,a);return b}
58
- class eb extends cb{constructor(a){super(a);this.__children=[];this.__indent=this.__format=0;this.__dir=null}getFormat(){return this.getLatest().__format}getIndent(){return this.getLatest().__indent}getChildren(){const a=this.getLatest().__children,b=[];for(let c=0;c<a.length;c++){const d=I(a[c]);null!==d&&b.push(d)}return b}getChildrenKeys(){return this.getLatest().__children}getChildrenSize(){return this.getLatest().__children.length}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const a=
59
- D()._dirtyElements;return null!==a&&a.has(this.__key)}getAllTextNodes(a){const b=[],c=this.getLatest().__children;for(let e=0;e<c.length;e++){var d=I(c[e]);!z(d)||!a&&d.isInert()?E(d)&&(d=d.getAllTextNodes(a),b.push(...d)):b.push(d)}return b}getFirstDescendant(){let a=this.getFirstChild();for(;null!==a;){if(E(a)){const b=a.getFirstChild();if(null!==b){a=b;continue}}break}return a}getLastDescendant(){let a=this.getLastChild();for(;null!==a;){if(E(a)){const b=a.getLastChild();if(null!==b){a=b;continue}}break}return a}getDescendantByIndex(a){const b=
60
- this.getChildren(),c=b.length;if(0===c)return this;if(a>=c)return a=b[c-1],E(a)&&a.getLastDescendant()||a;a=b[a];return E(a)&&a.getFirstDescendant()||a}getFirstChild(){const a=this.getLatest().__children;return 0===a.length?null:I(a[0])}getFirstChildOrThrow(){const a=this.getFirstChild();null===a&&q(15,this.__key);return a}getLastChild(){const a=this.getLatest().__children,b=a.length;return 0===b?null:I(a[b-1])}getChildAtIndex(a){a=this.getLatest().__children[a];return void 0===a?null:I(a)}getTextContent(a,
61
- b){let c="";const d=this.getChildren(),e=d.length;for(let f=0;f<e;f++){const g=d[f];c+=g.getTextContent(a,b);E(g)&&f!==e-1&&(c+="\n\n")}return c}getDirection(){return this.__dir}hasFormat(a){a=ca[a];return 0!==(this.getFormat()&a)}select(a,b){H();const c=t();var d=this.getChildrenSize();void 0===a&&(a=d);void 0===b&&(b=d);d=this.__key;if(null===c)return Va(d,a,d,b,"element","element");c.anchor.set(d,a,"element");c.focus.set(d,b,"element");c.dirty=!0;return c}selectStart(){const a=this.getFirstDescendant();
62
- return E(a)||z(a)?a.select(0,0):null!==a?a.selectPrevious():this.select(0,0)}selectEnd(){const a=this.getLastDescendant();return E(a)||z(a)?a.select():null!==a?a.selectNext():this.select()}clear(){H();const a=this.getWritable();this.getChildren().forEach(b=>b.remove());return a}append(...a){H();const b=this.getWritable(),c=b.__key,d=b.__children,e=a.length;var f=this.getLastChild();null!==f&&Ea(f);for(f=0;f<e;f++){const h=a[f].getWritable();var g=h.getParent();if(null!==g){g=g.getWritable().__children;
63
- const l=g.indexOf(h.__key);-1===l&&q(16);g.splice(l,1)}h.__parent=c;d.push(h.__key)}return b}setDirection(a){H();const b=this.getWritable();b.__dir=a;return b}setFormat(a){H();this.getWritable().__format=ca[a];return this}setIndent(a){H();this.getWritable().__indent=a;return this}insertNewAfter(){return null}canInsertTab(){return!1}collapseAtStart(){return!1}excludeFromCopy(){return!1}canExtractContents(){return!0}canReplaceWith(){return!0}canInsertAfter(){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}canSelectionRemove(){return!0}canMergeWith(){return!1}}
64
- function E(a){return a instanceof eb}
65
- class fb{constructor(a,b){this.id=a||Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5);this.editorState=b||null;this.editor=null}init(a){let b=this.editorState;"string"===typeof b&&(this.editorState=b=a.parseEditorState(b),null!==b&&a.setEditorState(b,{tag:"without-history"}))}set(a){this.editor=a;this.editorState=a.getEditorState()}toJSON(){const a=this.editorState;return{id:this.id,type:"editor",editorState:null===a||"string"===typeof a?a:JSON.stringify(a.toJSON())}}isEmpty(){return null===this.editorState}}
66
- function gb(a,b){return new fb(a,b)}class hb{constructor(a,b){this._editor=a;this._map=b||new Map}get(a){return this._map.get(a)}has(a){return this._map.has(a)}set(a,b){this._map.set(a,b);A("decoratorstate",this._editor,!1,this,a)}toJSON(){return{type:"map",map:Array.from(this._map.entries())}}}function ib(a,b){return new hb(a,b)}class jb extends cb{constructor(a,b){super(b);b=D();this.__state=a||ib(b)}decorate(){q(4)}}function v(a){return a instanceof jb}
67
- class kb extends eb{static getType(){return"root"}static clone(){return new kb}constructor(){super("root");this.__cachedText=null}getTextContent(a,b){const c=this.__cachedText;return!N&&0!==D()._dirtyType||null===c||a&&!1===b?super.getTextContent(a,b):c}select(){q(9)}remove(){q(10)}replace(){q(11)}insertBefore(){q(12)}insertAfter(){q(13)}updateDOM(){return!1}append(...a){for(let b=0;b<a.length;b++){const c=a[b];E(c)||v(c)||q(46)}return super.append(...a)}canBeEmpty(){return!1}}
68
- function R(a){return a instanceof kb}function lb(a,b){b=b.getEditorState()._selection;a=a._selection;if(null!==a){if(a.dirty||!a.is(b))return!0}else if(null!==b)return!0;return!1}function mb(){return new nb(new Map([["root",new kb]]))}
69
- class nb{constructor(a,b){this._nodeMap=a;this._selection=b||null;this._readOnly=this._flushSync=!1}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(a){a:{const c=S,d=N,e=T;S=this;N=!0;T=null;try{var b=a();break a}finally{S=c,N=d,T=e}b=void 0}return b}clone(a){a=new nb(this._nodeMap,void 0===a?this._selection:a);a._readOnly=!0;return a}toJSON(){const a=this._selection;return{_nodeMap:Array.from(this._nodeMap.entries()),_selection:null===a?null:{anchor:{key:a.anchor.key,offset:a.anchor.offset,
70
- type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type}}}}}let U="",V="",X="",ob,Y,pb=!1,qb=!1,rb=null,sb,tb,ub,vb,wb;function xb(a,b){const c=ub.get(a);if(null!==b){const d=yb(a);b.removeChild(d)}vb.has(a)||Y._keyToDOMMap.delete(a);E(c)&&(a=c.__children,zb(a,0,a.length-1,null))}function zb(a,b,c,d){for(;b<=c;++b){const e=a[b];void 0!==e&&xb(e,d)}}function Ab(a,b){a.setProperty("text-align",b)}
71
- function Bb(a,b){a.style.setProperty("padding-inline-start",0===b?"":40*b+"px")}function Cb(a,b){a=a.style;0===b?Ab(a,""):1===b?Ab(a,"left"):2===b?Ab(a,"center"):3===b?Ab(a,"right"):4===b&&Ab(a,"justify")}
72
- function Db(a,b,c){var d=vb.get(a);void 0===d&&q(42);const e=d.createDOM(ob,Y);var f=Y._keyToDOMMap;e["__lexicalKey_"+Y._key]=a;f.set(a,e);z(d)?e.setAttribute("data-lexical-text","true"):v(d)&&e.setAttribute("data-lexical-decorator","true");if(E(d)){a=d.__indent;0!==a&&Bb(e,a);a=d.__children;var g=a.length;if(0!==g){f=a;--g;const h=V;V="";Eb(f,0,g,e,null);Fb(d,e);V=h}d=d.__format;0!==d&&Cb(e,d);Gb(null,a,e)}else v(d)?(d=d.decorate(Y),null!==d&&Hb(a,d),e.contentEditable="false"):(a=d.getTextContent(),
73
- z(d)&&(d.isDirectionless()||(V+=a),d.isInert()&&(d=e.style,d.pointerEvents="none",d.userSelect="none",e.contentEditable="false",d.setProperty("-webkit-user-select","none"))),U+=a,X+=a);null!==b&&(null!=c?b.insertBefore(e,c):(c=b.__lexicalLineBreak,null!=c?b.insertBefore(e,c):b.appendChild(e)));return e}function Eb(a,b,c,d,e){const f=U;for(U="";b<=c;++b)Db(a[b],d,e);d.__lexicalTextContent=U;U=f+U}function Ib(a,b){a=b.get(a[a.length-1]);return Da(a)||v(a)}
74
- function Gb(a,b,c){a=null!==a&&(0===a.length||Ib(a,ub));b=null!==b&&(0===b.length||Ib(b,vb));a?b||(b=c.__lexicalLineBreak,null!=b&&c.removeChild(b),c.__lexicalLineBreak=null):b&&(b=document.createElement("br"),c.__lexicalLineBreak=b,c.appendChild(b))}
75
- function Fb(a,b){const c=b.__lexicalDir;if(b.__lexicalDirTextContent!==V||c!==rb){var d=""===V;if(d)var e=rb;else e=V,e=aa.test(e)?"rtl":ba.test(e)?"ltr":null;if(e!==c){const f=b.classList,g=ob.theme;null===e||d&&"ltr"===e?(b.removeAttribute("dir"),d=g[c],void 0!==d&&("string"===typeof d&&(d=d.split(" "),d=g[c]=d),f.remove(...d))):null!==e&&(d=g[e],void 0!==d&&("string"===typeof d&&(d=d.split(" "),d=g[c]=d),f.add(...d)),b.dir=e);qb||(a.getWritable().__dir=e)}rb=e;b.__lexicalDirTextContent=V;b.__lexicalDir=
1
+ 'use strict';const da=/^[^A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff]*[\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]/,ea=/^[^\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]*[A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff]/,fa={bold:1,underline:8,strikethrough:4,italic:2,code:16,subscript:32,superscript:64},ha={left:1,right:3,center:2,justify:4},ia={normal:0,token:1,segmented:2,
2
+ inert:3};function p(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}let ja=!1,ka=0;function la(a){ka=a.timeStamp}function ma(a){return a.getEditorState().read(()=>{const b=r();return null!==b?b.clone():null})}
3
+ function na(a,b,c){ja=!0;const d=100<performance.now()-ka;try{oa(a,()=>{t("onMutation");var e=new Map,f=a.getRootElement(),g=a._editorState,h=!1;for(var l=0;l<b.length;l++){var k=b[l],m=k.type,n=k.target,q=pa(n,g);if(!y(q))if("characterData"===m){if(d&&3===n.nodeType&&z(q)&&q.isAttached()){k=window.getSelection();var u=m=null;null!==k&&k.anchorNode===n&&(m=k.anchorOffset,u=k.focusOffset);qa(q,n.nodeValue,m,u,!1)}}else if("childList"===m){h=!0;m=k.addedNodes;for(u=0;u<m.length;u++){var x=m[u],v=ra(x);
4
+ const A=x.parentNode;null!=A&&null===v&&A.removeChild(x)}k=k.removedNodes;m=k.length;if(0<m){u=0;for(x=0;x<m;x++)v=k[x],"BR"!==v.nodeName||n.__lexicalLineBreak!==v&&void 0===v["__lexicalKey_"+a._key]||(n.appendChild(v),u++);m!==u&&(n===f&&(q=sa(g)),e.set(n,q))}}}if(0<e.size)for(e=Array.from(e.entries()),f=0;f<e.length;f++){const [A,w]=e[f];if(B(w))for(g=w.__children,l=A.firstChild,q=0;q<g.length;q++)n=a.getElementByKey(g[q]),null!==n&&(null==l?(A.appendChild(n),l=n):l!==n&&A.replaceChild(n,l),l=l.nextSibling);
5
+ else z(w)&&w.markDirty()}e=c.takeRecords();if(0<e.length){for(f=0;f<e.length;f++)for(l=e[f],g=l.addedNodes,l=l.target,q=0;q<g.length;q++)n=g[q],k=n.parentNode,null!=k&&"BR"===n.nodeName&&l.__lexicalLineBreak!==n&&void 0===n["__lexicalKey_"+a._key]&&k.removeChild(n);c.takeRecords()}h&&(h=r()||ma(a),null!==h&&(h.dirty=!0,ta(h)))},!0)}finally{ja=!1}}function ua(a){const b=a._observer;if(null!==b){const c=b.takeRecords();na(a,c,b)}}
6
+ function va(a){0===ka&&window.addEventListener("textInput",la,!0);a._observer=new MutationObserver((b,c)=>{na(a,b,c)})}
7
+ const wa="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,xa=wa&&"documentMode"in document?document.documentMode:null,C=wa&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),ya=wa&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),za=wa&&"InputEvent"in window&&!xa?"getTargetRanges"in new window.InputEvent("input"):!1;let Aa=0;const Ba=window.Promise,Ca="function"===typeof queueMicrotask?queueMicrotask:a=>Ba.resolve().then(a);
8
+ function Da(a,b,c){a=a.getRootElement();try{return null!==a&&a.contains(b)&&a.contains(c)&&null!=b&&!y(pa(b))}catch(d){return!1}}function D(a){return a.isToken()||a.isInert()}function Ea(a){for(;null!=a;){if(3===a.nodeType)return a;a=a.firstChild}return null}function Fa(a,b,c){b=fa[b];return a&b&&(null===c||0===(c&b))?a^b:null===c||c&b?a|b:a}function Ga(a){return z(a)||La(a)||y(a)||Ma(a)}
9
+ function E(a){99<Na&&p(26);var b=a.getLatest(),c=b.__parent,d=F();const e=G(),f=d._nodeMap;d=e._dirtyElements;if(null!==c)a:for(;null!==c;){if(d.has(c))break a;const g=f.get(c);if(void 0===g)break;d.set(c,!1);c=g.__parent}b=b.__key;e._dirtyType=1;B(a)?d.set(b,!0):e._dirtyLeaves.add(b)}function H(a){const b=a.getPreviousSibling();a=a.getNextSibling();null!==b&&E(b);null!==a&&E(a)}
10
+ function I(a){J();var b=G();const c=b._compositionKey;b._compositionKey=a;null!==c&&(b=K(c),null!==b&&b.getWritable());null!==a&&(a=K(a),null!==a&&a.getWritable())}function L(){return G()._compositionKey}function K(a,b){a=(b||F())._nodeMap.get(a);return void 0===a?null:a}function ra(a,b){const c=G();a=a["__lexicalKey_"+c._key];return void 0!==a?K(a,b):null}function pa(a,b){for(;null!=a;){const c=ra(a,b);if(null!==c)return c;a=a.parentNode}return null}
11
+ function Oa(a){const b=Object.assign({},a._decorators);return a._pendingDecorators=b}function t(a){G()._log.push(a)}function Pa(a){return a.read(()=>sa().getTextContent())}function Qa(a,b){oa(a,()=>{var c=F();if(!c.isEmpty())if("root"===b)sa().markDirty();else{c=Array.from(c._nodeMap);for(let d=0;d<c.length;d++)c[d][1].markDirty()}},!0,null===a._pendingEditorState?{tag:"without-history"}:void 0)}function sa(a){return(a||F())._nodeMap.get("root")}function ta(a){F()._selection=a}
12
+ function Ra(a){var b=G(),c;a:{for(c=a;null!=c;){const d=c["__lexicalKey_"+b._key];if(void 0!==d){c=d;break a}c=c.parentNode}c=null}return null===c?(b=b.getRootElement(),a===b?K("root"):null):K(c)}function Sa(a){const b=[];for(;null!==a;)b.push(a),a=a._parentEditor;return b}function Ta(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}
13
+ function Ua(a,b){a=window.getSelection();if(null!==a){var {anchorNode:c,anchorOffset:d,focusOffset:e}=a;null!==c&&3===c.nodeType&&(a=pa(c),z(a)&&qa(a,c.nodeValue,d,e,b))}}
14
+ function qa(a,b,c,d,e){if(a.isAttached()&&(e||!a.isDirty())){var f=a.isComposing();let g=b;(f||e)&&"\u00a0"===b[b.length-1]&&(g=b.slice(0,-1));b=a.getTextContent();if(e||g!==b)""===g?(f&&I(null),a.remove()):(e=a.getParent(),b=Va(),D(a)||null!==L()&&!f||null!==e&&null!==b&&!e.canInsertTextBefore()&&0===b.anchor.offset?a.markDirty():(f=r(),null!==f&&null!==c&&null!==d&&(f.setTextNodeRange(a,c,a,d),a.isSegmented()&&(c=a.getTextContent(),c=M(c),a.replace(c),a=c)),a.setTextContent(g)))}}
15
+ function Wa(a,b,c){var d=a.anchor;const e=a.focus;var f=d.getNode();(b=d.key!==e.key||d.offset!==e.offset&&!f.isComposing()||(c||f.isDirty())&&1<b.length||!z(f)||f.getFormat()!==a.format)||(f.isSegmented()?b=!0:a.isCollapsed()?(b=a.anchor.offset,c=f.getParentOrThrow(),d=f.isToken(),a=0===b&&(!f.canInsertTextBefore()||!c.canInsertTextBefore()||d),f=f.getTextContentSize()===b&&(!f.canInsertTextBefore()||!c.canInsertTextBefore()||d),b=a||f):b=!1);return b}
16
+ function Xa(a,b){var c=a[b];return"string"===typeof c?(c=c.split(" "),a[b]=c):c}
17
+ class Ya{constructor(a,b,c){this.key=a;this.offset=b;this.type=c}is(a){return this.key===a.key&&this.offset===a.offset&&this.type===a.type}isBefore(a){let b=this.getNode(),c=a.getNode();const d=this.offset;a=a.offset;B(b)&&(b=b.getDescendantByIndex(d));B(c)&&(c=c.getDescendantByIndex(a));return b===c?d<a:b.isBefore(c)}getCharacterOffset(){return"text"===this.type?this.offset:0}getNode(){const a=K(this.key);null===a&&p(5);return a}set(a,b,c){const d=r(),e=this.key;this.key=a;this.offset=b;this.type=
18
+ c;P||(L()===e&&I(a),null===d||d.anchor!==this&&d.focus!==this||(d.dirty=!0))}}function Q(a,b,c){return new Ya(a,b,c)}function Za(a,b){const c=b.getKey();let d=a.offset,e="element";z(b)&&(e="text",b=b.getTextContentSize(),d>b&&(d=b));a.set(c,d,e)}function $a(a,b){if(B(b)){const c=b.getLastDescendant();B(c)||z(c)?Za(a,c):Za(a,b)}else z(b)&&Za(a,b)}
19
+ function ab(a,b,c){b=a.getNode();const d=b.getChildAtIndex(a.offset),e=M();e.setFormat(c);null===d?b.append(e):d.insertBefore(e);a.set(e.getKey(),0,"text")}function R(a,b,c,d){a.key=b;a.offset=c;a.type=d}
20
+ class bb{constructor(a,b,c){this.anchor=a;this.focus=b;this.dirty=!1;this.format=c}is(a){return null===a?!1:this.anchor.is(a.anchor)&&this.focus.is(a.focus)}isBackward(){return this.focus.isBefore(this.anchor)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const a=this.anchor,b=this.focus;let c=a.getNode(),d=b.getNode();B(c)&&(c=c.getDescendantByIndex(a.offset));B(d)&&(d=d.getDescendantByIndex(b.offset));return c.is(d)?B(c)?[]:[c]:c.getNodesBetween(d)}setTextNodeRange(a,b,c,d){R(this.anchor,
21
+ a.__key,b,"text");R(this.focus,c.__key,d,"text");this.dirty=!0}getTextContent(){const a=this.getNodes();if(0===a.length)return"";const b=a[0],c=a[a.length-1];var d=this.anchor,e=this.focus;const f=d.isBefore(e);d=d.getCharacterOffset();e=e.getCharacterOffset();let g="",h=!0;for(let l=0;l<a.length;l++){const k=a[l];if(B(k)&&!k.isInline())h||(g+="\n"),h=k.isEmpty()?!1:!0;else if(h=!1,z(k)){let m=k.getTextContent();k===b?m=k===c?d<e?m.slice(d,e):m.slice(e,d):f?m.slice(d):m.slice(e):k===c&&(m=f?m.slice(0,
22
+ e):m.slice(0,d));g+=m}else!(y(k)||La(k)||Ma(k))||k===c&&this.isCollapsed()||(g+=k.getTextContent())}return g}applyDOMRange(a){const b=G();a=cb(a.startContainer,a.startOffset,a.endContainer,a.endOffset,b);if(null!==a){var [c,d]=a;R(this.anchor,c.key,c.offset,c.type);R(this.focus,d.key,d.offset,d.type)}}clone(){const a=this.anchor,b=this.focus;return new bb(Q(a.key,a.offset,a.type),Q(b.key,b.offset,b.type),this.format)}toggleFormatType(a){this.format=Fa(this.format,a,null);this.dirty=!0}hasFormat(a){return 0!==
23
+ (this.format&fa[a])}insertRawText(a){const b=a.split(/\r?\n/);if(1===b.length)this.insertText(a);else{a=[];const c=b.length;for(let d=0;d<c;d++){const e=b[d];""!==e&&a.push(M(e));d!==c-1&&a.push(db())}this.insertNodes(a)}}insertText(a){var b=this.anchor,c=this.focus,d=this.isCollapsed()||b.isBefore(c),e=this.format;d&&"element"===b.type?ab(b,c,e):d||"element"!==c.type||ab(c,b,e);var f=this.getNodes(),g=f.length,h=d?c:b;b=(d?b:c).offset;var l=h.offset;c=f[0];z(c)||p(6);d=c.getTextContent().length;
24
+ var k=c.getParentOrThrow();if(!this.isCollapsed()||b!==d||!c.isSegmented()&&!c.isToken()&&c.canInsertTextAfter()&&k.canInsertTextAfter())if(!this.isCollapsed()||0!==b||!c.isSegmented()&&!c.isToken()&&c.canInsertTextBefore()&&k.canInsertTextBefore())c.isSegmented()&&b!==d&&(k=M(c.getTextContent()),c.replace(k),c=k);else{m=c.getPreviousSibling();if(!z(m)||D(m)||m.isSegmented())m=M(),k.canInsertTextBefore()?c.insertBefore(m):k.insertBefore(m);m.select();c=m;if(""!==a){this.insertText(a);return}}else{var m=
25
+ c.getNextSibling();if(!z(m)||D(m)||m.isSegmented())m=M(),k.canInsertTextAfter()?c.insertAfter(m):k.insertAfter(m);m.select(0,0);c=m;if(""!==a){this.insertText(a);return}}if(1===g)if(D(c))c.remove();else{f=c.getFormat();if(b===l&&f!==e)if(""===c.getTextContent())c.setFormat(e);else{f=M(a);f.setFormat(e);f.select();0===b?c.insertBefore(f):([g]=c.splitText(b),g.insertAfter(f));return}c=c.spliceText(b,l-b,a,!0);""===c.getTextContent()?c.remove():c.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=
26
+ a.length)}else{k=f[g-1];e=new Set([...c.getParentKeys(),...k.getParentKeys()]);var n=B(c)?c:c.getParentOrThrow();m=B(k)?k:k.getParentOrThrow();"text"===h.type&&(0!==l||""===k.getTextContent())||"element"===h.type&&k.getIndexWithinParent()<l?z(k)&&!D(k)&&l!==k.getTextContentSize()?(k.isSegmented()&&(h=M(k.getTextContent()),k.replace(h),k=h),k=k.spliceText(0,l,""),e.add(k.getKey())):k.remove():e.add(k.getKey());h=m.getChildren();l=new Set(f);const q=n.is(m);if(m.canBeEmpty()||n===m){for(n=h.length-
27
+ 1;0<=n;n--){const u=h[n];if(u.is(c)||B(u)&&u.isParentOf(c))break;u.isAttached()&&(!l.has(u)||u.is(k)?q||c.insertAfter(u):u.remove())}if(!q)for(h=m,l=null;null!==h;){k=h.getChildren();m=k.length;if(0===m||k[m-1].is(l))e.delete(h.getKey()),l=h;h=h.getParent()}}else n.append(m);D(c)?b===d?c.select():c.remove():(c=c.spliceText(b,d-b,a,!0),""===c.getTextContent()?c.remove():c.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=a.length));for(a=1;a<g;a++)b=f[a],c=b.getKey(),e.has(c)||B(b)&&!b.canSelectionRemove()||
28
+ b.remove()}}removeText(){this.insertText("")}formatText(a){const b=this.getNodes(),c=b.length-1;let d=b[0],e=b[c];if(this.isCollapsed())this.toggleFormatType(a);else{var f=this.anchor,g=this.focus,h=d.getTextContent().length,l=g.offset,k=0;for(var m=0;m<b.length;m++){var n=b[m];if(z(n)){k=n.getFormatFlags(a,null);break}}var q=f.offset;n=(m=f.isBefore(g))?q:l;m=m?l:q;if(n===d.getTextContentSize()){const u=d.getNextSibling();z(u)&&(n=q=0,d=u,k=d.getFormatFlags(a,null))}if(d.is(e))z(d)&&("element"===
29
+ f.type&&"element"===g.type?(d.setFormat(k),d.select(n,m),this.format=k):(n=q>l?l:q,m=q>l?q:l,n!==m&&(0===n&&m===h?(d.setFormat(k),d.select(n,m)):(a=d.splitText(n,m),a=0===n?a[0]:a[1],a.setFormat(k),a.select(0,m-n)),this.format=k)));else for(z(d)&&(0!==n&&([,d]=d.splitText(n)),d.setFormat(k)),f=k,z(e)&&(f=e.getFormatFlags(a,k),k=e.getTextContent().length,0!==m&&(m!==k&&([e]=e.splitText(m)),e.setFormat(f))),k=1;k<c;k++)m=b[k],g=m.getKey(),z(m)&&g!==d.getKey()&&g!==e.getKey()&&!m.isToken()&&(g=m.getFormatFlags(a,
30
+ f),m.setFormat(g))}}insertNodes(a,b){this.isCollapsed()||this.removeText();var c=this.anchor,d=c.offset,e=c.getNode(),f=e;"element"===c.type&&(f=c.getNode(),c=f.getChildAtIndex(d-1),f=null===c?f:c);c=[];var g=e.getNextSiblings(),h=e.getTopLevelElementOrThrow();if(z(e))if(f=e.getTextContent().length,0===d&&0!==f)f=e.getPreviousSibling(),f=null!==f?f:e.getParentOrThrow(),c.push(e);else if(d===f)f=e;else{if(D(e))return!1;[f,e]=e.splitText(d);c.push(e)}e=f;c.push(...g);d=a[0];var l=!1;for(g=0;g<a.length;g++){const n=
31
+ a[g];if(B(n)){if(n.is(d)){if(B(f)&&f.isEmpty()&&f.canReplaceWith(n)){f.replace(n);f=n;l=!0;continue}var k=n.getFirstDescendant();if(Ga(k)){for(k=k.getParentOrThrow();k.isInline();)k=k.getParentOrThrow();l=k.getChildren();var m=l.length;if(B(f))for(let q=0;q<m;q++)f.append(l[q]);else{for(--m;0<=m;m--)f.insertAfter(l[m]);f=f.getParentOrThrow()}k.remove();l=!0;if(k.is(n))continue}}z(f)&&(f=h)}else l&&S(f.getParent())&&p(7);l=!1;if(B(f))if(B(n)){if(n.canBeEmpty()||!n.isEmpty())f=f.insertAfter(n)}else k=
32
+ f.getFirstChild(),null!==k?k.insertBefore(n):f.append(n),f=n;else B(n)?(f=n.getParentOrThrow(),g--):f=f.insertAfter(n)}b&&(z(e)?e.select():(a=f.getPreviousSibling(),z(a)?a.select():(a=f.getIndexWithinParent(),f.getParentOrThrow().select(a,a))));if(B(f)){if(a=f.getLastDescendant(),b||(null===a?f.select():z(a)?a.select():a.selectNext()),0!==c.length)for(b=c.length-1;0<=b;b--)a=c[b],h=a.getParentOrThrow(),B(f)&&!B(a)?(f.append(a),f=a):B(a)&&!a.canInsertAfter(f)?(e=h.constructor.clone(h),B(e)||p(8),e.append(a),
33
+ f.insertAfter(e)):f.insertAfter(a),h.isEmpty()&&!h.canBeEmpty()&&h.remove()}else b||(z(f)?f.select():(c=f.getParentOrThrow(),f=f.getIndexWithinParent()+1,c.select(f,f)));return!0}insertParagraph(){this.isCollapsed()||this.removeText();var a=this.anchor,b=a.offset;if("text"===a.type){var c=a.getNode(),d=c.getTextContent().length;a=c.getNextSiblings().reverse();var e=c.getParentOrThrow();0===b?a.push(c):b!==d&&([,b]=c.splitText(b),a.push(b))}else e=a.getNode(),a=e.getChildren().slice(b).reverse();b=
34
+ e.insertNewAfter(this);if(null===b)this.insertLineBreak();else if(B(b)){e=a.length;c=null;if(0!==e)for(d=0;d<e;d++){const f=a[d];null===c?b.append(f):c.insertBefore(f);c=f}b.canBeEmpty()||0!==b.getChildrenSize()?b.selectStart():(b.selectPrevious(),b.remove())}}insertLineBreak(a){const b=db();a?this.insertNodes([b],!0):this.insertNodes([b])&&b.selectNext(0,0)}extract(){var a=this.getNodes(),b=a.length,c=b-1,d=this.anchor;const e=this.focus;var f=a[0];let g=a[c];var h=d.getCharacterOffset();const l=
35
+ e.getCharacterOffset();if(0===b)return[];if(1===b)return z(f)?(a=h>l?l:h,c=f.splitText(a,h>l?h:l),a=0===a?c[0]:c[1],null!=a?[a]:[]):[f];b=d.isBefore(e);z(f)&&(d=b?h:l,d===f.getTextContentSize()?a.shift():0!==d&&([,f]=f.splitText(d),a[0]=f));z(g)&&(f=g.getTextContent().length,h=b?l:h,0===h?a.pop():h!==f&&([g]=g.splitText(h),a[c]=g));return a}modify(a,b,c){var d=this.focus,e=this.anchor,f="move"===a;var g=d.offset;if("element"===d.type)g=d.getNode().getChildAtIndex(b?g-1:g);else{var h=d.getNode();g=
36
+ b&&0===g||!b&&g===h.getTextContentSize()?b?h.getPreviousSibling():h.getNextSibling():null}if(y(g)&&(h=b?g.getPreviousSibling():g.getNextSibling(),!z(h))){a=g.getParentOrThrow().getKey();c=g.getIndexWithinParent();b||c++;d.set(a,c,"element");f&&e.set(a,c,"element");return}d=window.getSelection();d.modify(a,b?"backward":"forward",c);0<d.rangeCount&&(b=d.getRangeAt(0),this.applyDOMRange(b),f||d.anchorNode===b.startContainer&&d.anchorOffset===b.startOffset||(f=this.focus,b=this.anchor,d=b.key,e=b.offset,
37
+ a=b.type,R(b,f.key,f.offset,f.type),R(f,d,e,a)))}deleteCharacter(a){if(this.isCollapsed()){var b=this.anchor,c=this.focus,d=b.getNode();if(B(d)&&!d.canSelectionRemove()||!a&&("element"===b.type&&b.offset===d.getChildrenSize()||"text"===b.type&&b.offset===d.getTextContentSize())&&(d=d.getNextSibling()||d.getParentOrThrow().getNextSibling(),B(d)&&!d.canExtractContents()))return;this.modify("extend",a,"character");if(!this.isCollapsed()){var e="text"===c.type?c.getNode():null;d="text"===b.type?b.getNode():
38
+ null;if(null!==e&&e.isSegmented()){if(b=c.offset,c=e.getTextContentSize(),e.is(d)||a&&b!==c||!a&&0!==b){eb(e,a);return}}else if(null!==d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(e)||a&&0!==b||!a&&b!==c)){eb(d,a);return}d=this.anchor;e=this.focus;b=d.getNode();c=e.getNode();if(b===c&&"text"===d.type&&"text"===e.type){var f=d.offset,g=e.offset;const h=f<g;c=h?f:g;g=h?g:f;f=g-1;c!==f&&(b=b.getTextContent().slice(c,g),/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(b)||(a?e.offset=f:d.offset=
39
+ f))}}else if(a&&0===b.offset&&("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).collapseAtStart(this))return}this.removeText();a=this.anchor;"text"===a.type&&(a=a.getNode(),d=a.getTextContent(),e=this.anchor.offset,0===e&&a.isSimpleText()?(e=a.getPreviousSibling(),z(e)&&"hashtag"===e.getType()&&(e.select(),b=e.getTextContent(),e.setTextContent(b+d),a.remove())):z(a)&&"hashtag"===a.getType()&&e===a.getTextContentSize()&&(e=a.getNextSibling(),z(e)&&e.isSimpleText()&&(b=e.getTextContent(),
40
+ a.setTextContent(d+b),e.remove())))}deleteLine(a){this.isCollapsed()&&this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");this.removeText()}}function eb(a,b){var c=a.getTextContent().split(/\s/g);b?c.pop():c.shift();c=c.join(" ");""===c?a.remove():(a=a.setTextContent(c),b?a.select():a.select(0,0))}
41
+ function fb(a,b){if(1===a.nodeType){let e=!1;var c=a.childNodes;var d=c.length;b===d&&(e=!0,b=d-1);c=Ra(c[b]);if(z(c))b=e?c.getTextContentSize():0;else{if(Ma(c))return Q(c.__key,0,"element");d=Ra(a);if(null===d)return null;B(d)?(a=d.getChildAtIndex(b),B(a)&&(d=e?a.getLastDescendant():a.getFirstDescendant(),null===d?(d=a,b=0):(a=d,d=a.getParentOrThrow())),z(a)?(c=a,d=null,b=e?c.getTextContentSize():0):a!==d&&e&&b++):(b=d.getIndexWithinParent()+1,d=d.getParentOrThrow());if(S(d))return null;if(B(d))return Q(d.__key,
42
+ b,"element")}}else c=Ra(a);return z(c)?Q(c.__key,b,"text"):null}
43
+ function cb(a,b,c,d,e){if(null===a||null===c||!Da(e,a,c))return null;a=fb(a,b);if(null===a)return null;c=fb(c,d);if(null===c)return null;if("text"===a.type&&"text"===c.type){d=a.getNode();const f=c.getNode(),g=d.getTextContentSize(),h=a.offset,l=c.offset;d===f&&h===l?0===b&&(d=d.getPreviousSibling(),z(d)&&!d.isInert()&&(b=d.getTextContentSize(),d=d.__key,a.key=d,c.key=d,a.offset=b,c.offset=b)):h===g&&(b=d.getNextSibling(),z(b)&&!b.isInert()&&(a.key=b.__key,a.offset=0));b=e.getEditorState()._selection;
44
+ e.isComposing()&&e._compositionKey!==a.key&&null!==b&&(e=b.anchor,b=b.focus,R(a,e.key,e.offset,e.type),R(c,b.key,b.offset,b.type))}return[a,c]}function gb(a,b,c,d,e,f){const g=F();a=new bb(Q(a,b,e),Q(c,d,f),0);a.dirty=!0;return g._selection=a}
45
+ function hb(a){const b=a.getEditorState()._selection;var c=(c=window.event)&&c.type;c=!ja&&("selectionchange"===c||"beforeinput"===c||"compositionstart"===c||"compositionend"===c||"click"===c&&3===window.event.detail||void 0===c);let d,e;if(null===b||c){var f=window.getSelection();if(null===f)return null;c=f.anchorNode;d=f.focusNode;e=f.anchorOffset;f=f.focusOffset}else return a=b.anchor,c=b.focus,new bb(Q(a.key,a.offset,a.type),Q(c.key,c.offset,c.type),b.format);a=cb(c,e,d,f,a);if(null===a)return null;
46
+ const [g,h]=a;return new bb(g,h,null===b?0:b.format)}function r(){return F()._selection}function Va(){return G()._editorState._selection}
47
+ function ib(a,b,c,d=1){var e=a.anchor,f=a.focus,g=e.getNode(),h=f.getNode();if(b.is(g)||b.is(h))if(g=b.getKey(),a.isCollapsed())b=e.offset,c<=b&&(c=Math.max(0,b+d),e.set(g,c,"element"),f.set(g,c,"element"),jb(a));else{var l=a.isBackward();h=l?f:e;var k=h.getNode();e=l?e:f;f=e.getNode();b.is(k)&&(k=h.offset,c<=k&&h.set(g,Math.max(0,k+d),"element"));b.is(f)&&(b=e.offset,c<=b&&e.set(g,Math.max(0,b+d),"element"));jb(a)}}
48
+ function jb(a){var b=a.anchor,c=b.offset;const d=a.focus;var e=d.offset,f=b.getNode(),g=d.getNode();if(a.isCollapsed())B(f)&&(g=f.getChildrenSize(),g=(e=c>=g)?f.getChildAtIndex(g-1):f.getChildAtIndex(c),z(g)&&(c=0,e&&(c=g.getTextContentSize()),b.set(g.getKey(),c,"text"),d.set(g.getKey(),c,"text")));else{if(B(f)){const h=f.getChildrenSize();c=(a=c>=h)?f.getChildAtIndex(h-1):f.getChildAtIndex(c);z(c)&&(f=0,a&&(f=c.getTextContentSize()),b.set(c.getKey(),f,"text"))}B(g)&&(c=g.getChildrenSize(),e=(b=e>=
49
+ c)?g.getChildAtIndex(c-1):g.getChildAtIndex(e),z(e)&&(g=0,b&&(g=e.getTextContentSize()),d.set(e.getKey(),g,"text")))}}function kb(a,b){b=b.getEditorState()._selection;a=a._selection;if(null!==a){var c=a.anchor;const d=a.focus;let e;"text"===c.type&&(e=c.getNode(),e.selectionTransform(b,a));"text"===d.type&&(c=d.getNode(),e!==c&&c.selectionTransform(b,a))}}
50
+ function lb(a,b,c,d,e){let f=null,g=0,h=null;null!==d?(f=d.__key,z(d)?(g=d.getTextContentSize(),h="text"):B(d)&&(g=d.getChildrenSize(),h="element")):null!==e&&(f=e.__key,z(e)?h="text":B(e)&&(h="element"));null!==f&&null!==h?a.set(f,g,h):(g=b.getIndexWithinParent(),a.set(c.__key,g,"element"))}function mb(a,b,c,d,e){"text"===a.type?(a.key=c,b||(a.offset+=e)):a.offset>d.getIndexWithinParent()&&--a.offset}
51
+ function nb(a,b){J();var c=a.__key;const d=a.getParent();if(null!==d){var e=r(),f=!1;if(null!==e&&b){var g=e.anchor;const h=e.focus;g.key===c&&(lb(g,a,d,a.getPreviousSibling(),a.getNextSibling()),f=!0);h.key===c&&(lb(h,a,d,a.getPreviousSibling(),a.getNextSibling()),f=!0)}g=d.getWritable().__children;c=g.indexOf(c);-1===c&&p(16);H(a);g.splice(c,1);a.getWritable().__parent=null;null!==e&&b&&!f&&ib(e,d,c,-1);null===d||S(d)||d.canBeEmpty()||0!==d.getChildrenSize()||nb(d,b)}}
52
+ class ob{static getType(){p(31,this.name)}static clone(){p(32,this.name)}constructor(a){this.__type=this.constructor.getType();if(!a){J();99<Na&&p(26);a=G();const b=F(),c=""+Aa++;b._nodeMap.set(c,this);B(this)?a._dirtyElements.set(c,!0):a._dirtyLeaves.add(c);a._cloneNotNeeded.add(c);a._dirtyType=1;a=c}this.__key=a;this.__parent=null}getType(){return this.__type}isAttached(){for(var a=this.__key;null!==a;){if("root"===a)return!0;a=K(a);if(null===a)break;a=a.__parent}return!1}isSelected(){const a=r();
53
+ if(null==a)return!1;const b=(new Set(a.getNodes().map(c=>c.__key))).has(this.__key);return z(this)?b:"element"===a.anchor.type&&"element"===a.focus.type&&a.anchor.key===a.focus.key&&a.anchor.offset===a.focus.offset?!1:b}getKey(){return this.__key}getIndexWithinParent(){const a=this.getParent();return null===a?-1:a.__children.indexOf(this.__key)}getParent(){const a=this.getLatest().__parent;return null===a?null:K(a)}getParentOrThrow(){const a=this.getParent();null===a&&p(33,this.__key);return a}getTopLevelElement(){let a=
54
+ this;for(;null!==a;){const b=a.getParent();if(S(b)&&B(a))return a;a=b}return null}getTopLevelElementOrThrow(){const a=this.getTopLevelElement();null===a&&p(34,this.__key);return a}getParents(){const a=[];let b=this.getParent();for(;null!==b;)a.push(b),b=b.getParent();return a}getParentKeys(){const a=[];let b=this.getParent();for(;null!==b;)a.push(b.__key),b=b.getParent();return a}getPreviousSibling(){var a=this.getParent();if(null===a)return null;a=a.__children;const b=a.indexOf(this.__key);return 0>=
55
+ b?null:K(a[b-1])}getPreviousSiblings(){var a=this.getParent();if(null===a)return[];a=a.__children;const b=a.indexOf(this.__key);return a.slice(0,b).map(c=>pb(c))}getNextSibling(){var a=this.getParent();if(null===a)return null;a=a.__children;const b=a.length,c=a.indexOf(this.__key);return c>=b-1?null:K(a[c+1])}getNextSiblings(){var a=this.getParent();if(null===a)return[];a=a.__children;const b=a.indexOf(this.__key);return a.slice(b+1).map(c=>pb(c))}getCommonAncestor(a){const b=this.getParents();var c=
56
+ a.getParents();B(this)&&b.unshift(this);B(a)&&c.unshift(a);a=b.length;var d=c.length;if(0===a||0===d||b[a-1]!==c[d-1])return null;c=new Set(c);for(d=0;d<a;d++){const e=b[d];if(c.has(e))return e}return null}is(a){return null==a?!1:this.getKey()===a.getKey()}isBefore(a){if(a.isParentOf(this))return!0;if(this.isParentOf(a))return!1;var b=this.getCommonAncestor(a);let c=this;for(;;){var d=c.getParentOrThrow();if(d===b){d=d.__children.indexOf(c.__key);break}c=d}for(c=a;;){a=c.getParentOrThrow();if(a===
57
+ b){b=a.__children.indexOf(c.__key);break}c=a}return d<b}isParentOf(a){const b=this.__key;if(b===a.__key)return!1;for(;null!==a;){if(a.__key===b)return!0;a=a.getParent()}return!1}getNodesBetween(a){const b=this.isBefore(a),c=[],d=new Set;var e=this;let f=null;for(;;){var g=e.__key;d.has(g)||(d.add(g),c.push(e));if(e===a)break;g=B(e)?b?e.getFirstChild():e.getLastChild():null;if(null!==g)null===f&&(f=e),e=g;else if(g=b?e.getNextSibling():e.getPreviousSibling(),null!==g)e=g;else{g=e.getParentOrThrow();
58
+ d.has(g.__key)||c.push(g);if(g===a)break;e=g;g.is(f)&&(f=null);do null===e&&p(35),g=b?e.getNextSibling():e.getPreviousSibling(),e=e.getParent(),null!==e&&(e.is(f)&&(f=null),null!==g||d.has(e.__key)||c.push(e));while(null===g);e=g}}b||c.reverse();return c}isDirty(){const a=G()._dirtyLeaves;return null!==a&&a.has(this.__key)}isComposing(){return this.__key===L()}getLatest(){const a=K(this.__key);null===a&&p(36);return a}getWritable(){J();var a=F(),b=G();a=a._nodeMap;const c=this.__key,d=this.getLatest(),
59
+ e=d.__parent;b=b._cloneNotNeeded;if(b.has(c))return E(d),d;const f=d.constructor.clone(d);f.__parent=e;B(d)&&B(f)?(f.__children=Array.from(d.__children),f.__indent=d.__indent,f.__format=d.__format,f.__dir=d.__dir):z(d)&&z(f)?(f.__format=d.__format,f.__style=d.__style,f.__mode=d.__mode,f.__detail=d.__detail):y(d)&&y(f)&&(f.__state=d.__state);b.add(c);f.__key=c;E(f);a.set(c,f);return f}getTextContent(){return""}getTextContentSize(a,b){return this.getTextContent(a,b).length}createDOM(){p(37)}updateDOM(){p(38)}remove(){J();
60
+ nb(this,!0)}replace(a){J();const b=this.__key;a=a.getWritable();var c=a.getParent();if(null!==c){c=c.getWritable().__children;var d=c.indexOf(a.__key);-1===d&&p(16);H(a);c.splice(d,1)}d=this.getParentOrThrow();var e=d.getWritable().__children;const f=e.indexOf(this.__key);c=a.__key;-1===f&&p(16);e.splice(f,0,c);a.__parent=d.__key;nb(this,!1);H(a);e=r();null!==e&&(d=e.anchor,e=e.focus,d.key===b&&$a(d,a),e.key===b&&$a(e,a));L()===b&&I(c);return a}insertAfter(a){J();var b=this.getWritable(),c=a.getWritable(),
61
+ d=c.getParent();const e=r();var f=!1,g=!1;if(null!==d){var h=d.getWritable().__children,l=h.indexOf(c.__key);-1===l&&p(16);H(c);if(null!==e){g=d.getKey();d=a.getIndexWithinParent();f=e.anchor;const k=e.focus;f="element"===f.type&&f.key===g&&f.offset===d+1;g="element"===k.type&&k.key===g&&k.offset===d+1}h.splice(l,1)}h=this.getParentOrThrow().getWritable();l=c.__key;c.__parent=b.__parent;d=h.__children;b=d.indexOf(b.__key);-1===b&&p(16);d.splice(b+1,0,l);H(c);null!==e&&(ib(e,h,b+1),c=h.getKey(),f&&
62
+ e.anchor.set(c,b+2,"element"),g&&e.focus.set(c,b+2,"element"));return a}insertBefore(a){J();var b=this.getWritable(),c=a.getWritable(),d=c.getParent();if(null!==d){d=d.getWritable().__children;var e=d.indexOf(c.__key);-1===e&&p(16);H(c);d.splice(e,1)}d=this.getParentOrThrow().getWritable();e=c.__key;c.__parent=b.__parent;const f=d.__children;b=f.indexOf(b.__key);-1===b&&p(16);f.splice(b,0,e);H(c);c=r();null!==c&&ib(c,d,b);return a}selectPrevious(a,b){J();const c=this.getPreviousSibling(),d=this.getParentOrThrow();
63
+ return null===c?d.select(0,0):B(c)?c.select():z(c)?c.select(a,b):(a=c.getIndexWithinParent()+1,d.select(a,a))}selectNext(a,b){J();const c=this.getNextSibling(),d=this.getParentOrThrow();return null===c?d.select():B(c)?c.select(0,0):z(c)?c.select(a,b):(a=c.getIndexWithinParent(),d.select(a,a))}markDirty(){this.getWritable()}}function pb(a){const b=K(a);null===b&&p(39,a);return b}
64
+ class qb extends ob{constructor(a){super(a);this.__children=[];this.__indent=this.__format=0;this.__dir=null}getFormat(){return this.getLatest().__format}getIndent(){return this.getLatest().__indent}getChildren(){const a=this.getLatest().__children,b=[];for(let c=0;c<a.length;c++){const d=K(a[c]);null!==d&&b.push(d)}return b}getChildrenKeys(){return this.getLatest().__children}getChildrenSize(){return this.getLatest().__children.length}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const a=
65
+ G()._dirtyElements;return null!==a&&a.has(this.__key)}getAllTextNodes(a){const b=[],c=this.getLatest().__children;for(let e=0;e<c.length;e++){var d=K(c[e]);!z(d)||!a&&d.isInert()?B(d)&&(d=d.getAllTextNodes(a),b.push(...d)):b.push(d)}return b}getFirstDescendant(){let a=this.getFirstChild();for(;null!==a;){if(B(a)){const b=a.getFirstChild();if(null!==b){a=b;continue}}break}return a}getLastDescendant(){let a=this.getLastChild();for(;null!==a;){if(B(a)){const b=a.getLastChild();if(null!==b){a=b;continue}}break}return a}getDescendantByIndex(a){const b=
66
+ this.getChildren(),c=b.length;if(0===c)return this;if(a>=c)return a=b[c-1],B(a)&&a.getLastDescendant()||a;a=b[a];return B(a)&&a.getFirstDescendant()||a}getFirstChild(){const a=this.getLatest().__children;return 0===a.length?null:K(a[0])}getFirstChildOrThrow(){const a=this.getFirstChild();null===a&&p(15,this.__key);return a}getLastChild(){const a=this.getLatest().__children,b=a.length;return 0===b?null:K(a[b-1])}getChildAtIndex(a){a=this.getLatest().__children[a];return void 0===a?null:K(a)}getTextContent(a,
67
+ b){let c="";const d=this.getChildren(),e=d.length;for(let f=0;f<e;f++){const g=d[f];c+=g.getTextContent(a,b);B(g)&&f!==e-1&&!g.isInline()&&(c+="\n\n")}return c}getDirection(){return this.__dir}hasFormat(a){a=ha[a];return 0!==(this.getFormat()&a)}select(a,b){J();const c=r();var d=this.getChildrenSize();void 0===a&&(a=d);void 0===b&&(b=d);d=this.__key;if(null===c)return gb(d,a,d,b,"element","element");c.anchor.set(d,a,"element");c.focus.set(d,b,"element");c.dirty=!0;return c}selectStart(){const a=this.getFirstDescendant();
68
+ return B(a)||z(a)?a.select(0,0):null!==a?a.selectPrevious():this.select(0,0)}selectEnd(){const a=this.getLastDescendant();return B(a)||z(a)?a.select():null!==a?a.selectNext():this.select()}clear(){J();const a=this.getWritable();this.getChildren().forEach(b=>b.remove());return a}append(...a){J();const b=this.getWritable(),c=b.__key,d=b.__children,e=a.length;var f=this.getLastChild();null!==f&&E(f);for(f=0;f<e;f++){var g=a[f];g.__key===c&&p(49);g=g.getWritable();var h=g.getParent();if(null!==h){h=h.getWritable().__children;
69
+ const l=h.indexOf(g.__key);-1===l&&p(16);h.splice(l,1)}g.__parent=c;d.push(g.__key)}return b}setDirection(a){J();const b=this.getWritable();b.__dir=a;return b}setFormat(a){J();this.getWritable().__format=ha[a];return this}setIndent(a){J();this.getWritable().__indent=a;return this}splice(a,b,c){J();const d=this.getWritable();var e=d.__key;const f=d.__children,g=c.length;var h=[];for(let k=0;k<g;k++){const m=c[k],n=m.getWritable();m.__key===e&&p(49);var l=n.getParent();if(null!==l){l=l.getWritable().__children;
70
+ const q=l.indexOf(n.__key);-1===q&&p(16);H(m);l.splice(q,1)}n.__parent=e;h.push(n.__key)}(c=this.getChildAtIndex(a-1))&&E(c);(e=this.getChildAtIndex(a+b))&&E(e);a=f.splice(a,b,...h);if(b&&(b=r(),null!==b)){const k=new Set(a),m=new Set(h);h=u=>{for(u=u.getNode();u;){const x=u.__key;if(k.has(x)&&!m.has(x))return!0;u=u.getParent()}return!1};const {anchor:n,focus:q}=b;h(n)&&lb(n,n.getNode(),this,c,e);h(q)&&lb(q,q.getNode(),this,c,e);h=a.length;for(b=0;b<h;b++)c=K(a[b]),null!=c&&(c.getWritable().__parent=
71
+ null);0!==f.length||this.canBeEmpty()||S(this)||this.remove()}return d}insertNewAfter(){return null}canInsertTab(){return!1}collapseAtStart(){return!1}excludeFromCopy(){return!1}canExtractContents(){return!0}canReplaceWith(){return!0}canInsertAfter(){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}canSelectionRemove(){return!0}canMergeWith(){return!1}}function B(a){return a instanceof qb}
72
+ class rb{constructor(a,b){this.id=a||Ta();this.editorState=b||null;this.editor=null}init(a){let b=this.editorState;"string"===typeof b&&(this.editorState=b=a.parseEditorState(b),null!==b&&a.setEditorState(b,{tag:"without-history"}))}set(a){this.editor=a;this.editorState=a.getEditorState()}toJSON(){const a=this.editorState;return{id:this.id,type:"editor",editorState:null===a||"string"===typeof a?a:JSON.stringify(a.toJSON())}}isEmpty(){return null===this.editorState}}
73
+ function sb(a,b){return new rb(a,b)}class tb{constructor(a,b){this._editor=a;this._observers=new Set;this._map=b||new Map}get(a){return this._map.get(a)}has(a){return this._map.has(a)}set(a,b){this._map.set(a,b);const c=Array.from(this._observers);for(let d=0;d<c.length;d++)c[d](a,b)}observe(a){const b=this._observers;b.add(a);return()=>{b.delete(a)}}destroy(){this._observers.clear()}toJSON(){return{type:"map",map:Array.from(this._map.entries())}}}function ub(a,b){return new tb(a,b)}
74
+ class vb{constructor(a,b){this._editor=a;this._observers=new Set;this._array=b||[]}observe(a){const b=this._observers;b.add(a);return()=>{b.delete(a)}}get length(){return this._array.length}map(a){const b=[],c=this._array;for(let d=0;d<c.length;d++)b.push(a(c[d],d,c));return b}reduce(a,b){const c=this._array;for(let d=0;d<c.length;d++){const e=c[d];b=void 0!==b?a(b,e):e}return b}push(a){this.splice(this._array.length,0,a)}splice(a,b,c){void 0===c?this._array.splice(a,b):this._array.splice(a,b,c);
75
+ const d=Array.from(this._observers);for(let e=0;e<d.length;e++)d[e](a,b,c)}indexOf(a){return this._array.indexOf(a)}destroy(){this._observers.clear()}toJSON(){return{type:"array",array:this._array}}}function wb(a,b){return new vb(a,b)}class xb extends ob{constructor(a,b){super(b);b=G();this.__state=a||ub(b)}decorate(){p(4)}}function y(a){return a instanceof xb}
76
+ class yb extends qb{static getType(){return"root"}static clone(){return new yb}constructor(){super("root");this.__cachedText=null}getTextContent(a,b){const c=this.__cachedText;return!P&&0!==G()._dirtyType||null===c||a&&!1===b?super.getTextContent(a,b):c}select(){p(9)}remove(){p(10)}replace(){p(11)}insertBefore(){p(12)}insertAfter(){p(13)}updateDOM(){return!1}append(...a){for(let b=0;b<a.length;b++){const c=a[b];B(c)||y(c)||p(46)}return super.append(...a)}canBeEmpty(){return!1}}
77
+ function S(a){return a instanceof yb}function zb(a,b){b=b.getEditorState()._selection;a=a._selection;if(null!==a){if(a.dirty||!a.is(b))return!0}else if(null!==b)return!0;return!1}function Ab(){return new Bb(new Map([["root",new yb]]))}
78
+ class Bb{constructor(a,b){this._nodeMap=a;this._selection=b||null;this._readOnly=this._flushSync=!1}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(a){a:{const c=T,d=P,e=U;T=this;P=!0;U=null;try{var b=a();break a}finally{T=c,P=d,U=e}b=void 0}return b}clone(a){a=new Bb(this._nodeMap,void 0===a?this._selection:a);a._readOnly=!0;return a}toJSON(){const a=this._selection;return{_nodeMap:Array.from(this._nodeMap.entries()),_selection:null===a?null:{anchor:{key:a.anchor.key,offset:a.anchor.offset,
79
+ type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type}}}}}let V="",W="",X="",Cb,Y,Db=!1,Eb=!1,Fb=null,Gb,Hb,Ib,Jb,Kb;function Lb(a,b){const c=Ib.get(a);if(null!==b){const d=Mb(a);b.removeChild(d)}Jb.has(a)||Y._keyToDOMMap.delete(a);B(c)&&(a=c.__children,Nb(a,0,a.length-1,null))}function Nb(a,b,c,d){for(;b<=c;++b){const e=a[b];void 0!==e&&Lb(e,d)}}function Ob(a,b){a.setProperty("text-align",b)}
80
+ function Pb(a,b){a.style.setProperty("padding-inline-start",0===b?"":40*b+"px")}function Qb(a,b){a=a.style;0===b?Ob(a,""):1===b?Ob(a,"left"):2===b?Ob(a,"center"):3===b?Ob(a,"right"):4===b&&Ob(a,"justify")}
81
+ function Rb(a,b,c){var d=Jb.get(a);void 0===d&&p(42);const e=d.createDOM(Cb,Y);var f=Y._keyToDOMMap;e["__lexicalKey_"+Y._key]=a;f.set(a,e);z(d)?e.setAttribute("data-lexical-text","true"):y(d)&&e.setAttribute("data-lexical-decorator","true");if(B(d)){a=d.__indent;0!==a&&Pb(e,a);a=d.__children;var g=a.length;if(0!==g){f=a;--g;const h=W;W="";Sb(f,0,g,e,null);Tb(d,e);W=h}d=d.__format;0!==d&&Qb(e,d);Ub(null,a,e)}else y(d)?(f=d.decorate(Y),d=d.getTextContent(),null!==f&&Vb(a,f),e.contentEditable="false",
82
+ V+=d,X+=d):(a=d.getTextContent(),z(d)&&(d.isDirectionless()||(W+=a),d.isInert()&&(d=e.style,d.pointerEvents="none",d.userSelect="none",e.contentEditable="false",d.setProperty("-webkit-user-select","none"))),V+=a,X+=a);null!==b&&(null!=c?b.insertBefore(e,c):(c=b.__lexicalLineBreak,null!=c?b.insertBefore(e,c):b.appendChild(e)));return e}function Sb(a,b,c,d,e){const f=V;for(V="";b<=c;++b)Rb(a[b],d,e);d.__lexicalTextContent=V;V=f+V}function Wb(a,b){a=b.get(a[a.length-1]);return La(a)||y(a)}
83
+ function Ub(a,b,c){a=null!==a&&(0===a.length||Wb(a,Ib));b=null!==b&&(0===b.length||Wb(b,Jb));a?b||(b=c.__lexicalLineBreak,null!=b&&c.removeChild(b),c.__lexicalLineBreak=null):b&&(b=document.createElement("br"),c.__lexicalLineBreak=b,c.appendChild(b))}
84
+ function Tb(a,b){const c=b.__lexicalDir;if(b.__lexicalDirTextContent!==W||c!==Fb){var d=""===W;if(d)var e=Fb;else e=W,e=da.test(e)?"rtl":ea.test(e)?"ltr":null;if(e!==c){const f=b.classList,g=Cb.theme;null===e||d&&"ltr"===e?(b.removeAttribute("dir"),d=g[c],void 0!==d&&("string"===typeof d&&(d=d.split(" "),d=g[c]=d),f.remove(...d))):null!==e&&(d=g[e],void 0!==d&&("string"===typeof d&&(d=d.split(" "),d=g[c]=d),f.add(...d)),b.dir=e);Eb||(a.getWritable().__dir=e)}Fb=e;b.__lexicalDirTextContent=W;b.__lexicalDir=
76
85
  e}}
77
- function Jb(a,b){var c=ub.get(a),d=vb.get(a);void 0!==c&&void 0!==d||q(43);var e=pb||tb.has(a)||sb.has(a);const f=Kb(Y,a);if(c===d&&!e)return E(c)?(d=f.__lexicalTextContent,void 0!==d&&(U+=d,X+=d),d=f.__lexicalDirTextContent,void 0!==d&&(V+=d)):v(c)||(d=c.getTextContent(),z(c)&&!c.isDirectionless()&&(V+=d),X+=d,U+=d),f;if(d.updateDOM(c,f,ob))return d=Db(a,null,null),null===b&&q(44),b.replaceChild(d,f),xb(a,null),d;if(E(c)&&E(d)){if(a=d.__indent,a!==c.__indent&&Bb(f,a),a=d.__format,a!==c.__format&&Cb(f,
78
- a),c=c.__children,a=d.__children,c!==a||e){var g=c,h=a;e=d;b=V;V="";const u=U;U="";var l=g.length,k=h.length;if(1===l&&1===k){var m=g[0];h=h[0];if(m===h)Jb(m,f);else{var n=yb(m);h=Db(h,null,null);f.replaceChild(h,n);xb(m,null)}}else if(0===l)0!==k&&Eb(h,0,k-1,f,null);else if(0===k)0!==l&&(m=null==f.__lexicalLineBreak,zb(g,0,l-1,m?null:f),m&&(f.textContent=""));else{const w=l-1;l=k-1;let x=f.firstChild,B=0;for(k=0;B<=w&&k<=l;){var r=g[B];const y=h[k];if(r===y)x=Jb(y,f).nextSibling,B++,k++;else{void 0===
79
- m&&(m=new Set(g));void 0===n&&(n=new Set(h));const L=n.has(r),xa=m.has(y);L?(xa?(r=Kb(Y,y),r===x?x=Jb(y,f).nextSibling:(null!=x?f.insertBefore(r,x):f.appendChild(r),Jb(y,f)),B++):Db(y,f,x),k++):(x=yb(r).nextSibling,xb(r,f),B++)}}m=B>w;n=k>l;m&&!n?(m=h[l+1],m=void 0===m?null:Y.getElementByKey(m),Eb(h,k,l,f,m)):n&&!m&&zb(g,B,w,f)}f.__lexicalTextContent=U;U=u+U;Fb(e,f);V=b;R(d)||Gb(c,a,f)}}else v(d)?(c=d.decorate(Y),null!==c&&Hb(a,c)):(c=d.getTextContent(),z(d)&&!d.isDirectionless()&&(V+=c),U+=c,X+=
80
- c);!qb&&R(d)&&d.__cachedText!==X&&(d=d.getWritable(),d.__cachedText=X);return f}function Hb(a,b){let c=Y._pendingDecorators;const d=Y._decorators;if(null===c){if(d[a]===b)return;c=Ga(Y)}c[a]=b}function yb(a){a=wb.get(a);void 0===a&&q(45);return a}function Kb(a,b){a=a._keyToDOMMap.get(b);void 0===a&&q(45);return a}function Lb(a,b,c,d,e){a=a.__children;const f=a.length;for(let g=0;g<f;g++){const h=a[g],l=d.get(h);void 0!==l&&l.__parent===b&&(E(l)&&Lb(l,h,c,d,e),c.has(h)||e.delete(h),d.delete(h))}}
81
- function Qb(a,b,c,d){var e=Array.from(c),f=e.length;const g=Array.from(d),h=g.length;a=a._nodeMap;b=b._nodeMap;for(let l=0;l<f;l++){const k=e[l],m=b.get(k);void 0===m||m.isAttached()||(a.has(k)||c.delete(k),b.delete(k))}for(c=0;c<h;c++)e=g[c][0],f=b.get(e),void 0===f||f.isAttached()||(E(f)&&Lb(f,e,a,b,d),a.has(e)||d.delete(e),b.delete(e))}
82
- function Rb(a,b){b=b.map;const c=new Map;for(let d=0;d<b.length;d++){const [e,f]=b[d];let g;if("string"===typeof f||"number"===typeof f||"boolean"===typeof f||null===f)g=f;else if("object"===typeof f)g="editor"===f.type?gb(f.id,f.editorState):Rb(a,f);else throw Error("Should never happen");c.set(e,g)}return ib(a,c)}
83
- function Sb(a,b,c,d,e={}){var f=a.__type,g=c._registeredNodes.get(f);void 0===g&&q(24,f);f=g.klass;g=a.__key;a.__key=void 0;f=f.clone(a);a.__key=g;g=f.__key;R(f)&&C()._nodeMap.set("root",f);f.__parent=d;if(E(f)){d=a.__children;for(let l=0;l<d.length;l++){var h=b.get(d[l]);void 0!==h&&(h=Sb(h,b,c,g,e).getKey(),f.__children.push(h))}f.__indent=a.__indent;f.__format=a.__format;f.__dir=a.__dir}else z(f)?(f.__format=a.__format,f.__style=a.__style,f.__mode=a.__mode,f.__detail=a.__detail):v(f)&&(f.__state=
84
- Rb(c,a.__state));b=null!=e?e.originalSelection:void 0;null!=b&&(a.__key===b.anchor.key&&(e.remappedSelection=e.remappedSelection||{anchor:{...b.anchor},focus:{...b.focus}},e.remappedSelection.anchor.key=f.__key),a.__key===b.focus.key&&(e.remappedSelection=e.remappedSelection||{anchor:{...b.anchor},focus:{...b.focus}},e.remappedSelection.focus.key=f.__key));return f}
85
- function Tb(a,b){const c=a.__mode,d=a.__format;a=a.__style;const e=b.__mode,f=b.__format;b=b.__style;return(null===c||c===e)&&(null===d||d===f)&&(null===a||a===b)}function Ub(a,b){const c=a.mergeWithSibling(b),d=D()._normalizedNodes;d.add(a.__key);d.add(b.__key);return c}
86
- function Vb(a){if(""===a.__text&&a.isSimpleText()&&!a.isUnmergeable())a.remove();else{for(var b;null!==(b=a.getPreviousSibling())&&z(b)&&b.isSimpleText()&&!b.isUnmergeable();)if(""===b.__text)b.remove();else{Tb(b,a)&&(a=Ub(b,a));break}for(var c;null!==(c=a.getNextSibling())&&z(c)&&c.isSimpleText()&&!c.isUnmergeable();)if(""===c.__text)c.remove();else{Tb(a,c)&&Ub(a,c);break}}}let S=null,T=null,N=!1,Wb=!1,Fa=0;function H(){N&&q(25)}function C(){null===S&&q(27);return S}
87
- function D(){null===T&&q(28);return T}function Xb(a,b,c){var d=b.__type;const e=a._registeredNodes.get(d);void 0===e&&q(23,d);a=c.get(d);void 0===a&&(a=Array.from(e.transforms),c.set(d,a));c=a.length;for(d=0;d<c&&(a[d](b),b.isAttached());d++);}function Yb(a,b){var c=b._dirtyLeaves;a=a._nodeMap;b=c.size;c=Array.from(c);for(let d=0;d<b;d++){const e=a.get(c[d]);z(e)&&e.isSimpleText()&&!e.isUnmergeable()&&Vb(e)}}
88
- function Zb(a,b){const c=b._dirtyLeaves,d=b._dirtyElements;a=a._nodeMap;const e=J(),f=new Map;var g=c,h=g.size,l=d;let k=l.size;for(;0<h||0<k;){if(0<h){b._dirtyLeaves=new Set;g=Array.from(g);for(var m=0;m<h;m++){var n=g[m];const r=a.get(n);z(r)&&r.isSimpleText()&&!r.isUnmergeable()&&Vb(r);void 0!==r&&void 0!==r&&r.__key!==e&&r.isAttached()&&Xb(b,r,f);c.add(n)}g=b._dirtyLeaves;h=g.size;if(0<h){Fa++;continue}}b._dirtyLeaves=new Set;b._dirtyElements=new Map;h=Array.from(l);for(l=0;l<k;l++)m=h[l],g=m[0],
89
- m=m[1],"root"!==g&&m&&(m=h[l][1],n=a.get(g),void 0!==n&&void 0!==n&&n.__key!==e&&n.isAttached()&&Xb(b,n,f),d.set(g,m));g=b._dirtyLeaves;h=g.size;l=b._dirtyElements;k=l.size;Fa++}b._dirtyLeaves=c;b._dirtyElements=d}
90
- function Z(a){var b=a._pendingEditorState,c=a._rootElement;if(null!==c&&null!==b){var d=a._editorState,e=d._selection,f=b._selection,g=0!==a._dirtyType;a._pendingEditorState=null;a._editorState=b;var h=S,l=N,k=T,m=a._updating;T=a;S=b;N=!1;a._updating=!0;try{var n=a._observer;if(g&&null!==n){var r=a._dirtyType,u=a._dirtyElements,w=a._dirtyLeaves;n.disconnect();try{V=X=U="",pb=2===r,rb=null,Y=a,ob=a._config,sb=u,tb=w,ub=d._nodeMap,vb=b._nodeMap,qb=b._readOnly,wb=new Map(a._keyToDOMMap),Jb("root",null),
91
- wb=ob=vb=ub=tb=sb=Y=void 0}finally{n.observe(c,{childList:!0,subtree:!0,characterData:!0})}}const W=window.getSelection();if(null!==W&&(g||null===f||f.dirty)){n=W;const ya=n.anchorNode,Mb=n.focusNode,jc=n.anchorOffset,kc=n.focusOffset,za=document.activeElement,ja=a._rootElement;if(!a._updateTags.has("collaboration")||za===ja)if(null===f)null!==e&&wa(a,ya,Mb)&&n.removeAllRanges();else{var x=f.anchor,B=f.focus,y=B.key,L=Kb(a,x.key),xa=Kb(a,y),Nb=x.offset,Ob=B.offset;e=L;y=xa;"text"===x.type&&(e=Aa(L));
92
- "text"===B.type&&(y=Aa(xa));if(null!==e&&null!==y)if(jc===Nb&&kc===Ob&&ya===e&&Mb===y)null===ja||null!==za&&ja.contains(za)||ja.focus({preventScroll:!0});else try{if(n.setBaseAndExtent(e,Nb,y,Ob),f.isCollapsed()&&ja===za){const ka=3===e.nodeType?e.parentNode:e;if(null!==ka){const Pb=ka.getBoundingClientRect();Pb.bottom>window.innerHeight?ka.scrollIntoView(!1):0>Pb.top&&ka.scrollIntoView()}}}catch(ka){}}}}catch(W){A("error",a,!1,W,W._log);Wb||($b(a,null,c,b),sa(a),a._dirtyType=2,Wb=!0,a._log.push("ReconcileRecover"),
93
- Z(a),Wb=!1);return}finally{a._updating=m,S=h,N=l,T=k}b._readOnly=!0;c=a._dirtyLeaves;f=a._dirtyElements;h=a._normalizedNodes;l=a._updateTags;k=a._log;a._log=[];g&&(a._dirtyType=0,a._cloneNotNeeded.clear(),a._dirtyLeaves=new Set,a._dirtyElements=new Map,a._normalizedNodes=new Set,a._updateTags=new Set);g=a._decorators;m=a._pendingDecorators||g;x=b._nodeMap;for(var M in m)x.has(M)||(m===g&&(m=Ga(a)),delete m[M]);M=a._pendingDecorators;null!==M&&(a._decorators=M,a._pendingDecorators=null,A("decorator",
94
- a,!0,M));M=Ha(d);g=Ha(b);M!==g&&A("textcontent",a,!0,g);A("update",a,!0,{tags:l,normalizedNodes:h,prevEditorState:d,editorState:b,dirtyLeaves:c,dirtyElements:f,log:k});b=a._deferred;a._deferred=[];if(0!==b.length){d=a._updating;a._updating=!0;try{for(M=0;M<b.length;M++)b[M]()}finally{a._updating=d}}b=a._updates;if(0!==b.length){const [W,ya]=b.shift();ac(a,W,!1,ya)}}}
95
- function A(a,b,c,...d){const e=b._updating;b._updating=c;try{const f=Array.from(b._listeners[a]);for(a=0;a<f.length;a++)f[a](...d)}finally{b._updating=e}}function bc(a,b,c){if(!1===a._updating||T!==a){let e=!1;a.update(()=>{e=bc(a,b,c)});return e}const d=La(a);for(let e=4;0<=e;e--)for(let f=0;f<d.length;f++){const g=Array.from(d[f]._listeners.command[e]);for(let h=0;h<g.length;h++)if(!0===g[h](b,c,a))return!0}return!1}
96
- function cc(a,b){for(a=a._updates;0!==a.length;){const [c,d]=a.shift(),e=void 0!==d&&d.onUpdate;e&&b.push(e);c()}}
97
- function ac(a,b,c,d){c=a._deferred;let e,f,g=!1;void 0!==d&&(e=d.onUpdate,f=d.tag,g=d.skipTransforms);e&&c.push(e);const h=a._editorState;d=a._pendingEditorState;let l=!1;null===d&&(d=a._pendingEditorState=new nb(new Map(h._nodeMap)),l=!0);const k=S,m=N,n=T,r=a._updating;S=d;N=!1;a._updating=!0;T=a;try{l&&(d._selection=Wa(a));const u=a._compositionKey;b();cc(a,c);Za(d,a);0!==a._dirtyType&&(d.isEmpty()&&q(29),g?Yb(d,a):Zb(d,a),cc(a,c),Qb(h,d,a._dirtyLeaves,a._dirtyElements));u!==a._compositionKey&&
98
- (d._flushSync=!0);const w=d._selection;if(null!==w){const x=d._nodeMap,B=w.focus.key;void 0!==x.get(w.anchor.key)&&void 0!==x.get(B)||q(30)}}catch(u){A("error",a,!1,u,a._log);a._pendingEditorState=h;a._dirtyType=2;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();a._log.push("UpdateRecover");Z(a);return}finally{S=k,N=m,T=n,a._updating=r,Fa=0}0!==a._dirtyType||lb(d,a)?(null!=f&&a._updateTags.add(f),d._flushSync?(d._flushSync=!1,Z(a)):l&&va(()=>{Z(a)})):(e&&(b=c.indexOf(e),c.splice(b,
99
- 1)),d._flushSync=!1,l&&(a._pendingEditorState=null))}function ma(a,b,c,d){a._updating?a._updates.push([b,d]):ac(a,b,c,d)}class dc extends cb{static getType(){return"linebreak"}static clone(a){return new dc(a.__key)}constructor(a){super(a)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}}function Sa(){return new dc}function Da(a){return a instanceof dc}
100
- function $b(a,b,c,d){const e=a._keyToDOMMap;e.clear();a._editorState=mb();a._pendingEditorState=d;a._compositionKey=null;a._dirtyType=0;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();a._normalizedNodes=new Set;a._updateTags=new Set;a._log=[];a._updates=[];d=a._observer;null!==d&&(d.disconnect(),a._observer=null);null!==b&&(b.textContent="");null!==c&&(c.textContent="",e.set("root",c))}
101
- function ec(a,b){const c=b.getType();let d=a.get(c);void 0===d&&(d={count:0,klass:b,transforms:new Set},a.set(c,d));const e=d;e.count++;return()=>{1===e.count?a.delete(c):e.count--}}
102
- class fc{constructor(a,b,c){this._parentEditor=b;this._rootElement=null;this._editorState=a;this._compositionKey=this._pendingEditorState=null;this._deferred=[];this._keyToDOMMap=new Map;this._updates=[];this._updating=!1;this._listeners={decorator:new Set,error:new Set,textcontent:new Set,textmutation:new Set,root:new Set,update:new Set,command:[new Set,new Set,new Set,new Set,new Set],decoratorstate:new Set};this._config=c;this._registeredNodes=new Map;this.registerNodes([kb,gc,dc]);this._decorators=
103
- {};this._pendingDecorators=null;this._dirtyType=0;this._cloneNotNeeded=new Set;this._dirtyLeaves=new Set;this._dirtyElements=new Map;this._normalizedNodes=new Set;this._updateTags=new Set;this._observer=null;this._log=[];this._key=""+ta++}isComposing(){return null!=this._compositionKey}registerNodes(a){const b=a.length,c=this._registeredNodes,d=[];for(let e=0;e<b;e++)d.push(ec(c,a[e]));return()=>{for(let e=0;e<b;e++)d[e]()}}addListener(a,b,c){const d=this._listeners[a];if("command"===a&&void 0!==
104
- c){const f=d[c];f.add(b);return()=>{f.delete(b)}}d.add(b);const e="root"===a;e&&b(this._rootElement,null);return()=>{d.delete(b);e&&b(null,this._rootElement)}}addTransform(a,b){const c=a.getType(),d=this._registeredNodes.get(c);void 0===d&&q(18,a.name);const e=d.transforms;e.add(b);Ja(this,c);return()=>{e.delete(b)}}execCommand(a,b){return bc(this,a,b)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}setRootElement(a){const b=this._rootElement;if(a!==b){const c=this._pendingEditorState||
105
- this._editorState;this._rootElement=a;$b(this,b,a,c);null!==b&&(b.__lexicalEditor=null);null!==a&&(a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,sa(this),this._updateTags.add("without-history"),Z(this),a.__lexicalEditor=this);A("root",this,!1,a,b)}}getElementByKey(a){return this._keyToDOMMap.get(a)||null}getEditorState(){return this._editorState}setEditorState(a,b){a.isEmpty()&&q(19);ra(this);const c=this._pendingEditorState,d=this._updateTags;b=void 0!==b?b.tag:null;null===c||c.isEmpty()||
106
- (null!=b&&d.add(b),Z(this));this._pendingEditorState=a;this._dirtyType=2;this._compositionKey=null;null!=b&&d.add(b);Z(this)}parseEditorState(a){const b=JSON.parse(a);a=new Map;a=new nb(a);const c={originalSelection:b._selection},d=N,e=T;S=a;N=!1;T=this;try{var f=new Map(b._nodeMap);const g=f.get("root");Sb(g,f,this,null,c)}finally{S=a,N=d,T=e}f=c.remappedSelection||c.originalSelection;f=null===f?null:new Qa(O(f.anchor.key,f.anchor.offset,f.anchor.type),O(f.focus.key,f.focus.offset,f.focus.type),
107
- 0);a._selection=f;return a}update(a,b){ma(this,a,!1,b)}focus(a){const b=this._rootElement;null!==b&&(b.setAttribute("autocapitalize","off"),ma(this,()=>{const c=t(),d=Ia();null!==c?c.dirty=!0:0!==d.getChildrenSize()&&d.selectEnd()},!0,{onUpdate:()=>{b.removeAttribute("autocapitalize");a&&a()}}))}blur(){const a=this._rootElement;null!==a&&a.blur()}}function hc(a,b){return b&1?"strong":b&2?"em":"span"}function ic(a,b){var c=a[b];return"string"===typeof c?(c=c.split(" "),a[b]=c):c}
108
- function lc(a,b,c,d,e){a=d.classList;d=ic(e,"base");void 0!==d&&a.add(...d);d=ic(e,"underlineStrikethrough");let f=!1;const g=b&8&&b&4;var h=c&8&&c&4;void 0!==d&&(h?(f=!0,g||a.add(...d)):g&&a.remove(...d));for(const l in p)h=p[l],d=ic(e,l),void 0!==d&&(c&h?!f||"underline"!==l&&"strikethrough"!==l?(0===(b&h)||g&&"underline"===l||"strikethrough"===l)&&a.add(...d):b&h&&a.remove(...d):b&h&&a.remove(...d))}
109
- function mc(a,b,c){const d=b.firstChild;c=c.isComposing()?"\u00a0":"";a+=c;null==d?b.textContent=a:d.nodeValue!==a&&(d.nodeValue=a)}
110
- class gc extends cb{static getType(){return"text"}static clone(a){return new gc(a.__text,a.__key)}constructor(a,b){super(b);this.__text=a;this.__format=0;this.__style="";this.__detail=this.__mode=0}getFormat(){return this.getLatest().__format}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isSegmented(){return 2===this.getLatest().__mode}isInert(){return 3===this.getLatest().__mode}isDirectionless(){return 0!==(this.getLatest().__detail&1)}isUnmergeable(){return 0!==
111
- (this.getLatest().__detail&2)}hasFormat(a){a=p[a];return 0!==(this.getFormat()&a)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(a,b){return!a&&this.isInert()||!1===b&&this.isDirectionless()?"":this.getLatest().__text}getFormatFlags(a,b){const c=this.getLatest().__format;return Ba(c,a,b)}createDOM(a){var b=this.__format,c=b&16?"code":null;const d=hc(this,b),e=document.createElement(null===c?d:c);let f=e;null!==c&&(f=document.createElement(d),e.appendChild(f));c=f;mc(this.__text,
112
- c,this);a=a.theme.text;void 0!==a&&lc(d,0,b,c,a);b=this.__style;""!==b&&(e.style.cssText=b);return e}updateDOM(a,b,c){const d=this.__text;var e=a.__format,f=this.__format,g=e&16?"code":null;const h=f&16?"code":null;var l=hc(this,e);const k=hc(this,f);if((null===g?l:g)!==(null===h?k:h))return!0;if(g===h&&l!==k)return e=b.firstChild,null==e&&q(20),a=g=document.createElement(k),mc(d,a,this),c=c.theme.text,void 0!==c&&lc(k,0,f,a,c),b.replaceChild(g,e),!1;l=b;null!==h&&null!==g&&(l=b.firstChild,null==
113
- l&&q(21));mc(d,l,this);c=c.theme.text;void 0!==c&&e!==f&&lc(k,e,f,l,c);f=this.__style;a.__style!==f&&(b.style.cssText=f);return!1}selectionTransform(){}setFormat(a){H();const b=this.getWritable();this.getWritable().__format=a;return b}setStyle(a){H();const b=this.getWritable();this.getWritable().__style=a;return b}toggleFormat(a){a=p[a];return this.setFormat(this.getFormat()^a)}toggleDirectionless(){const a=this.getWritable();a.__detail^=1;return a}toggleUnmergeable(){const a=this.getWritable();a.__detail^=
114
- 2;return a}setMode(a){a=da[a];const b=this.getWritable();b.__mode=a;return b}setTextContent(a){H();const b=this.getWritable();b.__text=a;return b}select(a,b){H();const c=t();var d=this.getTextContent();const e=this.__key;"string"===typeof d?(d=d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(null===c)return Va(e,a,e,b,"text","text");d=J();d!==c.anchor.key&&d!==c.focus.key||G(e);c.setTextNodeRange(this,a,this,b);return c}spliceText(a,b,c,d){H();const e=this.getWritable(),f=e.__text,g=c.length;
115
- let h=a;0>h&&(h=g+h,0>h&&(h=0));const l=t();d&&null!==l&&(a+=g,l.setTextNodeRange(e,a,e,a));b=f.slice(0,h)+c+f.slice(h+b);return e.setTextContent(b)}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...a){H();var b=this.getLatest(),c=b.getTextContent(),d=b.__key,e=J(),f=new Set(a);a=[];var g=c.length,h="";for(var l=0;l<g;l++)""!==h&&f.has(l)&&(a.push(h),h=""),h+=c[l];""!==h&&a.push(h);f=a.length;if(0===f)return[];if(a[0]===c)return[b];var k=a[0];c=b.getParentOrThrow();l=c.__key;
116
- const m=b.getFormat(),n=b.getStyle(),r=b.__detail;g=!1;b.isSegmented()?(h=P(k),h.__parent=l,h.__format=m,h.__style=n,h.__detail=r,g=!0):(h=b.getWritable(),h.__text=k);b=t();h=[h];k=k.length;for(let x=1;x<f;x++){var u=a[x],w=u.length;u=P(u).getWritable();u.__format=m;u.__style=n;u.__detail=r;const B=u.__key;w=k+w;if(null!==b){const y=b.anchor,L=b.focus;y.key===d&&"text"===y.type&&y.offset>k&&y.offset<=w&&(y.key=B,y.offset-=k,b.dirty=!0);L.key===d&&"text"===L.type&&L.offset>k&&L.offset<=w&&(L.key=B,
117
- L.offset-=k,b.dirty=!0)}e===d&&G(B);k=w;u.__parent=l;h.push(u)}F(this);e=c.getWritable().__children;d=e.indexOf(d);a=h.map(x=>x.__key);g?(e.splice(d,0,...a),this.remove()):e.splice(d,1,...a);null!==b&&Xa(b,c,d,f-1);return h}mergeWithSibling(a){const b=a===this.getPreviousSibling();b||a===this.getNextSibling()||q(22);const c=this.__key,d=a.__key,e=this.__text,f=e.length;J()===d&&G(c);const g=t();if(null!==g){const h=g.anchor,l=g.focus;null!==h&&h.key===d&&(ab(h,b,c,a,f),g.dirty=!0);null!==l&&l.key===
118
- d&&(ab(l,b,c,a,f),g.dirty=!0)}this.setTextContent(b?a.__text+e:e+a.__text);a.remove();return this.getLatest()}}function P(a=""){return new gc(a)}function z(a){return a instanceof gc}exports.$createLineBreakNode=Sa;exports.$createNodeFromParse=function(a,b){H();const c=D();return Sb(a,b,c,null)};exports.$createSelection=function(){const a=O("root",0,"element"),b=O("root",0,"element");return new Qa(a,b,0)};exports.$createTextNode=P;exports.$flushMutations=function(){H();const a=D();ra(a)};
119
- exports.$getCompositionKey=J;exports.$getNearestNodeFromDOMNode=oa;exports.$getNodeByKey=I;exports.$getPreviousSelection=function(){return D()._editorState._selection};exports.$getRoot=Ia;exports.$getSelection=t;exports.$isDecoratorNode=v;exports.$isElementNode=E;exports.$isLeafNode=Ca;exports.$isLineBreakNode=Da;exports.$isRootNode=R;exports.$isTextNode=z;exports.$log=na;exports.$setCompositionKey=G;exports.$setSelection=qa;exports.DecoratorNode=jb;exports.ElementNode=eb;exports.TextNode=gc;
120
- exports.VERSION="0.1.1";exports.createDecoratorEditor=gb;exports.createDecoratorMap=ib;exports.createEditor=function(a){var b=a||{};a=b.theme||{};const c=b.context||{},d=b.parentEditor||null,e=b.htmlTransforms||{},f=mb();b=b.initialEditorState;a=new fc(f,d,{context:c,theme:a,htmlTransforms:e});void 0!==b&&(a._pendingEditorState=b,a._dirtyType=2);return a};exports.isDecoratorEditor=function(a){return a instanceof fb};exports.isDecoratorMap=function(a){return a instanceof hb};
86
+ function Xb(a,b){var c=Ib.get(a),d=Jb.get(a);void 0!==c&&void 0!==d||p(43);var e=Db||Hb.has(a)||Gb.has(a);const f=Yb(Y,a);if(c===d&&!e)return B(c)?(d=f.__lexicalTextContent,void 0!==d&&(V+=d,X+=d),d=f.__lexicalDirTextContent,void 0!==d&&(W+=d)):y(c)||(d=c.getTextContent(),z(c)&&!c.isDirectionless()&&(W+=d),X+=d,V+=d),f;if(d.updateDOM(c,f,Cb))return d=Rb(a,null,null),null===b&&p(44),b.replaceChild(d,f),Lb(a,null),d;if(B(c)&&B(d)){if(a=d.__indent,a!==c.__indent&&Pb(f,a),a=d.__format,a!==c.__format&&Qb(f,
87
+ a),c=c.__children,a=d.__children,c!==a||e){var g=c,h=a;e=d;b=W;W="";const u=V;V="";var l=g.length,k=h.length;if(1===l&&1===k){var m=g[0];h=h[0];if(m===h)Xb(m,f);else{var n=Mb(m);h=Rb(h,null,null);f.replaceChild(h,n);Lb(m,null)}}else if(0===l)0!==k&&Sb(h,0,k-1,f,null);else if(0===k)0!==l&&(m=null==f.__lexicalLineBreak,Nb(g,0,l-1,m?null:f),m&&(f.textContent=""));else{const x=l-1;l=k-1;let v=f.firstChild,A=0;for(k=0;A<=x&&k<=l;){var q=g[A];const w=h[k];if(q===w)v=Xb(w,f).nextSibling,A++,k++;else{void 0===
88
+ m&&(m=new Set(g));void 0===n&&(n=new Set(h));const N=n.has(q),Ha=m.has(w);N?(Ha?(q=Yb(Y,w),q===v?v=Xb(w,f).nextSibling:(null!=v?f.insertBefore(q,v):f.appendChild(q),Xb(w,f)),A++):Rb(w,f,v),k++):(v=Mb(q).nextSibling,Lb(q,f),A++)}}m=A>x;n=k>l;m&&!n?(m=h[l+1],m=void 0===m?null:Y.getElementByKey(m),Sb(h,k,l,f,m)):n&&!m&&Nb(g,A,x,f)}f.__lexicalTextContent=V;V=u+V;Tb(e,f);W=b;S(d)||Ub(c,a,f)}}else y(d)?(c=d.decorate(Y),null!==c&&Vb(a,c)):(c=d.getTextContent(),z(d)&&!d.isDirectionless()&&(W+=c),V+=c,X+=
89
+ c);!Eb&&S(d)&&d.__cachedText!==X&&(d=d.getWritable(),d.__cachedText=X);return f}function Vb(a,b){let c=Y._pendingDecorators;const d=Y._decorators;if(null===c){if(d[a]===b)return;c=Oa(Y)}c[a]=b}function Mb(a){a=Kb.get(a);void 0===a&&p(45);return a}function Yb(a,b){a=a._keyToDOMMap.get(b);void 0===a&&p(45);return a}function Zb(a,b,c,d,e){a=a.__children;const f=a.length;for(let g=0;g<f;g++){const h=a[g],l=d.get(h);void 0!==l&&l.__parent===b&&(B(l)&&Zb(l,h,c,d,e),c.has(h)||e.delete(h),d.delete(h))}}
90
+ function $b(a,b,c,d){var e=Array.from(c),f=e.length;const g=Array.from(d),h=g.length;a=a._nodeMap;b=b._nodeMap;for(let l=0;l<f;l++){const k=e[l],m=b.get(k);void 0===m||m.isAttached()||(a.has(k)||c.delete(k),b.delete(k))}for(c=0;c<h;c++)e=g[c][0],f=b.get(e),void 0===f||f.isAttached()||(B(f)&&Zb(f,e,a,b,d),a.has(e)||d.delete(e),b.delete(e))}
91
+ function ac(a,b){if("string"===typeof b||"number"===typeof b||"boolean"===typeof b||null===b)var c=b;else if("object"===typeof b)if(c=b.type,"editor"===c)c=sb(b.id,b.editorState);else if("array"===c){b=b.array;c=[];for(let d=0;d<b.length;d++)c.push(ac(a,b[d]));c=wb(a,c)}else c=bc(a,b);else p(48);return c}function bc(a,b){b=b.map;const c=new Map;for(let d=0;d<b.length;d++){const [e,f]=b[d];c.set(e,ac(a,f))}return ub(a,c)}
92
+ function gc(a,b,c,d,e={}){var f=a.__type,g=c._registeredNodes.get(f);void 0===g&&p(24,f);f=g.klass;g=a.__key;a.__key=void 0;f=f.clone(a);a.__key=g;g=f.__key;S(f)&&F()._nodeMap.set("root",f);f.__parent=d;if(B(f)){d=a.__children;for(let l=0;l<d.length;l++){var h=b.get(d[l]);void 0!==h&&(h=gc(h,b,c,g,e).getKey(),f.__children.push(h))}f.__indent=a.__indent;f.__format=a.__format;f.__dir=a.__dir}else z(f)?(f.__format=a.__format,f.__style=a.__style,f.__mode=a.__mode,f.__detail=a.__detail):y(f)&&(f.__state=
93
+ bc(c,a.__state));b=null!=e?e.originalSelection:void 0;null!=b&&(a.__key===b.anchor.key&&(e.remappedSelection=e.remappedSelection||{anchor:{...b.anchor},focus:{...b.focus}},e.remappedSelection.anchor.key=f.__key),a.__key===b.focus.key&&(e.remappedSelection=e.remappedSelection||{anchor:{...b.anchor},focus:{...b.focus}},e.remappedSelection.focus.key=f.__key));return f}
94
+ function hc(a,b){const c=a.__mode,d=a.__format;a=a.__style;const e=b.__mode,f=b.__format;b=b.__style;return(null===c||c===e)&&(null===d||d===f)&&(null===a||a===b)}function ic(a,b){const c=a.mergeWithSibling(b),d=G()._normalizedNodes;d.add(a.__key);d.add(b.__key);return c}
95
+ function jc(a){if(""===a.__text&&a.isSimpleText()&&!a.isUnmergeable())a.remove();else{for(var b;null!==(b=a.getPreviousSibling())&&z(b)&&b.isSimpleText()&&!b.isUnmergeable();)if(""===b.__text)b.remove();else{hc(b,a)&&(a=ic(b,a));break}for(var c;null!==(c=a.getNextSibling())&&z(c)&&c.isSimpleText()&&!c.isUnmergeable();)if(""===c.__text)c.remove();else{hc(a,c)&&ic(a,c);break}}}let T=null,U=null,P=!1,kc=!1,Na=0;function J(){P&&p(25)}function F(){null===T&&p(27);return T}
96
+ function G(){null===U&&p(28);return U}function lc(a,b,c){var d=b.__type;const e=a._registeredNodes.get(d);void 0===e&&p(23,d);a=c.get(d);void 0===a&&(a=Array.from(e.transforms),c.set(d,a));c=a.length;for(d=0;d<c&&(a[d](b),b.isAttached());d++);}function mc(a,b){var c=b._dirtyLeaves;a=a._nodeMap;b=c.size;c=Array.from(c);for(let d=0;d<b;d++){const e=a.get(c[d]);z(e)&&e.isSimpleText()&&!e.isUnmergeable()&&jc(e)}}
97
+ function nc(a,b){const c=b._dirtyLeaves,d=b._dirtyElements;a=a._nodeMap;const e=L(),f=new Map;var g=c,h=g.size,l=d;let k=l.size;for(;0<h||0<k;){if(0<h){b._dirtyLeaves=new Set;g=Array.from(g);for(var m=0;m<h;m++){var n=g[m];const q=a.get(n);z(q)&&q.isSimpleText()&&!q.isUnmergeable()&&jc(q);void 0!==q&&void 0!==q&&q.__key!==e&&q.isAttached()&&lc(b,q,f);c.add(n)}g=b._dirtyLeaves;h=g.size;if(0<h){Na++;continue}}b._dirtyLeaves=new Set;b._dirtyElements=new Map;h=Array.from(l);for(l=0;l<k;l++)m=h[l],g=m[0],
98
+ m=m[1],"root"!==g&&m&&(m=h[l][1],n=a.get(g),void 0!==n&&void 0!==n&&n.__key!==e&&n.isAttached()&&lc(b,n,f),d.set(g,m));g=b._dirtyLeaves;h=g.size;l=b._dirtyElements;k=l.size;Na++}b._dirtyLeaves=c;b._dirtyElements=d}
99
+ function Z(a){var b=a._pendingEditorState,c=a._rootElement;if(null!==c&&null!==b){var d=a._editorState,e=d._selection,f=b._selection,g=0!==a._dirtyType;a._pendingEditorState=null;a._editorState=b;var h=T,l=P,k=U,m=a._updating;U=a;T=b;P=!1;a._updating=!0;try{var n=a._observer;if(g&&null!==n){var q=a._dirtyType,u=a._dirtyElements,x=a._dirtyLeaves;n.disconnect();try{W=X=V="",Db=2===q,Fb=null,Y=a,Cb=a._config,Gb=u,Hb=x,Ib=d._nodeMap,Jb=b._nodeMap,Eb=b._readOnly,Kb=new Map(a._keyToDOMMap),Xb("root",null),
100
+ Kb=Cb=Jb=Ib=Hb=Gb=Y=void 0}finally{n.observe(c,{childList:!0,subtree:!0,characterData:!0})}}const aa=window.getSelection();if(null!==aa&&(g||null===f||f.dirty)){n=aa;const Ia=n.anchorNode,cc=n.focusNode,Ic=n.anchorOffset,Jc=n.focusOffset,Ja=document.activeElement,ba=a._rootElement;if(!a._updateTags.has("collaboration")||Ja===ba)if(null===f)null!==e&&Da(a,Ia,cc)&&n.removeAllRanges();else{var v=f.anchor,A=f.focus,w=A.key,N=Yb(a,v.key),Ha=Yb(a,w),dc=v.offset,ec=A.offset;e=N;w=Ha;"text"===v.type&&(e=
101
+ Ea(N));"text"===A.type&&(w=Ea(Ha));if(null!==e&&null!==w)if(Ic===dc&&Jc===ec&&Ia===e&&cc===w)null===ba||null!==Ja&&ba.contains(Ja)||ba.focus({preventScroll:!0});else try{if(n.setBaseAndExtent(e,dc,w,ec),f.isCollapsed()&&ba===Ja){const ca=3===e.nodeType?e.parentNode:e;if(null!==ca){const Ka=ca.getBoundingClientRect();if(Ka.bottom>window.innerHeight)ca.scrollIntoView(!1);else if(0>Ka.top)ca.scrollIntoView();else if(ba){const fc=ba.getBoundingClientRect();Ka.bottom>fc.bottom?ca.scrollIntoView(!1):Ka.top<
102
+ fc.top&&ca.scrollIntoView()}}}}catch(ca){}}}}catch(aa){oc("error",a,!1,aa,aa._log);kc||(pc(a,null,c,b),va(a),a._dirtyType=2,kc=!0,a._log.push("ReconcileRecover"),Z(a),kc=!1);return}finally{a._updating=m,T=h,P=l,U=k}b._readOnly=!0;c=a._dirtyLeaves;f=a._dirtyElements;h=a._normalizedNodes;l=a._updateTags;k=a._log;a._log=[];g&&(a._dirtyType=0,a._cloneNotNeeded.clear(),a._dirtyLeaves=new Set,a._dirtyElements=new Map,a._normalizedNodes=new Set,a._updateTags=new Set);g=a._decorators;m=a._pendingDecorators||
103
+ g;v=b._nodeMap;for(var O in m)v.has(O)||(m===g&&(m=Oa(a)),delete m[O]);O=a._pendingDecorators;null!==O&&(a._decorators=O,a._pendingDecorators=null,oc("decorator",a,!0,O));O=Pa(d);g=Pa(b);O!==g&&oc("textcontent",a,!0,g);oc("update",a,!0,{tags:l,normalizedNodes:h,prevEditorState:d,editorState:b,dirtyLeaves:c,dirtyElements:f,log:k});b=a._deferred;a._deferred=[];if(0!==b.length){d=a._updating;a._updating=!0;try{for(O=0;O<b.length;O++)b[O]()}finally{a._updating=d}}b=a._updates;if(0!==b.length){const [aa,
104
+ Ia]=b.shift();qc(a,aa,!1,Ia)}}}function oc(a,b,c,...d){const e=b._updating;b._updating=c;try{const f=Array.from(b._listeners[a]);for(a=0;a<f.length;a++)f[a](...d)}finally{b._updating=e}}function rc(a,b,c){if(!1===a._updating||U!==a){let e=!1;a.update(()=>{e=rc(a,b,c)});return e}const d=Sa(a);for(let e=4;0<=e;e--)for(let f=0;f<d.length;f++){const g=Array.from(d[f]._listeners.command[e]);for(let h=0;h<g.length;h++)if(!0===g[h](b,c,a))return!0}return!1}
105
+ function sc(a){const b=a._updates;let c=!1;for(;0!==b.length;){const [d,e]=b.shift();let f,g;void 0!==e&&(f=e.onUpdate,g=e.tag,e.skipTransforms&&(c=!0),f&&a._deferred.push(f),g&&a._updateTags.add(g));d()}return c}
106
+ function qc(a,b,c,d){const e=a._updateTags;var f=!1;if(void 0!==d){var g=d.onUpdate;f=d.tag;null!=f&&e.add(f);f=d.skipTransforms}g&&a._deferred.push(g);d=a._editorState;g=a._pendingEditorState;let h=!1;null===g&&(g=a._pendingEditorState=new Bb(new Map(d._nodeMap)),h=!0);const l=T,k=P,m=U,n=a._updating;T=g;P=!1;a._updating=!0;U=a;try{h&&(g._selection=hb(a));const q=a._compositionKey;b();f=sc(a);kb(g,a);0!==a._dirtyType&&(!c&&g.isEmpty()&&p(29),f?mc(g,a):nc(g,a),sc(a),$b(d,g,a._dirtyLeaves,a._dirtyElements));
107
+ q!==a._compositionKey&&(g._flushSync=!0);const u=g._selection;if(null!==u){const x=g._nodeMap,v=u.focus.key;void 0!==x.get(u.anchor.key)&&void 0!==x.get(v)||p(30)}}catch(q){oc("error",a,!1,q,a._log);a._pendingEditorState=d;a._dirtyType=2;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();a._log.push("UpdateRecover");Z(a);return}finally{T=l,P=k,U=m,a._updating=n,Na=0}0!==a._dirtyType||zb(g,a)?g._flushSync?(g._flushSync=!1,Z(a)):h&&Ca(()=>{Z(a)}):(g._flushSync=!1,h&&(e.clear(),
108
+ a._deferred=[],a._pendingEditorState=null))}function oa(a,b,c,d){a._updating?a._updates.push([b,d]):qc(a,b,c,d)}class tc extends ob{static getType(){return"linebreak"}static clone(a){return new tc(a.__key)}constructor(a){super(a)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}}function db(){return new tc}function La(a){return a instanceof tc}
109
+ class uc extends ob{static getType(){return"horizontal-rule"}static clone(a){return new uc(a.__key)}constructor(a){super(a)}createDOM(){const a=document.createElement("hr");a.setAttribute("contenteditable","false");return a}updateDOM(){return!1}}function Ma(a){return a instanceof uc}function vc(a,b){return b&1?"strong":b&2?"em":"span"}
110
+ function wc(a,b,c,d,e){a=d.classList;d=Xa(e,"base");void 0!==d&&a.add(...d);d=Xa(e,"underlineStrikethrough");let f=!1;const g=b&8&&b&4;var h=c&8&&c&4;void 0!==d&&(h?(f=!0,g||a.add(...d)):g&&a.remove(...d));for(const l in fa)h=fa[l],d=Xa(e,l),void 0!==d&&(c&h?!f||"underline"!==l&&"strikethrough"!==l?(0===(b&h)||g&&"underline"===l||"strikethrough"===l)&&a.add(...d):b&h&&a.remove(...d):b&h&&a.remove(...d))}
111
+ function xc(a,b,c){const d=b.firstChild;c=c.isComposing()?"\u00a0":"";a+=c;null==d?b.textContent=a:d.nodeValue!==a&&(d.nodeValue=a)}
112
+ class yc extends ob{static getType(){return"text"}static clone(a){return new yc(a.__text,a.__key)}constructor(a,b){super(b);this.__text=a;this.__format=0;this.__style="";this.__detail=this.__mode=0}getFormat(){return this.getLatest().__format}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isSegmented(){return 2===this.getLatest().__mode}isInert(){return 3===this.getLatest().__mode}isDirectionless(){return 0!==(this.getLatest().__detail&1)}isUnmergeable(){return 0!==
113
+ (this.getLatest().__detail&2)}hasFormat(a){a=fa[a];return 0!==(this.getFormat()&a)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(a,b){return!a&&this.isInert()||!1===b&&this.isDirectionless()?"":this.getLatest().__text}getFormatFlags(a,b){const c=this.getLatest().__format;return Fa(c,a,b)}createDOM(a){var b=this.__format,c=b&16?"code":null;const d=vc(this,b),e=document.createElement(null===c?d:c);let f=e;null!==c&&(f=document.createElement(d),e.appendChild(f));c=f;xc(this.__text,
114
+ c,this);a=a.theme.text;void 0!==a&&wc(d,0,b,c,a);b=this.__style;""!==b&&(e.style.cssText=b);return e}updateDOM(a,b,c){const d=this.__text;var e=a.__format,f=this.__format,g=e&16?"code":null;const h=f&16?"code":null;var l=vc(this,e);const k=vc(this,f);if((null===g?l:g)!==(null===h?k:h))return!0;if(g===h&&l!==k)return e=b.firstChild,null==e&&p(20),a=g=document.createElement(k),xc(d,a,this),c=c.theme.text,void 0!==c&&wc(k,0,f,a,c),b.replaceChild(g,e),!1;l=b;null!==h&&null!==g&&(l=b.firstChild,null==
115
+ l&&p(21));xc(d,l,this);c=c.theme.text;void 0!==c&&e!==f&&wc(k,e,f,l,c);f=this.__style;a.__style!==f&&(b.style.cssText=f);return!1}selectionTransform(){}setFormat(a){J();const b=this.getWritable();this.getWritable().__format=a;return b}setStyle(a){J();const b=this.getWritable();this.getWritable().__style=a;return b}toggleFormat(a){a=fa[a];return this.setFormat(this.getFormat()^a)}toggleDirectionless(){const a=this.getWritable();a.__detail^=1;return a}toggleUnmergeable(){const a=this.getWritable();
116
+ a.__detail^=2;return a}setMode(a){a=ia[a];const b=this.getWritable();b.__mode=a;return b}setTextContent(a){J();const b=this.getWritable();b.__text=a;return b}select(a,b){J();const c=r();var d=this.getTextContent();const e=this.__key;"string"===typeof d?(d=d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(null===c)return gb(e,a,e,b,"text","text");d=L();d!==c.anchor.key&&d!==c.focus.key||I(e);c.setTextNodeRange(this,a,this,b);return c}spliceText(a,b,c,d){J();const e=this.getWritable(),f=e.__text,
117
+ g=c.length;let h=a;0>h&&(h=g+h,0>h&&(h=0));const l=r();d&&null!==l&&(a+=g,l.setTextNodeRange(e,a,e,a));b=f.slice(0,h)+c+f.slice(h+b);return e.setTextContent(b)}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...a){J();var b=this.getLatest(),c=b.getTextContent(),d=b.__key,e=L(),f=new Set(a);a=[];var g=c.length,h="";for(var l=0;l<g;l++)""!==h&&f.has(l)&&(a.push(h),h=""),h+=c[l];""!==h&&a.push(h);f=a.length;if(0===f)return[];if(a[0]===c)return[b];var k=a[0];c=b.getParentOrThrow();
118
+ l=c.__key;const m=b.getFormat(),n=b.getStyle(),q=b.__detail;g=!1;b.isSegmented()?(h=M(k),h.__parent=l,h.__format=m,h.__style=n,h.__detail=q,g=!0):(h=b.getWritable(),h.__text=k);b=r();h=[h];k=k.length;for(let v=1;v<f;v++){var u=a[v],x=u.length;u=M(u).getWritable();u.__format=m;u.__style=n;u.__detail=q;const A=u.__key;x=k+x;if(null!==b){const w=b.anchor,N=b.focus;w.key===d&&"text"===w.type&&w.offset>k&&w.offset<=x&&(w.key=A,w.offset-=k,b.dirty=!0);N.key===d&&"text"===N.type&&N.offset>k&&N.offset<=x&&
119
+ (N.key=A,N.offset-=k,b.dirty=!0)}e===d&&I(A);k=x;u.__parent=l;h.push(u)}H(this);e=c.getWritable().__children;d=e.indexOf(d);a=h.map(v=>v.__key);g?(e.splice(d,0,...a),this.remove()):e.splice(d,1,...a);null!==b&&ib(b,c,d,f-1);return h}mergeWithSibling(a){const b=a===this.getPreviousSibling();b||a===this.getNextSibling()||p(22);const c=this.__key,d=a.__key,e=this.__text,f=e.length;L()===d&&I(c);const g=r();if(null!==g){const h=g.anchor,l=g.focus;null!==h&&h.key===d&&(mb(h,b,c,a,f),g.dirty=!0);null!==
120
+ l&&l.key===d&&(mb(l,b,c,a,f),g.dirty=!0)}this.setTextContent(b?a.__text+e:e+a.__text);a.remove();return this.getLatest()}}function M(a=""){return new yc(a)}function z(a){return a instanceof yc}
121
+ class zc extends qb{static getType(){return"paragraph"}static clone(a){return new zc(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("p");a=Xa(a.theme,"paragraph");void 0!==a&&b.classList.add(...a);return b}updateDOM(){return!1}insertNewAfter(){const a=Ac(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){var a=this.getChildren();const b=this.getNextSibling();return B(b)&&0===this.getIndexWithinParent()&&(0===a.length||z(a[0])&&""===
122
+ a[0].getTextContent().trim())?(a=b.getFirstChild(),z(a)?a.select(0,0):b.select(0,0),this.remove(),!0):!1}}function Ac(){return new zc}const Bc={},Kc=[["selectionchange",Cc],["keydown",Dc],["compositionstart",Ec],["compositionend",Fc],["input",Gc],["click",Hc],["cut",Bc],["copy",Bc],["dragstart",Bc],["paste",Bc],["focus",Bc],["blur",Bc]];za?Kc.push(["beforeinput",Lc]):Kc.push(["drop",Bc]);let Mc=!1;
123
+ function Cc(a,b){const c=window.getSelection();a=Sa(b);(a=a[a.length-1].getRootElement())&&!a.contains(c.anchorNode)||b.update(()=>{t("onSelectionChange");if(Da(b,c.anchorNode,c.focusNode)){var d=r();if(null!==d&&d.isCollapsed()){var e=d.anchor;"text"===e.type?(e=e.getNode(),d.format=e.getFormat()):"element"===e.type&&(d.format=0)}b.execCommand("selectionChange")}})}
124
+ function Hc(a,b){b.update(()=>{t("onClick");const c=r();if(null!==c){var d=c.anchor;"element"===d.type&&0===d.offset&&c.isCollapsed()&&1===sa().getChildrenSize()&&d.getNode().getTopLevelElementOrThrow().isEmpty()&&(d=b.getEditorState()._selection,null!==d&&c.is(d)&&(window.getSelection().removeAllRanges(),c.dirty=!0))}})}
125
+ function Lc(a,b){const c=a.inputType;"deleteCompositionText"!==c&&"insertCompositionText"!==c&&b.update(()=>{t("onBeforeInputForRichText");const d=r();if(null!==d)if("deleteContentBackward"===c)I(null),a.preventDefault(),b.execCommand("deleteCharacter",!0);else{var e=a.data;if(!d.dirty&&d.isCollapsed()&&a.getTargetRanges){var f=a.getTargetRanges()[0];f&&d.applyDOMRange(f)}var g=d.focus;f=d.anchor.getNode();g=g.getNode();if("insertText"===c)"\n"===e?(a.preventDefault(),b.execCommand("insertLineBreak")):
126
+ "\n\n"===e?(a.preventDefault(),b.execCommand("insertParagraph")):null==e&&a.dataTransfer?(e=a.dataTransfer.getData("text/plain"),a.preventDefault(),d.insertRawText(e)):null!=e&&Wa(d,e,!0)&&(a.preventDefault(),b.execCommand("insertText",e));else switch(a.preventDefault(),c){case "insertFromYank":case "insertFromDrop":case "insertReplacementText":b.execCommand("insertText",a);break;case "insertFromComposition":I(null);b.execCommand("insertText",a);break;case "insertLineBreak":I(null);b.execCommand("insertLineBreak");
127
+ break;case "insertParagraph":I(null);b.execCommand("insertParagraph");break;case "insertFromPaste":case "insertFromPasteAsQuotation":b.execCommand("paste",a);break;case "deleteByComposition":f===g&&!B(f)&&!B(g)&&D(f)&&D(g)||b.execCommand("removeText");break;case "deleteByDrag":case "deleteByCut":b.execCommand("removeText");break;case "deleteContent":b.execCommand("deleteCharacter",!1);break;case "deleteWordBackward":b.execCommand("deleteWord",!0);break;case "deleteWordForward":b.execCommand("deleteWord",
128
+ !1);break;case "deleteHardLineBackward":case "deleteSoftLineBackward":b.execCommand("deleteLine",!0);break;case "deleteContentForward":case "deleteHardLineForward":case "deleteSoftLineForward":b.execCommand("deleteLine",!1);break;case "formatStrikeThrough":b.execCommand("formatText","strikethrough");break;case "formatBold":b.execCommand("formatText","bold");break;case "formatItalic":b.execCommand("formatText","italic");break;case "formatUnderline":b.execCommand("formatText","underline");break;case "historyUndo":b.execCommand("undo");
129
+ break;case "historyRedo":b.execCommand("redo")}}})}function Gc(a,b){a.stopPropagation();b.update(()=>{t("onInput");var c=r();const d=a.data;null!=d&&null!==c&&Wa(c,d,!1)?b.execCommand("insertText",d):Ua(b,!1);J();c=G();ua(c)})}function Ec(a,b){b.update(()=>{t("onCompositionStart");const c=r();if(null!==c&&!b.isComposing()){const d=c.anchor;I(d.key);Mc&&"element"!==d.type&&c.isCollapsed()||b.execCommand("insertText"," ")}})}function Nc(a,b){b.update(()=>{t("onCompositionEnd");I(null);Ua(b,!0)})}
130
+ function Fc(a,b){ya?setTimeout(()=>{Nc(a,b)},0):Nc(a,b)}
131
+ function Dc(a,b){Mc="Unidentified"===a.key&&229===a.keyCode;b.isComposing()||b.update(()=>{t("onKeyDown");if(null!==r()){var {keyCode:c,shiftKey:d,ctrlKey:e,metaKey:f,altKey:g}=a;if(39!==c||e||f||g)if(37!==c||e||f||g)if(38!==c||e||f)if(40!==c||e||f)if(13===c&&d)b.execCommand("keyEnter",a);else if(C&&e&&79===c)a.preventDefault(),b.execCommand("insertLineBreak",!0);else if(13!==c||d){var h=C?g||f?!1:8===c||72===c&&e:e||g||f?!1:8===c;h?8===c?b.execCommand("keyBackspace",a):b.execCommand("deleteCharacter",
132
+ !0):27===c?b.execCommand("keyEscape",a):(h=C?d||g||f?!1:46===c||68===c&&e:e||g||f?!1:46===c,h?46===c?b.execCommand("keyDelete",a):b.execCommand("deleteCharacter",!1):8===c&&(C?g:e)?(a.preventDefault(),b.execCommand("deleteWord",!0)):46===c&&(C?g:e)?(a.preventDefault(),b.execCommand("deleteWord",!1)):C&&f&&8===c?(a.preventDefault(),b.execCommand("deleteLine",!0)):C&&f&&46===c?(a.preventDefault(),b.execCommand("deleteLine",!1)):66===c&&(C?f:e)?(a.preventDefault(),b.execCommand("formatText","bold")):
133
+ 85===c&&(C?f:e)?(a.preventDefault(),b.execCommand("formatText","underline")):73===c&&(C?f:e)?(a.preventDefault(),b.execCommand("formatText","italic")):9!==c||g||e||f?90===c&&!d&&(C?f:e)?(a.preventDefault(),b.execCommand("undo")):(h=C?90===c&&f&&d:89===c&&e||90===c&&e&&d,h&&(a.preventDefault(),b.execCommand("redo"))):b.execCommand("keyTab",a))}else b.execCommand("keyEnter",a);else b.execCommand("keyArrowDown",a);else b.execCommand("keyArrowUp",a);else b.execCommand("keyArrowLeft",a);else b.execCommand("keyArrowRight",
134
+ a)}})}function Oc(a,b){return"selectionchange"===a||"keyup"===a||"pointerup"===a||"pointercancel"===a?b.ownerDocument:b}function Pc(a){a=a.getRootElement();return null!==a&&"true"===a.contentEditable}function Qc(a){let b=a._lexicalEventHandles;void 0===b&&(b=[],a._lexicalEventHandles=b);return b}
135
+ function Rc(a,b){const c=Qc(a);for(let d=0;d<Kc.length;d++){const [e,f]=Kc[d],g="function"===typeof f?h=>{Pc(b)&&f(h,b)}:h=>{Pc(b)&&b.execCommand(e,h)};Oc(e,a).addEventListener(e,g);c.push(()=>{Oc(e,a).removeEventListener(e,g)})}}
136
+ function pc(a,b,c,d){const e=a._keyToDOMMap;e.clear();a._editorState=Ab();a._pendingEditorState=d;a._compositionKey=null;a._dirtyType=0;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();a._normalizedNodes=new Set;a._updateTags=new Set;a._log=[];a._updates=[];d=a._observer;null!==d&&(d.disconnect(),a._observer=null);null!==b&&(b.textContent="");null!==c&&(c.textContent="",e.set("root",c))}
137
+ function Sc(a,b){const c=b.getType();let d=a.get(c);void 0===d&&(d={count:0,klass:b,transforms:new Set},a.set(c,d));const e=d;e.count++;return()=>{1===e.count?a.delete(c):e.count--}}
138
+ class Tc{constructor(a,b,c){this._parentEditor=b;this._rootElement=null;this._editorState=a;this._compositionKey=this._pendingEditorState=null;this._deferred=[];this._keyToDOMMap=new Map;this._updates=[];this._updating=!1;this._listeners={decorator:new Set,error:new Set,textcontent:new Set,root:new Set,update:new Set,command:[new Set,new Set,new Set,new Set,new Set]};this._config=c;this._registeredNodes=new Map;this.registerNodes([yb,yc,uc,tc,zc]);this._decorators={};this._pendingDecorators=null;
139
+ this._dirtyType=0;this._cloneNotNeeded=new Set;this._dirtyLeaves=new Set;this._dirtyElements=new Map;this._normalizedNodes=new Set;this._updateTags=new Set;this._observer=null;this._log=[];this._key=""+Aa++}isComposing(){return null!=this._compositionKey}registerNodes(a){const b=a.length,c=this._registeredNodes,d=[];for(let e=0;e<b;e++)d.push(Sc(c,a[e]));return()=>{for(let e=0;e<b;e++)d[e]()}}addListener(a,b,c){const d=this._listeners[a];if("command"===a){if(void 0===c)throw Error('Listener for type "command" requires a "priority".');
140
+ const f=d[c];f.add(b);return()=>{f.delete(b)}}d.add(b);const e="root"===a;e&&b(this._rootElement,null);return()=>{d.delete(b);e&&b(null,this._rootElement)}}addTransform(a,b){const c=a.getType(),d=this._registeredNodes.get(c);void 0===d&&p(18,a.name);const e=d.transforms;e.add(b);Qa(this,c);return()=>{e.delete(b)}}execCommand(a,b){return rc(this,a,b)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}setRootElement(a){const b=this._rootElement;if(a!==b){var c=this._pendingEditorState||
141
+ this._editorState;this._rootElement=a;pc(this,b,a,c);if(null!==b&&!this._config.disableEvents){c=Qc(b);for(let d=0;d<c.length;d++)c[d]();b._lexicalEventHandles=[]}null!==a&&(c=a.style,c.userSelect="text",c.whiteSpace="pre-wrap",c.overflowWrap="break-word",a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,va(this),this._updateTags.add("without-history"),Z(this),this._config.disableEvents||Rc(a,this));oc("root",this,!1,a,b)}}getElementByKey(a){return this._keyToDOMMap.get(a)||null}getEditorState(){return this._editorState}setEditorState(a,
142
+ b){a.isEmpty()&&p(19);ua(this);const c=this._pendingEditorState,d=this._updateTags;b=void 0!==b?b.tag:null;null===c||c.isEmpty()||(null!=b&&d.add(b),Z(this));this._pendingEditorState=a;this._dirtyType=2;this._compositionKey=null;null!=b&&d.add(b);Z(this)}parseEditorState(a){const b=JSON.parse(a);a=new Map;a=new Bb(a);const c={originalSelection:b._selection},d=P,e=U;T=a;P=!1;U=this;try{var f=new Map(b._nodeMap);const g=f.get("root");gc(g,f,this,null,c)}finally{T=a,P=d,U=e}f=c.remappedSelection||c.originalSelection;
143
+ f=null===f?null:new bb(Q(f.anchor.key,f.anchor.offset,f.anchor.type),Q(f.focus.key,f.focus.offset,f.focus.type),0);a._selection=f;return a}update(a,b){oa(this,a,!1,b)}focus(a){const b=this._rootElement;null!==b&&(b.setAttribute("autocapitalize","off"),oa(this,()=>{const c=r(),d=sa();null!==c?c.dirty=!0:0!==d.getChildrenSize()&&d.selectEnd()},!0,{onUpdate:()=>{b.removeAttribute("autocapitalize");a&&a()}}))}blur(){const a=this._rootElement;null!==a&&a.blur()}}exports.$createHorizontalRuleNode=function(){return new uc};
144
+ exports.$createLineBreakNode=db;exports.$createNodeFromParse=function(a,b){J();const c=G();return gc(a,b,c,null)};exports.$createParagraphNode=Ac;exports.$createSelection=function(){const a=Q("root",0,"element"),b=Q("root",0,"element");return new bb(a,b,0)};exports.$createTextNode=M;exports.$getCompositionKey=L;exports.$getNearestNodeFromDOMNode=pa;exports.$getNodeByKey=K;exports.$getPreviousSelection=Va;exports.$getRoot=sa;exports.$getSelection=r;exports.$isDecoratorNode=y;
145
+ exports.$isElementNode=B;exports.$isHorizontalRuleNode=Ma;exports.$isLeafNode=Ga;exports.$isLineBreakNode=La;exports.$isParagraphNode=function(a){return a instanceof zc};exports.$isRootNode=S;exports.$isTextNode=z;exports.$log=t;exports.$setCompositionKey=I;exports.$setSelection=ta;exports.DecoratorNode=xb;exports.ElementNode=qb;exports.ParagraphNode=zc;exports.TextNode=yc;exports.VERSION="0.1.6";exports.createDecoratorArray=wb;exports.createDecoratorEditor=sb;exports.createDecoratorMap=ub;
146
+ exports.createEditor=function(a){var b=a||{};a=b.namespace||Ta();const c=b.theme||{},d=b.context||{},e=b.parentEditor||null,f=b.htmlTransforms||{},g=b.disableEvents||!1,h=Ab();b=b.initialEditorState;a=new Tc(h,e,{context:d,namespace:a,theme:c,htmlTransforms:f,disableEvents:g});void 0!==b&&(a._pendingEditorState=b,a._dirtyType=2);return a};exports.isDecoratorArray=function(a){return a instanceof vb};exports.isDecoratorEditor=function(a){return a instanceof rb};
147
+ exports.isDecoratorMap=function(a){return a instanceof tb};
package/LinkNode.js CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict';var d=require("lexical");function e(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}
2
- class f extends d.ElementNode{static getType(){return"link"}static clone(a){return new f(a.__url,a.__key)}constructor(a,b){super(b);this.__url=a}createDOM(a){const b=document.createElement("a");b.href=this.__url;e(b,a.theme.link);return b}updateDOM(a,b){const c=this.__url;c!==a.__url&&(b.href=c);return!1}getURL(){return this.getLatest().__url}setURL(a){this.getWritable().__url=a}insertNewAfter(a){a=this.getParentOrThrow().insertNewAfter(a);if(null!==a){const b=g(this.__url);a.append(b);return b}return null}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}}
3
- function g(a){return new f(a)}exports.$createLinkNode=g;exports.$isLinkNode=function(a){return a instanceof f};exports.LinkNode=f;
2
+ class f extends d.ElementNode{static getType(){return"link"}static clone(a){return new f(a.__url,a.__key)}constructor(a,b){super(b);this.__url=a}createDOM(a){const b=document.createElement("a");b.href=this.__url;e(b,a.theme.link);return b}updateDOM(a,b){const c=this.__url;c!==a.__url&&(b.href=c);return!1}getURL(){return this.getLatest().__url}setURL(a){this.getWritable().__url=a}insertNewAfter(a){a=this.getParentOrThrow().insertNewAfter(a);if(d.$isElementNode(a)){const b=g(this.__url);a.append(b);
3
+ return b}return null}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}}function g(a){return new f(a)}exports.$createLinkNode=g;exports.$isLinkNode=function(a){return a instanceof f};exports.LinkNode=f;
package/ListItemNode.js CHANGED
@@ -1,8 +1,8 @@
1
- 'use strict';var f=require("lexical"),g=require("lexical/ParagraphNode"),l=require("lexical/ListNode"),m=require("lexical/ListItemNode");function n(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}function p(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}function q(a,...b){b.forEach(c=>{a.classList.remove(...c.split(" "))})}
2
- class r extends f.ElementNode{static getType(){return"listitem"}static clone(a){return new r(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("li");b.value=t(this);u(b,a.theme,this);return b}updateDOM(a,b,c){b.value=t(this);u(b,c.theme,this);return!1}append(...a){for(let b=0;b<a.length;b++){const c=a[b];if(f.$isElementNode(c)&&this.canMergeWith(c)){const d=c.getChildren();this.append(...d);c.remove()}else super.append(c)}return this}replace(a){if(v(a))return super.replace(a);
3
- const b=this.getParentOrThrow();if(l.$isListNode(b)){var c=b.__children;const e=c.length;var d=c.indexOf(this.__key);if(0===d)b.insertBefore(a);else if(d===e-1)b.insertAfter(a);else{c=l.$createListNode(b.__tag);const h=b.getChildren();for(d+=1;d<e;d++)c.append(h[d]);b.insertAfter(a);a.insertAfter(c)}this.remove();1===e&&b.remove()}return a}insertAfter(a){var b=this.getNextSiblings();if(v(a))return b.forEach(d=>d.markDirty()),super.insertAfter(a);var c=this.getParentOrThrow();l.$isListNode(c)||n(1);
4
- if(l.$isListNode(a)&&a.getTag()===c.getTag()){b=a;a=a.getChildren();for(c=a.length-1;0<=c;c--)b=a[c],this.insertAfter(b);return b}c.insertAfter(a);if(0!==b.length){const d=l.$createListNode(c.getTag());b.forEach(e=>d.append(e));a.insertAfter(d)}return a}insertNewAfter(){var a=this.getNextSibling(),b=this.getPreviousSibling();var c=this.getParent();l.$isListNode(c)||n(2);for(var d=c;null!==d;)d=d.getParent(),l.$isListNode(d)&&(c=d);d=!0;var e=this.getFirstChild();if(l.$isListNode(e))d=!1;else for(e=
5
- this;null!==e;)m.$isListItemNode(e)&&0<e.getNextSiblings().length&&(d=!1),e=e.getParent();if(f.$isElementNode(c)&&""===this.getTextContent()&&(null===b||null===a)&&d){null===a?(a=g.$createParagraphNode(),c.insertAfter(a)):(a=g.$createParagraphNode(),c.insertBefore(a));for(b=this;null==b.getNextSibling()&&null==b.getPreviousSibling();){c=b.getParent();if(null==c||!v(b)&&!l.$isListNode(b))break;b=c}b.remove()}else a=w(),this.insertAfter(a);return a}collapseAtStart(a){const b=g.$createParagraphNode();
6
- this.getChildren().forEach(h=>b.append(h));var c=this.getParentOrThrow(),d=c.getParentOrThrow();const e=v(d);1===c.getChildrenSize()?e?(c.remove(),d.select()):(c.replace(b),c=a.anchor,a=a.focus,d=b.getKey(),"element"===c.type&&c.getNode().is(this)&&c.set(d,c.offset,"element"),"element"===a.type&&a.getNode().is(this)&&a.set(d,a.offset,"element")):(c.insertBefore(b),this.remove());return!0}canInsertAfter(a){return v(a)}canReplaceWith(a){return v(a)}canMergeWith(a){return g.$isParagraphNode(a)||v(a)}}
7
- function t(a){var b=a.getParent();let c=1;if(null!=b)if(l.$isListNode(b))c=b.__start;else throw Error("getListItemValue: list node is not parent of list item node");a=a.getPreviousSiblings();for(b=0;b<a.length;b++){const d=a[b];v(d)&&!l.$isListNode(d.getFirstChild())&&c++}return c}
8
- function u(a,b,c){const d=[],e=[],h=(b=b.list)?b.listitem:void 0;if(b&&b.nested)var k=b.nested.listitem;void 0!==h&&(b=h.split(" "),d.push(...b));void 0!==k&&(k=k.split(" "),c.getChildren().some(x=>l.$isListNode(x))?d.push(...k):e.push(...k));0<d.length&&p(a,...d);0<e.length&&q(a,...e)}function w(){return new r}function v(a){return a instanceof r}exports.$createListItemNode=w;exports.$isListItemNode=v;exports.ListItemNode=r;
1
+ 'use strict';var f=require("lexical"),g=require("lexical/ListNode"),h=require("lexical/ListItemNode");function m(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}function n(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}function p(a,...b){b.forEach(c=>{a.classList.remove(...c.split(" "))})}
2
+ class q extends f.ElementNode{static getType(){return"listitem"}static clone(a){return new q(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("li");b.value=r(this);t(b,a.theme,this);return b}updateDOM(a,b,c){b.value=r(this);t(b,c.theme,this);return!1}append(...a){for(let b=0;b<a.length;b++){const c=a[b];if(f.$isElementNode(c)&&this.canMergeWith(c)){const d=c.getChildren();this.append(...d);c.remove()}else super.append(c)}return this}replace(a){if(u(a))return super.replace(a);
3
+ const b=this.getParentOrThrow();if(g.$isListNode(b)){var c=b.__children;const e=c.length;var d=c.indexOf(this.__key);if(0===d)b.insertBefore(a);else if(d===e-1)b.insertAfter(a);else{c=g.$createListNode(b.__tag);const k=b.getChildren();for(d+=1;d<e;d++)c.append(k[d]);b.insertAfter(a);a.insertAfter(c)}this.remove();1===e&&b.remove()}return a}insertAfter(a){var b=this.getNextSiblings();if(u(a))return b.forEach(d=>d.markDirty()),super.insertAfter(a);var c=this.getParentOrThrow();g.$isListNode(c)||m(1);
4
+ if(g.$isListNode(a)&&a.getTag()===c.getTag()){b=a;a=a.getChildren();for(c=a.length-1;0<=c;c--)b=a[c],this.insertAfter(b);return b}c.insertAfter(a);if(0!==b.length){const d=g.$createListNode(c.getTag());b.forEach(e=>d.append(e));a.insertAfter(d)}return a}insertNewAfter(){var a=this.getNextSibling(),b=this.getPreviousSibling();var c=this.getParent();g.$isListNode(c)||m(2);for(var d=c;null!==d;)d=d.getParent(),g.$isListNode(d)&&(c=d);d=!0;var e=this.getFirstChild();if(g.$isListNode(e))d=!1;else for(e=
5
+ this;null!==e;)h.$isListItemNode(e)&&0<e.getNextSiblings().length&&(d=!1),e=e.getParent();if(f.$isElementNode(c)&&""===this.getTextContent()&&(null===b||null===a)&&d){null===a?(a=f.$createParagraphNode(),c.insertAfter(a)):(a=f.$createParagraphNode(),c.insertBefore(a));for(b=this;null==b.getNextSibling()&&null==b.getPreviousSibling();){c=b.getParent();if(null==c||!u(b)&&!g.$isListNode(b))break;b=c}b.remove()}else a=v(),this.insertAfter(a);return a}collapseAtStart(a){const b=f.$createParagraphNode();
6
+ this.getChildren().forEach(k=>b.append(k));var c=this.getParentOrThrow(),d=c.getParentOrThrow();const e=u(d);1===c.getChildrenSize()?e?(c.remove(),d.select()):(c.replace(b),c=a.anchor,a=a.focus,d=b.getKey(),"element"===c.type&&c.getNode().is(this)&&c.set(d,c.offset,"element"),"element"===a.type&&a.getNode().is(this)&&a.set(d,a.offset,"element")):(c.insertBefore(b),this.remove());return!0}getIndent(){let a=this.getParentOrThrow().getParentOrThrow(),b=0;for(;u(a);)a=a.getParentOrThrow().getParentOrThrow(),
7
+ b++;return b}setIndent(){return this}insertBefore(a){const b=this.getNextSiblings();u(a)&&b.forEach(c=>c.markDirty());return super.insertBefore(a)}canInsertAfter(a){return u(a)}canReplaceWith(a){return u(a)}canMergeWith(a){return f.$isParagraphNode(a)||u(a)}}function r(a){var b=a.getParent();let c=1;null!=b&&(g.$isListNode(b)?c=b.__start:m(47));a=a.getPreviousSiblings();for(b=0;b<a.length;b++){const d=a[b];u(d)&&!g.$isListNode(d.getFirstChild())&&c++}return c}
8
+ function t(a,b,c){const d=[],e=[],k=(b=b.list)?b.listitem:void 0;if(b&&b.nested)var l=b.nested.listitem;void 0!==k&&(b=k.split(" "),d.push(...b));void 0!==l&&(l=l.split(" "),c.getChildren().some(w=>g.$isListNode(w))?d.push(...l):e.push(...l));0<d.length&&n(a,...d);0<e.length&&p(a,...e)}function v(){return new q}function u(a){return a instanceof q}exports.$createListItemNode=v;exports.$isListItemNode=u;exports.ListItemNode=q;
package/QuoteNode.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var c=require("lexical"),e=require("lexical/ParagraphNode");function f(a,...b){b.forEach(d=>{null!=d&&"string"===typeof d&&a.classList.add(...d.split(" "))})}
2
- class g extends c.ElementNode{static getType(){return"quote"}static clone(a){return new g(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("blockquote");f(b,a.theme.quote);return b}updateDOM(){return!1}insertNewAfter(){const a=e.$createParagraphNode(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=e.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}}exports.$createQuoteNode=function(){return new g};
3
- exports.$isQuoteNode=function(a){return a instanceof g};exports.QuoteNode=g;
1
+ 'use strict';var c=require("lexical");function d(a,...b){b.forEach(e=>{null!=e&&"string"===typeof e&&a.classList.add(...e.split(" "))})}
2
+ class f extends c.ElementNode{static getType(){return"quote"}static clone(a){return new f(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("blockquote");d(b,a.theme.quote);return b}updateDOM(){return!1}insertNewAfter(){const a=c.$createParagraphNode(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=c.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}}exports.$createQuoteNode=function(){return new f};
3
+ exports.$isQuoteNode=function(a){return a instanceof f};exports.QuoteNode=f;
package/README.md CHANGED
@@ -2,4 +2,152 @@
2
2
 
3
3
  Lexical is an extensible JavaScript text-editor that provides reliable, accessible and performant typing experiences for the web.
4
4
 
5
- The `lexical` package contains only the core Lexical engine and nodes. This package is intended to be used in conjunction with packages that wire Lexical up to applications, such as `@lexical/react`.
5
+ The core of Lexical is a dependency-free text editor engine that allows for powerful, simple and complex,
6
+ editor implementations to be built on top. Lexical's engine provides three main parts:
7
+ - editor instances that each attach to a single content editable element.
8
+ - a set of editor states that represent the current and pending states of the editor at any given time.
9
+ - a DOM reconciler that takes a set of editor states, diffs the changes, and updates the DOM according to their state.
10
+
11
+ By design, the core of Lexical tries to be as minimal as possible.
12
+ Lexical doesn't directly concern itself with things that monolithic editors tend to do – such as UI components, toolbars or rich-text features and markdown. Instead
13
+ the logic for those features can be included via a plugin interface and used as and when they're needed. This ensures great extensibilty and keeps code-sizes
14
+ to a minimal – ensuring apps only pay the cost for what they actually import.
15
+
16
+ For React apps, Lexical has tight intergration with React 18+ via the optional `@lexical/react` package. This package provides
17
+ production-ready utility functions, helpers and React hooks that make it seemless to create text editors within React.
18
+
19
+ ## Usage
20
+
21
+ The `lexical` package contains only the core Lexical engine and nodes. This package is intended to be used in conjunction with packages that wire Lexical up to applications, such as `@lexical/react`.
22
+
23
+ ## Working with Lexical
24
+
25
+ This section covers how to use Lexical, independently of any framework or library. For those intending to use Lexical in their React applications,
26
+ it's advisable to [check out the source-code for the hooks that are shipped in `@lexical/react`](https://github.com/facebook/lexical/tree/main/packages/lexical-react/src).
27
+
28
+ ### Creating an editor and using it
29
+
30
+ When you work with Lexical, you normally work with a single editor instance. An editor instance can be thought of as the one responsible
31
+ for wiring up an EditorState with the DOM. The editor is also the place where you can register custom nodes, add listeners, and transforms.
32
+
33
+ An editor instance can be created from the `lexical` package and accepts an optional configuration object that allows for theming and other options:
34
+
35
+ ```js
36
+ import {createEditor} from 'lexical';
37
+
38
+ const config = {
39
+ theme: {
40
+ ...
41
+ },
42
+ };
43
+
44
+ const editor = createEditor(config);
45
+ ```
46
+
47
+ Once you have an editor instance, when ready, you can associate the editor instance with a content editable `<div>` element in your document:
48
+
49
+ ```js
50
+ const contentEditableElement = document.getElementById('editor');
51
+
52
+ editor.setRootElement(contentEditableElement);
53
+ ```
54
+
55
+ If you want to clear the editor instance from the element, you can pass `null`. Alternatively, you can switch to another element if need be,
56
+ just pass an alternative element reference to `setRootElement()`.
57
+
58
+ ### Understanding the Editor State
59
+
60
+ With Lexical, the source of truth is not the DOM, but rather an underlying state model
61
+ that Lexical maintains and associates with an editor instance. You can get the latest
62
+ editor state from an editor by calling `editor.getEditorState()`.
63
+
64
+ Editor states have two phases:
65
+
66
+ - During an update they can be thought of as "mutable". See "Updating an editor" below to
67
+ mutate an editor state.
68
+ - After an update, the editor state is then locked and deemed immutable from there one. This
69
+ editor state can therefore be thought of as a "snapshot".
70
+
71
+ Editor states contain two core things:
72
+
73
+ - The editor node tree (starting from the root node).
74
+ - The editor selection (which can be null).
75
+
76
+ Editor states are serializable to JSON, and the editor instance provides a useful method
77
+ to deserialize stringified editor states.
78
+
79
+ ```js
80
+ const stringifiedEditorState = JSON.stringify(
81
+ editor.getEditorState().toJSON(),
82
+ );
83
+
84
+ const newEditorState = editor.parseEditorState(stringifiedEditorState);
85
+ ```
86
+
87
+ ### Updating an editor
88
+
89
+ There are a few ways to update an editor instance:
90
+
91
+ - Trigger an update with `editor.update()`
92
+ - Setting the editor state via `editor.setEditorState()`
93
+ - Applying a change as part of an existing update via `editor.addTransform()`
94
+ - Using a command listener with `editor.addListener('command', () => {...}, priority)`
95
+
96
+ The most common way to update the editor is to use `editor.update()`. Calling this function
97
+ requires a function to be passed in that will provide access to mutate the underlying
98
+ editor state. When starting a fresh update, the current editor state is cloned and
99
+ used as the starting point. From a technical perspective, this means that Lexical leverages a technique
100
+ called double-buffering during updates. There's an editor state to represent what is current on
101
+ the screen, and another work-in-progress editor state that represents future changes.
102
+
103
+ Creating an update is typically an async process that allows Lexical to batch multiple updates together in
104
+ a single update – improving performance. When Lexical is ready to commit the update to
105
+ the DOM, the underlying mutations and changes in the update will form a new immutable
106
+ editor state. Calling `editor.getEditorState()` will then return the latest editor state
107
+ based on the changes from the update.
108
+
109
+ Here's an example of how you can update an editor instance:
110
+
111
+ ```js
112
+ import {$getRoot, $getSelection} from 'lexical';
113
+ import {$createParagraphNode} from 'lexical/PargraphNode';
114
+
115
+ // Inside the `editor.update` you can use special $ prefixed helper functions.
116
+ // These functions cannot be used outside the closure, and will error if you try.
117
+ // (If you're familiar with React, you can imagine these to be a bit like using a hook
118
+ // outside of a React function component).
119
+ editor.update(() => {
120
+ // Get the RootNode from the EditorState
121
+ const root = $getRoot();
122
+
123
+ // Get the selection from the EditorState
124
+ const selection = $getSelection();
125
+
126
+ // Create a new ParagraphNode
127
+ const paragraphNode = $createParagraphNode();
128
+
129
+ // Create a new TextNode
130
+ const textNode = $createTextNode('Hello world');
131
+
132
+ // Append the text node to the paragraph
133
+ paragraphNode.append(textNode);
134
+
135
+ // Finally, append the paragraph to the root
136
+ root.append(paragraphNode);
137
+ });
138
+ ```
139
+
140
+ If you want to know when the editor updates so you can react to the changes, you can add an update
141
+ listener to the editor, as shown below:
142
+
143
+ ```js
144
+ editor.addListener('update', ({editorState}) => {
145
+ // The latest EditorState can be found as `editorState`.
146
+ // To read the contents of the EditorState, use the following API:
147
+
148
+ editorState.read(() => {
149
+ // Just like editor.update(), .read() expects a closure where you can use
150
+ // the $ prefixed helper functions.
151
+ });
152
+ });
153
+ ```
package/TableNode.js CHANGED
@@ -1,7 +1,15 @@
1
- 'use strict';var r=require("lexical");function v(a,...e){e.forEach(g=>{null!=g&&"string"===typeof g&&a.classList.add(...g.split(" "))})}const x=document.createElement("style");x.appendChild(document.createTextNode("::selection{background-color: transparent}"));function A(a){for(;null!=a;){const e=a.nodeName;if("TD"===e||"TH"===e){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null}
2
- function B(a){const e=[],g={rows:0,columns:0,cells:e};(new MutationObserver(b=>{var d=a.firstChild;let h=0,f=0,n=!1;for(let k=0;k<b.length;k++){const l=b[k].target.nodeName;if("TABLE"===l||"TR"===l){n=!0;break}}if(n){for(e.length=0;null!=d;){b=d.nodeName;if("TD"===b||"TH"===b)b={elem:d,highlighted:!1,x:h,y:f},d._cell=b,void 0===e[f]&&(e[f]=[]),e[f][h]=b;else if(b=d.firstChild,null!=b){d=b;continue}b=d.nextSibling;if(null!=b)h++,d=b;else if(b=d.parentNode,null!=b){d=b.nextSibling;if(null==d)break;
3
- f++;h=0}}g.columns=h+1;g.rows=f+1}})).observe(a,{childList:!0,subtree:!0});return g}function C(a,e,g,b,d){const h=[];for(let f=0;f<d.length;f++){const n=d[f];for(let k=0;k<n.length;k++){const l=n[k],q=l.elem.style;k>=a&&k<=e&&f>=g&&f<=b?(l.highlighted||(l.highlighted=!0,q.setProperty("background-color","rgb(163, 187, 255)"),q.setProperty("caret-color","transparent")),h.push(l)):l.highlighted&&(l.highlighted=!1,q.removeProperty("background-color"),q.removeProperty("caret-color"))}}return h}
4
- function D(a,e,g){const b=B(e);if(null!==g.getRootElement()){var d=!1,h=!1,f=-1,n=-1,k=-1,l=-1,q=[];e.addEventListener("mousemove",m=>{if(d){var c=A(m.target);if(null!==c){const t=c.x;c=c.y;if(!h&&(f!==t||n!==c))m.preventDefault(),m=window.getSelection(),m.setBaseAndExtent(m.anchorNode,0,m.anchorNode,0),h=!0,document.body&&document.body.appendChild(x),null===u&&(u=g.addListener("command",(w,y)=>{if("deleteCharacter"===w){if(q.length===b.columns*b.rows)return a.selectPrevious(),a.remove(),z(),!0;q.forEach(({elem:p})=>
5
- {p=r.$getNearestNodeFromDOMNode(p);r.$isElementNode(p)&&p.clear()});return!0}return"formatText"===w?(F(y),!0):!1},1));else if(t===k&&c===l)return;k=t;l=c;h&&(q=C(Math.min(f,k),Math.max(f,k),Math.min(n,l),Math.max(n,l),b.cells))}}});var z=()=>{d=h=!1;l=k=n=f=-1;C(-1,-1,-1,-1,b.cells);q=[];null!==u&&(u(),u=null);const m=x.parentNode;null!=m&&m.removeChild(x)};e.addEventListener("mouseleave",()=>{});var F=m=>{let c=r.$getSelection();null===c&&(c=r.$createSelection());const t=c,w=t.anchor,y=t.focus;q.forEach(p=>
6
- {p=r.$getNearestNodeFromDOMNode(p.elem);r.$isElementNode(p)&&(w.set(p.getKey(),0,"element"),y.set(p.getKey(),p.getChildrenSize(),"element"),t.formatText(m))});c.anchor.set(c.anchor.key,c.anchor.offset,c.anchor.type);c.focus.set(c.anchor.key,c.anchor.offset,c.anchor.type);r.$setSelection(c)},u=null;e.addEventListener("mousedown",m=>{d?h&&z():setTimeout(()=>{h&&z();const c=A(m.target);null!==c&&(d=!0,f=c.x,n=c.y,document.addEventListener("mouseup",()=>{d=!1},{capture:!0,once:!0}))},0)})}}
7
- class E extends r.ElementNode{static getType(){return"table"}static clone(a){return new E(a.__key)}constructor(a){super(a)}createDOM(a,e){const g=document.createElement("table");v(g,a.theme.table);D(this,g,e);return g}updateDOM(){return!1}canExtractContents(){return!1}canBeEmpty(){return!1}}exports.$createTableNode=function(){return new E};exports.$isTableNode=function(a){return a instanceof E};exports.TableNode=E;
1
+ 'use strict';var n=require("lexical"),y=require("lexical/TableCellNode");function A(a,...g){g.forEach(d=>{null!=d&&"string"===typeof d&&a.classList.add(...d.split(" "))})}function B(a,g){for(;a!==n.$getRoot()&&null!=a;){if(g(a))return a;a=a.getParent()}return null}const C=document.createElement("style");C.appendChild(document.createTextNode("::selection{background-color: transparent}"));
2
+ function D(a){for(;null!=a;){const g=a.nodeName;if("TD"===g||"TH"===g){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null}
3
+ function E(a,g,d){const k=[],l={rows:0,columns:0,cells:k};(new MutationObserver(t=>{d.update(()=>{var h=g.firstChild;let u=0,p=0;var e=!1;for(let q=0;q<t.length;q++){const w=t[q].target.nodeName;if("TABLE"===w||"TR"===w){e=!0;break}}if(e){for(k.length=0;null!=h;){e=h.nodeName;if("TD"===e||"TH"===e)e={elem:h,highlighted:!1,x:u,y:p},h._cell=e,void 0===k[p]&&(k[p]=[]),k[p][u]=e;else if(e=h.firstChild,null!=e){h=e;continue}e=h.nextSibling;if(null!=e)u++,h=e;else if(e=h.parentNode,null!=e){h=e.nextSibling;
4
+ if(null==h)break;p++;u=0}}l.columns=u+1;l.rows=p+1;a.setGrid(l)}})})).observe(g,{childList:!0,subtree:!0});a.setGrid(l);return l}
5
+ function F(a,g,d,k,l){const t=[];for(let h=0;h<l.length;h++){const u=l[h];for(let p=0;p<u.length;p++){const e=u[p],q=e.elem.style;p>=a&&p<=g&&h>=d&&h<=k?(e.highlighted||(e.highlighted=!0,q.setProperty("background-color","rgb(163, 187, 255)"),q.setProperty("caret-color","transparent")),t.push(e)):e.highlighted&&(e.highlighted=!1,q.removeProperty("background-color"),q.removeProperty("caret-color"))}}return t}
6
+ function H(a,g,d){if(null!==d.getRootElement()){E(a,g,d);var k=a.getGrid(),l=!1,t=!1,h=-1,u=-1,p=-1,e=-1,q=[];if(null==k)throw Error("Table grid not found.");g.addEventListener("mousemove",c=>{if(l){var b=D(c.target);if(null!==b){const f=b.x;b=b.y;if(!t&&(h!==f||u!==b))c.preventDefault(),c=window.getSelection(),c.setBaseAndExtent(c.anchorNode,0,c.anchorNode,0),t=!0,document.body&&document.body.appendChild(C),null===x&&(x=d.addListener("command",(m,v)=>{if("deleteCharacter"===m){if(q.length===k.columns*
7
+ k.rows)return a.selectPrevious(),a.remove(),w(),!0;q.forEach(({elem:r})=>{r=n.$getNearestNodeFromDOMNode(r);if(n.$isElementNode(r)){r.clear();const z=n.$createParagraphNode(),J=n.$createTextNode();z.append(J);r.append(z)}});a.setSelectionState(null);n.$setSelection(null);return!0}if("formatText"===m)return K(v),!0;"insertText"===m&&w();return!1},1));else if(f===p&&b===e)return;p=f;e=b;if(t){const m=Math.min(h,p),v=Math.max(h,p),r=Math.min(u,e),z=Math.max(u,e);d.update(()=>{q=a.setSelectionState({fromX:m,
8
+ toX:v,fromY:r,toY:z})})}}}});var w=()=>{d.update(()=>{l=t=!1;e=p=u=h=-1;d.update(()=>{a.setSelectionState(null)});q=[];null!==x&&(x(),x=null);const c=C.parentNode;null!=c&&c.removeChild(C)})};g.addEventListener("mouseleave",()=>{});var K=c=>{let b=n.$getSelection();null===b&&(b=n.$createSelection());const f=b,m=f.anchor,v=f.focus;q.forEach(r=>{r=n.$getNearestNodeFromDOMNode(r.elem);n.$isElementNode(r)&&(m.set(r.getKey(),0,"element"),v.set(r.getKey(),r.getChildrenSize(),"element"),f.formatText(c))});
9
+ b.anchor.set(b.anchor.key,b.anchor.offset,b.anchor.type);b.focus.set(b.anchor.key,b.anchor.offset,b.anchor.type);n.$setSelection(b)},x=null;g.addEventListener("mousedown",c=>{l?t&&w():setTimeout(()=>{t&&w();const b=D(c.target);null!==b&&(l=!0,h=b.x,u=b.y,document.addEventListener("mouseup",()=>{l=!1},{capture:!0,once:!0}))},0)});window.addEventListener("click",c=>{0<q.length&&!g.contains(c.target)&&d.update(()=>{a.setSelectionState(null)})});var G=(c,b,f)=>{let m;switch(f){case "backward":case "forward":f=
10
+ "forward"===f;m=b!==(f?k.columns-1:0)?a.getCellNodeFromCords(c,b+(f?1:-1)):c!==(f?k.rows-1:0)?a.getCellNodeFromCords(c+(f?1:-1),f?0:k.columns-1):f?a.getNextSibling():a.getPreviousSibling();break;case "up":m=0!==c?a.getCellNodeFromCords(c-1,b):a.getPreviousSibling();break;case "down":m=c!==k.rows-1?a.getCellNodeFromCords(c+1,b):a.getNextSibling()}return n.$isElementNode(m)||n.$isTextNode(m)?(m.select(),!0):!1};d.addListener("command",(c,b)=>{var f=n.$getSelection();if(null==f)return!1;const m=B(f.anchor.getNode(),
11
+ v=>y.$isTableCellNode(v));if(!y.$isTableCellNode(m))return!1;if("deleteCharacter"===c&&0===q.length&&f.isCollapsed()&&0===f.anchor.offset)return!0;if(("indentContent"===c||"outdentContent"===c)&&f.isCollapsed()&&0===q.length)return b=a.getCordsFromCellNode(m),G(b.x,b.y,"indentContent"===c?"forward":"backward"),!0;if(("keyArrowDown"===c||"keyArrowUp"===c)&&f.isCollapsed()&&0===q.length){const v=a.getCordsFromCellNode(m);f=B(f.anchor.getNode(),r=>n.$isElementNode(r));if("keyArrowUp"===c&&f===m.getFirstChild()||
12
+ "keyArrowDown"===c&&f===m.getLastChild())return b.preventDefault(),b.stopImmediatePropagation(),G(v.x,v.y,"keyArrowUp"===c?"up":"down"),!0}return!1},4)}}
13
+ class I extends n.ElementNode{static getType(){return"table"}static clone(a){return new I(a.__key,a.__selectionShape,a.__grid)}constructor(a,g,d){super(a);this.__selectionShape=g;this.__grid=d}createDOM(a,g){const d=document.createElement("table");A(d,a.theme.table);H(this,d,g);return d}updateDOM(){return!1}canExtractContents(){return!1}canBeEmpty(){return!1}setSelectionState(a){this.getWritable().__selectionShape=a;return null==this.__grid?[]:a?F(a.fromX,a.toX,a.fromY,a.toY,this.__grid.cells):F(-1,
14
+ -1,-1,-1,this.__grid.cells)}getSelectionState(){return this.__selectionShape}getCordsFromCellNode(a){if(!this.__grid)throw Error("Grid not found.");const {rows:g,cells:d}=this.__grid;for(let l=0;l<g;l++){var k=d[l];if(null==k)throw Error(`Row not found at x:${l}`);k=k.findIndex(({elem:t})=>n.$getNearestNodeFromDOMNode(t)===a);if(-1!==k)return{x:l,y:k}}throw Error("Cell not found in table.");}getCellNodeFromCords(a,g){if(!this.__grid)throw Error("Grid not found.");var {cells:d}=this.__grid;d=d[a];
15
+ if(null==d)throw Error(`Table row x:"${a}" not found.`);d=d[g];if(null==d)throw Error(`Table cell y:"${g}" in row x:"${a}" not found.`);a=n.$getNearestNodeFromDOMNode(d.elem);if(y.$isTableCellNode(a))return a;throw Error("Node at cords not TableCellNode.");}setGrid(a){this.getWritable().__grid=a}getGrid(){return this.__grid}}exports.$createTableNode=function(){return new I};exports.$isTableNode=function(a){return a instanceof I};exports.TableNode=I;exports.trackTableGrid=E;
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "rich-text"
14
14
  ],
15
15
  "license": "MIT",
16
- "version": "0.1.2",
16
+ "version": "0.1.6",
17
17
  "main": "Lexical.js",
18
18
  "repository": {
19
19
  "type": "git",
package/ParagraphNode.js DELETED
@@ -1,3 +0,0 @@
1
- 'use strict';var c=require("lexical");function d(a,...b){b.forEach(e=>{null!=e&&"string"===typeof e&&a.classList.add(...e.split(" "))})}
2
- class f extends c.ElementNode{static getType(){return"paragraph"}static clone(a){return new f(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("p");d(b,a.theme.paragraph);return b}updateDOM(){return!1}insertNewAfter(){const a=g(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){var a=this.getChildren();const b=this.getNextSibling();return c.$isElementNode(b)&&0===this.getIndexWithinParent()&&(0===a.length||c.$isTextNode(a[0])&&""===
3
- a[0].getTextContent().trim())?(a=b.getFirstChild(),c.$isTextNode(a)?a.select(0,0):b.select(0,0),this.remove(),!0):!1}}function g(){return new f}exports.$createParagraphNode=g;exports.$isParagraphNode=function(a){return a instanceof f};exports.ParagraphNode=f;