lexical 0.1.4 → 0.1.5
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/Lexical.js +132 -132
- package/README.md +103 -4
- package/package.json +1 -1
package/Lexical.js
CHANGED
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
'use strict';const
|
|
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
|
|
3
|
-
function
|
|
4
|
-
const x
|
|
5
|
-
else A(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,
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
function
|
|
10
|
-
function
|
|
11
|
-
function
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
function
|
|
15
|
-
function
|
|
16
|
-
class
|
|
17
|
-
c;
|
|
18
|
-
function
|
|
19
|
-
class
|
|
20
|
-
a.__key,b,"text");
|
|
21
|
-
e):m.slice(0,d));g+=m}else!(
|
|
22
|
-
(this.format&
|
|
23
|
-
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=
|
|
24
|
-
c.getNextSibling();if(!A(m)||D(m)||m.isSegmented())m=
|
|
25
|
-
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?A(k)&&!D(k)&&l!==k.getTextContentSize()?(k.isSegmented()&&(h=
|
|
26
|
-
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)?
|
|
27
|
-
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(A(n)){k=n.getFormatFlags(a,null);break}}var
|
|
28
|
-
f.type&&"element"===g.type?(d.setFormat(k),d.select(n,m),this.format=k):(n=
|
|
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(!z(q))if("characterData"===m){if(d&&3===n.nodeType&&A(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 y=x.parentNode;null!=y&&null===v&&y.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 [y,w]=e[f];if(B(w))for(g=w.__children,l=y.firstChild,q=0;q<g.length;q++)n=a.getElementByKey(g[q]),null!==n&&(null==l?(y.appendChild(n),l=n):l!==n&&y.replaceChild(n,l),l=l.nextSibling);
|
|
5
|
+
else A(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&&!z(pa(b))}catch(d){return!1}}function D(a){return a.isToken()||a.isInert()}function Ia(a){for(;null!=a;){if(3===a.nodeType)return a;a=a.firstChild}return null}function Ja(a,b,c){b=fa[b];return a&b&&(null===c||0===(c&b))?a^b:null===c||c&b?a|b:a}function Ka(a){return A(a)||La(a)||z(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),A(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||!A(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
|
+
class Xa{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=
|
|
17
|
+
c;P||(L()===e&&I(a),null===d||d.anchor!==this&&d.focus!==this||(d.dirty=!0))}}function Q(a,b,c){return new Xa(a,b,c)}function Ya(a,b){const c=b.getKey();let d=a.offset,e="element";A(b)&&(e="text",b=b.getTextContentSize(),d>b&&(d=b));a.set(c,d,e)}function Za(a,b){if(B(b)){const c=b.getLastDescendant();B(c)||A(c)?Ya(a,c):Ya(a,b)}else A(b)&&Ya(a,b)}
|
|
18
|
+
function $a(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}
|
|
19
|
+
class ab{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,
|
|
20
|
+
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,A(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,
|
|
21
|
+
e):m.slice(0,d));g+=m}else!(z(k)||La(k)||Ma(k))||k===c&&this.isCollapsed()||(g+=k.getTextContent())}return g}applyDOMRange(a){const b=G();a=bb(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 ab(Q(a.key,a.offset,a.type),Q(b.key,b.offset,b.type),this.format)}toggleFormatType(a){this.format=Ja(this.format,a,null);this.dirty=!0}hasFormat(a){return 0!==
|
|
22
|
+
(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(cb())}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?$a(b,c,e):d||"element"!==c.type||$a(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];A(c)||p(6);d=c.getTextContent().length;
|
|
23
|
+
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(!A(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=
|
|
24
|
+
c.getNextSibling();if(!A(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-=
|
|
25
|
+
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?A(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-
|
|
26
|
+
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()||
|
|
27
|
+
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(A(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();A(u)&&(n=q=0,d=u,k=d.getFormatFlags(a,null))}if(d.is(e))A(d)&&("element"===
|
|
28
|
+
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(A(d)&&(0!==n&&([,d]=d.splitText(n)),d.setFormat(k)),f=k,A(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(),A(m)&&g!==d.getKey()&&g!==e.getKey()&&!m.isToken()&&(g=m.getFormatFlags(a,
|
|
29
29
|
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(A(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=
|
|
30
|
-
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(
|
|
30
|
+
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(Ka(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}}A(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=
|
|
31
31
|
f.getFirstChild(),null!==k?k.insertBefore(n):f.append(n),f=n;else B(n)?(f=n.getParentOrThrow(),g--):f=f.insertAfter(n)}b&&(A(e)?e.select():(a=f.getPreviousSibling(),A(a)?a.select():(a=f.getIndexWithinParent(),f.getParentOrThrow().select(a,a))));if(B(f)){if(a=f.getLastDescendant(),b||(null===a?f.select():A(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),
|
|
32
32
|
f.insertAfter(e)):f.insertAfter(a),h.isEmpty()&&!h.canBeEmpty()&&h.remove()}else b||(A(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=
|
|
33
|
-
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=
|
|
33
|
+
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=cb();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=
|
|
34
34
|
e.getCharacterOffset();if(0===b)return[];if(1===b)return A(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);A(f)&&(d=b?h:l,d===f.getTextContentSize()?a.shift():0!==d&&([,f]=f.splitText(d),a[0]=f));A(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=
|
|
35
|
-
b&&0===g||!b&&g===h.getTextContentSize()?b?h.getPreviousSibling():h.getNextSibling():null}if(
|
|
36
|
-
a=b.type,
|
|
37
|
-
null;if(null!==e&&e.isSegmented()){if(b=c.offset,c=e.getTextContentSize(),e.is(d)||a&&b!==c||!a&&0!==b){
|
|
35
|
+
b&&0===g||!b&&g===h.getTextContentSize()?b?h.getPreviousSibling():h.getNextSibling():null}if(z(g)&&(h=b?g.getPreviousSibling():g.getNextSibling(),!A(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,
|
|
36
|
+
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():
|
|
37
|
+
null;if(null!==e&&e.isSegmented()){if(b=c.offset,c=e.getTextContentSize(),e.is(d)||a&&b!==c||!a&&0!==b){db(e,a);return}}else if(null!==d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(e)||a&&0!==b||!a&&b!==c)){db(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=
|
|
38
38
|
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(),A(e)&&"hashtag"===e.getType()&&(e.select(),b=e.getTextContent(),e.setTextContent(b+d),a.remove())):A(a)&&"hashtag"===a.getType()&&e===a.getTextContentSize()&&(e=a.getNextSibling(),A(e)&&e.isSimpleText()&&(b=e.getTextContent(),
|
|
39
|
-
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
|
|
40
|
-
function
|
|
41
|
-
b,"element")}}else c=
|
|
42
|
-
function
|
|
43
|
-
e.isComposing()&&e._compositionKey!==a.key&&null!==b&&(e=b.anchor,b=b.focus,
|
|
44
|
-
function
|
|
45
|
-
const [g,h]=a;return new
|
|
46
|
-
function
|
|
47
|
-
function
|
|
48
|
-
c)?g.getChildAtIndex(c-1):g.getChildAtIndex(e),A(e)&&(g=0,b&&(g=e.getTextContentSize()),d.set(e.getKey(),g,"text")))}}function
|
|
49
|
-
function
|
|
50
|
-
function
|
|
51
|
-
class
|
|
52
|
-
if(null==a)return!1;const b=(new Set(a.getNodes().map(c=>c.__key))).has(this.__key);return A(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:
|
|
53
|
-
this;for(;null!==a;){const b=a.getParent();if(
|
|
54
|
-
b?null:
|
|
39
|
+
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 db(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))}
|
|
40
|
+
function eb(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(A(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())),A(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,
|
|
41
|
+
b,"element")}}else c=Ra(a);return A(c)?Q(c.__key,b,"text"):null}
|
|
42
|
+
function bb(a,b,c,d,e){if(null===a||null===c||!Da(e,a,c))return null;a=eb(a,b);if(null===a)return null;c=eb(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(),A(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(),A(b)&&!b.isInert()&&(a.key=b.__key,a.offset=0));b=e.getEditorState()._selection;
|
|
43
|
+
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 fb(a,b,c,d,e,f){const g=F();a=new ab(Q(a,b,e),Q(c,d,f),0);a.dirty=!0;return g._selection=a}
|
|
44
|
+
function gb(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 ab(Q(a.key,a.offset,a.type),Q(c.key,c.offset,c.type),b.format);a=bb(c,e,d,f,a);if(null===a)return null;
|
|
45
|
+
const [g,h]=a;return new ab(g,h,null===b?0:b.format)}function r(){return F()._selection}function Va(){return G()._editorState._selection}
|
|
46
|
+
function hb(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"),ib(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"));ib(a)}}
|
|
47
|
+
function ib(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),A(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);A(c)&&(f=0,a&&(f=c.getTextContentSize()),b.set(c.getKey(),f,"text"))}B(g)&&(c=g.getChildrenSize(),e=(b=e>=
|
|
48
|
+
c)?g.getChildAtIndex(c-1):g.getChildAtIndex(e),A(e)&&(g=0,b&&(g=e.getTextContentSize()),d.set(e.getKey(),g,"text")))}}function jb(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))}}
|
|
49
|
+
function kb(a,b,c,d,e){let f=null,g=0,h=null;null!==d?(f=d.__key,A(d)?(g=d.getTextContentSize(),h="text"):B(d)&&(g=d.getChildrenSize(),h="element")):null!==e&&(f=e.__key,A(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 lb(a,b,c,d,e){"text"===a.type?(a.key=c,b||(a.offset+=e)):a.offset>d.getIndexWithinParent()&&--a.offset}
|
|
50
|
+
function mb(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&&(kb(g,a,d,a.getPreviousSibling(),a.getNextSibling()),f=!0);h.key===c&&(kb(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&&hb(e,d,c,-1);null===d||S(d)||d.canBeEmpty()||0!==d.getChildrenSize()||mb(d,b)}}
|
|
51
|
+
class nb{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();
|
|
52
|
+
if(null==a)return!1;const b=(new Set(a.getNodes().map(c=>c.__key))).has(this.__key);return A(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=
|
|
53
|
+
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>=
|
|
54
|
+
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=>ob(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=>ob(c))}getCommonAncestor(a){const b=this.getParents();var c=
|
|
55
55
|
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===
|
|
56
56
|
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();
|
|
57
|
-
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=
|
|
58
|
-
e=d.__parent;b=b._cloneNotNeeded;if(b.has(c))return
|
|
59
|
-
|
|
60
|
-
d=c.getParent();const e=
|
|
61
|
-
e.anchor.set(c,b+2,"element"),g&&e.focus.set(c,b+2,"element"));return a}insertBefore(a){
|
|
62
|
-
return null===c?d.select(0,0):B(c)?c.select():A(c)?c.select(a,b):(a=c.getIndexWithinParent()+1,d.select(a,a))}selectNext(a,b){
|
|
63
|
-
class
|
|
64
|
-
|
|
65
|
-
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:
|
|
66
|
-
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=
|
|
67
|
-
return B(a)||A(a)?a.select(0,0):null!==a?a.selectPrevious():this.select(0,0)}selectEnd(){const a=this.getLastDescendant();return B(a)||A(a)?a.select():null!==a?a.selectNext():this.select()}clear(){
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
class ub extends
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
function
|
|
57
|
+
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(),
|
|
58
|
+
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):A(d)&&A(f)?(f.__format=d.__format,f.__style=d.__style,f.__mode=d.__mode,f.__detail=d.__detail):z(d)&&z(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();
|
|
59
|
+
mb(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;mb(this,!1);H(a);e=r();null!==e&&(d=e.anchor,e=e.focus,d.key===b&&Za(d,a),e.key===b&&Za(e,a));L()===b&&I(c);return a}insertAfter(a){J();var b=this.getWritable(),c=a.getWritable(),
|
|
60
|
+
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&&(hb(e,h,b+1),c=h.getKey(),f&&
|
|
61
|
+
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&&hb(c,d,b);return a}selectPrevious(a,b){J();const c=this.getPreviousSibling(),d=this.getParentOrThrow();
|
|
62
|
+
return null===c?d.select(0,0):B(c)?c.select():A(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):A(c)?c.select(a,b):(a=c.getIndexWithinParent(),d.select(a,a))}markDirty(){this.getWritable()}}function ob(a){const b=K(a);null===b&&p(39,a);return b}
|
|
63
|
+
class pb extends nb{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=
|
|
64
|
+
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]);!A(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=
|
|
65
|
+
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,
|
|
66
|
+
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 fb(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();
|
|
67
|
+
return B(a)||A(a)?a.select(0,0):null!==a?a.selectPrevious():this.select(0,0)}selectEnd(){const a=this.getLastDescendant();return B(a)||A(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;
|
|
68
|
+
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;
|
|
69
|
+
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)&&kb(n,n.getNode(),this,c,e);h(q)&&kb(q,q.getNode(),this,c,e);h=a.length;for(b=0;b<h;b++)c=K(a[b]),null!=c&&(c.getWritable().__parent=
|
|
70
|
+
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 pb}
|
|
71
|
+
class qb{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}}
|
|
72
|
+
function rb(a,b){return new qb(a,b)}class sb{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 tb(a,b){return new sb(a,b)}
|
|
73
|
+
class ub extends nb{constructor(a,b){super(b);b=G();this.__state=a||tb(b)}decorate(){p(4)}}function z(a){return a instanceof ub}
|
|
74
|
+
class vb extends pb{static getType(){return"root"}static clone(){return new vb}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)||z(c)||p(46)}return super.append(...a)}canBeEmpty(){return!1}}
|
|
75
|
+
function S(a){return a instanceof vb}function wb(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 xb(){return new yb(new Map([["root",new vb]]))}
|
|
76
|
+
class yb{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 yb(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,
|
|
77
|
+
type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type}}}}}let V="",W="",X="",zb,Y,Ab=!1,Bb=!1,Cb=null,Db,Eb,Fb,Gb,Hb;function Ib(a,b){const c=Fb.get(a);if(null!==b){const d=Jb(a);b.removeChild(d)}Gb.has(a)||Y._keyToDOMMap.delete(a);B(c)&&(a=c.__children,Kb(a,0,a.length-1,null))}function Kb(a,b,c,d){for(;b<=c;++b){const e=a[b];void 0!==e&&Ib(e,d)}}function Lb(a,b){a.setProperty("text-align",b)}
|
|
78
|
+
function Mb(a,b){a.style.setProperty("padding-inline-start",0===b?"":40*b+"px")}function Nb(a,b){a=a.style;0===b?Lb(a,""):1===b?Lb(a,"left"):2===b?Lb(a,"center"):3===b?Lb(a,"right"):4===b&&Lb(a,"justify")}
|
|
79
|
+
function Ob(a,b,c){var d=Gb.get(a);void 0===d&&p(42);const e=d.createDOM(zb,Y);var f=Y._keyToDOMMap;e["__lexicalKey_"+Y._key]=a;f.set(a,e);A(d)?e.setAttribute("data-lexical-text","true"):z(d)&&e.setAttribute("data-lexical-decorator","true");if(B(d)){a=d.__indent;0!==a&&Mb(e,a);a=d.__children;var g=a.length;if(0!==g){f=a;--g;const h=W;W="";Pb(f,0,g,e,null);Qb(d,e);W=h}d=d.__format;0!==d&&Nb(e,d);Rb(null,a,e)}else z(d)?(f=d.decorate(Y),d=d.getTextContent(),null!==f&&Sb(a,f),e.contentEditable="false",
|
|
80
|
+
V+=d,X+=d):(a=d.getTextContent(),A(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 Pb(a,b,c,d,e){const f=V;for(V="";b<=c;++b)Ob(a[b],d,e);d.__lexicalTextContent=V;V=f+V}function Tb(a,b){a=b.get(a[a.length-1]);return La(a)||z(a)}
|
|
81
|
+
function Rb(a,b,c){a=null!==a&&(0===a.length||Tb(a,Fb));b=null!==b&&(0===b.length||Tb(b,Gb));a?b||(b=c.__lexicalLineBreak,null!=b&&c.removeChild(b),c.__lexicalLineBreak=null):b&&(b=document.createElement("br"),c.__lexicalLineBreak=b,c.appendChild(b))}
|
|
82
|
+
function Qb(a,b){const c=b.__lexicalDir;if(b.__lexicalDirTextContent!==W||c!==Cb){var d=""===W;if(d)var e=Cb;else e=W,e=da.test(e)?"rtl":ea.test(e)?"ltr":null;if(e!==c){const f=b.classList,g=zb.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);Bb||(a.getWritable().__dir=e)}Cb=e;b.__lexicalDirTextContent=W;b.__lexicalDir=
|
|
82
83
|
e}}
|
|
83
|
-
function
|
|
84
|
-
a),c=c.__children,a=d.__children,c!==a||e){var g=c,h=a;e=d;b=
|
|
85
|
-
m&&(m=new Set(g));void 0===n&&(n=new Set(h));const N=n.has(
|
|
86
|
-
c);!
|
|
87
|
-
function
|
|
88
|
-
function
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
function
|
|
92
|
-
function
|
|
93
|
-
function
|
|
94
|
-
function
|
|
95
|
-
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()&&
|
|
96
|
-
function
|
|
97
|
-
Gb=
|
|
98
|
-
"text"===
|
|
99
|
-
|
|
100
|
-
a,!0,O));O=
|
|
101
|
-
function
|
|
102
|
-
function
|
|
103
|
-
function
|
|
104
|
-
(d._flushSync=!0);const v=d._selection;if(null!==v){const
|
|
105
|
-
e.splice(b,1)),d._flushSync=!1,k&&(a._pendingEditorState=null))}function
|
|
106
|
-
class
|
|
107
|
-
|
|
108
|
-
function
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
-
"
|
|
112
|
-
break;case "insertParagraph":H(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",
|
|
84
|
+
function Ub(a,b){var c=Fb.get(a),d=Gb.get(a);void 0!==c&&void 0!==d||p(43);var e=Ab||Eb.has(a)||Db.has(a);const f=Vb(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)):z(c)||(d=c.getTextContent(),A(c)&&!c.isDirectionless()&&(W+=d),X+=d,V+=d),f;if(d.updateDOM(c,f,zb))return d=Ob(a,null,null),null===b&&p(44),b.replaceChild(d,f),Ib(a,null),d;if(B(c)&&B(d)){if(a=d.__indent,a!==c.__indent&&Mb(f,a),a=d.__format,a!==c.__format&&Nb(f,
|
|
85
|
+
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)Ub(m,f);else{var n=Jb(m);h=Ob(h,null,null);f.replaceChild(h,n);Ib(m,null)}}else if(0===l)0!==k&&Pb(h,0,k-1,f,null);else if(0===k)0!==l&&(m=null==f.__lexicalLineBreak,Kb(g,0,l-1,m?null:f),m&&(f.textContent=""));else{const x=l-1;l=k-1;let v=f.firstChild,y=0;for(k=0;y<=x&&k<=l;){var q=g[y];const w=h[k];if(q===w)v=Ub(w,f).nextSibling,y++,k++;else{void 0===
|
|
86
|
+
m&&(m=new Set(g));void 0===n&&(n=new Set(h));const N=n.has(q),Ea=m.has(w);N?(Ea?(q=Vb(Y,w),q===v?v=Ub(w,f).nextSibling:(null!=v?f.insertBefore(q,v):f.appendChild(q),Ub(w,f)),y++):Ob(w,f,v),k++):(v=Jb(q).nextSibling,Ib(q,f),y++)}}m=y>x;n=k>l;m&&!n?(m=h[l+1],m=void 0===m?null:Y.getElementByKey(m),Pb(h,k,l,f,m)):n&&!m&&Kb(g,y,x,f)}f.__lexicalTextContent=V;V=u+V;Qb(e,f);W=b;S(d)||Rb(c,a,f)}}else z(d)?(c=d.decorate(Y),null!==c&&Sb(a,c)):(c=d.getTextContent(),A(d)&&!d.isDirectionless()&&(W+=c),V+=c,X+=
|
|
87
|
+
c);!Bb&&S(d)&&d.__cachedText!==X&&(d=d.getWritable(),d.__cachedText=X);return f}function Sb(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 Jb(a){a=Hb.get(a);void 0===a&&p(45);return a}function Vb(a,b){a=a._keyToDOMMap.get(b);void 0===a&&p(45);return a}function Wb(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)&&Wb(l,h,c,d,e),c.has(h)||e.delete(h),d.delete(h))}}
|
|
88
|
+
function Xb(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)&&Wb(f,e,a,b,d),a.has(e)||d.delete(e),b.delete(e))}
|
|
89
|
+
function Yb(a,b){b=b.map;const c=new Map;for(let d=0;d<b.length;d++){const [e,f]=b[d];let g;"string"===typeof f||"number"===typeof f||"boolean"===typeof f||null===f?g=f:"object"===typeof f?g="editor"===f.type?rb(f.id,f.editorState):Yb(a,f):p(48);c.set(e,g)}return tb(a,c)}
|
|
90
|
+
function cc(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=cc(h,b,c,g,e).getKey(),f.__children.push(h))}f.__indent=a.__indent;f.__format=a.__format;f.__dir=a.__dir}else A(f)?(f.__format=a.__format,f.__style=a.__style,f.__mode=a.__mode,f.__detail=a.__detail):z(f)&&(f.__state=
|
|
91
|
+
Yb(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}
|
|
92
|
+
function dc(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 ec(a,b){const c=a.mergeWithSibling(b),d=G()._normalizedNodes;d.add(a.__key);d.add(b.__key);return c}
|
|
93
|
+
function fc(a){if(""===a.__text&&a.isSimpleText()&&!a.isUnmergeable())a.remove();else{for(var b;null!==(b=a.getPreviousSibling())&&A(b)&&b.isSimpleText()&&!b.isUnmergeable();)if(""===b.__text)b.remove();else{dc(b,a)&&(a=ec(b,a));break}for(var c;null!==(c=a.getNextSibling())&&A(c)&&c.isSimpleText()&&!c.isUnmergeable();)if(""===c.__text)c.remove();else{dc(a,c)&&ec(a,c);break}}}let T=null,U=null,P=!1,gc=!1,Na=0;function J(){P&&p(25)}function F(){null===T&&p(27);return T}
|
|
94
|
+
function G(){null===U&&p(28);return U}function hc(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 ic(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]);A(e)&&e.isSimpleText()&&!e.isUnmergeable()&&fc(e)}}
|
|
95
|
+
function jc(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);A(q)&&q.isSimpleText()&&!q.isUnmergeable()&&fc(q);void 0!==q&&void 0!==q&&q.__key!==e&&q.isAttached()&&hc(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],
|
|
96
|
+
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()&&hc(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}
|
|
97
|
+
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="",Ab=2===q,Cb=null,Y=a,zb=a._config,Db=u,Eb=x,Fb=d._nodeMap,Gb=b._nodeMap,Bb=b._readOnly,Hb=new Map(a._keyToDOMMap),Ub("root",null),
|
|
98
|
+
Hb=zb=Gb=Fb=Eb=Db=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 Fa=n.anchorNode,Zb=n.focusNode,Dc=n.anchorOffset,Ec=n.focusOffset,Ga=document.activeElement,ba=a._rootElement;if(!a._updateTags.has("collaboration")||Ga===ba)if(null===f)null!==e&&Da(a,Fa,Zb)&&n.removeAllRanges();else{var v=f.anchor,y=f.focus,w=y.key,N=Vb(a,v.key),Ea=Vb(a,w),$b=v.offset,ac=y.offset;e=N;w=Ea;"text"===v.type&&(e=
|
|
99
|
+
Ia(N));"text"===y.type&&(w=Ia(Ea));if(null!==e&&null!==w)if(Dc===$b&&Ec===ac&&Fa===e&&Zb===w)null===ba||null!==Ga&&ba.contains(Ga)||ba.focus({preventScroll:!0});else try{if(n.setBaseAndExtent(e,$b,w,ac),f.isCollapsed()&&ba===Ga){const ca=3===e.nodeType?e.parentNode:e;if(null!==ca){const Ha=ca.getBoundingClientRect();if(Ha.bottom>window.innerHeight)ca.scrollIntoView(!1);else if(0>Ha.top)ca.scrollIntoView();else if(ba){const bc=ba.getBoundingClientRect();Ha.top<bc.top?ca.scrollIntoView():Ha.bottom>
|
|
100
|
+
bc.bottom&&ca.scrollIntoView(!1)}}}}catch(ca){}}}}catch(aa){kc("error",a,!1,aa,aa._log);gc||(lc(a,null,c,b),va(a),a._dirtyType=2,gc=!0,a._log.push("ReconcileRecover"),Z(a),gc=!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||
|
|
101
|
+
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,kc("decorator",a,!0,O));O=Pa(d);g=Pa(b);O!==g&&kc("textcontent",a,!0,g);kc("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,
|
|
102
|
+
Fa]=b.shift();mc(a,aa,!1,Fa)}}}function kc(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 nc(a,b,c){if(!1===a._updating||U!==a){let e=!1;a.update(()=>{e=nc(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}
|
|
103
|
+
function oc(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()}}
|
|
104
|
+
function mc(a,b,c,d){const e=a._deferred;let f,g,h=!1;void 0!==d&&(f=d.onUpdate,g=d.tag,h=d.skipTransforms);f&&e.push(f);const l=a._editorState;d=a._pendingEditorState;let k=!1;null===d&&(d=a._pendingEditorState=new yb(new Map(l._nodeMap)),k=!0);const m=T,n=P,q=U,u=a._updating;T=d;P=!1;a._updating=!0;U=a;try{k&&(d._selection=gb(a));const x=a._compositionKey;b();oc(a,e);jb(d,a);0!==a._dirtyType&&(!c&&d.isEmpty()&&p(29),h?ic(d,a):jc(d,a),oc(a,e),Xb(l,d,a._dirtyLeaves,a._dirtyElements));x!==a._compositionKey&&
|
|
105
|
+
(d._flushSync=!0);const v=d._selection;if(null!==v){const y=d._nodeMap,w=v.focus.key;void 0!==y.get(v.anchor.key)&&void 0!==y.get(w)||p(30)}}catch(x){kc("error",a,!1,x,a._log);a._pendingEditorState=l;a._dirtyType=2;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();a._log.push("UpdateRecover");Z(a);return}finally{T=m,P=n,U=q,a._updating=u,Na=0}0!==a._dirtyType||wb(d,a)?(null!=g&&a._updateTags.add(g),d._flushSync?(d._flushSync=!1,Z(a)):k&&Ca(()=>{Z(a)})):(f&&(b=e.indexOf(f),
|
|
106
|
+
e.splice(b,1)),d._flushSync=!1,k&&(a._pendingEditorState=null))}function oa(a,b,c,d){a._updating?a._updates.push([b,d]):mc(a,b,c,d)}class pc extends nb{static getType(){return"linebreak"}static clone(a){return new pc(a.__key)}constructor(a){super(a)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}}function cb(){return new pc}function La(a){return a instanceof pc}
|
|
107
|
+
class qc extends nb{static getType(){return"horizontal-rule"}static clone(a){return new qc(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 qc}const rc={},yc=[["selectionchange",sc],["keydown",tc],["compositionstart",uc],["compositionend",vc],["input",wc],["click",xc],["cut",rc],["copy",rc],["dragstart",rc],["paste",rc],["focus",rc],["blur",rc]];
|
|
108
|
+
za?yc.push(["beforeinput",zc]):yc.push(["drop",rc]);let Ac=!1;function sc(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")}})}
|
|
109
|
+
function xc(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))}})}
|
|
110
|
+
function zc(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")):
|
|
111
|
+
"\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");
|
|
112
|
+
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",
|
|
113
113
|
!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");
|
|
114
|
-
break;case "historyRedo":b.execCommand("redo")}}})}function
|
|
115
|
-
function
|
|
116
|
-
function
|
|
114
|
+
break;case "historyRedo":b.execCommand("redo")}}})}function wc(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 uc(a,b){b.update(()=>{t("onCompositionStart");const c=r();if(null!==c&&!b.isComposing()){const d=c.anchor;I(d.key);Ac&&"element"!==d.type&&c.isCollapsed()||b.execCommand("insertText"," ")}})}function Bc(a,b){b.update(()=>{t("onCompositionEnd");I(null);Ua(b,!0)})}
|
|
115
|
+
function vc(a,b){ya?setTimeout(()=>{Bc(a,b)},0):Bc(a,b)}
|
|
116
|
+
function tc(a,b){Ac="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",
|
|
117
117
|
!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")):
|
|
118
118
|
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",
|
|
119
|
-
a)}})}function
|
|
120
|
-
function
|
|
121
|
-
function
|
|
122
|
-
function
|
|
123
|
-
class
|
|
124
|
-
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=""+
|
|
125
|
-
{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);
|
|
126
|
-
this._rootElement=a;
|
|
127
|
-
b){a.isEmpty()&&p(19);
|
|
128
|
-
f=null===f?null:new
|
|
129
|
-
function
|
|
130
|
-
function
|
|
131
|
-
function
|
|
132
|
-
class
|
|
133
|
-
(this.getLatest().__detail&2)}hasFormat(a){a=
|
|
134
|
-
c,this);a=a.theme.text;void 0!==a&&
|
|
135
|
-
l&&p(21));
|
|
136
|
-
a.__detail^=2;return a}setMode(a){a=
|
|
137
|
-
g=c.length;let h=a;0>h&&(h=g+h,0>h&&(h=0));const l=
|
|
138
|
-
l=c.__key;const m=b.getFormat(),n=b.getStyle(),
|
|
139
|
-
(N.key=
|
|
140
|
-
l&&l.key===d&&(
|
|
141
|
-
exports.$createTextNode=
|
|
142
|
-
exports.TextNode=
|
|
143
|
-
exports.isDecoratorEditor=function(a){return a instanceof
|
|
119
|
+
a)}})}function Cc(a,b){return"selectionchange"===a||"keyup"===a||"pointerup"===a||"pointercancel"===a?b.ownerDocument:b}function Fc(a){a=a.getRootElement();return null!==a&&"true"===a.contentEditable}function Gc(a){let b=a._lexicalEventHandles;void 0===b&&(b=[],a._lexicalEventHandles=b);return b}
|
|
120
|
+
function Hc(a,b){const c=Gc(a);for(let d=0;d<yc.length;d++){const [e,f]=yc[d],g="function"===typeof f?h=>{Fc(b)&&f(h,b)}:h=>{Fc(b)&&b.execCommand(e,h)};Cc(e,a).addEventListener(e,g);c.push(()=>{Cc(e,a).removeEventListener(e,g)})}}
|
|
121
|
+
function lc(a,b,c,d){const e=a._keyToDOMMap;e.clear();a._editorState=xb();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))}
|
|
122
|
+
function Ic(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--}}
|
|
123
|
+
class Jc{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]};this._config=c;this._registeredNodes=new Map;this.registerNodes([vb,Kc,qc,pc]);this._decorators={};this._pendingDecorators=
|
|
124
|
+
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=""+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(Ic(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!==c){const f=d[c];f.add(b);return()=>
|
|
125
|
+
{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 nc(this,a,b)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}setRootElement(a){const b=this._rootElement;if(a!==b){var c=this._pendingEditorState||this._editorState;
|
|
126
|
+
this._rootElement=a;lc(this,b,a,c);if(null!==b&&!this._config.disableEvents){c=Gc(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||Hc(a,this));kc("root",this,!1,a,b)}}getElementByKey(a){return this._keyToDOMMap.get(a)||null}getEditorState(){return this._editorState}setEditorState(a,
|
|
127
|
+
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 yb(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");cc(g,f,this,null,c)}finally{T=a,P=d,U=e}f=c.remappedSelection||c.originalSelection;
|
|
128
|
+
f=null===f?null:new ab(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()}}
|
|
129
|
+
function Lc(a,b){return b&1?"strong":b&2?"em":"span"}function Mc(a,b){var c=a[b];return"string"===typeof c?(c=c.split(" "),a[b]=c):c}
|
|
130
|
+
function Nc(a,b,c,d,e){a=d.classList;d=Mc(e,"base");void 0!==d&&a.add(...d);d=Mc(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=Mc(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))}
|
|
131
|
+
function Oc(a,b,c){const d=b.firstChild;c=c.isComposing()?"\u00a0":"";a+=c;null==d?b.textContent=a:d.nodeValue!==a&&(d.nodeValue=a)}
|
|
132
|
+
class Kc extends nb{static getType(){return"text"}static clone(a){return new Kc(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!==
|
|
133
|
+
(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 Ja(c,a,b)}createDOM(a){var b=this.__format,c=b&16?"code":null;const d=Lc(this,b),e=document.createElement(null===c?d:c);let f=e;null!==c&&(f=document.createElement(d),e.appendChild(f));c=f;Oc(this.__text,
|
|
134
|
+
c,this);a=a.theme.text;void 0!==a&&Nc(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=Lc(this,e);const k=Lc(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),Oc(d,a,this),c=c.theme.text,void 0!==c&&Nc(k,0,f,a,c),b.replaceChild(g,e),!1;l=b;null!==h&&null!==g&&(l=b.firstChild,null==
|
|
135
|
+
l&&p(21));Oc(d,l,this);c=c.theme.text;void 0!==c&&e!==f&&Nc(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();
|
|
136
|
+
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 fb(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,
|
|
137
|
+
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();
|
|
138
|
+
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 y=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=y,w.offset-=k,b.dirty=!0);N.key===d&&"text"===N.type&&N.offset>k&&N.offset<=x&&
|
|
139
|
+
(N.key=y,N.offset-=k,b.dirty=!0)}e===d&&I(y);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&&hb(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&&(lb(h,b,c,a,f),g.dirty=!0);null!==
|
|
140
|
+
l&&l.key===d&&(lb(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 Kc(a)}function A(a){return a instanceof Kc}exports.$createHorizontalRuleNode=function(){return new qc};exports.$createLineBreakNode=cb;exports.$createNodeFromParse=function(a,b){J();const c=G();return cc(a,b,c,null)};exports.$createSelection=function(){const a=Q("root",0,"element"),b=Q("root",0,"element");return new ab(a,b,0)};
|
|
141
|
+
exports.$createTextNode=M;exports.$getCompositionKey=L;exports.$getNearestNodeFromDOMNode=pa;exports.$getNodeByKey=K;exports.$getPreviousSelection=Va;exports.$getRoot=sa;exports.$getSelection=r;exports.$isDecoratorNode=z;exports.$isElementNode=B;exports.$isHorizontalRuleNode=Ma;exports.$isLeafNode=Ka;exports.$isLineBreakNode=La;exports.$isRootNode=S;exports.$isTextNode=A;exports.$log=t;exports.$setCompositionKey=I;exports.$setSelection=ta;exports.DecoratorNode=ub;exports.ElementNode=pb;
|
|
142
|
+
exports.TextNode=Kc;exports.VERSION="0.1.5";exports.createDecoratorEditor=rb;exports.createDecoratorMap=tb;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=xb();b=b.initialEditorState;a=new Jc(h,e,{context:d,namespace:a,theme:c,htmlTransforms:f,disableEvents:g});void 0!==b&&(a._pendingEditorState=b,a._dirtyType=2);return a};
|
|
143
|
+
exports.isDecoratorEditor=function(a){return a instanceof qb};exports.isDecoratorMap=function(a){return a instanceof sb};
|
package/README.md
CHANGED
|
@@ -25,10 +25,12 @@ The `lexical` package contains only the core Lexical engine and nodes. This pack
|
|
|
25
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
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
27
|
|
|
28
|
-
### Creating an editor
|
|
28
|
+
### Creating an editor and using it
|
|
29
29
|
|
|
30
|
-
When you work with Lexical, you normally work with a single editor instance. An editor instance can be
|
|
31
|
-
an
|
|
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:
|
|
32
34
|
|
|
33
35
|
```js
|
|
34
36
|
import {createEditor} from 'lexical';
|
|
@@ -51,4 +53,101 @@ editor.setRootElement(contentEditableElement);
|
|
|
51
53
|
```
|
|
52
54
|
|
|
53
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,
|
|
54
|
-
just pass an alternative element reference to `setRootElement`.
|
|
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
|
+
```
|