lexical 0.7.1 → 0.7.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.dev.js CHANGED
@@ -6,6 +6,8 @@
6
6
  */
7
7
  'use strict';
8
8
 
9
+ var lexical = require('lexical');
10
+
9
11
  /**
10
12
  * Copyright (c) Meta Platforms, Inc. and affiliates.
11
13
  *
@@ -69,18 +71,6 @@ const KEY_MODIFIER_COMMAND = createCommand('KEY_MODIFIER_COMMAND');
69
71
  */
70
72
  const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
71
73
 
72
- /**
73
- * Copyright (c) Meta Platforms, Inc. and affiliates.
74
- *
75
- * This source code is licensed under the MIT license found in the
76
- * LICENSE file in the root directory of this source tree.
77
- *
78
- */
79
-
80
- const getSelection = () => CAN_USE_DOM ? window.getSelection() : null;
81
-
82
- var getDOMSelection = getSelection;
83
-
84
74
  /**
85
75
  * Copyright (c) Meta Platforms, Inc. and affiliates.
86
76
  *
@@ -232,7 +222,7 @@ function getLastSelection(editor) {
232
222
  }
233
223
 
234
224
  function handleTextMutation(target, node, editor) {
235
- const domSelection = getDOMSelection();
225
+ const domSelection = getDOMSelection(editor._window);
236
226
  let anchorOffset = null;
237
227
  let focusOffset = null;
238
228
 
@@ -291,7 +281,7 @@ function $flushMutations$1(editor, mutations, observer) {
291
281
  // processed outside of the Lexical engine.
292
282
  if (shouldFlushTextMutations && $isTextNode(targetNode) && shouldUpdateTextNodeFromMutation(selection, targetDOM, targetNode)) {
293
283
  handleTextMutation( // nodeType === DOM_TEXT_TYPE is a Text DOM node
294
- targetDOM, targetNode);
284
+ targetDOM, targetNode, editor);
295
285
  }
296
286
  } else if (type === 'childList') {
297
287
  shouldRevertSelection = true; // We attempt to "undo" any changes that have occurred outside
@@ -489,7 +479,7 @@ function getNearestEditorFromDOMNode(node) {
489
479
  return editor;
490
480
  }
491
481
 
492
- currentNode = currentNode.parentNode;
482
+ currentNode = getParentElement(currentNode);
493
483
  }
494
484
 
495
485
  return null;
@@ -750,7 +740,7 @@ function $getNearestNodeFromDOMNode(startingDOM, editorState) {
750
740
  return node;
751
741
  }
752
742
 
753
- dom = dom.parentNode;
743
+ dom = getParentElement(dom);
754
744
  }
755
745
 
756
746
  return null;
@@ -794,6 +784,7 @@ function internalGetRoot(editorState) {
794
784
  return editorState._nodeMap.get('root');
795
785
  }
796
786
  function $setSelection(selection) {
787
+ errorOnReadOnly();
797
788
  const editorState = getActiveEditorState();
798
789
 
799
790
  if (selection !== null) {
@@ -848,7 +839,7 @@ dom, editor) {
848
839
  return key;
849
840
  }
850
841
 
851
- node = node.parentNode;
842
+ node = getParentElement(node);
852
843
  }
853
844
 
854
845
  return null;
@@ -878,9 +869,9 @@ function getAnchorTextFromDOM(anchorNode) {
878
869
 
879
870
  return null;
880
871
  }
881
- function $updateSelectedTextFromDOM(isCompositionEnd, data) {
872
+ function $updateSelectedTextFromDOM(isCompositionEnd, editor, data) {
882
873
  // Update the text content with the latest composition text
883
- const domSelection = getDOMSelection();
874
+ const domSelection = getDOMSelection(editor._window);
884
875
 
885
876
  if (domSelection === null) {
886
877
  return;
@@ -1290,8 +1281,8 @@ function getElementByKeyOrThrow(editor, key) {
1290
1281
 
1291
1282
  return element;
1292
1283
  }
1293
- function getParentElement(element) {
1294
- const parentElement = element.assignedSlot || element.parentElement;
1284
+ function getParentElement(node) {
1285
+ const parentElement = node.assignedSlot || node.parentElement;
1295
1286
  return parentElement !== null && parentElement.nodeType === 11 ? parentElement.host : parentElement;
1296
1287
  }
1297
1288
  function scrollIntoViewIfNeeded(editor, selectionRect, rootElement) {
@@ -1566,6 +1557,9 @@ function updateDOMBlockCursorElement(editor, rootElement, nextSelection) {
1566
1557
  removeDOMBlockCursorElement(blockCursorElement, editor, rootElement);
1567
1558
  }
1568
1559
  }
1560
+ function getDOMSelection(targetWindow) {
1561
+ return !CAN_USE_DOM ? null : (targetWindow || window).getSelection();
1562
+ }
1569
1563
 
1570
1564
  /**
1571
1565
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -2430,7 +2424,7 @@ function getPrevElementByKeyOrThrow(key) {
2430
2424
  */
