slate-react 0.128.0 → 0.128.2-20261007172010

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.
@@ -2543,9 +2543,15 @@
2543
2543
  return rect.top <= middle && rect.bottom >= middle;
2544
2544
  };
2545
2545
  var areRangesSameLine = (editor, range1, range2) => {
2546
- var rect1 = DOMEditor.toDOMRange(editor, range1).getBoundingClientRect();
2547
- var rect2 = DOMEditor.toDOMRange(editor, range2).getBoundingClientRect();
2548
- return doRectsIntersect(rect1, rect2) && doRectsIntersect(rect2, rect1);
2546
+ try {
2547
+ var domRange1 = DOMEditor.toDOMRange(editor, range1);
2548
+ var domRange2 = DOMEditor.toDOMRange(editor, range2);
2549
+ var rect1 = domRange1.getBoundingClientRect();
2550
+ var rect2 = domRange2.getBoundingClientRect();
2551
+ return doRectsIntersect(rect1, rect2) && doRectsIntersect(rect2, rect1);
2552
+ } catch (_unused) {
2553
+ return false;
2554
+ }
2549
2555
  };
2550
2556
  /**
2551
2557
  * A helper utility that returns the end portion of a `Range`
@@ -38437,8 +38443,8 @@
38437
38443
  onValueChange = props.onValueChange,
38438
38444
  initialValue = props.initialValue,
38439
38445
  rest = _objectWithoutProperties$1(props, _excluded);
38440
- // Run once on first mount, but before `useEffect` or render
38441
- React.useState(function () {
38446
+ var initializedEditor = React.useRef(null);
38447
+ if (initializedEditor.current !== editor) {
38442
38448
  if (!slate.Node.isNodeList(initialValue)) {
38443
38449
  throw new Error("[Slate] initialValue is invalid! Expected a list of elements but got: ".concat(slate.Scrubber.stringify(initialValue)));
38444
38450
  }
@@ -38447,7 +38453,8 @@
38447
38453
  }
38448
38454
  editor.children = initialValue;
38449
38455
  Object.assign(editor, rest);
38450
- });
38456
+ initializedEditor.current = editor;
38457
+ }
38451
38458
  var _useSelectorContext = useSelectorContext(),
38452
38459
  selectorContext = _useSelectorContext.selectorContext,
38453
38460
  handleSelectorChange = _useSelectorContext.onChange;