lexical 0.2.2 → 0.2.3
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 +6 -5
- package/Lexical.dev.js +63 -55
- package/Lexical.js.flow +2 -1
- package/Lexical.prod.js +113 -113
- package/package.json +1 -1
package/Lexical.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ 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>;
|
|
38
38
|
export var KEY_TAB_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
39
|
+
export var KEY_MODIFIER_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
39
40
|
export var INDENT_CONTENT_COMMAND: LexicalCommand<void>;
|
|
40
41
|
export var OUTDENT_CONTENT_COMMAND: LexicalCommand<void>;
|
|
41
42
|
export var DROP_COMMAND: LexicalCommand<DragEvent>;
|
|
@@ -144,7 +145,7 @@ export declare class LexicalEditor {
|
|
|
144
145
|
klass: Class<T>,
|
|
145
146
|
listener: Transform<T>,
|
|
146
147
|
): () => void;
|
|
147
|
-
dispatchCommand(type: string, payload: P): boolean;
|
|
148
|
+
dispatchCommand<P>(type: string, payload: P): boolean;
|
|
148
149
|
hasNodes(nodes: Array<Class<LexicalNode>>): boolean;
|
|
149
150
|
getDecorators<X>(): Record<NodeKey, X>;
|
|
150
151
|
getRootElement(): null | HTMLElement;
|
|
@@ -292,8 +293,8 @@ export type DOMConversionFn = (
|
|
|
292
293
|
) => DOMConversionOutput;
|
|
293
294
|
export type DOMChildConversion = (
|
|
294
295
|
lexicalNode: LexicalNode,
|
|
295
|
-
parentLexicalNode:
|
|
296
|
-
) =>
|
|
296
|
+
parentLexicalNode: LexicalNode | null,
|
|
297
|
+
) => LexicalNode | void | null;
|
|
297
298
|
export type DOMConversionMap = Record<
|
|
298
299
|
NodeName,
|
|
299
300
|
(node: Node) => DOMConversion | null
|
|
@@ -305,7 +306,7 @@ export type DOMConversionOutput = {
|
|
|
305
306
|
node: LexicalNode | null;
|
|
306
307
|
};
|
|
307
308
|
export type DOMExportOutput = {
|
|
308
|
-
after?: (generatedElement:
|
|
309
|
+
after?: (generatedElement: HTMLElement | null) => HTMLElement | null;
|
|
309
310
|
element: HTMLElement | null;
|
|
310
311
|
};
|
|
311
312
|
export type NodeKey = string;
|
|
@@ -360,7 +361,7 @@ export declare class LexicalNode {
|
|
|
360
361
|
dom: HTMLElement,
|
|
361
362
|
config: EditorConfig<EditorContext>,
|
|
362
363
|
): boolean;
|
|
363
|
-
remove(): void;
|
|
364
|
+
remove(preserveEmptyParent?: boolean): void;
|
|
364
365
|
replace<N extends LexicalNode>(replaceWith: N): N;
|
|
365
366
|
insertAfter(nodeToInsert: LexicalNode): LexicalNode;
|
|
366
367
|
insertBefore(nodeToInsert: LexicalNode): LexicalNode;
|
package/Lexical.dev.js
CHANGED
|
@@ -724,6 +724,9 @@ function isMoveUp(keyCode, ctrlKey, shiftKey, altKey, metaKey) {
|
|
|
724
724
|
function isMoveDown(keyCode, ctrlKey, shiftKey, altKey, metaKey) {
|
|
725
725
|
return isArrowDown(keyCode) && !ctrlKey && !metaKey;
|
|
726
726
|
}
|
|
727
|
+
function isModifier(ctrlKey, shiftKey, altKey, metaKey) {
|
|
728
|
+
return ctrlKey || shiftKey || altKey || metaKey;
|
|
729
|
+
}
|
|
727
730
|
function controlOrMeta(metaKey, ctrlKey) {
|
|
728
731
|
if (IS_APPLE) {
|
|
729
732
|
return metaKey;
|
|
@@ -1166,6 +1169,55 @@ function internalCreateNodeFromParse(parsedNode, parsedNodeMap, editor, parentKe
|
|
|
1166
1169
|
return node;
|
|
1167
1170
|
}
|
|
1168
1171
|
|
|
1172
|
+
/**
|
|
1173
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1174
|
+
*
|
|
1175
|
+
* This source code is licensed under the MIT license found in the
|
|
1176
|
+
* LICENSE file in the root directory of this source tree.
|
|
1177
|
+
*
|
|
1178
|
+
*
|
|
1179
|
+
*/
|
|
1180
|
+
function createCommand() {
|
|
1181
|
+
// $FlowFixMe: avoid freezing the object for perf reasons
|
|
1182
|
+
return {};
|
|
1183
|
+
}
|
|
1184
|
+
const SELECTION_CHANGE_COMMAND = createCommand();
|
|
1185
|
+
const CLICK_COMMAND = createCommand();
|
|
1186
|
+
const DELETE_CHARACTER_COMMAND = createCommand();
|
|
1187
|
+
const INSERT_LINE_BREAK_COMMAND = createCommand();
|
|
1188
|
+
const INSERT_PARAGRAPH_COMMAND = createCommand();
|
|
1189
|
+
const INSERT_TEXT_COMMAND = createCommand();
|
|
1190
|
+
const PASTE_COMMAND = createCommand();
|
|
1191
|
+
const REMOVE_TEXT_COMMAND = createCommand();
|
|
1192
|
+
const DELETE_WORD_COMMAND = createCommand();
|
|
1193
|
+
const DELETE_LINE_COMMAND = createCommand();
|
|
1194
|
+
const FORMAT_TEXT_COMMAND = createCommand();
|
|
1195
|
+
const UNDO_COMMAND = createCommand();
|
|
1196
|
+
const REDO_COMMAND = createCommand();
|
|
1197
|
+
const KEY_ARROW_RIGHT_COMMAND = createCommand();
|
|
1198
|
+
const KEY_ARROW_LEFT_COMMAND = createCommand();
|
|
1199
|
+
const KEY_ARROW_UP_COMMAND = createCommand();
|
|
1200
|
+
const KEY_ARROW_DOWN_COMMAND = createCommand();
|
|
1201
|
+
const KEY_ENTER_COMMAND = createCommand();
|
|
1202
|
+
const KEY_BACKSPACE_COMMAND = createCommand();
|
|
1203
|
+
const KEY_ESCAPE_COMMAND = createCommand();
|
|
1204
|
+
const KEY_DELETE_COMMAND = createCommand();
|
|
1205
|
+
const KEY_TAB_COMMAND = createCommand();
|
|
1206
|
+
const INDENT_CONTENT_COMMAND = createCommand();
|
|
1207
|
+
const OUTDENT_CONTENT_COMMAND = createCommand();
|
|
1208
|
+
const DROP_COMMAND = createCommand();
|
|
1209
|
+
const FORMAT_ELEMENT_COMMAND = createCommand();
|
|
1210
|
+
const DRAGSTART_COMMAND = createCommand();
|
|
1211
|
+
const COPY_COMMAND = createCommand();
|
|
1212
|
+
const CUT_COMMAND = createCommand();
|
|
1213
|
+
const CLEAR_EDITOR_COMMAND = createCommand();
|
|
1214
|
+
const CLEAR_HISTORY_COMMAND = createCommand();
|
|
1215
|
+
const CAN_REDO_COMMAND = createCommand();
|
|
1216
|
+
const CAN_UNDO_COMMAND = createCommand();
|
|
1217
|
+
const FOCUS_COMMAND = createCommand();
|
|
1218
|
+
const BLUR_COMMAND = createCommand();
|
|
1219
|
+
const KEY_MODIFIER_COMMAND = createCommand();
|
|
1220
|
+
|
|
1169
1221
|
/**
|
|
1170
1222
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1171
1223
|
*
|
|
@@ -1672,6 +1724,10 @@ function onKeyDown(event, editor) {
|
|
|
1672
1724
|
event.preventDefault();
|
|
1673
1725
|
dispatchCommand(editor, REDO_COMMAND);
|
|
1674
1726
|
}
|
|
1727
|
+
|
|
1728
|
+
if (isModifier(ctrlKey, shiftKey, altKey, metaKey)) {
|
|
1729
|
+
dispatchCommand(editor, KEY_MODIFIER_COMMAND, event);
|
|
1730
|
+
}
|
|
1675
1731
|
}
|
|
1676
1732
|
|
|
1677
1733
|
function getRootElementRemoveHandles(rootElement) {
|
|
@@ -4637,6 +4693,7 @@ class RangeSelection {
|
|
|
4637
4693
|
|
|
4638
4694
|
if (anchor.type === 'text') {
|
|
4639
4695
|
const anchorNode = anchor.getNode();
|
|
4696
|
+
nodesToMove = anchorNode.getNextSiblings().reverse();
|
|
4640
4697
|
currentElement = anchorNode.getParentOrThrow();
|
|
4641
4698
|
const isInline = currentElement.isInline();
|
|
4642
4699
|
const textContentLength = isInline ? currentElement.getTextContentSize() : anchorNode.getTextContentSize();
|
|
@@ -4652,8 +4709,6 @@ class RangeSelection {
|
|
|
4652
4709
|
}
|
|
4653
4710
|
|
|
4654
4711
|
if (anchorOffset !== textContentLength) {
|
|
4655
|
-
nodesToMove = anchorNode.getNextSiblings().reverse();
|
|
4656
|
-
|
|
4657
4712
|
if (!isInline || anchorOffset !== anchorNode.getTextContentSize()) {
|
|
4658
4713
|
const [, splitNode] = anchorNode.splitText(anchorOffset);
|
|
4659
4714
|
nodesToMove.push(splitNode);
|
|
@@ -5479,7 +5534,7 @@ function adjustPointOffsetForMergedSibling(point, isBefore, key, target, textLen
|
|
|
5479
5534
|
*
|
|
5480
5535
|
*
|
|
5481
5536
|
*/
|
|
5482
|
-
function removeNode(nodeToRemove, restoreSelection) {
|
|
5537
|
+
function removeNode(nodeToRemove, restoreSelection, preserveEmptyParent) {
|
|
5483
5538
|
errorOnReadOnly();
|
|
5484
5539
|
const key = nodeToRemove.__key;
|
|
5485
5540
|
const parent = nodeToRemove.getParent();
|
|
@@ -5525,7 +5580,7 @@ function removeNode(nodeToRemove, restoreSelection) {
|
|
|
5525
5580
|
$updateElementSelectionOnCreateDeleteNode(selection, parent, index, -1);
|
|
5526
5581
|
}
|
|
5527
5582
|
|
|
5528
|
-
if (parent !== null && !$isRootNode(parent) && !parent.canBeEmpty() && parent.isEmpty()) {
|
|
5583
|
+
if (!preserveEmptyParent && parent !== null && !$isRootNode(parent) && !parent.canBeEmpty() && parent.isEmpty()) {
|
|
5529
5584
|
removeNode(parent, restoreSelection);
|
|
5530
5585
|
}
|
|
5531
5586
|
|
|
@@ -6077,9 +6132,9 @@ class LexicalNode {
|
|
|
6077
6132
|
} // Setters and mutators
|
|
6078
6133
|
|
|
6079
6134
|
|
|
6080
|
-
remove() {
|
|
6135
|
+
remove(preserveEmptyParent) {
|
|
6081
6136
|
errorOnReadOnly();
|
|
6082
|
-
removeNode(this, true);
|
|
6137
|
+
removeNode(this, true, preserveEmptyParent);
|
|
6083
6138
|
}
|
|
6084
6139
|
|
|
6085
6140
|
replace(replaceWith) {
|
|
@@ -8301,7 +8356,7 @@ class LexicalEditor {
|
|
|
8301
8356
|
*
|
|
8302
8357
|
*
|
|
8303
8358
|
*/
|
|
8304
|
-
const VERSION = '0.2.
|
|
8359
|
+
const VERSION = '0.2.3';
|
|
8305
8360
|
|
|
8306
8361
|
/**
|
|
8307
8362
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -8347,54 +8402,6 @@ function $isGridRowNode(node) {
|
|
|
8347
8402
|
return node instanceof GridRowNode;
|
|
8348
8403
|
}
|
|
8349
8404
|
|
|
8350
|
-
/**
|
|
8351
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8352
|
-
*
|
|
8353
|
-
* This source code is licensed under the MIT license found in the
|
|
8354
|
-
* LICENSE file in the root directory of this source tree.
|
|
8355
|
-
*
|
|
8356
|
-
*
|
|
8357
|
-
*/
|
|
8358
|
-
function createCommand() {
|
|
8359
|
-
// $FlowFixMe: avoid freezing the object for perf reasons
|
|
8360
|
-
return {};
|
|
8361
|
-
}
|
|
8362
|
-
const SELECTION_CHANGE_COMMAND = createCommand();
|
|
8363
|
-
const CLICK_COMMAND = createCommand();
|
|
8364
|
-
const DELETE_CHARACTER_COMMAND = createCommand();
|
|
8365
|
-
const INSERT_LINE_BREAK_COMMAND = createCommand();
|
|
8366
|
-
const INSERT_PARAGRAPH_COMMAND = createCommand();
|
|
8367
|
-
const INSERT_TEXT_COMMAND = createCommand();
|
|
8368
|
-
const PASTE_COMMAND = createCommand();
|
|
8369
|
-
const REMOVE_TEXT_COMMAND = createCommand();
|
|
8370
|
-
const DELETE_WORD_COMMAND = createCommand();
|
|
8371
|
-
const DELETE_LINE_COMMAND = createCommand();
|
|
8372
|
-
const FORMAT_TEXT_COMMAND = createCommand();
|
|
8373
|
-
const UNDO_COMMAND = createCommand();
|
|
8374
|
-
const REDO_COMMAND = createCommand();
|
|
8375
|
-
const KEY_ARROW_RIGHT_COMMAND = createCommand();
|
|
8376
|
-
const KEY_ARROW_LEFT_COMMAND = createCommand();
|
|
8377
|
-
const KEY_ARROW_UP_COMMAND = createCommand();
|
|
8378
|
-
const KEY_ARROW_DOWN_COMMAND = createCommand();
|
|
8379
|
-
const KEY_ENTER_COMMAND = createCommand();
|
|
8380
|
-
const KEY_BACKSPACE_COMMAND = createCommand();
|
|
8381
|
-
const KEY_ESCAPE_COMMAND = createCommand();
|
|
8382
|
-
const KEY_DELETE_COMMAND = createCommand();
|
|
8383
|
-
const KEY_TAB_COMMAND = createCommand();
|
|
8384
|
-
const INDENT_CONTENT_COMMAND = createCommand();
|
|
8385
|
-
const OUTDENT_CONTENT_COMMAND = createCommand();
|
|
8386
|
-
const DROP_COMMAND = createCommand();
|
|
8387
|
-
const FORMAT_ELEMENT_COMMAND = createCommand();
|
|
8388
|
-
const DRAGSTART_COMMAND = createCommand();
|
|
8389
|
-
const COPY_COMMAND = createCommand();
|
|
8390
|
-
const CUT_COMMAND = createCommand();
|
|
8391
|
-
const CLEAR_EDITOR_COMMAND = createCommand();
|
|
8392
|
-
const CLEAR_HISTORY_COMMAND = createCommand();
|
|
8393
|
-
const CAN_REDO_COMMAND = createCommand();
|
|
8394
|
-
const CAN_UNDO_COMMAND = createCommand();
|
|
8395
|
-
const FOCUS_COMMAND = createCommand();
|
|
8396
|
-
const BLUR_COMMAND = createCommand();
|
|
8397
|
-
|
|
8398
8405
|
exports.$createGridSelection = $createEmptyGridSelection;
|
|
8399
8406
|
exports.$createLineBreakNode = $createLineBreakNode;
|
|
8400
8407
|
exports.$createNodeFromParse = $createNodeFromParse;
|
|
@@ -8462,6 +8469,7 @@ exports.KEY_BACKSPACE_COMMAND = KEY_BACKSPACE_COMMAND;
|
|
|
8462
8469
|
exports.KEY_DELETE_COMMAND = KEY_DELETE_COMMAND;
|
|
8463
8470
|
exports.KEY_ENTER_COMMAND = KEY_ENTER_COMMAND;
|
|
8464
8471
|
exports.KEY_ESCAPE_COMMAND = KEY_ESCAPE_COMMAND;
|
|
8472
|
+
exports.KEY_MODIFIER_COMMAND = KEY_MODIFIER_COMMAND;
|
|
8465
8473
|
exports.KEY_TAB_COMMAND = KEY_TAB_COMMAND;
|
|
8466
8474
|
exports.OUTDENT_CONTENT_COMMAND = OUTDENT_CONTENT_COMMAND;
|
|
8467
8475
|
exports.PASTE_COMMAND = PASTE_COMMAND;
|
package/Lexical.js.flow
CHANGED
|
@@ -35,6 +35,7 @@ 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>;
|
|
37
37
|
declare export var KEY_TAB_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
38
|
+
declare export var KEY_MODIFIER_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
38
39
|
declare export var INDENT_CONTENT_COMMAND: LexicalCommand<void>;
|
|
39
40
|
declare export var OUTDENT_CONTENT_COMMAND: LexicalCommand<void>;
|
|
40
41
|
declare export var DROP_COMMAND: LexicalCommand<DragEvent>;
|
|
@@ -369,7 +370,7 @@ declare export class LexicalNode {
|
|
|
369
370
|
dom: HTMLElement,
|
|
370
371
|
config: EditorConfig<EditorContext>,
|
|
371
372
|
): boolean;
|
|
372
|
-
remove(): void;
|
|
373
|
+
remove(preserveEmptyParent?: boolean): void;
|
|
373
374
|
replace<N: LexicalNode>(replaceWith: N): N;
|
|
374
375
|
insertAfter(nodeToInsert: LexicalNode): LexicalNode;
|
|
375
376
|
insertBefore(nodeToInsert: LexicalNode): LexicalNode;
|
package/Lexical.prod.js
CHANGED
|
@@ -25,59 +25,59 @@ function $a(a,b){const c=a.mergeWithSibling(b),d=B()._normalizedNodes;d.add(a.__
|
|
|
25
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
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}
|
|
28
|
-
const N=Object.freeze({}),
|
|
29
|
-
function
|
|
30
|
-
function
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
function
|
|
36
|
-
function
|
|
37
|
-
function
|
|
38
|
-
(r?g:f)?(a.preventDefault(),
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
g)})}}let Q="",R="",
|
|
42
|
-
function
|
|
43
|
-
function
|
|
44
|
-
w(d)&&(d.isDirectionless()||(R+=e),d.isInert()&&(a=f.style,a.pointerEvents="none",a.userSelect="none",f.contentEditable="false",a.setProperty("-webkit-user-select","none"))),Q+=e,
|
|
45
|
-
function
|
|
46
|
-
function
|
|
28
|
+
const eb={},fb={},gb={},hb={},ib={},N={},jb={},kb={},lb={},mb={},O={},nb={},ob={},pb={},qb={},rb={},sb={},tb={},ub={},vb={},wb={},xb={},yb={},zb={},Ab={},Bb={},Cb={},Db={},Eb={},Fb=Object.freeze({}),Lb=[["keydown",Gb],["compositionstart",Hb],["compositionend",Ib],["input",Jb],["click",Kb],["cut",Fb],["copy",Fb],["dragstart",Fb],["paste",Fb],["focus",Fb],["blur",Fb]];la?Lb.push(["beforeinput",Mb]):Lb.push(["drop",Fb]);let Nb=0,Ob=0,Pb=!1;
|
|
29
|
+
function Qb(a,b,c){if(Pb){Pb=!1;const {anchorNode:d,focusNode:f}=a;if(null!==d&&null!==f&&3===d.nodeType&&3===f.nodeType)return}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)}P(b,eb,void 0)}else Ia(null)})}
|
|
30
|
+
function Kb(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))}P(b,fb,a)})}function Rb(a,b){b.getTargetRanges&&(b=b.getTargetRanges()[0])&&a.applyDOMRange(b)}function Sb(a,b){return a!==b||C(a)||C(b)||!v(a)||!v(b)}
|
|
31
|
+
function Mb(a,b){const c=a.inputType;if(!("deleteCompositionText"===c||ka&&Ta()))if("insertCompositionText"===c){const d=a.data;d&&I(b,()=>{var f=K();if(J(f)){const e=f.anchor,g=e.getNode(),h=g.getPreviousSibling();0===e.offset&&w(g)&&w(h)&&" "===g.getTextContent()&&h.getFormat()!==f.format&&(f=h.getTextContent(),0===d.indexOf(f)&&(f=d.slice(f.length),P(b,N,f),setTimeout(()=>{I(b,()=>{g.select()})},30)))}})}else I(b,()=>{const d=K();if(J(d))if("deleteContentBackward"===c)D(null),a.preventDefault(),
|
|
32
|
+
Nb=0,P(b,gb,!0),setTimeout(()=>{b.update(()=>{D(null)})},30);else{var f=a.data;d.dirty||!d.isCollapsed()||M(d.anchor.getNode())||Rb(d,a);var e=d.focus,g=d.anchor.getNode();e=e.getNode();if("insertText"===c)"\n"===f?(a.preventDefault(),P(b,hb,void 0)):"\n\n"===f?(a.preventDefault(),P(b,ib,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(),P(b,N,f));else switch(a.preventDefault(),c){case "insertFromYank":case "insertFromDrop":case "insertReplacementText":P(b,
|
|
33
|
+
N,a);break;case "insertFromComposition":D(null);P(b,N,a);break;case "insertLineBreak":D(null);P(b,hb,void 0);break;case "insertParagraph":D(null);P(b,ib,void 0);break;case "insertFromPaste":case "insertFromPasteAsQuotation":P(b,jb,a);break;case "deleteByComposition":Sb(g,e)&&P(b,kb,void 0);break;case "deleteByDrag":case "deleteByCut":P(b,kb,void 0);break;case "deleteContent":P(b,gb,!1);break;case "deleteWordBackward":P(b,lb,!0);break;case "deleteWordForward":P(b,lb,!1);break;case "deleteHardLineBackward":case "deleteSoftLineBackward":P(b,
|
|
34
|
+
mb,!0);break;case "deleteContentForward":case "deleteHardLineForward":case "deleteSoftLineForward":P(b,mb,!1);break;case "formatStrikeThrough":P(b,O,"strikethrough");break;case "formatBold":P(b,O,"bold");break;case "formatItalic":P(b,O,"italic");break;case "formatUnderline":P(b,O,"underline");break;case "historyUndo":P(b,nb,void 0);break;case "historyRedo":P(b,ob,void 0)}}})}
|
|
35
|
+
function Jb(a,b){a.stopPropagation();I(b,()=>{var c=K();const d=a.data;null!=d&&J(c)&&Oa(c,d,!1)?(P(b,N,d),null!==b._compositionKey&&(Nb=0,D(null))):La(b,null);F();c=B();Tb(c)})}function Hb(a,b){I(b,()=>{const c=K();if(J(c)&&!b.isComposing()){const d=c.anchor;D(d.key);(a.timeStamp<Nb+30||"element"===d.type||!c.isCollapsed()||c.anchor.getNode().getFormat()!==c.format)&&P(b,N," ")}})}
|
|
36
|
+
function Ib(a,b){I(b,()=>{var c=b._compositionKey;D(null);var d=a.data;if(null!==c&&null!=d){if(""===d){d=G(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);P(b,tb,null);return}}La(b,a)})}
|
|
37
|
+
function Gb(a,b){Nb=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)P(b,tb,a);else if(r&&f&&79===c)a.preventDefault(),P(b,hb,!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?P(b,ub,a):(a.preventDefault(),P(b,gb,!0)):27===c?P(b,vb,a):(h=r?d||g||e?!1:46===c||68===c&&f:f||g||e?!1:46===c,h?46===c?P(b,wb,a):(a.preventDefault(),P(b,gb,!1)):8===c&&
|
|
38
|
+
(r?g:f)?(a.preventDefault(),P(b,lb,!0)):46===c&&(r?g:f)?(a.preventDefault(),P(b,lb,!1)):r&&e&&8===c?(a.preventDefault(),P(b,mb,!0)):r&&e&&46===c?(a.preventDefault(),P(b,mb,!1)):66===c&&!g&&(r?e:f)?(a.preventDefault(),P(b,O,"bold")):85===c&&!g&&(r?e:f)?(a.preventDefault(),P(b,O,"underline")):73===c&&!g&&(r?e:f)?(a.preventDefault(),P(b,O,"italic")):9!==c||g||f||e?90===c&&!d&&(r?e:f)?(a.preventDefault(),P(b,nb,void 0)):(h=r?90===c&&e&&d:89===c&&f||90===c&&f&&d,h&&(a.preventDefault(),P(b,ob,void 0))):
|
|
39
|
+
P(b,xb,a))}else P(b,tb,a);else P(b,sb,a);else P(b,rb,a);else P(b,qb,a);else P(b,pb,a);(f||d||g||e)&&P(b,Eb,a)}}function Ub(a){let b=a.__lexicalEventHandles;void 0===b&&(b=[],a.__lexicalEventHandles=b);return b}const Vb=new Map;function Wb(){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=Vb.get(d),e=f||c;e!==b&&Qb(a,e,!1);Qb(a,b,!0);b!==c?Vb.set(d,b):f&&Vb.delete(d)}}
|
|
40
|
+
function Xb(a,b){0===Ob&&a.ownerDocument.addEventListener("selectionchange",Wb);Ob++;a.__lexicalEditor=b;const c=Ub(a);for(let d=0;d<Lb.length;d++){const [f,e]=Lb[d],g="function"===typeof e?h=>{b.isReadOnly()||e(h,b)}:h=>{if(!b.isReadOnly())switch(f){case "cut":return P(b,Bb,h);case "copy":return P(b,Ab,h);case "paste":return P(b,jb,h);case "dragstart":return P(b,zb,h);case "focus":return P(b,Cb,h);case "blur":return P(b,Db,h);case "drop":return P(b,yb,h)}};a.addEventListener(f,g);c.push(()=>{a.removeEventListener(f,
|
|
41
|
+
g)})}}let Q="",R="",Yb="",Zb,T,$b,ac=!1,bc=!1,cc,dc=null,ec,fc,gc,hc,ic,jc;function kc(a,b){const c=gc.get(a);if(null!==b){const d=lc(a);b.removeChild(d)}hc.has(a)||T._keyToDOMMap.delete(a);C(c)&&(a=c.__children,mc(a,0,a.length-1,null));void 0!==c&&Qa(jc,$b,cc,c,"destroyed")}function mc(a,b,c,d){for(;b<=c;++b){const f=a[b];void 0!==f&&kc(f,d)}}function nc(a,b){a.setProperty("text-align",b)}function oc(a,b){a.style.setProperty("padding-inline-start",0===b?"":40*b+"px")}
|
|
42
|
+
function pc(a,b){a=a.style;0===b?nc(a,""):1===b?nc(a,"left"):2===b?nc(a,"center"):3===b?nc(a,"right"):4===b&&nc(a,"justify")}
|
|
43
|
+
function qc(a,b,c){const d=hc.get(a);void 0===d&&q(42);const f=d.createDOM(Zb,T);var e=T._keyToDOMMap;f["__lexicalKey_"+T._key]=a;e.set(a,f);w(d)?f.setAttribute("data-lexical-text","true"):t(d)&&f.setAttribute("data-lexical-decorator","true");if(C(d)){a=d.__indent;0!==a&&oc(f,a);a=d.__children;var g=a.length;if(0!==g){e=a;--g;const h=R;R="";rc(e,0,g,f,null);sc(d,f);R=h}e=d.__format;0!==e&&pc(f,e);tc(null,a,f)}else e=d.getTextContent(),t(d)?(g=d.decorate(T),null!==g&&uc(a,g),f.contentEditable="false"):
|
|
44
|
+
w(d)&&(d.isDirectionless()||(R+=e),d.isInert()&&(a=f.style,a.pointerEvents="none",a.userSelect="none",f.contentEditable="false",a.setProperty("-webkit-user-select","none"))),Q+=e,Yb+=e;null!==b&&(null!=c?b.insertBefore(f,c):(c=b.__lexicalLineBreak,null!=c?b.insertBefore(f,c):b.appendChild(f)));Qa(jc,$b,cc,d,"created");return f}function rc(a,b,c,d,f){const e=Q;for(Q="";b<=c;++b)qc(a[b],d,f);d.__lexicalTextContent=Q;Q=e+Q}function vc(a,b){a=b.get(a[a.length-1]);return xa(a)||t(a)}
|
|
45
|
+
function tc(a,b,c){a=null!==a&&(0===a.length||vc(a,gc));b=null!==b&&(0===b.length||vc(b,hc));a?b||(b=c.__lexicalLineBreak,null!=b&&c.removeChild(b),c.__lexicalLineBreak=null):b&&(b=document.createElement("br"),c.__lexicalLineBreak=b,c.appendChild(b))}
|
|
46
|
+
function sc(a,b){var c=b.__lexicalDir;if(b.__lexicalDirTextContent!==R||c!==dc){const e=""===R;if(e)var d=dc;else d=R,d=aa.test(d)?"rtl":ba.test(d)?"ltr":null;if(d!==c){const g=b.classList,h=Zb.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);bc||(a.getWritable().__dir=d)}dc=d;b.__lexicalDirTextContent=
|
|
47
47
|
R;b.__lexicalDir=d}}
|
|
48
|
-
function
|
|
49
|
-
a),a=d.__format,a!==c.__format&&
|
|
50
|
-
|
|
51
|
-
!d.isDirectionless()&&(R+=c),Q+=c,
|
|
52
|
-
function
|
|
53
|
-
function
|
|
54
|
-
g&&void 0!==g&&g.__key!==f&&g.isAttached()&&
|
|
55
|
-
function
|
|
56
|
-
b._readOnly;
|
|
57
|
-
E.offset;f=H;x=W;"text"===y.type&&(f=ua(H));"text"===E.type&&(x=ua(W));if(null!==f&&null!==x)if(
|
|
58
|
-
|
|
59
|
-
new Set,a._dirtyElements=new Map,a._normalizedNodes=new Set,a._updateTags=new Set);g=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,
|
|
60
|
-
a._updating=!0;try{for(S=0;S<b.length;S++)b[S]()}finally{a._updating=d}}b=a._updates;if(0!==b.length){const [na,Xa]=b.shift();
|
|
61
|
-
function
|
|
62
|
-
function
|
|
63
|
-
(e._flushSync=!0);const u=e._selection;if(J(u)){const p=e._nodeMap,A=u.focus.key;void 0!==p.get(u.anchor.key)&&void 0!==p.get(A)||q(30)}else
|
|
64
|
-
a._pendingEditorState=null))}function I(a,b,c){a._updating?a._updates.push([b,c]):
|
|
65
|
-
function
|
|
66
|
-
null==x||null!==E||"BR"===y.nodeName&&
|
|
67
|
-
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++)u=g[p],m=u.parentNode,null==m||"BR"!==u.nodeName||
|
|
68
|
-
function
|
|
69
|
-
class
|
|
70
|
-
c;X||(B()._compositionKey===f&&D(a),null===d||d.anchor!==this&&d.focus!==this||(d.dirty=!0))}}function Y(a,b,c){return new
|
|
71
|
-
function
|
|
72
|
-
class
|
|
73
|
-
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
|
|
74
|
-
class
|
|
75
|
-
G(this.anchorCellKey);a||q(74);var b=a.getIndexWithinParent();a=a.getParentOrThrow().getIndexWithinParent();var c=G(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=G(this.gridKey);
|
|
76
|
-
for(let l=c;l<=f;l++){var g=e[l];a.add(g);
|
|
77
|
-
class
|
|
48
|
+
function wc(a,b){var c=gc.get(a),d=hc.get(a);void 0!==c&&void 0!==d||q(43);var f=ac||fc.has(a)||ec.has(a);const e=xc(T,a);if(c===d&&!f)return C(c)?(d=e.__lexicalTextContent,void 0!==d&&(Q+=d,Yb+=d),d=e.__lexicalDirTextContent,void 0!==d&&(R+=d)):(d=c.getTextContent(),w(c)&&!c.isDirectionless()&&(R+=d),Yb+=d,Q+=d),e;c!==d&&f&&Qa(jc,$b,cc,d,"updated");if(d.updateDOM(c,e,Zb))return d=qc(a,null,null),null===b&&q(44),b.replaceChild(d,e),kc(a,null),d;if(C(c)&&C(d)){if(a=d.__indent,a!==c.__indent&&oc(e,
|
|
49
|
+
a),a=d.__format,a!==c.__format&&pc(e,a),a=c.__children,c=d.__children,a!==c||f){var g=a,h=c;f=d;b=R;R="";const p=Q;Q="";var l=g.length,k=h.length;if(1===l&&1===k){var m=g[0];h=h[0];if(m===h)wc(m,e);else{var n=lc(m);h=qc(h,null,null);e.replaceChild(h,n);kc(m,null)}}else if(0===l)0!==k&&rc(h,0,k-1,e,null);else if(0===k)0!==l&&(m=null==e.__lexicalLineBreak,mc(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 u=g[E];const x=h[k];if(u===x)y=
|
|
50
|
+
wc(x,e).nextSibling,E++,k++;else{void 0===m&&(m=new Set(g));void 0===n&&(n=new Set(h));const H=n.has(u),W=m.has(x);H?(W?(u=xc(T,x),u===y?y=wc(x,e).nextSibling:(null!=y?e.insertBefore(u,y):e.appendChild(u),wc(x,e)),E++):qc(x,e,y),k++):(y=lc(u).nextSibling,kc(u,e),E++)}}m=E>A;n=k>l;m&&!n?(m=h[l+1],m=void 0===m?null:T.getElementByKey(m),rc(h,k,l,e,m)):n&&!m&&mc(g,E,A,e)}e.__lexicalTextContent=Q;Q=p+Q;sc(f,e);R=b;M(d)||tc(a,c,e)}}else c=d.getTextContent(),t(d)?(f=d.decorate(T),null!==f&&uc(a,f)):w(d)&&
|
|
51
|
+
!d.isDirectionless()&&(R+=c),Q+=c,Yb+=c;!bc&&M(d)&&d.__cachedText!==Yb&&(d=d.getWritable(),d.__cachedText=Yb);return e}function uc(a,b){let c=T._pendingDecorators;const d=T._decorators;if(null===c){if(d[a]===b)return;c=Ea(T)}c[a]=b}function lc(a){a=ic.get(a);void 0===a&&q(45);return a}function xc(a,b){a=a._keyToDOMMap.get(b);void 0===a&&q(45);return a}let U=null,V=null,X=!1,yc=!1,Ba=0;function F(){X&&q(25)}function z(){null===U&&q(27);return U}function B(){null===V&&q(28);return V}
|
|
52
|
+
function zc(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 Ac(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)}
|
|
53
|
+
function Bc(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()&&zc(b,g,e),c.add(m);g=b._dirtyLeaves;h=g.size;if(0<h){Ba++;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!==
|
|
54
|
+
g&&void 0!==g&&g.__key!==f&&g.isAttached()&&zc(b,g,e),d.set(l,k));g=b._dirtyLeaves;h=g.size;l=b._dirtyElements;k=l.size;Ba++}b._dirtyLeaves=c;b._dirtyElements=d}function db(a,b){var c=new Map;c=new Cc(c);const d={originalSelection:a._selection},f=U,e=X,g=V;U=c;X=!1;V=b;try{const h=new Map(a._nodeMap),l=h.get("root");bb(l,h,b,null,d)}finally{U=f,X=e,V=g}c._selection=Dc(d.remappedSelection||d.originalSelection);return c}
|
|
55
|
+
function Ec(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=U,l=X,k=V,m=a._updating;V=a;U=b;X=!1;a._updating=!0;try{var n=a._observer;let na=null;if(g&&null!==n){var u=a._dirtyType,p=a._dirtyElements,A=a._dirtyLeaves;n.disconnect();try{R=Yb=Q="";ac=2===u;dc=null;T=a;Zb=a._config;$b=a._nodes;cc=T._listeners.mutation;ec=p;fc=A;gc=d._nodeMap;hc=b._nodeMap;bc=
|
|
56
|
+
b._readOnly;ic=new Map(a._keyToDOMMap);const Ca=new Map;jc=Ca;wc("root",null);jc=ic=Zb=hc=gc=fc=ec=$b=T=void 0;na=Ca}finally{n.observe(c,{characterData:!0,childList:!0,subtree:!0})}}const Xa=window.getSelection();if(null!==Xa&&(g||null===e||e.dirty)){n=Xa;const Ca=n.anchorNode,Ic=n.focusNode,Ed=n.anchorOffset,Fd=n.focusOffset,Ya=document.activeElement,da=a._rootElement;if(!a._updateTags.has("collaboration")||Ya===da)if(J(e)){var y=e.anchor,E=e.focus,x=E.key,H=xc(a,y.key),W=xc(a,x),Jc=y.offset,Kc=
|
|
57
|
+
E.offset;f=H;x=W;"text"===y.type&&(f=ua(H));"text"===E.type&&(x=ua(W));if(null!==f&&null!==x)if(Ed!==Jc||Fd!==Kc||Ca!==f||Ic!==x||"Range"===n.type&&e.isCollapsed())try{n.setBaseAndExtent(f,Jc,x,Kc);if(e.isCollapsed()&&da===Ya){const ea=3===f.nodeType?f.parentNode:f;if(null!==ea){const Za=ea.getBoundingClientRect();if(Za.bottom>window.innerHeight)ea.scrollIntoView(!1);else if(0>Za.top)ea.scrollIntoView();else if(da){const Lc=da.getBoundingClientRect();Za.bottom>Lc.bottom?ea.scrollIntoView(!1):Za.top<
|
|
58
|
+
Lc.top&&ea.scrollIntoView()}a._updateTags.add("scroll-into-view")}}Pb=!0}catch(ea){}else null===da||null!==Ya&&da.contains(Ya)||da.focus({preventScroll:!0})}else null!==f&&ra(a,Ca,Ic)&&n.removeAllRanges()}var Mc=na;null!==Mc&&Fc(a,d,b,Mc)}catch(na){a._onError(na);yc||(Gc(a,null,c,b),Hc(a),a._dirtyType=2,yc=!0,Ec(a),yc=!1);return}finally{a._updating=m,U=h,X=l,V=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=
|
|
59
|
+
new Set,a._dirtyElements=new Map,a._normalizedNodes=new Set,a._updateTags=new Set);g=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,Nc("decorator",a,!0,S));S=Fa(d);g=Fa(b);S!==g&&Nc("textcontent",a,!0,g);Nc("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;
|
|
60
|
+
a._updating=!0;try{for(S=0;S<b.length;S++)b[S]()}finally{a._updating=d}}b=a._updates;if(0!==b.length){const [na,Xa]=b.shift();Oc(a,na,Xa)}}}function Fc(a,b,c,d){a._listeners.mutation.forEach((f,e)=>{f=d.get(f);void 0!==f&&e(f)})}function Nc(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}}
|
|
61
|
+
function P(a,b,c){if(!1===a._updating||V!==a){let e=!1;a.update(()=>{e=P(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 Pc(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}
|
|
62
|
+
function Oc(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 Cc(new Map(c._nodeMap)),g=!0);const h=U,l=X,k=V,m=a._updating;U=e;X=!1;a._updating=!0;V=a;try{g&&(e._selection=Qc(a));const n=a._compositionKey;b();f=Pc(a);Rc(e,a);0!==a._dirtyType&&(f?Ac(e,a):Bc(e,a),Pc(a),Va(c,e,a._dirtyLeaves,a._dirtyElements));n!==a._compositionKey&&
|
|
63
|
+
(e._flushSync=!0);const u=e._selection;if(J(u)){const p=e._nodeMap,A=u.focus.key;void 0!==p.get(u.anchor.key)&&void 0!==p.get(A)||q(30)}else Sc(u)&&0===u._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();Ec(a);return}finally{U=h,X=l,V=k,a._updating=m,Ba=0}0!==a._dirtyType||Tc(e,a)?e._flushSync?(e._flushSync=!1,Ec(a)):g&&qa(()=>{Ec(a)}):(e._flushSync=!1,g&&(d.clear(),a._deferred=[],
|
|
64
|
+
a._pendingEditorState=null))}function I(a,b,c){a._updating?a._updates.push([b,c]):Oc(a,b,c)}let Uc=!1,Vc=0;function Wc(a){Vc=a.timeStamp}function Xc(a,b,c){return b.__lexicalLineBreak===a||void 0!==a["__lexicalKey_"+c._key]}function Yc(a){return a.getEditorState().read(()=>{const b=K();return null!==b?b.clone():null})}
|
|
65
|
+
function Zc(a,b,c){Uc=!0;const d=100<performance.now()-Vc;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,u=m.target,p=sa(u,g);if(!t(p))if("characterData"===n){if(d&&3===u.nodeType&&w(p)&&p.isAttached()){m=window.getSelection();var A=n=null;null!==m&&m.anchorNode===u&&(n=m.anchorOffset,A=m.focusOffset);Ma(p,u.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;
|
|
66
|
+
null==x||null!==E||"BR"===y.nodeName&&Xc(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&&Xc(x,u,a)&&(u.appendChild(x),A++);n!==A&&(u===e&&(p=g._nodeMap.get("root")),f.set(u,p))}}}if(0<f.size)for(const [H,W]of f)if(C(W))for(f=W.__children,e=H.firstChild,g=0;g<f.length;g++)k=a.getElementByKey(f[g]),null!==k&&(null==e?(H.appendChild(k),e=k):e!==k&&H.replaceChild(k,e),e=e.nextSibling);else w(W)&&W.markDirty();
|
|
67
|
+
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++)u=g[p],m=u.parentNode,null==m||"BR"!==u.nodeName||Xc(u,k,a)||m.removeChild(u);c.takeRecords()}f=K()||Yc(a);null!==f&&(h&&(f.dirty=!0,Ia(f)),ka&&Ta()&&f.insertRawText(l))})}finally{Uc=!1}}function Tb(a){const b=a._observer;if(null!==b){const c=b.takeRecords();Zc(a,c,b)}}
|
|
68
|
+
function Hc(a){0===Vc&&window.addEventListener("textInput",Wc,!0);a._observer=new MutationObserver((b,c)=>{Zc(a,b,c)})}
|
|
69
|
+
class $c{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=G(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=
|
|
70
|
+
c;X||(B()._compositionKey===f&&D(a),null===d||d.anchor!==this&&d.focus!==this||(d.dirty=!0))}}function Y(a,b,c){return new $c(a,b,c)}function ad(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 bd(a,b){if(C(b)){const c=b.getLastDescendant();C(c)||w(c)?ad(a,c):ad(a,b)}else w(b)&&ad(a,b)}
|
|
71
|
+
function cd(a,b,c){const d=a.getNode(),f=d.getChildAtIndex(a.offset),e=L(),g=M(d)?dd().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 Z(a,b,c,d){a.key=b;a.offset=c;a.type=d}
|
|
72
|
+
class ed{constructor(a){this.dirty=!1;this._nodes=a}is(a){if(!Sc(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 ed(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(){}insertText(){}getNodes(){var a=this._nodes;const b=[];for(const c of a)a=G(c),null!==
|
|
73
|
+
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 fd}
|
|
74
|
+
class gd{constructor(a,b,c){this.gridKey=a;this.anchorCellKey=b;this.anchor=Y(b,0,"element");this.focusCellKey=c;this.focus=Y(c,0,"element");this.dirty=!1}is(a){return hd(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 gd(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=
|
|
75
|
+
G(this.anchorCellKey);a||q(74);var b=a.getIndexWithinParent();a=a.getParentOrThrow().getIndexWithinParent();var c=G(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=G(this.gridKey);id(e)||q(76);a.add(e);e=e.getChildren();
|
|
76
|
+
for(let l=c;l<=f;l++){var g=e[l];a.add(g);jd(g)||q(77);g=g.getChildren();for(let k=b;k<=d;k++){var h=g[k];kd(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 hd(a){return a instanceof gd}
|
|
77
|
+
class fd{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,
|
|
78
78
|
b,c,d){Z(this.anchor,a.__key,b,"text");Z(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):
|
|
79
|
-
k===c&&(m=e?m.slice(0,f):m.slice(0,d));g+=m}else!t(k)&&!xa(k)||k===c&&this.isCollapsed()||(g+=k.getTextContent())}return g}applyDOMRange(a){const b=B(),c=b.getEditorState()._selection;a=
|
|
80
|
-
a,null);this.dirty=!0}hasFormat(a){return 0!==(this.format&ca[a])}insertRawText(a){const b=a.split(/\r?\n/);if(1===b.length)this.insertText(a);else{a=[];const c=b.length;for(let d=0;d<c;d++){const f=b[d];""!==f&&a.push(L(f));d!==c-1&&a.push(
|
|
79
|
+
k===c&&(m=e?m.slice(0,f):m.slice(0,d));g+=m}else!t(k)&&!xa(k)||k===c&&this.isCollapsed()||(g+=k.getTextContent())}return g}applyDOMRange(a){const b=B(),c=b.getEditorState()._selection;a=ld(a.startContainer,a.startOffset,a.endContainer,a.endOffset,b,c);if(null!==a){var [d,f]=a;Z(this.anchor,d.key,d.offset,d.type);Z(this.focus,f.key,f.offset,f.type)}}clone(){const a=this.anchor,b=this.focus;return new fd(Y(a.key,a.offset,a.type),Y(b.key,b.offset,b.type),this.format)}toggleFormat(a){this.format=va(this.format,
|
|
80
|
+
a,null);this.dirty=!0}hasFormat(a){return 0!==(this.format&ca[a])}insertRawText(a){const b=a.split(/\r?\n/);if(1===b.length)this.insertText(a);else{a=[];const c=b.length;for(let d=0;d<c;d++){const f=b[d];""!==f&&a.push(L(f));d!==c-1&&a.push(md())}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?cd(b,c,f):d||"element"!==c.type||cd(c,b,f);var e=this.getNodes(),g=e.length,h=d?c:b;c=(d?b:c).offset;var l=h.offset;
|
|
81
81
|
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();
|
|
82
82
|
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-=
|
|
83
83
|
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,
|
|
@@ -88,81 +88,81 @@ f.splitText(m)),f.setFormat(e))),k=1;k<c;k++)m=b[k],g=m.__key,w(m)&&g!==d.__key&
|
|
|
88
88
|
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 u=0;u<a.length;u++){const p=a[u];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();
|
|
89
89
|
k=!0;if(m.is(p))continue}}w(e)&&(null===h&&q(69),e=h)}else k&&!t(p)&&M(e.getParent())&&q(7);k=!1;if(C(e))if(f=p,t(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)||t(e)&&e.isTopLevel()?(f=p,e=e.insertAfter(p)):(e=p.getParentOrThrow(),u--)}b&&(w(l)?l.select():(a=e.getPreviousSibling(),w(a)?a.select():
|
|
90
90
|
(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()+
|
|
91
|
-
1,c.select(e,e)));return!0}insertParagraph(){this.isCollapsed()||this.removeText();var a=this.anchor,b=a.offset,c=[]
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
function
|
|
91
|
+
1,c.select(e,e)));return!0}insertParagraph(){this.isCollapsed()||this.removeText();var a=this.anchor,b=a.offset,c=[];if("text"===a.type){var d=a.getNode();var f=d.getNextSiblings().reverse();var e=d.getParentOrThrow();var g=e.isInline(),h=g?e.getTextContentSize():d.getTextContentSize();0===b?f.push(d):(g&&(c=e.getNextSiblings()),b===h||g&&b===d.getTextContentSize()||([,d]=d.splitText(b),f.push(d)))}else{e=a.getNode();if(M(e)){f=dd();c=e.getChildAtIndex(b);f.select();null!==c?c.insertBefore(f):e.append(f);
|
|
92
|
+
return}f=e.getChildren().slice(b).reverse()}d=f.length;if(0===b&&0<d&&e.isInline())e.getParentOrThrow().insertBefore(dd());else if(g=e.insertNewAfter(this),null===g)this.insertLineBreak();else if(C(g))if(h=e.getFirstChild(),0===b&&(e.is(a.getNode())||h&&h.is(a.getNode()))&&0<d)e.insertBefore(g);else{e=null;b=c.length;a=g.getParentOrThrow();if(0<b)for(h=0;h<b;h++)a.append(c[h]);if(0!==d)for(c=0;c<d;c++)b=f[c],null===e?g.append(b):e.insertBefore(b),e=b;g.canBeEmpty()||0!==g.getChildrenSize()?g.selectStart():
|
|
93
|
+
(g.selectPrevious(),g.remove())}}insertLineBreak(a){const b=md();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;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);
|
|
94
|
+
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(t(g)&&!g.isIsolated()){var h=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");
|
|
95
|
+
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,Z(b,e.key,e.offset,e.type),Z(e,d,f,h)))}deleteCharacter(a){if(this.isCollapsed()){var b=this.anchor,c=this.focus,d=b.getNode();if(!a&&("element"===b.type&&b.offset===d.getChildrenSize()||"text"===b.type&&b.offset===d.getTextContentSize())&&(d=d.getNextSibling()||
|
|
96
|
+
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){nd(f,a,b);return}}else if(null!==d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(f)||a&&0!==b||!a&&b!==c)){nd(d,a,b);return}d=this.anchor;f=this.focus;b=d.getNode();c=f.getNode();
|
|
97
|
+
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()&&this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");
|
|
98
|
+
this.removeText()}}function Sc(a){return a instanceof ed}function nd(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))}
|
|
99
|
+
function od(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(),
|
|
100
100
|
d=0===b&&t(e)&&Ja(a)===e?d:d+1,e=e.getParentOrThrow();if(C(e))return Y(e.__key,d,"element")}}else f=Ja(a);return w(f)?Y(f.__key,d,"text"):null}
|
|
101
|
-
function
|
|
102
|
-
0));f.isComposing()&&f._compositionKey!==a.key&&J(e)&&(f=e.anchor,e=e.focus,Z(a,f.key,f.offset,f.type),Z(c,e.key,e.offset,e.type))}return[a,c]}function
|
|
103
|
-
function
|
|
104
|
-
function K(){return z()._selection}function Na(){return B()._editorState._selection}function
|
|
105
|
-
function
|
|
106
|
-
function
|
|
107
|
-
1):g.getChildAtIndex(f),w(f)&&(g=0,b&&(g=f.getTextContentSize()),d.set(f.__key,g,"text")))}}function
|
|
108
|
-
function
|
|
109
|
-
function
|
|
110
|
-
function
|
|
111
|
-
class
|
|
101
|
+
function ld(a,b,c,d,f,e){if(null===a||null===c||!ra(f,a,c))return null;a=od(a,b,J(e)?e.anchor:null);if(null===a)return null;c=od(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=
|
|
102
|
+
0));f.isComposing()&&f._compositionKey!==a.key&&J(e)&&(f=e.anchor,e=e.focus,Z(a,f.key,f.offset,f.type),Z(c,e.key,e.offset,e.type))}return[a,c]}function pd(a,b,c,d,f,e){const g=z();a=new fd(Y(a,b,f),Y(c,d,e),0);a.dirty=!0;return g._selection=a}
|
|
103
|
+
function Qc(a){var b=a.getEditorState()._selection,c=window.getSelection();if(Sc(b)||hd(b))return b.clone();{var d=(d=window.event)&&d.type;d=!Uc&&("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=ld(d,h,g,c,a,b),null===a)b=null;else{var [f,e]=a;b=new fd(f,e,J(b)?b.format:0)}else b=b.clone()}return b}
|
|
104
|
+
function K(){return z()._selection}function Na(){return B()._editorState._selection}function Dc(a){if(null!==a){if("range"===a.type)return new fd(Y(a.anchor.key,a.anchor.offset,a.anchor.type),Y(a.focus.key,a.focus.offset,a.focus.type),0);if("node"===a.type)return new ed(new Set(a.nodes));if("grid"===a.type)return new gd(a.gridKey,a.anchorCellKey,a.focusCellKey)}return null}
|
|
105
|
+
function qd(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"),rd(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"));rd(a)}}
|
|
106
|
+
function rd(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-
|
|
107
|
+
1):g.getChildAtIndex(f),w(f)&&(g=0,b&&(g=f.getTextContentSize()),d.set(f.__key,g,"text")))}}function Rc(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))}}
|
|
108
|
+
function sd(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 td(a,b,c,d,f){"text"===a.type?(a.key=c,b||(a.offset+=f)):a.offset>d.getIndexWithinParent()&&--a.offset}
|
|
109
|
+
function ud(a,b,c){F();var d=a.__key;const f=a.getParent();if(null!==f){var e=K(),g=!1;if(J(e)&&b){var h=e.anchor;const l=e.focus;h.key===d&&(sd(h,a,f,a.getPreviousSibling(),a.getNextSibling()),g=!0);l.key===d&&(sd(l,a,f,a.getPreviousSibling(),a.getNextSibling()),g=!0)}h=f.getWritable().__children;d=h.indexOf(d);-1===d&&q(16);za(a);h.splice(d,1);a.getWritable().__parent=null;J(e)&&b&&!g&&qd(e,f,d,-1);c||null===f||M(f)||f.canBeEmpty()||!f.isEmpty()||ud(f,b);null!==f&&M(f)&&f.isEmpty()&&f.selectEnd()}}
|
|
110
|
+
function vd(a){const b=G(a);null===b&&q(39,a);return b}
|
|
111
|
+
class wd{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<Ba&&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=G(a);if(null===a)break;a=a.__parent}return!1}isSelected(){const a=
|
|
112
112
|
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:G(a)}getParentOrThrow(){const a=this.getParent();null===a&&q(33,this.__key);return a}getTopLevelElement(){let a=
|
|
113
113
|
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>=
|
|
114
|
-
b?null:G(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=>
|
|
114
|
+
b?null:G(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=>vd(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:G(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=>vd(c))}getCommonAncestor(a){const b=this.getParents();var c=
|
|
115
115
|
a.getParents();C(this)&&b.unshift(this);C(a)&&c.unshift(a);a=b.length;var d=c.length;if(0===a||0===d||b[a-1]!==c[d-1])return null;c=new Set(c);for(d=0;d<a;d++){const f=b[d];if(c.has(f))return f}return null}is(a){return null==a?!1:this.__key===a.__key}isBefore(a){if(a.isParentOf(this))return!0;if(this.isParentOf(a))return!1;var b=this.getCommonAncestor(a);let c=this;for(;;){var d=c.getParentOrThrow();if(d===b){d=d.__children.indexOf(c.__key);break}c=d}for(c=a;;){a=c.getParentOrThrow();if(a===b){b=
|
|
116
116
|
a.__children.indexOf(c.__key);break}c=a}return d<b}isParentOf(a){const b=this.__key;if(b===a.__key)return!1;for(;null!==a;){if(a.__key===b)return!0;a=a.getParent()}return!1}getNodesBetween(a){const b=this.isBefore(a),c=[],d=new Set;var f=this;let e=null;for(;;){var g=f.__key;d.has(g)||(d.add(g),c.push(f));if(f===a)break;g=C(f)?b?f.getFirstChild():f.getLastChild():null;if(null!==g)null===e&&(e=f),f=g;else if(g=b?f.getNextSibling():f.getPreviousSibling(),null!==g)f=g;else{g=f.getParentOrThrow();d.has(g.__key)||
|
|
117
117
|
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=G(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(),
|
|
118
118
|
f=d.__parent;b=b._cloneNotNeeded;if(b.has(c))return Aa(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;Aa(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 t(this)?
|
|
119
|
-
(a=a.getElementByKey(this.getKey()),{element:a?a.cloneNode():null}):{element:this.createDOM(a._config,a)}}static importDOM(){return null}remove(){F();
|
|
120
|
-
var b=this.getWritable(),c=a.getWritable(),d=c.getParent();const f=K();var e=a.getIndexWithinParent(),g=!1,h=!1;null!==d&&(ya(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);za(c);J(f)&&(
|
|
121
|
-
return a}insertBefore(a){F();var b=this.getWritable(),c=a.getWritable();ya(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);za(c);c=K();J(c)&&
|
|
122
|
-
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
|
|
123
|
-
class
|
|
119
|
+
(a=a.getElementByKey(this.getKey()),{element:a?a.cloneNode():null}):{element:this.createDOM(a._config,a)}}static importDOM(){return null}remove(a){F();ud(this,!0,a)}replace(a){F();const b=this.__key;a=a.getWritable();ya(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;ud(this,!1);za(a);d=K();J(d)&&(c=d.anchor,d=d.focus,c.key===b&&bd(c,a),d.key===b&&bd(d,a));B()._compositionKey===b&&D(e);return a}insertAfter(a){F();
|
|
120
|
+
var b=this.getWritable(),c=a.getWritable(),d=c.getParent();const f=K();var e=a.getIndexWithinParent(),g=!1,h=!1;null!==d&&(ya(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);za(c);J(f)&&(qd(f,e,b+1),c=e.__key,g&&f.anchor.set(c,b+2,"element"),h&&f.focus.set(c,b+2,"element"));
|
|
121
|
+
return a}insertBefore(a){F();var b=this.getWritable(),c=a.getWritable();ya(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);za(c);c=K();J(c)&&qd(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(),
|
|
122
|
+
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 xd extends wd{constructor(a){super(a)}decorate(){q(4)}isIsolated(){return!1}isTopLevel(){return!1}}function t(a){return a instanceof xd}
|
|
123
|
+
class yd extends wd{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=G(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=
|
|
124
124
|
B()._dirtyElements;return null!==a&&a.has(this.__key)}getAllTextNodes(a){const b=[],c=this.getLatest().__children;for(let f=0;f<c.length;f++){var d=G(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=
|
|
125
125
|
this.getChildren(),c=b.length;if(0===c)return this;if(a>=c)return a=b[c-1],C(a)&&a.getLastDescendant()||a;a=b[a];return C(a)&&a.getFirstDescendant()||a}getFirstChild(){const a=this.getLatest().__children;return 0===a.length?null:G(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:G(a[b-1])}getChildAtIndex(a){a=this.getLatest().__children[a];return void 0===a?null:G(a)}getTextContent(a,
|
|
126
|
-
b){let c="";const d=this.getChildren(),f=d.length;for(let e=0;e<f;e++){const g=d[e];c+=g.getTextContent(a,b);C(g)&&e!==f-1&&!g.isInline()&&(c+="\n\n")}return c}getDirection(){return this.getLatest().__dir}hasFormat(a){a=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
|
|
126
|
+
b){let c="";const d=this.getChildren(),f=d.length;for(let e=0;e<f;e++){const g=d[e];c+=g.getTextContent(a,b);C(g)&&e!==f-1&&!g.isInline()&&(c+="\n\n")}return c}getDirection(){return this.getLatest().__dir}hasFormat(a){a=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 pd(d,a,d,b,"element","element");return c}selectStart(){const a=
|
|
127
127
|
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();
|
|
128
128
|
this.getWritable().__indent=a;return this}splice(a,b,c){F();const d=this.getWritable();var f=d.__key;const e=d.__children,g=c.length;var h=[];for(let l=0;l<g;l++){const k=c[l],m=k.getWritable();k.__key===f&&q(49);ya(m);m.__parent=f;h.push(m.__key)}(c=this.getChildAtIndex(a-1))&&Aa(c);(f=this.getChildAtIndex(a+b))&&Aa(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=u=>{for(u=u.getNode();u;){const p=u.__key;if(l.has(p)&&!k.has(p))return!0;
|
|
129
|
-
u=u.getParent()}return!1};const {anchor:m,focus:n}=b;h(m)&&
|
|
130
|
-
function C(a){return a instanceof
|
|
131
|
-
class
|
|
132
|
-
__format:this.__format,__indent:this.__indent,__key:"root",__parent:null,__type:"root"}}}function M(a){return a instanceof
|
|
133
|
-
class
|
|
134
|
-
type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type},type:"range"}:
|
|
135
|
-
class
|
|
136
|
-
function
|
|
137
|
-
function
|
|
138
|
-
class
|
|
139
|
-
(this.getLatest().__detail&2)}hasFormat(a){a=ca[a];return 0!==(this.getFormat()&a)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(a,b){return!a&&this.isInert()||!1===b&&this.isDirectionless()?"":this.getLatest().__text}getFormatFlags(a,b){const c=this.getLatest().__format;return va(c,a,b)}createDOM(a){var b=this.__format,c=b&16?"code":null;const d=
|
|
140
|
-
c,this);a=a.theme.text;void 0!==a&&
|
|
141
|
-
l&&q(21));
|
|
129
|
+
u=u.getParent()}return!1};const {anchor:m,focus:n}=b;h(m)&&sd(m,m.getNode(),this,c,f);h(n)&&sd(n,n.getNode(),this,c,f);h=a.length;for(b=0;b<h;b++)c=G(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}}
|
|
130
|
+
function C(a){return a instanceof yd}
|
|
131
|
+
class zd extends yd{static getType(){return"root"}static clone(){return new zd}constructor(){super("root");this.__cachedText=null}getTopLevelElementOrThrow(){q(70)}getTextContent(a,b){const c=this.__cachedText;return!X&&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)||t(c)||q(46)}return super.append(...a)}toJSON(){return{__children:this.__children,__dir:this.__dir,
|
|
132
|
+
__format:this.__format,__indent:this.__indent,__key:"root",__parent:null,__type:"root"}}}function M(a){return a instanceof zd}function Tc(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 Ad(){return new Cc(new Map([["root",new zd]]))}
|
|
133
|
+
class Cc{constructor(a,b){this._nodeMap=a;this._selection=b||null;this._readOnly=this._flushSync=!1}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(a){a:{const c=U,d=X,f=V;U=this;X=!0;V=null;try{var b=a();break a}finally{U=c,X=d,V=f}b=void 0}return b}clone(a){a=new Cc(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,
|
|
134
|
+
type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type},type:"range"}:Sc(a)?{nodes:Array.from(a._nodes),type:"node"}:hd(a)?{anchorCellKey:a.anchorCellKey,focusCellKey:a.focusCellKey,gridKey:a.gridKey,type:"grid"}:null}}}
|
|
135
|
+
class Bd extends wd{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:md()}}function md(){return new Bd}function xa(a){return a instanceof Bd}function Dd(a,b){return b&1?"strong":b&2?"em":"span"}
|
|
136
|
+
function Gd(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 ca)h=ca[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))}
|
|
137
|
+
function Hd(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}
|
|
138
|
+
class Id extends wd{static getType(){return"text"}static clone(a){return new Id(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!==
|
|
139
|
+
(this.getLatest().__detail&2)}hasFormat(a){a=ca[a];return 0!==(this.getFormat()&a)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(a,b){return!a&&this.isInert()||!1===b&&this.isDirectionless()?"":this.getLatest().__text}getFormatFlags(a,b){const c=this.getLatest().__format;return 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;Hd(this.__text,
|
|
140
|
+
c,this);a=a.theme.text;void 0!==a&&Gd(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),Hd(d,a,this),c=c.theme.text,void 0!==c&&Gd(k,0,e,a,c),b.replaceChild(g,f),!1;l=b;null!==h&&null!==g&&(l=b.firstChild,null==
|
|
141
|
+
l&&q(21));Hd(d,l,this);c=c.theme.text;void 0!==c&&f!==e&&Gd(k,f,e,l,c);e=this.__style;a.__style!==e&&(b.style.cssText=e);return!1}static importDOM(){return{"#text":()=>({conversion:Jd,priority:0}),b:()=>({conversion:Kd,priority:0}),em:()=>({conversion:Ld,priority:0}),i:()=>({conversion:Ld,priority:0}),span:()=>({conversion:Md,priority:0}),strong:()=>({conversion:Ld,priority:0}),u:()=>({conversion:Ld,priority:0})}}selectionTransform(){}setFormat(a){F();const b=this.getWritable();b.__format=a;return b}setStyle(a){F();
|
|
142
142
|
const b=this.getWritable();b.__style=a;return b}toggleFormat(a){a=ca[a];return this.setFormat(this.getFormat()^a)}toggleDirectionless(){F();const a=this.getWritable();a.__detail^=1;return a}toggleUnmergeable(){F();const a=this.getWritable();a.__detail^=2;return a}setMode(a){F();a=ha[a];const b=this.getWritable();b.__mode=a;return b}setTextContent(a){F();const b=this.getWritable();b.__text=a;return b}select(a,b){F();const c=K();var d=this.getTextContent();const f=this.__key;"string"===typeof d?(d=
|
|
143
|
-
d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(J(c))d=B()._compositionKey,d!==c.anchor.key&&d!==c.focus.key||D(f),c.setTextNodeRange(this,a,this,b);else return
|
|
143
|
+
d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(J(c))d=B()._compositionKey,d!==c.anchor.key&&d!==c.focus.key||D(f),c.setTextNodeRange(this,a,this,b);else return pd(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();
|
|
144
144
|
var b=this.getLatest(),c=b.getTextContent(),d=b.__key,f=B()._compositionKey,e=new Set(a);a=[];var g=c.length,h="";for(var 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(),u=b.__detail;g=!1;b.isSegmented()?(h=L(k),h.__parent=l,h.__format=m,h.__style=n,h.__detail=u,g=!0):(h=b.getWritable(),h.__text=k);b=K();h=[h];k=k.length;for(let y=1;y<e;y++){var p=
|
|
145
|
-
a[y],A=p.length;p=L(p).getWritable();p.__format=m;p.__style=n;p.__detail=u;const E=p.__key;A=k+A;if(J(b)){const x=b.anchor,H=b.focus;x.key===d&&"text"===x.type&&x.offset>k&&x.offset<=A&&(x.key=E,x.offset-=k,b.dirty=!0);H.key===d&&"text"===H.type&&H.offset>k&&H.offset<=A&&(H.key=E,H.offset-=k,b.dirty=!0)}f===d&&D(E);k=A;p.__parent=l;h.push(p)}za(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)&&
|
|
146
|
-
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&&(
|
|
147
|
-
function
|
|
148
|
-
function L(a=""){return new
|
|
149
|
-
class
|
|
150
|
-
this.insertAfter(a);return a}collapseAtStart(){const a=this.getChildren();if(0===a.length||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
|
|
151
|
-
function
|
|
152
|
-
function
|
|
153
|
-
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=
|
|
145
|
+
a[y],A=p.length;p=L(p).getWritable();p.__format=m;p.__style=n;p.__detail=u;const E=p.__key;A=k+A;if(J(b)){const x=b.anchor,H=b.focus;x.key===d&&"text"===x.type&&x.offset>k&&x.offset<=A&&(x.key=E,x.offset-=k,b.dirty=!0);H.key===d&&"text"===H.type&&H.offset>k&&H.offset<=A&&(H.key=E,H.offset-=k,b.dirty=!0)}f===d&&D(E);k=A;p.__parent=l;h.push(p)}za(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)&&qd(b,c,d,e-1);return h}mergeWithSibling(a){const b=
|
|
146
|
+
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&&(td(h,b,c,a,e),g.dirty=!0);null!==l&&l.key===d&&(td(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}}
|
|
147
|
+
function Md(a){const b="700"===a.style.fontWeight;return{forChild:c=>{w(c)&&b&&c.toggleFormat("bold");return c},node:null}}function Kd(a){const b="normal"===a.style.fontWeight;return{forChild:c=>{w(c)&&!b&&c.toggleFormat("bold");return c},node:null}}function Jd(a){return{node:L(a.textContent)}}const Nd={em:"italic",i:"italic",strong:"bold",u:"underline"};function Ld(a){const b=Nd[a.nodeName.toLowerCase()];return void 0===b?{node:null}:{forChild:c=>{w(c)&&c.toggleFormat(b);return c},node:null}}
|
|
148
|
+
function L(a=""){return new Id(a)}function w(a){return a instanceof Id}
|
|
149
|
+
class Od extends yd{static getType(){return"paragraph"}static clone(a){return new Od(a.__key)}createDOM(a){const b=document.createElement("p");a=Pa(a.theme,"paragraph");void 0!==a&&b.classList.add(...a);return b}updateDOM(){return!1}static importDOM(){return{p:()=>({conversion:Pd,priority:0})}}exportDOM(a){({element:a}=super.exportDOM(a));a&&0===this.getTextContentSize()&&a.append(document.createElement("br"));return{element:a}}insertNewAfter(){const a=dd(),b=this.getDirection();a.setDirection(b);
|
|
150
|
+
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 Pd(){return{node:dd()}}function dd(){return new Od}
|
|
151
|
+
function Gc(a,b,c,d){const f=a._keyToDOMMap;f.clear();a._editorState=Ad();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))}
|
|
152
|
+
function Qd(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}
|
|
153
|
+
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=Ad();a=b.editorState;const l=[zd,Id,Bd,Od,...(b.nodes||[])],k=b.onError;b=b.readOnly||!1;const m=new Map;for(let n=0;n<l.length;n++){const u=l[n],p=u.getType();m.set(p,{klass:u,transforms:new Set})}c=new Rd(h,e,m,{context:f,disableEvents:g,namespace:c,theme:d},k,Qd(m),b);void 0!==a&&(c._pendingEditorState=a,c._dirtyType=
|
|
154
154
|
2);return c}
|
|
155
|
-
class
|
|
155
|
+
class Rd{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=
|
|
156
156
|
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()=>
|
|
157
157
|
{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,
|
|
158
|
-
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
|
|
159
|
-
this._rootElement;if(a!==b){var c=this._pendingEditorState||this._editorState;this._rootElement=a;
|
|
160
|
-
"text",c.whiteSpace="pre-wrap",c.wordBreak="break-word",a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,
|
|
161
|
-
|
|
162
|
-
a&&a.removeAllRanges()}isReadOnly(){return this._readOnly}setReadOnly(a){this._readOnly=a;
|
|
163
|
-
|
|
164
|
-
exports.$
|
|
165
|
-
exports.$
|
|
166
|
-
exports.
|
|
167
|
-
exports.
|
|
168
|
-
exports.
|
|
158
|
+
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 P(this,a,b)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(a){const b=
|
|
159
|
+
this._rootElement;if(a!==b){var c=this._pendingEditorState||this._editorState;this._rootElement=a;Gc(this,b,a,c);if(null!==b&&!this._config.disableEvents){0!==Ob&&(Ob--,0===Ob&&b.ownerDocument.removeEventListener("selectionchange",Wb));c=b.__lexicalEditor;if(null!=c){if(null!==c._parentEditor){var d=Ka(c);d=d[d.length-1]._key;Vb.get(d)===c&&Vb.delete(d)}else Vb.delete(c._key);b.__lexicalEditor=null}c=Ub(b);for(d=0;d<c.length;d++)c[d]();b.__lexicalEventHandles=[]}null!==a&&(c=a.style,c.userSelect=
|
|
160
|
+
"text",c.whiteSpace="pre-wrap",c.wordBreak="break-word",a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,Hc(this),this._updateTags.add("history-merge"),Ec(this),this._config.disableEvents||Xb(a,this));Nc("root",this,!1,a,b)}}getElementByKey(a){return this._keyToDOMMap.get(a)||null}getEditorState(){return this._editorState}setEditorState(a,b){a.isEmpty()&&q(19);Tb(this);const c=this._pendingEditorState,d=this._updateTags;b=void 0!==b?b.tag:null;null===c||c.isEmpty()||(null!=b&&d.add(b),
|
|
161
|
+
Ec(this));this._pendingEditorState=a;this._dirtyType=2;this._compositionKey=null;null!=b&&d.add(b);Ec(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!==
|
|
162
|
+
a&&a.removeAllRanges()}isReadOnly(){return this._readOnly}setReadOnly(a){this._readOnly=a;Nc("readonly",this,!0,a)}toJSON(){return{editorState:this._editorState}}}class Sd extends yd{constructor(a,b){super(b)}}function kd(a){return a instanceof Sd}class Td extends yd{}function id(a){return a instanceof Td}class Ud extends yd{}function jd(a){return a instanceof Ud}exports.$createGridSelection=function(){return new gd("root","root","root")};exports.$createLineBreakNode=md;
|
|
163
|
+
exports.$createNodeFromParse=function(a,b){F();const c=B();return bb(a,b,c,null)};exports.$createNodeSelection=function(){return new ed(new Set)};exports.$createParagraphNode=dd;exports.$createRangeSelection=function(){const a=Y("root",0,"element"),b=Y("root",0,"element");return new fd(a,b,0)};exports.$createTextNode=L;exports.$getDecoratorNode=Sa;exports.$getNearestNodeFromDOMNode=sa;exports.$getNodeByKey=G;exports.$getPreviousSelection=Na;exports.$getRoot=Ga;exports.$getSelection=K;
|
|
164
|
+
exports.$isDecoratorNode=t;exports.$isElementNode=C;exports.$isGridCellNode=kd;exports.$isGridNode=id;exports.$isGridRowNode=jd;exports.$isGridSelection=hd;exports.$isLeafNode=wa;exports.$isLineBreakNode=xa;exports.$isNodeSelection=Sc;exports.$isParagraphNode=function(a){return a instanceof Od};exports.$isRangeSelection=J;exports.$isRootNode=M;exports.$isTextNode=w;
|
|
165
|
+
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=Db;exports.CAN_REDO_COMMAND={};exports.CAN_UNDO_COMMAND={};exports.CLEAR_EDITOR_COMMAND={};exports.CLEAR_HISTORY_COMMAND={};exports.CLICK_COMMAND=fb;exports.COMMAND_PRIORITY_CRITICAL=4;exports.COMMAND_PRIORITY_EDITOR=0;
|
|
166
|
+
exports.COMMAND_PRIORITY_HIGH=3;exports.COMMAND_PRIORITY_LOW=1;exports.COMMAND_PRIORITY_NORMAL=2;exports.COPY_COMMAND=Ab;exports.CUT_COMMAND=Bb;exports.DELETE_CHARACTER_COMMAND=gb;exports.DELETE_LINE_COMMAND=mb;exports.DELETE_WORD_COMMAND=lb;exports.DRAGSTART_COMMAND=zb;exports.DROP_COMMAND=yb;exports.DecoratorNode=xd;exports.ElementNode=yd;exports.FOCUS_COMMAND=Cb;exports.FORMAT_ELEMENT_COMMAND={};exports.FORMAT_TEXT_COMMAND=O;exports.GridCellNode=Sd;exports.GridNode=Td;exports.GridRowNode=Ud;
|
|
167
|
+
exports.INDENT_CONTENT_COMMAND={};exports.INSERT_LINE_BREAK_COMMAND=hb;exports.INSERT_PARAGRAPH_COMMAND=ib;exports.INSERT_TEXT_COMMAND=N;exports.KEY_ARROW_DOWN_COMMAND=sb;exports.KEY_ARROW_LEFT_COMMAND=qb;exports.KEY_ARROW_RIGHT_COMMAND=pb;exports.KEY_ARROW_UP_COMMAND=rb;exports.KEY_BACKSPACE_COMMAND=ub;exports.KEY_DELETE_COMMAND=wb;exports.KEY_ENTER_COMMAND=tb;exports.KEY_ESCAPE_COMMAND=vb;exports.KEY_MODIFIER_COMMAND=Eb;exports.KEY_TAB_COMMAND=xb;exports.OUTDENT_CONTENT_COMMAND={};
|
|
168
|
+
exports.PASTE_COMMAND=jb;exports.ParagraphNode=Od;exports.REDO_COMMAND=ob;exports.REMOVE_TEXT_COMMAND=kb;exports.SELECTION_CHANGE_COMMAND=eb;exports.TextNode=Id;exports.UNDO_COMMAND=nb;exports.VERSION="0.2.3";exports.createCommand=function(){return{}};exports.createEditor=cb;
|