lexical 0.29.1-nightly.20250328.0 → 0.29.1-nightly.20250401.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
@@ -10219,7 +10219,9 @@ class LexicalEditor {
10219
10219
  const root = $getRoot();
10220
10220
  if (selection !== null) {
10221
10221
  // Marking the selection dirty will force the selection back to it
10222
- selection.dirty = true;
10222
+ if (!selection.dirty) {
10223
+ $setSelection(selection.clone());
10224
+ }
10223
10225
  } else if (root.getChildrenSize() !== 0) {
10224
10226
  if (options.defaultSelection === 'rootStart') {
10225
10227
  root.selectStart();
@@ -10289,7 +10291,7 @@ class LexicalEditor {
10289
10291
  };
10290
10292
  }
10291
10293
  }
10292
- LexicalEditor.version = "0.29.1-nightly.20250328.0+dev.cjs";
10294
+ LexicalEditor.version = "0.29.1-nightly.20250401.0+dev.cjs";
10293
10295
 
10294
10296
  let keyCounter = 1;
10295
10297
  function resetRandomKey() {
@@ -12089,7 +12091,7 @@ function $getTextPointCaret(origin, direction, offset) {
12089
12091
 
12090
12092
  /**
12091
12093
  * Get a normalized offset into a TextNode given a numeric offset or a
12092
- * direction for which end of the string to use. Throws if the offset
12094
+ * direction for which end of the string to use. Throws in dev if the offset
12093
12095
  * is not in the bounds of the text content size.
12094
12096
  *
12095
12097
  * @param origin a TextNode
@@ -12098,9 +12100,12 @@ function $getTextPointCaret(origin, direction, offset) {
12098
12100
  */
12099
12101
  function $getTextNodeOffset(origin, offset) {
12100
12102
  const size = origin.getTextContentSize();
12101
- const numericOffset = offset === 'next' ? size : offset === 'previous' ? 0 : offset;
12102
- if (!(numericOffset >= 0 && numericOffset <= size)) {
12103
- formatDevErrorMessage(`$getTextNodeOffset: invalid offset ${String(offset)} for size ${String(size)}`);
12103
+ let numericOffset = offset === 'next' ? size : offset === 'previous' ? 0 : offset;
12104
+ if (numericOffset < 0 || numericOffset > size) {
12105
+ {
12106
+ formatDevErrorMessage(`$getTextNodeOffset: invalid offset ${String(offset)} for size ${String(size)} at key ${origin.getKey()}`);
12107
+ } // Clamp invalid offsets in prod
12108
+ numericOffset = numericOffset < 0 ? 0 : size;
12104
12109
  }
12105
12110
  return numericOffset;
12106
12111
  }
package/Lexical.dev.mjs CHANGED
@@ -10217,7 +10217,9 @@ class LexicalEditor {
10217
10217
  const root = $getRoot();
10218
10218
  if (selection !== null) {
10219
10219
  // Marking the selection dirty will force the selection back to it
10220
- selection.dirty = true;
10220
+ if (!selection.dirty) {
10221
+ $setSelection(selection.clone());
10222
+ }
10221
10223
  } else if (root.getChildrenSize() !== 0) {
10222
10224
  if (options.defaultSelection === 'rootStart') {
10223
10225
  root.selectStart();
@@ -10287,7 +10289,7 @@ class LexicalEditor {
10287
10289
  };
10288
10290
  }
10289
10291
  }
10290
- LexicalEditor.version = "0.29.1-nightly.20250328.0+dev.esm";
10292
+ LexicalEditor.version = "0.29.1-nightly.20250401.0+dev.esm";
10291
10293
 
10292
10294
  let keyCounter = 1;
10293
10295
  function resetRandomKey() {
@@ -12087,7 +12089,7 @@ function $getTextPointCaret(origin, direction, offset) {
12087
12089
 
12088
12090
  /**
12089
12091
  * Get a normalized offset into a TextNode given a numeric offset or a
12090
- * direction for which end of the string to use. Throws if the offset
12092
+ * direction for which end of the string to use. Throws in dev if the offset
12091
12093
  * is not in the bounds of the text content size.
12092
12094
  *
12093
12095
  * @param origin a TextNode
@@ -12096,9 +12098,12 @@ function $getTextPointCaret(origin, direction, offset) {
12096
12098
  */
12097
12099
  function $getTextNodeOffset(origin, offset) {
12098
12100
  const size = origin.getTextContentSize();
12099
- const numericOffset = offset === 'next' ? size : offset === 'previous' ? 0 : offset;
12100
- if (!(numericOffset >= 0 && numericOffset <= size)) {
12101
- formatDevErrorMessage(`$getTextNodeOffset: invalid offset ${String(offset)} for size ${String(size)}`);
12101
+ let numericOffset = offset === 'next' ? size : offset === 'previous' ? 0 : offset;
12102
+ if (numericOffset < 0 || numericOffset > size) {
12103
+ {
12104
+ formatDevErrorMessage(`$getTextNodeOffset: invalid offset ${String(offset)} for size ${String(size)} at key ${origin.getKey()}`);
12105
+ } // Clamp invalid offsets in prod
12106
+ numericOffset = numericOffset < 0 ? 0 : size;
12102
12107
  }
12103
12108
  return numericOffset;
12104
12109
  }