lexical 0.3.2 → 0.3.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 CHANGED
@@ -6,7 +6,6 @@
6
6
  *
7
7
  */
8
8
 
9
- import {Spread} from 'libdefs/globals';
10
9
  import {Class} from 'utility-types';
11
10
 
12
11
  /**
@@ -232,6 +231,7 @@ export type EditorThemeClasses = {
232
231
  h3?: EditorThemeClassName;
233
232
  h4?: EditorThemeClassName;
234
233
  h5?: EditorThemeClassName;
234
+ h6?: EditorThemeClassName;
235
235
  };
236
236
  // Handle other generic values
237
237
  [key: string]:
@@ -249,6 +249,7 @@ export type EditorThemeClasses = {
249
249
  };
250
250
 
251
251
  export type EditorConfig = {
252
+ namespace: string;
252
253
  theme: EditorThemeClasses;
253
254
  disableEvents?: boolean;
254
255
  };
@@ -262,6 +263,7 @@ export const COMMAND_PRIORITY_CRITICAL = 4;
262
263
  export type IntentionallyMarkedAsDirtyElement = boolean;
263
264
  export function createEditor(editorConfig?: {
264
265
  editorState?: EditorState;
266
+ namespace: string;
265
267
  theme?: EditorThemeClasses;
266
268
  parentEditor?: LexicalEditor;
267
269
  nodes?: ReadonlyArray<Class<LexicalNode>>;
@@ -779,7 +781,7 @@ export function $getDecoratorNode(
779
781
  focus: Point,
780
782
  isBackward: boolean,
781
783
  ): null | LexicalNode;
782
-
784
+ export function generateRandomKey(): string;
783
785
  export type EventHandler = (event: Event, editor: LexicalEditor) => void;
784
786
 
785
787
  /**
@@ -790,6 +792,8 @@ export declare var VERSION: string;
790
792
  /**
791
793
  * Serialization/Deserialization
792
794
  * */
