lexical 0.30.1-nightly.20250414.0 → 0.30.1-nightly.20250415.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
@@ -10355,7 +10355,7 @@ class LexicalEditor {
10355
10355
  };
10356
10356
  }
10357
10357
  }
10358
- LexicalEditor.version = "0.30.1-nightly.20250414.0+dev.cjs";
10358
+ LexicalEditor.version = "0.30.1-nightly.20250415.0+dev.cjs";
10359
10359
 
10360
10360
  let keyCounter = 1;
10361
10361
  function resetRandomKey() {
@@ -10546,6 +10546,13 @@ function internalMarkParentElementsAsDirty(parentKey, nodeMap, dirtyElements) {
10546
10546
  }
10547
10547
 
10548
10548
  // TODO #6031 this function or their callers have to adjust selection (i.e. insertBefore)
10549
+ /**
10550
+ * Removes a node from its parent, updating all necessary pointers and links.
10551
+ * @internal
10552
+ *
10553
+ * This function is for internal use of the library.
10554
+ * Please do not use it as it may change in the future.
10555
+ */
10549
10556
  function removeFromParent(node) {
10550
10557
  const oldParent = node.getParent();
10551
10558
  if (oldParent !== null) {
@@ -10553,47 +10560,38 @@ function removeFromParent(node) {
10553
10560
  const writableParent = oldParent.getWritable();
10554
10561
  const prevSibling = node.getPreviousSibling();
10555
10562
  const nextSibling = node.getNextSibling();
10556
- // TODO: this function duplicates a bunch of operations, can be simplified.
10563
+
10564
+ // Store sibling keys
10565
+ const nextSiblingKey = nextSibling !== null ? nextSibling.__key : null;
10566
+ const prevSiblingKey = prevSibling !== null ? prevSibling.__key : null;
10567
+
10568
+ // Get writable siblings once
10569
+ const writablePrevSibling = prevSibling !== null ? prevSibling.getWritable() : null;
10570
+ const writableNextSibling = nextSibling !== null ? nextSibling.getWritable() : null;
10571
+
10572
+ // Update parent's first/last pointers
10557
10573
  if (prevSibling === null) {
10558
- if (nextSibling !== null) {
10559
- const writableNextSibling = nextSibling.getWritable();
10560
- writableParent.__first = nextSibling.__key;
10561
- writableNextSibling.__prev = null;
10562
- } else {
10563
- writableParent.__first = null;
10564
- }
10565
- } else {
10566
- const writablePrevSibling = prevSibling.getWritable();
10567
- if (nextSibling !== null) {
10568
- const writableNextSibling = nextSibling.getWritable();
10569
- writableNextSibling.__prev = writablePrevSibling.__key;
10570
- writablePrevSibling.__next = writableNextSibling.__key;
10571
- } else {
10572
- writablePrevSibling.__next = null;
10573
- }
10574
- writableNode.__prev = null;
10574
+ writableParent.__first = nextSiblingKey;
10575
10575
  }
10576
10576
  if (nextSibling === null) {
10577
- if (prevSibling !== null) {
10578
- const writablePrevSibling = prevSibling.getWritable();
10579
- writableParent.__last = prevSibling.__key;
10580
- writablePrevSibling.__next = null;
10581
- } else {
10582
- writableParent.__last = null;
10583
- }
10584
- } else {
10585
- const writableNextSibling = nextSibling.getWritable();
10586
- if (prevSibling !== null) {
10587
- const writablePrevSibling = prevSibling.getWritable();
10588
- writablePrevSibling.__next = writableNextSibling.__key;
10589
- writableNextSibling.__prev = writablePrevSibling.__key;
10590
- } else {
10591
- writableNextSibling.__prev = null;
10592
- }
10593
- writableNode.__next = null;
10577
+ writableParent.__last = prevSiblingKey;
10594
10578
  }
10595
- writableParent.__size--;
10579
+
10580
+ // Update sibling links
10581
+ if (writablePrevSibling !== null) {
10582
+ writablePrevSibling.__next = nextSiblingKey;
10583
+ }
10584
+ if (writableNextSibling !== null) {
10585
+ writableNextSibling.__prev = prevSiblingKey;
10586
+ }
10587
+
10588
+ // Clear node's links
10589
+ writableNode.__prev = null;
10590
+ writableNode.__next = null;
10596
10591
  writableNode.__parent = null;
10592
+
10593
+ // Update parent size
10594
+ writableParent.__size--;
10597
10595
  }
10598
10596
  }
10599
10597
 
@@ -13249,6 +13247,7 @@ exports.isLexicalEditor = isLexicalEditor;
13249
13247
  exports.isSelectionCapturedInDecoratorInput = isSelectionCapturedInDecoratorInput;
13250
13248
  exports.isSelectionWithinEditor = isSelectionWithinEditor;
13251
13249
  exports.makeStepwiseIterator = makeStepwiseIterator;
13250
+ exports.removeFromParent = removeFromParent;
13252
13251
  exports.resetRandomKey = resetRandomKey;
13253
13252
  exports.setDOMUnmanaged = setDOMUnmanaged;
13254
13253
  exports.setNodeIndentFromDOM = setNodeIndentFromDOM;
package/Lexical.dev.mjs CHANGED
@@ -10353,7 +10353,7 @@ class LexicalEditor {
10353
10353
  };
10354
10354
  }
10355
10355
  }
