lexical 0.2.0 → 0.2.1
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 +1 -1
- package/Lexical.dev.js +63 -28
- package/Lexical.js.flow +1 -1
- package/Lexical.prod.js +150 -150
- package/README.md +3 -3
- package/package.json +2 -2
package/Lexical.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export var KEY_ARROW_RIGHT_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
|
31
31
|
export var KEY_ARROW_LEFT_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
32
32
|
export var KEY_ARROW_UP_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
33
33
|
export var KEY_ARROW_DOWN_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
34
|
-
export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
34
|
+
export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent | null>;
|
|
35
35
|
export var KEY_BACKSPACE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
36
36
|
export var KEY_ESCAPE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
37
37
|
export var KEY_DELETE_COMMAND: LexicalCommand<KeyboardEvent>;
|
package/Lexical.dev.js
CHANGED
|
@@ -104,9 +104,9 @@ const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.docume
|
|
|
104
104
|
const IS_APPLE = CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
105
105
|
const IS_FIREFOX = CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
|
|
106
106
|
const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
|
|
107
|
-
const IS_SAFARI = CAN_USE_DOM && /Version\/[\d\.]+.*Safari/.test(navigator.userAgent);
|
|
107
|
+
const IS_SAFARI = CAN_USE_DOM && /Version\/[\d\.]+.*Safari/.test(navigator.userAgent);
|
|
108
|
+
const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; // Keep these in case we need to use them in the future.
|
|
108
109
|
// export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
|
|
109
|
-
// export const IS_IOS: boolean = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
|
110
110
|
// export const IS_CHROME: boolean = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
|
|
111
111
|
// export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
|
|
112
112
|
|
|
@@ -422,6 +422,11 @@ function internalGetRoot(editorState) {
|
|
|
422
422
|
}
|
|
423
423
|
function $setSelection(selection) {
|
|
424
424
|
const editorState = getActiveEditorState();
|
|
425
|
+
|
|
426
|
+
if (selection !== null && Object.isFrozen(selection)) {
|
|
427
|
+
console.warn('$setSelection called on frozen selection object. Ensure selection is cloned before passing in.');
|
|
428
|
+
}
|
|
429
|
+
|
|
425
430
|
editorState._selection = selection;
|
|
426
431
|
}
|
|
427
432
|
function $flushMutations$1() {
|
|
@@ -533,7 +538,7 @@ function $updateTextNodeFromDOMContent(textNode, textContent, anchorOffset, focu
|
|
|
533
538
|
if (normalizedTextContent === '') {
|
|
534
539
|
$setCompositionKey(null);
|
|
535
540
|
|
|
536
|
-
if (!IS_SAFARI) {
|
|
541
|
+
if (!IS_SAFARI && !IS_IOS) {
|
|
537
542
|
// For composition (mainly Android), we have to remove the node on a later update
|
|
538
543
|
const editor = getActiveEditor();
|
|
539
544
|
setTimeout(() => {
|
|
@@ -2634,7 +2639,7 @@ function $flushMutations(editor, mutations, observer) {
|
|
|
2634
2639
|
targetDOM, targetNode);
|
|
2635
2640
|
}
|
|
2636
2641
|
} else if (type === 'childList') {
|
|
2637
|
-
shouldRevertSelection = true; // We attempt to "undo" any changes that have
|
|
2642
|
+
shouldRevertSelection = true; // We attempt to "undo" any changes that have occurred outside
|
|
2638
2643
|
// of Lexical. We want Lexical's editor state to be source of truth.
|
|
2639
2644
|
// To the user, these will look like no-ops.
|
|
2640
2645
|
|
|
@@ -3733,7 +3738,8 @@ class RangeSelection {
|
|
|
3733
3738
|
const startingNode = target;
|
|
3734
3739
|
siblings.push(...nextSiblings);
|
|
3735
3740
|
const firstNode = nodes[0];
|
|
3736
|
-
let didReplaceOrMerge = false;
|
|
3741
|
+
let didReplaceOrMerge = false;
|
|
3742
|
+
let lastNodeInserted = null; // Time to insert the nodes!
|
|
3737
3743
|
|
|
3738
3744
|
for (let i = 0; i < nodes.length; i++) {
|
|
3739
3745
|
const node = nodes[i];
|
|
@@ -3796,11 +3802,13 @@ class RangeSelection {
|
|
|
3796
3802
|
|
|
3797
3803
|
if ($isElementNode(target)) {
|
|
3798
3804
|
for (let s = 0; s < childrenLength; s++) {
|
|
3799
|
-
|
|
3805
|
+
lastNodeInserted = children[s];
|
|
3806
|
+
target.append(lastNodeInserted);
|
|
3800
3807
|
}
|
|
3801
3808
|
} else {
|
|
3802
3809
|
for (let s = childrenLength - 1; s >= 0; s--) {
|
|
3803
|
-
|
|
3810
|
+
lastNodeInserted = children[s];
|
|
3811
|
+
target.insertAfter(lastNodeInserted);
|
|
3804
3812
|
}
|
|
3805
3813
|
|
|
3806
3814
|
target = target.getParentOrThrow();
|
|
@@ -3833,6 +3841,8 @@ class RangeSelection {
|
|
|
3833
3841
|
didReplaceOrMerge = false;
|
|
3834
3842
|
|
|
3835
3843
|
if ($isElementNode(target)) {
|
|
3844
|
+
lastNodeInserted = node;
|
|
3845
|
+
|
|
3836
3846
|
if ($isDecoratorNode(node) && node.isTopLevel()) {
|
|
3837
3847
|
target = target.insertAfter(node);
|
|
3838
3848
|
} else if (!$isElementNode(node)) {
|
|
@@ -3865,6 +3875,7 @@ class RangeSelection {
|
|
|
3865
3875
|
}
|
|
3866
3876
|
}
|
|
3867
3877
|
} else if (!$isElementNode(node) || $isDecoratorNode(target) && target.isTopLevel()) {
|
|
3878
|
+
lastNodeInserted = node;
|
|
3868
3879
|
target = target.insertAfter(node);
|
|
3869
3880
|
} else {
|
|
3870
3881
|
target = node.getParentOrThrow(); // Re-try again with the target being the parent
|
|
@@ -3891,7 +3902,9 @@ class RangeSelection {
|
|
|
3891
3902
|
}
|
|
3892
3903
|
|
|
3893
3904
|
if ($isElementNode(target)) {
|
|
3894
|
-
|
|
3905
|
+
// If the last node to be inserted was a text node,
|
|
3906
|
+
// then we should attempt to move selection to that.
|
|
3907
|
+
const lastChild = $isTextNode(lastNodeInserted) ? lastNodeInserted : target.getLastDescendant();
|
|
3895
3908
|
|
|
3896
3909
|
if (!selectStart) {
|
|
3897
3910
|
// Handle moving selection to end for elements
|
|
@@ -6273,6 +6286,7 @@ class EditorState {
|
|
|
6273
6286
|
*
|
|
6274
6287
|
*/
|
|
6275
6288
|
const PASS_THROUGH_COMMAND = Object.freeze({});
|
|
6289
|
+
const ANDROID_COMPOSITION_LATENCY = 30;
|
|
6276
6290
|
const rootElementEvents = [// $FlowIgnore bad event inheritance
|
|
6277
6291
|
['keydown', onKeyDown], // $FlowIgnore bad event inheritance
|
|
6278
6292
|
['compositionstart', onCompositionStart], // $FlowIgnore bad event inheritance
|
|
@@ -6287,7 +6301,7 @@ if (CAN_USE_BEFORE_INPUT) {
|
|
|
6287
6301
|
rootElementEvents.push(['drop', PASS_THROUGH_COMMAND]);
|
|
6288
6302
|
}
|
|
6289
6303
|
|
|
6290
|
-
let
|
|
6304
|
+
let lastKeyDownTimeStamp = 0;
|
|
6291
6305
|
let rootElementsRegistered = 0;
|
|
6292
6306
|
|
|
6293
6307
|
function onSelectionChange(domSelection, editor, isActive) {
|
|
@@ -6398,7 +6412,7 @@ function onBeforeInput(event, editor) {
|
|
|
6398
6412
|
updateEditor(editor, () => {
|
|
6399
6413
|
node.select();
|
|
6400
6414
|
});
|
|
6401
|
-
},
|
|
6415
|
+
}, ANDROID_COMPOSITION_LATENCY);
|
|
6402
6416
|
}
|
|
6403
6417
|
}
|
|
6404
6418
|
}
|
|
@@ -6419,7 +6433,14 @@ function onBeforeInput(event, editor) {
|
|
|
6419
6433
|
// Used for Android
|
|
6420
6434
|
$setCompositionKey(null);
|
|
6421
6435
|
event.preventDefault();
|
|
6422
|
-
|
|
6436
|
+
lastKeyDownTimeStamp = 0;
|
|
6437
|
+
dispatchCommand(editor, DELETE_CHARACTER_COMMAND, true); // Fixes an Android bug where selection flickers when backspacing
|
|
6438
|
+
|
|
6439
|
+
setTimeout(() => {
|
|
6440
|
+
editor.update(() => {
|
|
6441
|
+
$setCompositionKey(null);
|
|
6442
|
+
});
|
|
6443
|
+
}, ANDROID_COMPOSITION_LATENCY);
|
|
6423
6444
|
return;
|
|
6424
6445
|
}
|
|
6425
6446
|
|
|
@@ -6599,7 +6620,7 @@ function onInput(event, editor) {
|
|
|
6599
6620
|
dispatchCommand(editor, INSERT_TEXT_COMMAND, data);
|
|
6600
6621
|
} else {
|
|
6601
6622
|
$updateSelectedTextFromDOM(editor, null);
|
|
6602
|
-
} // Also flush any other mutations that might have
|
|
6623
|
+
} // Also flush any other mutations that might have occurred
|
|
6603
6624
|
// since the change.
|
|
6604
6625
|
|
|
6605
6626
|
|
|
@@ -6615,7 +6636,9 @@ function onCompositionStart(event, editor) {
|
|
|
6615
6636
|
const anchor = selection.anchor;
|
|
6616
6637
|
$setCompositionKey(anchor.key);
|
|
6617
6638
|
|
|
6618
|
-
if (
|
|
6639
|
+
if ( // If it has been 30ms since the last keydown, then we should
|
|
6640
|
+
// apply the empty space heuristic.
|
|
6641
|
+
event.timeStamp < lastKeyDownTimeStamp + ANDROID_COMPOSITION_LATENCY || anchor.type === 'element' || !selection.isCollapsed() || selection.anchor.getNode().getFormat() !== selection.format) {
|
|
6619
6642
|
// We insert an empty space, ready for the composition
|
|
6620
6643
|
// to get inserted into the new node we create. If
|
|
6621
6644
|
// we don't do this, Safari will fail on us because
|
|
@@ -6629,30 +6652,41 @@ function onCompositionStart(event, editor) {
|
|
|
6629
6652
|
function onCompositionEnd(event, editor) {
|
|
6630
6653
|
updateEditor(editor, () => {
|
|
6631
6654
|
const compositionKey = editor._compositionKey;
|
|
6632
|
-
$setCompositionKey(null);
|
|
6633
|
-
|
|
6655
|
+
$setCompositionKey(null);
|
|
6656
|
+
const data = event.data; // Handle termination of composition.
|
|
6657
|
+
|
|
6658
|
+
if (compositionKey !== null && data != null) {
|
|
6659
|
+
// It can sometimes move to an adjacent DOM node when backspacing.
|
|
6660
|
+
// So check for the empty case.
|
|
6661
|
+
if (data === '') {
|
|
6662
|
+
const node = $getNodeByKey(compositionKey);
|
|
6663
|
+
const textNode = getDOMTextNode(editor.getElementByKey(compositionKey));
|
|
6664
|
+
|
|
6665
|
+
if (textNode !== null && $isTextNode(node)) {
|
|
6666
|
+
$updateTextNodeFromDOMContent(node, textNode.nodeValue, null, null, true);
|
|
6667
|
+
}
|
|
6634
6668
|
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6669
|
+
return;
|
|
6670
|
+
} else if (data[data.length - 1] === '\n') {
|
|
6671
|
+
const selection = $getSelection();
|
|
6638
6672
|
|
|
6639
|
-
|
|
6640
|
-
|
|
6673
|
+
if ($isRangeSelection(selection)) {
|
|
6674
|
+
// If the last character is a line break, we also need to insert
|
|
6675
|
+
// a line break.
|
|
6676
|
+
const focus = selection.focus;
|
|
6677
|
+
selection.anchor.set(focus.key, focus.offset, focus.type);
|
|
6678
|
+
dispatchCommand(editor, KEY_ENTER_COMMAND, null);
|
|
6679
|
+
return;
|
|
6680
|
+
}
|
|
6641
6681
|
}
|
|
6642
|
-
|
|
6643
|
-
return;
|
|
6644
6682
|
}
|
|
6645
6683
|
|
|
6646
6684
|
$updateSelectedTextFromDOM(editor, event);
|
|
6647
6685
|
});
|
|
6648
6686
|
}
|
|
6649
6687
|
|
|
6650
|
-
function updateAndroidSoftKeyFlagIfAny(event) {
|
|
6651
|
-
lastKeyWasMaybeAndroidSoftKey = event.key === 'Unidentified' && event.keyCode === 229;
|
|
6652
|
-
}
|
|
6653
|
-
|
|
6654
6688
|
function onKeyDown(event, editor) {
|
|
6655
|
-
|
|
6689
|
+
lastKeyDownTimeStamp = event.timeStamp;
|
|
6656
6690
|
|
|
6657
6691
|
if (editor.isComposing()) {
|
|
6658
6692
|
return;
|
|
@@ -6685,6 +6719,7 @@ function onKeyDown(event, editor) {
|
|
|
6685
6719
|
if (isBackspace(keyCode)) {
|
|
6686
6720
|
dispatchCommand(editor, KEY_BACKSPACE_COMMAND, event);
|
|
6687
6721
|
} else {
|
|
6722
|
+
event.preventDefault();
|
|
6688
6723
|
dispatchCommand(editor, DELETE_CHARACTER_COMMAND, true);
|
|
6689
6724
|
}
|
|
6690
6725
|
} else if (isEscape(keyCode)) {
|
|
@@ -8205,7 +8240,7 @@ class LexicalEditor {
|
|
|
8205
8240
|
*
|
|
8206
8241
|
*
|
|
8207
8242
|
*/
|
|
8208
|
-
const VERSION = '0.2.
|
|
8243
|
+
const VERSION = '0.2.1';
|
|
8209
8244
|
|
|
8210
8245
|
/**
|
|
8211
8246
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
package/Lexical.js.flow
CHANGED
|
@@ -30,7 +30,7 @@ declare export var KEY_ARROW_RIGHT_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
|
30
30
|
declare export var KEY_ARROW_LEFT_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
31
31
|
declare export var KEY_ARROW_UP_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
32
32
|
declare export var KEY_ARROW_DOWN_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
33
|
-
declare export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
33
|
+
declare export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent | null>;
|
|
34
34
|
declare export var KEY_BACKSPACE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
35
35
|
declare export var KEY_ESCAPE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
36
36
|
declare export var KEY_DELETE_COMMAND: LexicalCommand<KeyboardEvent>;
|
package/Lexical.prod.js
CHANGED
|
@@ -6,161 +6,161 @@
|
|
|
6
6
|
*/
|
|
7
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
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]"),da=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]"),ea={bold:1,code:16,italic:2,strikethrough:4,subscript:32,superscript:64,underline:8},fa={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),
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
function
|
|
15
|
-
function
|
|
16
|
-
function
|
|
17
|
-
function
|
|
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,na=ia&&/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),oa=ia&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&
|
|
10
|
+
!window.MSStream;let pa=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 v(a){return a.isToken()||a.isInert()}function ua(a){for(;null!=a;){if(3===a.nodeType)return a;a=a.firstChild}return null}function va(a,b,c){b=ea[b];return a&b&&(null===c||0===(c&b))?a^b:null===c||c&b?a|b:a}function wa(a){return w(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&&q(16);Aa(a);b.splice(c,1)}}
|
|
12
|
+
function Ba(a){99<Ca&&q(26);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;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}function Ea(a){const b=Object.assign({},a._decorators);return a._pendingDecorators=b}
|
|
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?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){a=window.getSelection();if(null!==a){var c=a.anchorNode,{anchorOffset:d,focusOffset:f}=a;if(null!==c&&3===c.nodeType&&(a=sa(c),w(a))){c=c.nodeValue;const e=null!==b&&b.data;if("\u200b"===c&&e){const g=e.length;c=e;f=d=g}Ma(a,c,d,f,null!==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),na||oa)e.remove();else{const h=B();setTimeout(()=>{h.update(()=>{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,d),e.isSegmented()&&
|
|
18
18
|
(c=e.getTextContent(),c=L(c),e.replace(c),e=c)),e.setTextContent(a))}}
|
|
19
|
-
function
|
|
20
|
-
b&&(!e.canInsertTextBefore()||!c.canInsertTextBefore()||d),b=a||e):b=!1);return b}function
|
|
21
|
-
function
|
|
22
|
-
function
|
|
23
|
-
function
|
|
24
|
-
function
|
|
25
|
-
function
|
|
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,l=B().getElementByKey(h);(b=h!==f.key||!w(e)||d.offset!==f.offset&&!e.isComposing()||(c||e.isDirty())&&1<b.length||null!==l&&!e.isComposing()&&g!==ua(l)||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&&q(66,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
|
+
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 Wa(){var a=window.event;a=a&&a.inputType;return"insertFromPaste"===a||"insertFromPasteAsQuotation"===a}function Xa(a,b,c,d,f){a=a.__children;const e=a.length;for(let g=0;g<e;g++){const h=a[g],l=d.get(h);void 0!==l&&l.__parent===b&&(C(l)&&Xa(l,h,c,d,f),c.has(h)||f.delete(h),d.delete(h))}}
|
|
23
|
+
function Ya(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)&&Xa(c,f,a,b,d),a.has(f)||d.delete(f),b.delete(f))}function Za(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 $a(a,b){const c=a.mergeWithSibling(b),d=B()._normalizedNodes;d.add(a.__key);d.add(b.__key);return c}function ab(a){if(""===a.__text&&a.isSimpleText()&&!a.isUnmergeable())a.remove();else{for(var b;null!==(b=a.getPreviousSibling())&&w(b)&&b.isSimpleText()&&!b.isUnmergeable();)if(""===b.__text)b.remove();else{Za(b,a)&&(a=$a(b,a));break}for(var c;null!==(c=a.getNextSibling())&&w(c)&&c.isSimpleText()&&!c.isUnmergeable();)if(""===c.__text)c.remove();else{Za(a,c)&&$a(a,c);break}}}
|
|
25
|
+
function bb(a,b,c,d,f={originalSelection:null}){var e=a.__type,g=c._nodes.get(e);void 0===g&&q(24,e);for(var h in a)if(e=a[h],null!=e&&"object"===typeof e&&(e=e.editorState,null!=e)){var l=cb();l._nodes=c._nodes;l._parentEditor=c._parentEditor;l._pendingEditorState=db(e,l);a[h]=l}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(l=0;l<d.length;l++){var k=b.get(d[l]);void 0!==k&&(k=bb(k,b,c,e,f).__key,h.__children.push(k))}h.__indent=
|
|
26
26
|
a.__indent;h.__format=a.__format;h.__dir=a.__dir}else w(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.anchorCellKey,l=b.focusCellKey,null!=a||c!==g&&c!==d&&c!==l||(f.remappedSelection=a={...b,type:"grid"}),null!=a&&"grid"===a.type&&(c===g&&(a.gridKey=e),d===g&&(a.anchorCellKey=e),l===g&&(a.focusCellKey=e))));return h}let N="",O="",P="",
|
|
28
|
-
function
|
|
29
|
-
function
|
|
30
|
-
function
|
|
31
|
-
w(d)&&(d.isDirectionless()||(O+=e),d.isInert()&&(a=f.style,a.pointerEvents="none",a.userSelect="none",f.contentEditable="false",a.setProperty("-webkit-user-select","none"))),N+=e,P+=e;null!==b&&(null!=c?b.insertBefore(f,c):(c=b.__lexicalLineBreak,null!=c?b.insertBefore(f,c):b.appendChild(f)));
|
|
32
|
-
function
|
|
33
|
-
function
|
|
27
|
+
a={nodes:[...b],type:"node"}),"node"===a.type&&a.nodes.splice(g,1,e))):"grid"===b.type&&(c=b.gridKey,d=b.anchorCellKey,l=b.focusCellKey,null!=a||c!==g&&c!==d&&c!==l||(f.remappedSelection=a={...b,type:"grid"}),null!=a&&"grid"===a.type&&(c===g&&(a.gridKey=e),d===g&&(a.anchorCellKey=e),l===g&&(a.focusCellKey=e))));return h}let N="",O="",P="",eb,Q,fb,gb=!1,hb=!1,ib,jb=null,kb,lb,mb,nb,ob,pb;
|
|
28
|
+
function qb(a,b){const c=mb.get(a);if(null!==b){const d=rb(a);b.removeChild(d)}nb.has(a)||Q._keyToDOMMap.delete(a);C(c)&&(a=c.__children,sb(a,0,a.length-1,null));void 0!==c&&Qa(pb,fb,ib,c,"destroyed")}function sb(a,b,c,d){for(;b<=c;++b){const f=a[b];void 0!==f&&qb(f,d)}}function tb(a,b){a.setProperty("text-align",b)}function ub(a,b){a.style.setProperty("padding-inline-start",0===b?"":40*b+"px")}
|
|
29
|
+
function vb(a,b){a=a.style;0===b?tb(a,""):1===b?tb(a,"left"):2===b?tb(a,"center"):3===b?tb(a,"right"):4===b&&tb(a,"justify")}
|
|
30
|
+
function wb(a,b,c){const d=nb.get(a);void 0===d&&q(42);const f=d.createDOM(eb,Q);var e=Q._keyToDOMMap;f["__lexicalKey_"+Q._key]=a;e.set(a,f);w(d)?f.setAttribute("data-lexical-text","true"):u(d)&&f.setAttribute("data-lexical-decorator","true");if(C(d)){a=d.__indent;0!==a&&ub(f,a);a=d.__children;var g=a.length;if(0!==g){e=a;--g;const h=O;O="";xb(e,0,g,f,null);yb(d,f);O=h}e=d.__format;0!==e&&vb(f,e);zb(null,a,f)}else e=d.getTextContent(),u(d)?(g=d.decorate(Q),null!==g&&Ab(a,g),f.contentEditable="false"):
|
|
31
|
+
w(d)&&(d.isDirectionless()||(O+=e),d.isInert()&&(a=f.style,a.pointerEvents="none",a.userSelect="none",f.contentEditable="false",a.setProperty("-webkit-user-select","none"))),N+=e,P+=e;null!==b&&(null!=c?b.insertBefore(f,c):(c=b.__lexicalLineBreak,null!=c?b.insertBefore(f,c):b.appendChild(f)));Qa(pb,fb,ib,d,"created");return f}function xb(a,b,c,d,f){const e=N;for(N="";b<=c;++b)wb(a[b],d,f);d.__lexicalTextContent=N;N=e+N}function Bb(a,b){a=b.get(a[a.length-1]);return ya(a)||u(a)}
|
|
32
|
+
function zb(a,b,c){a=null!==a&&(0===a.length||Bb(a,mb));b=null!==b&&(0===b.length||Bb(b,nb));a?b||(b=c.__lexicalLineBreak,null!=b&&c.removeChild(b),c.__lexicalLineBreak=null):b&&(b=document.createElement("br"),c.__lexicalLineBreak=b,c.appendChild(b))}
|
|
33
|
+
function yb(a,b){var c=b.__lexicalDir;if(b.__lexicalDirTextContent!==O||c!==jb){const e=""===O;if(e)var d=jb;else d=O,d=aa.test(d)?"rtl":da.test(d)?"ltr":null;if(d!==c){const g=b.classList,h=eb.theme;var f=null!==c?h[c]:void 0;let l=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!==l&&("string"===typeof l&&(c=l.split(" "),l=h[d]=c),g.add(...l)),b.dir=d);hb||(a.getWritable().__dir=d)}jb=d;b.__lexicalDirTextContent=
|
|
34
34
|
O;b.__lexicalDir=d}}
|
|
35
|
-
function
|
|
36
|
-
a=d.__format,a!==c.__format&&
|
|
37
|
-
e).nextSibling,E++,k++;else{void 0===m&&(m=new Set(g));void 0===
|
|
38
|
-
(O+=c),N+=c,P+=c;!
|
|
39
|
-
function
|
|
40
|
-
function
|
|
41
|
-
g&&void 0!==g&&g.__key!==f&&g.isAttached()&&
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
x=W;"text"===y.type&&(f=
|
|
45
|
-
ba||null!==Ua&&ba.contains(Ua)||ba.focus({preventScroll:!0})}else null!==f&&
|
|
46
|
-
a._decorators;k=a._pendingDecorators||g;m=b._nodeMap;for(var S in k)m.has(S)||(k===g&&(k=
|
|
47
|
-
if(0!==b.length){const [
|
|
48
|
-
function V(a,b,c){if(!1===a._updating||T!==a){let e=!1;a.update(()=>{e=V(a,b,c)});return e}const d=
|
|
49
|
-
function
|
|
50
|
-
(e._flushSync=!0);const
|
|
51
|
-
a._pendingEditorState=null))}function I(a,b,c){a._updating?a._updates.push([b,c]):
|
|
52
|
-
function
|
|
53
|
-
null==x||null!==E||"BR"===y.nodeName&&
|
|
54
|
-
f=c.takeRecords();if(0<f.length){for(e=0;e<f.length;e++)for(k=f[e],g=k.addedNodes,k=k.target,
|
|
55
|
-
function
|
|
56
|
-
class
|
|
57
|
-
c;U||(
|
|
58
|
-
function
|
|
59
|
-
class
|
|
60
|
-
a&&b.push(a);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
|
|
61
|
-
class
|
|
62
|
-
H(this.anchorCellKey);a||q(74);var b=a.getIndexWithinParent();a=a.getParentOrThrow().getIndexWithinParent();var c=H(this.focusCellKey);c||q(75);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(){const a=new Set,{fromX:b,fromY:c,toX:d,toY:f}=this.getShape();var e=H(this.gridKey);
|
|
63
|
-
for(let l=c;l<=f;l++){var g=e[l];a.add(g);
|
|
64
|
-
class
|
|
65
|
-
b,c,d){Y(this.anchor,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,f=this.focus;const e=d.isBefore(f);d=d.getCharacterOffset();f=f.getCharacterOffset();let g="",h=!0;for(let l=0;l<a.length;l++){const k=a[l];if(
|
|
66
|
-
k===c&&(m=e?m.slice(0,f):m.slice(0,d));g+=m}else!
|
|
67
|
-
a,null);this.dirty=!0}hasFormat(a){return 0!==(this.format&ea[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(
|
|
68
|
-
b=e[0];w(b)||q(6);d=b.getTextContent().length;var k=b.getParentOrThrow();if(!this.isCollapsed()||c!==d||!b.isSegmented()&&!b.isToken()&&b.canInsertTextAfter()&&k.canInsertTextAfter())if(!this.isCollapsed()||0!==c||!b.isSegmented()&&!b.isToken()&&b.canInsertTextBefore()&&k.canInsertTextBefore())b.isSegmented()&&c!==d&&(k=L(b.getTextContent()),b.replace(k),b=k);else{m=b.getPreviousSibling();if(!w(m)||
|
|
69
|
-
b=m;if(""!==a){this.insertText(a);return}}else{var m=b.getNextSibling();if(!w(m)||
|
|
70
|
-
a.length);return}b=b.spliceText(c,l-c,a,!0);""===b.getTextContent()?b.remove():b.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=a.length)}else{k=e[g-1];f=new Set([...b.getParentKeys(),...k.getParentKeys()]);var
|
|
71
|
-
l,""),f.add(k.__key)):k.remove():f.add(k.__key);h=m.getChildren();l=new Set(e);const n
|
|
72
|
-
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),
|
|
73
|
-
d.getTextContentSize()){const
|
|
35
|
+
function Cb(a,b){var c=mb.get(a),d=nb.get(a);void 0!==c&&void 0!==d||q(43);var f=gb||lb.has(a)||kb.has(a);const e=Db(Q,a);if(c===d&&!f)return C(c)?(d=e.__lexicalTextContent,void 0!==d&&(N+=d,P+=d),d=e.__lexicalDirTextContent,void 0!==d&&(O+=d)):(d=c.getTextContent(),w(c)&&!c.isDirectionless()&&(O+=d),P+=d,N+=d),e;c!==d&&f&&Qa(pb,fb,ib,d,"updated");if(d.updateDOM(c,e,eb))return d=wb(a,null,null),null===b&&q(44),b.replaceChild(d,e),qb(a,null),d;if(C(c)&&C(d)){if(a=d.__indent,a!==c.__indent&&ub(e,a),
|
|
36
|
+
a=d.__format,a!==c.__format&&vb(e,a),a=c.__children,c=d.__children,a!==c||f){var g=a,h=c;f=d;b=O;O="";const p=N;N="";var l=g.length,k=h.length;if(1===l&&1===k){var m=g[0];h=h[0];if(m===h)Cb(m,e);else{var n=rb(m);h=wb(h,null,null);e.replaceChild(h,n);qb(m,null)}}else if(0===l)0!==k&&xb(h,0,k-1,e,null);else if(0===k)0!==l&&(m=null==e.__lexicalLineBreak,sb(g,0,l-1,m?null:e),m&&(e.textContent=""));else{const A=l-1;l=k-1;let y=e.firstChild,E=0;for(k=0;E<=A&&k<=l;){var t=g[E];const x=h[k];if(t===x)y=Cb(x,
|
|
37
|
+
e).nextSibling,E++,k++;else{void 0===m&&(m=new Set(g));void 0===n&&(n=new Set(h));const G=n.has(t),W=m.has(x);G?(W?(t=Db(Q,x),t===y?y=Cb(x,e).nextSibling:(null!=y?e.insertBefore(t,y):e.appendChild(t),Cb(x,e)),E++):wb(x,e,y),k++):(y=rb(t).nextSibling,qb(t,e),E++)}}m=E>A;n=k>l;m&&!n?(m=h[l+1],m=void 0===m?null:Q.getElementByKey(m),xb(h,k,l,e,m)):n&&!m&&sb(g,E,A,e)}e.__lexicalTextContent=N;N=p+N;yb(f,e);O=b;M(d)||zb(a,c,e)}}else c=d.getTextContent(),u(d)?(f=d.decorate(Q),null!==f&&Ab(a,f)):w(d)&&!d.isDirectionless()&&
|
|
38
|
+
(O+=c),N+=c,P+=c;!hb&&M(d)&&d.__cachedText!==P&&(d=d.getWritable(),d.__cachedText=P);return e}function Ab(a,b){let c=Q._pendingDecorators;const d=Q._decorators;if(null===c){if(d[a]===b)return;c=Ea(Q)}c[a]=b}function rb(a){a=ob.get(a);void 0===a&&q(45);return a}function Db(a,b){a=a._keyToDOMMap.get(b);void 0===a&&q(45);return a}let R=null,T=null,U=!1,Eb=!1,Ca=0;function F(){U&&q(25)}function z(){null===R&&q(27);return R}function B(){null===T&&q(28);return T}
|
|
39
|
+
function Fb(a,b,c){var d=b.__type;const f=a._nodes.get(d);void 0===f&&q(23,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 Gb(a,b){b=b._dirtyLeaves;a=a._nodeMap;for(const c of b)b=a.get(c),w(b)&&b.isSimpleText()&&!b.isUnmergeable()&&ab(b)}
|
|
40
|
+
function Hb(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 l=d,k=l.size;0<h||0<k;){if(0<h){b._dirtyLeaves=new Set;for(const m of g)g=a.get(m),w(g)&&g.isSimpleText()&&!g.isUnmergeable()&&ab(g),void 0!==g&&void 0!==g&&g.__key!==f&&g.isAttached()&&Fb(b,g,e),c.add(m);g=b._dirtyLeaves;h=g.size;if(0<h){Ca++;continue}}b._dirtyLeaves=new Set;b._dirtyElements=new Map;for(const m of l)l=m[0],k=m[1],"root"!==l&&k&&(g=a.get(l),void 0!==
|
|
41
|
+
g&&void 0!==g&&g.__key!==f&&g.isAttached()&&Fb(b,g,e),d.set(l,k));g=b._dirtyLeaves;h=g.size;l=b._dirtyElements;k=l.size;Ca++}b._dirtyLeaves=c;b._dirtyElements=d}function db(a,b){var c=new Map;c=new Ib(c);const d={originalSelection:a._selection},f=R,e=U,g=T;R=c;U=!1;T=b;try{const h=new Map(a._nodeMap),l=h.get("root");bb(l,h,b,null,d)}finally{R=f,U=e,T=g}c._selection=Jb(d.remappedSelection||d.originalSelection);return c}
|
|
42
|
+
function Kb(a){var b=a._pendingEditorState,c=a._rootElement;if(null!==c&&null!==b){var d=a._editorState,f=d._selection,e=b._selection,g=0!==a._dirtyType;a._pendingEditorState=null;a._editorState=b;var h=R,l=U,k=T,m=a._updating;T=a;R=b;U=!1;a._updating=!0;try{var n=a._observer;let ma=null;if(g&&null!==n){var t=a._dirtyType,p=a._dirtyElements,A=a._dirtyLeaves;n.disconnect();try{O=P=N="";gb=2===t;jb=null;Q=a;eb=a._config;fb=a._nodes;ib=Q._listeners.mutation;kb=p;lb=A;mb=d._nodeMap;nb=b._nodeMap;hb=b._readOnly;
|
|
43
|
+
ob=new Map(a._keyToDOMMap);const xa=new Map;pb=xa;Cb("root",null);pb=ob=eb=nb=mb=lb=kb=fb=Q=void 0;ma=xa}finally{n.observe(c,{characterData:!0,childList:!0,subtree:!0})}}const Ta=window.getSelection();if(null!==Ta&&(g||null===e||e.dirty)){n=Ta;const xa=n.anchorNode,mc=n.focusNode,td=n.anchorOffset,ud=n.focusOffset,Ua=document.activeElement,ba=a._rootElement;if(!a._updateTags.has("collaboration")||Ua===ba)if(J(e)){var y=e.anchor,E=e.focus,x=E.key,G=Db(a,y.key),W=Db(a,x),nc=y.offset,oc=E.offset;f=G;
|
|
44
|
+
x=W;"text"===y.type&&(f=ua(G));"text"===E.type&&(x=ua(W));if(null!==f&&null!==x)if(td!==nc||ud!==oc||xa!==f||mc!==x||"Range"===n.type&&e.isCollapsed())try{if(n.setBaseAndExtent(f,nc,x,oc),e.isCollapsed()&&ba===Ua){const ca=3===f.nodeType?f.parentNode:f;if(null!==ca){const Va=ca.getBoundingClientRect();if(Va.bottom>window.innerHeight)ca.scrollIntoView(!1);else if(0>Va.top)ca.scrollIntoView();else if(ba){const pc=ba.getBoundingClientRect();Va.bottom>pc.bottom?ca.scrollIntoView(!1):Va.top<pc.top&&ca.scrollIntoView()}a._updateTags.add("scroll-into-view")}}}catch(ca){}else null===
|
|
45
|
+
ba||null!==Ua&&ba.contains(Ua)||ba.focus({preventScroll:!0})}else null!==f&&ra(a,xa,mc)&&n.removeAllRanges()}var qc=ma;null!==qc&&Lb(a,d,b,qc)}catch(ma){a._onError(ma);Eb||(Mb(a,null,c,b),Nb(a),a._dirtyType=2,Eb=!0,Kb(a),Eb=!1);return}finally{a._updating=m,R=h,U=l,T=k}b._readOnly=!0;c=a._dirtyLeaves;e=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=
|
|
46
|
+
a._decorators;k=a._pendingDecorators||g;m=b._nodeMap;for(var S in k)m.has(S)||(k===g&&(k=Ea(a)),delete k[S]);S=a._pendingDecorators;null!==S&&(a._decorators=S,a._pendingDecorators=null,Ob("decorator",a,!0,S));S=Fa(d);g=Fa(b);S!==g&&Ob("textcontent",a,!0,g);Ob("update",a,!0,{dirtyElements:e,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(S=0;S<b.length;S++)b[S]()}finally{a._updating=d}}b=a._updates;
|
|
47
|
+
if(0!==b.length){const [ma,Ta]=b.shift();Pb(a,ma,Ta)}}}function Lb(a,b,c,d){a._listeners.mutation.forEach((f,e)=>{f=d.get(f);void 0!==f&&e(f)})}function Ob(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}}
|
|
48
|
+
function V(a,b,c){if(!1===a._updating||T!==a){let e=!1;a.update(()=>{e=V(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}function Qb(a){const b=a._updates;let c=!1;for(;0!==b.length;){const [d,f]=b.shift();let e,g;void 0!==f&&(e=f.onUpdate,g=f.tag,f.skipTransforms&&(c=!0),e&&a._deferred.push(e),g&&a._updateTags.add(g));d()}return c}
|
|
49
|
+
function Pb(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 Ib(new Map(c._nodeMap)),g=!0);const h=R,l=U,k=T,m=a._updating;R=e;U=!1;a._updating=!0;T=a;try{g&&(e._selection=Rb(a));const n=a._compositionKey;b();f=Qb(a);Sb(e,a);0!==a._dirtyType&&(f?Gb(e,a):Hb(e,a),Qb(a),Ya(c,e,a._dirtyLeaves,a._dirtyElements));n!==a._compositionKey&&
|
|
50
|
+
(e._flushSync=!0);const t=e._selection;if(J(t)){const p=e._nodeMap,A=t.focus.key;void 0!==p.get(t.anchor.key)&&void 0!==p.get(A)||q(30)}else Tb(t)&&0===t._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();Kb(a);return}finally{R=h,U=l,T=k,a._updating=m,Ca=0}0!==a._dirtyType||Ub(e,a)?e._flushSync?(e._flushSync=!1,Kb(a)):g&&qa(()=>{Kb(a)}):(e._flushSync=!1,g&&(d.clear(),a._deferred=[],
|
|
51
|
+
a._pendingEditorState=null))}function I(a,b,c){a._updating?a._updates.push([b,c]):Pb(a,b,c)}let Vb=!1,Wb=0;function Xb(a){Wb=a.timeStamp}function Yb(a,b,c){return b.__lexicalLineBreak===a||void 0!==a["__lexicalKey_"+c._key]}function Zb(a){return a.getEditorState().read(()=>{const b=K();return null!==b?b.clone():null})}
|
|
52
|
+
function $b(a,b,c){Vb=!0;const d=100<performance.now()-Wb;try{I(a,()=>{var f=new Map,e=a.getRootElement(),g=a._editorState;let h=!1,l="";for(var k=0;k<b.length;k++){var m=b[k],n=m.type,t=m.target,p=sa(t,g);if(!u(p))if("characterData"===n){if(d&&3===t.nodeType&&w(p)&&p.isAttached()){m=window.getSelection();var A=n=null;null!==m&&m.anchorNode===t&&(n=m.anchorOffset,A=m.focusOffset);Ma(p,t.nodeValue,n,A,!1)}}else if("childList"===n){h=!0;n=m.addedNodes;for(A=0;A<n.length;A++){var y=n[A],E=Da(y),x=y.parentNode;
|
|
53
|
+
null==x||null!==E||"BR"===y.nodeName&&Yb(y,x,a)||(ka&&(E=y.innerText||y.nodeValue)&&(l+=E),x.removeChild(y))}m=m.removedNodes;n=m.length;if(0<n){A=0;for(y=0;y<n;y++)x=m[y],"BR"===x.nodeName&&Yb(x,t,a)&&(t.appendChild(x),A++);n!==A&&(t===e&&(p=g._nodeMap.get("root")),f.set(t,p))}}}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++)k=a.getElementByKey(f[g]),null!==k&&(null==e?(G.appendChild(k),e=k):e!==k&&G.replaceChild(k,e),e=e.nextSibling);else w(W)&&W.markDirty();
|
|
54
|
+
f=c.takeRecords();if(0<f.length){for(e=0;e<f.length;e++)for(k=f[e],g=k.addedNodes,k=k.target,p=0;p<g.length;p++)t=g[p],m=t.parentNode,null==m||"BR"!==t.nodeName||Yb(t,k,a)||m.removeChild(t);c.takeRecords()}f=K()||Zb(a);null!==f&&(h&&(f.dirty=!0,Ia(f)),ka&&Wa()&&f.insertRawText(l))})}finally{Vb=!1}}function ac(a){const b=a._observer;if(null!==b){const c=b.takeRecords();$b(a,c,b)}}
|
|
55
|
+
function Nb(a){0===Wb&&window.addEventListener("textInput",Xb,!0);a._observer=new MutationObserver((b,c)=>{$b(a,b,c)})}
|
|
56
|
+
class bc{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;C(b)&&(b=b.getDescendantByIndex(d));C(c)&&(c=c.getDescendantByIndex(a));return b===c?d<a:b.isBefore(c)}getCharacterOffset(){return"text"===this.type?this.offset:0}getNode(){const a=H(this.key);null===a&&q(5);return a}set(a,b,c){const d=K(),f=this.key;this.key=a;this.offset=b;this.type=
|
|
57
|
+
c;U||(B()._compositionKey===f&&D(a),null===d||d.anchor!==this&&d.focus!==this||(d.dirty=!0))}}function X(a,b,c){return new bc(a,b,c)}function cc(a,b){const c=b.__key;let d=a.offset,f="element";w(b)&&(f="text",b=b.getTextContentSize(),d>b&&(d=b));a.set(c,d,f)}function dc(a,b){if(C(b)){const c=b.getLastDescendant();C(c)||w(c)?cc(a,c):cc(a,b)}else w(b)&&cc(a,b)}
|
|
58
|
+
function ec(a,b,c){const d=a.getNode(),f=d.getChildAtIndex(a.offset),e=L(),g=M(d)?fc().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 Y(a,b,c,d){a.key=b;a.offset=c;a.type=d}
|
|
59
|
+
class gc{constructor(a){this.dirty=!1;this._nodes=a}is(a){if(!Tb(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 gc(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(){}insertText(){}getNodes(){var a=this._nodes;const b=[];for(const c of a)a=H(c),null!==
|
|
60
|
+
a&&b.push(a);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 hc}
|
|
61
|
+
class ic{constructor(a,b,c){this.gridKey=a;this.anchorCellKey=b;this.anchor=X(b,0,"element");this.focusCellKey=c;this.focus=X(c,0,"element");this.dirty=!1}is(a){return jc(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 ic(this.gridKey,this.anchorCellKey,this.focusCellKey)}isCollapsed(){return!1}isBackward(){return this.focus.isBefore(this.anchor)}extract(){return this.getNodes()}insertRawText(){}insertText(){}getShape(){var a=
|
|
62
|
+
H(this.anchorCellKey);a||q(74);var b=a.getIndexWithinParent();a=a.getParentOrThrow().getIndexWithinParent();var c=H(this.focusCellKey);c||q(75);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(){const a=new Set,{fromX:b,fromY:c,toX:d,toY:f}=this.getShape();var e=H(this.gridKey);kc(e)||q(76);a.add(e);e=e.getChildren();
|
|
63
|
+
for(let l=c;l<=f;l++){var g=e[l];a.add(g);lc(g)||q(77);g=g.getChildren();for(let k=b;k<=d;k++){var h=g[k];rc(h)||q(78);a.add(h);for(h=h.getChildren();0<h.length;){const m=h.shift();a.add(m);C(m)&&h.unshift(...m.getChildren())}}}return Array.from(a)}getTextContent(){const a=this.getNodes();let b="";for(let c=0;c<a.length;c++)b+=a[c].getTextContent();return b}}function jc(a){return a instanceof ic}
|
|
64
|
+
class hc{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)&&this.format===a.format:!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();C(c)&&(c=c.getDescendantByIndex(a.offset));C(d)&&(d=d.getDescendantByIndex(b.offset));return c.is(d)?C(c)?[]:[c]:c.getNodesBetween(d)}setTextNodeRange(a,
|
|
65
|
+
b,c,d){Y(this.anchor,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,f=this.focus;const e=d.isBefore(f);d=d.getCharacterOffset();f=f.getCharacterOffset();let g="",h=!0;for(let l=0;l<a.length;l++){const k=a[l];if(C(k)&&!k.isInline())h||(g+="\n"),h=k.isEmpty()?!1:!0;else if(h=!1,w(k)){let m=k.getTextContent();k===b?m=k===c?d<f?m.slice(d,f):m.slice(f,d):e?m.slice(d):m.slice(f):
|
|
66
|
+
k===c&&(m=e?m.slice(0,f):m.slice(0,d));g+=m}else!u(k)&&!ya(k)||k===c&&this.isCollapsed()||(g+=k.getTextContent())}return g}applyDOMRange(a){const b=B(),c=b.getEditorState()._selection;a=sc(a.startContainer,a.startOffset,a.endContainer,a.endOffset,b,c);if(null!==a){var [d,f]=a;Y(this.anchor,d.key,d.offset,d.type);Y(this.focus,f.key,f.offset,f.type)}}clone(){const a=this.anchor,b=this.focus;return new hc(X(a.key,a.offset,a.type),X(b.key,b.offset,b.type),this.format)}toggleFormat(a){this.format=va(this.format,
|
|
67
|
+
a,null);this.dirty=!0}hasFormat(a){return 0!==(this.format&ea[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(tc())}this.insertNodes(a)}}insertText(a){var b=this.anchor,c=this.focus,d=this.isCollapsed()||b.isBefore(c),f=this.format;d&&"element"===b.type?ec(b,c,f):d||"element"!==c.type||ec(c,b,f);var e=this.getNodes(),g=e.length,h=d?c:b;c=(d?b:c).offset;var l=h.offset;
|
|
68
|
+
b=e[0];w(b)||q(6);d=b.getTextContent().length;var k=b.getParentOrThrow();if(!this.isCollapsed()||c!==d||!b.isSegmented()&&!b.isToken()&&b.canInsertTextAfter()&&k.canInsertTextAfter())if(!this.isCollapsed()||0!==c||!b.isSegmented()&&!b.isToken()&&b.canInsertTextBefore()&&k.canInsertTextBefore())b.isSegmented()&&c!==d&&(k=L(b.getTextContent()),b.replace(k),b=k);else{m=b.getPreviousSibling();if(!w(m)||v(m)||m.isSegmented())m=L(),k.canInsertTextBefore()?b.insertBefore(m):k.insertBefore(m);m.select();
|
|
69
|
+
b=m;if(""!==a){this.insertText(a);return}}else{var m=b.getNextSibling();if(!w(m)||v(m)||m.isSegmented())m=L(),k.canInsertTextAfter()?b.insertAfter(m):k.insertAfter(m);m.select(0,0);b=m;if(""!==a){this.insertText(a);return}}if(1===g)if(v(b))a=L(a),a.select(),b.replace(a);else{e=b.getFormat();if(c===l&&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-=
|
|
70
|
+
a.length);return}b=b.spliceText(c,l-c,a,!0);""===b.getTextContent()?b.remove():b.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=a.length)}else{k=e[g-1];f=new Set([...b.getParentKeys(),...k.getParentKeys()]);var n=C(b)?b:b.getParentOrThrow();m=C(k)?k:k.getParentOrThrow();"text"===h.type&&(0!==l||""===k.getTextContent())||"element"===h.type&&k.getIndexWithinParent()<l?w(k)&&!v(k)&&l!==k.getTextContentSize()?(k.isSegmented()&&(h=L(k.getTextContent()),k.replace(h),k=h),k=k.spliceText(0,
|
|
71
|
+
l,""),f.add(k.__key)):k.remove():f.add(k.__key);h=m.getChildren();l=new Set(e);const t=n.is(m);if(m.canBeEmpty()||n===m){for(n=h.length-1;0<=n;n--){const p=h[n];if(p.is(b)||C(p)&&p.isParentOf(b))break;p.isAttached()&&(!l.has(p)||p.is(k)?t||b.insertAfter(p):p.remove())}if(!t)for(h=m,l=null;null!==h;){k=h.getChildren();m=k.length;if(0===m||k[m-1].is(l))f.delete(h.__key),l=h;h=h.getParent()}}else n.append(m);v(b)?c===d?b.select():(a=L(a),a.select(),b.replace(a)):(b=b.spliceText(c,d-c,a,!0),""===b.getTextContent()?
|
|
72
|
+
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=d.getTextContent().length,l=g.offset,k=0;for(var m=0;m<b.length;m++){var n=b[m];if(w(n)){k=n.getFormatFlags(a,null);break}}var t=e.offset;n=(m=e.isBefore(g))?t:l;m=m?l:t;if(n===
|
|
73
|
+
d.getTextContentSize()){const p=d.getNextSibling();w(p)&&(n=t=0,d=p,k=d.getFormatFlags(a,null))}if(d.is(f))w(d)&&("element"===e.type&&"element"===g.type?(d.setFormat(k),d.select(n,m),this.format=k):(n=t>l?l:t,m=t>l?t: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(w(d)&&(0!==n&&([,d]=d.splitText(n)),d.setFormat(k)),e=k,w(f)&&(e=f.getFormatFlags(a,k),k=f.getTextContent().length,0!==m&&(m!==k&&([f]=
|
|
74
74
|
f.splitText(m)),f.setFormat(e))),k=1;k<c;k++)m=b[k],g=m.__key,w(m)&&g!==d.__key&&g!==f.__key&&!m.isToken()&&(g=m.getFormatFlags(a,e),m.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(),h=M(f)?null:f.getTopLevelElementOrThrow();if(w(f))if(e=f.getTextContent().length,0===d&&0!==e)e=f.getPreviousSibling(),e=null!==e?e:f.getParentOrThrow(),
|
|
75
|
-
c.push(f);else if(d===e)e=f;else{if(
|
|
76
|
-
|
|
77
|
-
e.getParentOrThrow().select(a,a))));if(
|
|
78
|
-
e)));return!0}insertParagraph(){this.isCollapsed()||this.removeText();var a=this.anchor,b=a.offset;if("text"===a.type){var c=a.getNode(),d=c.getTextContent().length;a=c.getNextSiblings().reverse();var f=c.getParentOrThrow();0===b?a.push(c):b!==d&&([,c]=c.splitText(b),a.push(c))}else{f=a.getNode();if(M(f)){a=
|
|
79
|
-
a.length,0===b&&0<d)f.insertBefore(c);else{b=null;if(0!==d)for(f=0;f<d;f++){const e=a[f];null===b?c.append(e):b.insertBefore(e);b=e}c.canBeEmpty()||0!==c.getChildrenSize()?c.selectStart():(c.selectPrevious(),c.remove())}}insertLineBreak(a){const b=
|
|
80
|
-
a[c];var h=d.getCharacterOffset();const l=f.getCharacterOffset();if(0===b)return[];if(1===b)return w(e)?(a=h>l?l:h,c=e.splitText(a,h>l?h:l),a=0===a?c[0]:c[1],null!=a?[a]:[]):[e];b=d.isBefore(f);w(e)&&(d=b?h:l,d===e.getTextContentSize()?a.shift():0!==d&&([,e]=e.splitText(d),a[0]=e));w(g)&&(e=g.getTextContent().length,h=b?l:h,0===h?a.pop():h!==e&&([g]=g.splitText(h),a[c]=g));return a}modify(a,b,c){var d=this.focus,f=this.anchor,e="move"===a;const g=
|
|
81
|
-
g.getNextSibling();if(!w(h)){a=g.getParentOrThrow();
|
|
82
|
-
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(),
|
|
83
|
-
d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(f)||a&&0!==b||!a&&b!==c)){
|
|
84
|
-
this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");this.removeText()}}function
|
|
85
|
-
function
|
|
86
|
-
d=0===b&&
|
|
87
|
-
function
|
|
88
|
-
0));f.isComposing()&&f._compositionKey!==a.key&&J(e)&&(f=e.anchor,e=e.focus,Y(a,f.key,f.offset,f.type),Y(c,e.key,e.offset,e.type))}return[a,c]}function
|
|
89
|
-
function
|
|
90
|
-
function K(){return z()._selection}function
|
|
91
|
-
function
|
|
92
|
-
function
|
|
93
|
-
1):g.getChildAtIndex(f),w(f)&&(g=0,b&&(g=f.getTextContentSize()),d.set(f.__key,g,"text")))}}function
|
|
94
|
-
function
|
|
95
|
-
function
|
|
96
|
-
function
|
|
97
|
-
class
|
|
75
|
+
c.push(f);else if(d===e)e=f;else{if(v(f))return!1;[e,f]=f.splitText(d);c.push(f)}const l=e;c.push(...g);g=a[0];var k=!1;f=null;for(let t=0;t<a.length;t++){const p=a[t];if(C(p)){if(p.is(g)){if(C(e)&&e.isEmpty()&&e.canReplaceWith(p)){e.replace(p);e=p;k=!0;continue}var m=p.getFirstDescendant();if(wa(m)){for(m=m.getParentOrThrow();m.isInline();)m=m.getParentOrThrow();k=m.getChildren();var n=k.length;if(C(e))for(let A=0;A<n;A++)f=k[A],e.append(f);else{for(--n;0<=n;n--)f=k[n],e.insertAfter(f);e=e.getParentOrThrow()}m.remove();
|
|
76
|
+
k=!0;if(m.is(p))continue}}w(e)&&(null===h&&q(69),e=h)}else k&&!u(p)&&M(e.getParent())&&q(7);k=!1;if(C(e))if(f=p,u(p)&&p.isTopLevel())e=e.insertAfter(p);else if(C(p)){if(p.canBeEmpty()||!p.isEmpty())M(e)?(m=e.getChildAtIndex(d),null!==m?m.insertBefore(p):e.append(p),e=p):e=e.insertAfter(p)}else m=e.getFirstChild(),null!==m?m.insertBefore(p):e.append(p),e=p;else!C(p)||u(e)&&e.isTopLevel()?(f=p,e=e.insertAfter(p)):(e=p.getParentOrThrow(),t--)}b&&(w(l)?l.select():(a=e.getPreviousSibling(),w(a)?a.select():
|
|
77
|
+
(a=e.getIndexWithinParent(),e.getParentOrThrow().select(a,a))));if(C(e)){if(a=w(f)?f:e.getLastDescendant(),b||(null===a?e.select():w(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)?(h=d.constructor.clone(d),C(h)||q(8),h.append(a),e.insertAfter(h)):e.insertAfter(a):(e.insertBefore(a),e=a),d.isEmpty()&&!d.canBeEmpty()&&d.remove()}else b||(w(e)?e.select():(c=e.getParentOrThrow(),e=e.getIndexWithinParent()+
|
|
78
|
+
1,c.select(e,e)));return!0}insertParagraph(){this.isCollapsed()||this.removeText();var a=this.anchor,b=a.offset;if("text"===a.type){var c=a.getNode(),d=c.getTextContent().length;a=c.getNextSiblings().reverse();var f=c.getParentOrThrow();0===b?a.push(c):b!==d&&([,c]=c.splitText(b),a.push(c))}else{f=a.getNode();if(M(f)){a=fc();b=f.getChildAtIndex(b);a.select();null!==b?b.insertBefore(a):f.append(a);return}a=f.getChildren().slice(b).reverse()}c=f.insertNewAfter(this);if(null===c)this.insertLineBreak();
|
|
79
|
+
else if(C(c))if(d=a.length,0===b&&0<d)f.insertBefore(c);else{b=null;if(0!==d)for(f=0;f<d;f++){const e=a[f];null===b?c.append(e):b.insertBefore(e);b=e}c.canBeEmpty()||0!==c.getChildrenSize()?c.selectStart():(c.selectPrevious(),c.remove())}}insertLineBreak(a){const b=tc();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 f=this.focus;
|
|
80
|
+
var e=a[0];let g=a[c];var h=d.getCharacterOffset();const l=f.getCharacterOffset();if(0===b)return[];if(1===b)return w(e)?(a=h>l?l:h,c=e.splitText(a,h>l?h:l),a=0===a?c[0]:c[1],null!=a?[a]:[]):[e];b=d.isBefore(f);w(e)&&(d=b?h:l,d===e.getTextContentSize()?a.shift():0!==d&&([,e]=e.splitText(d),a[0]=e));w(g)&&(e=g.getTextContent().length,h=b?l:h,0===h?a.pop():h!==e&&([g]=g.splitText(h),a[c]=g));return a}modify(a,b,c){var d=this.focus,f=this.anchor,e="move"===a;const g=Sa(d,b);if(u(g)&&!g.isIsolated()){var h=
|
|
81
|
+
b?g.getPreviousSibling():g.getNextSibling();if(!w(h)){a=g.getParentOrThrow();C(h)?(a=h.__key,h=b?h.getChildrenSize():0):(h=g.getIndexWithinParent(),a=a.__key,b||h++);d.set(a,h,"element");e&&f.set(a,h,"element");return}}d=window.getSelection();d.modify(a,b?"backward":"forward",c);0<d.rangeCount&&(b=d.getRangeAt(0),this.applyDOMRange(b),e||d.anchorNode===b.startContainer&&d.anchorOffset===b.startOffset||(e=this.focus,b=this.anchor,d=b.key,f=b.offset,h=b.type,Y(b,e.key,e.offset,e.type),Y(e,d,f,h)))}deleteCharacter(a){if(this.isCollapsed()){var b=
|
|
82
|
+
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",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){uc(f,a,b);return}}else if(null!==
|
|
83
|
+
d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(f)||a&&0!==b||!a&&b!==c)){uc(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: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()&&
|
|
84
|
+
this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");this.removeText()}}function Tb(a){return a instanceof gc}function uc(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 l=d[h],k=h===f-1;g=e;e+=l.length;if(b&&e===c||e>c||k){d.splice(h,1);k&&(g=void 0);break}}b=d.join(" ");""===b?a.remove():(a.setTextContent(b),a.select(g,g))}
|
|
85
|
+
function vc(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(w(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()));w(a)?(f=a,e=null,d=g?f.getTextContentSize():0):a!==e&&g&&d++}else d=e.getIndexWithinParent(),
|
|
86
|
+
d=0===b&&u(e)&&Ja(a)===e?d:d+1,e=e.getParentOrThrow();if(C(e))return X(e.__key,d,"element")}}else f=Ja(a);return w(f)?X(f.__key,d,"text"):null}
|
|
87
|
+
function sc(a,b,c,d,f,e){if(null===a||null===c||!ra(f,a,c))return null;a=vc(a,b,J(e)?e.anchor:null);if(null===a)return null;c=vc(c,d,J(e)?e.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(),w(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(),w(b)&&!b.isInert()&&(a.key=b.__key,a.offset=
|
|
88
|
+
0));f.isComposing()&&f._compositionKey!==a.key&&J(e)&&(f=e.anchor,e=e.focus,Y(a,f.key,f.offset,f.type),Y(c,e.key,e.offset,e.type))}return[a,c]}function wc(a,b,c,d,f,e){const g=z();a=new hc(X(a,b,f),X(c,d,e),0);a.dirty=!0;return g._selection=a}
|
|
89
|
+
function Rb(a){var b=a.getEditorState()._selection,c=window.getSelection();if(Tb(b)||jc(b))return b.clone();{var d=(d=window.event)&&d.type;d=!Vb&&("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=sc(d,h,g,c,a,b),null===a)b=null;else{var [f,e]=a;b=new hc(f,e,J(b)?b.format:0)}else b=b.clone()}return b}
|
|
90
|
+
function K(){return z()._selection}function Na(){return B()._editorState._selection}function Jb(a){if(null!==a){if("range"===a.type)return new hc(X(a.anchor.key,a.anchor.offset,a.anchor.type),X(a.focus.key,a.focus.offset,a.focus.type),0);if("node"===a.type)return new gc(new Set(a.nodes));if("grid"===a.type)return new ic(a.gridKey,a.anchorCellKey,a.focusCellKey)}return null}
|
|
91
|
+
function xc(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"),yc(a));else{var l=a.isBackward();h=l?e:f;var k=h.getNode();f=l?f:e;e=f.getNode();b.is(k)&&(k=h.offset,c<=k&&h.set(g,Math.max(0,k+d),"element"));b.is(e)&&(b=f.offset,c<=b&&f.set(g,Math.max(0,b+d),"element"));yc(a)}}
|
|
92
|
+
function yc(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),w(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);w(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-
|
|
93
|
+
1):g.getChildAtIndex(f),w(f)&&(g=0,b&&(g=f.getTextContentSize()),d.set(f.__key,g,"text")))}}function Sb(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))}}
|
|
94
|
+
function zc(a,b,c,d,f){let e=null,g=0,h=null;null!==d?(e=d.__key,w(d)?(g=d.getTextContentSize(),h="text"):C(d)&&(g=d.getChildrenSize(),h="element")):null!==f&&(e=f.__key,w(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 Ac(a,b,c,d,f){"text"===a.type?(a.key=c,b||(a.offset+=f)):a.offset>d.getIndexWithinParent()&&--a.offset}
|
|
95
|
+
function Bc(a,b){F();var c=a.__key;const d=a.getParent();if(null!==d){var f=K(),e=!1;if(J(f)&&b){var g=f.anchor;const h=f.focus;g.key===c&&(zc(g,a,d,a.getPreviousSibling(),a.getNextSibling()),e=!0);h.key===c&&(zc(h,a,d,a.getPreviousSibling(),a.getNextSibling()),e=!0)}g=d.getWritable().__children;c=g.indexOf(c);-1===c&&q(16);Aa(a);g.splice(c,1);a.getWritable().__parent=null;J(f)&&b&&!e&&xc(f,d,c,-1);null===d||M(d)||d.canBeEmpty()||!d.isEmpty()||Bc(d,b);null!==d&&M(d)&&d.isEmpty()&&d.selectEnd()}}
|
|
96
|
+
function Cc(a){const b=H(a);null===b&&q(39,a);return b}
|
|
97
|
+
class Dc{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{F();99<Ca&&q(26);a=B();var b=z(),c=""+pa++;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=
|
|
98
98
|
K();if(null==a)return!1;const b=(new Set(a.getNodes().map(c=>c.__key))).has(this.__key);return w(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&&q(33,this.__key);return a}getTopLevelElement(){let a=
|
|
99
|
-
this;for(;null!==a;){const b=a.getParent();if(M(b)&&
|
|
100
|
-
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=>
|
|
101
|
-
a.getParents();
|
|
102
|
-
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=
|
|
103
|
-
c.push(g);if(g===a)break;f=g;g.is(e)&&(e=null);do null===f&&q(35),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=
|
|
104
|
-
f=d.__parent;b=b._cloneNotNeeded;if(b.has(c))return
|
|
105
|
-
(a=a.getElementByKey(this.getKey()),{element:a?a.cloneNode():null}):{element:this.createDOM(a._config,a)}}static importDOM(){return null}remove(){F();
|
|
106
|
-
var b=this.getWritable(),c=a.getWritable(),d=c.getParent();const f=K();var e=a.getIndexWithinParent(),g=!1,h=!1;null!==d&&(
|
|
107
|
-
return a}insertBefore(a){F();var b=this.getWritable(),c=a.getWritable();
|
|
108
|
-
d=this.getParentOrThrow();return null===c?d.select():
|
|
109
|
-
class
|
|
110
|
-
|
|
111
|
-
this.getChildren(),c=b.length;if(0===c)return this;if(a>=c)return a=b[c-1],
|
|
112
|
-
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);
|
|
113
|
-
this.getFirstDescendant();return
|
|
114
|
-
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 l=0;l<g;l++){const k=c[l],m=k.getWritable();k.__key===f&&q(49);
|
|
115
|
-
|
|
116
|
-
function
|
|
117
|
-
class
|
|
118
|
-
__format:this.__format,__indent:this.__indent,__key:"root",__parent:null,__type:"root"}}}function M(a){return a instanceof
|
|
119
|
-
class
|
|
120
|
-
type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type},type:"range"}:
|
|
121
|
-
let
|
|
122
|
-
function
|
|
123
|
-
function
|
|
124
|
-
V(b,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
function
|
|
128
|
-
function
|
|
129
|
-
function
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
function
|
|
133
|
-
g)})}}class
|
|
134
|
-
function
|
|
135
|
-
function
|
|
136
|
-
class
|
|
137
|
-
(this.getLatest().__detail&2)}hasFormat(a){a=ea[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
|
|
138
|
-
c,this);a=a.theme.text;void 0!==a&&
|
|
139
|
-
l&&q(21));
|
|
99
|
+
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&&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>=
|
|
100
|
+
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=>Cc(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=>Cc(c))}getCommonAncestor(a){const b=this.getParents();var c=
|
|
101
|
+
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=
|
|
102
|
+
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)||
|
|
103
|
+
c.push(g);if(g===a)break;f=g;g.is(e)&&(e=null);do null===f&&q(35),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)}isComposing(){return this.__key===B()._compositionKey}getLatest(){const a=H(this.__key);null===a&&q(36);return a}getWritable(){F();var a=z(),b=B();a=a._nodeMap;const c=this.__key,d=this.getLatest(),
|
|
104
|
+
f=d.__parent;b=b._cloneNotNeeded;if(b.has(c))return Ba(d),d;const 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):w(d)&&w(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(){q(37)}updateDOM(){q(38)}exportDOM(a){return u(this)?
|
|
105
|
+
(a=a.getElementByKey(this.getKey()),{element:a?a.cloneNode():null}):{element:this.createDOM(a._config,a)}}static importDOM(){return null}remove(){F();Bc(this,!0)}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&&q(16);d.splice(f,0,e);a.__parent=c.__key;Bc(this,!1);Aa(a);d=K();J(d)&&(c=d.anchor,d=d.focus,c.key===b&&dc(c,a),d.key===b&&dc(d,a));B()._compositionKey===b&&D(e);return a}insertAfter(a){F();
|
|
106
|
+
var b=this.getWritable(),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 l=e.__children;b=l.indexOf(b.__key);-1===b&&q(16);l.splice(b+1,0,d);Aa(c);J(f)&&(xc(f,e,b+1),c=e.__key,g&&f.anchor.set(c,b+2,"element"),h&&f.focus.set(c,b+2,"element"));
|
|
107
|
+
return a}insertBefore(a){F();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&&q(16);e.splice(b,0,f);Aa(c);c=K();J(c)&&xc(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():w(c)?c.select(a,b):(a=c.getIndexWithinParent()+1,d.select(a,a))}selectNext(a,b){F();const c=this.getNextSibling(),
|
|
108
|
+
d=this.getParentOrThrow();return null===c?d.select():C(c)?c.select(0,0):w(c)?c.select(a,b):(a=c.getIndexWithinParent(),d.select(a,a))}markDirty(){this.getWritable()}}class Ec extends Dc{constructor(a){super(a)}decorate(){q(4)}isIsolated(){return!1}isTopLevel(){return!1}}function u(a){return a instanceof Ec}
|
|
109
|
+
class Fc extends Dc{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=
|
|
110
|
+
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=H(c[f]);!w(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();for(;null!==a;){if(C(a)){const b=a.getLastChild();if(null!==b){a=b;continue}}break}return a}getDescendantByIndex(a){const b=
|
|
111
|
+
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&&q(15,this.__key);return a}getLastChild(){const a=this.getLatest().__children,b=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,
|
|
112
|
+
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=fa[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,a,"element"),c.focus.set(d,b,"element"),c.dirty=!0;else return wc(d,a,d,b,"element","element");return c}selectStart(){const a=
|
|
113
|
+
this.getFirstDescendant();return C(a)||w(a)?a.select(0,0):null!==a?a.selectPrevious():this.select(0,0)}selectEnd(){const a=this.getLastDescendant();return C(a)||w(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();const b=this.getWritable();b.__dir=a;return b}setFormat(a){F();this.getWritable().__format=fa[a];return this}setIndent(a){F();
|
|
114
|
+
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 l=0;l<g;l++){const k=c[l],m=k.getWritable();k.__key===f&&q(49);za(m);m.__parent=f;h.push(m.__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);if(a.length&&(b=K(),J(b))){const l=new Set(a),k=new Set(h);h=t=>{for(t=t.getNode();t;){const p=t.__key;if(l.has(p)&&!k.has(p))return!0;
|
|
115
|
+
t=t.getParent()}return!1};const {anchor:m,focus:n}=b;h(m)&&zc(m,m.getNode(),this,c,f);h(n)&&zc(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}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}}
|
|
116
|
+
function C(a){return a instanceof Fc}
|
|
117
|
+
class Gc extends Fc{static getType(){return"root"}static clone(){return new Gc}constructor(){super("root");this.__cachedText=null}getTopLevelElementOrThrow(){q(70)}getTextContent(a,b){const c=this.__cachedText;return!U&&0!==B()._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];C(c)||u(c)||q(46)}return super.append(...a)}toJSON(){return{__children:this.__children,__dir:this.__dir,
|
|
118
|
+
__format:this.__format,__indent:this.__indent,__key:"root",__parent:null,__type:"root"}}}function M(a){return a instanceof Gc}function Ub(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 Hc(){return new Ib(new Map([["root",new Gc]]))}
|
|
119
|
+
class Ib{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=R,d=U,f=T;R=this;U=!0;T=null;try{var b=a();break a}finally{R=c,U=d,T=f}b=void 0}return b}clone(a){a=new Ib(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,
|
|
120
|
+
type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type},type:"range"}:Tb(a)?{nodes:Array.from(a._nodes),type:"node"}:jc(a)?{anchorCellKey:a.anchorCellKey,focusCellKey:a.focusCellKey,gridKey:a.gridKey,type:"grid"}:null}}}const Ic=Object.freeze({}),Oc=[["keydown",Jc],["compositionstart",Kc],["compositionend",Lc],["input",Mc],["click",Nc],["cut",Ic],["copy",Ic],["dragstart",Ic],["paste",Ic],["focus",Ic],["blur",Ic]];la?Oc.push(["beforeinput",Pc]):Oc.push(["drop",Ic]);
|
|
121
|
+
let Qc=0,Rc=0;function Sc(a,b,c){I(b,()=>{if(c){var d=K();if(J(d)&&d.isCollapsed()){"Range"===a.type&&(d.dirty=!0);var f=d.anchor;"text"===f.type?(f=f.getNode(),d.format=f.getFormat()):"element"===f.type&&(d.format=0)}V(b,Tc,void 0)}else Ia(null)})}
|
|
122
|
+
function Nc(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=b.getEditorState()._selection,null!==d&&c.is(d)&&(window.getSelection().removeAllRanges(),c.dirty=!0))}V(b,Uc,a)})}function Vc(a,b){b.getTargetRanges&&(b=b.getTargetRanges()[0])&&a.applyDOMRange(b)}function Wc(a,b){return a!==b||C(a)||C(b)||!v(a)||!v(b)}
|
|
123
|
+
function Pc(a,b){const c=a.inputType;if(!("deleteCompositionText"===c||ka&&Wa()))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&&w(g)&&w(h)&&" "===g.getTextContent()&&h.getFormat()!==f.format&&(f=h.getTextContent(),0===d.indexOf(f)&&(f=d.slice(f.length),V(b,Xc,f),setTimeout(()=>{I(b,()=>{g.select()})},30)))}})}else I(b,()=>{const d=K();if(J(d))if("deleteContentBackward"===c)D(null),a.preventDefault(),
|
|
124
|
+
Qc=0,V(b,Yc,!0),setTimeout(()=>{b.update(()=>{D(null)})},30);else{var f=a.data;d.dirty||!d.isCollapsed()||M(d.anchor.getNode())||Vc(d,a);var e=d.focus,g=d.anchor.getNode();e=e.getNode();if("insertText"===c)"\n"===f?(a.preventDefault(),V(b,Zc,void 0)):"\n\n"===f?(a.preventDefault(),V(b,$c,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(),V(b,Xc,f));else switch(a.preventDefault(),c){case "insertFromYank":case "insertFromDrop":case "insertReplacementText":V(b,
|
|
125
|
+
Xc,a);break;case "insertFromComposition":D(null);V(b,Xc,a);break;case "insertLineBreak":D(null);V(b,Zc,void 0);break;case "insertParagraph":D(null);V(b,$c,void 0);break;case "insertFromPaste":case "insertFromPasteAsQuotation":V(b,ad,a);break;case "deleteByComposition":Wc(g,e)&&V(b,bd,void 0);break;case "deleteByDrag":case "deleteByCut":V(b,bd,void 0);break;case "deleteContent":V(b,Yc,!1);break;case "deleteWordBackward":V(b,cd,!0);break;case "deleteWordForward":V(b,cd,!1);break;case "deleteHardLineBackward":case "deleteSoftLineBackward":V(b,
|
|
126
|
+
dd,!0);break;case "deleteContentForward":case "deleteHardLineForward":case "deleteSoftLineForward":V(b,dd,!1);break;case "formatStrikeThrough":V(b,Z,"strikethrough");break;case "formatBold":V(b,Z,"bold");break;case "formatItalic":V(b,Z,"italic");break;case "formatUnderline":V(b,Z,"underline");break;case "historyUndo":V(b,ed,void 0);break;case "historyRedo":V(b,fd,void 0)}}})}
|
|
127
|
+
function Mc(a,b){a.stopPropagation();I(b,()=>{var c=K();const d=a.data;null!=d&&J(c)&&Oa(c,d,!1)?V(b,Xc,d):La(b,null);F();c=B();ac(c)})}function Kc(a,b){I(b,()=>{const c=K();if(J(c)&&!b.isComposing()){const d=c.anchor;D(d.key);(a.timeStamp<Qc+30||"element"===d.type||!c.isCollapsed()||c.anchor.getNode().getFormat()!==c.format)&&V(b,Xc," ")}})}
|
|
128
|
+
function Lc(a,b){I(b,()=>{var c=b._compositionKey;D(null);var d=a.data;if(null!==c&&null!=d){if(""===d){d=H(c);c=ua(b.getElementByKey(c));null!==c&&w(d)&&Ma(d,c.nodeValue,null,null,!0);return}if("\n"===d[d.length-1]&&(c=K(),J(c))){d=c.focus;c.anchor.set(d.key,d.offset,d.type);V(b,gd,null);return}}La(b,a)})}
|
|
129
|
+
function Jc(a,b){Qc=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)V(b,gd,a);else if(r&&f&&79===c)a.preventDefault(),V(b,Zc,!0);else if(13!==c||d){var h=r?g||e?!1:8===c||72===c&&f:f||g||e?!1:8===c;h?8===c?V(b,hd,a):(a.preventDefault(),V(b,Yc,!0)):27===c?V(b,id,a):(h=r?d||g||e?!1:46===c||68===c&&f:f||g||e?!1:46===c,h?46===c?V(b,jd,a):(a.preventDefault(),V(b,Yc,!1)):8===c&&
|
|
130
|
+
(r?g:f)?(a.preventDefault(),V(b,cd,!0)):46===c&&(r?g:f)?(a.preventDefault(),V(b,cd,!1)):r&&e&&8===c?(a.preventDefault(),V(b,dd,!0)):r&&e&&46===c?(a.preventDefault(),V(b,dd,!1)):66===c&&(r?e:f)?(a.preventDefault(),V(b,Z,"bold")):85===c&&(r?e:f)?(a.preventDefault(),V(b,Z,"underline")):73===c&&(r?e:f)?(a.preventDefault(),V(b,Z,"italic")):9!==c||g||f||e?90===c&&!d&&(r?e:f)?(a.preventDefault(),V(b,ed,void 0)):(h=r?90===c&&e&&d:89===c&&f||90===c&&f&&d,h&&(a.preventDefault(),V(b,fd,void 0))):V(b,kd,a))}else V(b,
|
|
131
|
+
gd,a);else V(b,ld,a);else V(b,md,a);else V(b,nd,a);else V(b,od,a)}}function pd(a){let b=a.__lexicalEventHandles;void 0===b&&(b=[],a.__lexicalEventHandles=b);return b}const qd=new Map;function rd(){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=qd.get(d),e=f||c;e!==b&&Sc(a,e,!1);Sc(a,b,!0);b!==c?qd.set(d,b):f&&qd.delete(d)}}
|
|
132
|
+
function sd(a,b){0===Rc&&a.ownerDocument.addEventListener("selectionchange",rd);Rc++;a.__lexicalEditor=b;const c=pd(a);for(let d=0;d<Oc.length;d++){const [f,e]=Oc[d],g="function"===typeof e?h=>{b.isReadOnly()||e(h,b)}:h=>{if(!b.isReadOnly())switch(f){case "cut":return V(b,vd,h);case "copy":return V(b,wd,h);case "paste":return V(b,ad,h);case "dragstart":return V(b,xd,h);case "focus":return V(b,yd,h);case "blur":return V(b,zd,h);case "drop":return V(b,Ad,h)}};a.addEventListener(f,g);c.push(()=>{a.removeEventListener(f,
|
|
133
|
+
g)})}}class Bd extends Dc{static getType(){return"linebreak"}static clone(a){return new Bd(a.__key)}constructor(a){super(a)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:()=>({conversion:Cd,priority:0})}}}function Cd(){return{node:tc()}}function tc(){return new Bd}function ya(a){return a instanceof Bd}function Dd(a,b){return b&1?"strong":b&2?"em":"span"}
|
|
134
|
+
function Ed(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 l in ea)h=ea[l],d=Pa(f,l),void 0!==d&&(c&h?!e||"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))}
|
|
135
|
+
function Fd(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,l,k]=a;0!==l&&d.deleteData(h,l);d.insertData(h,k)}else d.nodeValue=a}
|
|
136
|
+
class Gd extends Dc{static getType(){return"text"}static clone(a){return new Gd(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!==
|
|
137
|
+
(this.getLatest().__detail&2)}hasFormat(a){a=ea[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 va(c,a,b)}createDOM(a){var b=this.__format,c=b&16?"code":null;const d=Dd(this,b),f=document.createElement(null===c?d:c);let e=f;null!==c&&(e=document.createElement(d),f.appendChild(e));c=e;Fd(this.__text,
|
|
138
|
+
c,this);a=a.theme.text;void 0!==a&&Ed(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=f&16?"code":null;const h=e&16?"code":null;var l=Dd(this,f);const k=Dd(this,e);if((null===g?l:g)!==(null===h?k:h))return!0;if(g===h&&l!==k)return f=b.firstChild,null==f&&q(20),a=g=document.createElement(k),Fd(d,a,this),c=c.theme.text,void 0!==c&&Ed(k,0,e,a,c),b.replaceChild(g,f),!1;l=b;null!==h&&null!==g&&(l=b.firstChild,null==
|
|
139
|
+
l&&q(21));Fd(d,l,this);c=c.theme.text;void 0!==c&&f!==e&&Ed(k,f,e,l,c);e=this.__style;a.__style!==e&&(b.style.cssText=e);return!1}static importDOM(){return{"#text":()=>({conversion:Hd,priority:0}),b:()=>({conversion:Id,priority:0}),em:()=>({conversion:Jd,priority:0}),i:()=>({conversion:Jd,priority:0}),span:()=>({conversion:Kd,priority:0}),strong:()=>({conversion:Jd,priority:0}),u:()=>({conversion:Jd,priority:0})}}selectionTransform(){}setFormat(a){F();const b=this.getWritable();b.__format=a;return b}setStyle(a){F();
|
|
140
140
|
const b=this.getWritable();b.__style=a;return b}toggleFormat(a){a=ea[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=this.__key;"string"===typeof d?(d=
|
|
141
|
-
d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(J(c))d=
|
|
142
|
-
var b=this.getLatest(),c=b.getTextContent(),d=b.__key,f=
|
|
143
|
-
a[y],
|
|
144
|
-
a===this.getPreviousSibling();b||a===this.getNextSibling()||q(22);const c=this.__key,d=a.__key,f=this.__text,e=f.length;
|
|
145
|
-
function
|
|
146
|
-
function L(a=""){return new
|
|
147
|
-
class
|
|
148
|
-
a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=this.getChildren();if(0===a.length||w(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
|
|
149
|
-
function
|
|
150
|
-
function
|
|
151
|
-
function
|
|
141
|
+
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 wc(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 l=K();d&&J(l)&&(a+=g,l.setTextNodeRange(f,a,f,a));b=e.slice(0,h)+c+e.slice(h+b);return f.setTextContent(b)}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...a){F();
|
|
142
|
+
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 l=0;l<g;l++)""!==h&&e.has(l)&&(a.push(h),h=""),h+=c[l];""!==h&&a.push(h);e=a.length;if(0===e)return[];if(a[0]===c)return[b];var k=a[0];c=b.getParentOrThrow();l=c.__key;const m=b.getFormat(),n=b.getStyle(),t=b.__detail;g=!1;b.isSegmented()?(h=L(k),h.__parent=l,h.__format=m,h.__style=n,h.__detail=t,g=!0):(h=b.getWritable(),h.__text=k);b=K();h=[h];k=k.length;for(let y=1;y<e;y++){var p=
|
|
143
|
+
a[y],A=p.length;p=L(p).getWritable();p.__format=m;p.__style=n;p.__detail=t;const E=p.__key;A=k+A;if(J(b)){const x=b.anchor,G=b.focus;x.key===d&&"text"===x.type&&x.offset>k&&x.offset<=A&&(x.key=E,x.offset-=k,b.dirty=!0);G.key===d&&"text"===G.type&&G.offset>k&&G.offset<=A&&(G.key=E,G.offset-=k,b.dirty=!0)}f===d&&D(E);k=A;p.__parent=l;h.push(p)}Aa(this);f=c.getWritable().__children;d=f.indexOf(d);a=h.map(y=>y.__key);g?(f.splice(d,0,...a),this.remove()):f.splice(d,1,...a);J(b)&&xc(b,c,d,e-1);return h}mergeWithSibling(a){const b=
|
|
144
|
+
a===this.getPreviousSibling();b||a===this.getNextSibling()||q(22);const c=this.__key,d=a.__key,f=this.__text,e=f.length;B()._compositionKey===d&&D(c);const g=K();if(J(g)){const h=g.anchor,l=g.focus;null!==h&&h.key===d&&(Ac(h,b,c,a,e),g.dirty=!0);null!==l&&l.key===d&&(Ac(l,b,c,a,e),g.dirty=!0)}this.setTextContent(b?a.__text+f:f+a.__text);a.remove();return this.getLatest()}isTextEntity(){return!1}}
|
|
145
|
+
function Kd(a){const b="700"===a.style.fontWeight;return{forChild:c=>{w(c)&&b&&c.toggleFormat("bold");return c},node:null}}function Id(a){const b="normal"===a.style.fontWeight;return{forChild:c=>{w(c)&&!b&&c.toggleFormat("bold");return c},node:null}}function Hd(a){return{node:L(a.textContent)}}const Ld={em:"italic",i:"italic",strong:"bold",u:"underline"};function Jd(a){const b=Ld[a.nodeName.toLowerCase()];return void 0===b?{node:null}:{forChild:c=>{w(c)&&c.toggleFormat(b);return c},node:null}}
|
|
146
|
+
function L(a=""){return new Gd(a)}function w(a){return a instanceof Gd}
|
|
147
|
+
class Md extends Fc{static getType(){return"paragraph"}static clone(a){return new Md(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 importDOM(){return{p:()=>({conversion:Nd,priority:0})}}exportDOM(a){({element:a}=super.exportDOM(a));a&&0===this.getTextContentSize()&&a.append(document.createElement("br"));return{element:a}}insertNewAfter(){const a=fc(),b=this.getDirection();
|
|
148
|
+
a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=this.getChildren();if(0===a.length||w(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 Nd(){return{node:fc()}}function fc(){return new Md}
|
|
149
|
+
function Mb(a,b,c,d){const f=a._keyToDOMMap;f.clear();a._editorState=Hc();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))}
|
|
150
|
+
function Od(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}
|
|
151
|
+
function cb(a){var b=a||{},c=b.namespace||Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5);const d=b.theme||{},f=b.context||{},e=b.parentEditor||null,g=b.disableEvents||!1,h=Hc();a=b.editorState;const l=[Gc,Gd,Bd,Md,...(b.nodes||[])],k=b.onError;b=b.readOnly||!1;const m=new Map;for(let n=0;n<l.length;n++){const t=l[n],p=t.getType();m.set(p,{klass:t,transforms:new Set})}c=new Pd(h,e,m,{context:f,disableEvents:g,namespace:c,theme:d},k,Od(m),b);void 0!==a&&(c._pendingEditorState=a,c._dirtyType=
|
|
152
152
|
2);return c}
|
|
153
|
-
class
|
|
154
|
-
new Set;this._dirtyElements=new Map;this._normalizedNodes=new Set;this._updateTags=new Set;this._observer=null;this._key=""+
|
|
153
|
+
class Pd{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=
|
|
154
|
+
new Set;this._dirtyElements=new Map;this._normalizedNodes=new Set;this._updateTags=new Set;this._observer=null;this._key=""+pa++;this._onError=f;this._htmlConversions=e;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);return()=>
|
|
155
155
|
{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&&q(56);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&&q(81,a);const e=f[c];e.add(b);return()=>{e.delete(b);f.every(g=>0===g.size)&&d.delete(a)}}registerMutationListener(a,
|
|
156
|
-
b){void 0===this._nodes.get(a.getType())&&q(57,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&&q(57,a.name);const f=d.transforms;f.add(b);
|
|
157
|
-
this._rootElement;if(a!==b){var c=this._pendingEditorState||this._editorState;this._rootElement=a;
|
|
158
|
-
"text",c.whiteSpace="pre-wrap",c.wordBreak="break-word",a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,
|
|
159
|
-
|
|
160
|
-
a&&a.removeAllRanges()}isReadOnly(){return this._readOnly}setReadOnly(a){this._readOnly=a;
|
|
161
|
-
const
|
|
162
|
-
exports.$createRangeSelection=function(){const a=X("root",0,"element"),b=X("root",0,"element");return new
|
|
163
|
-
exports.$isLineBreakNode=
|
|
164
|
-
exports.CAN_UNDO_COMMAND={};exports.CLEAR_EDITOR_COMMAND={};exports.CLEAR_HISTORY_COMMAND={};exports.CLICK_COMMAND=
|
|
165
|
-
exports.GridRowNode=
|
|
166
|
-
exports.PASTE_COMMAND=
|
|
156
|
+
b){void 0===this._nodes.get(a.getType())&&q(57,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&&q(57,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 V(this,a,b)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(a){const b=
|
|
157
|
+
this._rootElement;if(a!==b){var c=this._pendingEditorState||this._editorState;this._rootElement=a;Mb(this,b,a,c);if(null!==b&&!this._config.disableEvents){0!==Rc&&(Rc--,0===Rc&&b.ownerDocument.removeEventListener("selectionchange",rd));c=b.__lexicalEditor;if(null!=c){if(null!==c._parentEditor){var d=Ka(c);d=d[d.length-1]._key;qd.get(d)===c&&qd.delete(d)}else qd.delete(c._key);b.__lexicalEditor=null}c=pd(b);for(d=0;d<c.length;d++)c[d]();b.__lexicalEventHandles=[]}null!==a&&(c=a.style,c.userSelect=
|
|
158
|
+
"text",c.whiteSpace="pre-wrap",c.wordBreak="break-word",a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,Nb(this),this._updateTags.add("history-merge"),Kb(this),this._config.disableEvents||sd(a,this));Ob("root",this,!1,a,b)}}getElementByKey(a){return this._keyToDOMMap.get(a)||null}getEditorState(){return this._editorState}setEditorState(a,b){a.isEmpty()&&q(19);ac(this);const c=this._pendingEditorState,d=this._updateTags;b=void 0!==b?b.tag:null;null===c||c.isEmpty()||(null!=b&&d.add(b),
|
|
159
|
+
Kb(this));this._pendingEditorState=a;this._dirtyType=2;this._compositionKey=null;null!=b&&d.add(b);Kb(this)}parseEditorState(a){a=JSON.parse(a);return db(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();null!==
|
|
160
|
+
a&&a.removeAllRanges()}isReadOnly(){return this._readOnly}setReadOnly(a){this._readOnly=a;Ob("readonly",this,!0,a)}toJSON(){return{editorState:this._editorState}}}class Qd extends Fc{constructor(a,b){super(b)}}function rc(a){return a instanceof Qd}class Rd extends Fc{}function kc(a){return a instanceof Rd}class Sd extends Fc{}function lc(a){return a instanceof Sd}
|
|
161
|
+
const Tc={},Uc={},Yc={},Zc={},$c={},Xc={},ad={},bd={},cd={},dd={},Z={},ed={},fd={},od={},nd={},md={},ld={},gd={},hd={},id={},jd={},kd={},Ad={},xd={},wd={},vd={},yd={},zd={};exports.$createGridSelection=function(){return new ic("root","root","root")};exports.$createLineBreakNode=tc;exports.$createNodeFromParse=function(a,b){F();const c=B();return bb(a,b,c,null)};exports.$createNodeSelection=function(){return new gc(new Set)};exports.$createParagraphNode=fc;
|
|
162
|
+
exports.$createRangeSelection=function(){const a=X("root",0,"element"),b=X("root",0,"element");return new hc(a,b,0)};exports.$createTextNode=L;exports.$getDecoratorNode=Sa;exports.$getNearestNodeFromDOMNode=sa;exports.$getNodeByKey=H;exports.$getPreviousSelection=Na;exports.$getRoot=Ga;exports.$getSelection=K;exports.$isDecoratorNode=u;exports.$isElementNode=C;exports.$isGridCellNode=rc;exports.$isGridNode=kc;exports.$isGridRowNode=lc;exports.$isGridSelection=jc;exports.$isLeafNode=wa;
|
|
163
|
+
exports.$isLineBreakNode=ya;exports.$isNodeSelection=Tb;exports.$isParagraphNode=function(a){return a instanceof Md};exports.$isRangeSelection=J;exports.$isRootNode=M;exports.$isTextNode=w;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=zd;exports.CAN_REDO_COMMAND={};
|
|
164
|
+
exports.CAN_UNDO_COMMAND={};exports.CLEAR_EDITOR_COMMAND={};exports.CLEAR_HISTORY_COMMAND={};exports.CLICK_COMMAND=Uc;exports.COPY_COMMAND=wd;exports.CUT_COMMAND=vd;exports.DELETE_CHARACTER_COMMAND=Yc;exports.DELETE_LINE_COMMAND=dd;exports.DELETE_WORD_COMMAND=cd;exports.DRAGSTART_COMMAND=xd;exports.DROP_COMMAND=Ad;exports.DecoratorNode=Ec;exports.ElementNode=Fc;exports.FOCUS_COMMAND=yd;exports.FORMAT_ELEMENT_COMMAND={};exports.FORMAT_TEXT_COMMAND=Z;exports.GridCellNode=Qd;exports.GridNode=Rd;
|
|
165
|
+
exports.GridRowNode=Sd;exports.INDENT_CONTENT_COMMAND={};exports.INSERT_LINE_BREAK_COMMAND=Zc;exports.INSERT_PARAGRAPH_COMMAND=$c;exports.INSERT_TEXT_COMMAND=Xc;exports.KEY_ARROW_DOWN_COMMAND=ld;exports.KEY_ARROW_LEFT_COMMAND=nd;exports.KEY_ARROW_RIGHT_COMMAND=od;exports.KEY_ARROW_UP_COMMAND=md;exports.KEY_BACKSPACE_COMMAND=hd;exports.KEY_DELETE_COMMAND=jd;exports.KEY_ENTER_COMMAND=gd;exports.KEY_ESCAPE_COMMAND=id;exports.KEY_TAB_COMMAND=kd;exports.OUTDENT_CONTENT_COMMAND={};
|
|
166
|
+
exports.PASTE_COMMAND=ad;exports.ParagraphNode=Md;exports.READ_ONLY_COMMAND={};exports.REDO_COMMAND=fd;exports.REMOVE_TEXT_COMMAND=bd;exports.SELECTION_CHANGE_COMMAND=Tc;exports.TextNode=Gd;exports.UNDO_COMMAND=ed;exports.VERSION="0.2.1";exports.createCommand=function(){return{}};exports.createEditor=cb;
|
package/README.md
CHANGED
|
@@ -11,10 +11,10 @@ editor implementations to be built on top. Lexical's engine provides three main
|
|
|
11
11
|
|
|
12
12
|
By design, the core of Lexical tries to be as minimal as possible.
|
|
13
13
|
Lexical doesn't directly concern itself with things that monolithic editors tend to do – such as UI components, toolbars or rich-text features and markdown. Instead
|
|
14
|
-
the logic for those features can be included via a plugin interface and used as and when they're needed. This ensures great
|
|
14
|
+
the logic for those features can be included via a plugin interface and used as and when they're needed. This ensures great extensibility and keeps code-sizes
|
|
15
15
|
to a minimal – ensuring apps only pay the cost for what they actually import.
|
|
16
16
|
|
|
17
|
-
For React apps, Lexical has tight
|
|
17
|
+
For React apps, Lexical has tight integration with React 18+ via the optional `@lexical/react` package. This package provides
|
|
18
18
|
production-ready utility functions, helpers and React hooks that make it seemless to create text editors within React.
|
|
19
19
|
|
|
20
20
|
## Usage
|
|
@@ -90,7 +90,7 @@ There are a few ways to update an editor instance:
|
|
|
90
90
|
- Trigger an update with `editor.update()`
|
|
91
91
|
- Setting the editor state via `editor.setEditorState()`
|
|
92
92
|
- Applying a change as part of an existing update via `editor.registerNodeTransform()`
|
|
93
|
-
- Using a command listener with `editor.registerCommand( () => {...}, priority)`
|
|
93
|
+
- Using a command listener with `editor.registerCommand(EXAMPLE_COMMAND, () => {...}, priority)`
|
|
94
94
|
|
|
95
95
|
The most common way to update the editor is to use `editor.update()`. Calling this function
|
|
96
96
|
requires a function to be passed in that will provide access to mutate the underlying
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lexical",
|
|
3
|
-
"description": "Lexical is an extensible text editor
|
|
3
|
+
"description": "Lexical is an extensible text editor framework that provides excellent reliability, accessible and performance.",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"react",
|
|
6
6
|
"lexical",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"rich-text"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "0.2.
|
|
12
|
+
"version": "0.2.1",
|
|
13
13
|
"main": "Lexical.js",
|
|
14
14
|
"typings": "Lexical.d.ts",
|
|
15
15
|
"repository": {
|