@portabletext/editor 7.3.1 → 7.3.2

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.
@@ -1,4 +1,4 @@
1
- import * as _portabletext_schema5 from "@portabletext/schema";
1
+ import * as _portabletext_schema6 from "@portabletext/schema";
2
2
  import { AnnotationDefinition, AnnotationSchemaType, AnnotationSchemaType as AnnotationSchemaType$1, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, BlockObjectSchemaType as BlockObjectSchemaType$1, DecoratorDefinition, DecoratorSchemaType, DecoratorSchemaType as DecoratorSchemaType$1, FieldDefinition, FieldDefinition as FieldDefinition$1, InlineObjectDefinition, InlineObjectSchemaType, InlineObjectSchemaType as InlineObjectSchemaType$1, ListDefinition, ListSchemaType, ListSchemaType as ListSchemaType$1, OfDefinition, PortableTextBlock, PortableTextBlock as PortableTextBlock$1, PortableTextChild, PortableTextChild as PortableTextChild$1, PortableTextObject, PortableTextObject as PortableTextObject$1, PortableTextSpan, PortableTextSpan as PortableTextSpan$1, PortableTextTextBlock, PortableTextTextBlock as PortableTextTextBlock$1, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1, StyleDefinition, StyleSchemaType, StyleSchemaType as StyleSchemaType$1, TypedObject, defineSchema } from "@portabletext/schema";
3
3
  import * as xstate35 from "xstate";
4
4
  import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
@@ -855,7 +855,7 @@ declare class PortableTextEditor {
855
855
  */
856
856
  static delete: (editor: PortableTextEditor, selection: EditorSelection, options?: EditableAPIDeleteOptions) => void;
857
857
  static findDOMNode: (editor: PortableTextEditor, element: PortableTextBlock | PortableTextChild) => Node | undefined;
858
- static findByPath: (editor: PortableTextEditor, path: Path) => [_portabletext_schema5.PortableTextTextBlock<PortableTextObject | _portabletext_schema5.PortableTextSpan> | PortableTextObject | _portabletext_schema5.PortableTextSpan | undefined, Path | undefined];
858
+ static findByPath: (editor: PortableTextEditor, path: Path) => [_portabletext_schema6.PortableTextTextBlock<PortableTextObject | _portabletext_schema6.PortableTextSpan> | PortableTextObject | _portabletext_schema6.PortableTextSpan | undefined, Path | undefined];
859
859
  /**
860
860
  * @deprecated
861
861
  * Use `editor.send(...)` instead
package/lib/index.js CHANGED
@@ -3270,13 +3270,15 @@ const RestoreDOM = IS_ANDROID ? RestoreDOMComponent : ({
3270
3270
  }
3271
3271
  }
3272
3272
  if ((!type.startsWith("delete") || type.startsWith("deleteBy")) && !editor.isNodeMapDirty) {
3273
- const [targetRange2] = event.getTargetRanges();
3274
- if (targetRange2) {
3275
- const range2 = DOMEditor.toEditorSelection(editor, targetRange2, {
3273
+ const [targetRange2] = event.getTargetRanges(), domSelection = getSelection(DOMEditor.findDocumentOrShadowRoot(editor)), inputTarget = targetRange2 ?? (domSelection && domSelection.rangeCount > 0 ? domSelection : void 0);
3274
+ if (inputTarget) {
3275
+ const range2 = DOMEditor.toEditorSelection(editor, inputTarget, {
3276
3276
  exactMatch: !1,
3277
- suppressThrow: !1
3277
+ // The DOM selection fallback is not guaranteed to be a valid
3278
+ // editor range, so don't throw on it.
3279
+ suppressThrow: !targetRange2
3278
3280
  });
3279
- if (!selection || !rangeEquals(selection, range2)) {
3281
+ if (range2 && (!selection || !rangeEquals(selection, range2))) {
3280
3282
  native = !1;
3281
3283
  const selectionRef = !isCompositionChange && editor.snapshot.context.selection && rangeRef(editor, editor.snapshot.context.selection);
3282
3284
  editor.select(range2), selectionRef && (editor.userSelection = selectionRef);