2431
2425
  const PASS_THROUGH_COMMAND = Object.freeze({});
2432
2426
  const ANDROID_COMPOSITION_LATENCY = 30;
2433
- const rootElementEvents = [['keydown', onKeyDown], ['mousedown', onMouseDown], ['compositionstart', onCompositionStart], ['compositionend', onCompositionEnd], ['input', onInput], ['click', onClick], ['cut', PASS_THROUGH_COMMAND], ['copy', PASS_THROUGH_COMMAND], ['dragstart', PASS_THROUGH_COMMAND], ['dragover', PASS_THROUGH_COMMAND], ['dragend', PASS_THROUGH_COMMAND], ['paste', PASS_THROUGH_COMMAND], ['focus', PASS_THROUGH_COMMAND], ['blur', PASS_THROUGH_COMMAND], ['drop', PASS_THROUGH_COMMAND]];
2427
+ const rootElementEvents = [['keydown', onKeyDown], ['pointerdown', onPointerDown], ['compositionstart', onCompositionStart], ['compositionend', onCompositionEnd], ['input', onInput], ['click', onClick], ['cut', PASS_THROUGH_COMMAND], ['copy', PASS_THROUGH_COMMAND], ['dragstart', PASS_THROUGH_COMMAND], ['dragover', PASS_THROUGH_COMMAND], ['dragend', PASS_THROUGH_COMMAND], ['paste', PASS_THROUGH_COMMAND], ['focus', PASS_THROUGH_COMMAND], ['blur', PASS_THROUGH_COMMAND], ['drop', PASS_THROUGH_COMMAND]];
2434
2428
 