795
+ export type Spread<T1, T2> = {[K in Exclude<keyof T1, keyof T2>]: T1[K]} & T2;
796
+
793
797
  interface InternalSerializedNode {
794
798
  children?: Array<InternalSerializedNode>;
795
799
  type: string;
package/Lexical.dev.js CHANGED
@@ -1173,11 +1173,12 @@ function scrollIntoViewIfNeeded(editor, anchor, rootElement, tags) {
1173
1173
  } else if (rect.top < 0) {
1174
1174
  element.scrollIntoView();
1175
1175
  } else {
1176
- const rootRect = rootElement.getBoundingClientRect();
1176
+ const rootRect = rootElement.getBoundingClientRect(); // Rects can returning decimal numbers that differ due to rounding
1177
+ // differences. So let's normalize the values.
1177
1178
 
1178
- if (rect.bottom > rootRect.bottom) {
1179
+ if (Math.floor(rect.bottom) > Math.floor(rootRect.bottom)) {
1179
1180
  element.scrollIntoView(false);
1180
- } else if (rect.top < rootRect.top) {
1181
+ } else if (Math.floor(rect.top) < Math.floor(rootRect.top)) {
1181
1182
  element.scrollIntoView();
1182
1183
  }
1183
1184
  }
@@ -2438,9 +2439,8 @@ function onInput(event, editor) {
2438
2439
  updateEditor(editor, () => {
2439
2440
  const selection = $getSelection();
2440
2441
  const data = event.data;
2441
- const possibleTextReplacement = event.inputType === 'insertText' && data != null && data.length > 1 && !doesContainGrapheme(data);
2442
2442
 
2443
- if (data != null && $isRangeSelection(selection) && (possibleTextReplacement || $shouldPreventDefaultAndInsertText(selection, data))) {
2443
+ if (data != null && $isRangeSelection(selection) && $shouldPreventDefaultAndInsertText(selection, data)) {
2444
2444
  // Given we're over-riding the default behavior, we will need
2445
2445
  // to ensure to disable composition before dispatching the
2446
2446
  // insertText command for when changing the sequence for FF.
@@ -2449,24 +2449,7 @@ function onInput(event, editor) {
2449
2449
  isFirefoxEndingComposition = false;
2450
2450
  }
2451
2451
 
2452
- dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, data);
2453
-
2454
- if (possibleTextReplacement) {
2455
- // If the DOM selection offset is higher than the existing
2456
- // offset, then restore the offset as it's likely correct
2457
- // in the case of text replacements.
2458
- const {
2459
- anchorOffset
2460
- } = window.getSelection();
2461
- const anchor = selection.anchor;
2462
- const focus = selection.focus;
2463
-
2464
- if (anchorOffset > anchor.offset) {
2465
- anchor.set(anchor.key, anchorOffset, anchor.type);
2466
- focus.set(anchor.key, anchorOffset, anchor.type);
2467
- }
2468
- } // This ensures consistency on Android.
2469
-
2452
+ dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, data); // This ensures consistency on Android.
2470
2453
 
2471
2454
  if (!IS_SAFARI && !IS_IOS && editor.isComposing()) {
2472
2455
  lastKeyDownTimeStamp = 0;
@@ -5470,6 +5453,9 @@ function commitPendingUpdates(editor) {
5470
5453
  isAttemptingToRecoverFromReconcilerError = true;
5471
5454
  commitPendingUpdates(editor);
5472
5455
  isAttemptingToRecoverFromReconcilerError = false;
5456
+ } else {
5457
+ // To avoid a possible situation of infinite loops, lets throw
5458
+ throw error;
5473
5459
  }
5474
5460
 
5475
5461
  return;
@@ -5827,6 +5813,9 @@ function updateEditor(editor, updateFn, options) {
5827
5813
  beginUpdate(editor, updateFn, options);
5828
5814
  }
5829
5815
  }
5816
+ function internalGetActiveEditor() {
5817
+ return activeEditor;
5818
+ }
5830
5819
 
5831
5820
  /* eslint-disable no-constant-condition */
5832
5821
  function removeNode(nodeToRemove, restoreSelection, preserveEmptyParent) {
@@ -5895,6 +5884,7 @@ function $getNodeByKeyOrThrow(key) {
5895
5884
  return node;
5896
5885
  }
5897
5886
  class LexicalNode {
5887
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5898
5888
  // Flow doesn't support abstract classes unfortunately, so we can't _force_
5899
5889
  // subclasses of Node to implement statics. All subclasses of Node should have
5900
5890
  // a static getType and clone method though. We define getType and clone here so we can call it
@@ -7561,7 +7551,9 @@ function setTextContent(nextText, dom, node) {
7561
7551
  dom.textContent = text;
7562
7552
  } else {
7563
7553
  const nodeValue = firstChild.nodeValue;
7564
- if (nodeValue !== text) if (isComposing) {
7554
+ if (nodeValue !== text) if (isComposing || IS_FIREFOX) {
7555
+ // We also use the diff composed text for general text in FF to avoid
7556
+ // the spellcheck red line from flickering.
7565
7557
  const [index, remove, insert] = diffComposedText(nodeValue, text);
7566
7558
 
7567
7559
  if (remove !== 0) {
@@ -8410,69 +8402,78 @@ function initializeConversionCache(nodes) {
8410
8402
  return conversionCache;
8411
8403
  }
8412
8404
 
8413
- function createEditor(editorConfig = {}) {
8414
- const config = editorConfig;
8405
+ function createEditor(editorConfig) {
8406
+ const config = editorConfig || {};
8407
+ const activeEditor = internalGetActiveEditor();
8415
8408
  const theme = config.theme || {};
8416
- const parentEditor = config.parentEditor || null;
8409
+ const parentEditor = editorConfig === undefined ? activeEditor : config.parentEditor || null;
8417
8410
  const disableEvents = config.disableEvents || false;
8418
8411
  const editorState = createEmptyEditorState();
8412
+ const namespace = config.namespace || (parentEditor !== null ? parentEditor._config.namespace : createUID());
8419
8413
  const initialEditorState = config.editorState;
8420
8414
  const nodes = [RootNode, TextNode, LineBreakNode, ParagraphNode, ...(config.nodes || [])];
8421
8415
  const onError = config.onError;
8422
8416
  const isReadOnly = config.readOnly || false;
8423
- const registeredNodes = new Map();
8417
+ let registeredNodes;
8424
8418
 
8425
- for (let i = 0; i < nodes.length; i++) {
8426
- const klass = nodes[i]; // Ensure custom nodes implement required methods.
8427
- // @ts-ignore
8419
+ if (editorConfig === undefined && activeEditor !== null) {
8420
+ registeredNodes = activeEditor._nodes;
8421
+ } else {
8422
+ registeredNodes = new Map();
8428
8423
 
8429
- {
8430
- const name = klass.name;
8431
-
8432
- if (name !== 'RootNode') {
8433
- const proto = klass.prototype;
8434
- ['getType', 'clone'].forEach(method => {
8435
- // eslint-disable-next-line no-prototype-builtins
8436
- if (!klass.hasOwnProperty(method)) {
8437
- console.warn(`${name} must implement static "${method}" method`);
8438
- }
8439
- });
8424
+ for (let i = 0; i < nodes.length; i++) {
8425
+ const klass = nodes[i]; // Ensure custom nodes implement required methods.
8426
+ // @ts-ignore
8440
8427
 
8441
- if ( // eslint-disable-next-line no-prototype-builtins
8442
- !klass.hasOwnProperty('importDOM') && // eslint-disable-next-line no-prototype-builtins
8443
- klass.hasOwnProperty('exportDOM')) {
8444
- console.warn(`${name} should implement "importDOM" if using a custom "exportDOM" method to ensure HTML serialization (important for copy & paste) works as expected`);
8445
- }
8428
+ {
8429
+ const name = klass.name;
8430
+
8431
+ if (name !== 'RootNode') {
8432
+ const proto = klass.prototype;
8433
+ ['getType', 'clone'].forEach(method => {
8434
+ // eslint-disable-next-line no-prototype-builtins
8435
+ if (!klass.hasOwnProperty(method)) {
8436
+ console.warn(`${name} must implement static "${method}" method`);
8437
+ }
8438
+ });
8446
8439
 
8447
- if (proto instanceof DecoratorNode) {
8448
- // eslint-disable-next-line no-prototype-builtins
8449
- if (!proto.hasOwnProperty('decorate')) {
8450
- console.warn(`${this.constructor.name} must implement "decorate" method`);
8440
+ if ( // eslint-disable-next-line no-prototype-builtins
8441
+ !klass.hasOwnProperty('importDOM') && // eslint-disable-next-line no-prototype-builtins
8442
+ klass.hasOwnProperty('exportDOM')) {
8443
+ console.warn(`${name} should implement "importDOM" if using a custom "exportDOM" method to ensure HTML serialization (important for copy & paste) works as expected`);
8451
8444
  }
8452
- }
8453
8445
 
8454
- if ( // eslint-disable-next-line no-prototype-builtins
8455
- !klass.hasOwnProperty('importJSON')) {
8456
- console.warn(`${name} should implement "importJSON" method to ensure JSON and default HTML serialization works as expected`);
8457
- }
8446
+ if (proto instanceof DecoratorNode) {
8447
+ // eslint-disable-next-line no-prototype-builtins
8448
+ if (!proto.hasOwnProperty('decorate')) {
8449
+ console.warn(`${this.constructor.name} must implement "decorate" method`);
8450
+ }
8451
+ }
8452
+
8453
+ if ( // eslint-disable-next-line no-prototype-builtins
8454
+ !klass.hasOwnProperty('importJSON')) {
8455
+ console.warn(`${name} should implement "importJSON" method to ensure JSON and default HTML serialization works as expected`);
8456
+ }
8458
8457
 
8459
- if ( // eslint-disable-next-line no-prototype-builtins
8460
- !proto.hasOwnProperty('exportJSON')) {
8461
- console.warn(`${name} should implement "exportJSON" method to ensure JSON and default HTML serialization works as expected`);
8458
+ if ( // eslint-disable-next-line no-prototype-builtins
8459
+ !proto.hasOwnProperty('exportJSON')) {
8460
+ console.warn(`${name} should implement "exportJSON" method to ensure JSON and default HTML serialization works as expected`);
8461
+ }
8462
8462
  }
8463
- }
8464
- } // @ts-expect-error TODO Replace Class utility type with InstanceType
8463
+ } // @ts-expect-error TODO Replace Class utility type with InstanceType
8465
8464
 
8466
8465
 
8467
- const type = klass.getType();
8468
- registeredNodes.set(type, {
8469
- klass,
8470
- transforms: new Set()
8471
- });
8466
+ const type = klass.getType();
8467
+ registeredNodes.set(type, {
8468
+ klass,
8469
+ transforms: new Set()
8470
+ });
8471
+ }
8472
8472
  }
8473
8473
 
8474
8474
  const editor = new LexicalEditor(editorState, parentEditor, registeredNodes, {
8475
8475
  disableEvents,
8476
+ namespace,
8476
8477
  theme
8477
8478
  }, onError, initializeConversionCache(registeredNodes), isReadOnly);
8478
8479
 
@@ -8835,7 +8836,7 @@ class LexicalEditor {
8835
8836
  * LICENSE file in the root directory of this source tree.
8836
8837
  *
8837
8838
  */
8838
- const VERSION = '0.3.2';
8839
+ const VERSION = '0.3.3';
8839
8840
 
8840
8841
  /**
8841
8842
  * Copyright (c) Meta Platforms, Inc. and affiliates.
package/Lexical.js.flow CHANGED
@@ -231,12 +231,14 @@ export type EditorThemeClasses = {
231
231
  h3?: EditorThemeClassName,
232
232
  h4?: EditorThemeClassName,
233
233
  h5?: EditorThemeClassName,
234
+ h6?: EditorThemeClassName,
234
235
  },
235
236
  // Handle other generic values
236
237
  [string]: EditorThemeClassName | {[string]: EditorThemeClassName},
237
238
  };
238
239
  export type EditorConfig = {
239
240
  theme: EditorThemeClasses,
241
+ namespace: string,
240
242
  disableEvents?: boolean,
241
243
  };
242
244
  export type CommandListenerPriority = 0 | 1 | 2 | 3 | 4;
@@ -249,6 +251,7 @@ export const COMMAND_PRIORITY_CRITICAL = 4;
249
251
  export type IntentionallyMarkedAsDirtyElement = boolean;
250
252
  declare export function createEditor(editorConfig?: {
251
253
  editorState?: EditorState,
254
+ namespace: string,
252
255
  theme?: EditorThemeClasses,
253
256
  parentEditor?: LexicalEditor,
254
257
  nodes?: $ReadOnlyArray<Class<LexicalNode>>,
@@ -803,7 +806,7 @@ declare export function $getDecoratorNode(
803
806
  focus: Point,
804
807
  isBackward: boolean,
805
808
  ): null | LexicalNode;
806
-
809
+ declare export function generateRandomKey(): string;
807
810
  export type EventHandler = (event: Event, editor: LexicalEditor) => void;
808
811
 
809
812
  /**
package/Lexical.prod.js CHANGED
@@ -5,20 +5,20 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict';function p(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
8
- let aa="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,ba=aa&&"documentMode"in document?document.documentMode:null,t=aa&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),ca=aa&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),fa=aa&&"InputEvent"in window&&!ba?"getTargetRanges"in new window.InputEvent("input"):!1,ha=aa&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),ia=aa&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&
9
- !window.MSStream,ja=ha||ia?"\u00a0":"\u200b",ka=ca?"\u00a0":ja,la=/^[^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]/,ma=/^[^\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]/,na={bold:1,code:16,italic:2,strikethrough:4,subscript:32,superscript:64,underline:8},oa={center:2,justify:4,
10
- left:1,right:3},pa={2:"center",4:"justify",1:"left",3:"right"},ta={inert:3,normal:0,segmented:2,token:1},ua={3:"inert",0:"normal",2:"segmented",1:"token"},va=!1,wa=0;function xa(a){wa=a.timeStamp}function ya(a,b,c){return b.__lexicalLineBreak===a||void 0!==a["__lexicalKey_"+c._key]}function za(a){return a.getEditorState().read(()=>{let b=u();return null!==b?b.clone():null})}
8
+ let aa="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,ba=aa&&"documentMode"in document?document.documentMode:null,t=aa&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),ca=aa&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),ha=aa&&"InputEvent"in window&&!ba?"getTargetRanges"in new window.InputEvent("input"):!1,ia=aa&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),ja=aa&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&
9
+ !window.MSStream,ka=ia||ja?"\u00a0":"\u200b",la=ca?"\u00a0":ka,ma=/^[^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]/,na=/^[^\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]/,oa={bold:1,code:16,italic:2,strikethrough:4,subscript:32,superscript:64,underline:8},pa={center:2,justify:4,
10
+ left:1,right:3},qa={2:"center",4:"justify",1:"left",3:"right"},ra={inert:3,normal:0,segmented:2,token:1},ua={3:"inert",0:"normal",2:"segmented",1:"token"},va=!1,wa=0;function xa(a){wa=a.timeStamp}function ya(a,b,c){return b.__lexicalLineBreak===a||void 0!==a["__lexicalKey_"+c._key]}function za(a){return a.getEditorState().read(()=>{let b=u();return null!==b?b.clone():null})}
11
11
  function Aa(a,b,c){va=!0;let d=100<performance.now()-wa;try{v(a,()=>{var e=new Map,f=a.getRootElement(),g=a._editorState;let h=!1,k="";for(var m=0;m<b.length;m++){var l=b[m],n=l.type,r=l.target,q=Ba(r,g);if(!x(q))if("characterData"===n){if(d&&3===r.nodeType&&A(q)&&q.isAttached()){l=window.getSelection();var w=n=null;null!==l&&l.anchorNode===r&&(n=l.anchorOffset,w=l.focusOffset);Ca(q,r.nodeValue,n,w,!1)}}else if("childList"===n){h=!0;n=l.addedNodes;for(w=0;w<n.length;w++){var y=n[w],E=Da(y),z=y.parentNode;
12
12
  null==z||null!==E||"BR"===y.nodeName&&ya(y,z,a)||(ca&&(E=y.innerText||y.nodeValue)&&(k+=E),z.removeChild(y))}l=l.removedNodes;n=l.length;if(0<n){w=0;for(y=0;y<n;y++)z=l[y],"BR"===z.nodeName&&ya(z,r,a)&&(r.appendChild(z),w++);n!==w&&(r===f&&(q=g._nodeMap.get("root")),e.set(r,q))}}}if(0<e.size)for(let [G,V]of e)if(B(V))for(e=V.__children,f=G.firstChild,g=0;g<e.length;g++)m=a.getElementByKey(e[g]),null!==m&&(null==f?(G.appendChild(m),f=m):f!==m&&G.replaceChild(m,f),f=f.nextSibling);else A(V)&&V.markDirty();
13
13
  e=c.takeRecords();if(0<e.length){for(f=0;f<e.length;f++)for(m=e[f],g=m.addedNodes,m=m.target,q=0;q<g.length;q++)r=g[q],l=r.parentNode,null==l||"BR"!==r.nodeName||ya(r,m,a)||l.removeChild(r);c.takeRecords()}e=u()||za(a);null!==e&&(h&&(e.dirty=!0,Ea(e)),ca&&Fa()&&e.insertRawText(k))})}finally{va=!1}}function Ga(a){let b=a._observer;if(null!==b){let c=b.takeRecords();Aa(a,c,b)}}function Ha(a){0===wa&&window.addEventListener("textInput",xa,!0);a._observer=new MutationObserver((b,c)=>{Aa(a,b,c)})}
14
14
  let Ia=1,Ja="function"===typeof queueMicrotask?queueMicrotask:a=>{Promise.resolve().then(a)};function Ka(a,b,c){let d=a.getRootElement();try{var e;if(e=null!==d&&d.contains(b)&&d.contains(c)&&null!==b){let f=document.activeElement,g=null!==f?f.nodeName:null;e=!x(Ba(b))||"INPUT"!==g&&"TEXTAREA"!==g}return e&&Na(b)===a}catch(f){return!1}}function Na(a){for(;null!=a;){let b=a.__lexicalEditor;if(null!=b&&!b.isReadOnly())return b;a=a.parentNode}return null}function Oa(a){return C(a)||a.isSegmented()}
15
- function C(a){return a.isToken()||a.isInert()}function Pa(a){for(;null!=a;){if(3===a.nodeType)return a;a=a.firstChild}return null}function Qa(a,b,c){b=na[b];return a&b&&(null===c||0===(c&b))?a^b:null===c||c&b?a|b:a}function Ra(a){return A(a)||Sa(a)||x(a)}function Ta(a){var b=a.getParent();if(null!==b){b=b.getWritable().__children;let c=b.indexOf(a.__key);-1===c&&p(31);Ua(a);b.splice(c,1)}}
15
+ function C(a){return a.isToken()||a.isInert()}function Pa(a){for(;null!=a;){if(3===a.nodeType)return a;a=a.firstChild}return null}function Qa(a,b,c){b=oa[b];return a&b&&(null===c||0===(c&b))?a^b:null===c||c&b?a|b:a}function Ra(a){return A(a)||Sa(a)||x(a)}function Ta(a){var b=a.getParent();if(null!==b){b=b.getWritable().__children;let c=b.indexOf(a.__key);-1===c&&p(31);Ua(a);b.splice(c,1)}}
16
16
  function Va(a){99<Wa&&p(14);var b=a.getLatest(),c=b.__parent,d=D();let e=F(),f=d._nodeMap;d=e._dirtyElements;if(null!==c)a:for(;null!==c;){if(d.has(c))break a;let g=f.get(c);if(void 0===g)break;d.set(c,!1);c=g.__parent}b=b.__key;e._dirtyType=1;B(a)?d.set(b,!0):e._dirtyLeaves.add(b)}function Ua(a){let b=a.getPreviousSibling();a=a.getNextSibling();null!==b&&Va(b);null!==a&&Va(a)}
17
17
  function H(a){I();var b=F();let c=b._compositionKey;a!==c&&(b._compositionKey=a,null!==c&&(b=J(c),null!==b&&b.getWritable()),null!==a&&(a=J(a),null!==a&&a.getWritable()))}function J(a,b){a=(b||D())._nodeMap.get(a);return void 0===a?null:a}function Da(a,b){let c=F();a=a["__lexicalKey_"+c._key];return void 0!==a?J(a,b):null}function Ba(a,b){for(;null!=a;){let c=Da(a,b);if(null!==c)return c;a=a.parentNode}return null}
18
18
  function Xa(a){let b=Object.assign({},a._decorators);return a._pendingDecorators=b}function Ya(a){return a.read(()=>Za().getTextContent())}function $a(a,b){v(a,()=>{var c=D();if(!c.isEmpty())if("root"===b)Za().markDirty();else{c=c._nodeMap;for(let [,d]of c)d.markDirty()}},null===a._pendingEditorState?{tag:"history-merge"}:void 0)}function Za(){return D()._nodeMap.get("root")}function Ea(a){let b=D();null!==a&&(a.dirty=!0,a._cachedNodes=null);b._selection=a}
19
- function ab(a){var b=F(),c;a:{for(c=a;null!=c;){let 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?J("root"):null):J(c)}function bb(a){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(a)}function cb(a){let b=[];for(;null!==a;)b.push(a),a=a._parentEditor;return b}
20
- function db(a,b,c){a=window.getSelection();if(null!==a){var d=a.anchorNode,{anchorOffset:e,focusOffset:f}=a;if(null!==d&&3===d.nodeType&&(a=Ba(d),A(a))){d=d.nodeValue;if(d===ja&&c){let g=c.length;d=c;f=e=g}Ca(a,d,e,f,b)}}}
21
- function Ca(a,b,c,d,e){let f=a;if(f.isAttached()&&(e||!f.isDirty())){var g=f.isComposing();a=b;(g||e)&&b[b.length-1]===ja&&(a=b.slice(0,-1));b=f.getTextContent();if(e||a!==b)if(""===a)if(H(null),ha||ia)f.remove();else{let h=F();setTimeout(()=>{h.update(()=>{f.isAttached()&&f.remove()})},20)}else e=f.getParent(),b=eb(),C(f)||null!==F()._compositionKey&&!g||null!==e&&K(b)&&!e.canInsertTextBefore()&&0===b.anchor.offset?f.markDirty():(g=u(),K(g)&&null!==c&&null!==d&&(g.setTextNodeRange(f,c,f,d),f.isSegmented()&&
19
+ function ab(a){var b=F(),c;a:{for(c=a;null!=c;){let 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?J("root"):null):J(c)}function bb(a){let b=[];for(;null!==a;)b.push(a),a=a._parentEditor;return b}function cb(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}
20
+ function db(a,b,c){a=window.getSelection();if(null!==a){var d=a.anchorNode,{anchorOffset:e,focusOffset:f}=a;if(null!==d&&3===d.nodeType&&(a=Ba(d),A(a))){d=d.nodeValue;if(d===ka&&c){let g=c.length;d=c;f=e=g}Ca(a,d,e,f,b)}}}
21
+ function Ca(a,b,c,d,e){let f=a;if(f.isAttached()&&(e||!f.isDirty())){var g=f.isComposing();a=b;(g||e)&&b[b.length-1]===ka&&(a=b.slice(0,-1));b=f.getTextContent();if(e||a!==b)if(""===a)if(H(null),ia||ja)f.remove();else{let h=F();setTimeout(()=>{h.update(()=>{f.isAttached()&&f.remove()})},20)}else e=f.getParent(),b=eb(),C(f)||null!==F()._compositionKey&&!g||null!==e&&K(b)&&!e.canInsertTextBefore()&&0===b.anchor.offset?f.markDirty():(g=u(),K(g)&&null!==c&&null!==d&&(g.setTextNodeRange(f,c,f,d),f.isSegmented()&&
22
22
  (c=f.getTextContent(),c=L(c),f.replace(c),f=c)),f.setTextContent(a))}}
23
23
  function fb(a,b){var c=a.anchor,d=a.focus,e=c.getNode(),f=window.getSelection();f=null!==f?f.anchorNode:null;let g=c.key,h=F().getElementByKey(g);b=b.length;(c=g!==d.key||!A(e)||2>b&&c.offset!==d.offset&&!e.isComposing()||Oa(e)||e.isDirty()&&1<b||null!==h&&!e.isComposing()&&f!==Pa(h)||e.getFormat()!==a.format)||(e.isSegmented()?c=!0:a.isCollapsed()?(c=a.anchor.offset,d=e.getParentOrThrow(),b=e.isToken(),a=0===c&&(!e.canInsertTextBefore()||!d.canInsertTextBefore()||b),e=e.getTextContentSize()===c&&
24
24
  (!e.canInsertTextBefore()||!d.canInsertTextBefore()||b),c=a||e):c=!1);return c}function gb(a,b){var c=a[b];return"string"===typeof c?(c=c.split(" "),a[b]=c):c}function hb(a,b,c,d,e){0!==c.size&&(c=d.__type,d=d.__key,b=b.get(c),void 0===b&&p(33,c),b=b.klass,c=a.get(b),void 0===c&&(c=new Map,a.set(b,c)),c.has(d)||c.set(d,e))}
@@ -31,28 +31,27 @@ function Kb(a,b){a=a.style;0===b?Ib(a,""):1===b?Ib(a,"left"):2===b?Ib(a,"center"
31
31
  function Lb(a,b,c){let d=Cb.get(a);void 0===d&&p(60);let e=d.createDOM(tb,Q);var f=Q._keyToDOMMap;e["__lexicalKey_"+Q._key]=a;f.set(a,e);A(d)?e.setAttribute("data-lexical-text","true"):x(d)&&e.setAttribute("data-lexical-decorator","true");if(B(d)){a=d.__indent;0!==a&&Jb(e,a);a=d.__children;var g=a.length;if(0!==g){f=a;--g;let h=O;O="";Mb(f,0,g,e,null);Nb(d,e);O=h}f=d.__format;0!==f&&Kb(e,f);Ob(null,a,e);kb(d)&&(N+="\n\n",P+="\n\n")}else f=d.getTextContent(),x(d)?(g=d.decorate(Q),null!==g&&Pb(a,g),
32
32
  e.contentEditable="false"):A(d)&&(d.isDirectionless()||(O+=f),d.isInert()&&(a=e.style,a.pointerEvents="none",a.userSelect="none",e.contentEditable="false",a.setProperty("-webkit-user-select","none"))),N+=f,P+=f;null!==b&&(null!=c?b.insertBefore(e,c):(c=b.__lexicalLineBreak,null!=c?b.insertBefore(e,c):b.appendChild(e)));hb(Eb,ub,xb,d,"created");return e}function Mb(a,b,c,d,e){let f=N;for(N="";b<=c;++b)Lb(a[b],d,e);d.__lexicalTextContent=N;N=f+N}
33
33
  function Qb(a,b){a=b.get(a[a.length-1]);return Sa(a)||x(a)}function Ob(a,b,c){a=null!==a&&(0===a.length||Qb(a,Bb));b=null!==b&&(0===b.length||Qb(b,Cb));a?b||(b=c.__lexicalLineBreak,null!=b&&c.removeChild(b),c.__lexicalLineBreak=null):b&&(b=document.createElement("br"),c.__lexicalLineBreak=b,c.appendChild(b))}
34
- function Nb(a,b){var c=b.__lexicalDir;if(b.__lexicalDirTextContent!==O||c!==yb){let f=""===O;if(f)var d=yb;else d=O,d=la.test(d)?"rtl":ma.test(d)?"ltr":null;if(d!==c){let g=b.classList,h=tb.theme;var e=null!==c?h[c]:void 0;let k=null!==d?h[d]:void 0;void 0!==e&&("string"===typeof e&&(e=e.split(" "),e=h[c]=e),g.remove(...e));null===d||f&&"ltr"===d?b.removeAttribute("dir"):(void 0!==k&&("string"===typeof k&&(c=k.split(" "),k=h[d]=c),g.add(...k)),b.dir=d);wb||(a.getWritable().__dir=d)}yb=d;b.__lexicalDirTextContent=
34
+ function Nb(a,b){var c=b.__lexicalDir;if(b.__lexicalDirTextContent!==O||c!==yb){let f=""===O;if(f)var d=yb;else d=O,d=ma.test(d)?"rtl":na.test(d)?"ltr":null;if(d!==c){let g=b.classList,h=tb.theme;var e=null!==c?h[c]:void 0;let k=null!==d?h[d]:void 0;void 0!==e&&("string"===typeof e&&(e=e.split(" "),e=h[c]=e),g.remove(...e));null===d||f&&"ltr"===d?b.removeAttribute("dir"):(void 0!==k&&("string"===typeof k&&(c=k.split(" "),k=h[d]=c),g.add(...k)),b.dir=d);wb||(a.getWritable().__dir=d)}yb=d;b.__lexicalDirTextContent=
35
35
  O;b.__lexicalDir=d}}
36
36
  function Rb(a,b){var c=Bb.get(a),d=Cb.get(a);void 0!==c&&void 0!==d||p(61);var e=vb||Ab.has(a)||zb.has(a);let f=nb(Q,a);if(c===d&&!e)return B(c)?(d=f.__lexicalTextContent,void 0!==d&&(N+=d,P+=d),d=f.__lexicalDirTextContent,void 0!==d&&(O+=d)):(d=c.getTextContent(),A(c)&&!c.isDirectionless()&&(O+=d),P+=d,N+=d),f;c!==d&&e&&hb(Eb,ub,xb,d,"updated");if(d.updateDOM(c,f,tb))return d=Lb(a,null,null),null===b&&p(62),b.replaceChild(d,f),Fb(a,null),d;if(B(c)&&B(d)){a=d.__indent;a!==c.__indent&&Jb(f,a);a=d.__format;
37
37
  a!==c.__format&&Kb(f,a);a=c.__children;c=d.__children;if(a!==c||e){var g=a,h=c;e=d;b=O;O="";let q=N;N="";var k=g.length,m=h.length;if(1===k&&1===m){var l=g[0];h=h[0];if(l===h)Rb(l,f);else{var n=Gb(l);h=Lb(h,null,null);f.replaceChild(h,n);Fb(l,null)}}else if(0===k)0!==m&&Mb(h,0,m-1,f,null);else if(0===m)0!==k&&(l=null==f.__lexicalLineBreak,Hb(g,0,k-1,l?null:f),l&&(f.textContent=""));else{let w=k-1;k=m-1;let y=f.firstChild,E=0;for(m=0;E<=w&&m<=k;){var r=g[E];let z=h[m];if(r===z)y=Rb(z,f).nextSibling,
38
38
  E++,m++;else{void 0===l&&(l=new Set(g));void 0===n&&(n=new Set(h));let G=n.has(r),V=l.has(z);G?(V?(r=nb(Q,z),r===y?y=Rb(z,f).nextSibling:(null!=y?f.insertBefore(r,y):f.appendChild(r),Rb(z,f)),E++):Lb(z,f,y),m++):(y=Gb(r).nextSibling,Fb(r,f),E++)}}l=E>w;n=m>k;l&&!n?(l=h[k+1],l=void 0===l?null:Q.getElementByKey(l),Mb(h,m,k,f,l)):n&&!l&&Hb(g,E,w,f)}kb(e)&&(N+="\n\n");f.__lexicalTextContent=N;N=q+N;Nb(e,f);O=b;M(d)||Ob(a,c,f)}kb(d)&&(N+="\n\n",P+="\n\n")}else c=d.getTextContent(),x(d)?(e=d.decorate(Q),
39
39
  null!==e&&Pb(a,e),N+=c,P+=c):A(d)&&!d.isDirectionless()&&(O+=c),N+=c,P+=c;!wb&&M(d)&&d.__cachedText!==P&&(d=d.getWritable(),d.__cachedText=P);return f}function Pb(a,b){let c=Q._pendingDecorators,d=Q._decorators;if(null===c){if(d[a]===b)return;c=Xa(Q)}c[a]=b}function Gb(a){a=Db.get(a);void 0===a&&p(34);return a}
40
- let Sb={},Tb={},Xb={},Yb={},Zb={},$b={},ac={},bc={},cc={},dc={},R={},ec={},fc={},gc={},hc={},ic={},jc={},kc={},lc={},mc={},nc={},oc={},pc={},qc={},rc={},sc={},tc={},uc={},vc={},wc={},xc={},yc={},zc={},Ac={},S=Object.freeze({}),Gc=[["keydown",Bc],["compositionstart",Cc],["compositionend",Dc],["input",Ec],["click",Fc],["cut",S],["copy",S],["dragstart",S],["dragover",S],["paste",S],["focus",S],["blur",S],["drop",S]];fa&&Gc.push(["beforeinput",Hc]);let Ic=0,Jc=0,Kc=!1,Lc=!1,Mc=!1,Nc=[0,0,"root",0];
40
+ let Sb={},Tb={},Xb={},Yb={},Zb={},$b={},ac={},bc={},cc={},dc={},R={},ec={},fc={},gc={},hc={},ic={},jc={},kc={},lc={},mc={},nc={},oc={},pc={},qc={},rc={},sc={},tc={},uc={},vc={},wc={},xc={},yc={},zc={},Ac={},S=Object.freeze({}),Gc=[["keydown",Bc],["compositionstart",Cc],["compositionend",Dc],["input",Ec],["click",Fc],["cut",S],["copy",S],["dragstart",S],["dragover",S],["paste",S],["focus",S],["blur",S],["drop",S]];ha&&Gc.push(["beforeinput",Hc]);let Ic=0,Jc=0,Kc=!1,Lc=!1,Mc=!1,Nc=[0,0,"root",0];
41
41
  function Oc(a,b,c){let {anchorNode:d,anchorOffset:e,focusNode:f,focusOffset:g}=a;if(Kc&&(Kc=!1,null!==d&&3===d.nodeType&&0!==e&&e!==d.nodeValue.length&&null!==f&&3===f.nodeType&&0!==g&&g!==f.nodeValue.length))return;v(b,()=>{if(!c)Ea(null);else if(Ka(b,d,f)){var h=u();if(K(h)){let m=h.anchor,l=m.getNode();if(h.isCollapsed()){"Range"===a.type&&(h.dirty=!0);var k=window.event;k=k?k.timeStamp:performance.now();let [n,r,q,w]=Nc;k<w+200&&m.offset===r&&m.key===q?h.format=n:"text"===m.type?h.format=l.getFormat():
42
42
  "element"===m.type&&(h.format=0)}else{k=h.focus;let n=k.getNode(),r=0;"text"===m.type&&(r|=l.getFormat());"text"!==k.type||l.is(n)||(r|=n.getFormat());h.format=r}}T(b,Sb,void 0)}})}
43
43
  function Fc(a,b){v(b,()=>{var c=u(),d=window.getSelection();let e=eb();if(K(c)){let f=c.anchor,g=f.getNode();"element"===f.type&&0===f.offset&&c.isCollapsed()&&!M(g)&&1===Za().getChildrenSize()&&g.getTopLevelElementOrThrow().isEmpty()&&null!==e&&c.is(e)&&(d.removeAllRanges(),c.dirty=!0)}else Pc(c)&&d.isCollapsed&&(c=d.anchorNode,null!==c&&3===c.nodeType&&(d=Qc(e,d,b),Ea(d)));T(b,Tb,a)})}function Rc(a,b){b.getTargetRanges&&(b=b.getTargetRanges()[0])&&a.applyDOMRange(b)}
44
44
  function Sc(a,b){return a!==b||B(a)||B(b)||!C(a)||!C(b)}
45
- function Hc(a,b){let c=a.inputType;if(!("deleteCompositionText"===c||ca&&Fa()))if("insertCompositionText"===c){let d=a.data;d&&v(b,()=>{var e=u();if(K(e)){let f=e.anchor,g=f.getNode(),h=g.getPreviousSibling();0===f.offset&&A(g)&&A(h)&&g.getTextContent()===ka&&h.getFormat()!==e.format&&(e=h.getTextContent(),0===d.indexOf(e)&&(e=d.slice(e.length),T(b,$b,e),setTimeout(()=>{v(b,()=>{g.select()})},30)))}})}else v(b,()=>{var d=u();if("deleteContentBackward"===c){if(null===d){d=eb();if(!K(d))return;Ea(d.clone())}H(null);
45
+ function Hc(a,b){let c=a.inputType;if(!("deleteCompositionText"===c||ca&&Fa()))if("insertCompositionText"===c){let d=a.data;d&&v(b,()=>{var e=u();if(K(e)){let f=e.anchor,g=f.getNode(),h=g.getPreviousSibling();0===f.offset&&A(g)&&A(h)&&g.getTextContent()===la&&h.getFormat()!==e.format&&(e=h.getTextContent(),0===d.indexOf(e)&&(e=d.slice(e.length),T(b,$b,e),setTimeout(()=>{v(b,()=>{g.select()})},30)))}})}else v(b,()=>{var d=u();if("deleteContentBackward"===c){if(null===d){d=eb();if(!K(d))return;Ea(d.clone())}H(null);
46
46
  a.preventDefault();Ic=0;T(b,Xb,!0);setTimeout(()=>{v(b,()=>{H(null)})},30)}else if(K(d)){var e=a.data;d.dirty||!d.isCollapsed()||M(d.anchor.getNode())||Rc(d,a);var f=d.focus,g=d.anchor.getNode();f=f.getNode();if("insertText"===c)"\n"===e?(a.preventDefault(),T(b,Yb,void 0)):"\n\n"===e?(a.preventDefault(),T(b,Zb,void 0)):null==e&&a.dataTransfer?(e=a.dataTransfer.getData("text/plain"),a.preventDefault(),d.insertRawText(e)):null!=e&&fb(d,e)&&(a.preventDefault(),T(b,$b,e));else switch(a.preventDefault(),
47
47
  c){case "insertFromYank":case "insertFromDrop":case "insertReplacementText":T(b,$b,a);break;case "insertFromComposition":H(null);T(b,$b,a);break;case "insertLineBreak":H(null);T(b,Yb,void 0);break;case "insertParagraph":H(null);Lc?(Lc=!1,T(b,Yb,void 0)):T(b,Zb,void 0);break;case "insertFromPaste":case "insertFromPasteAsQuotation":T(b,ac,a);break;case "deleteByComposition":Sc(g,f)&&T(b,bc,void 0);break;case "deleteByDrag":case "deleteByCut":T(b,bc,void 0);break;case "deleteContent":T(b,Xb,!1);break;
48
48
  case "deleteWordBackward":T(b,cc,!0);break;case "deleteWordForward":T(b,cc,!1);break;case "deleteHardLineBackward":case "deleteSoftLineBackward":T(b,dc,!0);break;case "deleteContentForward":case "deleteHardLineForward":case "deleteSoftLineForward":T(b,dc,!1);break;case "formatStrikeThrough":T(b,R,"strikethrough");break;case "formatBold":T(b,R,"bold");break;case "formatItalic":T(b,R,"italic");break;case "formatUnderline":T(b,R,"underline");break;case "historyUndo":T(b,ec,void 0);break;case "historyRedo":T(b,
49
- fc,void 0)}}})}function Ec(a,b){a.stopPropagation();v(b,()=>{var c=u(),d=a.data,e="insertText"===a.inputType&&null!=d&&1<d.length&&!bb(d);null!=d&&K(c)&&(e||fb(c,d))?(Mc&&(Tc(b,d),Mc=!1),T(b,$b,d),e&&({anchorOffset:d}=window.getSelection(),e=c.anchor,c=c.focus,d>e.offset&&(e.set(e.key,d,e.type),c.set(e.key,d,e.type))),ha||ia||!b.isComposing()||(Ic=0,H(null))):(db(b,!1),Mc&&(Tc(b,d),Mc=!1));I();c=F();Ga(c)})}
50
- function Cc(a,b){v(b,()=>{let c=u();if(K(c)&&!b.isComposing()){let d=c.anchor;H(d.key);(a.timeStamp<Ic+30||"element"===d.type||!c.isCollapsed()||c.anchor.getNode().getFormat()!==c.format)&&T(b,$b,ka)}})}function Tc(a,b){var c=a._compositionKey;H(null);if(null!==c&&null!=b){if(""===b){b=J(c);a=Pa(a.getElementByKey(c));null!==a&&A(b)&&Ca(b,a.nodeValue,null,null,!0);return}if("\n"===b[b.length-1]&&(c=u(),K(c))){b=c.focus;c.anchor.set(b.key,b.offset,b.type);T(a,mc,null);return}}db(a,!0,b)}
51
- function Dc(a,b){ca?Mc=!0:v(b,()=>{Tc(b,a.data)})}
49
+ fc,void 0)}}})}function Ec(a,b){a.stopPropagation();v(b,()=>{var c=u();let d=a.data;null!=d&&K(c)&&fb(c,d)?(Mc&&(Tc(b,d),Mc=!1),T(b,$b,d),ia||ja||!b.isComposing()||(Ic=0,H(null))):(db(b,!1),Mc&&(Tc(b,d),Mc=!1));I();c=F();Ga(c)})}function Cc(a,b){v(b,()=>{let c=u();if(K(c)&&!b.isComposing()){let d=c.anchor;H(d.key);(a.timeStamp<Ic+30||"element"===d.type||!c.isCollapsed()||c.anchor.getNode().getFormat()!==c.format)&&T(b,$b,la)}})}
50
+ function Tc(a,b){var c=a._compositionKey;H(null);if(null!==c&&null!=b){if(""===b){b=J(c);a=Pa(a.getElementByKey(c));null!==a&&A(b)&&Ca(b,a.nodeValue,null,null,!0);return}if("\n"===b[b.length-1]&&(c=u(),K(c))){b=c.focus;c.anchor.set(b.key,b.offset,b.type);T(a,mc,null);return}}db(a,!0,b)}function Dc(a,b){ca?Mc=!0:v(b,()=>{Tc(b,a.data)})}
52
51
  function Bc(a,b){Ic=a.timeStamp;if(!b.isComposing()){var {keyCode:c,shiftKey:d,ctrlKey:e,metaKey:f,altKey:g}=a;if(39!==c||e||f||g)if(39!==c||g||d||!e&&!f)if(37!==c||e||f||g)if(37!==c||g||d||!e&&!f)if(38!==c||e||f)if(40!==c||e||f)if(13===c&&d)Lc=!0,T(b,mc,a);else if(32===c)T(b,nc,a);else if(t&&e&&79===c)a.preventDefault(),Lc=!0,T(b,Yb,!0);else if(13!==c||d){var h=t?g||f?!1:8===c||72===c&&e:e||g||f?!1:8===c;h?8===c?T(b,oc,a):(a.preventDefault(),T(b,Xb,!0)):27===c?T(b,pc,a):(h=t?d||g||f?!1:46===c||68===
53
52
  c&&e:e||g||f?!1:46===c,h?46===c?T(b,qc,a):(a.preventDefault(),T(b,Xb,!1)):8===c&&(t?g:e)?(a.preventDefault(),T(b,cc,!0)):46===c&&(t?g:e)?(a.preventDefault(),T(b,cc,!1)):t&&f&&8===c?(a.preventDefault(),T(b,dc,!0)):t&&f&&46===c?(a.preventDefault(),T(b,dc,!1)):66===c&&!g&&(t?f:e)?(a.preventDefault(),T(b,R,"bold")):85===c&&!g&&(t?f:e)?(a.preventDefault(),T(b,R,"underline")):73===c&&!g&&(t?f:e)?(a.preventDefault(),T(b,R,"italic")):9!==c||g||e||f?90===c&&!d&&(t?f:e)?(a.preventDefault(),T(b,ec,void 0)):
54
53
  (h=t?90===c&&f&&d:89===c&&e||90===c&&e&&d,h?(a.preventDefault(),T(b,fc,void 0)):Pc(b._editorState._selection)&&(h=d?!1:67===c?t?f:e:void 0,h?(a.preventDefault(),T(b,wc,a)):(h=d?!1:88===c?t?f:e:void 0,h&&(a.preventDefault(),T(b,xc,a))))):T(b,rc,a))}else Lc=!1,T(b,mc,a);else T(b,lc,a);else T(b,kc,a);else T(b,jc,a);else T(b,ic,a);else T(b,hc,a);else T(b,gc,a);(e||d||g||f)&&T(b,Ac,a)}}function Uc(a){let b=a.__lexicalEventHandles;void 0===b&&(b=[],a.__lexicalEventHandles=b);return b}let Vc=new Map;
55
- function Wc(){let a=window.getSelection(),b=Na(a.anchorNode);if(null!==b){var c=cb(b);c=c[c.length-1];var d=c._key,e=Vc.get(d),f=e||c;f!==b&&Oc(a,f,!1);Oc(a,b,!0);b!==c?Vc.set(d,b):e&&Vc.delete(d)}}
54
+ function Wc(){let a=window.getSelection(),b=Na(a.anchorNode);if(null!==b){var c=bb(b);c=c[c.length-1];var d=c._key,e=Vc.get(d),f=e||c;f!==b&&Oc(a,f,!1);Oc(a,b,!0);b!==c?Vc.set(d,b):e&&Vc.delete(d)}}
56
55
  function Xc(a,b){0===Jc&&a.ownerDocument.addEventListener("selectionchange",Wc);Jc++;a.__lexicalEditor=b;let c=Uc(a);for(let d=0;d<Gc.length;d++){let [e,f]=Gc[d],g="function"===typeof f?h=>{b.isReadOnly()||f(h,b)}:h=>{if(!b.isReadOnly())switch(e){case "cut":return T(b,xc,h);case "copy":return T(b,wc,h);case "paste":return T(b,ac,h);case "dragstart":return T(b,tc,h);case "dragover":return T(b,uc,h);case "dragend":return T(b,vc,h);case "focus":return T(b,yc,h);case "blur":return T(b,zc,h);case "drop":return T(b,
57
56
  sc,h)}};a.addEventListener(e,g);c.push(()=>{a.removeEventListener(e,g)})}}
58
57
  class U{constructor(a,b,c){this._selection=null;this.key=a;this.offset=b;this.type=c}is(a){return this.key===a.key&&this.offset===a.offset&&this.type===a.type}isBefore(a){let b=this.getNode(),c=a.getNode(),d=this.offset;a=a.offset;if(B(b)){var e=b.getDescendantByIndex(d);b=null!=e?e:b}B(c)&&(e=c.getDescendantByIndex(a),c=null!=e?e:c);return b===c?d<a:b.isBefore(c)}getNode(){let a=J(this.key);null===a&&p(20);return a}set(a,b,c){let d=this._selection,e=this.key;this.key=a;this.offset=b;this.type=c;
@@ -66,7 +65,7 @@ J(this.gridKey);gd(f)||p(23);a.add(f);f=f.getChildren();for(let k=c;k<=e;k++){va
66
65
  class cd{constructor(a,b,c){this.anchor=a;this.focus=b;this.dirty=!1;this.format=c;this._cachedNodes=null;a._selection=this;b._selection=this}is(a){return K(a)?this.anchor.is(a.anchor)&&this.focus.is(a.focus)&&this.format===a.format:!1}isBackward(){return this.focus.isBefore(this.anchor)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){var a=this._cachedNodes;if(null!==a)return a;var b=this.anchor,c=this.focus;a=b.getNode();let d=c.getNode();B(a)&&(b=a.getDescendantByIndex(b.offset),a=null!=
67
66
  b?b:a);B(d)&&(c=d.getDescendantByIndex(c.offset),d=null!=c?c:d);a=a.is(d)?B(a)&&(0<a.getChildrenSize()||a.excludeFromCopy())?[]:[a]:a.getNodesBetween(d);W||(this._cachedNodes=a);return a}setTextNodeRange(a,b,c,d){X(this.anchor,a.__key,b,"text");X(this.focus,c.__key,d,"text");this._cachedNodes=null;this.dirty=!0}getTextContent(){let a=this.getNodes();if(0===a.length)return"";let b=a[0],c=a[a.length-1],d=this.anchor.isBefore(this.focus),[e,f]=fd(this),g="",h=!0;for(let k=0;k<a.length;k++){let m=a[k];
68
67
  if(B(m)&&!m.isInline())h||(g+="\n"),h=m.isEmpty()?!1:!0;else if(h=!1,A(m)){let l=m.getTextContent();m===b?l=m===c?e<f?l.slice(e,f):l.slice(f,e):d?l.slice(e):l.slice(f):m===c&&(l=d?l.slice(0,f):l.slice(0,e));g+=l}else!x(m)&&!Sa(m)||m===c&&this.isCollapsed()||(g+=m.getTextContent())}return g}applyDOMRange(a){let b=F(),c=b.getEditorState()._selection;a=jd(a.startContainer,a.startOffset,a.endContainer,a.endOffset,b,c);if(null!==a){var [d,e]=a;X(this.anchor,d.key,d.offset,d.type);X(this.focus,e.key,e.offset,
69
- e.type);this._cachedNodes=null}}clone(){let a=this.anchor,b=this.focus;return new cd(new U(a.key,a.offset,a.type),new U(b.key,b.offset,b.type),this.format)}toggleFormat(a){this.format=Qa(this.format,a,null);this.dirty=!0}hasFormat(a){return 0!==(this.format&na[a])}insertRawText(a){let b=a.split(/\r?\n/);if(1===b.length)this.insertText(a);else{a=[];let c=b.length;for(let d=0;d<c;d++){let e=b[d];""!==e&&a.push(L(e));d!==c-1&&a.push(kd())}this.insertNodes(a)}}insertText(a){var b=this.anchor,c=this.focus,
68
+ e.type);this._cachedNodes=null}}clone(){let a=this.anchor,b=this.focus;return new cd(new U(a.key,a.offset,a.type),new U(b.key,b.offset,b.type),this.format)}toggleFormat(a){this.format=Qa(this.format,a,null);this.dirty=!0}hasFormat(a){return 0!==(this.format&oa[a])}insertRawText(a){let b=a.split(/\r?\n/);if(1===b.length)this.insertText(a);else{a=[];let c=b.length;for(let d=0;d<c;d++){let e=b[d];""!==e&&a.push(L(e));d!==c-1&&a.push(kd())}this.insertNodes(a)}}insertText(a){var b=this.anchor,c=this.focus,
70
69
  d=this.isCollapsed()||b.isBefore(c),e=this.format;d&&"element"===b.type?$c(b,c,e):d||"element"!==c.type||$c(c,b,e);var f=this.getNodes(),g=f.length,h=d?c:b;c=(d?b:c).offset;var k=h.offset;b=f[0];A(b)||p(26);d=b.getTextContent().length;var m=b.getParentOrThrow(),l=f[g-1];if(this.isCollapsed()&&c===d&&(b.isSegmented()||b.isToken()||!b.canInsertTextAfter()||!m.canInsertTextAfter())){var n=b.getNextSibling();if(!A(n)||Oa(n))n=L(),m.canInsertTextAfter()?b.insertAfter(n):m.insertAfter(n);n.select(0,0);
71
70
  b=n;if(""!==a){this.insertText(a);return}}else if(this.isCollapsed()&&0===c&&(b.isSegmented()||b.isToken()||!b.canInsertTextBefore()||!m.canInsertTextBefore())){n=b.getPreviousSibling();if(!A(n)||Oa(n))n=L(),m.canInsertTextBefore()?b.insertBefore(n):m.insertBefore(n);n.select();b=n;if(""!==a){this.insertText(a);return}}else if(b.isSegmented()&&c!==d)m=L(b.getTextContent()),b.replace(m),b=m;else if(!(this.isCollapsed()||""===a||(n=l.getParent(),m.canInsertTextBefore()&&m.canInsertTextAfter()&&(!B(n)||
72
71
  n.canInsertTextBefore()&&n.canInsertTextAfter())))){this.insertText("");ld(this.anchor,this.focus,null);this.insertText(a);return}if(1===g)if(C(b))a=L(a),a.select(),b.replace(a);else{f=b.getFormat();if(c===k&&f!==e)if(""===b.getTextContent())b.setFormat(e);else{f=L(a);f.setFormat(e);f.select();0===c?b.insertBefore(f):([g]=b.splitText(c),g.insertAfter(f));f.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=a.length);return}b=b.spliceText(c,k-c,a,!0);""===b.getTextContent()?b.remove():
@@ -84,9 +83,10 @@ b&&(f.is(a.getNode())||h&&h.is(a.getNode()))&&0<d)f.insertBefore(g);else{f=null;
84
83
  this.getNodes(),b=a.length,c=b-1,d=this.anchor;let e=this.focus;var f=a[0];let g=a[c],[h,k]=fd(this);if(0===b)return[];if(1===b)return A(f)?(a=h>k?k:h,c=f.splitText(a,h>k?h:k),a=0===a?c[0]:c[1],null!=a?[a]:[]):[f];b=d.isBefore(e);A(f)&&(d=b?h:k,d===f.getTextContentSize()?a.shift():0!==d&&([,f]=f.splitText(d),a[0]=f));A(g)&&(f=g.getTextContent().length,b=b?k:h,0===b?a.pop():b!==f&&([g]=g.splitText(b),a[c]=g));return a}modify(a,b,c){var d=this.focus,e=this.anchor,f="move"===a,g=jb(d,b);x(g)&&!g.isIsolated()?
85
84
  (a=b?g.getPreviousSibling():g.getNextSibling(),A(a)?(g=a.__key,b=b?a.getTextContent().length:0,d.set(g,b,"text"),f&&e.set(g,b,"text")):(c=g.getParentOrThrow(),B(a)?(c=a.__key,g=b?a.getChildrenSize():0):(g=g.getIndexWithinParent(),c=c.__key,b||g++),d.set(c,g,"element"),f&&e.set(c,g,"element"))):(d=window.getSelection(),d.modify(a,b?"backward":"forward",c),0<d.rangeCount&&(b=d.getRangeAt(0),this.applyDOMRange(b),this.dirty=!0,f||d.anchorNode===b.startContainer&&d.anchorOffset===b.startOffset||(f=this.focus,
86
85
  b=this.anchor,d=b.key,e=b.offset,g=b.type,X(b,f.key,f.offset,f.type),X(f,d,e,g),this._cachedNodes=null)))}deleteCharacter(a){if(this.isCollapsed()){var b=this.anchor,c=this.focus,d=b.getNode();if(!a&&("element"===b.type&&b.offset===d.getChildrenSize()||"text"===b.type&&b.offset===d.getTextContentSize())&&(d=d.getNextSibling()||d.getParentOrThrow().getNextSibling(),B(d)&&!d.canExtractContents()))return;this.modify("extend",a,"character");if(!this.isCollapsed()){var e="text"===c.type?c.getNode():null;
87
- d="text"===b.type?b.getNode():null;if(null!==e&&e.isSegmented()){if(b=c.offset,c=e.getTextContentSize(),e.is(d)||a&&b!==c||!a&&0!==b){md(e,a,b);return}}else if(null!==d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(e)||a&&0!==b||!a&&b!==c)){md(d,a,b);return}d=this.anchor;e=this.focus;b=d.getNode();c=e.getNode();if(b===c&&"text"===d.type&&"text"===e.type){var f=d.offset,g=e.offset;let h=f<g;c=h?f:g;g=h?g:f;f=g-1;c!==f&&(b=b.getTextContent().slice(c,g),bb(b)||(a?e.offset=f:d.offset=f))}}else if(a&&
88
- 0===b.offset&&("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).collapseAtStart(this))return}this.removeText()}deleteLine(a){this.isCollapsed()&&this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");this.removeText()}}function Pc(a){return a instanceof bd}function nd(a){let b=a.offset;if("text"===a.type)return b;a=a.getNode();return b===a.getChildrenSize()?a.getTextContent().length:0}
89
- function fd(a){let b=a.anchor;a=a.focus;return"element"===b.type&&"element"===a.type&&b.key===a.key&&b.offset===a.offset?[0,0]:[nd(b),nd(a)]}function md(a,b,c){let d=a.getTextContent().split(/(?=\s)/g),e=d.length,f=0,g=0;for(let h=0;h<e;h++){let k=d[h],m=h===e-1;g=f;f+=k.length;if(b&&f===c||f>c||m){d.splice(h,1);m&&(g=void 0);break}}b=d.join("").trim();""===b?a.remove():(a.setTextContent(b),a.select(g,g))}
86
+ d="text"===b.type?b.getNode():null;if(null!==e&&e.isSegmented()){if(b=c.offset,c=e.getTextContentSize(),e.is(d)||a&&b!==c||!a&&0!==b){md(e,a,b);return}}else if(null!==d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(e)||a&&0!==b||!a&&b!==c)){md(d,a,b);return}d=this.anchor;e=this.focus;b=d.getNode();c=e.getNode();if(b===c&&"text"===d.type&&"text"===e.type){var f=d.offset,g=e.offset;let h=f<g;c=h?f:g;g=h?g:f;f=g-1;c!==f&&(b=b.getTextContent().slice(c,g),/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(b)||
87
+ (a?e.offset=f:d.offset=f))}}else if(a&&0===b.offset&&("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).collapseAtStart(this))return}this.removeText()}deleteLine(a){this.isCollapsed()&&this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");this.removeText()}}function Pc(a){return a instanceof bd}
88
+ function nd(a){let b=a.offset;if("text"===a.type)return b;a=a.getNode();return b===a.getChildrenSize()?a.getTextContent().length:0}function fd(a){let b=a.anchor;a=a.focus;return"element"===b.type&&"element"===a.type&&b.key===a.key&&b.offset===a.offset?[0,0]:[nd(b),nd(a)]}
89
+ function md(a,b,c){let d=a.getTextContent().split(/(?=\s)/g),e=d.length,f=0,g=0;for(let h=0;h<e;h++){let k=d[h],m=h===e-1;g=f;f+=k.length;if(b&&f===c||f>c||m){d.splice(h,1);m&&(g=void 0);break}}b=d.join("").trim();""===b?a.remove():(a.setTextContent(b),a.select(g,g))}
90
90
  function od(a,b,c){var d=b;if(1===a.nodeType){let g=!1;var e=a.childNodes;var f=e.length;d===f&&(g=!0,d=f-1);e=ab(e[d]);if(A(e))d=g?e.getTextContentSize():0;else{f=ab(a);if(null===f)return null;if(B(f)){a=f.getChildAtIndex(d);if(b=B(a))b=a.getParent(),b=null===c||null===b||!b.canBeEmpty()||b!==c.getNode();b&&(c=g?a.getLastDescendant():a.getFirstDescendant(),null===c?(f=a,d=0):(a=c,f=a.getParentOrThrow()));A(a)?(e=a,f=null,d=g?a.getTextContentSize():0):a!==f&&g&&d++}else d=f.getIndexWithinParent(),
91
91
  d=0===b&&x(f)&&ab(a)===f?d:d+1,f=f.getParentOrThrow();if(B(f))return new U(f.__key,d,"element")}}else e=ab(a);return A(e)?new U(e.__key,d,"text"):null}
92
92
  function pd(a,b,c){var d=a.offset,e=a.getNode();0===d?(d=e.getPreviousSibling(),e=e.getParent(),b)?(c||!b)&&null===d&&B(e)&&e.isInline()&&(b=e.getPreviousSibling(),A(b)&&(a.key=b.__key,a.offset=b.getTextContent().length)):B(d)&&!c&&d.isInline()?(a.key=d.__key,a.offset=d.getChildrenSize(),a.type="element"):A(d)&&!d.isInert()&&(a.key=d.__key,a.offset=d.getTextContent().length):d===e.getTextContent().length&&(d=e.getNextSibling(),e=e.getParent(),b&&B(d)&&d.isInline()?(a.key=d.__key,a.offset=0,a.type=
@@ -101,13 +101,13 @@ function D(){null===Y&&p(15);return Y}function F(){null===Z&&p(16);return Z}func
101
101
  function Gd(a,b){let c=b._dirtyLeaves,d=b._dirtyElements;a=a._nodeMap;let e=F()._compositionKey,f=new Map;var g=c;let h=g.size;for(var k=d,m=k.size;0<h||0<m;){if(0<h){b._dirtyLeaves=new Set;for(let l of g)g=a.get(l),A(g)&&g.isAttached()&&g.isSimpleText()&&!g.isUnmergeable()&&sb(g),void 0!==g&&void 0!==g&&g.__key!==e&&g.isAttached()&&Ed(b,g,f),c.add(l);g=b._dirtyLeaves;h=g.size;if(0<h){Wa++;continue}}b._dirtyLeaves=new Set;b._dirtyElements=new Map;for(let l of k)if(k=l[0],m=l[1],"root"===k||m)g=a.get(k),
102
102
  void 0!==g&&void 0!==g&&g.__key!==e&&g.isAttached()&&Ed(b,g,f),d.set(k,m);g=b._dirtyLeaves;h=g.size;k=b._dirtyElements;m=k.size;Wa++}b._dirtyLeaves=c;b._dirtyElements=d}function Hd(a,b){var c=a.type,d=b.get(c);void 0===d&&p(17,c);c=d.klass;a.type!==c.getType()&&p(18,c.name);c=c.importJSON(a);a=a.children;if(B(c)&&Array.isArray(a))for(d=0;d<a.length;d++){let e=Hd(a[d],b);c.append(e)}return c}function Id(a,b){let c=Y,d=W,e=Z;Y=a;W=!0;Z=null;try{return b()}finally{Y=c,W=d,Z=e}}
103
103
  function Jd(a){var b=a._pendingEditorState,c=a._rootElement,d=a._headless;if((null!==c||d)&&null!==b){var e=a._editorState,f=e._selection,g=b._selection,h=0!==a._dirtyType,k=Y,m=W,l=Z,n=a._updating,r=a._observer,q=null;a._pendingEditorState=null;a._editorState=b;if(!d&&h&&null!==r){Z=a;Y=b;W=!1;a._updating=!0;try{var w=a._dirtyType,y=a._dirtyElements,E=a._dirtyLeaves;r.disconnect();O=P=N="";vb=2===w;yb=null;Q=a;tb=a._config;ub=a._nodes;xb=Q._listeners.mutation;zb=y;Ab=E;Bb=e._nodeMap;Cb=b._nodeMap;
104
- wb=b._readOnly;Db=new Map(a._keyToDOMMap);var z=new Map;Eb=z;Rb("root",null);Eb=Db=tb=Cb=Bb=Ab=zb=ub=Q=void 0;q=z}catch(qa){a._onError(qa);Dd||(Kd(a,null,c,b),Ha(a),a._dirtyType=2,Dd=!0,Jd(a),Dd=!1);return}finally{r.observe(c,{characterData:!0,childList:!0,subtree:!0}),a._updating=n,Y=k,W=m,Z=l}}b._readOnly=!0;n=a._dirtyLeaves;r=a._dirtyElements;z=a._normalizedNodes;w=a._updateTags;E=a._pendingDecorators;m=a._deferred;h&&(a._dirtyType=0,a._cloneNotNeeded.clear(),a._dirtyLeaves=new Set,a._dirtyElements=
105
- new Map,a._normalizedNodes=new Set,a._updateTags=new Set);y=a._decorators;var G=a._pendingDecorators||y,V=b._nodeMap;for(La in G)V.has(La)||(G===y&&(G=Xa(a)),delete G[La]);d=d?null:window.getSelection();if(!a._readOnly&&null!==d&&(h||null===g||g.dirty)){Z=a;Y=b;try{a:{let qa=d.anchorNode,lb=d.focusNode,he=d.anchorOffset,ie=d.focusOffset,mb=document.activeElement;if(!w.has("collaboration")||mb===c)if(K(g)){var da=g.anchor,Ub=g.focus,ud=da.key,ra=Ub.key,vd=nb(a,ud),wd=nb(a,ra),Vb=da.offset,xd=Ub.offset,
106
- Wb=g.format,yd=g.isCollapsed();h=vd;ra=wd;var La=!1;"text"===da.type&&(h=Pa(vd),La=da.getNode().getFormat()!==Wb);"text"===Ub.type&&(ra=Pa(wd));if(null!==h&&null!==ra){if(yd&&(null===f||La||K(f)&&f.format!==Wb)){var je=performance.now();Nc=[Wb,Vb,ud,je]}if(he===Vb&&ie===xd&&qa===h&&lb===ra&&("Range"!==d.type||!yd)&&(null!==mb&&c.contains(mb)||c.focus({preventScroll:!0}),!ia&&!ha||"element"!==da.type))break a;try{d.setBaseAndExtent(h,Vb,ra,xd);if(g.isCollapsed()&&c===mb){let Ma=da.getNode();if(B(Ma)){let ea=
107
- Ma.getDescendantByIndex(da.offset);null!==ea&&(Ma=ea)}let sa=a.getElementByKey(Ma.__key);if(null!==sa){let ea=sa.getBoundingClientRect();if(ea.bottom>window.innerHeight)sa.scrollIntoView(!1);else if(0>ea.top)sa.scrollIntoView();else{let zd=c.getBoundingClientRect();ea.bottom>zd.bottom?sa.scrollIntoView(!1):ea.top<zd.top&&sa.scrollIntoView()}w.add("scroll-into-view")}}Kc=!0}catch(Ma){}}}else null!==f&&Ka(a,qa,lb)&&d.removeAllRanges()}}finally{Z=l,Y=k}}null!==q&&Ld(a,e,b,q);null!==E&&(a._decorators=
108
- E,a._pendingDecorators=null,Md("decorator",a,!0,E));c=Ya(e);f=Ya(b);c!==f&&Md("textcontent",a,!0,f);Md("update",a,!0,{dirtyElements:r,dirtyLeaves:n,editorState:b,normalizedNodes:z,prevEditorState:e,tags:w});a._deferred=[];if(0!==m.length){b=a._updating;a._updating=!0;try{for(e=0;e<m.length;e++)m[e]()}finally{a._updating=b}}b=a._updates;if(0!==b.length){let [qa,lb]=b.shift();Nd(a,qa,lb)}}}function Ld(a,b,c,d){a._listeners.mutation.forEach((e,f)=>{e=d.get(e);void 0!==e&&f(e)})}
109
- function Md(a,b,c,...d){let e=b._updating;b._updating=c;try{let f=Array.from(b._listeners[a]);for(a=0;a<f.length;a++)f[a].apply(null,d)}finally{b._updating=e}}function T(a,b,c){if(!1===a._updating||Z!==a){let f=!1;a.update(()=>{f=T(a,b,c)});return f}let d=cb(a);for(let f=4;0<=f;f--)for(let g=0;g<d.length;g++){var e=d[g]._commands.get(b);if(void 0!==e&&(e=e[f],void 0!==e))for(let h of e)if(!0===h(c,a))return!0}return!1}
110
- function Od(a,b){let c=a._updates;for(b=b||!1;0!==c.length;){let [d,e]=c.shift(),f,g;void 0!==e&&(f=e.onUpdate,g=e.tag,e.skipTransforms&&(b=!0),f&&a._deferred.push(f),g&&a._updateTags.add(g));d()}return b}
104
+ wb=b._readOnly;Db=new Map(a._keyToDOMMap);var z=new Map;Eb=z;Rb("root",null);Eb=Db=tb=Cb=Bb=Ab=zb=ub=Q=void 0;q=z}catch(da){a._onError(da);if(Dd)throw da;Kd(a,null,c,b);Ha(a);a._dirtyType=2;Dd=!0;Jd(a);Dd=!1;return}finally{r.observe(c,{characterData:!0,childList:!0,subtree:!0}),a._updating=n,Y=k,W=m,Z=l}}b._readOnly=!0;n=a._dirtyLeaves;r=a._dirtyElements;z=a._normalizedNodes;w=a._updateTags;E=a._pendingDecorators;m=a._deferred;h&&(a._dirtyType=0,a._cloneNotNeeded.clear(),a._dirtyLeaves=new Set,a._dirtyElements=
105
+ new Map,a._normalizedNodes=new Set,a._updateTags=new Set);y=a._decorators;var G=a._pendingDecorators||y,V=b._nodeMap;for(La in G)V.has(La)||(G===y&&(G=Xa(a)),delete G[La]);d=d?null:window.getSelection();if(!a._readOnly&&null!==d&&(h||null===g||g.dirty)){Z=a;Y=b;try{a:{let da=d.anchorNode,lb=d.focusNode,he=d.anchorOffset,ie=d.focusOffset,mb=document.activeElement;if(!w.has("collaboration")||mb===c)if(K(g)){var ea=g.anchor,Ub=g.focus,ud=ea.key,sa=Ub.key,vd=nb(a,ud),wd=nb(a,sa),Vb=ea.offset,xd=Ub.offset,
106
+ Wb=g.format,yd=g.isCollapsed();h=vd;sa=wd;var La=!1;"text"===ea.type&&(h=Pa(vd),La=ea.getNode().getFormat()!==Wb);"text"===Ub.type&&(sa=Pa(wd));if(null!==h&&null!==sa){if(yd&&(null===f||La||K(f)&&f.format!==Wb)){var je=performance.now();Nc=[Wb,Vb,ud,je]}if(he===Vb&&ie===xd&&da===h&&lb===sa&&("Range"!==d.type||!yd)&&(null!==mb&&c.contains(mb)||c.focus({preventScroll:!0}),!ja&&!ia||"element"!==ea.type))break a;try{d.setBaseAndExtent(h,Vb,sa,xd);if(g.isCollapsed()&&c===mb){let Ma=ea.getNode();if(B(Ma)){let fa=
107
+ Ma.getDescendantByIndex(ea.offset);null!==fa&&(Ma=fa)}let ta=a.getElementByKey(Ma.__key);if(null!==ta){let fa=ta.getBoundingClientRect();if(fa.bottom>window.innerHeight)ta.scrollIntoView(!1);else if(0>fa.top)ta.scrollIntoView();else{let zd=c.getBoundingClientRect();Math.floor(fa.bottom)>Math.floor(zd.bottom)?ta.scrollIntoView(!1):Math.floor(fa.top)<Math.floor(zd.top)&&ta.scrollIntoView()}w.add("scroll-into-view")}}Kc=!0}catch(Ma){}}}else null!==f&&Ka(a,da,lb)&&d.removeAllRanges()}}finally{Z=l,Y=k}}null!==
108
+ q&&Ld(a,e,b,q);null!==E&&(a._decorators=E,a._pendingDecorators=null,Md("decorator",a,!0,E));c=Ya(e);f=Ya(b);c!==f&&Md("textcontent",a,!0,f);Md("update",a,!0,{dirtyElements:r,dirtyLeaves:n,editorState:b,normalizedNodes:z,prevEditorState:e,tags:w});a._deferred=[];if(0!==m.length){b=a._updating;a._updating=!0;try{for(e=0;e<m.length;e++)m[e]()}finally{a._updating=b}}b=a._updates;if(0!==b.length){let [da,lb]=b.shift();Nd(a,da,lb)}}}
109
+ function Ld(a,b,c,d){a._listeners.mutation.forEach((e,f)=>{e=d.get(e);void 0!==e&&f(e)})}function Md(a,b,c,...d){let e=b._updating;b._updating=c;try{let f=Array.from(b._listeners[a]);for(a=0;a<f.length;a++)f[a].apply(null,d)}finally{b._updating=e}}
110
+ function T(a,b,c){if(!1===a._updating||Z!==a){let f=!1;a.update(()=>{f=T(a,b,c)});return f}let d=bb(a);for(let f=4;0<=f;f--)for(let g=0;g<d.length;g++){var e=d[g]._commands.get(b);if(void 0!==e&&(e=e[f],void 0!==e))for(let h of e)if(!0===h(c,a))return!0}return!1}function Od(a,b){let c=a._updates;for(b=b||!1;0!==c.length;){let [d,e]=c.shift(),f,g;void 0!==e&&(f=e.onUpdate,g=e.tag,e.skipTransforms&&(b=!0),f&&a._deferred.push(f),g&&a._updateTags.add(g));d()}return b}
111
111
  function Nd(a,b,c){let d=a._updateTags;var e=!1;if(void 0!==c){var f=c.onUpdate;e=c.tag;null!=e&&d.add(e);e=c.skipTransforms}f&&a._deferred.push(f);c=a._editorState;f=a._pendingEditorState;let g=!1;null===f&&(f=a._pendingEditorState=new Pd(new Map(c._nodeMap)),g=!0);let h=Y,k=W,m=Z,l=a._updating;Y=f;W=!1;a._updating=!0;Z=a;try{g&&!a._headless&&(f._selection=rd(a));let n=a._compositionKey;b();e=Od(a,e);Ad(f,a);0!==a._dirtyType&&(e?Fd(f,a):Gd(f,a),Od(a),pb(c,f,a._dirtyLeaves,a._dirtyElements));n!==
112
112
  a._compositionKey&&(f._flushSync=!0);let r=f._selection;if(K(r)){let q=f._nodeMap,w=r.focus.key;void 0!==q.get(r.anchor.key)&&void 0!==q.get(w)||p(19)}else Pc(r)&&0===r._nodes.size&&(f._selection=null)}catch(n){a._onError(n);a._pendingEditorState=c;a._dirtyType=2;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();Jd(a);return}finally{Y=h,W=k,Z=m,a._updating=l,Wa=0}0!==a._dirtyType||Qd(f,a)?f._flushSync?(f._flushSync=!1,Jd(a)):g&&Ja(()=>{Jd(a)}):(f._flushSync=!1,g&&(d.clear(),
113
113
  a._deferred=[],a._pendingEditorState=null))}function v(a,b,c){a._updating?a._updates.push([b,c]):Nd(a,b,c)}
@@ -126,12 +126,12 @@ this.name)}remove(a){I();Rd(this,!0,a)}replace(a){I();let b=this.__key;a=a.getWr
126
126
  d&&(Ta(c),K(e)&&(h=d.__key,g=e.anchor,d=e.focus,g="element"===g.type&&g.key===h&&g.offset===f+1,h="element"===d.type&&d.key===h&&d.offset===f+1));f=this.getParentOrThrow().getWritable();d=c.__key;c.__parent=b.__parent;let k=f.__children;b=k.indexOf(b.__key);-1===b&&p(31);k.splice(b+1,0,d);Ua(c);K(e)&&(sd(e,f,b+1),c=f.__key,g&&e.anchor.set(c,b+2,"element"),h&&e.focus.set(c,b+2,"element"));return a}insertBefore(a){I();var b=this.getWritable(),c=a.getWritable();Ta(c);let d=this.getParentOrThrow().getWritable(),
127
127
  e=c.__key;c.__parent=b.__parent;let f=d.__children;b=f.indexOf(b.__key);-1===b&&p(31);f.splice(b,0,e);Ua(c);c=u();K(c)&&sd(c,d,b);return a}selectPrevious(a,b){I();let c=this.getPreviousSibling(),d=this.getParentOrThrow();return null===c?d.select(0,0):B(c)?c.select():A(c)?c.select(a,b):(a=c.getIndexWithinParent()+1,d.select(a,a))}selectNext(a,b){I();let c=this.getNextSibling(),d=this.getParentOrThrow();return null===c?d.select():B(c)?c.select(0,0):A(c)?c.select(a,b):(a=c.getIndexWithinParent(),d.select(a,
128
128
  a))}markDirty(){this.getWritable()}}class Ud extends Td{constructor(a){super(a)}decorate(){p(47)}isIsolated(){return!1}isTopLevel(){return!1}}function x(a){return a instanceof Ud}
129
- class Vd extends Td{constructor(a){super(a);this.__children=[];this.__indent=this.__format=0;this.__dir=null}getFormat(){return this.getLatest().__format}getFormatType(){let a=this.getFormat();return pa[a]||""}getIndent(){return this.getLatest().__indent}getChildren(){let a=this.getLatest().__children,b=[];for(let c=0;c<a.length;c++){let d=J(a[c]);null!==d&&b.push(d)}return b}getChildrenKeys(){return this.getLatest().__children}getChildrenSize(){return this.getLatest().__children.length}isEmpty(){return 0===
129
+ class Vd extends Td{constructor(a){super(a);this.__children=[];this.__indent=this.__format=0;this.__dir=null}getFormat(){return this.getLatest().__format}getFormatType(){let a=this.getFormat();return qa[a]||""}getIndent(){return this.getLatest().__indent}getChildren(){let a=this.getLatest().__children,b=[];for(let c=0;c<a.length;c++){let d=J(a[c]);null!==d&&b.push(d)}return b}getChildrenKeys(){return this.getLatest().__children}getChildrenSize(){return this.getLatest().__children.length}isEmpty(){return 0===
130
130
  this.getChildrenSize()}isDirty(){let a=F()._dirtyElements;return null!==a&&a.has(this.__key)}isLastChild(){let a=this.getLatest();return a.getParentOrThrow().getLastChild()===a}getAllTextNodes(a){let b=[],c=this.getLatest().__children;for(let e=0;e<c.length;e++){var d=J(c[e]);!A(d)||!a&&d.isInert()?B(d)&&(d=d.getAllTextNodes(a),b.push(...d)):b.push(d)}return b}getFirstDescendant(){let a=this.getFirstChild();for(;null!==a;){if(B(a)){let b=a.getFirstChild();if(null!==b){a=b;continue}}break}return a}getLastDescendant(){let a=
131
131
  this.getLastChild();for(;null!==a;){if(B(a)){let b=a.getLastChild();if(null!==b){a=b;continue}}break}return a}getDescendantByIndex(a){let b=this.getChildren(),c=b.length;if(a>=c)return a=b[c-1],B(a)&&a.getLastDescendant()||a||null;a=b[a];return B(a)&&a.getFirstDescendant()||a||null}getFirstChild(){let a=this.getLatest().__children;return 0===a.length?null:J(a[0])}getFirstChildOrThrow(){let a=this.getFirstChild();null===a&&p(45,this.__key);return a}getLastChild(){let a=this.getLatest().__children,
132
- b=a.length;return 0===b?null:J(a[b-1])}getChildAtIndex(a){a=this.getLatest().__children[a];return void 0===a?null:J(a)}getTextContent(a,b){let c="",d=this.getChildren(),e=d.length;for(let f=0;f<e;f++){let g=d[f];c+=g.getTextContent(a,b);B(g)&&f!==e-1&&!g.isInline()&&(c+="\n\n")}return c}getDirection(){return this.getLatest().__dir}hasFormat(a){a=oa[a];return 0!==(this.getFormat()&a)}select(a,b){I();let c=u();var d=this.getChildrenSize();void 0===a&&(a=d);void 0===b&&(b=d);d=this.__key;if(K(c))c.anchor.set(d,
132
+ b=a.length;return 0===b?null:J(a[b-1])}getChildAtIndex(a){a=this.getLatest().__children[a];return void 0===a?null:J(a)}getTextContent(a,b){let c="",d=this.getChildren(),e=d.length;for(let f=0;f<e;f++){let g=d[f];c+=g.getTextContent(a,b);B(g)&&f!==e-1&&!g.isInline()&&(c+="\n\n")}return c}getDirection(){return this.getLatest().__dir}hasFormat(a){a=pa[a];return 0!==(this.getFormat()&a)}select(a,b){I();let c=u();var d=this.getChildrenSize();void 0===a&&(a=d);void 0===b&&(b=d);d=this.__key;if(K(c))c.anchor.set(d,
133
133
  a,"element"),c.focus.set(d,b,"element"),c.dirty=!0;else return qd(d,a,d,b,"element","element");return c}selectStart(){let a=this.getFirstDescendant();return B(a)||A(a)?a.select(0,0):null!==a?a.selectPrevious():this.select(0,0)}selectEnd(){let a=this.getLastDescendant();return B(a)||A(a)?a.select():null!==a?a.selectNext():this.select()}clear(){I();let a=this.getWritable();this.getChildren().forEach(b=>b.remove());return a}append(...a){I();return this.splice(this.getChildrenSize(),0,a)}setDirection(a){I();
134
- let b=this.getWritable();b.__dir=a;return b}setFormat(a){I();this.getWritable().__format=oa[a]||0;return this}setIndent(a){I();this.getWritable().__indent=a;return this}splice(a,b,c){I();let d=this.getWritable();var e=d.__key;let f=d.__children,g=c.length;var h=[];for(let k=0;k<g;k++){let m=c[k],l=m.getWritable();m.__key===e&&p(46);Ta(l);l.__parent=e;h.push(l.__key)}(c=this.getChildAtIndex(a-1))&&Va(c);(e=this.getChildAtIndex(a+b))&&Va(e);a===f.length?(f.push(...h),a=[]):a=f.splice(a,b,...h);if(a.length&&
134
+ let b=this.getWritable();b.__dir=a;return b}setFormat(a){I();this.getWritable().__format=pa[a]||0;return this}setIndent(a){I();this.getWritable().__indent=a;return this}splice(a,b,c){I();let d=this.getWritable();var e=d.__key;let f=d.__children,g=c.length;var h=[];for(let k=0;k<g;k++){let m=c[k],l=m.getWritable();m.__key===e&&p(46);Ta(l);l.__parent=e;h.push(l.__key)}(c=this.getChildAtIndex(a-1))&&Va(c);(e=this.getChildAtIndex(a+b))&&Va(e);a===f.length?(f.push(...h),a=[]):a=f.splice(a,b,...h);if(a.length&&
135
135
  (b=u(),K(b))){let k=new Set(a),m=new Set(h);h=r=>{for(r=r.getNode();r;){const q=r.__key;if(k.has(q)&&!m.has(q))return!0;r=r.getParent()}return!1};let {anchor:l,focus:n}=b;h(l)&&Bd(l,l.getNode(),this,c,e);h(n)&&Bd(n,n.getNode(),this,c,e);h=a.length;for(b=0;b<h;b++)c=J(a[b]),null!=c&&(c.getWritable().__parent=null);0!==f.length||this.canBeEmpty()||M(this)||this.remove()}return d}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"element",
136
136
  version:1}}insertNewAfter(){return null}canInsertTab(){return!1}canIndent(){return!0}collapseAtStart(){return!1}excludeFromCopy(){return!1}canExtractContents(){return!0}canReplaceWith(){return!0}canInsertAfter(){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}canMergeWith(){return!1}extractWithChild(){return!1}}function B(a){return a instanceof Vd}
137
137
  class Wd extends Vd{static getType(){return"root"}static clone(){return new Wd}constructor(){super("root");this.__cachedText=null}getTopLevelElementOrThrow(){p(51)}getTextContent(a,b){let c=this.__cachedText;return!W&&0!==F()._dirtyType||null===c||a&&!1===b?super.getTextContent(a,b):c}remove(){p(52)}replace(){p(53)}insertBefore(){p(54)}insertAfter(){p(55)}updateDOM(){return!1}append(...a){for(let b=0;b<a.length;b++){let c=a[b];B(c)||x(c)||p(56)}return super.append(...a)}static importJSON(a){let b=
@@ -140,14 +140,14 @@ function Yd(a){let b=a.exportJSON();var c=a.constructor;b.type!==c.getType()&&p(
140
140
  class Pd{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){return Id(this,a)}clone(a){a=new Pd(this._nodeMap,void 0===a?this._selection:a);a._readOnly=!0;return a}toJSON(){return Id(this,()=>({root:Yd(Za())}))}}
141
141
  class Zd extends Td{static getType(){return"linebreak"}static clone(a){return new Zd(a.__key)}constructor(a){super(a)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:a=>{let b=a.parentElement;return null!=b&&b.firstChild===a&&b.lastChild===a?null:{conversion:$d,priority:0}}}}static importJSON(){return kd()}exportJSON(){return{type:"linebreak",version:1}}}function $d(){return{node:kd()}}function kd(){return new Zd}
142
142
  function Sa(a){return a instanceof Zd}function ae(a,b){return b&16?"code":b&32?"sub":b&64?"sup":null}function be(a,b){return b&1?"strong":b&2?"em":"span"}
143
- function ce(a,b,c,d,e){a=d.classList;d=gb(e,"base");void 0!==d&&a.add(...d);d=gb(e,"underlineStrikethrough");let f=!1,g=b&8&&b&4;var h=c&8&&c&4;void 0!==d&&(h?(f=!0,g||a.add(...d)):g&&a.remove(...d));for(let k in na)h=na[k],d=gb(e,k),void 0!==d&&(c&h?!f||"underline"!==k&&"strikethrough"!==k?(0===(b&h)||g&&"underline"===k||"strikethrough"===k)&&a.add(...d):b&h&&a.remove(...d):b&h&&a.remove(...d))}
144
- function de(a,b,c){let d=b.firstChild;c=c.isComposing();a+=c?ja:"";if(null==d)b.textContent=a;else if(b=d.nodeValue,b!==a)if(c){c=b.length;let e=a.length,f=0,g=0;for(;f<c&&f<e&&b[f]===a[f];)f++;for(;g+f<c&&g+f<e&&b[c-g-1]===a[e-g-1];)g++;a=[f,c-f-g,a.slice(f,e-g)];let [h,k,m]=a;0!==k&&d.deleteData(h,k);d.insertData(h,m)}else d.nodeValue=a}
143
+ function ce(a,b,c,d,e){a=d.classList;d=gb(e,"base");void 0!==d&&a.add(...d);d=gb(e,"underlineStrikethrough");let f=!1,g=b&8&&b&4;var h=c&8&&c&4;void 0!==d&&(h?(f=!0,g||a.add(...d)):g&&a.remove(...d));for(let k in oa)h=oa[k],d=gb(e,k),void 0!==d&&(c&h?!f||"underline"!==k&&"strikethrough"!==k?(0===(b&h)||g&&"underline"===k||"strikethrough"===k)&&a.add(...d):b&h&&a.remove(...d):b&h&&a.remove(...d))}
144
+ function de(a,b,c){let d=b.firstChild;c=c.isComposing();a+=c?ka:"";if(null==d)b.textContent=a;else if(b=d.nodeValue,b!==a)if(c||ca){c=b.length;let e=a.length,f=0,g=0;for(;f<c&&f<e&&b[f]===a[f];)f++;for(;g+f<c&&g+f<e&&b[c-g-1]===a[e-g-1];)g++;a=[f,c-f-g,a.slice(f,e-g)];let [h,k,m]=a;0!==k&&d.deleteData(h,k);d.insertData(h,m)}else d.nodeValue=a}
145
145
  class ee extends Td{static getType(){return"text"}static clone(a){return new ee(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}getDetail(){return this.getLatest().__detail}getMode(){let a=this.getLatest();return ua[a.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===F()._compositionKey}isSegmented(){return 2===
146
- this.getLatest().__mode}isInert(){return 3===this.getLatest().__mode}isDirectionless(){return 0!==(this.getLatest().__detail&1)}isUnmergeable(){return 0!==(this.getLatest().__detail&2)}hasFormat(a){a=na[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){let c=this.getLatest().__format;return Qa(c,a,b)}createDOM(a){var b=this.__format,
146
+ this.getLatest().__mode}isInert(){return 3===this.getLatest().__mode}isDirectionless(){return 0!==(this.getLatest().__detail&1)}isUnmergeable(){return 0!==(this.getLatest().__detail&2)}hasFormat(a){a=oa[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){let c=this.getLatest().__format;return Qa(c,a,b)}createDOM(a){var b=this.__format,
147
147
  c=ae(this,b);let d=be(this,b),e=document.createElement(null===c?d:c),f=e;null!==c&&(f=document.createElement(d),e.appendChild(f));c=f;de(this.__text,c,this);a=a.theme.text;void 0!==a&&ce(d,0,b,c,a);b=this.__style;""!==b&&(e.style.cssText=b);return e}updateDOM(a,b,c){let d=this.__text;var e=a.__format,f=this.__format,g=ae(this,e);let h=ae(this,f);var k=be(this,e);let m=be(this,f);if((null===g?k:g)!==(null===h?m:h))return!0;if(g===h&&k!==m)return e=b.firstChild,null==e&&p(48),a=g=document.createElement(m),
148
148
  de(d,a,this),c=c.theme.text,void 0!==c&&ce(m,0,f,a,c),b.replaceChild(g,e),!1;k=b;null!==h&&null!==g&&(k=b.firstChild,null==k&&p(49));de(d,k,this);c=c.theme.text;void 0!==c&&e!==f&&ce(m,e,f,k,c);f=this.__style;a.__style!==f&&(b.style.cssText=f);return!1}static importDOM(){return{"#text":()=>({conversion:fe,priority:0}),b:()=>({conversion:ge,priority:0}),em:()=>({conversion:ke,priority:0}),i:()=>({conversion:ke,priority:0}),span:()=>({conversion:le,priority:0}),strong:()=>({conversion:ke,priority:0}),
149
149
  u:()=>({conversion:ke,priority:0})}}static importJSON(a){let b=L(a.text);b.setFormat(a.format);b.setDetail(a.detail);b.setMode(a.mode);b.setStyle(a.style);return b}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),type:"text",version:1}}selectionTransform(){}setFormat(a){I();let b=this.getWritable();b.__format=a;return b}setDetail(a){I();let b=this.getWritable();b.__detail=a;return b}setStyle(a){I();let b=this.getWritable();
150
- b.__style=a;return b}toggleFormat(a){a=na[a];return this.setFormat(this.getFormat()^a)}toggleDirectionless(){I();let a=this.getWritable();a.__detail^=1;return a}toggleUnmergeable(){I();let a=this.getWritable();a.__detail^=2;return a}setMode(a){I();a=ta[a];let b=this.getWritable();b.__mode=a;return b}setTextContent(a){I();let b=this.getWritable();b.__text=a;return b}select(a,b){I();let c=u();var d=this.getTextContent();let e=this.__key;"string"===typeof d?(d=d.length,void 0===a&&(a=d),void 0===b&&
150
+ b.__style=a;return b}toggleFormat(a){a=oa[a];return this.setFormat(this.getFormat()^a)}toggleDirectionless(){I();let a=this.getWritable();a.__detail^=1;return a}toggleUnmergeable(){I();let a=this.getWritable();a.__detail^=2;return a}setMode(a){I();a=ra[a];let b=this.getWritable();b.__mode=a;return b}setTextContent(a){I();let b=this.getWritable();b.__text=a;return b}select(a,b){I();let c=u();var d=this.getTextContent();let e=this.__key;"string"===typeof d?(d=d.length,void 0===a&&(a=d),void 0===b&&
151
151
  (b=d)):b=a=0;if(K(c))d=F()._compositionKey,d!==c.anchor.key&&d!==c.focus.key||H(e),c.setTextNodeRange(this,a,this,b);else return qd(e,a,e,b,"text","text");return c}spliceText(a,b,c,d){I();let e=this.getWritable(),f=e.__text,g=c.length,h=a;0>h&&(h=g+h,0>h&&(h=0));let k=u();d&&K(k)&&(a+=g,k.setTextNodeRange(e,a,e,a));b=f.slice(0,h)+c+f.slice(h+b);e.__text=b;return e}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...a){I();var b=this.getLatest(),c=b.getTextContent(),d=b.__key,
152
152
  e=F()._compositionKey,f=new Set(a);a=[];var g=c.length,h="";for(var k=0;k<g;k++)""!==h&&f.has(k)&&(a.push(h),h=""),h+=c[k];""!==h&&a.push(h);f=a.length;if(0===f)return[];if(a[0]===c)return[b];var m=a[0];c=b.getParentOrThrow();k=c.__key;let l=b.getFormat(),n=b.getStyle(),r=b.__detail;g=!1;b.isSegmented()?(h=L(m),h.__parent=k,h.__format=l,h.__style=n,h.__detail=r,g=!0):(h=b.getWritable(),h.__text=m);b=u();h=[h];m=m.length;for(let y=1;y<f;y++){var q=a[y],w=q.length;q=L(q).getWritable();q.__format=l;
153
153
  q.__style=n;q.__detail=r;let E=q.__key;w=m+w;if(K(b)){let z=b.anchor,G=b.focus;z.key===d&&"text"===z.type&&z.offset>m&&z.offset<=w&&(z.key=E,z.offset-=m,b.dirty=!0);G.key===d&&"text"===G.type&&G.offset>m&&G.offset<=w&&(G.key=E,G.offset-=m,b.dirty=!0)}e===d&&H(E);m=w;q.__parent=k;h.push(q)}Ua(this);e=c.getWritable().__children;d=e.indexOf(d);a=h.map(y=>y.__key);g?(e.splice(d,0,...a),this.remove()):e.splice(d,1,...a);K(b)&&sd(b,c,d,f-1);return h}mergeWithSibling(a){var b=a===this.getPreviousSibling();
@@ -159,10 +159,10 @@ b.setDirection(a.direction);return b}exportJSON(){return{...super.exportJSON(),t
159
159
  function oe(){return{node:ad()}}function ad(){return new ne}function Kd(a,b,c,d){let e=a._keyToDOMMap;e.clear();a._editorState=Xd();a._pendingEditorState=d;a._compositionKey=null;a._dirtyType=0;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();a._normalizedNodes=new Set;a._updateTags=new Set;a._updates=[];d=a._observer;null!==d&&(d.disconnect(),a._observer=null);null!==b&&(b.textContent="");null!==c&&(c.textContent="",e.set("root",c))}
160
160
  function pe(a){let b=new Map,c=new Set;a.forEach(d=>{d=d.klass.importDOM.bind(d.klass);if(!c.has(d)){c.add(d);var e=d();null!==e&&Object.keys(e).forEach(f=>{let g=b.get(f);void 0===g&&(g=[],b.set(f,g));g.push(e[f])})}});return b}
161
161
  class qe{constructor(a,b,c,d,e,f){this._parentEditor=b;this._rootElement=null;this._editorState=a;this._compositionKey=this._pendingEditorState=null;this._deferred=[];this._keyToDOMMap=new Map;this._updates=[];this._updating=!1;this._listeners={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=
162
- new Set;this._dirtyElements=new Map;this._normalizedNodes=new Set;this._updateTags=new Set;this._observer=null;this._key=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5);this._onError=e;this._htmlConversions=f;this._headless=this._readOnly=!1}isComposing(){return null!=this._compositionKey}registerUpdateListener(a){let b=this._listeners.update;b.add(a);return()=>{b.delete(a)}}registerReadOnlyListener(a){let b=this._listeners.readonly;b.add(a);return()=>{b.delete(a)}}registerDecoratorListener(a){let b=
163
- this._listeners.decorator;b.add(a);return()=>{b.delete(a)}}registerTextContentListener(a){let b=this._listeners.textcontent;b.add(a);return()=>{b.delete(a)}}registerRootListener(a){let b=this._listeners.root;a(this._rootElement,null);b.add(a);return()=>{a(null,this._rootElement);b.delete(a)}}registerCommand(a,b,c){void 0===c&&p(35);let d=this._commands;d.has(a)||d.set(a,[new Set,new Set,new Set,new Set,new Set]);let e=d.get(a);void 0===e&&p(36,String(a));let f=e[c];f.add(b);return()=>{f.delete(b);
164
- e.every(g=>0===g.size)&&d.delete(a)}}registerMutationListener(a,b){void 0===this._nodes.get(a.getType())&&p(37,a.name);let c=this._listeners.mutation;c.set(b,a);return()=>{c.delete(b)}}registerNodeTransform(a,b){let c=a.getType(),d=this._nodes.get(c);void 0===d&&p(37,a.name);let e=d.transforms;e.add(b);$a(this,c);return()=>{e.delete(b)}}hasNodes(a){for(let b=0;b<a.length;b++){let c=a[b].getType();if(!this._nodes.has(c))return!1}return!0}dispatchCommand(a,b){return T(this,a,b)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(a){let b=
165
- this._rootElement;if(a!==b){var c=this._pendingEditorState||this._editorState;this._rootElement=a;Kd(this,b,a,c);if(null!==b&&!this._config.disableEvents){0!==Jc&&(Jc--,0===Jc&&b.ownerDocument.removeEventListener("selectionchange",Wc));c=b.__lexicalEditor;if(null!==c||void 0!==c){if(null!==c._parentEditor){var d=cb(c);d=d[d.length-1]._key;Vc.get(d)===c&&Vc.delete(d)}else Vc.delete(c._key);b.__lexicalEditor=null}c=Uc(b);for(d=0;d<c.length;d++)c[d]();b.__lexicalEventHandles=[]}null!==a&&(c=a.style,
162
+ new Set;this._dirtyElements=new Map;this._normalizedNodes=new Set;this._updateTags=new Set;this._observer=null;this._key=cb();this._onError=e;this._htmlConversions=f;this._headless=this._readOnly=!1}isComposing(){return null!=this._compositionKey}registerUpdateListener(a){let b=this._listeners.update;b.add(a);return()=>{b.delete(a)}}registerReadOnlyListener(a){let b=this._listeners.readonly;b.add(a);return()=>{b.delete(a)}}registerDecoratorListener(a){let b=this._listeners.decorator;b.add(a);return()=>
163
+ {b.delete(a)}}registerTextContentListener(a){let b=this._listeners.textcontent;b.add(a);return()=>{b.delete(a)}}registerRootListener(a){let b=this._listeners.root;a(this._rootElement,null);b.add(a);return()=>{a(null,this._rootElement);b.delete(a)}}registerCommand(a,b,c){void 0===c&&p(35);let d=this._commands;d.has(a)||d.set(a,[new Set,new Set,new Set,new Set,new Set]);let e=d.get(a);void 0===e&&p(36,String(a));let f=e[c];f.add(b);return()=>{f.delete(b);e.every(g=>0===g.size)&&d.delete(a)}}registerMutationListener(a,
164
+ b){void 0===this._nodes.get(a.getType())&&p(37,a.name);let c=this._listeners.mutation;c.set(b,a);return()=>{c.delete(b)}}registerNodeTransform(a,b){let c=a.getType(),d=this._nodes.get(c);void 0===d&&p(37,a.name);let e=d.transforms;e.add(b);$a(this,c);return()=>{e.delete(b)}}hasNodes(a){for(let b=0;b<a.length;b++){let c=a[b].getType();if(!this._nodes.has(c))return!1}return!0}dispatchCommand(a,b){return T(this,a,b)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(a){let b=
165
+ this._rootElement;if(a!==b){var c=this._pendingEditorState||this._editorState;this._rootElement=a;Kd(this,b,a,c);if(null!==b&&!this._config.disableEvents){0!==Jc&&(Jc--,0===Jc&&b.ownerDocument.removeEventListener("selectionchange",Wc));c=b.__lexicalEditor;if(null!==c||void 0!==c){if(null!==c._parentEditor){var d=bb(c);d=d[d.length-1]._key;Vc.get(d)===c&&Vc.delete(d)}else Vc.delete(c._key);b.__lexicalEditor=null}c=Uc(b);for(d=0;d<c.length;d++)c[d]();b.__lexicalEventHandles=[]}null!==a&&(c=a.style,
166
166
  c.userSelect="text",c.whiteSpace="pre-wrap",c.wordBreak="break-word",a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,Ha(this),this._updateTags.add("history-merge"),Jd(this),this._config.disableEvents||Xc(a,this));Md("root",this,!1,a,b)}}getElementByKey(a){return this._keyToDOMMap.get(a)||null}getEditorState(){return this._editorState}setEditorState(a,b){a.isEmpty()&&p(38);Ga(this);let c=this._pendingEditorState,d=this._updateTags;b=void 0!==b?b.tag:null;null===c||c.isEmpty()||(null!=
167
167
  b&&d.add(b),Jd(this));this._pendingEditorState=a;this._dirtyType=2;this._dirtyElements.set("root",!1);this._compositionKey=null;null!=b&&d.add(b);Jd(this)}parseEditorState(a,b){a="string"===typeof a?JSON.parse(a):a;let c=Xd(),d=Y,e=W,f=Z,g=this._dirtyElements,h=this._dirtyLeaves,k=this._cloneNotNeeded,m=this._dirtyType;this._dirtyElements=new Map;this._dirtyLeaves=new Set;this._cloneNotNeeded=new Set;this._dirtyType=0;Y=c;W=!1;Z=this;try{Hd(a.root,this._nodes),b&&b(),c._readOnly=!0}finally{this._dirtyElements=
168
168
  g,this._dirtyLeaves=h,this._cloneNotNeeded=k,this._dirtyType=m,Y=d,W=e,Z=f}return c}update(a,b){v(this,a,b)}focus(a){let b=this._rootElement;null!==b&&(b.setAttribute("autocapitalize","off"),v(this,()=>{let c=u(),d=Za();null!==c?c.dirty=!0:0!==d.getChildrenSize()&&d.selectEnd()},{onUpdate:()=>{b.removeAttribute("autocapitalize");a&&a()}}))}blur(){var a=this._rootElement;null!==a&&a.blur();a=window.getSelection();null!==a&&a.removeAllRanges()}isReadOnly(){return this._readOnly}setReadOnly(a){this._readOnly=
@@ -172,5 +172,6 @@ exports.$isGridCellNode=id;exports.$isGridNode=gd;exports.$isGridRowNode=hd;expo
172
172
  exports.$parseSerializedNode=function(a){return Hd(a,F()._nodes)};exports.$setCompositionKey=H;exports.$setSelection=Ea;exports.BLUR_COMMAND=zc;exports.CAN_REDO_COMMAND={};exports.CAN_UNDO_COMMAND={};exports.CLEAR_EDITOR_COMMAND={};exports.CLEAR_HISTORY_COMMAND={};exports.CLICK_COMMAND=Tb;exports.COMMAND_PRIORITY_CRITICAL=4;exports.COMMAND_PRIORITY_EDITOR=0;exports.COMMAND_PRIORITY_HIGH=3;exports.COMMAND_PRIORITY_LOW=1;exports.COMMAND_PRIORITY_NORMAL=2;exports.CONTROLLED_TEXT_INSERTION_COMMAND=$b;
173
173
  exports.COPY_COMMAND=wc;exports.CUT_COMMAND=xc;exports.DELETE_CHARACTER_COMMAND=Xb;exports.DELETE_LINE_COMMAND=dc;exports.DELETE_WORD_COMMAND=cc;exports.DRAGEND_COMMAND=vc;exports.DRAGOVER_COMMAND=uc;exports.DRAGSTART_COMMAND=tc;exports.DROP_COMMAND=sc;exports.DecoratorNode=Ud;exports.ElementNode=Vd;exports.FOCUS_COMMAND=yc;exports.FORMAT_ELEMENT_COMMAND={};exports.FORMAT_TEXT_COMMAND=R;exports.GridCellNode=re;exports.GridNode=se;exports.GridRowNode=te;exports.INDENT_CONTENT_COMMAND={};
174
174
  exports.INSERT_LINE_BREAK_COMMAND=Yb;exports.INSERT_PARAGRAPH_COMMAND=Zb;exports.KEY_ARROW_DOWN_COMMAND=lc;exports.KEY_ARROW_LEFT_COMMAND=ic;exports.KEY_ARROW_RIGHT_COMMAND=gc;exports.KEY_ARROW_UP_COMMAND=kc;exports.KEY_BACKSPACE_COMMAND=oc;exports.KEY_DELETE_COMMAND=qc;exports.KEY_ENTER_COMMAND=mc;exports.KEY_ESCAPE_COMMAND=pc;exports.KEY_MODIFIER_COMMAND=Ac;exports.KEY_SPACE_COMMAND=nc;exports.KEY_TAB_COMMAND=rc;exports.LineBreakNode=Zd;exports.MOVE_TO_END=hc;exports.MOVE_TO_START=jc;
175
- exports.OUTDENT_CONTENT_COMMAND={};exports.PASTE_COMMAND=ac;exports.ParagraphNode=ne;exports.REDO_COMMAND=fc;exports.REMOVE_TEXT_COMMAND=bc;exports.RootNode=Wd;exports.SELECTION_CHANGE_COMMAND=Sb;exports.TextNode=ee;exports.UNDO_COMMAND=ec;exports.VERSION="0.3.2";exports.createCommand=function(){return{}};
176
- exports.createEditor=function(a={}){var b=a.theme||{};let c=a.parentEditor||null,d=a.disableEvents||!1,e=Xd(),f=a.editorState,g=[Wd,ee,Zd,ne,...(a.nodes||[])],h=a.onError;a=a.readOnly||!1;let k=new Map;for(let m=0;m<g.length;m++){let l=g[m],n=l.getType();k.set(n,{klass:l,transforms:new Set})}b=new qe(e,c,k,{disableEvents:d,theme:b},h,pe(k),a);void 0!==f&&(b._pendingEditorState=f,b._dirtyType=2);return b}
175
+ exports.OUTDENT_CONTENT_COMMAND={};exports.PASTE_COMMAND=ac;exports.ParagraphNode=ne;exports.REDO_COMMAND=fc;exports.REMOVE_TEXT_COMMAND=bc;exports.RootNode=Wd;exports.SELECTION_CHANGE_COMMAND=Sb;exports.TextNode=ee;exports.UNDO_COMMAND=ec;exports.VERSION="0.3.3";exports.createCommand=function(){return{}};
176
+ exports.createEditor=function(a){var b=a||{},c=Z,d=b.theme||{};let e=void 0===a?c:b.parentEditor||null,f=b.disableEvents||!1,g=Xd(),h=b.namespace||(null!==e?e._config.namespace:cb()),k=b.editorState,m=[Wd,ee,Zd,ne,...(b.nodes||[])],l=b.onError;b=b.readOnly||!1;if(void 0===a&&null!==c)a=c._nodes;else for(a=new Map,c=0;c<m.length;c++){let n=m[c],r=n.getType();a.set(r,{klass:n,transforms:new Set})}d=new qe(g,e,a,{disableEvents:f,namespace:h,theme:d},l,pe(a),b);void 0!==k&&(d._pendingEditorState=k,d._dirtyType=
177
+ 2);return d}
package/README.md CHANGED
@@ -37,6 +37,7 @@ An editor instance can be created from the `lexical` package and accepts an opti
37
37
  import {createEditor} from 'lexical';
38
38
 
39
39
  const config = {
40
+ namespace: 'MyEditor',
40
41
  theme: {
41
42
  ...
42
43
  },
package/package.json CHANGED
@@ -9,12 +9,15 @@
9
9
  "rich-text"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.3.2",
12
+ "version": "0.3.3",
13
13
  "main": "Lexical.js",
14
14
  "typings": "Lexical.d.ts",
15
15
  "repository": {
16
16
  "type": "git",
17
17
  "url": "https://github.com/facebook/lexical",
18
18
  "directory": "packages/lexical"
19
+ },
20
+ "devDependencies": {
21
+ "utility-types": "^3.10.0"
19
22
  }
20
23
  }