lexical 0.1.13 → 0.1.14
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 +0 -2
- package/Lexical.dev.js +19 -8
- package/Lexical.js.flow +1 -3
- package/Lexical.prod.js +157 -156
- package/LexicalHashtagNode.dev.js +1 -1
- package/LexicalHashtagNode.prod.js +1 -1
- package/package.json +1 -1
package/Lexical.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ import {Class, $ReadOnly} from 'utility-types';
|
|
|
14
14
|
type ErrorHandler = (error: Error) => void;
|
|
15
15
|
type MutationListeners = Map<MutationListener, Class<LexicalNode>>;
|
|
16
16
|
export type NodeMutation = 'created' | 'destroyed';
|
|
17
|
-
export type ErrorListener = (error: Error) => void;
|
|
18
17
|
type UpdateListener = (arg0: {
|
|
19
18
|
tags: Set<string>;
|
|
20
19
|
prevEditorState: EditorState;
|
|
@@ -40,7 +39,6 @@ export type ReadOnlyListener = (readOnly: boolean) => void;
|
|
|
40
39
|
type CommandPayload = any;
|
|
41
40
|
type Listeners = {
|
|
42
41
|
decorator: Set<DecoratorListener>;
|
|
43
|
-
error: Set<ErrorListener>;
|
|
44
42
|
mutation: MutationListeners;
|
|
45
43
|
textcontent: Set<TextContentListener>;
|
|
46
44
|
root: Set<RootListener>;
|
package/Lexical.dev.js
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
*
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
const getSelection = window.getSelection;
|
|
17
|
+
const getSelection = () => window.getSelection();
|
|
18
|
+
|
|
18
19
|
var getDOMSelection = getSelection;
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -461,7 +462,7 @@ function getEditorsToPropagate(editor) {
|
|
|
461
462
|
function createUID() {
|
|
462
463
|
return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
|
|
463
464
|
}
|
|
464
|
-
function $updateSelectedTextFromDOM(editor,
|
|
465
|
+
function $updateSelectedTextFromDOM(editor, compositionEndEvent) {
|
|
465
466
|
// Update the text content with the latest composition text
|
|
466
467
|
const domSelection = getDOMSelection();
|
|
467
468
|
|
|
@@ -469,8 +470,8 @@ function $updateSelectedTextFromDOM(editor, compositionEnd) {
|
|
|
469
470
|
return;
|
|
470
471
|
}
|
|
471
472
|
|
|
472
|
-
const
|
|
473
|
-
|
|
473
|
+
const anchorNode = domSelection.anchorNode;
|
|
474
|
+
let {
|
|
474
475
|
anchorOffset,
|
|
475
476
|
focusOffset
|
|
476
477
|
} = domSelection;
|
|
@@ -479,7 +480,17 @@ function $updateSelectedTextFromDOM(editor, compositionEnd) {
|
|
|
479
480
|
const node = $getNearestNodeFromDOMNode(anchorNode);
|
|
480
481
|
|
|
481
482
|
if ($isTextNode(node)) {
|
|
482
|
-
|
|
483
|
+
let textContent = anchorNode.nodeValue;
|
|
484
|
+
const data = compositionEndEvent !== null && compositionEndEvent.data; // Data is intentionally truthy, as we check for boolean, null and empty string.
|
|
485
|
+
|
|
486
|
+
if (textContent === ZERO_WIDTH_CHAR && data) {
|
|
487
|
+
const offset = data.length;
|
|
488
|
+
textContent = data;
|
|
489
|
+
anchorOffset = offset;
|
|
490
|
+
focusOffset = offset;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
$updateTextNodeFromDOMContent(node, textContent, anchorOffset, focusOffset, compositionEndEvent !== null);
|
|
483
494
|
}
|
|
484
495
|
}
|
|
485
496
|
}
|
|
@@ -6685,7 +6696,7 @@ function onInput(event, editor) {
|
|
|
6685
6696
|
if (data != null && $isRangeSelection(selection) && $shouldPreventDefaultAndInsertText(selection, data, false)) {
|
|
6686
6697
|
editor.execCommand('insertText', data);
|
|
6687
6698
|
} else {
|
|
6688
|
-
$updateSelectedTextFromDOM(editor,
|
|
6699
|
+
$updateSelectedTextFromDOM(editor, null);
|
|
6689
6700
|
} // Also flush any other mutations that might have occured
|
|
6690
6701
|
// since the change.
|
|
6691
6702
|
|
|
@@ -6730,7 +6741,7 @@ function onCompositionEndInternal(event, editor) {
|
|
|
6730
6741
|
return;
|
|
6731
6742
|
}
|
|
6732
6743
|
|
|
6733
|
-
$updateSelectedTextFromDOM(editor,
|
|
6744
|
+
$updateSelectedTextFromDOM(editor, event);
|
|
6734
6745
|
});
|
|
6735
6746
|
}
|
|
6736
6747
|
|
|
@@ -8230,7 +8241,7 @@ class BaseLexicalEditor {
|
|
|
8230
8241
|
*
|
|
8231
8242
|
*
|
|
8232
8243
|
*/
|
|
8233
|
-
const VERSION = '0.1.
|
|
8244
|
+
const VERSION = '0.1.14';
|
|
8234
8245
|
|
|
8235
8246
|
/**
|
|
8236
8247
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
package/Lexical.js.flow
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
|
|
14
14
|
type MutationListeners = Map<MutationListener, Class<LexicalNode>>;
|
|
15
15
|
export type NodeMutation = 'created' | 'destroyed';
|
|
16
|
-
export type ErrorListener = (error: Error) => void;
|
|
17
16
|
type UpdateListener = ({
|
|
18
17
|
tags: Set<string>,
|
|
19
18
|
prevEditorState: EditorState,
|
|
@@ -44,7 +43,6 @@ export type ReadOnlyListener = (readOnly: boolean) => void;
|
|
|
44
43
|
type CommandPayload = any;
|
|
45
44
|
type Listeners = {
|
|
46
45
|
decorator: Set<DecoratorListener>,
|
|
47
|
-
error: Set<ErrorListener>,
|
|
48
46
|
mutation: MutationListeners,
|
|
49
47
|
textcontent: Set<TextContentListener>,
|
|
50
48
|
root: Set<RootListener>,
|
|
@@ -177,7 +175,7 @@ export type EditorThemeClasses = {
|
|
|
177
175
|
table?: EditorThemeClassName,
|
|
178
176
|
tableRow?: EditorThemeClassName,
|
|
179
177
|
tableCell?: EditorThemeClassName,
|
|
180
|
-
|
|
178
|
+
TableCellHeaderStyles?: EditorThemeClassName,
|
|
181
179
|
link?: EditorThemeClassName,
|
|
182
180
|
quote?: EditorThemeClassName,
|
|
183
181
|
code?: EditorThemeClassName,
|
package/Lexical.prod.js
CHANGED
|
@@ -4,161 +4,162 @@
|
|
|
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 q(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
|
|
8
|
-
const
|
|
9
|
-
segmented:2,token:1},
|
|
10
|
-
function
|
|
11
|
-
function
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
function
|
|
15
|
-
function
|
|
16
|
-
function
|
|
17
|
-
function
|
|
18
|
-
!c.canInsertTextBefore()||d),b=a||f):b=!1);return b}function
|
|
19
|
-
function
|
|
20
|
-
function
|
|
21
|
-
function
|
|
22
|
-
function
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
d
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
class
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
function
|
|
7
|
+
function q(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
|
|
8
|
+
const ba=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]"),ca=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]"),da={bold:1,code:16,italic:2,strikethrough:4,subscript:32,superscript:64,underline:8},ea={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,r=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;let ma=0;const na="function"===typeof queueMicrotask?queueMicrotask:a=>{Promise.resolve().then(a)};
|
|
10
|
+
function oa(a,b,c){const d=a.getRootElement();try{return null!==d&&d.contains(b)&&d.contains(c)&&null!==b&&qa(b)===a}catch(e){return!1}}function qa(a){for(;null!=a;){const b=a.__lexicalEditor;if(null!=b&&!b.isReadOnly())return b;a=a.parentNode}return null}function t(a){return a.isToken()||a.isInert()}function ra(a){for(;null!=a;){if(3===a.nodeType)return a;a=a.firstChild}return null}function sa(a,b,c){b=da[b];return a&b&&(null===c||0===(c&b))?a^b:null===c||c&b?a|b:a}
|
|
11
|
+
function ta(a){return v(a)||ua(a)||x(a)}function y(a){99<va&&q(26);var b=a.getLatest(),c=b.__parent,d=B();const e=D(),f=d._nodeMap;d=e._dirtyElements;if(null!==c)a:for(;null!==c;){if(d.has(c))break a;const g=f.get(c);if(void 0===g)break;d.set(c,!1);c=g.__parent}b=b.__key;e._dirtyType=1;E(a)?d.set(b,!0):e._dirtyLeaves.add(b)}function F(a){const b=a.getPreviousSibling();a=a.getNextSibling();null!==b&&y(b);null!==a&&y(a)}
|
|
12
|
+
function G(a){H();var b=D();const c=b._compositionKey;b._compositionKey=a;null!==c&&(b=I(c),null!==b&&b.getWritable());null!==a&&(a=I(a),null!==a&&a.getWritable())}function I(a,b){a=(b||B())._nodeMap.get(a);return void 0===a?null:a}function wa(a,b){const c=D();a=a["__lexicalKey_"+c._key];return void 0!==a?I(a,b):null}function xa(a,b){for(;null!=a;){const c=wa(a,b);if(null!==c)return c;a=a.parentNode}return null}function ya(a){const b=Object.assign({},a._decorators);return a._pendingDecorators=b}
|
|
13
|
+
function za(a){return a.read(()=>Aa().getTextContent())}function Ba(a,b){Ca(a,()=>{var c=B();if(!c.isEmpty())if("root"===b)Aa().markDirty();else{c=Array.from(c._nodeMap);for(let d=0;d<c.length;d++)c[d][1].markDirty()}},null===a._pendingEditorState?{tag:"history-merge"}:void 0)}function Aa(){return B()._nodeMap.get("root")}function Da(a){B()._selection=a}
|
|
14
|
+
function Ea(a){var b=D(),c;a:{for(c=a;null!=c;){const d=c["__lexicalKey_"+b._key];if(void 0!==d){c=d;break a}c=c.parentNode}c=null}return null===c?(b=b.getRootElement(),a===b?I("root"):null):I(c)}function Fa(a){const b=[];for(;null!==a;)b.push(a),a=a._parentEditor;return b}function Ga(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}
|
|
15
|
+
function Ha(a,b){a=window.getSelection();if(null!==a){var c=a.anchorNode,{anchorOffset:d,focusOffset:e}=a;if(null!==c&&3===c.nodeType&&(a=xa(c),v(a))){c=c.nodeValue;const f=null!==b&&b.data;if("\u200b"===c&&f){const g=f.length;c=f;e=d=g}Ia(a,c,d,e,null!==b)}}}
|
|
16
|
+
function Ia(a,b,c,d,e){if(a.isAttached()&&(e||!a.isDirty())){var f=a.isComposing();let g=b;(f||e)&&"\u200b"===b[b.length-1]&&(g=b.slice(0,-1));b=a.getTextContent();if(e||g!==b)""===g?(f&&G(null),a.remove()):(e=a.getParent(),b=Ja(),t(a)||null!==D()._compositionKey&&!f||null!==e&&J(b)&&!e.canInsertTextBefore()&&0===b.anchor.offset?a.markDirty():(f=K(),J(f)&&null!==c&&null!==d&&(f.setTextNodeRange(a,c,a,d),a.isSegmented()&&(c=a.getTextContent(),c=L(c),a.replace(c),a=c)),a.setTextContent(g)))}}
|
|
17
|
+
function Ka(a,b,c){var d=a.anchor;const e=a.focus;var f=d.getNode(),g=window.getSelection();g=null!==g?g.anchorNode:null;const h=d.key,l=D().getElementByKey(h);(b=h!==e.key||!v(f)||d.offset!==e.offset&&!f.isComposing()||(c||f.isDirty())&&1<b.length||null!==l&&!f.isComposing()&&g!==ra(l)||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()===
|
|
18
|
+
b&&(!f.canInsertTextBefore()||!c.canInsertTextBefore()||d),b=a||f):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){b=b.get(c.__type);void 0===b&&q(66,c.__type);b=b.klass;let e=a.get(b);void 0===e&&(e=new Map,a.set(b,e));e.set(c.__key,d)}
|
|
19
|
+
function Ra(a,b,c){const d=a.getParent();let e=c;null!==d&&(b&&0===c?(e=a.getIndexWithinParent(),a=d):b||c!==a.getChildrenSize()||(e=a.getIndexWithinParent()+1,a=d));return a.getChildAtIndex(b?e-1:e)}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}
|
|
20
|
+
function Ta(a,b,c,d,e){a=a.__children;const f=a.length;for(let g=0;g<f;g++){const h=a[g],l=d.get(h);void 0!==l&&l.__parent===b&&(E(l)&&Ta(l,h,c,d,e),c.has(h)||e.delete(h),d.delete(h))}}
|
|
21
|
+
function Ua(a,b,c,d){var e=Array.from(c),f=e.length;const g=Array.from(d),h=g.length;a=a._nodeMap;b=b._nodeMap;for(let l=0;l<f;l++){const k=e[l],m=b.get(k);void 0===m||m.isAttached()||(a.has(k)||c.delete(k),b.delete(k))}for(c=0;c<h;c++)e=g[c][0],f=b.get(e),void 0===f||f.isAttached()||(E(f)&&Ta(f,e,a,b,d),a.has(e)||d.delete(e),b.delete(e))}
|
|
22
|
+
function Va(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 Wa(a,b){const c=a.mergeWithSibling(b),d=D()._normalizedNodes;d.add(a.__key);d.add(b.__key);return c}
|
|
23
|
+
function Xa(a){if(""===a.__text&&a.isSimpleText()&&!a.isUnmergeable())a.remove();else{for(var b;null!==(b=a.getPreviousSibling())&&v(b)&&b.isSimpleText()&&!b.isUnmergeable();)if(""===b.__text)b.remove();else{Va(b,a)&&(a=Wa(b,a));break}for(var c;null!==(c=a.getNextSibling())&&v(c)&&c.isSimpleText()&&!c.isUnmergeable();)if(""===c.__text)c.remove();else{Va(a,c)&&Wa(a,c);break}}}
|
|
24
|
+
function Ya(a,b){H();var c=a.__key;const d=a.getParent();if(null!==d){var e=K(),f=!1;if(J(e)&&b){var g=e.anchor;const h=e.focus;g.key===c&&(Za(g,a,d,a.getPreviousSibling(),a.getNextSibling()),f=!0);h.key===c&&(Za(h,a,d,a.getPreviousSibling(),a.getNextSibling()),f=!0)}g=d.getWritable().__children;c=g.indexOf(c);-1===c&&q(16);F(a);g.splice(c,1);a.getWritable().__parent=null;J(e)&&b&&!f&&$a(e,d,c,-1);null===d||M(d)||d.canBeEmpty()||0!==d.getChildrenSize()||Ya(d,b)}}
|
|
25
|
+
class ab{static getType(){q(31,this.name)}static clone(){q(32,this.name)}constructor(a){this.__type=this.constructor.getType();this.__parent=null;if(null!=a)this.__key=a;else{H();99<va&&q(26);a=D();var b=B(),c=""+ma++;b._nodeMap.set(c,this);E(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=I(a);if(null===a)break;a=a.__parent}return!1}isSelected(){const a=
|
|
26
|
+
K();if(null==a)return!1;const b=(new Set(a.getNodes().map(c=>c.__key))).has(this.__key);return v(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:I(a)}getParentOrThrow(){const a=this.getParent();null===a&&q(33,this.__key);return a}getTopLevelElement(){let a=
|
|
27
|
+
this;for(;null!==a;){const b=a.getParent();if(M(b)&&E(a))return a;a=b}return null}getTopLevelElementOrThrow(){const a=this.getTopLevelElement();null===a&&q(34,this.__key);return a}getParents(){const a=[];let b=this.getParent();for(;null!==b;)a.push(b),b=b.getParent();return a}getParentKeys(){const a=[];let b=this.getParent();for(;null!==b;)a.push(b.__key),b=b.getParent();return a}getPreviousSibling(){var a=this.getParent();if(null===a)return null;a=a.__children;const b=a.indexOf(this.__key);return 0>=
|
|
28
|
+
b?null:I(a[b-1])}getPreviousSiblings(){var a=this.getParent();if(null===a)return[];a=a.__children;const b=a.indexOf(this.__key);return a.slice(0,b).map(c=>bb(c))}getNextSibling(){var a=this.getParent();if(null===a)return null;a=a.__children;const b=a.length,c=a.indexOf(this.__key);return c>=b-1?null:I(a[c+1])}getNextSiblings(){var a=this.getParent();if(null===a)return[];a=a.__children;const b=a.indexOf(this.__key);return a.slice(b+1).map(c=>bb(c))}getCommonAncestor(a){const b=this.getParents();var c=
|
|
29
|
+
a.getParents();E(this)&&b.unshift(this);E(a)&&c.unshift(a);a=b.length;var d=c.length;if(0===a||0===d||b[a-1]!==c[d-1])return null;c=new Set(c);for(d=0;d<a;d++){const e=b[d];if(c.has(e))return e}return null}is(a){return null==a?!1:this.getKey()===a.getKey()}isBefore(a){if(a.isParentOf(this))return!0;if(this.isParentOf(a))return!1;var b=this.getCommonAncestor(a);let c=this;for(;;){var d=c.getParentOrThrow();if(d===b){d=d.__children.indexOf(c.__key);break}c=d}for(c=a;;){a=c.getParentOrThrow();if(a===
|
|
30
|
+
b){b=a.__children.indexOf(c.__key);break}c=a}return d<b}isParentOf(a){const b=this.__key;if(b===a.__key)return!1;for(;null!==a;){if(a.__key===b)return!0;a=a.getParent()}return!1}getNodesBetween(a){const b=this.isBefore(a),c=[],d=new Set;var e=this;let f=null;for(;;){var g=e.__key;d.has(g)||(d.add(g),c.push(e));if(e===a)break;g=E(e)?b?e.getFirstChild():e.getLastChild():null;if(null!==g)null===f&&(f=e),e=g;else if(g=b?e.getNextSibling():e.getPreviousSibling(),null!==g)e=g;else{g=e.getParentOrThrow();
|
|
31
|
+
d.has(g.__key)||c.push(g);if(g===a)break;e=g;g.is(f)&&(f=null);do null===e&&q(35),g=b?e.getNextSibling():e.getPreviousSibling(),e=e.getParent(),null!==e&&(e.is(f)&&(f=null),null!==g||d.has(e.__key)||c.push(e));while(null===g);e=g}}b||c.reverse();return c}isDirty(){const a=D()._dirtyLeaves;return null!==a&&a.has(this.__key)}isComposing(){return this.__key===D()._compositionKey}getLatest(){const a=I(this.__key);null===a&&q(36);return a}getWritable(){H();var a=B(),b=D();a=a._nodeMap;const c=this.__key,
|
|
32
|
+
d=this.getLatest(),e=d.__parent;b=b._cloneNotNeeded;if(b.has(c))return y(d),d;const f=d.constructor.clone(d);f.__parent=e;E(d)&&E(f)?(f.__children=Array.from(d.__children),f.__indent=d.__indent,f.__format=d.__format,f.__dir=d.__dir):v(d)&&v(f)?(f.__format=d.__format,f.__style=d.__style,f.__mode=d.__mode,f.__detail=d.__detail):x(d)&&x(f)&&(f.__state=d.__state);b.add(c);f.__key=c;y(f);a.set(c,f);return f}getTextContent(){return""}getTextContentSize(a,b){return this.getTextContent(a,b).length}createDOM(){q(37)}updateDOM(){q(38)}static convertDOM(){return null}remove(){H();
|
|
33
|
+
Ya(this,!0)}replace(a){H();const b=this.__key;a=a.getWritable();var c=a.getParent();if(null!==c){c=c.getWritable().__children;var d=c.indexOf(a.__key);-1===d&&q(16);F(a);c.splice(d,1)}d=this.getParentOrThrow();var e=d.getWritable().__children;const f=e.indexOf(this.__key);c=a.__key;-1===f&&q(16);e.splice(f,0,c);a.__parent=d.__key;Ya(this,!1);F(a);e=K();J(e)&&(d=e.anchor,e=e.focus,d.key===b&&cb(d,a),e.key===b&&cb(e,a));D()._compositionKey===b&&G(c);return a}insertAfter(a){H();var b=this.getWritable(),
|
|
34
|
+
c=a.getWritable(),d=c.getParent();const e=K();var f=!1,g=!1;if(null!==d){var h=d.getWritable().__children,l=h.indexOf(c.__key);-1===l&&q(16);F(c);if(J(e)){g=d.getKey();d=a.getIndexWithinParent();f=e.anchor;const k=e.focus;f="element"===f.type&&f.key===g&&f.offset===d+1;g="element"===k.type&&k.key===g&&k.offset===d+1}h.splice(l,1)}h=this.getParentOrThrow().getWritable();l=c.__key;c.__parent=b.__parent;d=h.__children;b=d.indexOf(b.__key);-1===b&&q(16);d.splice(b+1,0,l);F(c);J(e)&&($a(e,h,b+1),c=h.getKey(),
|
|
35
|
+
f&&e.anchor.set(c,b+2,"element"),g&&e.focus.set(c,b+2,"element"));return a}insertBefore(a){H();var b=this.getWritable(),c=a.getWritable(),d=c.getParent();if(null!==d){d=d.getWritable().__children;var e=d.indexOf(c.__key);-1===e&&q(16);F(c);d.splice(e,1)}d=this.getParentOrThrow().getWritable();e=c.__key;c.__parent=b.__parent;const f=d.__children;b=f.indexOf(b.__key);-1===b&&q(16);f.splice(b,0,e);F(c);c=K();J(c)&&$a(c,d,b);return a}selectPrevious(a,b){H();const c=this.getPreviousSibling(),d=this.getParentOrThrow();
|
|
36
|
+
return null===c?d.select(0,0):E(c)?c.select():v(c)?c.select(a,b):(a=c.getIndexWithinParent()+1,d.select(a,a))}selectNext(a,b){H();const c=this.getNextSibling(),d=this.getParentOrThrow();return null===c?d.select():E(c)?c.select(0,0):v(c)?c.select(a,b):(a=c.getIndexWithinParent(),d.select(a,a))}markDirty(){this.getWritable()}}function bb(a){const b=I(a);null===b&&q(39,a);return b}
|
|
37
|
+
class db{constructor(a,b){this.id=a||Ga();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:"history-merge"}))}set(a){this.editor=a;this.editorState=a.getEditorState()}toJSON(){const a=this.editorState;return{editorState:null===a||"string"===typeof a?a:JSON.stringify(a.toJSON()),id:this.id,type:"editor"}}isEmpty(){return null===this.editorState}}
|
|
38
|
+
function eb(a,b){return new db(a,b)}class fb{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{map:Array.from(this._map.entries()),type:"map"}}}function gb(a,b){return new fb(a,b)}
|
|
39
|
+
class hb{constructor(a,b){this._editor=a;this._observers=new Set;this._array=b||[]}observe(a){const b=this._observers;b.add(a);return()=>{b.delete(a)}}getLength(){return this._array.length}map(a){const b=[],c=this._array;for(let d=0;d<c.length;d++)b.push(a(c[d],d,c));return b}reduce(a,b){const c=this._array;for(let d=0;d<c.length;d++){const e=c[d];b=void 0!==b?a(b,e):e}return b}push(a){this.splice(this._array.length,0,a)}splice(a,b,c){void 0===c?this._array.splice(a,b):this._array.splice(a,b,c);const d=
|
|
40
|
+
Array.from(this._observers);for(let e=0;e<d.length;e++)d[e](a,b,c)}indexOf(a){return this._array.indexOf(a)}destroy(){this._observers.clear()}toJSON(){return{array:this._array,type:"array"}}}function ib(a,b){return new hb(a,b)}class jb extends ab{constructor(a,b){super(b);b=D();this.__state=a||gb(b)}decorate(){q(4)}isIsolated(){return!1}isTopLevel(){return!1}}function x(a){return a instanceof jb}
|
|
41
|
+
function kb(a,b){if("string"===typeof b||"number"===typeof b||"boolean"===typeof b||null===b)var c=b;else if("object"===typeof b)if(c=b.type,"editor"===c)c=eb(b.id,b.editorState);else if("array"===c){b=b.array;c=[];for(let d=0;d<b.length;d++)c.push(kb(a,b[d]));c=ib(a,c)}else c=lb(a,b);else q(48);return c}function lb(a,b){b=b.map;const c=new Map;for(let d=0;d<b.length;d++){const [e,f]=b[d];c.set(e,kb(a,f))}return gb(a,c)}
|
|
42
|
+
function mb(a,b,c,d,e={originalSelection:null}){var f=a.__type,g=c._nodes.get(f);void 0===g&&q(24,f);g=g.klass;f=a.__key;a.__key=void 0;g=g.clone(a);a.__key=f;const h=g.__key;M(g)&&B()._nodeMap.set("root",g);g.__parent=d;if(E(g)){d=a.__children;for(var l=0;l<d.length;l++){var k=b.get(d[l]);void 0!==k&&(k=mb(k,b,c,h,e).getKey(),g.__children.push(k))}g.__indent=a.__indent;g.__format=a.__format;g.__dir=a.__dir}else v(g)?(g.__format=a.__format,g.__style=a.__style,g.__mode=a.__mode,g.__detail=a.__detail):
|
|
43
|
+
x(g)&&(g.__state=lb(c,a.__state));b=null!=e?e.originalSelection:void 0;null!=b&&(a=e.remappedSelection,"range"===b.type?(c=b.anchor,b=b.focus,null!=a||f!==c.key&&f!==b.key||(e.remappedSelection=a={anchor:{...c},focus:{...b},type:"range"}),null!=a&&"range"===a.type&&(f===c.key&&(a.anchor.key=h),f===b.key&&(a.focus.key=h))):"node"===b.type?(b=b.nodes,f=b.indexOf(f),-1!==f&&(null==a&&(e.remappedSelection=a={nodes:[...b],type:"node"}),"node"===a.type&&a.nodes.splice(f,1,h))):"grid"===b.type&&(c=b.gridKey,
|
|
44
|
+
d=b.anchorCellKey,l=b.focusCellKey,null!=a||c!==f&&c!==d&&c!==l||(e.remappedSelection=a={...b,type:"grid"}),null!=a&&"grid"===a.type&&(c===f&&(a.gridKey=h),d===f&&(a.anchorCellKey=h),l===f&&(a.focusCellKey=h))));return g}let N="",O="",R="",nb,S,ob,pb=!1,qb=!1,rb=null,sb,tb,ub,vb,wb,xb;function yb(a,b){const c=ub.get(a);if(null!==b){const d=zb(a);b.removeChild(d)}vb.has(a)||S._keyToDOMMap.delete(a);E(c)&&(a=c.__children,Ab(a,0,a.length-1,null));void 0!==c&&Qa(xb,ob,c,"destroyed")}
|
|
45
|
+
function Ab(a,b,c,d){for(;b<=c;++b){const e=a[b];void 0!==e&&yb(e,d)}}function Bb(a,b){a.setProperty("text-align",b)}function Cb(a,b){a.style.setProperty("padding-inline-start",0===b?"":40*b+"px")}function Db(a,b){a=a.style;0===b?Bb(a,""):1===b?Bb(a,"left"):2===b?Bb(a,"center"):3===b?Bb(a,"right"):4===b&&Bb(a,"justify")}
|
|
46
|
+
function Eb(a,b,c){const d=vb.get(a);void 0===d&&q(42);const e=d.createDOM(nb,S);var f=S._keyToDOMMap;e["__lexicalKey_"+S._key]=a;f.set(a,e);v(d)?e.setAttribute("data-lexical-text","true"):x(d)&&e.setAttribute("data-lexical-decorator","true");if(E(d)){a=d.__indent;0!==a&&Cb(e,a);a=d.__children;var g=a.length;if(0!==g){f=a;--g;const h=O;O="";Fb(f,0,g,e,null);Gb(d,e);O=h}f=d.__format;0!==f&&Db(e,f);Hb(null,a,e)}else x(d)?(f=d.decorate(S),g=d.getTextContent(),null!==f&&Ib(a,f),e.contentEditable="false",
|
|
47
|
+
N+=g,R+=g):(a=d.getTextContent(),v(d)&&(d.isDirectionless()||(O+=a),d.isInert()&&(f=e.style,f.pointerEvents="none",f.userSelect="none",e.contentEditable="false",f.setProperty("-webkit-user-select","none"))),N+=a,R+=a);null!==b&&(null!=c?b.insertBefore(e,c):(c=b.__lexicalLineBreak,null!=c?b.insertBefore(e,c):b.appendChild(e)));Qa(xb,ob,d,"created");return e}function Fb(a,b,c,d,e){const f=N;for(N="";b<=c;++b)Eb(a[b],d,e);d.__lexicalTextContent=N;N=f+N}
|
|
48
|
+
function Jb(a,b){a=b.get(a[a.length-1]);return ua(a)||x(a)}function Hb(a,b,c){a=null!==a&&(0===a.length||Jb(a,ub));b=null!==b&&(0===b.length||Jb(b,vb));a?b||(b=c.__lexicalLineBreak,null!=b&&c.removeChild(b),c.__lexicalLineBreak=null):b&&(b=document.createElement("br"),c.__lexicalLineBreak=b,c.appendChild(b))}
|
|
49
|
+
function Gb(a,b){const c=b.__lexicalDir;if(b.__lexicalDirTextContent!==O||c!==rb){var d=""===O;if(d)var e=rb;else e=O,e=ba.test(e)?"rtl":ca.test(e)?"ltr":null;if(e!==c){const f=b.classList,g=nb.theme;null===e||d&&"ltr"===e?(b.removeAttribute("dir"),d=g[c],void 0!==d&&("string"===typeof d&&(d=d.split(" "),d=g[c]=d),f.remove(...d))):null!==e&&(d=g[e],void 0!==d&&("string"===typeof d&&(d=d.split(" "),d=g[c]=d),f.add(...d)),b.dir=e);qb||(a.getWritable().__dir=e)}rb=e;b.__lexicalDirTextContent=O;b.__lexicalDir=
|
|
49
50
|
e}}
|
|
50
|
-
function
|
|
51
|
-
a),c=c.__children,a=d.__children,c!==a||e){var g=c,h=a;e=d;b=
|
|
52
|
-
m&&(m=new Set(g));void 0===n&&(n=new Set(h));const P=n.has(p),
|
|
53
|
-
c);!
|
|
54
|
-
function
|
|
55
|
-
function
|
|
56
|
-
k;l++)m=h[l],g=m[0],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()&&
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
(w=
|
|
60
|
-
e&&
|
|
61
|
-
(k===g&&(k=
|
|
62
|
-
function
|
|
63
|
-
function
|
|
64
|
-
function
|
|
65
|
-
(f._flushSync=!0);const p=f._selection;if(
|
|
66
|
-
null))}function
|
|
67
|
-
function
|
|
68
|
-
null===A&&C.removeChild(z)}k=k.removedNodes;m=k.length;if(0<m){u=0;for(z=0;z<m;z++)A=k[z],"BR"!==A.nodeName||n.__lexicalLineBreak!==A&&void 0===A["__lexicalKey_"+a._key]||(n.appendChild(A),u++);m!==u&&(n===f&&(p=g._nodeMap.get("root")),e.set(n,p))}}}if(0<e.size)for(e=Array.from(e.entries()),f=0;f<e.length;f++){const [C,w]=e[f];if(
|
|
69
|
-
else
|
|
70
|
-
function
|
|
71
|
-
class
|
|
72
|
-
c;
|
|
73
|
-
function
|
|
74
|
-
class
|
|
75
|
-
|
|
76
|
-
class
|
|
77
|
-
"";for(let c=0;c<a.length;c++)b+=a[c].getTextContent();return b}}function
|
|
78
|
-
class
|
|
79
|
-
a.__key,b,"text");
|
|
80
|
-
e):m.slice(0,d));g+=m}else!
|
|
81
|
-
this.dirty=!0}hasFormat(a){return 0!==(this.format&
|
|
82
|
-
q(6);d=c.getTextContent().length;var k=c.getParentOrThrow();if(!this.isCollapsed()||b!==d||!c.isSegmented()&&!c.isToken()&&c.canInsertTextAfter()&&k.canInsertTextAfter())if(!this.isCollapsed()||0!==b||!c.isSegmented()&&!c.isToken()&&c.canInsertTextBefore()&&k.canInsertTextBefore())c.isSegmented()&&b!==d&&(k=
|
|
83
|
-
return}}else{var m=c.getNextSibling();if(!
|
|
84
|
-
(this.anchor.offset-=a.length)}else{k=f[g-1];e=new Set([...c.getParentKeys(),...k.getParentKeys()]);var n=
|
|
85
|
-
m){for(n=h.length-1;0<=n;n--){const u=h[n];if(u.is(c)||
|
|
86
|
-
e.has(c)||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.toggleFormat(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(
|
|
87
|
-
f.type&&"element"===g.type?(d.setFormat(k),d.select(n,m),this.format=k):(n=p>l?l:p,m=p>l?p: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(
|
|
88
|
-
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=
|
|
89
|
-
0;n<a.length;n++){const p=a[n];if(
|
|
90
|
-
f.insertAfter(p);else if(
|
|
91
|
-
a.selectNext()),0!==c.length)for(b=c.length-1;0<=b;b--)a=c[b],d=a.getParentOrThrow(),
|
|
92
|
-
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();if(
|
|
93
|
-
e.remove())}}insertLineBreak(a){const b=
|
|
94
|
-
l,d===f.getTextContentSize()?a.shift():0!==d&&([,f]=f.splitText(d),a[0]=f));
|
|
95
|
-
return}}d=
|
|
96
|
-
|
|
97
|
-
d.offset,g=e.offset;const h=f<g;c=h?f:g;g=h?g:f;f=g-1;c!==f&&(b=b.getTextContent().slice(c,g),/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(b)||(a?e.offset=f:d.offset=f))}}else if(a&&0===b.offset&&("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).collapseAtStart(this))return}this.removeText();a=this.anchor;"text"===a.type&&(a=a.getNode(),d=a.getTextContent(),e=this.anchor.offset,0===e&&a.isSimpleText()?(e=a.getPreviousSibling(),
|
|
98
|
-
e.setTextContent(b+d),a.remove())):
|
|
99
|
-
function
|
|
100
|
-
function
|
|
101
|
-
d=0===b&&
|
|
102
|
-
function
|
|
103
|
-
0));e.isComposing()&&e._compositionKey!==a.key&&
|
|
104
|
-
function
|
|
105
|
-
function
|
|
106
|
-
function
|
|
107
|
-
function
|
|
108
|
-
c)?g.getChildAtIndex(c-1):g.getChildAtIndex(e),
|
|
109
|
-
function
|
|
110
|
-
class
|
|
111
|
-
|
|
112
|
-
this.getChildren(),c=b.length;if(0===c)return this;if(a>=c)return a=b[c-1],
|
|
113
|
-
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);
|
|
114
|
-
this.getFirstDescendant();return
|
|
115
|
-
if(null!==h){h=h.getWritable().__children;const l=h.indexOf(g.__key);-1===l&&q(16);h.splice(l,1)}g.__parent=c;d.push(g.__key)}return b}setDirection(a){
|
|
116
|
-
if(null!==l){l=l.getWritable().__children;const p=l.indexOf(n.__key);-1===p&&q(16);
|
|
117
|
-
null!=c&&(c.getWritable().__parent=null);0!==f.length||this.canBeEmpty()||
|
|
118
|
-
class
|
|
119
|
-
function
|
|
120
|
-
class
|
|
121
|
-
type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type},type:"range"}
|
|
122
|
-
let
|
|
123
|
-
function
|
|
124
|
-
function
|
|
125
|
-
e?(a.preventDefault(),b.execCommand("insertParagraph")):null==e&&a.dataTransfer?(e=a.dataTransfer.getData("text/plain"),a.preventDefault(),d.insertRawText(e)):null!=e&&
|
|
126
|
-
break;case "insertParagraph":
|
|
51
|
+
function Kb(a,b){var c=ub.get(a),d=vb.get(a);void 0!==c&&void 0!==d||q(43);var e=pb||tb.has(a)||sb.has(a);const f=Lb(S,a);if(c===d&&!e)return E(c)?(d=f.__lexicalTextContent,void 0!==d&&(N+=d,R+=d),d=f.__lexicalDirTextContent,void 0!==d&&(O+=d)):x(c)||(d=c.getTextContent(),v(c)&&!c.isDirectionless()&&(O+=d),R+=d,N+=d),f;if(d.updateDOM(c,f,nb))return d=Eb(a,null,null),null===b&&q(44),b.replaceChild(d,f),yb(a,null),d;if(E(c)&&E(d)){if(a=d.__indent,a!==c.__indent&&Cb(f,a),a=d.__format,a!==c.__format&&Db(f,
|
|
52
|
+
a),c=c.__children,a=d.__children,c!==a||e){var g=c,h=a;e=d;b=O;O="";const u=N;N="";var l=g.length,k=h.length;if(1===l&&1===k){var m=g[0];h=h[0];if(m===h)Kb(m,f);else{var n=zb(m);h=Eb(h,null,null);f.replaceChild(h,n);yb(m,null)}}else if(0===l)0!==k&&Fb(h,0,k-1,f,null);else if(0===k)0!==l&&(m=null==f.__lexicalLineBreak,Ab(g,0,l-1,m?null:f),m&&(f.textContent=""));else{const z=l-1;l=k-1;let A=f.firstChild,C=0;for(k=0;C<=z&&k<=l;){var p=g[C];const w=h[k];if(p===w)A=Kb(w,f).nextSibling,C++,k++;else{void 0===
|
|
53
|
+
m&&(m=new Set(g));void 0===n&&(n=new Set(h));const P=n.has(p),La=m.has(w);P?(La?(p=Lb(S,w),p===A?A=Kb(w,f).nextSibling:(null!=A?f.insertBefore(p,A):f.appendChild(p),Kb(w,f)),C++):Eb(w,f,A),k++):(A=zb(p).nextSibling,yb(p,f),C++)}}m=C>z;n=k>l;m&&!n?(m=h[l+1],m=void 0===m?null:S.getElementByKey(m),Fb(h,k,l,f,m)):n&&!m&&Ab(g,C,z,f)}f.__lexicalTextContent=N;N=u+N;Gb(e,f);O=b;M(d)||Hb(c,a,f)}}else x(d)?(c=d.decorate(S),null!==c&&Ib(a,c)):(c=d.getTextContent(),v(d)&&!d.isDirectionless()&&(O+=c),N+=c,R+=
|
|
54
|
+
c);!qb&&M(d)&&d.__cachedText!==R&&(d=d.getWritable(),d.__cachedText=R);return f}function Ib(a,b){let c=S._pendingDecorators;const d=S._decorators;if(null===c){if(d[a]===b)return;c=ya(S)}c[a]=b}function zb(a){a=wb.get(a);void 0===a&&q(45);return a}function Lb(a,b){a=a._keyToDOMMap.get(b);void 0===a&&q(45);return a}let T=null,U=null,V=!1,Mb=!1,va=0;function H(){V&&q(25)}function B(){null===T&&q(27);return T}function D(){null===U&&q(28);return U}
|
|
55
|
+
function Nb(a,b,c){var d=b.__type;const e=a._nodes.get(d);void 0===e&&q(23,d);a=c.get(d);void 0===a&&(a=Array.from(e.transforms),c.set(d,a));c=a.length;for(d=0;d<c&&(a[d](b),b.isAttached());d++);}function Ob(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]);v(e)&&e.isSimpleText()&&!e.isUnmergeable()&&Xa(e)}}
|
|
56
|
+
function Pb(a,b){const c=b._dirtyLeaves,d=b._dirtyElements;a=a._nodeMap;const e=D()._compositionKey,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 p=a.get(n);v(p)&&p.isSimpleText()&&!p.isUnmergeable()&&Xa(p);void 0!==p&&void 0!==p&&p.__key!==e&&p.isAttached()&&Nb(b,p,f);c.add(n)}g=b._dirtyLeaves;h=g.size;if(0<h){va++;continue}}b._dirtyLeaves=new Set;b._dirtyElements=new Map;h=Array.from(l);for(l=0;l<
|
|
57
|
+
k;l++)m=h[l],g=m[0],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()&&Nb(b,n,f),d.set(g,m));g=b._dirtyLeaves;h=g.size;l=b._dirtyElements;k=l.size;va++}b._dirtyLeaves=c;b._dirtyElements=d}
|
|
58
|
+
function W(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=V,k=U,m=a._updating;U=a;T=b;V=!1;a._updating=!0;try{var n=a._observer;let fa=null;if(g&&null!==n){var p=a._dirtyType,u=a._dirtyElements,z=a._dirtyLeaves;n.disconnect();try{O=R=N="";pb=2===p;rb=null;S=a;nb=a._config;ob=a._nodes;sb=u;tb=z;ub=d._nodeMap;vb=b._nodeMap;qb=b._readOnly;wb=new Map(a._keyToDOMMap);
|
|
59
|
+
const pa=new Map;xb=pa;Kb("root",null);xb=wb=nb=vb=ub=tb=sb=ob=S=void 0;fa=pa}finally{n.observe(c,{characterData:!0,childList:!0,subtree:!0})}}const Ma=window.getSelection();if(null!==Ma&&(g||null===f||f.dirty)){n=Ma;const pa=n.anchorNode,dc=n.focusNode,Qc=n.anchorOffset,Rc=n.focusOffset,Na=document.activeElement,Z=a._rootElement;if(!a._updateTags.has("collaboration")||Na===Z)if(J(f)){var A=f.anchor,C=f.focus,w=C.key,P=Lb(a,A.key),La=Lb(a,w),ec=A.offset,fc=C.offset;e=P;w=La;"text"===A.type&&(e=ra(P));
|
|
60
|
+
"text"===C.type&&(w=ra(La));if(null!==e&&null!==w)if(Qc===ec&&Rc===fc&&pa===e&&dc===w)null===Z||null!==Na&&Z.contains(Na)||Z.focus({preventScroll:!0});else try{if(n.setBaseAndExtent(e,ec,w,fc),f.isCollapsed()&&Z===Na){const aa=3===e.nodeType?e.parentNode:e;if(null!==aa){const Oa=aa.getBoundingClientRect();if(Oa.bottom>window.innerHeight)aa.scrollIntoView(!1);else if(0>Oa.top)aa.scrollIntoView();else if(Z){const gc=Z.getBoundingClientRect();Oa.bottom>gc.bottom?aa.scrollIntoView(!1):Oa.top<gc.top&&
|
|
61
|
+
aa.scrollIntoView()}}}}catch(aa){}}else null!==e&&oa(a,pa,dc)&&n.removeAllRanges()}var hc=fa;null!==hc&&Qb(a,d,b,hc)}catch(fa){a._onError(fa);Mb||(Rb(a,null,c,b),Sb(a),a._dirtyType=2,Mb=!0,W(a),Mb=!1);return}finally{a._updating=m,T=h,V=l,U=k}b._readOnly=!0;c=a._dirtyLeaves;f=a._dirtyElements;h=a._normalizedNodes;l=a._updateTags;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;k=a._pendingDecorators||
|
|
62
|
+
g;m=b._nodeMap;for(var Q in k)m.has(Q)||(k===g&&(k=ya(a)),delete k[Q]);Q=a._pendingDecorators;null!==Q&&(a._decorators=Q,a._pendingDecorators=null,Tb("decorator",a,!0,Q));Q=za(d);g=za(b);Q!==g&&Tb("textcontent",a,!0,g);Tb("update",a,!0,{dirtyElements:f,dirtyLeaves:c,editorState:b,normalizedNodes:h,prevEditorState:d,tags:l});b=a._deferred;a._deferred=[];if(0!==b.length){d=a._updating;a._updating=!0;try{for(Q=0;Q<b.length;Q++)b[Q]()}finally{a._updating=d}}b=a._updates;if(0!==b.length){const [fa,Ma]=
|
|
63
|
+
b.shift();Ub(a,fa,Ma)}}}function Qb(a,b,c,d){a._listeners.mutation.forEach((e,f)=>{e=d.get(e);void 0!==e&&f(e)})}function Tb(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}}
|
|
64
|
+
function Vb(a,b,c){if(!1===a._updating||U!==a){let e=!1;a.update(()=>{e=Vb(a,b,c)});return e}const d=Fa(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}function Wb(a){const b=a._updates;let c=!1;for(;0!==b.length;){const [d,e]=b.shift();let f,g;void 0!==e&&(f=e.onUpdate,g=e.tag,e.skipTransforms&&(c=!0),f&&a._deferred.push(f),g&&a._updateTags.add(g));d()}return c}
|
|
65
|
+
function Ub(a,b,c){const d=a._updateTags;var e=!1;if(void 0!==c){var f=c.onUpdate;e=c.tag;null!=e&&d.add(e);e=c.skipTransforms}f&&a._deferred.push(f);c=a._editorState;f=a._pendingEditorState;let g=!1;null===f&&(f=a._pendingEditorState=new Xb(new Map(c._nodeMap)),g=!0);const h=T,l=V,k=U,m=a._updating;T=f;V=!1;a._updating=!0;U=a;try{g&&(f._selection=Yb(a));const n=a._compositionKey;b();e=Wb(a);Zb(f,a);0!==a._dirtyType&&(e?Ob(f,a):Pb(f,a),Wb(a),Ua(c,f,a._dirtyLeaves,a._dirtyElements));n!==a._compositionKey&&
|
|
66
|
+
(f._flushSync=!0);const p=f._selection;if(J(p)){const u=f._nodeMap,z=p.focus.key;void 0!==u.get(p.anchor.key)&&void 0!==u.get(z)||q(30)}else $b(p)&&0===p._nodes.size&&(f._selection=null)}catch(n){a._onError(n);a._pendingEditorState=c;a._dirtyType=2;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();W(a);return}finally{T=h,V=l,U=k,a._updating=m,va=0}0!==a._dirtyType||ac(f,a)?f._flushSync?(f._flushSync=!1,W(a)):g&&na(()=>{W(a)}):(f._flushSync=!1,g&&(d.clear(),a._deferred=[],a._pendingEditorState=
|
|
67
|
+
null))}function Ca(a,b,c){a._updating?a._updates.push([b,c]):Ub(a,b,c)}let bc=!1,cc=0;function ic(a){cc=a.timeStamp}function jc(a){return a.getEditorState().read(()=>{const b=K();return null!==b?b.clone():null})}
|
|
68
|
+
function kc(a,b,c){bc=!0;const d=100<performance.now()-cc;try{Ca(a,()=>{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,p=xa(n,g);if(!x(p))if("characterData"===m){if(d&&3===n.nodeType&&v(p)&&p.isAttached()){k=window.getSelection();var u=m=null;null!==k&&k.anchorNode===n&&(m=k.anchorOffset,u=k.focusOffset);Ia(p,n.nodeValue,m,u,!1)}}else if("childList"===m){h=!0;m=k.addedNodes;for(u=0;u<m.length;u++){var z=m[u],A=wa(z);const C=z.parentNode;
|
|
69
|
+
null!=C&&null===A&&C.removeChild(z)}k=k.removedNodes;m=k.length;if(0<m){u=0;for(z=0;z<m;z++)A=k[z],"BR"!==A.nodeName||n.__lexicalLineBreak!==A&&void 0===A["__lexicalKey_"+a._key]||(n.appendChild(A),u++);m!==u&&(n===f&&(p=g._nodeMap.get("root")),e.set(n,p))}}}if(0<e.size)for(e=Array.from(e.entries()),f=0;f<e.length;f++){const [C,w]=e[f];if(E(w))for(g=w.__children,l=C.firstChild,p=0;p<g.length;p++)n=a.getElementByKey(g[p]),null!==n&&(null==l?(C.appendChild(n),l=n):l!==n&&C.replaceChild(n,l),l=l.nextSibling);
|
|
70
|
+
else v(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,p=0;p<g.length;p++)n=g[p],k=n.parentNode,null!=k&&"BR"===n.nodeName&&l.__lexicalLineBreak!==n&&void 0===n["__lexicalKey_"+a._key]&&k.removeChild(n);c.takeRecords()}h&&(h=K()||jc(a),null!==h&&(h.dirty=!0,Da(h)))})}finally{bc=!1}}function lc(a){const b=a._observer;if(null!==b){const c=b.takeRecords();kc(a,c,b)}}
|
|
71
|
+
function Sb(a){0===cc&&window.addEventListener("textInput",ic,!0);a._observer=new MutationObserver((b,c)=>{kc(a,b,c)})}
|
|
72
|
+
class X{constructor(a,b,c){this.key=a;this.offset=b;this.type=c}is(a){return this.key===a.key&&this.offset===a.offset&&this.type===a.type}isBefore(a){let b=this.getNode(),c=a.getNode();const d=this.offset;a=a.offset;E(b)&&(b=b.getDescendantByIndex(d));E(c)&&(c=c.getDescendantByIndex(a));return b===c?d<a:b.isBefore(c)}getCharacterOffset(){return"text"===this.type?this.offset:0}getNode(){const a=I(this.key);null===a&&q(5);return a}set(a,b,c){const d=K(),e=this.key;this.key=a;this.offset=b;this.type=
|
|
73
|
+
c;V||(D()._compositionKey===e&&G(a),null===d||d.anchor!==this&&d.focus!==this||(d.dirty=!0))}}function mc(a,b){const c=b.getKey();let d=a.offset,e="element";v(b)&&(e="text",b=b.getTextContentSize(),d>b&&(d=b));a.set(c,d,e)}function cb(a,b){if(E(b)){const c=b.getLastDescendant();E(c)||v(c)?mc(a,c):mc(a,b)}else v(b)&&mc(a,b)}
|
|
74
|
+
function nc(a,b,c){const d=a.getNode(),e=d.getChildAtIndex(a.offset),f=L(),g=M(d)?oc().append(f):f;f.setFormat(c);null===e?d.append(g):e.insertBefore(g);a.is(b)&&b.set(f.getKey(),0,"text");a.set(f.getKey(),0,"text")}function Y(a,b,c,d){a.key=b;a.offset=c;a.type=d}
|
|
75
|
+
class pc{constructor(a){this.dirty=!1;this._nodes=a}is(a){if(!$b(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)}delete(a){this.dirty=!0;this._nodes.delete(a)}clear(){this.dirty=!0;this._nodes.clear()}has(a){return this._nodes.has(a)}clone(){return new pc(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(){}insertText(){}getNodes(){const a=Array.from(this._nodes),b=[];for(let c=0;c<a.length;c++){const d=
|
|
76
|
+
I(a[c]);null!==d&&b.push(d)}return b}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 qc}
|
|
77
|
+
class rc{constructor(a,b,c){this.gridKey=a;this.anchorCellKey=b;this.focusCellKey=c;this.dirty=!1}is(a){return sc(a)?this.gridKey===a.gridKey&&this.anchorCellKey===a.anchorCellKey&&this.focusCellKey===a.focusCellKey:!1}set(a,b,c){this.dirty=!0;this.gridKey=a;this.anchorCellKey=b;this.focusCellKey=c}clone(){return new rc(this.gridKey,this.anchorCellKey,this.focusCellKey)}extract(){return this.getNodes()}insertRawText(){}insertText(){}getNodes(){return[]}getTextContent(){const a=this.getNodes();let b=
|
|
78
|
+
"";for(let c=0;c<a.length;c++)b+=a[c].getTextContent();return b}}function sc(a){return a instanceof rc}
|
|
79
|
+
class qc{constructor(a,b,c){this.anchor=a;this.focus=b;this.dirty=!1;this.format=c}is(a){return J(a)?this.anchor.is(a.anchor)&&this.focus.is(a.focus):!1}isBackward(){return this.focus.isBefore(this.anchor)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const a=this.anchor,b=this.focus;let c=a.getNode(),d=b.getNode();E(c)&&(c=c.getDescendantByIndex(a.offset));E(d)&&(d=d.getDescendantByIndex(b.offset));return c.is(d)?E(c)?[]:[c]:c.getNodesBetween(d)}setTextNodeRange(a,b,c,d){Y(this.anchor,
|
|
80
|
+
a.__key,b,"text");Y(this.focus,c.__key,d,"text");this.dirty=!0}getTextContent(){const a=this.getNodes();if(0===a.length)return"";const b=a[0],c=a[a.length-1];var d=this.anchor,e=this.focus;const f=d.isBefore(e);d=d.getCharacterOffset();e=e.getCharacterOffset();let g="",h=!0;for(let l=0;l<a.length;l++){const k=a[l];if(E(k)&&!k.isInline())h||(g+="\n"),h=k.isEmpty()?!1:!0;else if(h=!1,v(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,
|
|
81
|
+
e):m.slice(0,d));g+=m}else!x(k)&&!ua(k)||k===c&&this.isCollapsed()||(g+=k.getTextContent())}return g}applyDOMRange(a){const b=D(),c=b.getEditorState()._selection;a=tc(a.startContainer,a.startOffset,a.endContainer,a.endOffset,b,c);if(null!==a){var [d,e]=a;Y(this.anchor,d.key,d.offset,d.type);Y(this.focus,e.key,e.offset,e.type)}}clone(){const a=this.anchor,b=this.focus;return new qc(new X(a.key,a.offset,a.type),new X(b.key,b.offset,b.type),this.format)}toggleFormat(a){this.format=sa(this.format,a,null);
|
|
82
|
+
this.dirty=!0}hasFormat(a){return 0!==(this.format&da[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(L(e));d!==c-1&&a.push(uc())}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?nc(b,c,e):d||"element"!==c.type||nc(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];v(c)||
|
|
83
|
+
q(6);d=c.getTextContent().length;var k=c.getParentOrThrow();if(!this.isCollapsed()||b!==d||!c.isSegmented()&&!c.isToken()&&c.canInsertTextAfter()&&k.canInsertTextAfter())if(!this.isCollapsed()||0!==b||!c.isSegmented()&&!c.isToken()&&c.canInsertTextBefore()&&k.canInsertTextBefore())c.isSegmented()&&b!==d&&(k=L(c.getTextContent()),c.replace(k),c=k);else{m=c.getPreviousSibling();if(!v(m)||t(m)||m.isSegmented())m=L(),k.canInsertTextBefore()?c.insertBefore(m):k.insertBefore(m);m.select();c=m;if(""!==a){this.insertText(a);
|
|
84
|
+
return}}else{var m=c.getNextSibling();if(!v(m)||t(m)||m.isSegmented())m=L(),k.canInsertTextAfter()?c.insertAfter(m):k.insertAfter(m);m.select(0,0);c=m;if(""!==a){this.insertText(a);return}}if(1===g)if(t(c))c.remove();else{f=c.getFormat();if(b===l&&f!==e)if(""===c.getTextContent())c.setFormat(e);else{f=L(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&&
|
|
85
|
+
(this.anchor.offset-=a.length)}else{k=f[g-1];e=new Set([...c.getParentKeys(),...k.getParentKeys()]);var n=E(c)?c:c.getParentOrThrow();m=E(k)?k:k.getParentOrThrow();"text"===h.type&&(0!==l||""===k.getTextContent())||"element"===h.type&&k.getIndexWithinParent()<l?v(k)&&!t(k)&&l!==k.getTextContentSize()?(k.isSegmented()&&(h=L(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 p=n.is(m);if(m.canBeEmpty()||n===
|
|
86
|
+
m){for(n=h.length-1;0<=n;n--){const u=h[n];if(u.is(c)||E(u)&&u.isParentOf(c))break;u.isAttached()&&(!l.has(u)||u.is(k)?p||c.insertAfter(u):u.remove())}if(!p)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);t(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(),
|
|
87
|
+
e.has(c)||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.toggleFormat(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(v(n)){k=n.getFormatFlags(a,null);break}}var p=f.offset;n=(m=f.isBefore(g))?p:l;m=m?l:p;if(n===d.getTextContentSize()){const u=d.getNextSibling();v(u)&&(n=p=0,d=u,k=d.getFormatFlags(a,null))}if(d.is(e))v(d)&&("element"===
|
|
88
|
+
f.type&&"element"===g.type?(d.setFormat(k),d.select(n,m),this.format=k):(n=p>l?l:p,m=p>l?p: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(v(d)&&(0!==n&&([,d]=d.splitText(n)),d.setFormat(k)),f=k,v(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(),v(m)&&g!==d.getKey()&&g!==e.getKey()&&!m.isToken()&&(g=m.getFormatFlags(a,
|
|
89
|
+
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=M(e)?null:e.getTopLevelElementOrThrow();if(v(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(t(e))return!1;[f,e]=e.splitText(d);c.push(e)}e=f;c.push(...g);g=a[0];var l=!1;for(let n=
|
|
90
|
+
0;n<a.length;n++){const p=a[n];if(E(p)){if(p.is(g)){if(E(f)&&f.isEmpty()&&f.canReplaceWith(p)){f.replace(p);f=p;l=!0;continue}var k=p.getFirstDescendant();if(ta(k)){for(k=k.getParentOrThrow();k.isInline();)k=k.getParentOrThrow();l=k.getChildren();var m=l.length;if(E(f))for(let u=0;u<m;u++)f.append(l[u]);else{for(--m;0<=m;m--)f.insertAfter(l[m]);f=f.getParentOrThrow()}k.remove();l=!0;if(k.is(p))continue}}v(f)&&(null===h&&q(69),f=h)}else l&&!x(p)&&M(f.getParent())&&q(7);l=!1;if(E(f))if(x(p)&&p.isTopLevel())f=
|
|
91
|
+
f.insertAfter(p);else if(E(p)){if(p.canBeEmpty()||!p.isEmpty())M(f)?(k=f.getChildAtIndex(d),null!==k?k.insertBefore(p):f.append(p),f=p):f=f.insertAfter(p)}else k=f.getFirstChild(),null!==k?k.insertBefore(p):f.append(p),f=p;else!E(p)||x(f)&&f.isTopLevel()?f=f.insertAfter(p):(f=p.getParentOrThrow(),n--)}b&&(v(e)?e.select():(a=f.getPreviousSibling(),v(a)?a.select():(a=f.getIndexWithinParent(),f.getParentOrThrow().select(a,a))));if(E(f)){if(a=f.getLastDescendant(),b||(null===a?f.select():v(a)?a.select():
|
|
92
|
+
a.selectNext()),0!==c.length)for(b=c.length-1;0<=b;b--)a=c[b],d=a.getParentOrThrow(),E(f)&&!E(a)?(f.append(a),f=a):E(a)&&!a.canInsertAfter(f)?(h=d.constructor.clone(d),E(h)||q(8),h.append(a),f.insertAfter(h)):f.insertAfter(a),d.isEmpty()&&!d.canBeEmpty()&&d.remove()}else b||(v(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;
|
|
93
|
+
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();if(M(e)){a=oc();b=e.getChildAtIndex(b);a.select();null!==b?b.insertBefore(a):e.append(a);return}a=e.getChildren().slice(b).reverse()}e=e.insertNewAfter(this);if(null===e)this.insertLineBreak();else if(E(e)){b=a.length;c=null;if(0!==b)for(d=0;d<b;d++){const f=a[d];null===c?e.append(f):c.insertBefore(f);c=f}e.canBeEmpty()||0!==e.getChildrenSize()?e.selectStart():(e.selectPrevious(),
|
|
94
|
+
e.remove())}}insertLineBreak(a){const b=uc();var c=this.anchor;"element"===c.type&&(c=c.getNode(),M(c)&&this.insertParagraph());a?this.insertNodes([b],!0):this.insertNodes([b])&&b.selectNext(0,0)}extract(){var a=this.getNodes(),b=a.length,c=b-1,d=this.anchor;const e=this.focus;var f=a[0];let g=a[c];var h=d.getCharacterOffset();const l=e.getCharacterOffset();if(0===b)return[];if(1===b)return v(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);v(f)&&(d=b?h:
|
|
95
|
+
l,d===f.getTextContentSize()?a.shift():0!==d&&([,f]=f.splitText(d),a[0]=f));v(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;const g=Sa(d,b);if(x(g)&&!g.isIsolated()){var h=b?g.getPreviousSibling():g.getNextSibling();if(!v(h)){a=g.getParentOrThrow();E(h)?(a=h.getKey(),h=b?h.getChildrenSize():0):(h=g.getIndexWithinParent(),a=a.getKey(),b||h++);d.set(a,h,"element");f&&e.set(a,h,"element");
|
|
96
|
+
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,h=b.type,Y(b,f.key,f.offset,f.type),Y(f,d,e,h)))}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()||
|
|
97
|
+
d.getParentOrThrow().getNextSibling(),E(d)&&!d.canExtractContents()))return;this.modify("extend",a,"character");if(!this.isCollapsed()){var e="text"===c.type?c.getNode():null;d="text"===b.type?b.getNode():null;if(null!==e&&e.isSegmented()){if(b=c.offset,c=e.getTextContentSize(),e.is(d)||a&&b!==c||!a&&0!==b){vc(e,a);return}}else if(null!==d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(e)||a&&0!==b||!a&&b!==c)){vc(d,a);return}d=this.anchor;e=this.focus;b=d.getNode();c=e.getNode();if(b===
|
|
98
|
+
c&&"text"===d.type&&"text"===e.type){var f=d.offset,g=e.offset;const h=f<g;c=h?f:g;g=h?g:f;f=g-1;c!==f&&(b=b.getTextContent().slice(c,g),/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(b)||(a?e.offset=f:d.offset=f))}}else if(a&&0===b.offset&&("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).collapseAtStart(this))return}this.removeText();a=this.anchor;"text"===a.type&&(a=a.getNode(),d=a.getTextContent(),e=this.anchor.offset,0===e&&a.isSimpleText()?(e=a.getPreviousSibling(),v(e)&&"hashtag"===e.getType()&&
|
|
99
|
+
(e.select(),b=e.getTextContent(),e.setTextContent(b+d),a.remove())):v(a)&&"hashtag"===a.getType()&&e===a.getTextContentSize()&&(e=a.getNextSibling(),v(e)&&e.isSimpleText()&&(b=e.getTextContent(),a.setTextContent(d+b),e.remove())))}deleteLine(a){this.isCollapsed()&&this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");this.removeText()}}function $b(a){return a instanceof pc}
|
|
100
|
+
function vc(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))}
|
|
101
|
+
function wc(a,b,c){var d=b;if(1===a.nodeType){let g=!1;var e=a.childNodes;var f=e.length;d===f&&(g=!0,d=f-1);e=Ea(e[d]);if(v(e))d=g?e.getTextContentSize():0;else{f=Ea(a);if(null===f)return null;if(E(f)){a=f.getChildAtIndex(d);if(b=E(a))b=a.getParent(),b=null===c||null===b||!b.canBeEmpty()||b!==c.getNode();b&&(c=g?a.getLastDescendant():a.getFirstDescendant(),null===c?(f=a,d=0):(a=c,f=a.getParentOrThrow()));v(a)?(e=a,f=null,d=g?e.getTextContentSize():0):a!==f&&g&&d++}else d=f.getIndexWithinParent(),
|
|
102
|
+
d=0===b&&x(f)&&Ea(a)===f?d:d+1,f=f.getParentOrThrow();if(E(f))return new X(f.__key,d,"element")}}else e=Ea(a);return v(e)?new X(e.__key,d,"text"):null}
|
|
103
|
+
function tc(a,b,c,d,e,f){if(null===a||null===c||!oa(e,a,c))return null;a=wc(a,b,J(f)?f.anchor:null);if(null===a)return null;c=wc(c,d,J(f)?f.focus:null);if(null===c)return null;if("text"===a.type&&"text"===c.type){d=a.getNode();const g=c.getNode(),h=d.getTextContentSize(),l=a.offset,k=c.offset;d===g&&l===k?0===b&&(d=d.getPreviousSibling(),v(d)&&!d.isInert()&&(b=d.getTextContentSize(),d=d.__key,a.key=d,c.key=d,a.offset=b,c.offset=b)):l===h&&(b=d.getNextSibling(),v(b)&&!b.isInert()&&(a.key=b.__key,a.offset=
|
|
104
|
+
0));e.isComposing()&&e._compositionKey!==a.key&&J(f)&&(e=f.anchor,f=f.focus,Y(a,e.key,e.offset,e.type),Y(c,f.key,f.offset,f.type))}return[a,c]}function xc(a,b,c,d,e,f){const g=B();a=new qc(new X(a,b,e),new X(c,d,f),0);a.dirty=!0;return g._selection=a}
|
|
105
|
+
function Yb(a){var b=a.getEditorState()._selection,c=window.getSelection();if($b(b))return b.clone();{var d=(d=window.event)&&d.type;d=!bc&&("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=tc(d,h,g,c,a,b),null===a)b=null;else{var [e,f]=a;b=new qc(e,f,J(b)?b.format:0)}else b=b.clone()}return b}
|
|
106
|
+
function K(){return B()._selection}function Ja(){return D()._editorState._selection}function yc(a){if(null!==a){if("range"===a.type)return new qc(new X(a.anchor.key,a.anchor.offset,a.anchor.type),new X(a.focus.key,a.focus.offset,a.focus.type),0);if("node"===a.type)return new pc(new Set(a.nodes));if("grid"===a.type)return new rc(a.gridKey,a.anchorCellKey,a.focusCellKey)}return null}
|
|
107
|
+
function $a(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"),zc(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"));zc(a)}}
|
|
108
|
+
function zc(a){var b=a.anchor,c=b.offset;const d=a.focus;var e=d.offset,f=b.getNode(),g=d.getNode();if(a.isCollapsed())E(f)&&(g=f.getChildrenSize(),g=(e=c>=g)?f.getChildAtIndex(g-1):f.getChildAtIndex(c),v(g)&&(c=0,e&&(c=g.getTextContentSize()),b.set(g.getKey(),c,"text"),d.set(g.getKey(),c,"text")));else{if(E(f)){const h=f.getChildrenSize();c=(a=c>=h)?f.getChildAtIndex(h-1):f.getChildAtIndex(c);v(c)&&(f=0,a&&(f=c.getTextContentSize()),b.set(c.getKey(),f,"text"))}E(g)&&(c=g.getChildrenSize(),e=(b=e>=
|
|
109
|
+
c)?g.getChildAtIndex(c-1):g.getChildAtIndex(e),v(e)&&(g=0,b&&(g=e.getTextContentSize()),d.set(e.getKey(),g,"text")))}}function Zb(a,b){b=b.getEditorState()._selection;a=a._selection;if(J(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))}}
|
|
110
|
+
function Za(a,b,c,d,e){let f=null,g=0,h=null;null!==d?(f=d.__key,v(d)?(g=d.getTextContentSize(),h="text"):E(d)&&(g=d.getChildrenSize(),h="element")):null!==e&&(f=e.__key,v(e)?h="text":E(e)&&(h="element"));null!==f&&null!==h?a.set(f,g,h):(g=b.getIndexWithinParent(),a.set(c.__key,g,"element"))}function Ac(a,b,c,d,e){"text"===a.type?(a.key=c,b||(a.offset+=e)):a.offset>d.getIndexWithinParent()&&--a.offset}
|
|
111
|
+
class Bc extends ab{constructor(a){super(a);this.__children=[];this.__indent=this.__format=0;this.__dir=null}getFormat(){return this.getLatest().__format}getIndent(){return this.getLatest().__indent}getChildren(){const a=this.getLatest().__children,b=[];for(let c=0;c<a.length;c++){const d=I(a[c]);null!==d&&b.push(d)}return b}getChildrenKeys(){return this.getLatest().__children}getChildrenSize(){return this.getLatest().__children.length}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const a=
|
|
112
|
+
D()._dirtyElements;return null!==a&&a.has(this.__key)}getAllTextNodes(a){const b=[],c=this.getLatest().__children;for(let e=0;e<c.length;e++){var d=I(c[e]);!v(d)||!a&&d.isInert()?E(d)&&(d=d.getAllTextNodes(a),b.push(...d)):b.push(d)}return b}getFirstDescendant(){let a=this.getFirstChild();for(;null!==a;){if(E(a)){const b=a.getFirstChild();if(null!==b){a=b;continue}}break}return a}getLastDescendant(){let a=this.getLastChild();for(;null!==a;){if(E(a)){const b=a.getLastChild();if(null!==b){a=b;continue}}break}return a}getDescendantByIndex(a){const b=
|
|
113
|
+
this.getChildren(),c=b.length;if(0===c)return this;if(a>=c)return a=b[c-1],E(a)&&a.getLastDescendant()||a;a=b[a];return E(a)&&a.getFirstDescendant()||a}getFirstChild(){const a=this.getLatest().__children;return 0===a.length?null:I(a[0])}getFirstChildOrThrow(){const a=this.getFirstChild();null===a&&q(15,this.__key);return a}getLastChild(){const a=this.getLatest().__children,b=a.length;return 0===b?null:I(a[b-1])}getChildAtIndex(a){a=this.getLatest().__children[a];return void 0===a?null:I(a)}getTextContent(a,
|
|
114
|
+
b){let c="";const d=this.getChildren(),e=d.length;for(let f=0;f<e;f++){const g=d[f];c+=g.getTextContent(a,b);E(g)&&f!==e-1&&!g.isInline()&&(c+="\n\n")}return c}getDirection(){return this.__dir}hasFormat(a){a=ea[a];return 0!==(this.getFormat()&a)}select(a,b){H();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,a,"element"),c.focus.set(d,b,"element"),c.dirty=!0;else return xc(d,a,d,b,"element","element");return c}selectStart(){const a=
|
|
115
|
+
this.getFirstDescendant();return E(a)||v(a)?a.select(0,0):null!==a?a.selectPrevious():this.select(0,0)}selectEnd(){const a=this.getLastDescendant();return E(a)||v(a)?a.select():null!==a?a.selectNext():this.select()}clear(){H();const a=this.getWritable();this.getChildren().forEach(b=>b.remove());return a}append(...a){H();const b=this.getWritable(),c=b.__key,d=b.__children,e=a.length;var f=this.getLastChild();null!==f&&y(f);for(f=0;f<e;f++){var g=a[f];g.__key===c&&q(49);g=g.getWritable();var h=g.getParent();
|
|
116
|
+
if(null!==h){h=h.getWritable().__children;const l=h.indexOf(g.__key);-1===l&&q(16);h.splice(l,1)}g.__parent=c;d.push(g.__key)}return b}setDirection(a){H();const b=this.getWritable();b.__dir=a;return b}setFormat(a){H();this.getWritable().__format=ea[a];return this}setIndent(a){H();this.getWritable().__indent=a;return this}splice(a,b,c){H();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&&q(49);var l=n.getParent();
|
|
117
|
+
if(null!==l){l=l.getWritable().__children;const p=l.indexOf(n.__key);-1===p&&q(16);F(m);l.splice(p,1)}n.__parent=e;h.push(n.__key)}(c=this.getChildAtIndex(a-1))&&y(c);(e=this.getChildAtIndex(a+b))&&y(e);a=f.splice(a,b,...h);if(b&&(b=K(),J(b))){const k=new Set(a),m=new Set(h);h=u=>{for(u=u.getNode();u;){const z=u.__key;if(k.has(z)&&!m.has(z))return!0;u=u.getParent()}return!1};const {anchor:n,focus:p}=b;h(n)&&Za(n,n.getNode(),this,c,e);h(p)&&Za(p,p.getNode(),this,c,e);h=a.length;for(b=0;b<h;b++)c=I(a[b]),
|
|
118
|
+
null!=c&&(c.getWritable().__parent=null);0!==f.length||this.canBeEmpty()||M(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}canMergeWith(){return!1}}function E(a){return a instanceof Bc}
|
|
119
|
+
class Cc extends Bc{static getType(){return"root"}static clone(){return new Cc}constructor(){super("root");this.__cachedText=null}getTopLevelElementOrThrow(){q(70)}getTextContent(a,b){const c=this.__cachedText;return!V&&0!==D()._dirtyType||null===c||a&&!1===b?super.getTextContent(a,b):c}remove(){q(10)}replace(){q(11)}insertBefore(){q(12)}insertAfter(){q(13)}updateDOM(){return!1}append(...a){for(let b=0;b<a.length;b++){const c=a[b];E(c)||x(c)||q(46)}return super.append(...a)}}
|
|
120
|
+
function M(a){return a instanceof Cc}function ac(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 Dc(){return new Xb(new Map([["root",new Cc]]))}
|
|
121
|
+
class Xb{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=V,e=U;T=this;V=!0;U=null;try{var b=a();break a}finally{T=c,V=d,U=e}b=void 0}return b}clone(a){a=new Xb(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,
|
|
122
|
+
type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type},type:"range"}:$b(a)?{nodes:Array.from(a._nodes),type:"node"}:sc(a)?{anchorCellKey:a.anchorCellKey,focusCellKey:a.focusCellKey,gridKey:a.gridKey,type:"grid"}:null}}}const Ec=Object.freeze({}),Kc=[["keydown",Fc],["compositionstart",Gc],["compositionend",Hc],["input",Ic],["click",Jc],["cut",Ec],["copy",Ec],["dragstart",Ec],["paste",Ec],["focus",Ec],["blur",Ec]];la?Kc.push(["beforeinput",Lc]):Kc.push(["drop",Ec]);
|
|
123
|
+
let Mc=!1,Nc=0;function Oc(a,b){a.update(()=>{if(b){var c=K();if(J(c)&&c.isCollapsed()){var d=c.anchor;"text"===d.type?(d=d.getNode(),c.format=d.getFormat()):"element"===d.type&&(c.format=0)}a.execCommand("selectionChange")}else Da(null)})}
|
|
124
|
+
function Jc(a,b){b.update(()=>{const c=K();if(J(c)){var d=c.anchor;"element"===d.type&&0===d.offset&&c.isCollapsed()&&1===Aa().getChildrenSize()&&d.getNode().getTopLevelElementOrThrow().isEmpty()&&(d=b.getEditorState()._selection,null!==d&&c.is(d)&&(window.getSelection().removeAllRanges(),c.dirty=!0))}b.execCommand("click",a)})}
|
|
125
|
+
function Lc(a,b){const c=a.inputType;"deleteCompositionText"!==c&&"insertCompositionText"!==c&&b.update(()=>{const d=K();if(J(d))if("deleteContentBackward"===c)G(null),a.preventDefault(),b.execCommand("deleteCharacter",!0);else{var e=a.data;if(!d.dirty&&d.isCollapsed()&&!M(d.anchor.getNode())&&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")):"\n\n"===
|
|
126
|
+
e?(a.preventDefault(),b.execCommand("insertParagraph")):null==e&&a.dataTransfer?(e=a.dataTransfer.getData("text/plain"),a.preventDefault(),d.insertRawText(e)):null!=e&&Ka(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":G(null);b.execCommand("insertText",a);break;case "insertLineBreak":G(null);b.execCommand("insertLineBreak");
|
|
127
|
+
break;case "insertParagraph":G(null);b.execCommand("insertParagraph");break;case "insertFromPaste":case "insertFromPasteAsQuotation":b.execCommand("paste",a);break;case "deleteByComposition":f===g&&!E(f)&&!E(g)&&t(f)&&t(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",
|
|
127
128
|
!1);break;case "deleteHardLineBackward":case "deleteSoftLineBackward":b.execCommand("deleteLine",!0);break;case "deleteContentForward":case "deleteHardLineForward":case "deleteSoftLineForward":b.execCommand("deleteLine",!1);break;case "formatStrikeThrough":b.execCommand("formatText","strikethrough");break;case "formatBold":b.execCommand("formatText","bold");break;case "formatItalic":b.execCommand("formatText","italic");break;case "formatUnderline":b.execCommand("formatText","underline");break;case "historyUndo":b.execCommand("undo");
|
|
128
|
-
break;case "historyRedo":b.execCommand("redo")}}})}function
|
|
129
|
-
function
|
|
130
|
-
function
|
|
131
|
-
a):(h=
|
|
132
|
-
(a.preventDefault(),b.execCommand("formatText","underline")):73===c&&(
|
|
133
|
-
a)}}function
|
|
134
|
-
function
|
|
135
|
-
class
|
|
136
|
-
function
|
|
137
|
-
function
|
|
138
|
-
class
|
|
139
|
-
(this.getLatest().__detail&2)}hasFormat(a){a=
|
|
140
|
-
c,this);a=a.theme.text;void 0!==a
|
|
141
|
-
l&&q(21))
|
|
142
|
-
a;return b}setStyle(a){
|
|
143
|
-
"string"===typeof d?(d=d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(
|
|
144
|
-
var b=this.getLatest(),c=b.getTextContent(),d=b.__key,e=
|
|
145
|
-
a[A],z=u.length;u=
|
|
146
|
-
a===this.getPreviousSibling();b||a===this.getNextSibling()||q(22);const c=this.__key,d=a.__key,e=this.__text,f=e.length;
|
|
147
|
-
function
|
|
148
|
-
class
|
|
149
|
-
this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function
|
|
150
|
-
function
|
|
151
|
-
function
|
|
152
|
-
class
|
|
153
|
-
new Set;this._dirtyLeaves=new Set;this._dirtyElements=new Map;this._normalizedNodes=new Set;this._updateTags=new Set;this._observer=null;this._key=""+
|
|
154
|
-
b);return()=>{f.delete(c)}}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._nodes.get(c);void 0===d&&q(57,a.name);const e=d.transforms;e.add(b);
|
|
155
|
-
this._rootElement;if(a!==b){var c=this._pendingEditorState||this._editorState;this._rootElement=a;
|
|
156
|
-
"text",c.whiteSpace="pre-wrap",c.overflowWrap="break-word",a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,
|
|
157
|
-
|
|
158
|
-
()=>{const c=
|
|
159
|
-
exports.$createLineBreakNode=
|
|
160
|
-
exports.$getRoot=
|
|
161
|
-
exports.$isTextNode=
|
|
162
|
-
exports.createDecoratorArray=
|
|
163
|
-
exports.createEditor=function(a){var b=a||{},c=b.namespace||
|
|
164
|
-
exports.isDecoratorArray=function(a){return a instanceof
|
|
129
|
+
break;case "historyRedo":b.execCommand("redo")}}})}function Ic(a,b){a.stopPropagation();b.update(()=>{var c=K();const d=a.data;null!=d&&J(c)&&Ka(c,d,!1)?b.execCommand("insertText",d):Ha(b,null);H();c=D();lc(c)})}function Gc(a,b){b.update(()=>{const c=K();if(J(c)&&!b.isComposing()){const d=c.anchor;G(d.key);Mc&&"element"!==d.type&&c.isCollapsed()||b.execCommand("insertText"," ")}})}
|
|
130
|
+
function Pc(a,b){b.update(()=>{var c=b._compositionKey;G(null);if(null!==c&&""===a.data){const d=I(c);c=ra(b.getElementByKey(c));null!==c&&v(d)&&Ia(d,c.nodeValue,null,null,!0)}else Ha(b,a)})}function Hc(a,b){ka?setTimeout(()=>{Pc(a,b)},0):Pc(a,b)}
|
|
131
|
+
function Fc(a,b){Mc="Unidentified"===a.key&&229===a.keyCode;if(!b.isComposing()){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(r&&e&&79===c)a.preventDefault(),b.execCommand("insertLineBreak",!0);else if(13!==c||d){var h=r?g||f?!1:8===c||72===c&&e:e||g||f?!1:8===c;h?8===c?b.execCommand("keyBackspace",a):b.execCommand("deleteCharacter",!0):27===c?b.execCommand("keyEscape",
|
|
132
|
+
a):(h=r?d||g||f?!1:46===c||68===c&&e:e||g||f?!1:46===c,h?46===c?b.execCommand("keyDelete",a):(a.preventDefault(),b.execCommand("deleteCharacter",!1)):8===c&&(r?g:e)?(a.preventDefault(),b.execCommand("deleteWord",!0)):46===c&&(r?g:e)?(a.preventDefault(),b.execCommand("deleteWord",!1)):r&&f&&8===c?(a.preventDefault(),b.execCommand("deleteLine",!0)):r&&f&&46===c?(a.preventDefault(),b.execCommand("deleteLine",!1)):66===c&&(r?f:e)?(a.preventDefault(),b.execCommand("formatText","bold")):85===c&&(r?f:e)?
|
|
133
|
+
(a.preventDefault(),b.execCommand("formatText","underline")):73===c&&(r?f:e)?(a.preventDefault(),b.execCommand("formatText","italic")):9!==c||g||e||f?90===c&&!d&&(r?f:e)?(a.preventDefault(),b.execCommand("undo")):(h=r?90===c&&f&&d:89===c&&e||90===c&&e&&d,h&&(a.preventDefault(),b.execCommand("redo"))):b.execCommand("keyTab",a))}else b.execCommand("keyEnter",a);else b.execCommand("keyArrowDown",a);else b.execCommand("keyArrowUp",a);else b.execCommand("keyArrowLeft",a);else b.execCommand("keyArrowRight",
|
|
134
|
+
a)}}function Sc(a){let b=a.__lexicalEventHandles;void 0===b&&(b=[],a.__lexicalEventHandles=b);return b}const Tc=new Map;function Uc(){var a=window.getSelection();a=qa(a.anchorNode);if(null!==a){var b=Fa(a);b=b[b.length-1];var c=b._key,d=Tc.get(c),e=d||b;e!==a&&Oc(e,!1);Oc(a,!0);a!==b?Tc.set(c,a):d&&Tc.delete(c)}}
|
|
135
|
+
function Vc(a,b){0===Nc&&a.ownerDocument.addEventListener("selectionchange",Uc);Nc++;a.__lexicalEditor=b;const c=Sc(a);for(let d=0;d<Kc.length;d++){const [e,f]=Kc[d],g="function"===typeof f?h=>{b.isReadOnly()||f(h,b)}:h=>{b.isReadOnly()||b.execCommand(e,h)};a.addEventListener(e,g);c.push(()=>{a.removeEventListener(e,g)})}}
|
|
136
|
+
class Wc extends ab{static getType(){return"linebreak"}static clone(a){return new Wc(a.__key)}constructor(a){super(a)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}static convertDOM(){return{br:()=>({conversion:Xc,priority:0})}}}function Xc(){return{node:uc()}}function uc(){return new Wc}function ua(a){return a instanceof Wc}function Yc(a,b){return b&1?"strong":b&2?"em":"span"}
|
|
137
|
+
function Zc(a,b,c,d,e){a=d.classList;d=Pa(e,"base");void 0!==d&&a.add(...d);d=Pa(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 da)h=da[l],d=Pa(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))}
|
|
138
|
+
function $c(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 e=a.length;let f=0,g=0;for(;f<c&&f<e&&b[f]===a[f];)f++;for(;g+f<c&&g+f<e&&b[c-g-1]===a[e-g-1];)g++;a=[f,c-f-g,a.slice(f,e-g)];const [h,l,k]=a;0!==l&&d.deleteData(h,l);d.insertData(h,k)}else d.nodeValue=a}
|
|
139
|
+
class ad extends ab{static getType(){return"text"}static clone(a){return new ad(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!==
|
|
140
|
+
(this.getLatest().__detail&2)}hasFormat(a){a=da[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 sa(c,a,b)}createDOM(a){var b=this.__format,c=b&16?"code":null;const d=Yc(this,b),e=document.createElement(null===c?d:c);let f=e;null!==c&&(f=document.createElement(d),e.appendChild(f));c=f;$c(this.__text,
|
|
141
|
+
c,this);a=a.theme.text;void 0!==a&&Zc(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=Yc(this,e);const k=Yc(this,f);if((null===g?l:g)!==(null===h?k:h))return!0;if(g===h&&l!==k)return e=b.firstChild,null==e&&q(20),a=g=document.createElement(k),$c(d,a,this),c=c.theme.text,void 0!==c&&Zc(k,0,f,a,c),b.replaceChild(g,e),!1;l=b;null!==h&&null!==g&&(l=b.firstChild,null==
|
|
142
|
+
l&&q(21));$c(d,l,this);c=c.theme.text;void 0!==c&&e!==f&&Zc(k,e,f,l,c);f=this.__style;a.__style!==f&&(b.style.cssText=f);return!1}static convertDOM(){return{"#text":()=>({conversion:bd,priority:0}),b:()=>({conversion:cd,priority:0}),em:()=>({conversion:dd,priority:0}),i:()=>({conversion:dd,priority:0}),span:()=>({conversion:ed,priority:0}),strong:()=>({conversion:dd,priority:0}),u:()=>({conversion:dd,priority:0})}}selectionTransform(){}setFormat(a){H();const b=this.getWritable();this.getWritable().__format=
|
|
143
|
+
a;return b}setStyle(a){H();const b=this.getWritable();this.getWritable().__style=a;return b}toggleFormat(a){a=da[a];return this.setFormat(this.getFormat()^a)}toggleDirectionless(){const a=this.getWritable();a.__detail^=1;return a}toggleUnmergeable(){const a=this.getWritable();a.__detail^=2;return a}setMode(a){a=ha[a];const b=this.getWritable();b.__mode=a;return b}setTextContent(a){H();const b=this.getWritable();b.__text=a;return b}select(a,b){H();const c=K();var d=this.getTextContent();const e=this.__key;
|
|
144
|
+
"string"===typeof d?(d=d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(J(c))d=D()._compositionKey,d!==c.anchor.key&&d!==c.focus.key||G(e),c.setTextNodeRange(this,a,this,b);else return xc(e,a,e,b,"text","text");return c}spliceText(a,b,c,d){H();const e=this.getWritable(),f=e.__text,g=c.length;let h=a;0>h&&(h=g+h,0>h&&(h=0));const l=K();d&&J(l)&&(a+=g,l.setTextNodeRange(e,a,e,a));b=f.slice(0,h)+c+f.slice(h+b);return e.setTextContent(b)}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...a){H();
|
|
145
|
+
var b=this.getLatest(),c=b.getTextContent(),d=b.__key,e=D()._compositionKey,f=new Set(a);a=[];var g=c.length,h="";for(var l=0;l<g;l++)""!==h&&f.has(l)&&(a.push(h),h=""),h+=c[l];""!==h&&a.push(h);f=a.length;if(0===f)return[];if(a[0]===c)return[b];var k=a[0];c=b.getParentOrThrow();l=c.__key;const m=b.getFormat(),n=b.getStyle(),p=b.__detail;g=!1;b.isSegmented()?(h=L(k),h.__parent=l,h.__format=m,h.__style=n,h.__detail=p,g=!0):(h=b.getWritable(),h.__text=k);b=K();h=[h];k=k.length;for(let A=1;A<f;A++){var u=
|
|
146
|
+
a[A],z=u.length;u=L(u).getWritable();u.__format=m;u.__style=n;u.__detail=p;const C=u.__key;z=k+z;if(J(b)){const w=b.anchor,P=b.focus;w.key===d&&"text"===w.type&&w.offset>k&&w.offset<=z&&(w.key=C,w.offset-=k,b.dirty=!0);P.key===d&&"text"===P.type&&P.offset>k&&P.offset<=z&&(P.key=C,P.offset-=k,b.dirty=!0)}e===d&&G(C);k=z;u.__parent=l;h.push(u)}F(this);e=c.getWritable().__children;d=e.indexOf(d);a=h.map(A=>A.__key);g?(e.splice(d,0,...a),this.remove()):e.splice(d,1,...a);J(b)&&$a(b,c,d,f-1);return h}mergeWithSibling(a){const b=
|
|
147
|
+
a===this.getPreviousSibling();b||a===this.getNextSibling()||q(22);const c=this.__key,d=a.__key,e=this.__text,f=e.length;D()._compositionKey===d&&G(c);const g=K();if(J(g)){const h=g.anchor,l=g.focus;null!==h&&h.key===d&&(Ac(h,b,c,a,f),g.dirty=!0);null!==l&&l.key===d&&(Ac(l,b,c,a,f),g.dirty=!0)}this.setTextContent(b?a.__text+e:e+a.__text);a.remove();return this.getLatest()}}function ed(a){const b="700"===a.style.fontWeight;return{forChild:c=>{v(c)&&b&&c.toggleFormat("bold")},node:null}}
|
|
148
|
+
function cd(a){const b="normal"===a.style.fontWeight;return{forChild:c=>{v(c)&&!b&&c.toggleFormat("bold")},node:null}}function bd(a){return{node:L(a.textContent)}}const fd={em:"italic",i:"italic",strong:"bold",u:"underline"};function dd(a){const b=fd[a.nodeName.toLowerCase()];return void 0===b?{node:null}:{forChild:c=>{v(c)&&c.toggleFormat(b)},node:null}}function L(a=""){return new ad(a)}function v(a){return a instanceof ad}
|
|
149
|
+
class gd extends Bc{static getType(){return"paragraph"}static clone(a){return new gd(a.__key)}constructor(a){super(a)}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 convertDOM(){return{p:()=>({conversion:hd,priority:0})}}insertNewAfter(){const a=oc(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=this.getChildren();if(0===a.length||v(a[0])&&""===a[0].getTextContent().trim()){if(null!==
|
|
150
|
+
this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function hd(){return{node:oc()}}function oc(){return new gd}
|
|
151
|
+
function Rb(a,b,c,d){const e=a._keyToDOMMap;e.clear();a._editorState=Dc();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="",e.set("root",c))}
|
|
152
|
+
function id(a){const b=new Map,c=new Set;a.forEach(d=>{d=d.klass.convertDOM;if(!c.has(d)){c.add(d);var e=d();null!==e&&Object.keys(e).forEach(f=>{let g=b.get(f);void 0===g&&(g=[],b.set(f,g));g.push(e[f])})}});return b}
|
|
153
|
+
class jd{constructor(a,b,c,d,e,f){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={command:[new Set,new Set,new Set,new Set,new Set],decorator:new Set,mutation:new Map,readonly:new Set,root:new Set,textcontent:new Set,update:new Set};this._config=d;this._nodes=c;this._decorators={};this._pendingDecorators=null;this._dirtyType=0;this._cloneNotNeeded=
|
|
154
|
+
new Set;this._dirtyLeaves=new Set;this._dirtyElements=new Map;this._normalizedNodes=new Set;this._updateTags=new Set;this._observer=null;this._key=""+ma++;this._onError=e;this._htmlConversions=f;this._readOnly=!1}isComposing(){return null!=this._compositionKey}addListener(a,b,c){const d=this._listeners[a];if("command"===a){void 0===c&&q(56);const f=d[c];f.add(b);return()=>{f.delete(b)}}if("mutation"===a){void 0===this._nodes.get(b.getType())&&q(57,b.name);const f=this._listeners.mutation;f.set(c,
|
|
155
|
+
b);return()=>{f.delete(c)}}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._nodes.get(c);void 0===d&&q(57,a.name);const e=d.transforms;e.add(b);Ba(this,c);return()=>{e.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}execCommand(a,b){return Vb(this,a,b)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}setRootElement(a){const b=
|
|
156
|
+
this._rootElement;if(a!==b){var c=this._pendingEditorState||this._editorState;this._rootElement=a;Rb(this,b,a,c);if(null!==b&&!this._config.disableEvents){0!==Nc&&(Nc--,0===Nc&&b.ownerDocument.removeEventListener("selectionchange",Uc));c=b.__lexicalEditor;if(null!=c){if(null!==c._parentEditor){var d=Fa(c);d=d[d.length-1]._key;Tc.get(d)===c&&Tc.delete(d)}else Tc.delete(c._key);b.__lexicalEditor=null}c=Sc(b);for(d=0;d<c.length;d++)c[d]();b.__lexicalEventHandles=[]}null!==a&&(c=a.style,c.userSelect=
|
|
157
|
+
"text",c.whiteSpace="pre-wrap",c.overflowWrap="break-word",a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,Sb(this),this._updateTags.add("history-merge"),W(this),this._config.disableEvents||Vc(a,this));Tb("root",this,!1,a,b)}}getElementByKey(a){return this._keyToDOMMap.get(a)||null}getEditorState(){return this._editorState}setEditorState(a,b){a.isEmpty()&&q(19);lc(this);const c=this._pendingEditorState,d=this._updateTags;b=void 0!==b?b.tag:null;null===c||c.isEmpty()||(null!=b&&d.add(b),
|
|
158
|
+
W(this));this._pendingEditorState=a;this._dirtyType=2;this._compositionKey=null;null!=b&&d.add(b);W(this)}parseEditorState(a){a=JSON.parse(a);var b=new Map;b=new Xb(b);const c={originalSelection:a._selection},d=V,e=U;T=b;V=!1;U=this;try{const f=new Map(a._nodeMap),g=f.get("root");mb(g,f,this,null,c)}finally{T=b,V=d,U=e}b._selection=yc(c.remappedSelection||c.originalSelection);return b}update(a,b){Ca(this,a,b)}focus(a){const b=this._rootElement;null!==b&&(b.setAttribute("autocapitalize","off"),Ca(this,
|
|
159
|
+
()=>{const c=K(),d=Aa();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();null!==a&&a.removeAllRanges()}isReadOnly(){return this._readOnly}setReadOnly(a){this._readOnly=a;Tb("readonly",this,!0,a)}}class kd extends Bc{constructor(a,b){super(b)}}class ld extends Bc{}class md extends Bc{}exports.$createGridSelection=function(){return new rc("root","root","root")};
|
|
160
|
+
exports.$createLineBreakNode=uc;exports.$createNodeFromParse=function(a,b){H();const c=D();return mb(a,b,c,null)};exports.$createNodeSelection=function(){return new pc(new Set)};exports.$createParagraphNode=oc;exports.$createRangeSelection=function(){const a=new X("root",0,"element"),b=new X("root",0,"element");return new qc(a,b,0)};exports.$createTextNode=L;exports.$getDecoratorNode=Sa;exports.$getNearestNodeFromDOMNode=xa;exports.$getNodeByKey=I;exports.$getPreviousSelection=Ja;
|
|
161
|
+
exports.$getRoot=Aa;exports.$getSelection=K;exports.$isDecoratorNode=x;exports.$isElementNode=E;exports.$isGridCellNode=function(a){return a instanceof kd};exports.$isGridNode=function(a){return a instanceof ld};exports.$isGridRowNode=function(a){return a instanceof md};exports.$isGridSelection=sc;exports.$isLeafNode=ta;exports.$isLineBreakNode=ua;exports.$isNodeSelection=$b;exports.$isParagraphNode=function(a){return a instanceof gd};exports.$isRangeSelection=J;exports.$isRootNode=M;
|
|
162
|
+
exports.$isTextNode=v;exports.$nodesOfType=function(a){var b=B();const c=b._readOnly,d=a.getType();b=Array.from(b._nodeMap.values());const e=b.length,f=[];for(let g=0;g<e;g++){const h=b[g];h instanceof a&&h.__type===d&&(c||h.isAttached())&&f.push(h)}return f};exports.$setCompositionKey=G;exports.$setSelection=Da;exports.DecoratorNode=jb;exports.ElementNode=Bc;exports.GridCellNode=kd;exports.GridNode=ld;exports.GridRowNode=md;exports.ParagraphNode=gd;exports.TextNode=ad;exports.VERSION="0.1.14";
|
|
163
|
+
exports.createDecoratorArray=ib;exports.createDecoratorEditor=eb;exports.createDecoratorMap=gb;
|
|
164
|
+
exports.createEditor=function(a){var b=a||{},c=b.namespace||Ga();const d=b.theme||{},e=b.context||{},f=b.parentEditor||null,g=b.disableEvents||!1,h=Dc();a=b.editorState;const l=[Cc,ad,Wc,gd,...(b.nodes||[])],k=b.onError;b=b.readOnly||!1;const m=new Map;for(let n=0;n<l.length;n++){const p=l[n],u=p.getType();m.set(u,{klass:p,transforms:new Set})}c=new jd(h,f,m,{context:e,disableEvents:g,namespace:c,theme:d},k,id(m),b);void 0!==a&&(c._pendingEditorState=a,c._dirtyType=2);return c};
|
|
165
|
+
exports.isDecoratorArray=function(a){return a instanceof hb};exports.isDecoratorEditor=function(a){return a instanceof db};exports.isDecoratorMap=function(a){return a instanceof fb};
|
|
@@ -72,7 +72,7 @@ class HashtagNode extends lexical.TextNode {
|
|
|
72
72
|
if (indexOfInvalidChar === 0) {
|
|
73
73
|
targetNode = $toggleHashtag(targetNode);
|
|
74
74
|
} else if (indexOfInvalidChar > 0) {
|
|
75
|
-
[targetNode] = targetNode.splitText(indexOfInvalidChar + 1);
|
|
75
|
+
[, targetNode] = targetNode.splitText(indexOfInvalidChar + 1);
|
|
76
76
|
targetNode = $toggleHashtag(targetNode);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
var c=require("lexical");function d(b,...a){a.forEach(f=>{null!=f&&"string"===typeof f&&b.classList.add(...f.split(" "))})}
|
|
8
8
|
class e extends c.TextNode{static getType(){return"hashtag"}static clone(b){return new e(b.__text,b.__key)}constructor(b,a){super(b,a)}createDOM(b){const a=super.createDOM(b);d(a,b.theme.hashtag);return a}setTextContent(b){let a=super.setTextContent(b);return null===a.getParent()||a.isComposing()?this:(b=b.indexOf("#"),-1===b||"#"===a.getTextContent()?a=g(a):0<b&&([a]=a.splitText(b),a=g(a)),c.$isTextNode(a)&&a.isAttached()&&(b=a.getTextContent().slice(1).search(/[\s.,\\\/#!$%\^&\*;:{}=\-`~()@]/),
|
|
9
|
-
0===b?a=g(a):0<b&&([a]=a.splitText(b+1),a=g(a))),a)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!0}}function g(b){var a=b.getTextContent();a=h(b)?c.$createTextNode(a):k(a);b.replace(a);return a}function k(b=""){return new e(b)}function h(b){return b instanceof e}exports.$createHashtagNode=k;exports.$isHashtagNode=h;exports.$toggleHashtag=g;exports.HashtagNode=e;
|
|
9
|
+
0===b?a=g(a):0<b&&([,a]=a.splitText(b+1),a=g(a))),a)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!0}}function g(b){var a=b.getTextContent();a=h(b)?c.$createTextNode(a):k(a);b.replace(a);return a}function k(b=""){return new e(b)}function h(b){return b instanceof e}exports.$createHashtagNode=k;exports.$isHashtagNode=h;exports.$toggleHashtag=g;exports.HashtagNode=e;
|