2435
2429
  if (CAN_USE_BEFORE_INPUT) {
2436
2430
  rootElementEvents.push(['beforeinput', (event, editor) => onBeforeInput(event, editor)]);
@@ -2455,10 +2449,11 @@ function $shouldPreventDefaultAndInsertText(selection, text, timeStamp, isBefore
2455
2449
  const anchor = selection.anchor;
2456
2450
  const focus = selection.focus;
2457
2451
  const anchorNode = anchor.getNode();
2458
- const domSelection = getDOMSelection();
2452
+ const editor = getActiveEditor();
2453
+ const domSelection = getDOMSelection(editor._window);
2459
2454
  const domAnchorNode = domSelection !== null ? domSelection.anchorNode : null;
2460
2455
  const anchorKey = anchor.key;
2461
- const backingAnchorElement = getActiveEditor().getElementByKey(anchorKey);
2456
+ const backingAnchorElement = editor.getElementByKey(anchorKey);
2462
2457
  const textLength = text.length;
2463
2458
  return anchorKey !== focus.key || // If we're working with a non-text node.
2464
2459
  !$isTextNode(anchorNode) || // If we are replacing a range with a single character or grapheme, and not composing.
@@ -2578,7 +2573,7 @@ function onSelectionChange(domSelection, editor, isActive) {
2578
2573
  function onClick(event, editor) {
2579
2574
  updateEditor(editor, () => {
2580
2575
  const selection = $getSelection();
2581
- const domSelection = getDOMSelection();
2576
+ const domSelection = getDOMSelection(editor._window);
2582
2577
  const lastSelection = $getPreviousSelection();
2583
2578
 
2584
2579
  if ($isRangeSelection(selection)) {
@@ -2595,11 +2590,12 @@ function onClick(event, editor) {
2595
2590
  });
2596
2591
  }
2597
2592
 
2598
- function onMouseDown(event, editor) {
2593
+ function onPointerDown(event, editor) {
2599
2594
  // TODO implement text drag & drop
2600
2595
  const target = event.target;
2596
+ const pointerType = event.pointerType;
2601
2597
 
2602
- if (target instanceof Node) {
2598
+ if (target instanceof Node && pointerType !== 'touch') {
2603
2599
  updateEditor(editor, () => {
2604
2600
  // Drag & drop should not recompute selection until mouse up; otherwise the initially
2605
2601
  // selected content is lost.
@@ -2879,7 +2875,7 @@ function onInput(event, editor) {
2879
2875
 
2880
2876
  const anchor = selection.anchor;
2881
2877
  const anchorNode = anchor.getNode();
2882
- const domSelection = getDOMSelection();
2878
+ const domSelection = getDOMSelection(editor._window);
2883
2879
 
2884
2880
  if (domSelection === null) {
2885
2881
  return;
@@ -2906,7 +2902,7 @@ function onInput(event, editor) {
2906
2902
  $setCompositionKey(null);
2907
2903
  }
2908
2904
  } else {
2909
- $updateSelectedTextFromDOM(false); // onInput always fires after onCompositionEnd for FF.
2905
+ $updateSelectedTextFromDOM(false, editor); // onInput always fires after onCompositionEnd for FF.
2910
2906
 
2911
2907
  if (isFirefoxEndingComposition) {
2912
2908
  onCompositionEndImpl(editor, data || undefined);
@@ -2978,7 +2974,7 @@ function onCompositionEndImpl(editor, data) {
2978
2974
  }
2979
2975
  }
2980
2976
 
2981
- $updateSelectedTextFromDOM(true, data);
2977
+ $updateSelectedTextFromDOM(true, editor, data);
2982
2978
  }
2983
2979
 
2984
2980
  function onCompositionEnd(event, editor) {
@@ -3118,7 +3114,9 @@ function getRootElementRemoveHandles(rootElement) {
3118
3114
  const activeNestedEditorsMap = new Map();
3119
3115
 
3120
3116
  function onDocumentSelectionChange(event) {
3121
- const domSelection = getDOMSelection();
3117
+ const target = event.target;
3118
+ const targetWindow = target == null ? null : target.nodeType === 9 ? target.defaultView : target.ownerDocument.defaultView;
3119
+ const domSelection = getDOMSelection(targetWindow);
3122
3120
 
3123
3121
  if (domSelection === null) {
3124
3122
  return;
@@ -4115,7 +4113,7 @@ class RangeSelection {
4115
4113
  if ($isTextNode(lastNode) && !lastNode.isToken() && endOffset !== lastNode.getTextContentSize()) {
4116
4114
  if (lastNode.isSegmented()) {
4117
4115
  const textNode = $createTextNode(lastNode.getTextContent());
4118
- lastNode.replace(textNode, false);
4116
+ lastNode.replace(textNode);
4119
4117
  lastNode = textNode;
4120
4118
  }
4121
4119
 
@@ -4203,7 +4201,7 @@ class RangeSelection {
4203
4201
  } else {
4204
4202
  const textNode = $createTextNode(text);
4205
4203
  textNode.select();
4206
- firstNode.replace(textNode, false);
4204
+ firstNode.replace(textNode);
4207
4205
  } // Remove all selected nodes that haven't already been removed.
4208
4206
 
4209
4207
 
@@ -4937,13 +4935,13 @@ class RangeSelection {
4937
4935
  }
4938
4936
  }
4939
4937
 
4940
- const domSelection = getDOMSelection();
4938
+ const editor = getActiveEditor();
4939
+ const domSelection = getDOMSelection(editor._window);
4941
4940
 
4942
4941
  if (!domSelection) {
4943
4942
  return;
4944
4943
  }
4945
4944
 
4946
- const editor = getActiveEditor();
4947
4945
  const blockCursorElement = editor._blockCursorElement;
4948
4946
  const rootElement = editor._rootElement; // Remove the block cursor element if it exists. This will ensure selection
4949
4947
  // works as intended. If we leave it in the DOM all sorts of strange bugs
@@ -5025,7 +5023,8 @@ class RangeSelection {
5025
5023
 
5026
5024
  if (!isBackward && ( // Delete forward handle case
5027
5025
  anchor.type === 'element' && $isElementNode(anchorNode) && anchor.offset === anchorNode.getChildrenSize() || anchor.type === 'text' && anchor.offset === anchorNode.getTextContentSize())) {
5028
- const nextSibling = anchorNode.getNextSibling() || anchorNode.getParentOrThrow().getNextSibling();
5026
+ const parent = anchorNode.getParent();
5027
+ const nextSibling = anchorNode.getNextSibling() || (parent === null ? null : parent.getNextSibling());
5029
5028
 
5030
5029
  if ($isElementNode(nextSibling) && !nextSibling.canExtractContents()) {
5031
5030
  return;
@@ -5456,7 +5455,7 @@ function DEPRECATED_$createGridSelection() {
5456
5455
  function internalCreateSelection(editor) {
5457
5456
  const currentEditorState = editor.getEditorState();
5458
5457
  const lastSelection = currentEditorState._selection;
5459
- const domSelection = getDOMSelection();
5458
+ const domSelection = getDOMSelection(editor._window);
5460
5459
 
5461
5460
  if ($isNodeSelection(lastSelection) || DEPRECATED_$isGridSelection(lastSelection)) {
5462
5461
  return lastSelection.clone();
@@ -5718,7 +5717,7 @@ function adjustPointOffsetForMergedSibling(point, isBefore, key, target, textLen
5718
5717
  point.offset -= 1;
5719
5718
  }
5720
5719
  }
5721
- function updateDOMSelection(prevSelection, nextSelection, editor, domSelection, tags, rootElement, dirtyLeavesCount) {
5720
+ function updateDOMSelection(prevSelection, nextSelection, editor, domSelection, tags, rootElement, nodeCount) {
5722
5721
  const anchorDOMNode = domSelection.anchorNode;
5723
5722
  const focusDOMNode = domSelection.focusNode;
5724
5723
  const anchorOffset = domSelection.anchorOffset;
@@ -5803,7 +5802,7 @@ function updateDOMSelection(prevSelection, nextSelection, editor, domSelection,
5803
5802
  // The downside is that is makes the computation within Lexical more
5804
5803
  // complex, as now, we've sync update the DOM, but selection no longer
5805
5804
  // matches.
5806
- if (IS_CHROME && dirtyLeavesCount > 1000) {
5805
+ if (IS_CHROME && nodeCount > 1000) {
5807
5806
  window.requestAnimationFrame(() => domSelection.setBaseAndExtent(nextAnchorNode, nextAnchorOffset, nextFocusNode, nextFocusOffset));
5808
5807
  } else {
5809
5808
  domSelection.setBaseAndExtent(nextAnchorNode, nextAnchorOffset, nextFocusNode, nextFocusOffset);
@@ -5862,7 +5861,7 @@ const observerOptions = {
5862
5861
  subtree: true
5863
5862
  };
5864
5863
  function isCurrentlyReadOnlyMode() {
5865
- return isReadOnlyMode;
5864
+ return isReadOnlyMode || activeEditorState !== null && activeEditorState._readOnly;
5866
5865
  }
5867
5866
  function errorOnReadOnly() {
5868
5867
  if (isReadOnlyMode) {
@@ -5896,6 +5895,9 @@ function getActiveEditor() {
5896
5895
 
5897
5896
  return activeEditor;
5898
5897
  }
5898
+ function internalGetActiveEditor() {
5899
+ return activeEditor;
5900
+ }
5899
5901
  function $applyTransforms(editor, node, transformsCache) {
5900
5902
  const type = node.__type;
5901
5903
  const registeredNode = getRegisteredNodeOrThrow(editor, type);
@@ -6225,7 +6227,7 @@ function commitPendingUpdates(editor) {
6225
6227
  const normalizedNodes = editor._normalizedNodes;
6226
6228
  const tags = editor._updateTags;
6227
6229
  const deferred = editor._deferred;
6228
- const dirtyLeavesCount = dirtyLeaves.size;
6230
+ const nodeCount = pendingEditorState._nodeMap.size;
6229
6231
 
6230
6232
  if (needsUpdate) {
6231
6233
  editor._dirtyType = NO_DIRTY_NODES;
@@ -6242,7 +6244,7 @@ function commitPendingUpdates(editor) {
6242
6244
  // Reconciliation has finished. Now update selection and trigger listeners.
6243
6245
  // ======
6244
6246
 
6245
- const domSelection = shouldSkipDOM ? null : getDOMSelection(); // Attempt to update the DOM selection, including focusing of the root element,
6247
+ const domSelection = shouldSkipDOM ? null : getDOMSelection(editor._window); // Attempt to update the DOM selection, including focusing of the root element,
6246
6248
  // and scroll into view if needed.
6247
6249
 
6248
6250
  if (editor._editable && // domSelection will be null in headless
@@ -6262,7 +6264,7 @@ function commitPendingUpdates(editor) {
6262
6264
  removeDOMBlockCursorElement(blockCursorElement, editor, rootElement);
6263
6265
  }
6264
6266
 
6265
- updateDOMSelection(currentSelection, pendingSelection, editor, domSelection, tags, rootElement, dirtyLeavesCount);
6267
+ updateDOMSelection(currentSelection, pendingSelection, editor, domSelection, tags, rootElement, nodeCount);
6266
6268
  }
6267
6269
 
6268
6270
  updateDOMBlockCursorElement(editor, rootElement, pendingSelection);
@@ -6602,9 +6604,6 @@ function updateEditor(editor, updateFn, options) {
6602
6604
  beginUpdate(editor, updateFn, options);
6603
6605
  }
6604
6606
  }
6605
- function internalGetActiveEditor() {
6606
- return activeEditor;
6607
- }
6608
6607
 
6609
6608
  /**
6610
6609
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -6849,7 +6848,12 @@ class LexicalNode {
6849
6848
 
6850
6849
  getPreviousSiblings() {
6851
6850
  const siblings = [];
6852
- const parent = this.getParentOrThrow();
6851
+ const parent = this.getParent();
6852
+
6853
+ if (parent === null) {
6854
+ return siblings;
6855
+ }
6856
+
6853
6857
  let node = parent.getFirstChild();
6854
6858
 
6855
6859
  while (node !== null) {
@@ -6981,7 +6985,8 @@ class LexicalNode {
6981
6985
  }
6982
6986
 
6983
6987
  return false;
6984
- }
6988
+ } // TO-DO: this function can be simplified a lot
6989
+
6985
6990
 
6986
6991
  getNodesBetween(targetNode) {
6987
6992
  const isBefore = this.isBefore(targetNode);
@@ -7180,8 +7185,10 @@ class LexicalNode {
7180
7185
  removeNode(this, true, preserveEmptyParent);
7181
7186
  }
7182
7187
 
7183
- replace(replaceWith, restoreSelection = true) {
7188
+ replace(replaceWith, includeChildren) {
7184
7189
  errorOnReadOnly();
7190
+ let selection = $getSelection();
7191
+ if (selection !== null) selection = selection.clone();
7185
7192
  errorOnInsertTextNodeOnRoot(this, replaceWith);
7186
7193
  const self = this.getLatest();
7187
7194
  const toReplaceKey = this.__key;
@@ -7216,9 +7223,15 @@ class LexicalNode {
7216
7223
  writableReplaceWith.__next = nextKey;
7217
7224
  writableReplaceWith.__parent = parentKey;
7218
7225
  writableParent.__size = size;
7219
- const selection = $getSelection();
7220
7226
 
7221
- if ($isRangeSelection(selection) && restoreSelection) {
7227
+ if (includeChildren) {
7228
+ this.getChildren().forEach(child => {
7229
+ writableReplaceWith.append(child);
7230
+ });
7231
+ }
7232
+
7233
+ if ($isRangeSelection(selection)) {
7234
+ $setSelection(selection);
7222
7235
  const anchor = selection.anchor;
7223
7236
  const focus = selection.focus;
7224
7237
 
@@ -8003,7 +8016,7 @@ class ElementNode extends LexicalNode {
8003
8016
  return false;
8004
8017
  } // A shadow root is a Node that behaves like RootNode. The shadow root (and RootNode) mark the
8005
8018
  // end of the hiercharchy, most implementations should treat it as there's nothing (upwards)
8006
- // beyond this point. For example, node.getTopElement(), when performed inside a TableCellNode
8019
+ // beyond this point. For example, node.getTopLevelElement(), when performed inside a TableCellNode
8007
8020
  // will return the immediate first child underneath TableCellNode instead of RootNode.
8008
8021
 
8009
8022
 
@@ -8478,6 +8491,12 @@ function createTextInnerDOM(innerDOM, node, innerTag, format, text, config) {
8478
8491
  setTextThemeClassNames(innerTag, 0, format, innerDOM, textClassNames);
8479
8492
  }
8480
8493
  }
8494
+
8495
+ function wrapElementWith(element, tag) {
8496
+ const el = document.createElement(tag);
8497
+ el.appendChild(element);
8498
+ return el;
8499
+ }
8481
8500
  /** @noInheritDoc */
8482
8501
 
8483
8502
 
@@ -8661,43 +8680,47 @@ class TextNode extends LexicalNode {
8661
8680
 
8662
8681
  static importDOM() {
8663
8682
  return {
8664
- '#text': node => ({
8683
+ '#text': () => ({
8665
8684
  conversion: convertTextDOMNode,
8666
8685
  priority: 0
8667
8686
  }),
8668
- b: node => ({
8687
+ b: () => ({
8669
8688
  conversion: convertBringAttentionToElement,
8670
8689
  priority: 0
8671
8690
  }),
8672
- code: node => ({
8691
+ br: () => ({
8692
+ conversion: convertLineBreakToElement,
8693
+ priority: 0
8694
+ }),
8695
+ code: () => ({
8673
8696
  conversion: convertTextFormatElement,
8674
8697
  priority: 0
8675
8698
  }),
8676
- em: node => ({
8699
+ em: () => ({
8677
8700
  conversion: convertTextFormatElement,
8678
8701
  priority: 0
8679
8702
  }),
8680
- i: node => ({
8703
+ i: () => ({
8681
8704
  conversion: convertTextFormatElement,
8682
8705
  priority: 0
8683
8706
  }),
8684
- span: node => ({
8707
+ span: () => ({
8685
8708
  conversion: convertSpanElement,
8686
8709
  priority: 0
8687
8710
  }),
8688
- strong: node => ({
8711
+ strong: () => ({
8689
8712
  conversion: convertTextFormatElement,
8690
8713
  priority: 0
8691
8714
  }),
8692
- sub: node => ({
8715
+ sub: () => ({
8693
8716
  conversion: convertTextFormatElement,
8694
8717
  priority: 0
8695
8718
  }),
8696
- sup: node => ({
8719
+ sup: () => ({
8697
8720
  conversion: convertTextFormatElement,
8698
8721
  priority: 0
8699
8722
  }),
8700
- u: node => ({
8723
+ u: () => ({
8701
8724
  conversion: convertTextFormatElement,
8702
8725
  priority: 0
8703
8726
  })
@@ -8711,6 +8734,39 @@ class TextNode extends LexicalNode {
8711
8734
  node.setMode(serializedNode.mode);
8712
8735
  node.setStyle(serializedNode.style);
8713
8736
  return node;
8737
+ } // This improves Lexical's basic text output in copy+paste plus
8738
+ // for headless mode where people might use Lexical to generate
8739
+ // HTML content and not have the ability to use CSS classes.
8740
+
8741
+
8742
+ exportDOM(editor) {
8743
+ let {
8744
+ element
8745
+ } = super.exportDOM(editor); // This is the only way to properly add support for most clients,
8746
+ // even if it's semantically incorrect to have to resort to using
8747
+ // <b>, <u>, <s>, <i> elements.
8748
+
8749
+ if (element !== null) {
8750
+ if (this.hasFormat('bold')) {
8751
+ element = wrapElementWith(element, 'b');
8752
+ }
8753
+
8754
+ if (this.hasFormat('italic')) {
8755
+ element = wrapElementWith(element, 'i');
8756
+ }
8757
+
8758
+ if (this.hasFormat('strikethrough')) {
8759
+ element = wrapElementWith(element, 's');
8760
+ }
8761
+
8762
+ if (this.hasFormat('underline')) {
8763
+ element = wrapElementWith(element, 'u');
8764
+ }
8765
+ }
8766
+
8767
+ return {
8768
+ element
8769
+ };
8714
8770
  }
8715
8771
 
8716
8772
  exportJSON() {
@@ -9073,6 +9129,12 @@ function convertSpanElement(domNode) {
9073
9129
  };
9074
9130
  }
9075
9131
 
9132
+ function convertLineBreakToElement() {
9133
+ return {
9134
+ node: lexical.$createLineBreakNode()
9135
+ };
9136
+ }
9137
+
9076
9138
  function convertBringAttentionToElement(domNode) {
9077
9139
  // domNode is a <b> since we matched it by nodeName
9078
9140
  const b = domNode; // Google Docs wraps all copied HTML in a <b> with font-weight normal
@@ -9795,7 +9857,7 @@ class LexicalEditor {
9795
9857
  rootElement.blur();
9796
9858
  }
9797
9859
 
9798
- const domSelection = getDOMSelection();
9860
+ const domSelection = getDOMSelection(this._window);
9799
9861
 
9800
9862
  if (domSelection !== null) {
9801
9863
  domSelection.removeAllRanges();
@@ -9821,15 +9883,6 @@ class LexicalEditor {
9821
9883
 
9822
9884
  }
9823
9885
 
9824
- /**
9825
- * Copyright (c) Meta Platforms, Inc. and affiliates.
9826
- *
9827
- * This source code is licensed under the MIT license found in the
9828
- * LICENSE file in the root directory of this source tree.
9829
- *
9830
- */
9831
- const VERSION = '0.7.1';
9832
-
9833
9886
  /**
9834
9887
  * Copyright (c) Meta Platforms, Inc. and affiliates.
9835
9888
  *
@@ -9975,6 +10028,5 @@ exports.RootNode = RootNode;
9975
10028
  exports.SELECTION_CHANGE_COMMAND = SELECTION_CHANGE_COMMAND;
9976
10029
  exports.TextNode = TextNode;
9977
10030
  exports.UNDO_COMMAND = UNDO_COMMAND;
9978
- exports.VERSION = VERSION;
9979
10031
  exports.createCommand = createCommand;
9980
10032
  exports.createEditor = createEditor;
package/Lexical.js.flow CHANGED
@@ -846,11 +846,6 @@ declare export function $copyNode(
846
846
  offset: number,
847
847
  ): [ElementNode, ElementNode];
848
848
 
849
- /**
850
- * LexicalVersion
851
- */
852
- declare export var VERSION: string;
853
-
854
849
  /**
855
850
  * Serialization/Deserialization
856
851
  * */