lexical 0.35.1-nightly.20250918.0 → 0.35.1-nightly.20250922.0

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
@@ -6562,45 +6562,47 @@ class RangeSelection {
6562
6562
  * @returns The nodes in the Selection
6563
6563
  */
6564
6564
  extract() {
6565
- const selectedNodes = this.getNodes();
6565
+ const selectedNodes = [...this.getNodes()];
6566
6566
  const selectedNodesLength = selectedNodes.length;
6567
- const lastIndex = selectedNodesLength - 1;
6568
- const anchor = this.anchor;
6569
- const focus = this.focus;
6570
6567
  let firstNode = selectedNodes[0];
6571
- let lastNode = selectedNodes[lastIndex];
6568
+ let lastNode = selectedNodes[selectedNodesLength - 1];
6572
6569
  const [anchorOffset, focusOffset] = $getCharacterOffsets(this);
6570
+ const isBackward = this.isBackward();
6571
+ const [startPoint, endPoint] = isBackward ? [this.focus, this.anchor] : [this.anchor, this.focus];
6572
+ const [startOffset, endOffset] = isBackward ? [focusOffset, anchorOffset] : [anchorOffset, focusOffset];
6573
6573
  if (selectedNodesLength === 0) {
6574
6574
  return [];
6575
6575
  } else if (selectedNodesLength === 1) {
6576
6576
  if ($isTextNode(firstNode) && !this.isCollapsed()) {
6577
- const startOffset = anchorOffset > focusOffset ? focusOffset : anchorOffset;
6578
- const endOffset = anchorOffset > focusOffset ? anchorOffset : focusOffset;
6579
6577
  const splitNodes = firstNode.splitText(startOffset, endOffset);
6580
6578
  const node = startOffset === 0 ? splitNodes[0] : splitNodes[1];
6581
- return node != null ? [node] : [];
6579
+ if (node) {
6580
+ startPoint.set(node.getKey(), 0, 'text');
6581
+ endPoint.set(node.getKey(), node.getTextContentSize(), 'text');
6582
+ return [node];
6583
+ }
6584
+ return [];
6582
6585
  }
6583
6586
  return [firstNode];
6584
6587
  }
6585
- const isBefore = anchor.isBefore(focus);
6586
6588
  if ($isTextNode(firstNode)) {
6587
- const startOffset = isBefore ? anchorOffset : focusOffset;
6588
6589
  if (startOffset === firstNode.getTextContentSize()) {
6589
6590
  selectedNodes.shift();
6590
6591
  } else if (startOffset !== 0) {
6591
6592
  [, firstNode] = firstNode.splitText(startOffset);
6592
6593
  selectedNodes[0] = firstNode;
6594
+ startPoint.set(firstNode.getKey(), 0, 'text');
6593
6595
  }
6594
6596
  }
6595
6597
  if ($isTextNode(lastNode)) {
6596
6598
  const lastNodeText = lastNode.getTextContent();
6597
6599
  const lastNodeTextLength = lastNodeText.length;
6598
- const endOffset = isBefore ? focusOffset : anchorOffset;
6599
6600
  if (endOffset === 0) {
6600
6601
  selectedNodes.pop();
6601
6602
  } else if (endOffset !== lastNodeTextLength) {
6602
6603
  [lastNode] = lastNode.splitText(endOffset);
6603
- selectedNodes[lastIndex] = lastNode;
6604
+ selectedNodes[selectedNodes.length - 1] = lastNode;
6605
+ endPoint.set(lastNode.getKey(), lastNode.getTextContentSize(), 'text');
6604
6606
  }
6605
6607
  }
6606
6608
  return selectedNodes;
@@ -10740,7 +10742,7 @@ class LexicalEditor {
10740
10742
  };
10741
10743
  }
10742
10744
  }
10743
- LexicalEditor.version = "0.35.1-nightly.20250918.0+dev.cjs";
10745
+ LexicalEditor.version = "0.35.1-nightly.20250922.0+dev.cjs";
10744
10746
 
10745
10747
  let pendingNodeToClone = null;
