@portabletext/editor 6.6.4 → 6.6.6

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/lib/index.js CHANGED
@@ -3990,13 +3990,15 @@ const RestoreDOM = IS_ANDROID ? RestoreDOMComponent : ({
3990
3990
  }
3991
3991
  }
3992
3992
  if ((!type.startsWith("delete") || type.startsWith("deleteBy")) && !editor.isNodeMapDirty) {
3993
- const [targetRange2] = event.getTargetRanges();
3994
- if (targetRange2) {
3995
- const range2 = ReactEditor.toSlateRange(editor, targetRange2, {
3993
+ const [targetRange2] = event.getTargetRanges(), domSelection = getSelection(ReactEditor.findDocumentOrShadowRoot(editor)), inputTarget = targetRange2 ?? (domSelection && domSelection.rangeCount > 0 ? domSelection : void 0);
3994
+ if (inputTarget) {
3995
+ const range2 = ReactEditor.toSlateRange(editor, inputTarget, {
3996
3996
  exactMatch: !1,
3997
- suppressThrow: !1
3997
+ // The DOM selection fallback is not guaranteed to be a valid
3998
+ // Slate range, so don't throw on it.
3999
+ suppressThrow: !targetRange2
3998
4000
  });
3999
- if (!selection || !rangeEquals(selection, range2)) {
4001
+ if (range2 && (!selection || !rangeEquals(selection, range2))) {
4000
4002
  native = !1;
4001
4003
  const selectionRef = !isCompositionChange && editor.selection && rangeRef(editor, editor.selection);
4002
4004
  editor.select(range2), selectionRef && (editor.userSelection = selectionRef);
@@ -18408,17 +18410,14 @@ function updateBlock({
18408
18410
  if (isChildChanged)
18409
18411
  if (currentBlockChild._key === oldBlockChild?._key && currentBlockChild._type === oldBlockChild?._type) {
18410
18412
  debug$1.syncValue("Updating changed child", currentBlockChild, oldBlockChild);
18411
- const {
18412
- text: _text,
18413
- ...childProps
18414
- } = currentBlockChild;
18415
- applySetNode(slateEditor, childProps, path2);
18416
18413
  const isSpanNode2 = isSpan({
18417
18414
  schema: context.schema
18418
18415
  }, currentBlockChild) && isSpan({
18419
18416
  schema: context.schema
18420
- }, oldBlockChild);
18421
- isSpanNode2 && isTextChanged ? (oldBlockChild.text.length > 0 && deleteText(slateEditor, {
18417
+ }, oldBlockChild), childProps = {
18418
+ ...currentBlockChild
18419
+ };
18420
+ isSpanNode2 && delete childProps.text, applySetNode(slateEditor, childProps, path2), isSpanNode2 && isTextChanged ? (oldBlockChild.text.length > 0 && deleteText(slateEditor, {
18422
18421
  at: {
18423
18422
  focus: {
18424
18423
  path: path2,