lexical 0.2.3 → 0.2.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/Lexical.d.ts +83 -64
- package/Lexical.dev.js +620 -245
- package/Lexical.js.flow +40 -49
- package/Lexical.prod.js +164 -159
- package/package.json +1 -1
package/Lexical.prod.js
CHANGED
|
@@ -4,165 +4,170 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
function
|
|
8
|
-
const aa=RegExp("^[^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=RegExp("^[^\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]"),ca={bold:1,code:16,italic:2,strikethrough:4,subscript:32,superscript:64,underline:8},
|
|
9
|
-
segmented:2,token:1},ia="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,ja=ia&&"documentMode"in document?document.documentMode:null,
|
|
10
|
-
!window.MSStream;let
|
|
11
|
-
function v(a){return a.isToken()||a.isInert()}function
|
|
12
|
-
function
|
|
13
|
-
function D(a){F();var b=B();const c=b._compositionKey;b._compositionKey=a
|
|
14
|
-
function Fa(a){return a.read(()=>Ga().getTextContent())}function Ha(a,b){I(a,()=>{var c=z();if(!c.isEmpty())if("root"===b)Ga().markDirty();else{c=c._nodeMap;for(const [,d]of c)d.markDirty()}},null===a._pendingEditorState?{tag:"history-merge"}:void 0)}function Ga(){return z()._nodeMap.get("root")}function Ia(a){z()._selection=a}
|
|
15
|
-
function Ja(a){var b=B(),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?
|
|
16
|
-
function La(a,b){a=window.getSelection();if(null!==a){var
|
|
17
|
-
function Ma(a,b,c,d,f){let e=a;if(e.isAttached()&&(f||!e.isDirty())){var g=e.isComposing();a=b;(g||f)&&"\u200b"===b[b.length-1]&&(a=b.slice(0,-1));b=e.getTextContent();if(f||a!==b)if(""===a)if(D(null),ma||
|
|
18
|
-
(c=e.getTextContent(),c=L(c),e.replace(c),e=c)),e.setTextContent(a))}}
|
|
19
|
-
function Oa(a,b,c){var d=a.anchor;const f=a.focus;var e=d.getNode(),g=window.getSelection();g=null!==g?g.anchorNode:null;const h=d.key,
|
|
20
|
-
b&&(!e.canInsertTextBefore()||!c.canInsertTextBefore()||d),b=a||e):b=!1);return b}function Pa(a,b){var c=a[b];return"string"===typeof c?(c=c.split(" "),a[b]=c):c}function Qa(a,b,c,d,f){0!==c.size&&(c=d.__type,d=d.__key,b=b.get(c),void 0===b&&
|
|
7
|
+
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.");}
|
|
8
|
+
const aa=RegExp("^[^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=RegExp("^[^\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]"),ca={bold:1,code:16,italic:2,strikethrough:4,subscript:32,superscript:64,underline:8},da={center:2,justify:4,left:1,right:3},ha={inert:3,normal:0,
|
|
9
|
+
segmented:2,token:1},ia="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,ja=ia&&"documentMode"in document?document.documentMode:null,t=ia&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),ka=ia&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),la=ia&&"InputEvent"in window&&!ja?"getTargetRanges"in new window.InputEvent("input"):!1,ma=ia&&/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),na=ia&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&
|
|
10
|
+
!window.MSStream;let oa=0;const qa="function"===typeof queueMicrotask?queueMicrotask:a=>{Promise.resolve().then(a)};function ra(a,b,c){const d=a.getRootElement();try{var f;if(f=null!==d&&d.contains(b)&&d.contains(c)&&null!==b){const e=document.activeElement,g=null!==e?e.nodeName:null;f=!u(sa(b))||"INPUT"!==g&&"TEXTAREA"!==g}return f&&ta(b)===a}catch(e){return!1}}function ta(a){for(;null!=a;){const b=a.__lexicalEditor;if(null!=b&&!b.isReadOnly())return b;a=a.parentNode}return null}
|
|
11
|
+
function ua(a){return v(a)||a.isSegmented()}function v(a){return a.isToken()||a.isInert()}function va(a){for(;null!=a;){if(3===a.nodeType)return a;a=a.firstChild}return null}function wa(a,b,c){b=ca[b];return a&b&&(null===c||0===(c&b))?a^b:null===c||c&b?a|b:a}function xa(a){return x(a)||ya(a)||u(a)}function za(a){var b=a.getParent();if(null!==b){b=b.getWritable().__children;const c=b.indexOf(a.__key);-1===c&&p(34);Aa(a);b.splice(c,1)}}
|
|
12
|
+
function Ba(a){99<Ca&&p(51);var b=a.getLatest(),c=b.__parent,d=z();const f=B(),e=d._nodeMap;d=f._dirtyElements;if(null!==c)a:for(;null!==c;){if(d.has(c))break a;const g=e.get(c);if(void 0===g)break;d.set(c,!1);c=g.__parent}b=b.__key;f._dirtyType=1;C(a)?d.set(b,!0):f._dirtyLeaves.add(b)}function Aa(a){const b=a.getPreviousSibling();a=a.getNextSibling();null!==b&&Ba(b);null!==a&&Ba(a)}
|
|
13
|
+
function D(a){F();var b=B();const c=b._compositionKey;a!==c&&(b._compositionKey=a,null!==c&&(b=H(c),null!==b&&b.getWritable()),null!==a&&(a=H(a),null!==a&&a.getWritable()))}function H(a,b){a=(b||z())._nodeMap.get(a);return void 0===a?null:a}function Da(a,b){const c=B();a=a["__lexicalKey_"+c._key];return void 0!==a?H(a,b):null}function sa(a,b){for(;null!=a;){const c=Da(a,b);if(null!==c)return c;a=a.parentNode}return null}
|
|
14
|
+
function Ea(a){const b=Object.assign({},a._decorators);return a._pendingDecorators=b}function Fa(a){return a.read(()=>Ga().getTextContent())}function Ha(a,b){I(a,()=>{var c=z();if(!c.isEmpty())if("root"===b)Ga().markDirty();else{c=c._nodeMap;for(const [,d]of c)d.markDirty()}},null===a._pendingEditorState?{tag:"history-merge"}:void 0)}function Ga(){return z()._nodeMap.get("root")}function Ia(a){const b=z();null!==a&&(Object.isFrozen(a)&&p(35),a.dirty=!0,a._cachedNodes=null);b._selection=a}
|
|
15
|
+
function Ja(a){var b=B(),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?H("root"):null):H(c)}function Ka(a){const b=[];for(;null!==a;)b.push(a),a=a._parentEditor;return b}
|
|
16
|
+
function La(a,b,c){a=window.getSelection();if(null!==a){var d=a.anchorNode,{anchorOffset:f,focusOffset:e}=a;if(null!==d&&3===d.nodeType&&(a=sa(d),x(a))){d=d.nodeValue;if("\u200b"===d&&c){const g=c.length;d=c;e=f=g}Ma(a,d,f,e,b)}}}
|
|
17
|
+
function Ma(a,b,c,d,f){let e=a;if(e.isAttached()&&(f||!e.isDirty())){var g=e.isComposing();a=b;(g||f)&&"\u200b"===b[b.length-1]&&(a=b.slice(0,-1));b=e.getTextContent();if(f||a!==b)if(""===a)if(D(null),ma||na)e.remove();else{const h=B();setTimeout(()=>{h.update(()=>{e.isAttached()&&e.remove()})},20)}else f=e.getParent(),b=Na(),v(e)||null!==B()._compositionKey&&!g||null!==f&&J(b)&&!f.canInsertTextBefore()&&0===b.anchor.offset?e.markDirty():(g=K(),J(g)&&null!==c&&null!==d&&(g.setTextNodeRange(e,c,e,
|
|
18
|
+
d),e.isSegmented()&&(c=e.getTextContent(),c=L(c),e.replace(c),e=c)),e.setTextContent(a))}}
|
|
19
|
+
function Oa(a,b,c){var d=a.anchor;const f=a.focus;var e=d.getNode(),g=window.getSelection();g=null!==g?g.anchorNode:null;const h=d.key,k=B().getElementByKey(h);(b=h!==f.key||!x(e)||d.offset!==f.offset&&!e.isComposing()||(c||e.isDirty())&&1<b.length||null!==k&&!e.isComposing()&&g!==va(k)||e.getFormat()!==a.format)||(e.isSegmented()?b=!0:a.isCollapsed()?(b=a.anchor.offset,c=e.getParentOrThrow(),d=e.isToken(),a=0===b&&(!e.canInsertTextBefore()||!c.canInsertTextBefore()||d),e=e.getTextContentSize()===
|
|
20
|
+
b&&(!e.canInsertTextBefore()||!c.canInsertTextBefore()||d),b=a||e):b=!1);return b}function Pa(a,b){var c=a[b];return"string"===typeof c?(c=c.split(" "),a[b]=c):c}function Qa(a,b,c,d,f){0!==c.size&&(c=d.__type,d=d.__key,b=b.get(c),void 0===b&&p(36,c),b=b.klass,c=a.get(b),void 0===c&&(c=new Map,a.set(b,c)),c.has(d)||c.set(d,f))}
|
|
21
21
|
function Ra(a,b,c){const d=a.getParent();let f=c;null!==d&&(b&&0===c?(f=a.getIndexWithinParent(),a=d):b||c!==a.getChildrenSize()||(f=a.getIndexWithinParent()+1,a=d));return a.getChildAtIndex(b?f-1:f)}function Sa(a,b){var c=a.offset;if("element"===a.type)return a=a.getNode(),Ra(a,b,c);a=a.getNode();return b&&0===c||!b&&c===a.getTextContentSize()?(c=b?a.getPreviousSibling():a.getNextSibling(),null===c?Ra(a.getParentOrThrow(),b,a.getIndexWithinParent()+(b?0:1)):c):null}
|
|
22
|
-
function Ta(){var a=window.event;a=a&&a.inputType;return"insertFromPaste"===a||"insertFromPasteAsQuotation"===a}function Ua(a,b,c,d,f){a=a.__children;const e=a.length;for(let g=0;g<e;g++){const h=a[g],
|
|
23
|
-
function
|
|
24
|
-
function
|
|
25
|
-
function
|
|
26
|
-
a.__indent;h.__format=a.__format;h.__dir=a.__dir}else
|
|
27
|
-
a={nodes:[...b],type:"node"}),"node"===a.type&&a.nodes.splice(g,1,e))):"grid"===b.type&&(c=b.gridKey,d=b.
|
|
28
|
-
const
|
|
29
|
-
function
|
|
30
|
-
function
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function
|
|
37
|
-
function
|
|
38
|
-
(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
a)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
function
|
|
54
|
-
g&&void 0!==g&&g.__key!==f&&g.isAttached()&&
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
a.
|
|
61
|
-
|
|
62
|
-
function
|
|
63
|
-
(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
class
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
f.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
function
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
function
|
|
109
|
-
function
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
22
|
+
function Ta(){var a=window.event;a=a&&a.inputType;return"insertFromPaste"===a||"insertFromPasteAsQuotation"===a}function Ua(a){return!M(a)&&!a.isLastChild()&&!a.isInline()}function Va(a,b,c,d,f){a=a.__children;const e=a.length;for(let g=0;g<e;g++){const h=a[g],k=d.get(h);void 0!==k&&k.__parent===b&&(C(k)&&Va(k,h,c,d,f),c.has(h)||f.delete(h),d.delete(h))}}
|
|
23
|
+
function Wa(a,b,c,d){a=a._nodeMap;b=b._nodeMap;for(const f of c){const e=b.get(f);void 0===e||e.isAttached()||(a.has(f)||c.delete(f),b.delete(f))}for(const [f]of d)c=b.get(f),void 0===c||c.isAttached()||(C(c)&&Va(c,f,a,b,d),a.has(f)||d.delete(f),b.delete(f))}function Xa(a,b){const c=a.__mode,d=a.__format;a=a.__style;const f=b.__mode,e=b.__format;b=b.__style;return(null===c||c===f)&&(null===d||d===e)&&(null===a||a===b)}
|
|
24
|
+
function Ya(a,b){const c=a.mergeWithSibling(b),d=B()._normalizedNodes;d.add(a.__key);d.add(b.__key);return c}function Za(a){if(""===a.__text&&a.isSimpleText()&&!a.isUnmergeable())a.remove();else{for(var b;null!==(b=a.getPreviousSibling())&&x(b)&&b.isSimpleText()&&!b.isUnmergeable();)if(""===b.__text)b.remove();else{Xa(b,a)&&(a=Ya(b,a));break}for(var c;null!==(c=a.getNextSibling())&&x(c)&&c.isSimpleText()&&!c.isUnmergeable();)if(""===c.__text)c.remove();else{Xa(a,c)&&Ya(a,c);break}}}
|
|
25
|
+
function $a(a,b,c,d,f={originalSelection:null}){var e=a.__type,g=c._nodes.get(e);void 0===g&&p(32,e);for(var h in a)if(e=a[h],null!=e&&"object"===typeof e&&(e=e.editorState,null!=e)){var k=ab();k._nodes=c._nodes;k._parentEditor=c._parentEditor;k._pendingEditorState=bb(e,k);a[h]=k}h=g.klass;g=a.__key;a.__key=void 0;h=h.clone(a);a.__key=g;e=h.__key;M(h)&&z()._nodeMap.set("root",h);h.__parent=d;if(C(h)){d=a.__children;for(k=0;k<d.length;k++){var m=b.get(d[k]);void 0!==m&&(m=$a(m,b,c,e,f).__key,h.__children.push(m))}h.__indent=
|
|
26
|
+
a.__indent;h.__format=a.__format;h.__dir=a.__dir}else x(h)&&(h.__format=a.__format,h.__style=a.__style,h.__mode=a.__mode,h.__detail=a.__detail);b=null!=f?f.originalSelection:void 0;null!=b&&(a=f.remappedSelection,"range"===b.type?(c=b.anchor,b=b.focus,null!=a||g!==c.key&&g!==b.key||(f.remappedSelection=a={anchor:{...c},focus:{...b},type:"range"}),null!=a&&"range"===a.type&&(g===c.key&&(a.anchor.key=e),g===b.key&&(a.focus.key=e))):"node"===b.type?(b=b.nodes,g=b.indexOf(g),-1!==g&&(null==a&&(f.remappedSelection=
|
|
27
|
+
a={nodes:[...b],type:"node"}),"node"===a.type&&a.nodes.splice(g,1,e))):"grid"===b.type&&(c=b.gridKey,d=b.anchor.key,k=b.focus.key,null!=a||c!==g&&c!==d&&c!==k||(f.remappedSelection=a={...b,type:"grid"}),null!=a&&"grid"===a.type&&(c===g&&(a.gridKey=e),d===g&&(a.anchor.key=e),k===g&&(a.focus.key=e))));return h}
|
|
28
|
+
const fb={},gb={},hb={},ib={},jb={},kb={},lb={},mb={},nb={},ob={},N={},pb={},qb={},rb={},sb={},tb={},ub={},vb={},wb={},xb={},yb={},zb={},Ab={},Bb={},Cb={},Db={},Eb={},Fb={},Gb={},Hb={},Ib={},Lb=Object.freeze({}),Rb=[["keydown",Mb],["compositionstart",Nb],["compositionend",Ob],["input",Pb],["click",Qb],["cut",Lb],["copy",Lb],["dragstart",Lb],["paste",Lb],["focus",Lb],["blur",Lb]];la?Rb.push(["beforeinput",Sb]):Rb.push(["drop",Lb]);let Tb=0,Ub=0,Vb=!1,Wb=!1,Xb=!1,Yb=[0,0,"root",0];
|
|
29
|
+
function Zb(a,b,c){if(Vb){Vb=!1;const {anchorNode:d,anchorOffset:f,focusNode:e,focusOffset:g}=a;if(null!==d&&3===d.nodeType&&0!==f&&f!==d.nodeValue.length&&null!==e&&3===e.nodeType&&0!==g&&g!==e.nodeValue.length)return}I(b,()=>{if(c){var d=K();if(J(d)){const e=d.anchor,g=e.getNode();if(d.isCollapsed()){"Range"===a.type&&(d.dirty=!0);var f=window.event.timeStamp;const [h,k,m,l]=Yb;f<l+200&&e.offset===k&&e.key===m?d.format=h:"text"===e.type?d.format=g.getFormat():"element"===e.type&&(d.format=0)}else{f=
|
|
30
|
+
d.focus;const h=f.getNode();let k=0;"text"===e.type&&(k|=g.getFormat());"text"!==f.type||g.is(h)||(k|=h.getFormat());d.format=k}}O(b,fb,void 0)}else Ia(null)})}function Qb(a,b){I(b,()=>{const c=K();if(J(c)){var d=c.anchor;"element"===d.type&&0===d.offset&&c.isCollapsed()&&1===Ga().getChildrenSize()&&d.getNode().getTopLevelElementOrThrow().isEmpty()&&(d=Na(),null!==d&&c.is(d)&&(window.getSelection().removeAllRanges(),c.dirty=!0))}O(b,gb,a)})}
|
|
31
|
+
function $b(a,b){b.getTargetRanges&&(b=b.getTargetRanges()[0])&&a.applyDOMRange(b)}function ac(a,b){return a!==b||C(a)||C(b)||!v(a)||!v(b)}
|
|
32
|
+
function Sb(a,b){const c=a.inputType;if(!("deleteCompositionText"===c||ka&&Ta()))if("insertCompositionText"===c){const d=a.data;d&&I(b,()=>{var f=K();if(J(f)){const e=f.anchor,g=e.getNode(),h=g.getPreviousSibling();0===e.offset&&x(g)&&x(h)&&" "===g.getTextContent()&&h.getFormat()!==f.format&&(f=h.getTextContent(),0===d.indexOf(f)&&(f=d.slice(f.length),O(b,kb,f),setTimeout(()=>{I(b,()=>{g.select()})},30)))}})}else I(b,()=>{var d=K();if("deleteContentBackward"===c){if(null===d){d=Na();if(!J(d))return;
|
|
33
|
+
Ia(d.clone())}D(null);a.preventDefault();Tb=0;O(b,hb,!0);setTimeout(()=>{I(b,()=>{D(null)})},30)}else if(J(d)){var f=a.data;d.dirty||!d.isCollapsed()||M(d.anchor.getNode())||$b(d,a);var e=d.focus,g=d.anchor.getNode();e=e.getNode();if("insertText"===c)"\n"===f?(a.preventDefault(),O(b,ib,void 0)):"\n\n"===f?(a.preventDefault(),O(b,jb,void 0)):null==f&&a.dataTransfer?(f=a.dataTransfer.getData("text/plain"),a.preventDefault(),d.insertRawText(f)):null!=f&&Oa(d,f,!0)&&(a.preventDefault(),O(b,kb,f));else switch(a.preventDefault(),
|
|
34
|
+
c){case "insertFromYank":case "insertFromDrop":case "insertReplacementText":O(b,kb,a);break;case "insertFromComposition":D(null);O(b,kb,a);break;case "insertLineBreak":D(null);O(b,ib,void 0);break;case "insertParagraph":D(null);Wb?(Wb=!1,O(b,ib,void 0)):O(b,jb,void 0);break;case "insertFromPaste":case "insertFromPasteAsQuotation":O(b,lb,a);break;case "deleteByComposition":ac(g,e)&&O(b,mb,void 0);break;case "deleteByDrag":case "deleteByCut":O(b,mb,void 0);break;case "deleteContent":O(b,hb,!1);break;
|
|
35
|
+
case "deleteWordBackward":O(b,nb,!0);break;case "deleteWordForward":O(b,nb,!1);break;case "deleteHardLineBackward":case "deleteSoftLineBackward":O(b,ob,!0);break;case "deleteContentForward":case "deleteHardLineForward":case "deleteSoftLineForward":O(b,ob,!1);break;case "formatStrikeThrough":O(b,N,"strikethrough");break;case "formatBold":O(b,N,"bold");break;case "formatItalic":O(b,N,"italic");break;case "formatUnderline":O(b,N,"underline");break;case "historyUndo":O(b,pb,void 0);break;case "historyRedo":O(b,
|
|
36
|
+
qb,void 0)}}})}function Pb(a,b){a.stopPropagation();I(b,()=>{var c=K();const d=a.data;null!=d&&J(c)&&Oa(c,d,!1)?(Xb&&(bc(b,d),Xb=!1),O(b,kb,d),null!==b._compositionKey&&(Tb=0,D(null))):(La(b,!1),Xb&&(bc(b,d),Xb=!1));F();c=B();cc(c)})}function Nb(a,b){I(b,()=>{const c=K();if(J(c)&&!b.isComposing()){const d=c.anchor;D(d.key);(a.timeStamp<Tb+30||ka&&"element"===d.type||!c.isCollapsed()||c.anchor.getNode().getFormat()!==c.format)&&O(b,kb," ")}})}
|
|
37
|
+
function bc(a,b){var c=a._compositionKey;D(null);if(null!==c&&null!=b){if(""===b){b=H(c);a=va(a.getElementByKey(c));null!==a&&x(b)&&Ma(b,a.nodeValue,null,null,!0);return}if("\n"===b[b.length-1]&&(c=K(),J(c))){b=c.focus;c.anchor.set(b.key,b.offset,b.type);O(a,vb,null);return}}La(a,!0,b)}function Ob(a,b){ka?Xb=!0:I(b,()=>{bc(b,a.data)})}
|
|
38
|
+
function Mb(a,b){Tb=a.timeStamp;if(!b.isComposing()){var {keyCode:c,shiftKey:d,ctrlKey:f,metaKey:e,altKey:g}=a;if(39!==c||f||e||g)if(37!==c||f||e||g)if(38!==c||f||e)if(40!==c||f||e)if(13===c&&d)Wb=!0,O(b,vb,a);else if(32===c)O(b,wb,a);else if(t&&f&&79===c)a.preventDefault(),Wb=!0,O(b,ib,!0);else if(13!==c||d){var h=t?g||e?!1:8===c||72===c&&f:f||g||e?!1:8===c;h?8===c?O(b,xb,a):(a.preventDefault(),O(b,hb,!0)):27===c?O(b,yb,a):(h=t?d||g||e?!1:46===c||68===c&&f:f||g||e?!1:46===c,h?46===c?O(b,zb,a):(a.preventDefault(),
|
|
39
|
+
O(b,hb,!1)):8===c&&(t?g:f)?(a.preventDefault(),O(b,nb,!0)):46===c&&(t?g:f)?(a.preventDefault(),O(b,nb,!1)):t&&e&&8===c?(a.preventDefault(),O(b,ob,!0)):t&&e&&46===c?(a.preventDefault(),O(b,ob,!1)):66===c&&!g&&(t?e:f)?(a.preventDefault(),O(b,N,"bold")):85===c&&!g&&(t?e:f)?(a.preventDefault(),O(b,N,"underline")):73===c&&!g&&(t?e:f)?(a.preventDefault(),O(b,N,"italic")):9!==c||g||f||e?90===c&&!d&&(t?e:f)?(a.preventDefault(),O(b,pb,void 0)):(h=t?90===c&&e&&d:89===c&&f||90===c&&f&&d,h&&(a.preventDefault(),
|
|
40
|
+
O(b,qb,void 0))):O(b,Ab,a))}else Wb=!1,O(b,vb,a);else O(b,ub,a);else O(b,tb,a);else O(b,sb,a);else O(b,rb,a);(f||d||g||e)&&O(b,Ib,a)}}function dc(a){let b=a.__lexicalEventHandles;void 0===b&&(b=[],a.__lexicalEventHandles=b);return b}const ec=new Map;function fc(){const a=window.getSelection(),b=ta(a.anchorNode);if(null!==b){var c=Ka(b);c=c[c.length-1];var d=c._key,f=ec.get(d),e=f||c;e!==b&&Zb(a,e,!1);Zb(a,b,!0);b!==c?ec.set(d,b):f&&ec.delete(d)}}
|
|
41
|
+
function gc(a,b){0===Ub&&a.ownerDocument.addEventListener("selectionchange",fc);Ub++;a.__lexicalEditor=b;const c=dc(a);for(let d=0;d<Rb.length;d++){const [f,e]=Rb[d],g="function"===typeof e?h=>{b.isReadOnly()||e(h,b)}:h=>{if(!b.isReadOnly())switch(f){case "cut":return O(b,Fb,h);case "copy":return O(b,Eb,h);case "paste":return O(b,lb,h);case "dragstart":return O(b,Cb,h);case "dragend":return O(b,Db,h);case "focus":return O(b,Gb,h);case "blur":return O(b,Hb,h);case "drop":return O(b,Bb,h)}};a.addEventListener(f,
|
|
42
|
+
g);c.push(()=>{a.removeEventListener(f,g)})}}let P="",Q="",R="",hc,S,ic,jc=!1,kc=!1,lc,mc=null,nc,oc,pc,qc,rc,sc;function tc(a,b){const c=pc.get(a);if(null!==b){const d=uc(a);b.removeChild(d)}qc.has(a)||S._keyToDOMMap.delete(a);C(c)&&(a=c.__children,vc(a,0,a.length-1,null));void 0!==c&&Qa(sc,ic,lc,c,"destroyed")}function vc(a,b,c,d){for(;b<=c;++b){const f=a[b];void 0!==f&&tc(f,d)}}function wc(a,b){a.setProperty("text-align",b)}
|
|
43
|
+
function xc(a,b){a.style.setProperty("padding-inline-start",0===b?"":20*b+"px")}function yc(a,b){a=a.style;0===b?wc(a,""):1===b?wc(a,"left"):2===b?wc(a,"center"):3===b?wc(a,"right"):4===b&&wc(a,"justify")}
|
|
44
|
+
function zc(a,b,c){const d=qc.get(a);void 0===d&&p(66);const f=d.createDOM(hc,S);var e=S._keyToDOMMap;f["__lexicalKey_"+S._key]=a;e.set(a,f);x(d)?f.setAttribute("data-lexical-text","true"):u(d)&&f.setAttribute("data-lexical-decorator","true");if(C(d)){a=d.__indent;0!==a&&xc(f,a);a=d.__children;var g=a.length;if(0!==g){e=a;--g;const h=Q;Q="";Ac(e,0,g,f,null);Bc(d,f);Q=h}e=d.__format;0!==e&&yc(f,e);Cc(null,a,f);Ua(d)&&(P+="\n\n",R+="\n\n")}else e=d.getTextContent(),u(d)?(g=d.decorate(S),null!==g&&Dc(a,
|
|
45
|
+
g),f.contentEditable="false"):x(d)&&(d.isDirectionless()||(Q+=e),d.isInert()&&(a=f.style,a.pointerEvents="none",a.userSelect="none",f.contentEditable="false",a.setProperty("-webkit-user-select","none"))),P+=e,R+=e;null!==b&&(null!=c?b.insertBefore(f,c):(c=b.__lexicalLineBreak,null!=c?b.insertBefore(f,c):b.appendChild(f)));Qa(sc,ic,lc,d,"created");return f}function Ac(a,b,c,d,f){const e=P;for(P="";b<=c;++b)zc(a[b],d,f);d.__lexicalTextContent=P;P=e+P}
|
|
46
|
+
function Ec(a,b){a=b.get(a[a.length-1]);return ya(a)||u(a)}function Cc(a,b,c){a=null!==a&&(0===a.length||Ec(a,pc));b=null!==b&&(0===b.length||Ec(b,qc));a?b||(b=c.__lexicalLineBreak,null!=b&&c.removeChild(b),c.__lexicalLineBreak=null):b&&(b=document.createElement("br"),c.__lexicalLineBreak=b,c.appendChild(b))}
|
|
47
|
+
function Bc(a,b){var c=b.__lexicalDir;if(b.__lexicalDirTextContent!==Q||c!==mc){const e=""===Q;if(e)var d=mc;else d=Q,d=aa.test(d)?"rtl":ba.test(d)?"ltr":null;if(d!==c){const g=b.classList,h=hc.theme;var f=null!==c?h[c]:void 0;let k=null!==d?h[d]:void 0;void 0!==f&&("string"===typeof f&&(f=f.split(" "),f=h[c]=f),g.remove(...f));null===d||e&&"ltr"===d?b.removeAttribute("dir"):(void 0!==k&&("string"===typeof k&&(c=k.split(" "),k=h[d]=c),g.add(...k)),b.dir=d);kc||(a.getWritable().__dir=d)}mc=d;b.__lexicalDirTextContent=
|
|
48
|
+
Q;b.__lexicalDir=d}}
|
|
49
|
+
function Fc(a,b){var c=pc.get(a),d=qc.get(a);void 0!==c&&void 0!==d||p(67);var f=jc||oc.has(a)||nc.has(a);const e=Gc(S,a);if(c===d&&!f)return C(c)?(d=e.__lexicalTextContent,void 0!==d&&(P+=d,R+=d),d=e.__lexicalDirTextContent,void 0!==d&&(Q+=d)):(d=c.getTextContent(),x(c)&&!c.isDirectionless()&&(Q+=d),R+=d,P+=d),e;c!==d&&f&&Qa(sc,ic,lc,d,"updated");if(d.updateDOM(c,e,hc))return d=zc(a,null,null),null===b&&p(68),b.replaceChild(d,e),tc(a,null),d;if(C(c)&&C(d)){a=d.__indent;a!==c.__indent&&xc(e,a);a=
|
|
50
|
+
d.__format;a!==c.__format&&yc(e,a);a=c.__children;c=d.__children;if(a!==c||f){var g=a,h=c;f=d;b=Q;Q="";const q=P;P="";var k=g.length,m=h.length;if(1===k&&1===m){var l=g[0];h=h[0];if(l===h)Fc(l,e);else{var n=uc(l);h=zc(h,null,null);e.replaceChild(h,n);tc(l,null)}}else if(0===k)0!==m&&Ac(h,0,m-1,e,null);else if(0===m)0!==k&&(l=null==e.__lexicalLineBreak,vc(g,0,k-1,l?null:e),l&&(e.textContent=""));else{const w=k-1;k=m-1;let A=e.firstChild,E=0;for(m=0;E<=w&&m<=k;){var r=g[E];const y=h[m];if(r===y)A=Fc(y,
|
|
51
|
+
e).nextSibling,E++,m++;else{void 0===l&&(l=new Set(g));void 0===n&&(n=new Set(h));const G=n.has(r),W=l.has(y);G?(W?(r=Gc(S,y),r===A?A=Fc(y,e).nextSibling:(null!=A?e.insertBefore(r,A):e.appendChild(r),Fc(y,e)),E++):zc(y,e,A),m++):(A=uc(r).nextSibling,tc(r,e),E++)}}l=E>w;n=m>k;l&&!n?(l=h[k+1],l=void 0===l?null:S.getElementByKey(l),Ac(h,m,k,e,l)):n&&!l&&vc(g,E,w,e)}Ua(f)&&(P+="\n\n");e.__lexicalTextContent=P;P=q+P;Bc(f,e);Q=b;M(d)||Cc(a,c,e)}Ua(d)&&(P+="\n\n",R+="\n\n")}else c=d.getTextContent(),u(d)?
|
|
52
|
+
(f=d.decorate(S),null!==f&&Dc(a,f),P+=c,R+=c):x(d)&&!d.isDirectionless()&&(Q+=c),P+=c,R+=c;!kc&&M(d)&&d.__cachedText!==R&&(d=d.getWritable(),d.__cachedText=R);return e}function Dc(a,b){let c=S._pendingDecorators;const d=S._decorators;if(null===c){if(d[a]===b)return;c=Ea(S)}c[a]=b}function uc(a){a=rc.get(a);void 0===a&&p(69);return a}function Gc(a,b){a=a._keyToDOMMap.get(b);void 0===a&&p(69);return a}let U=null,V=null,Y=!1,Hc=!1,Ca=0;function F(){Y&&p(50)}function z(){null===U&&p(52);return U}
|
|
53
|
+
function B(){null===V&&p(53);return V}function Ic(a,b,c){var d=b.__type;const f=a._nodes.get(d);void 0===f&&p(33,d);a=c.get(d);void 0===a&&(a=Array.from(f.transforms),c.set(d,a));c=a.length;for(d=0;d<c&&(a[d](b),b.isAttached());d++);}function Jc(a,b){b=b._dirtyLeaves;a=a._nodeMap;for(const c of b)b=a.get(c),x(b)&&b.isAttached()&&b.isSimpleText()&&!b.isUnmergeable()&&Za(b)}
|
|
54
|
+
function Kc(a,b){const c=b._dirtyLeaves,d=b._dirtyElements;a=a._nodeMap;const f=B()._compositionKey,e=new Map;var g=c;let h=g.size;for(var k=d,m=k.size;0<h||0<m;){if(0<h){b._dirtyLeaves=new Set;for(const l of g)g=a.get(l),x(g)&&g.isAttached()&&g.isSimpleText()&&!g.isUnmergeable()&&Za(g),void 0!==g&&void 0!==g&&g.__key!==f&&g.isAttached()&&Ic(b,g,e),c.add(l);g=b._dirtyLeaves;h=g.size;if(0<h){Ca++;continue}}b._dirtyLeaves=new Set;b._dirtyElements=new Map;for(const l of k)k=l[0],m=l[1],"root"!==k&&m&&
|
|
55
|
+
(g=a.get(k),void 0!==g&&void 0!==g&&g.__key!==f&&g.isAttached()&&Ic(b,g,e),d.set(k,m));g=b._dirtyLeaves;h=g.size;k=b._dirtyElements;m=k.size;Ca++}b._dirtyLeaves=c;b._dirtyElements=d}function bb(a,b){var c=new Map;c=new Lc(c);const d={originalSelection:a._selection},f=U,e=Y,g=V;U=c;Y=!1;V=b;try{const h=new Map(a._nodeMap),k=h.get("root");$a(k,h,b,null,d)}finally{U=f,Y=e,V=g}c._selection=Mc(d.remappedSelection||d.originalSelection);return c}
|
|
56
|
+
function Nc(a){var b=a._pendingEditorState,c=a._rootElement,d=a._headless;if((null!==c||d)&&null!==b){var f=a._editorState,e=f._selection,g=b._selection,h=0!==a._dirtyType;a._pendingEditorState=null;a._editorState=b;var k=U,m=Y,l=V,n=a._updating;V=a;U=b;Y=!1;a._updating=!0;try{if(!d&&null!==c){var r=a._observer;d=null;if(h&&null!==r){var q=a._dirtyType,w=a._dirtyElements,A=a._dirtyLeaves;r.disconnect();try{Q=R=P="";jc=2===q;mc=null;S=a;hc=a._config;ic=a._nodes;lc=S._listeners.mutation;nc=w;oc=A;pc=
|
|
57
|
+
f._nodeMap;qc=b._nodeMap;kc=b._readOnly;rc=new Map(a._keyToDOMMap);var E=new Map;sc=E;Fc("root",null);sc=rc=hc=qc=pc=oc=nc=ic=S=void 0;d=E}finally{r.observe(c,{characterData:!0,childList:!0,subtree:!0})}}var y=window.getSelection();if(!a._readOnly&&null!==y&&(h||null===g||g.dirty))a:{r=y;const pa=r.anchorNode,cb=r.focusNode,Vd=r.anchorOffset,Wd=r.focusOffset,db=document.activeElement,ea=a._rootElement;if(!a._updateTags.has("collaboration")||db===ea)if(J(g)){var G=g.anchor,W=g.focus,Wc=G.key,X=W.key,
|
|
58
|
+
Xc=Gc(a,Wc),Yc=Gc(a,X),Jb=G.offset,Zc=W.offset,Kb=g.format,$c=g.isCollapsed();X=Xc;y=Yc;E=!1;"text"===G.type&&(X=va(Xc),E=G.getNode().getFormat()!==Kb);"text"===W.type&&(y=va(Yc));if(null!==X&&null!==y){if($c&&(null===e||E||e.format!==Kb)){var Xd=performance.now();Yb=[Kb,Jb,Wc,Xd]}if(Vd===Jb&&Wd===Zc&&pa===X&&cb===y&&("Range"!==r.type||!$c)&&(null===ea||null!==db&&ea.contains(db)||ea.focus({preventScroll:!0}),!na&&!ma||"element"!==G.type))break a;try{r.setBaseAndExtent(X,Jb,y,Zc);if(g.isCollapsed()&&
|
|
59
|
+
ea===db){const fa=3===X.nodeType?X.parentNode:X;if(null!==fa){const eb=fa.getBoundingClientRect();if(eb.bottom>window.innerHeight)fa.scrollIntoView(!1);else if(0>eb.top)fa.scrollIntoView();else if(ea){const ad=ea.getBoundingClientRect();eb.bottom>ad.bottom?fa.scrollIntoView(!1):eb.top<ad.top&&fa.scrollIntoView()}a._updateTags.add("scroll-into-view")}}Vb=!0}catch(fa){}}}else null!==e&&ra(a,pa,cb)&&r.removeAllRanges()}var bd=d;null!==bd&&Oc(a,f,b,bd)}}catch(pa){a._onError(pa);Hc||(Pc(a,null,c,b),Qc(a),
|
|
60
|
+
a._dirtyType=2,Hc=!0,Nc(a),Hc=!1);return}finally{a._updating=n,U=k,Y=m,V=l}b._readOnly=!0;c=a._dirtyLeaves;e=a._dirtyElements;g=a._normalizedNodes;k=a._updateTags;h&&(a._dirtyType=0,a._cloneNotNeeded.clear(),a._dirtyLeaves=new Set,a._dirtyElements=new Map,a._normalizedNodes=new Set,a._updateTags=new Set);h=a._decorators;m=a._pendingDecorators||h;l=b._nodeMap;for(var T in m)l.has(T)||(m===h&&(m=Ea(a)),delete m[T]);T=a._pendingDecorators;null!==T&&(a._decorators=T,a._pendingDecorators=null,Rc("decorator",
|
|
61
|
+
a,!0,T));T=Fa(f);h=Fa(b);T!==h&&Rc("textcontent",a,!0,h);Rc("update",a,!0,{dirtyElements:e,dirtyLeaves:c,editorState:b,normalizedNodes:g,prevEditorState:f,tags:k});b=a._deferred;a._deferred=[];if(0!==b.length){f=a._updating;a._updating=!0;try{for(T=0;T<b.length;T++)b[T]()}finally{a._updating=f}}b=a._updates;if(0!==b.length){const [pa,cb]=b.shift();Sc(a,pa,cb)}}}function Oc(a,b,c,d){a._listeners.mutation.forEach((f,e)=>{f=d.get(f);void 0!==f&&e(f)})}
|
|
62
|
+
function Rc(a,b,c,...d){const f=b._updating;b._updating=c;try{const e=Array.from(b._listeners[a]);for(a=0;a<e.length;a++)e[a](...d)}finally{b._updating=f}}function O(a,b,c){if(!1===a._updating||V!==a){let e=!1;a.update(()=>{e=O(a,b,c)});return e}const d=Ka(a);for(let e=4;0<=e;e--)for(let g=0;g<d.length;g++){var f=d[g]._commands.get(b);if(void 0!==f&&(f=f[e],void 0!==f))for(const h of f)if(!0===h(c,a))return!0}return!1}
|
|
63
|
+
function Tc(a,b){const c=a._updates;for(b=b||!1;0!==c.length;){const [d,f]=c.shift();let e,g;void 0!==f&&(e=f.onUpdate,g=f.tag,f.skipTransforms&&(b=!0),e&&a._deferred.push(e),g&&a._updateTags.add(g));d()}return b}
|
|
64
|
+
function Sc(a,b,c){const d=a._updateTags;var f=!1;if(void 0!==c){var e=c.onUpdate;f=c.tag;null!=f&&d.add(f);f=c.skipTransforms}e&&a._deferred.push(e);c=a._editorState;e=a._pendingEditorState;let g=!1;null===e&&(e=a._pendingEditorState=new Lc(new Map(c._nodeMap)),g=!0);const h=U,k=Y,m=V,l=a._updating;U=e;Y=!1;a._updating=!0;V=a;try{g&&!a._headless&&(e._selection=Uc(a));const n=a._compositionKey;b();f=Tc(a,f);Vc(e,a);0!==a._dirtyType&&(f?Jc(e,a):Kc(e,a),Tc(a),Wa(c,e,a._dirtyLeaves,a._dirtyElements));
|
|
65
|
+
n!==a._compositionKey&&(e._flushSync=!0);const r=e._selection;if(J(r)){const q=e._nodeMap,w=r.focus.key;void 0!==q.get(r.anchor.key)&&void 0!==q.get(w)||p(54)}else cd(r)&&0===r._nodes.size&&(e._selection=null)}catch(n){a._onError(n);a._pendingEditorState=c;a._dirtyType=2;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();Nc(a);return}finally{U=h,Y=k,V=m,a._updating=l,Ca=0}0!==a._dirtyType||dd(e,a)?e._flushSync?(e._flushSync=!1,Nc(a)):g&&qa(()=>{Nc(a)}):(e._flushSync=!1,g&&(d.clear(),
|
|
66
|
+
a._deferred=[],a._pendingEditorState=null))}function I(a,b,c){a._updating?a._updates.push([b,c]):Sc(a,b,c)}let ed=!1,fd=0;function gd(a){fd=a.timeStamp}function hd(a,b,c){return b.__lexicalLineBreak===a||void 0!==a["__lexicalKey_"+c._key]}function id(a){return a.getEditorState().read(()=>{const b=K();return null!==b?b.clone():null})}
|
|
67
|
+
function jd(a,b,c){ed=!0;const d=100<performance.now()-fd;try{I(a,()=>{var f=new Map,e=a.getRootElement(),g=a._editorState;let h=!1,k="";for(var m=0;m<b.length;m++){var l=b[m],n=l.type,r=l.target,q=sa(r,g);if(!u(q))if("characterData"===n){if(d&&3===r.nodeType&&x(q)&&q.isAttached()){l=window.getSelection();var w=n=null;null!==l&&l.anchorNode===r&&(n=l.anchorOffset,w=l.focusOffset);Ma(q,r.nodeValue,n,w,!1)}}else if("childList"===n){h=!0;n=l.addedNodes;for(w=0;w<n.length;w++){var A=n[w],E=Da(A),y=A.parentNode;
|
|
68
|
+
null==y||null!==E||"BR"===A.nodeName&&hd(A,y,a)||(ka&&(E=A.innerText||A.nodeValue)&&(k+=E),y.removeChild(A))}l=l.removedNodes;n=l.length;if(0<n){w=0;for(A=0;A<n;A++)y=l[A],"BR"===y.nodeName&&hd(y,r,a)&&(r.appendChild(y),w++);n!==w&&(r===e&&(q=g._nodeMap.get("root")),f.set(r,q))}}}if(0<f.size)for(const [G,W]of f)if(C(W))for(f=W.__children,e=G.firstChild,g=0;g<f.length;g++)m=a.getElementByKey(f[g]),null!==m&&(null==e?(G.appendChild(m),e=m):e!==m&&G.replaceChild(m,e),e=e.nextSibling);else x(W)&&W.markDirty();
|
|
69
|
+
f=c.takeRecords();if(0<f.length){for(e=0;e<f.length;e++)for(m=f[e],g=m.addedNodes,m=m.target,q=0;q<g.length;q++)r=g[q],l=r.parentNode,null==l||"BR"!==r.nodeName||hd(r,m,a)||l.removeChild(r);c.takeRecords()}f=K()||id(a);null!==f&&(h&&(f.dirty=!0,Ia(f)),ka&&Ta()&&f.insertRawText(k))})}finally{ed=!1}}function cc(a){const b=a._observer;if(null!==b){const c=b.takeRecords();jd(a,c,b)}}
|
|
70
|
+
function Qc(a){0===fd&&window.addEventListener("textInput",gd,!0);a._observer=new MutationObserver((b,c)=>{jd(a,b,c)})}
|
|
71
|
+
class kd{constructor(a,b,c){this._selection=null;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;C(b)&&(b=b.getDescendantByIndex(d));C(c)&&(c=c.getDescendantByIndex(a));return b===c?d<a:b.isBefore(c)}getNode(){const a=H(this.key);null===a&&p(24);return a}set(a,b,c){const d=this._selection,f=this.key;this.key=a;this.offset=b;this.type=c;Y||(B()._compositionKey===
|
|
72
|
+
f&&D(a),null===d||d.anchor!==this&&d.focus!==this||(d._cachedNodes=null,d.dirty=!0))}}function Z(a,b,c){return new kd(a,b,c)}function ld(a,b){const c=b.__key;let d=a.offset,f="element";x(b)&&(f="text",b=b.getTextContentSize(),d>b&&(d=b));a.set(c,d,f)}function md(a,b){if(C(b)){const c=b.getLastDescendant();C(c)||x(c)?ld(a,c):ld(a,b)}else x(b)&&ld(a,b)}
|
|
73
|
+
function nd(a,b,c){const d=a.getNode(),f=d.getChildAtIndex(a.offset),e=L(),g=M(d)?od().append(e):e;e.setFormat(c);null===f?d.append(g):f.insertBefore(g);a.is(b)&&b.set(e.__key,0,"text");a.set(e.__key,0,"text")}function pd(a,b,c,d){a.key=b;a.offset=c;a.type=d}
|
|
74
|
+
class qd{constructor(a){this.dirty=!1;this._nodes=a;this._cachedNodes=null}is(a){if(!cd(a))return!1;const b=this._nodes,c=a._nodes;return b.size===c.size&&Array.from(b).every(d=>c.has(d))}add(a){this.dirty=!0;this._nodes.add(a);this._cachedNodes=null}delete(a){this.dirty=!0;this._nodes.delete(a);this._cachedNodes=null}clear(){this.dirty=!0;this._nodes.clear();this._cachedNodes=null}has(a){return this._nodes.has(a)}clone(){return new qd(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(){}insertText(){}getNodes(){var a=
|
|
75
|
+
this._cachedNodes;if(null!==a)return a;var b=this._nodes;a=[];for(const c of b)b=H(c),null!==b&&a.push(b);Y||(this._cachedNodes=a);return a}getTextContent(){const a=this.getNodes();let b="";for(let c=0;c<a.length;c++)b+=a[c].getTextContent();return b}}function J(a){return a instanceof rd}
|
|
76
|
+
class sd{constructor(a,b,c){this.gridKey=a;this.anchor=b;this.focus=c;this.dirty=!1;this._cachedNodes=null;b._selection=this;c._selection=this}is(a){return td(a)?this.gridKey===a.gridKey&&this.anchor.is(this.focus):!1}set(a,b,c){this.dirty=!0;this.gridKey=a;this.anchor.key=b;this.focus.key=c;this._cachedNodes=null}clone(){return new sd(this.gridKey,this.anchor,this.focus)}isCollapsed(){return!1}isBackward(){return this.focus.isBefore(this.anchor)}getCharacterOffsets(){return ud(this)}extract(){return this.getNodes()}insertRawText(){}insertText(){}getShape(){var a=
|
|
77
|
+
H(this.anchor.key);a||p(25);var b=a.getIndexWithinParent();a=a.getParentOrThrow().getIndexWithinParent();var c=H(this.focus.key);c||p(26);var d=c.getIndexWithinParent();const f=c.getParentOrThrow().getIndexWithinParent();c=Math.min(b,d);b=Math.max(b,d);d=Math.min(a,f);a=Math.max(a,f);return{fromX:Math.min(c,b),fromY:Math.min(d,a),toX:Math.max(c,b),toY:Math.max(d,a)}}getNodes(){var a=this._cachedNodes;if(null!==a)return a;a=new Set;const {fromX:b,fromY:c,toX:d,toY:f}=this.getShape();var e=H(this.gridKey);
|
|
78
|
+
vd(e)||p(27);a.add(e);e=e.getChildren();for(let k=c;k<=f;k++){var g=e[k];a.add(g);wd(g)||p(18);g=g.getChildren();for(let m=b;m<=d;m++){var h=g[m];xd(h)||p(19);a.add(h);for(h=h.getChildren();0<h.length;){const l=h.shift();a.add(l);C(l)&&h.unshift(...l.getChildren())}}}a=Array.from(a);Y||(this._cachedNodes=a);return a}getTextContent(){const a=this.getNodes();let b="";for(let c=0;c<a.length;c++)b+=a[c].getTextContent();return b}}function td(a){return a instanceof sd}
|
|
79
|
+
class rd{constructor(a,b,c){this.anchor=a;this.focus=b;this.dirty=!1;this.format=c;this._cachedNodes=null;a._selection=this;b._selection=this}is(a){return J(a)?this.anchor.is(a.anchor)&&this.focus.is(a.focus)&&this.format===a.format:!1}isBackward(){return this.focus.isBefore(this.anchor)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){var a=this._cachedNodes;if(null!==a)return a;a=this.anchor;const b=this.focus;let c=a.getNode(),d=b.getNode();C(c)&&(c=c.getDescendantByIndex(a.offset));
|
|
80
|
+
C(d)&&(d=d.getDescendantByIndex(b.offset));a=c.is(d)?C(c)&&(0<c.getChildrenSize()||c.excludeFromCopy())?[]:[c]:c.getNodesBetween(d);Y||(this._cachedNodes=a);return a}setTextNodeRange(a,b,c,d){pd(this.anchor,a.__key,b,"text");pd(this.focus,c.__key,d,"text");this._cachedNodes=null;this.dirty=!0}getTextContent(){const a=this.getNodes();if(0===a.length)return"";const b=a[0],c=a[a.length-1],d=this.anchor.isBefore(this.focus),[f,e]=ud(this);let g="",h=!0;for(let k=0;k<a.length;k++){const m=a[k];if(C(m)&&
|
|
81
|
+
!m.isInline())h||(g+="\n"),h=m.isEmpty()?!1:!0;else if(h=!1,x(m)){let l=m.getTextContent();m===b?l=m===c?f<e?l.slice(f,e):l.slice(e,f):d?l.slice(f):l.slice(e):m===c&&(l=d?l.slice(0,e):l.slice(0,f));g+=l}else!u(m)&&!ya(m)||m===c&&this.isCollapsed()||(g+=m.getTextContent())}return g}applyDOMRange(a){const b=B(),c=b.getEditorState()._selection;a=yd(a.startContainer,a.startOffset,a.endContainer,a.endOffset,b,c);if(null!==a){var [d,f]=a;pd(this.anchor,d.key,d.offset,d.type);pd(this.focus,f.key,f.offset,
|
|
82
|
+
f.type);this._cachedNodes=null}}clone(){const a=this.anchor,b=this.focus;return new rd(Z(a.key,a.offset,a.type),Z(b.key,b.offset,b.type),this.format)}toggleFormat(a){this.format=wa(this.format,a,null);this.dirty=!0}hasFormat(a){return 0!==(this.format&ca[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 f=b[d];""!==f&&a.push(L(f));d!==c-1&&a.push(zd())}this.insertNodes(a)}}insertText(a){var b=this.anchor,c=this.focus,
|
|
83
|
+
d=this.isCollapsed()||b.isBefore(c),f=this.format;d&&"element"===b.type?nd(b,c,f):d||"element"!==c.type||nd(c,b,f);var e=this.getNodes(),g=e.length,h=d?c:b;c=(d?b:c).offset;var k=h.offset;b=e[0];x(b)||p(28);d=b.getTextContent().length;var m=b.getParentOrThrow(),l=e[g-1];if(this.isCollapsed()&&c===d&&(b.isSegmented()||b.isToken()||!b.canInsertTextAfter()||!m.canInsertTextAfter())){var n=b.getNextSibling();if(!x(n)||ua(n))n=L(),m.canInsertTextAfter()?b.insertAfter(n):m.insertAfter(n);n.select(0,0);
|
|
84
|
+
b=n;if(""!==a){this.insertText(a);return}}else if(this.isCollapsed()&&0===c&&(b.isSegmented()||b.isToken()||!b.canInsertTextBefore()||!m.canInsertTextBefore())){n=b.getPreviousSibling();if(!x(n)||ua(n))n=L(),m.canInsertTextBefore()?b.insertBefore(n):m.insertBefore(n);n.select();b=n;if(""!==a){this.insertText(a);return}}else if(b.isSegmented()&&c!==d)m=L(b.getTextContent()),b.replace(m),b=m;else if(!(this.isCollapsed()||""===a||(n=l.getParent(),m.canInsertTextBefore()&&m.canInsertTextAfter()&&(!C(n)||
|
|
85
|
+
n.canInsertTextBefore()&&n.canInsertTextAfter())))){this.insertText("");Ad(this.anchor,this.focus,null);this.insertText(a);return}if(1===g)if(v(b))a=L(a),a.select(),b.replace(a);else{e=b.getFormat();if(c===k&&e!==f)if(""===b.getTextContent())b.setFormat(f);else{e=L(a);e.setFormat(f);e.select();0===c?b.insertBefore(e):([g]=b.splitText(c),g.insertAfter(e));e.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=a.length);return}b=b.spliceText(c,k-c,a,!0);""===b.getTextContent()?b.remove():
|
|
86
|
+
b.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=a.length)}else{f=new Set([...b.getParentKeys(),...l.getParentKeys()]);var r=C(b)?b:b.getParentOrThrow();m=C(l)?l:l.getParentOrThrow();n=l;if(!r.is(m)&&m.isInline()){do n=m,m=m.getParentOrThrow();while(m.isInline())}"text"===h.type&&(0!==k||""===l.getTextContent())||"element"===h.type&&l.getIndexWithinParent()<k?x(l)&&!v(l)&&k!==l.getTextContentSize()?(l.isSegmented()&&(h=L(l.getTextContent()),l.replace(h),l=h),l=l.spliceText(0,k,""),
|
|
87
|
+
f.add(l.__key)):(h=l.getParentOrThrow(),h.canBeEmpty()||1!==h.getChildrenSize()?l.remove():h.remove()):f.add(l.__key);h=m.getChildren();k=new Set(e);l=r.is(m);r=r.isInline()&&null===b.getNextSibling()?r:b;for(let q=h.length-1;0<=q;q--){const w=h[q];if(w.is(b)||C(w)&&w.isParentOf(b))break;w.isAttached()&&(!k.has(w)||w.is(n)?l||r.insertAfter(w):w.remove())}if(!l)for(h=m,k=null;null!==h;){l=h.getChildren();m=l.length;if(0===m||l[m-1].is(k))f.delete(h.__key),k=h;h=h.getParent()}v(b)?c===d?b.select():
|
|
88
|
+
(a=L(a),a.select(),b.replace(a)):(b=b.spliceText(c,d-c,a,!0),""===b.getTextContent()?b.remove():b.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=a.length));for(a=1;a<g;a++)b=e[a],f.has(b.__key)||b.remove()}}removeText(){this.insertText("")}formatText(a){const b=this.getNodes(),c=b.length-1;let d=b[0],f=b[c];if(this.isCollapsed())this.toggleFormat(a),D(null);else{var e=this.anchor,g=this.focus,h=g.offset,k=0,m=d.getTextContent().length;for(var l=0;l<b.length;l++){var n=b[l];if(x(n)){k=
|
|
89
|
+
n.getFormatFlags(a,null);break}}var r=e.offset;n=(l=e.isBefore(g))?r:h;l=l?h:r;if(n===d.getTextContentSize()){let q=d.getNextSibling();C(q)&&q.isInline()&&(q=q.getFirstChild());x(q)&&(n=r=0,d=q,m=q.getTextContent().length,k=d.getFormatFlags(a,null))}if(d.is(f))x(d)&&("element"===e.type&&"element"===g.type?(d.setFormat(k),d.select(n,l),this.format=k):(n=r>h?h:r,l=r>h?r:h,n!==l&&(0===n&&l===m?(d.setFormat(k),d.select(n,l)):(a=d.splitText(n,l),a=0===n?a[0]:a[1],a.setFormat(k),a.select(0,l-n)),this.format=
|
|
90
|
+
k)));else for(x(d)&&(0!==n&&([,d]=d.splitText(n)),d.setFormat(k)),e=k,x(f)&&(e=f.getFormatFlags(a,k),k=f.getTextContent().length,0!==l&&(l!==k&&([f]=f.splitText(l)),f.setFormat(e))),k=1;k<c;k++)l=b[k],g=l.__key,x(l)&&g!==d.__key&&g!==f.__key&&!l.isToken()&&(g=l.getFormatFlags(a,e),l.setFormat(g))}}insertNodes(a,b){this.isCollapsed()||this.removeText();var c=this.anchor,d=c.offset,f=c.getNode(),e=f;"element"===c.type&&(e=c.getNode(),c=e.getChildAtIndex(d-1),e=null===c?e:c);c=[];var g=f.getNextSiblings(),
|
|
91
|
+
h=M(f)?null:f.getTopLevelElementOrThrow();if(x(f))if(e=f.getTextContent().length,0===d&&0!==e)e=f.getPreviousSibling(),e=null!==e?e:f.getParentOrThrow(),c.push(f);else if(d===e)e=f;else{if(v(f))return!1;[e,f]=f.splitText(d);c.push(f)}const k=e;c.push(...g);g=a[0];var m=!1;f=null;for(let r=0;r<a.length;r++){const q=a[r];if(C(q)&&!q.isInline()){if(q.is(g)){if(C(e)&&e.isEmpty()&&e.canReplaceWith(q)){e.replace(q);e=q;m=!0;continue}var l=q.getFirstDescendant();if(xa(l)){for(l=l.getParentOrThrow();l.isInline();)l=
|
|
92
|
+
l.getParentOrThrow();m=l.getChildren();var n=m.length;if(C(e))for(let w=0;w<n;w++)f=m[w],e.append(f);else{for(--n;0<=n;n--)f=m[n],e.insertAfter(f);e=e.getParentOrThrow()}l.remove();m=!0;if(l.is(q))continue}}x(e)&&(null===h&&p(29),e=h)}else m&&!u(q)&&M(e.getParent())&&p(30);m=!1;if(C(e)&&!e.isInline())if(f=q,u(q)&&q.isTopLevel())e=e.insertAfter(q);else if(C(q)){if(q.canBeEmpty()||!q.isEmpty())M(e)?(l=e.getChildAtIndex(d),null!==l?l.insertBefore(q):e.append(q),e=q):e=e.insertAfter(q)}else l=e.getFirstChild(),
|
|
93
|
+
null!==l?l.insertBefore(q):e.append(q),e=q;else!C(q)||C(q)&&q.isInline()||u(e)&&e.isTopLevel()?(f=q,e=e.insertAfter(q)):(e=q.getParentOrThrow(),r--)}b&&(x(k)?k.select():(a=e.getPreviousSibling(),x(a)?a.select():(a=e.getIndexWithinParent(),e.getParentOrThrow().select(a,a))));if(C(e)){if(a=x(f)?f:e.getLastDescendant(),b||(null===a?e.select():x(a)?a.select():a.selectNext()),0!==c.length)for(b=c.length-1;0<=b;b--)a=c[b],d=a.getParentOrThrow(),C(e)&&!C(a)?(e.append(a),e=a):C(e)||C(a)?C(a)&&!a.canInsertAfter(e)?
|
|
94
|
+
(h=d.constructor.clone(d),C(h)||p(31),h.append(a),e.insertAfter(h)):e.insertAfter(a):(e.insertBefore(a),e=a),d.isEmpty()&&!d.canBeEmpty()&&d.remove()}else b||(x(e)?e.select():(c=e.getParentOrThrow(),e=e.getIndexWithinParent()+1,c.select(e,e)));return!0}insertParagraph(){this.isCollapsed()||this.removeText();var a=this.anchor,b=a.offset,c=[];if("text"===a.type){var d=a.getNode();var f=d.getNextSiblings().reverse();var e=d.getParentOrThrow();var g=e.isInline(),h=g?e.getTextContentSize():d.getTextContentSize();
|
|
95
|
+
0===b?f.push(d):(g&&(c=e.getNextSiblings()),b===h||g&&b===d.getTextContentSize()||([,d]=d.splitText(b),f.push(d)))}else{e=a.getNode();if(M(e)){f=od();c=e.getChildAtIndex(b);f.select();null!==c?c.insertBefore(f):e.append(f);return}f=e.getChildren().slice(b).reverse()}d=f.length;if(0===b&&0<d&&e.isInline()){if(c=e.getParentOrThrow(),f=c.insertNewAfter(this),C(f))for(c=c.getChildren(),e=0;e<c.length;e++)f.append(c[e])}else if(g=e.insertNewAfter(this),null===g)this.insertLineBreak();else if(C(g))if(h=
|
|
96
|
+
e.getFirstChild(),0===b&&(e.is(a.getNode())||h&&h.is(a.getNode()))&&0<d)e.insertBefore(g);else{e=null;b=c.length;a=g.getParentOrThrow();if(0<b)for(h=0;h<b;h++)a.append(c[h]);if(0!==d)for(c=0;c<d;c++)b=f[c],null===e?g.append(b):e.insertBefore(b),e=b;g.canBeEmpty()||0!==g.getChildrenSize()?g.selectStart():(g.selectPrevious(),g.remove())}}insertLineBreak(a){const b=zd();var c=this.anchor;"element"===c.type&&(c=c.getNode(),M(c)&&this.insertParagraph());a?this.insertNodes([b],!0):this.insertNodes([b])&&
|
|
97
|
+
b.selectNext(0,0)}getCharacterOffsets(){return ud(this)}extract(){var a=this.getNodes(),b=a.length,c=b-1,d=this.anchor;const f=this.focus;var e=a[0];let g=a[c];const [h,k]=ud(this);if(0===b)return[];if(1===b)return x(e)?(a=h>k?k:h,c=e.splitText(a,h>k?h:k),a=0===a?c[0]:c[1],null!=a?[a]:[]):[e];b=d.isBefore(f);x(e)&&(d=b?h:k,d===e.getTextContentSize()?a.shift():0!==d&&([,e]=e.splitText(d),a[0]=e));x(g)&&(e=g.getTextContent().length,b=b?k:h,0===b?a.pop():b!==e&&([g]=g.splitText(b),a[c]=g));return a}modify(a,
|
|
98
|
+
b,c){var d=this.focus,f=this.anchor,e="move"===a,g=Sa(d,b);u(g)&&!g.isIsolated()?(a=b?g.getPreviousSibling():g.getNextSibling(),x(a)?(g=a.__key,b=b?a.getTextContent().length:0,d.set(g,b,"text"),e&&f.set(g,b,"text")):(c=g.getParentOrThrow(),C(a)?(c=a.__key,g=b?a.getChildrenSize():0):(g=g.getIndexWithinParent(),c=c.__key,b||g++),d.set(c,g,"element"),e&&f.set(c,g,"element"))):(d=window.getSelection(),d.modify(a,b?"backward":"forward",c),0<d.rangeCount&&(b=d.getRangeAt(0),this.applyDOMRange(b),this.dirty=
|
|
99
|
+
!0,e||d.anchorNode===b.startContainer&&d.anchorOffset===b.startOffset||(e=this.focus,b=this.anchor,d=b.key,f=b.offset,g=b.type,pd(b,e.key,e.offset,e.type),pd(e,d,f,g),this._cachedNodes=null)))}deleteCharacter(a){if(this.isCollapsed()){var b=this.anchor,c=this.focus,d=b.getNode();if(!a&&("element"===b.type&&b.offset===d.getChildrenSize()||"text"===b.type&&b.offset===d.getTextContentSize())&&(d=d.getNextSibling()||d.getParentOrThrow().getNextSibling(),C(d)&&!d.canExtractContents()))return;this.modify("extend",
|
|
100
|
+
a,"character");if(!this.isCollapsed()){var f="text"===c.type?c.getNode():null;d="text"===b.type?b.getNode():null;if(null!==f&&f.isSegmented()){if(b=c.offset,c=f.getTextContentSize(),f.is(d)||a&&b!==c||!a&&0!==b){Bd(f,a,b);return}}else if(null!==d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(f)||a&&0!==b||!a&&b!==c)){Bd(d,a,b);return}d=this.anchor;f=this.focus;b=d.getNode();c=f.getNode();if(b===c&&"text"===d.type&&"text"===f.type){var e=d.offset,g=f.offset;const h=e<g;c=h?e:g;g=h?g:
|
|
101
|
+
e;e=g-1;c!==e&&(b=b.getTextContent().slice(c,g),/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(b)||(a?f.offset=e:d.offset=e))}}else if(a&&0===b.offset&&("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).collapseAtStart(this))return}this.removeText()}deleteLine(a){this.isCollapsed()&&this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");this.removeText()}}function cd(a){return a instanceof qd}
|
|
102
|
+
function Cd(a){const b=a.offset;if("text"===a.type)return b;a=a.getNode();return b===a.getChildrenSize()?a.getTextContent().length:0}function ud(a){const b=a.anchor;a=a.focus;return"element"===b.type&&"element"===a.type&&b.key===a.key&&b.offset===a.offset?[0,0]:[Cd(b),Cd(a)]}
|
|
103
|
+
function Bd(a,b,c){const d=a.getTextContent().split(/(?=\s)/g),f=d.length;let e=0,g=0;for(let h=0;h<f;h++){const k=d[h],m=h===f-1;g=e;e+=k.length;if(b&&e===c||e>c||m){d.splice(h,1);m&&(g=void 0);break}}b=d.join("").trim();""===b?a.remove():(a.setTextContent(b),a.select(g,g))}
|
|
104
|
+
function Dd(a,b,c){var d=b;if(1===a.nodeType){let g=!1;var f=a.childNodes;var e=f.length;d===e&&(g=!0,d=e-1);f=Ja(f[d]);if(x(f))d=g?f.getTextContentSize():0;else{e=Ja(a);if(null===e)return null;if(C(e)){a=e.getChildAtIndex(d);if(b=C(a))b=a.getParent(),b=null===c||null===b||!b.canBeEmpty()||b!==c.getNode();b&&(c=g?a.getLastDescendant():a.getFirstDescendant(),null===c?(e=a,d=0):(a=c,e=a.getParentOrThrow()));x(a)?(f=a,e=null,d=g?f.getTextContentSize():0):a!==e&&g&&d++}else d=e.getIndexWithinParent(),
|
|
105
|
+
d=0===b&&u(e)&&Ja(a)===e?d:d+1,e=e.getParentOrThrow();if(C(e))return Z(e.__key,d,"element")}}else f=Ja(a);return x(f)?Z(f.__key,d,"text"):null}
|
|
106
|
+
function Ed(a,b,c){var d=a.offset,f=a.getNode();0===d?(d=f.getPreviousSibling(),f=f.getParent(),b)?(c||!b)&&null===d&&C(f)&&f.isInline()&&(b=f.getPreviousSibling(),x(b)&&(a.key=b.__key,a.offset=b.getTextContent().length)):C(d)&&!c&&d.isInline()?(a.key=d.__key,a.offset=d.getChildrenSize(),a.type="element"):x(d)&&!d.isInert()&&(a.key=d.__key,a.offset=d.getTextContent().length):d===f.getTextContent().length&&(d=f.getNextSibling(),f=f.getParent(),b&&C(d)&&d.isInline()?(a.key=d.__key,a.offset=0,a.type=
|
|
107
|
+
"element"):(c||b)&&null===d&&C(f)&&f.isInline()&&!f.canInsertTextAfter()&&(b=f.getNextSibling(),x(b)&&(a.key=b.__key,a.offset=0)))}function Ad(a,b,c){if("text"===a.type&&"text"===b.type){var d=a.isBefore(b);const f=a.is(b);Ed(a,d,f);Ed(b,!d,f);f&&(b.key=a.key,b.offset=a.offset,b.type=a.type);d=B();d.isComposing()&&d._compositionKey!==a.key&&J(c)&&(d=c.anchor,c=c.focus,pd(a,d.key,d.offset,d.type),pd(b,c.key,c.offset,c.type))}}
|
|
108
|
+
function yd(a,b,c,d,f,e){if(null===a||null===c||!ra(f,a,c))return null;b=Dd(a,b,J(e)?e.anchor:null);if(null===b)return null;d=Dd(c,d,J(e)?e.focus:null);if(null===d||"element"===b.type&&"element"===d.type&&(a=Ja(a),c=Ja(c),u(a)&&u(c)))return null;Ad(b,d,e);return[b,d]}function Fd(a,b,c,d,f,e){const g=z();a=new rd(Z(a,b,f),Z(c,d,e),0);a.dirty=!0;return g._selection=a}
|
|
109
|
+
function Uc(a){var b=a.getEditorState()._selection,c=window.getSelection();if(cd(b)||td(b))return b.clone();{var d=(d=window.event)&&d.type;d=!ed&&("selectionchange"===d||"beforeinput"===d||"compositionstart"===d||"compositionend"===d||"click"===d&&3===window.event.detail||void 0===d);let g,h;if(!J(b)||d)if(null===c)b=null;else if(d=c.anchorNode,g=c.focusNode,h=c.anchorOffset,c=c.focusOffset,a=yd(d,h,g,c,a,b),null===a)b=null;else{var [f,e]=a;b=new rd(f,e,J(b)?b.format:0)}else b=b.clone()}return b}
|
|
110
|
+
function K(){return z()._selection}function Na(){return B()._editorState._selection}function Mc(a){if(null!==a){if("range"===a.type)return new rd(Z(a.anchor.key,a.anchor.offset,a.anchor.type),Z(a.focus.key,a.focus.offset,a.focus.type),0);if("node"===a.type)return new qd(new Set(a.nodes));if("grid"===a.type)return new sd(a.gridKey,Z(a.anchor.key,a.anchor.offset,a.anchor.type),Z(a.focus.key,a.focus.offset,a.focus.type))}return null}
|
|
111
|
+
function Gd(a,b,c,d=1){var f=a.anchor,e=a.focus,g=f.getNode(),h=e.getNode();if(b.is(g)||b.is(h))if(g=b.__key,a.isCollapsed())b=f.offset,c<=b&&(c=Math.max(0,b+d),f.set(g,c,"element"),e.set(g,c,"element"),Hd(a));else{var k=a.isBackward();h=k?e:f;var m=h.getNode();f=k?f:e;e=f.getNode();b.is(m)&&(m=h.offset,c<=m&&h.set(g,Math.max(0,m+d),"element"));b.is(e)&&(b=f.offset,c<=b&&f.set(g,Math.max(0,b+d),"element"));Hd(a)}}
|
|
112
|
+
function Hd(a){var b=a.anchor,c=b.offset;const d=a.focus;var f=d.offset,e=b.getNode(),g=d.getNode();if(a.isCollapsed())C(e)&&(g=e.getChildrenSize(),g=(f=c>=g)?e.getChildAtIndex(g-1):e.getChildAtIndex(c),x(g)&&(c=0,f&&(c=g.getTextContentSize()),b.set(g.__key,c,"text"),d.set(g.__key,c,"text")));else{if(C(e)){const h=e.getChildrenSize();c=(a=c>=h)?e.getChildAtIndex(h-1):e.getChildAtIndex(c);x(c)&&(e=0,a&&(e=c.getTextContentSize()),b.set(c.__key,e,"text"))}C(g)&&(c=g.getChildrenSize(),f=(b=f>=c)?g.getChildAtIndex(c-
|
|
113
|
+
1):g.getChildAtIndex(f),x(f)&&(g=0,b&&(g=f.getTextContentSize()),d.set(f.__key,g,"text")))}}function Vc(a,b){b=b.getEditorState()._selection;a=a._selection;if(J(a)){var c=a.anchor;const d=a.focus;let f;"text"===c.type&&(f=c.getNode(),f.selectionTransform(b,a));"text"===d.type&&(c=d.getNode(),f!==c&&c.selectionTransform(b,a))}}
|
|
114
|
+
function Id(a,b,c,d,f){let e=null,g=0,h=null;null!==d?(e=d.__key,x(d)?(g=d.getTextContentSize(),h="text"):C(d)&&(g=d.getChildrenSize(),h="element")):null!==f&&(e=f.__key,x(f)?h="text":C(f)&&(h="element"));null!==e&&null!==h?a.set(e,g,h):(g=b.getIndexWithinParent(),-1===g&&(g=c.getChildrenSize()),a.set(c.__key,g,"element"))}function Jd(a,b,c,d,f){"text"===a.type?(a.key=c,b||(a.offset+=f)):a.offset>d.getIndexWithinParent()&&--a.offset}
|
|
115
|
+
function Kd(a,b,c){F();var d=a.__key;const f=a.getParent();if(null!==f){var e=K(),g=!1;if(J(e)&&b){var h=e.anchor;const k=e.focus;h.key===d&&(Id(h,a,f,a.getPreviousSibling(),a.getNextSibling()),g=!0);k.key===d&&(Id(k,a,f,a.getPreviousSibling(),a.getNextSibling()),g=!0)}h=f.getWritable().__children;d=h.indexOf(d);-1===d&&p(34);Aa(a);h.splice(d,1);a.getWritable().__parent=null;J(e)&&b&&!g&&Gd(e,f,d,-1);c||null===f||M(f)||f.canBeEmpty()||!f.isEmpty()||Kd(f,b);null!==f&&M(f)&&f.isEmpty()&&f.selectEnd()}}
|
|
116
|
+
function Ld(a){const b=H(a);null===b&&p(55,a);return b}
|
|
117
|
+
class Md{static getType(){p(56,this.name)}static clone(){p(57,this.name)}constructor(a){this.__type=this.constructor.getType();this.__parent=null;if(null!=a)this.__key=a;else{F();99<Ca&&p(51);a=B();var b=z(),c=""+oa++;b._nodeMap.set(c,this);C(this)?a._dirtyElements.set(c,!0):a._dirtyLeaves.add(c);a._cloneNotNeeded.add(c);a._dirtyType=1;this.__key=c}}getType(){return this.__type}isAttached(){for(var a=this.__key;null!==a;){if("root"===a)return!0;a=H(a);if(null===a)break;a=a.__parent}return!1}isSelected(){const a=
|
|
118
|
+
K();if(null==a)return!1;const b=a.getNodes().some(c=>c.__key===this.__key);return x(this)?b:J(a)&&"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:H(a)}getParentOrThrow(){const a=this.getParent();null===a&&p(58,this.__key);return a}getTopLevelElement(){let a=
|
|
119
|
+
this;for(;null!==a;){const b=a.getParent();if(M(b)&&C(a))return a;a=b}return null}getTopLevelElementOrThrow(){const a=this.getTopLevelElement();null===a&&p(59,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>=
|
|
120
|
+
b?null:H(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=>Ld(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:H(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=>Ld(c))}getCommonAncestor(a){const b=this.getParents();var c=
|
|
115
121
|
a.getParents();C(this)&&b.unshift(this);C(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 f=b[d];if(c.has(f))return f}return null}is(a){return null==a?!1:this.__key===a.__key}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===b){b=
|
|
116
122
|
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 f=this;let e=null;for(;;){var g=f.__key;d.has(g)||(d.add(g),c.push(f));if(f===a)break;g=C(f)?b?f.getFirstChild():f.getLastChild():null;if(null!==g)null===e&&(e=f),f=g;else if(g=b?f.getNextSibling():f.getPreviousSibling(),null!==g)f=g;else{g=f.getParentOrThrow();d.has(g.__key)||
|
|
117
|
-
c.push(g);if(g===a)break;f=g;g.is(e)&&(e=null);do null===f&&
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
class
|
|
124
|
-
B()._dirtyElements;return null!==a&&a.has(this.__key)}getAllTextNodes(a){const b=[],c=this.getLatest().__children;for(let f=0;f<c.length;f++){var d=
|
|
125
|
-
this.getChildren(),c=b.length;if(0===c)return this;if(a>=c)return a=b[c-1],C(a)&&a.getLastDescendant()||a;a=b[a];return C(a)&&a.getFirstDescendant()||a}getFirstChild(){const a=this.getLatest().__children;return 0===a.length?null:
|
|
126
|
-
b){let c="";const d=this.getChildren(),f=d.length;for(let e=0;e<f;e++){const g=d[e];c+=g.getTextContent(a,b);C(g)&&e!==f-1&&!g.isInline()&&(c+="\n\n")}return c}getDirection(){return this.getLatest().__dir}hasFormat(a){a=
|
|
127
|
-
this.getFirstDescendant();return C(a)||
|
|
128
|
-
this.getWritable().__indent=a;return this}splice(a,b,c){F();const d=this.getWritable();var f=d.__key;const e=d.__children,g=c.length;var h=[];for(let
|
|
129
|
-
|
|
130
|
-
function C(a){return a instanceof
|
|
131
|
-
class
|
|
132
|
-
__format:this.__format,__indent:this.__indent,__key:"root",__parent:null,__type:"root"}}}function M(a){return a instanceof
|
|
133
|
-
class
|
|
134
|
-
type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type},type:"range"}:
|
|
135
|
-
class
|
|
136
|
-
function
|
|
137
|
-
function
|
|
138
|
-
class
|
|
139
|
-
(this.getLatest().__detail&2)}hasFormat(a){a=ca[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
|
|
140
|
-
c,this);a=a.theme.text;void 0!==a&&
|
|
141
|
-
|
|
142
|
-
const b=this.getWritable();b.__style=a;return b}toggleFormat(a){a=ca[a];return this.setFormat(this.getFormat()^a)}toggleDirectionless(){F();const a=this.getWritable();a.__detail^=1;return a}toggleUnmergeable(){F();const a=this.getWritable();a.__detail^=2;return a}setMode(a){F();a=ha[a];const b=this.getWritable();b.__mode=a;return b}setTextContent(a){F();const b=this.getWritable();b.__text=a;return b}select(a,b){F();const c=K();var d=this.getTextContent();const f=
|
|
143
|
-
d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(J(c))d=B()._compositionKey,d!==c.anchor.key&&d!==c.focus.key||D(f),c.setTextNodeRange(this,a,this,b);else return
|
|
144
|
-
var b=this.getLatest(),c=b.getTextContent(),d=b.__key,f=B()._compositionKey,e=new Set(a);a=[];var g=c.length,h="";for(var
|
|
145
|
-
a[
|
|
146
|
-
a===this.getPreviousSibling();b||a===this.getNextSibling()||
|
|
147
|
-
function
|
|
148
|
-
function L(a=""){return new
|
|
149
|
-
class
|
|
150
|
-
this.insertAfter(a);return a}collapseAtStart(){const a=this.getChildren();if(0===a.length||
|
|
151
|
-
function
|
|
152
|
-
function
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
{
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
exports.$
|
|
164
|
-
exports.$
|
|
165
|
-
exports
|
|
166
|
-
exports.
|
|
167
|
-
exports.
|
|
168
|
-
exports.PASTE_COMMAND=jb;exports.ParagraphNode=Od;exports.REDO_COMMAND=ob;exports.REMOVE_TEXT_COMMAND=kb;exports.SELECTION_CHANGE_COMMAND=eb;exports.TextNode=Id;exports.UNDO_COMMAND=nb;exports.VERSION="0.2.3";exports.createCommand=function(){return{}};exports.createEditor=cb;
|
|
123
|
+
c.push(g);if(g===a)break;f=g;g.is(e)&&(e=null);do null===f&&p(60),g=b?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null!==f&&(f.is(e)&&(e=null),null!==g||d.has(f.__key)||c.push(f));while(null===g);f=g}}b||c.reverse();return c}isDirty(){const a=B()._dirtyLeaves;return null!==a&&a.has(this.__key)}getLatest(){const a=H(this.__key);null===a&&p(61);return a}getWritable(){F();var a=z(),b=B();a=a._nodeMap;const c=this.__key,d=this.getLatest(),f=d.__parent;b=b._cloneNotNeeded;var e=K();null!==
|
|
124
|
+
e&&(e._cachedNodes=null);if(b.has(c))return Ba(d),d;e=d.constructor.clone(d);e.__parent=f;C(d)&&C(e)?(e.__children=Array.from(d.__children),e.__indent=d.__indent,e.__format=d.__format,e.__dir=d.__dir):x(d)&&x(e)&&(e.__format=d.__format,e.__style=d.__style,e.__mode=d.__mode,e.__detail=d.__detail);b.add(c);e.__key=c;Ba(e);a.set(c,e);return e}getTextContent(){return""}getTextContentSize(a,b){return this.getTextContent(a,b).length}createDOM(){p(62)}updateDOM(){p(63)}exportDOM(a){return u(this)?(a=a.getElementByKey(this.getKey()),
|
|
125
|
+
{element:a?a.cloneNode():null}):{element:this.createDOM(a._config,a)}}static importDOM(){return null}remove(a){F();Kd(this,!0,a)}replace(a){F();const b=this.__key;a=a.getWritable();za(a);var c=this.getParentOrThrow(),d=c.getWritable().__children;const f=d.indexOf(this.__key),e=a.__key;-1===f&&p(34);d.splice(f,0,e);a.__parent=c.__key;Kd(this,!1);Aa(a);d=K();J(d)&&(c=d.anchor,d=d.focus,c.key===b&&md(c,a),d.key===b&&md(d,a));B()._compositionKey===b&&D(e);return a}insertAfter(a){F();var b=this.getWritable(),
|
|
126
|
+
c=a.getWritable(),d=c.getParent();const f=K();var e=a.getIndexWithinParent(),g=!1,h=!1;null!==d&&(za(c),J(f)&&(h=d.__key,g=f.anchor,d=f.focus,g="element"===g.type&&g.key===h&&g.offset===e+1,h="element"===d.type&&d.key===h&&d.offset===e+1));e=this.getParentOrThrow().getWritable();d=c.__key;c.__parent=b.__parent;const k=e.__children;b=k.indexOf(b.__key);-1===b&&p(34);k.splice(b+1,0,d);Aa(c);J(f)&&(Gd(f,e,b+1),c=e.__key,g&&f.anchor.set(c,b+2,"element"),h&&f.focus.set(c,b+2,"element"));return a}insertBefore(a){F();
|
|
127
|
+
var b=this.getWritable(),c=a.getWritable();za(c);const d=this.getParentOrThrow().getWritable(),f=c.__key;c.__parent=b.__parent;const e=d.__children;b=e.indexOf(b.__key);-1===b&&p(34);e.splice(b,0,f);Aa(c);c=K();J(c)&&Gd(c,d,b);return a}selectPrevious(a,b){F();const c=this.getPreviousSibling(),d=this.getParentOrThrow();return null===c?d.select(0,0):C(c)?c.select():x(c)?c.select(a,b):(a=c.getIndexWithinParent()+1,d.select(a,a))}selectNext(a,b){F();const c=this.getNextSibling(),d=this.getParentOrThrow();
|
|
128
|
+
return null===c?d.select():C(c)?c.select(0,0):x(c)?c.select(a,b):(a=c.getIndexWithinParent(),d.select(a,a))}markDirty(){this.getWritable()}}class Nd extends Md{constructor(a){super(a)}decorate(){p(39)}isIsolated(){return!1}isTopLevel(){return!1}}function u(a){return a instanceof Nd}
|
|
129
|
+
class Od extends Md{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=H(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=
|
|
130
|
+
B()._dirtyElements;return null!==a&&a.has(this.__key)}isLastChild(){const a=this.getLatest();return a.getParentOrThrow().getLastChild()===a}getAllTextNodes(a){const b=[],c=this.getLatest().__children;for(let f=0;f<c.length;f++){var d=H(c[f]);!x(d)||!a&&d.isInert()?C(d)&&(d=d.getAllTextNodes(a),b.push(...d)):b.push(d)}return b}getFirstDescendant(){let a=this.getFirstChild();for(;null!==a;){if(C(a)){const b=a.getFirstChild();if(null!==b){a=b;continue}}break}return a}getLastDescendant(){let a=this.getLastChild();
|
|
131
|
+
for(;null!==a;){if(C(a)){const b=a.getLastChild();if(null!==b){a=b;continue}}break}return a}getDescendantByIndex(a){const b=this.getChildren(),c=b.length;if(0===c)return this;if(a>=c)return a=b[c-1],C(a)&&a.getLastDescendant()||a;a=b[a];return C(a)&&a.getFirstDescendant()||a}getFirstChild(){const a=this.getLatest().__children;return 0===a.length?null:H(a[0])}getFirstChildOrThrow(){const a=this.getFirstChild();null===a&&p(37,this.__key);return a}getLastChild(){const a=this.getLatest().__children,b=
|
|
132
|
+
a.length;return 0===b?null:H(a[b-1])}getChildAtIndex(a){a=this.getLatest().__children[a];return void 0===a?null:H(a)}getTextContent(a,b){let c="";const d=this.getChildren(),f=d.length;for(let e=0;e<f;e++){const g=d[e];c+=g.getTextContent(a,b);C(g)&&e!==f-1&&!g.isInline()&&(c+="\n\n")}return c}getDirection(){return this.getLatest().__dir}hasFormat(a){a=da[a];return 0!==(this.getFormat()&a)}select(a,b){F();const c=K();var d=this.getChildrenSize();void 0===a&&(a=d);void 0===b&&(b=d);d=this.__key;if(J(c))c.anchor.set(d,
|
|
133
|
+
a,"element"),c.focus.set(d,b,"element"),c.dirty=!0;else return Fd(d,a,d,b,"element","element");return c}selectStart(){const a=this.getFirstDescendant();return C(a)||x(a)?a.select(0,0):null!==a?a.selectPrevious():this.select(0,0)}selectEnd(){const a=this.getLastDescendant();return C(a)||x(a)?a.select():null!==a?a.selectNext():this.select()}clear(){F();const a=this.getWritable();this.getChildren().forEach(b=>b.remove());return a}append(...a){F();return this.splice(this.getChildrenSize(),0,a)}setDirection(a){F();
|
|
134
|
+
const b=this.getWritable();b.__dir=a;return b}setFormat(a){F();this.getWritable().__format=da[a];return this}setIndent(a){F();this.getWritable().__indent=a;return this}splice(a,b,c){F();const d=this.getWritable();var f=d.__key;const e=d.__children,g=c.length;var h=[];for(let k=0;k<g;k++){const m=c[k],l=m.getWritable();m.__key===f&&p(38);za(l);l.__parent=f;h.push(l.__key)}(c=this.getChildAtIndex(a-1))&&Ba(c);(f=this.getChildAtIndex(a+b))&&Ba(f);a===e.length?(e.push(...h),a=[]):a=e.splice(a,b,...h);
|
|
135
|
+
if(a.length&&(b=K(),J(b))){const k=new Set(a),m=new Set(h);h=r=>{for(r=r.getNode();r;){const q=r.__key;if(k.has(q)&&!m.has(q))return!0;r=r.getParent()}return!1};const {anchor:l,focus:n}=b;h(l)&&Id(l,l.getNode(),this,c,f);h(n)&&Id(n,n.getNode(),this,c,f);h=a.length;for(b=0;b<h;b++)c=H(a[b]),null!=c&&(c.getWritable().__parent=null);0!==e.length||this.canBeEmpty()||M(this)||this.remove()}return d}insertNewAfter(){return null}canInsertTab(){return!1}canIndent(){return!0}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}canMergeWith(){return!1}extractWithChild(){return!1}}
|
|
136
|
+
function C(a){return a instanceof Od}
|
|
137
|
+
class Pd extends Od{static getType(){return"root"}static clone(){return new Pd}constructor(){super("root");this.__cachedText=null}getTopLevelElementOrThrow(){p(40)}getTextContent(a,b){const c=this.__cachedText;return!Y&&0!==B()._dirtyType||null===c||a&&!1===b?super.getTextContent(a,b):c}remove(){p(41)}replace(){p(42)}insertBefore(){p(43)}insertAfter(){p(44)}updateDOM(){return!1}append(...a){for(let b=0;b<a.length;b++){const c=a[b];C(c)||u(c)||p(45)}return super.append(...a)}toJSON(){return{__children:this.__children,__dir:this.__dir,
|
|
138
|
+
__format:this.__format,__indent:this.__indent,__key:"root",__parent:null,__type:"root"}}}function M(a){return a instanceof Pd}function dd(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 Qd(){return new Lc(new Map([["root",new Pd]]))}
|
|
139
|
+
class Lc{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=U,d=Y,f=V;U=this;Y=!0;V=null;try{var b=a();break a}finally{U=c,Y=d,V=f}b=void 0}return b}clone(a){a=new Lc(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:J(a)?{anchor:{key:a.anchor.key,offset:a.anchor.offset,
|
|
140
|
+
type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type},type:"range"}:cd(a)?{nodes:Array.from(a._nodes),type:"node"}:td(a)?{anchor:{key:a.anchor.key,offset:a.anchor.offset,type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type},gridKey:a.gridKey,type:"grid"}:null}}}
|
|
141
|
+
class Rd extends Md{static getType(){return"linebreak"}static clone(a){return new Rd(a.__key)}constructor(a){super(a)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:()=>({conversion:Sd,priority:0})}}}function Sd(){return{node:zd()}}function zd(){return new Rd}function ya(a){return a instanceof Rd}function Td(a,b){return b&16?"code":b&32?"sub":b&64?"sup":null}function Ud(a,b){return b&1?"strong":b&2?"em":"span"}
|
|
142
|
+
function Yd(a,b,c,d,f){a=d.classList;d=Pa(f,"base");void 0!==d&&a.add(...d);d=Pa(f,"underlineStrikethrough");let e=!1;const g=b&8&&b&4;var h=c&8&&c&4;void 0!==d&&(h?(e=!0,g||a.add(...d)):g&&a.remove(...d));for(const k in ca)h=ca[k],d=Pa(f,k),void 0!==d&&(c&h?!e||"underline"!==k&&"strikethrough"!==k?(0===(b&h)||g&&"underline"===k||"strikethrough"===k)&&a.add(...d):b&h&&a.remove(...d):b&h&&a.remove(...d))}
|
|
143
|
+
function Zd(a,b,c){const d=b.firstChild;c=c.isComposing();a+=c?"\u200b":"";if(null==d)b.textContent=a;else if(b=d.nodeValue,b!==a)if(c){c=b.length;const f=a.length;let e=0,g=0;for(;e<c&&e<f&&b[e]===a[e];)e++;for(;g+e<c&&g+e<f&&b[c-g-1]===a[f-g-1];)g++;a=[e,c-e-g,a.slice(e,f-g)];const [h,k,m]=a;0!==k&&d.deleteData(h,k);d.insertData(h,m)}else d.nodeValue=a}
|
|
144
|
+
class $d extends Md{static getType(){return"text"}static clone(a){return new $d(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}isComposing(){return this.__key===B()._compositionKey}isSegmented(){return 2===this.getLatest().__mode}isInert(){return 3===this.getLatest().__mode}isDirectionless(){return 0!==
|
|
145
|
+
(this.getLatest().__detail&1)}isUnmergeable(){return 0!==(this.getLatest().__detail&2)}hasFormat(a){a=ca[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 wa(c,a,b)}createDOM(a){var b=this.__format,c=Td(this,b);const d=Ud(this,b),f=document.createElement(null===c?d:c);let e=f;null!==c&&(e=document.createElement(d),
|
|
146
|
+
f.appendChild(e));c=e;Zd(this.__text,c,this);a=a.theme.text;void 0!==a&&Yd(d,0,b,c,a);b=this.__style;""!==b&&(f.style.cssText=b);return f}updateDOM(a,b,c){const d=this.__text;var f=a.__format,e=this.__format,g=Td(this,f);const h=Td(this,e);var k=Ud(this,f);const m=Ud(this,e);if((null===g?k:g)!==(null===h?m:h))return!0;if(g===h&&k!==m)return f=b.firstChild,null==f&&p(46),a=g=document.createElement(m),Zd(d,a,this),c=c.theme.text,void 0!==c&&Yd(m,0,e,a,c),b.replaceChild(g,f),!1;k=b;null!==h&&null!==
|
|
147
|
+
g&&(k=b.firstChild,null==k&&p(47));Zd(d,k,this);c=c.theme.text;void 0!==c&&f!==e&&Yd(m,f,e,k,c);e=this.__style;a.__style!==e&&(b.style.cssText=e);return!1}static importDOM(){return{"#text":()=>({conversion:ae,priority:0}),b:()=>({conversion:be,priority:0}),em:()=>({conversion:ce,priority:0}),i:()=>({conversion:ce,priority:0}),span:()=>({conversion:de,priority:0}),strong:()=>({conversion:ce,priority:0}),u:()=>({conversion:ce,priority:0})}}selectionTransform(){}setFormat(a){F();const b=this.getWritable();
|
|
148
|
+
b.__format=a;return b}setStyle(a){F();const b=this.getWritable();b.__style=a;return b}toggleFormat(a){a=ca[a];return this.setFormat(this.getFormat()^a)}toggleDirectionless(){F();const a=this.getWritable();a.__detail^=1;return a}toggleUnmergeable(){F();const a=this.getWritable();a.__detail^=2;return a}setMode(a){F();a=ha[a];const b=this.getWritable();b.__mode=a;return b}setTextContent(a){F();const b=this.getWritable();b.__text=a;return b}select(a,b){F();const c=K();var d=this.getTextContent();const f=
|
|
149
|
+
this.__key;"string"===typeof d?(d=d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(J(c))d=B()._compositionKey,d!==c.anchor.key&&d!==c.focus.key||D(f),c.setTextNodeRange(this,a,this,b);else return Fd(f,a,f,b,"text","text");return c}spliceText(a,b,c,d){F();const f=this.getWritable(),e=f.__text,g=c.length;let h=a;0>h&&(h=g+h,0>h&&(h=0));const k=K();d&&J(k)&&(a+=g,k.setTextNodeRange(f,a,f,a));b=e.slice(0,h)+c+e.slice(h+b);f.__text=b;return f}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...a){F();
|
|
150
|
+
var b=this.getLatest(),c=b.getTextContent(),d=b.__key,f=B()._compositionKey,e=new Set(a);a=[];var g=c.length,h="";for(var k=0;k<g;k++)""!==h&&e.has(k)&&(a.push(h),h=""),h+=c[k];""!==h&&a.push(h);e=a.length;if(0===e)return[];if(a[0]===c)return[b];var m=a[0];c=b.getParentOrThrow();k=c.__key;const l=b.getFormat(),n=b.getStyle(),r=b.__detail;g=!1;b.isSegmented()?(h=L(m),h.__parent=k,h.__format=l,h.__style=n,h.__detail=r,g=!0):(h=b.getWritable(),h.__text=m);b=K();h=[h];m=m.length;for(let A=1;A<e;A++){var q=
|
|
151
|
+
a[A],w=q.length;q=L(q).getWritable();q.__format=l;q.__style=n;q.__detail=r;const E=q.__key;w=m+w;if(J(b)){const y=b.anchor,G=b.focus;y.key===d&&"text"===y.type&&y.offset>m&&y.offset<=w&&(y.key=E,y.offset-=m,b.dirty=!0);G.key===d&&"text"===G.type&&G.offset>m&&G.offset<=w&&(G.key=E,G.offset-=m,b.dirty=!0)}f===d&&D(E);m=w;q.__parent=k;h.push(q)}Aa(this);f=c.getWritable().__children;d=f.indexOf(d);a=h.map(A=>A.__key);g?(f.splice(d,0,...a),this.remove()):f.splice(d,1,...a);J(b)&&Gd(b,c,d,e-1);return h}mergeWithSibling(a){var b=
|
|
152
|
+
a===this.getPreviousSibling();b||a===this.getNextSibling()||p(48);var c=this.__key;const d=a.__key,f=this.__text,e=f.length;B()._compositionKey===d&&D(c);const g=K();if(J(g)){const h=g.anchor,k=g.focus;null!==h&&h.key===d&&(Jd(h,b,c,a,e),g.dirty=!0);null!==k&&k.key===d&&(Jd(k,b,c,a,e),g.dirty=!0)}c=a.__text;this.setTextContent(b?c+f:f+c);b=this.getWritable();a.remove();return b}isTextEntity(){return!1}}
|
|
153
|
+
function de(a){const b="700"===a.style.fontWeight;return{forChild:c=>{x(c)&&b&&c.toggleFormat("bold");return c},node:null}}function be(a){const b="normal"===a.style.fontWeight;return{forChild:c=>{x(c)&&!b&&c.toggleFormat("bold");return c},node:null}}function ae(a){return{node:L(a.textContent)}}const ee={em:"italic",i:"italic",strong:"bold",u:"underline"};function ce(a){const b=ee[a.nodeName.toLowerCase()];return void 0===b?{node:null}:{forChild:c=>{x(c)&&c.toggleFormat(b);return c},node:null}}
|
|
154
|
+
function L(a=""){return new $d(a)}function x(a){return a instanceof $d}
|
|
155
|
+
class fe extends Od{static getType(){return"paragraph"}static clone(a){return new fe(a.__key)}createDOM(a){const b=document.createElement("p");a=Pa(a.theme,"paragraph");void 0!==a&&b.classList.add(...a);return b}updateDOM(){return!1}static importDOM(){return{p:()=>({conversion:ge,priority:0})}}exportDOM(a){({element:a}=super.exportDOM(a));a&&0===this.getTextContentSize()&&a.append(document.createElement("br"));return{element:a}}insertNewAfter(){const a=od(),b=this.getDirection();a.setDirection(b);
|
|
156
|
+
this.insertAfter(a);return a}collapseAtStart(){const a=this.getChildren();if(0===a.length||x(a[0])&&""===a[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function ge(){return{node:od()}}function od(){return new fe}
|
|
157
|
+
function Pc(a,b,c,d){const f=a._keyToDOMMap;f.clear();a._editorState=Qd();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._updates=[];d=a._observer;null!==d&&(d.disconnect(),a._observer=null);null!==b&&(b.textContent="");null!==c&&(c.textContent="",f.set("root",c))}
|
|
158
|
+
function he(a){const b=new Map,c=new Set;a.forEach(d=>{d=d.klass.importDOM;if(!c.has(d)){c.add(d);var f=d();null!==f&&Object.keys(f).forEach(e=>{let g=b.get(e);void 0===g&&(g=[],b.set(e,g));g.push(f[e])})}});return b}
|
|
159
|
+
function ab(a){var b=a||{},c=b.namespace||Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5);const d=b.theme||{},f=b.parentEditor||null,e=b.disableEvents||!1,g=Qd();a=b.editorState;const h=[Pd,$d,Rd,fe,...(b.nodes||[])],k=b.onError;b=b.readOnly||!1;const m=new Map;for(let l=0;l<h.length;l++){const n=h[l],r=n.getType();m.set(r,{klass:n,transforms:new Set})}c=new ie(g,f,m,{disableEvents:e,namespace:c,theme:d},k,he(m),b);void 0!==a&&(c._pendingEditorState=a,c._dirtyType=2);return c}
|
|
160
|
+
class ie{constructor(a,b,c,d,f,e){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,mutation:new Map,readonly:new Set,root:new Set,textcontent:new Set,update:new Set};this._commands=new Map;this._config=d;this._nodes=c;this._decorators={};this._pendingDecorators=null;this._dirtyType=0;this._cloneNotNeeded=new Set;this._dirtyLeaves=
|
|
161
|
+
new Set;this._dirtyElements=new Map;this._normalizedNodes=new Set;this._updateTags=new Set;this._observer=null;this._key=""+oa++;this._onError=f;this._htmlConversions=e;this._headless=this._readOnly=!1}isComposing(){return null!=this._compositionKey}registerUpdateListener(a){const b=this._listeners.update;b.add(a);return()=>{b.delete(a)}}registerReadOnlyListener(a){const b=this._listeners.readonly;b.add(a);return()=>{b.delete(a)}}registerDecoratorListener(a){const b=this._listeners.decorator;b.add(a);
|
|
162
|
+
return()=>{b.delete(a)}}registerTextContentListener(a){const b=this._listeners.textcontent;b.add(a);return()=>{b.delete(a)}}registerRootListener(a){const b=this._listeners.root;a(this._rootElement,null);b.add(a);return()=>{a(null,this._rootElement);b.delete(a)}}registerCommand(a,b,c){void 0===c&&p(20);const d=this._commands;d.has(a)||d.set(a,[new Set,new Set,new Set,new Set,new Set]);const f=d.get(a);void 0===f&&p(21,a);const e=f[c];e.add(b);return()=>{e.delete(b);f.every(g=>0===g.size)&&d.delete(a)}}registerMutationListener(a,
|
|
163
|
+
b){void 0===this._nodes.get(a.getType())&&p(22,a.name);const c=this._listeners.mutation;c.set(b,a);return()=>{c.delete(b)}}registerNodeTransform(a,b){const c=a.getType(),d=this._nodes.get(c);void 0===d&&p(22,a.name);const f=d.transforms;f.add(b);Ha(this,c);return()=>{f.delete(b)}}hasNodes(a){for(let b=0;b<a.length;b++){const c=a[b].getType();if(!this._nodes.has(c))return!1}return!0}dispatchCommand(a,b){return O(this,a,b)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(a){const b=
|
|
164
|
+
this._rootElement;if(a!==b){var c=this._pendingEditorState||this._editorState;this._rootElement=a;Pc(this,b,a,c);if(null!==b&&!this._config.disableEvents){0!==Ub&&(Ub--,0===Ub&&b.ownerDocument.removeEventListener("selectionchange",fc));c=b.__lexicalEditor;if(null!=c){if(null!==c._parentEditor){var d=Ka(c);d=d[d.length-1]._key;ec.get(d)===c&&ec.delete(d)}else ec.delete(c._key);b.__lexicalEditor=null}c=dc(b);for(d=0;d<c.length;d++)c[d]();b.__lexicalEventHandles=[]}null!==a&&(c=a.style,c.userSelect=
|
|
165
|
+
"text",c.whiteSpace="pre-wrap",c.wordBreak="break-word",a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,Qc(this),this._updateTags.add("history-merge"),Nc(this),this._config.disableEvents||gc(a,this));Rc("root",this,!1,a,b)}}getElementByKey(a){return this._keyToDOMMap.get(a)||null}getEditorState(){return this._editorState}setEditorState(a,b){a.isEmpty()&&p(23);cc(this);const c=this._pendingEditorState,d=this._updateTags;b=void 0!==b?b.tag:null;null===c||c.isEmpty()||(null!=b&&d.add(b),
|
|
166
|
+
Nc(this));this._pendingEditorState=a;this._dirtyType=2;this._compositionKey=null;null!=b&&d.add(b);Nc(this)}parseEditorState(a){a="string"===typeof a?JSON.parse(a):a;return bb(a,this)}update(a,b){I(this,a,b)}focus(a){const b=this._rootElement;null!==b&&(b.setAttribute("autocapitalize","off"),I(this,()=>{const c=K(),d=Ga();null!==c?c.dirty=!0:0!==d.getChildrenSize()&&d.selectEnd()},{onUpdate:()=>{b.removeAttribute("autocapitalize");a&&a()}}))}blur(){var a=this._rootElement;null!==a&&a.blur();a=window.getSelection();
|
|
167
|
+
null!==a&&a.removeAllRanges()}isReadOnly(){return this._readOnly}setReadOnly(a){this._readOnly=a;Rc("readonly",this,!0,a)}toJSON(){return{editorState:this._editorState}}}class je extends Od{constructor(a,b){super(b)}}function xd(a){return a instanceof je}class ke extends Od{}function vd(a){return a instanceof ke}class le extends Od{}function wd(a){return a instanceof le}exports.$createGridSelection=function(){const a=Z("root",0,"element"),b=Z("root",0,"element");return new sd("root",a,b)};
|
|
168
|
+
exports.$createLineBreakNode=zd;exports.$createNodeFromParse=function(a,b){F();const c=B();return $a(a,b,c,null)};exports.$createNodeSelection=function(){return new qd(new Set)};exports.$createParagraphNode=od;exports.$createRangeSelection=function(){const a=Z("root",0,"element"),b=Z("root",0,"element");return new rd(a,b,0)};exports.$createTextNode=L;exports.$getDecoratorNode=Sa;exports.$getNearestNodeFromDOMNode=sa;exports.$getNodeByKey=H;exports.$getPreviousSelection=Na;exports.$getRoot=Ga;
|
|
169
|
+
exports.$getSelection=K;exports.$isDecoratorNode=u;exports.$isElementNode=C;exports.$isGridCellNode=xd;exports.$isGridNode=vd;exports.$isGridRowNode=wd;exports.$isGridSelection=td;exports.$isLeafNode=xa;exports.$isLineBreakNode=ya;exports.$isNodeSelection=cd;exports.$isParagraphNode=function(a){return a instanceof fe};exports.$isRangeSelection=J;exports.$isRootNode=M;exports.$isTextNode=x;
|
|
170
|
+
exports.$nodesOfType=function(a){var b=z();const c=b._readOnly,d=a.getType();b=b._nodeMap;const f=[];for(const [,e]of b)e instanceof a&&e.__type===d&&(c||e.isAttached())&&f.push(e);return f};exports.$setCompositionKey=D;exports.$setSelection=Ia;exports.BLUR_COMMAND=Hb;exports.CAN_REDO_COMMAND={};exports.CAN_UNDO_COMMAND={};exports.CLEAR_EDITOR_COMMAND={};exports.CLEAR_HISTORY_COMMAND={};exports.CLICK_COMMAND=gb;exports.COMMAND_PRIORITY_CRITICAL=4;exports.COMMAND_PRIORITY_EDITOR=0;
|
|
171
|
+
exports.COMMAND_PRIORITY_HIGH=3;exports.COMMAND_PRIORITY_LOW=1;exports.COMMAND_PRIORITY_NORMAL=2;exports.COPY_COMMAND=Eb;exports.CUT_COMMAND=Fb;exports.DELETE_CHARACTER_COMMAND=hb;exports.DELETE_LINE_COMMAND=ob;exports.DELETE_WORD_COMMAND=nb;exports.DRAGEND_COMMAND=Db;exports.DRAGSTART_COMMAND=Cb;exports.DROP_COMMAND=Bb;exports.DecoratorNode=Nd;exports.ElementNode=Od;exports.FOCUS_COMMAND=Gb;exports.FORMAT_ELEMENT_COMMAND={};exports.FORMAT_TEXT_COMMAND=N;exports.GridCellNode=je;exports.GridNode=ke;
|
|
172
|
+
exports.GridRowNode=le;exports.INDENT_CONTENT_COMMAND={};exports.INSERT_LINE_BREAK_COMMAND=ib;exports.INSERT_PARAGRAPH_COMMAND=jb;exports.INSERT_TEXT_COMMAND=kb;exports.KEY_ARROW_DOWN_COMMAND=ub;exports.KEY_ARROW_LEFT_COMMAND=sb;exports.KEY_ARROW_RIGHT_COMMAND=rb;exports.KEY_ARROW_UP_COMMAND=tb;exports.KEY_BACKSPACE_COMMAND=xb;exports.KEY_DELETE_COMMAND=zb;exports.KEY_ENTER_COMMAND=vb;exports.KEY_ESCAPE_COMMAND=yb;exports.KEY_MODIFIER_COMMAND=Ib;exports.KEY_SPACE_COMMAND=wb;
|
|
173
|
+
exports.KEY_TAB_COMMAND=Ab;exports.LineBreakNode=Rd;exports.OUTDENT_CONTENT_COMMAND={};exports.PASTE_COMMAND=lb;exports.ParagraphNode=fe;exports.REDO_COMMAND=qb;exports.REMOVE_TEXT_COMMAND=mb;exports.SELECTION_CHANGE_COMMAND=fb;exports.TextNode=$d;exports.UNDO_COMMAND=pb;exports.VERSION="0.2.6";exports.createCommand=function(){return{}};exports.createEditor=ab;
|