10746
10748
  function setPendingNodeToClone(pendingNode) {
package/Lexical.dev.mjs CHANGED
@@ -6560,45 +6560,47 @@ class RangeSelection {
6560
6560
  * @returns The nodes in the Selection
6561
6561
  */
6562
6562
  extract() {
6563
- const selectedNodes = this.getNodes();
6563
+ const selectedNodes = [...this.getNodes()];
6564
6564
  const selectedNodesLength = selectedNodes.length;
6565
- const lastIndex = selectedNodesLength - 1;
6566
- const anchor = this.anchor;
6567
- const focus = this.focus;
6568
6565
  let firstNode = selectedNodes[0];
6569
- let lastNode = selectedNodes[lastIndex];
6566
+ let lastNode = selectedNodes[selectedNodesLength - 1];
6570
6567
  const [anchorOffset, focusOffset] = $getCharacterOffsets(this);
6568
+ const isBackward = this.isBackward();
6569
+ const [startPoint, endPoint] = isBackward ? [this.focus, this.anchor] : [this.anchor, this.focus];
6570
+ const [startOffset, endOffset] = isBackward ? [focusOffset, anchorOffset] : [anchorOffset, focusOffset];
6571
6571
  if (selectedNodesLength === 0) {
6572
6572
  return [];
6573
6573
  } else if (selectedNodesLength === 1) {
6574
6574
  if ($isTextNode(firstNode) && !this.isCollapsed()) {
6575
- const startOffset = anchorOffset > focusOffset ? focusOffset : anchorOffset;
6576
- const endOffset = anchorOffset > focusOffset ? anchorOffset : focusOffset;
6577
6575
  const splitNodes = firstNode.splitText(startOffset, endOffset);
6578
6576
  const node = startOffset === 0 ? splitNodes[0] : splitNodes[1];
6579
- return node != null ? [node] : [];
6577
+ if (node) {
6578
+ startPoint.set(node.getKey(), 0, 'text');
6579
+ endPoint.set(node.getKey(), node.getTextContentSize(), 'text');
6580
+ return [node];
6581
+ }
6582
+ return [];
6580
6583
  }
6581
6584
  return [firstNode];
6582
6585
  }
6583
- const isBefore = anchor.isBefore(focus);
6584
6586
  if ($isTextNode(firstNode)) {
6585
- const startOffset = isBefore ? anchorOffset : focusOffset;
6586
6587
  if (startOffset === firstNode.getTextContentSize()) {
6587
6588
  selectedNodes.shift();
6588
6589
  } else if (startOffset !== 0) {
6589
6590
  [, firstNode] = firstNode.splitText(startOffset);
6590
6591
  selectedNodes[0] = firstNode;
6592
+ startPoint.set(firstNode.getKey(), 0, 'text');
6591
6593
  }
6592
6594
  }
6593
6595
  if ($isTextNode(lastNode)) {
6594
6596
  const lastNodeText = lastNode.getTextContent();
6595
6597
  const lastNodeTextLength = lastNodeText.length;
6596
- const endOffset = isBefore ? focusOffset : anchorOffset;
6597
6598
  if (endOffset === 0) {
6598
6599
  selectedNodes.pop();
6599
6600
  } else if (endOffset !== lastNodeTextLength) {
6600
6601
  [lastNode] = lastNode.splitText(endOffset);
6601
- selectedNodes[lastIndex] = lastNode;
6602
+ selectedNodes[selectedNodes.length - 1] = lastNode;
6603
+ endPoint.set(lastNode.getKey(), lastNode.getTextContentSize(), 'text');
6602
6604
  }
6603
6605
  }
6604
6606
  return selectedNodes;
@@ -10738,7 +10740,7 @@ class LexicalEditor {
10738
10740
  };
10739
10741
  }
10740
10742
  }
10741
- LexicalEditor.version = "0.35.1-nightly.20250918.0+dev.esm";
10743
+ LexicalEditor.version = "0.35.1-nightly.20250922.0+dev.esm";
10742
10744
 
10743
10745
  let pendingNodeToClone = null;
10744
10746
  function setPendingNodeToClone(pendingNode) {