10356
- LexicalEditor.version = "0.30.1-nightly.20250414.0+dev.esm";
10356
+ LexicalEditor.version = "0.30.1-nightly.20250415.0+dev.esm";
10357
10357
 
10358
10358
  let keyCounter = 1;
10359
10359
  function resetRandomKey() {
@@ -10544,6 +10544,13 @@ function internalMarkParentElementsAsDirty(parentKey, nodeMap, dirtyElements) {
10544
10544
  }
10545
10545
 
10546
10546
  // TODO #6031 this function or their callers have to adjust selection (i.e. insertBefore)
10547
+ /**
10548
+ * Removes a node from its parent, updating all necessary pointers and links.
10549
+ * @internal
10550
+ *
10551
+ * This function is for internal use of the library.
10552
+ * Please do not use it as it may change in the future.
10553
+ */
10547
10554
  function removeFromParent(node) {
10548
10555
  const oldParent = node.getParent();
10549
10556
  if (oldParent !== null) {
@@ -10551,47 +10558,38 @@ function removeFromParent(node) {
10551
10558
  const writableParent = oldParent.getWritable();
10552
10559
  const prevSibling = node.getPreviousSibling();
10553
10560
  const nextSibling = node.getNextSibling();
10554
- // TODO: this function duplicates a bunch of operations, can be simplified.
10561
+
10562
+ // Store sibling keys
10563
+ const nextSiblingKey = nextSibling !== null ? nextSibling.__key : null;
10564
+ const prevSiblingKey = prevSibling !== null ? prevSibling.__key : null;
10565
+
10566
+ // Get writable siblings once
10567
+ const writablePrevSibling = prevSibling !== null ? prevSibling.getWritable() : null;
10568
+ const writableNextSibling = nextSibling !== null ? nextSibling.getWritable() : null;
10569
+
10570
+ // Update parent's first/last pointers
10555
10571
  if (prevSibling === null) {
10556
- if (nextSibling !== null) {
10557
- const writableNextSibling = nextSibling.getWritable();
10558
- writableParent.__first = nextSibling.__key;
10559
- writableNextSibling.__prev = null;
10560
- } else {
10561
- writableParent.__first = null;
10562
- }
10563
- } else {
10564
- const writablePrevSibling = prevSibling.getWritable();
10565
- if (nextSibling !== null) {
10566
- const writableNextSibling = nextSibling.getWritable();
10567
- writableNextSibling.__prev = writablePrevSibling.__key;
10568
- writablePrevSibling.__next = writableNextSibling.__key;
10569
- } else {
10570
- writablePrevSibling.__next = null;
10571
- }
10572
- writableNode.__prev = null;
10572
+ writableParent.__first = nextSiblingKey;
10573
10573
  }
10574
10574
  if (nextSibling === null) {
10575
- if (prevSibling !== null) {
10576
- const writablePrevSibling = prevSibling.getWritable();
10577
- writableParent.__last = prevSibling.__key;
10578
- writablePrevSibling.__next = null;
10579
- } else {
10580
- writableParent.__last = null;
10581
- }
10582
- } else {
10583
- const writableNextSibling = nextSibling.getWritable();
10584
- if (prevSibling !== null) {
10585
- const writablePrevSibling = prevSibling.getWritable();
10586
- writablePrevSibling.__next = writableNextSibling.__key;
10587
- writableNextSibling.__prev = writablePrevSibling.__key;
10588
- } else {
10589
- writableNextSibling.__prev = null;
10590
- }
10591
- writableNode.__next = null;
10575
+ writableParent.__last = prevSiblingKey;
10592
10576
  }
10593
- writableParent.__size--;
10577
+
10578
+ // Update sibling links
10579
+ if (writablePrevSibling !== null) {
10580
+ writablePrevSibling.__next = nextSiblingKey;
10581
+ }
10582
+ if (writableNextSibling !== null) {
10583
+ writableNextSibling.__prev = prevSiblingKey;
10584
+ }
10585
+
10586
+ // Clear node's links
10587
+ writableNode.__prev = null;
10588
+ writableNode.__next = null;
10594
10589
  writableNode.__parent = null;
10590
+
10591
+ // Update parent size
10592
+ writableParent.__size--;
10595
10593
  }
10596
10594
  }
10597
10595
 
@@ -13061,4 +13059,4 @@ function $splitAtPointCaretNext(pointCaret, {
13061
13059
  return parentCaret;
13062
13060
  }
13063
13061
 
13064
- export { $addUpdateTag, $applyNodeReplacement, $caretFromPoint, $caretRangeFromSelection, $cloneWithProperties, $comparePointCaretNext, $copyNode, $createLineBreakNode, $createNodeSelection, $createParagraphNode, $createPoint, $createRangeSelection, $createRangeSelectionFromDom, $createTabNode, $createTextNode, $extendCaretToRange, $getAdjacentChildCaret, $getAdjacentNode, $getAdjacentSiblingOrParentSiblingCaret, $getCaretInDirection, $getCaretRange, $getCaretRangeInDirection, $getCharacterOffsets, $getChildCaret, $getChildCaretAtIndex, $getChildCaretOrSelf, $getCollapsedCaretRange, $getCommonAncestor, $getCommonAncestorResultBranchOrder, $getEditor, $getNearestNodeFromDOMNode, $getNearestRootOrShadowRoot, $getNodeByKey, $getNodeByKeyOrThrow, $getPreviousSelection, $getRoot, $getSelection, $getSiblingCaret, $getState, $getStateChange, $getTextContent, $getTextNodeOffset, $getTextPointCaret, $getTextPointCaretSlice, $getWritableNodeState, $hasAncestor, $hasUpdateTag, $insertNodes, $isBlockElementNode, $isChildCaret, $isDecoratorNode, $isElementNode, $isExtendableTextPointCaret, $isInlineElementOrDecoratorNode, $isLeafNode, $isLineBreakNode, $isNodeCaret, $isNodeSelection, $isParagraphNode, $isRangeSelection, $isRootNode, $isRootOrShadowRoot, $isSiblingCaret, $isTabNode, $isTextNode, $isTextPointCaret, $isTextPointCaretSlice, $isTokenOrSegmented, $nodesOfType, $normalizeCaret, $normalizeSelection as $normalizeSelection__EXPERIMENTAL, $onUpdate, $parseSerializedNode, $removeTextFromCaretRange, $rewindSiblingCaret, $selectAll, $setCompositionKey, $setPointFromCaret, $setSelection, $setSelectionFromCaretRange, $setState, $splitAtPointCaretNext, $splitNode, $updateRangeSelectionFromCaretRange, ArtificialNode__DO_NOT_USE, BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, CLICK_COMMAND, COLLABORATION_TAG, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, CONTROLLED_TEXT_INSERTION_COMMAND, COPY_COMMAND, CUT_COMMAND, DELETE_CHARACTER_COMMAND, DELETE_LINE_COMMAND, DELETE_WORD_COMMAND, DRAGEND_COMMAND, DRAGOVER_COMMAND, DRAGSTART_COMMAND, DROP_COMMAND, DecoratorNode, ElementNode, FOCUS_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, HISTORIC_TAG, HISTORY_MERGE_TAG, HISTORY_PUSH_TAG, INDENT_CONTENT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, INSERT_TAB_COMMAND, INTERNAL_$isBlock, IS_ALL_FORMATTING, IS_BOLD, IS_CODE, IS_HIGHLIGHT, IS_ITALIC, IS_STRIKETHROUGH, IS_SUBSCRIPT, IS_SUPERSCRIPT, IS_UNDERLINE, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_DOWN_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_MODIFIER_COMMAND, KEY_SPACE_COMMAND, KEY_TAB_COMMAND, LineBreakNode, MOVE_TO_END, MOVE_TO_START, NODE_STATE_KEY, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, PASTE_TAG, ParagraphNode, REDO_COMMAND, REMOVE_TEXT_COMMAND, RootNode, SELECTION_CHANGE_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, SELECT_ALL_COMMAND, SKIP_COLLAB_TAG, SKIP_DOM_SELECTION_TAG, SKIP_SCROLL_INTO_VIEW_TAG, TEXT_TYPE_TO_FORMAT, TabNode, TextNode, UNDO_COMMAND, createCommand, createEditor, createState, flipDirection, getDOMOwnerDocument, getDOMSelection, getDOMSelectionFromTarget, getDOMTextNode, getEditorPropertyFromDOMNode, getNearestEditorFromDOMNode, isBlockDomNode, isCurrentlyReadOnlyMode, isDOMDocumentNode, isDOMNode, isDOMTextNode, isDOMUnmanaged, isDocumentFragment, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, isLexicalEditor, isSelectionCapturedInDecoratorInput, isSelectionWithinEditor, makeStepwiseIterator, resetRandomKey, setDOMUnmanaged, setNodeIndentFromDOM };
13062
+ export { $addUpdateTag, $applyNodeReplacement, $caretFromPoint, $caretRangeFromSelection, $cloneWithProperties, $comparePointCaretNext, $copyNode, $createLineBreakNode, $createNodeSelection, $createParagraphNode, $createPoint, $createRangeSelection, $createRangeSelectionFromDom, $createTabNode, $createTextNode, $extendCaretToRange, $getAdjacentChildCaret, $getAdjacentNode, $getAdjacentSiblingOrParentSiblingCaret, $getCaretInDirection, $getCaretRange, $getCaretRangeInDirection, $getCharacterOffsets, $getChildCaret, $getChildCaretAtIndex, $getChildCaretOrSelf, $getCollapsedCaretRange, $getCommonAncestor, $getCommonAncestorResultBranchOrder, $getEditor, $getNearestNodeFromDOMNode, $getNearestRootOrShadowRoot, $getNodeByKey, $getNodeByKeyOrThrow, $getPreviousSelection, $getRoot, $getSelection, $getSiblingCaret, $getState, $getStateChange, $getTextContent, $getTextNodeOffset, $getTextPointCaret, $getTextPointCaretSlice, $getWritableNodeState, $hasAncestor, $hasUpdateTag, $insertNodes, $isBlockElementNode, $isChildCaret, $isDecoratorNode, $isElementNode, $isExtendableTextPointCaret, $isInlineElementOrDecoratorNode, $isLeafNode, $isLineBreakNode, $isNodeCaret, $isNodeSelection, $isParagraphNode, $isRangeSelection, $isRootNode, $isRootOrShadowRoot, $isSiblingCaret, $isTabNode, $isTextNode, $isTextPointCaret, $isTextPointCaretSlice, $isTokenOrSegmented, $nodesOfType, $normalizeCaret, $normalizeSelection as $normalizeSelection__EXPERIMENTAL, $onUpdate, $parseSerializedNode, $removeTextFromCaretRange, $rewindSiblingCaret, $selectAll, $setCompositionKey, $setPointFromCaret, $setSelection, $setSelectionFromCaretRange, $setState, $splitAtPointCaretNext, $splitNode, $updateRangeSelectionFromCaretRange, ArtificialNode__DO_NOT_USE, BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, CLICK_COMMAND, COLLABORATION_TAG, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, CONTROLLED_TEXT_INSERTION_COMMAND, COPY_COMMAND, CUT_COMMAND, DELETE_CHARACTER_COMMAND, DELETE_LINE_COMMAND, DELETE_WORD_COMMAND, DRAGEND_COMMAND, DRAGOVER_COMMAND, DRAGSTART_COMMAND, DROP_COMMAND, DecoratorNode, ElementNode, FOCUS_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, HISTORIC_TAG, HISTORY_MERGE_TAG, HISTORY_PUSH_TAG, INDENT_CONTENT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, INSERT_TAB_COMMAND, INTERNAL_$isBlock, IS_ALL_FORMATTING, IS_BOLD, IS_CODE, IS_HIGHLIGHT, IS_ITALIC, IS_STRIKETHROUGH, IS_SUBSCRIPT, IS_SUPERSCRIPT, IS_UNDERLINE, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_DOWN_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_MODIFIER_COMMAND, KEY_SPACE_COMMAND, KEY_TAB_COMMAND, LineBreakNode, MOVE_TO_END, MOVE_TO_START, NODE_STATE_KEY, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, PASTE_TAG, ParagraphNode, REDO_COMMAND, REMOVE_TEXT_COMMAND, RootNode, SELECTION_CHANGE_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, SELECT_ALL_COMMAND, SKIP_COLLAB_TAG, SKIP_DOM_SELECTION_TAG, SKIP_SCROLL_INTO_VIEW_TAG, TEXT_TYPE_TO_FORMAT, TabNode, TextNode, UNDO_COMMAND, createCommand, createEditor, createState, flipDirection, getDOMOwnerDocument, getDOMSelection, getDOMSelectionFromTarget, getDOMTextNode, getEditorPropertyFromDOMNode, getNearestEditorFromDOMNode, isBlockDomNode, isCurrentlyReadOnlyMode, isDOMDocumentNode, isDOMNode, isDOMTextNode, isDOMUnmanaged, isDocumentFragment, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, isLexicalEditor, isSelectionCapturedInDecoratorInput, isSelectionWithinEditor, makeStepwiseIterator, removeFromParent, resetRandomKey, setDOMUnmanaged, setNodeIndentFromDOM };
package/Lexical.mjs CHANGED
@@ -195,6 +195,7 @@ export const isLexicalEditor = mod.isLexicalEditor;
195
195
  export const isSelectionCapturedInDecoratorInput = mod.isSelectionCapturedInDecoratorInput;
196
196
  export const isSelectionWithinEditor = mod.isSelectionWithinEditor;
197
197
  export const makeStepwiseIterator = mod.makeStepwiseIterator;
198
+ export const removeFromParent = mod.removeFromParent;
198
199
  export const resetRandomKey = mod.resetRandomKey;
199
200
  export const setDOMUnmanaged = mod.setDOMUnmanaged;
200
201
  export const setNodeIndentFromDOM = mod.setNodeIndentFromDOM;
package/Lexical.node.mjs CHANGED
@@ -193,6 +193,7 @@ export const isLexicalEditor = mod.isLexicalEditor;
193
193
  export const isSelectionCapturedInDecoratorInput = mod.isSelectionCapturedInDecoratorInput;
194
194
  export const isSelectionWithinEditor = mod.isSelectionWithinEditor;
195
195
  export const makeStepwiseIterator = mod.makeStepwiseIterator;
196
+ export const removeFromParent = mod.removeFromParent;
196
197
  export const resetRandomKey = mod.resetRandomKey;
197
198
  export const setDOMUnmanaged = mod.setDOMUnmanaged;
198
199
  export const setNodeIndentFromDOM = mod.setNodeIndentFromDOM;