@portabletext/editor 2.9.0 → 2.9.1
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/_chunks-dts/behavior.types.action.d.ts +12 -12
- package/lib/index.cjs +6 -2
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +6 -2
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.ts +3 -3
- package/package.json +2 -2
- package/src/editor/Editable.tsx +12 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Patch, Patch as Patch$1 } from "@portabletext/patches";
|
|
2
2
|
import * as _sanity_types5 from "@sanity/types";
|
|
3
3
|
import { ArrayDefinition, ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition, ObjectSchemaType, Path, PortableTextBlock, PortableTextBlock as PortableTextBlock$1, PortableTextChild, PortableTextChild as PortableTextChild$1, PortableTextListBlock, PortableTextObject, PortableTextObject as PortableTextObject$1, PortableTextSpan, PortableTextSpan as PortableTextSpan$1, PortableTextTextBlock, PortableTextTextBlock as PortableTextTextBlock$1, TypedObject } from "@sanity/types";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _portabletext_schema6 from "@portabletext/schema";
|
|
5
5
|
import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, DecoratorDefinition, DecoratorSchemaType, FieldDefinition, InlineObjectDefinition, InlineObjectSchemaType, ListDefinition, ListSchemaType, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1, StyleDefinition, StyleSchemaType, defineSchema } from "@portabletext/schema";
|
|
6
6
|
import * as xstate227 from "xstate";
|
|
7
7
|
import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
|
|
8
8
|
import { BaseRange, Descendant, Operation } from "slate";
|
|
9
|
-
import * as
|
|
9
|
+
import * as react20 from "react";
|
|
10
10
|
import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, KeyboardEvent as KeyboardEvent$1, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
|
|
11
11
|
import * as xstate_guards12 from "xstate/guards";
|
|
12
12
|
import { Observable, Subject } from "rxjs";
|
|
@@ -198,7 +198,7 @@ declare class PortableTextEditor extends Component<PortableTextEditorProps<Inter
|
|
|
198
198
|
componentDidUpdate(prevProps: PortableTextEditorProps): void;
|
|
199
199
|
componentWillUnmount(): void;
|
|
200
200
|
setEditable: (editable: EditableAPI) => void;
|
|
201
|
-
render():
|
|
201
|
+
render(): react20.JSX.Element;
|
|
202
202
|
/**
|
|
203
203
|
* @deprecated
|
|
204
204
|
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
@@ -593,7 +593,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
|
|
|
593
593
|
* ```
|
|
594
594
|
* @group Components
|
|
595
595
|
*/
|
|
596
|
-
declare const PortableTextEditable:
|
|
596
|
+
declare const PortableTextEditable: react20.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react20.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
|
|
597
597
|
type DecoratedRange = BaseRange & {
|
|
598
598
|
rangeDecoration: RangeDecoration;
|
|
599
599
|
};
|
|
@@ -1335,7 +1335,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1335
1335
|
initialValue?: Array<PortableTextBlock>;
|
|
1336
1336
|
}, xstate227.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
1337
1337
|
type: "blurred";
|
|
1338
|
-
event:
|
|
1338
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
1339
1339
|
} | {
|
|
1340
1340
|
type: "done loading";
|
|
1341
1341
|
} | {
|
|
@@ -1347,7 +1347,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1347
1347
|
data: unknown;
|
|
1348
1348
|
} | {
|
|
1349
1349
|
type: "focused";
|
|
1350
|
-
event:
|
|
1350
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
1351
1351
|
} | {
|
|
1352
1352
|
type: "invalid value";
|
|
1353
1353
|
resolution: InvalidValueResolution | null;
|
|
@@ -1502,7 +1502,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1502
1502
|
}, xstate227.AnyEventObject>;
|
|
1503
1503
|
}) => {
|
|
1504
1504
|
behaviors: Set<{
|
|
1505
|
-
behavior: Behavior<"*" | "split" | `custom.${string}` | "annotation.add" | "annotation.remove" | "block.set" | "block.unset" | "child.set" | "child.unset" | "decorator.add" | "decorator.remove" | "delete" | "history.redo" | "history.undo" | "insert.block" | "insert.text" | "move.backward" | "move.block" | "move.forward" | "select" | "annotation.set" | "annotation.toggle" | "decorator.toggle" | "delete.backward" | "delete.block" | "delete.child" | "delete.forward" | "delete.text" | "deserialize" | "deserialize.data" | "deserialization.success" | "deserialization.failure" | "insert.blocks" | "insert.break" | "insert.inline object" | "insert.soft break" | "insert.span" | "list item.add" | "list item.remove" | "list item.toggle" | "move.block down" | "move.block up" | "select.block" | "select.previous block" | "select.next block" | "serialize" | "serialize.data" | "serialization.success" | "serialization.failure" | "style.add" | "style.remove" | "style.toggle" | "clipboard.copy" | "clipboard.cut" | "clipboard.paste" | "drag.dragstart" | "drag.drag" | "drag.dragend" | "drag.dragenter" | "drag.dragover" | "drag.dragleave" | "drag.drop" | "input.*" | "keyboard.keydown" | "keyboard.keyup" | "mouse.click" | "
|
|
1505
|
+
behavior: Behavior<"*" | "split" | `custom.${string}` | "annotation.add" | "annotation.remove" | "block.set" | "block.unset" | "child.set" | "child.unset" | "decorator.add" | "decorator.remove" | "delete" | "history.redo" | "history.undo" | "insert.block" | "insert.text" | "move.backward" | "move.block" | "move.forward" | "select" | "annotation.set" | "annotation.toggle" | "decorator.toggle" | "delete.backward" | "delete.block" | "delete.child" | "delete.forward" | "delete.text" | "deserialize" | "deserialize.data" | "deserialization.success" | "deserialization.failure" | "insert.blocks" | "insert.break" | "insert.inline object" | "insert.soft break" | "insert.span" | "list item.add" | "list item.remove" | "list item.toggle" | "move.block down" | "move.block up" | "select.block" | "select.previous block" | "select.next block" | "serialize" | "serialize.data" | "serialization.success" | "serialization.failure" | "style.add" | "style.remove" | "style.toggle" | "clipboard.copy" | "clipboard.cut" | "clipboard.paste" | "drag.dragstart" | "drag.drag" | "drag.dragend" | "drag.dragenter" | "drag.dragover" | "drag.dragleave" | "drag.drop" | "input.*" | "keyboard.keydown" | "keyboard.keyup" | "mouse.click" | "history.*" | "split.*" | "delete.*" | "select.*" | "deserialize.*" | "serialize.*" | "annotation.*" | "block.*" | "child.*" | "decorator.*" | "insert.*" | "move.*" | "deserialization.*" | "list item.*" | "serialization.*" | "style.*" | "clipboard.*" | "drag.*" | "keyboard.*" | "mouse.*", true, {
|
|
1506
1506
|
type: StrictExtract<"split" | "annotation.add" | "annotation.remove" | "block.set" | "block.unset" | "child.set" | "child.unset" | "decorator.add" | "decorator.remove" | "delete" | "history.redo" | "history.undo" | "insert.block" | "insert.text" | "move.backward" | "move.block" | "move.forward" | "select" | "annotation.set" | "annotation.toggle" | "decorator.toggle" | "delete.backward" | "delete.block" | "delete.child" | "delete.forward" | "delete.text" | "deserialize" | "deserialize.data" | "deserialization.success" | "deserialization.failure" | "insert.blocks" | "insert.break" | "insert.inline object" | "insert.soft break" | "insert.span" | "list item.add" | "list item.remove" | "list item.toggle" | "move.block down" | "move.block up" | "select.block" | "select.previous block" | "select.next block" | "serialize" | "serialize.data" | "serialization.success" | "serialization.failure" | "style.add" | "style.remove" | "style.toggle", "annotation.add">;
|
|
1507
1507
|
annotation: {
|
|
1508
1508
|
name: string;
|
|
@@ -1784,7 +1784,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1784
1784
|
keyGenerator: () => string;
|
|
1785
1785
|
pendingEvents: never[];
|
|
1786
1786
|
pendingIncomingPatchesEvents: never[];
|
|
1787
|
-
schema:
|
|
1787
|
+
schema: _portabletext_schema6.Schema;
|
|
1788
1788
|
selection: null;
|
|
1789
1789
|
initialReadOnly: boolean;
|
|
1790
1790
|
maxBlocks: number | undefined;
|
|
@@ -2007,7 +2007,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2007
2007
|
type: "drop";
|
|
2008
2008
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
2009
2009
|
type: "blurred";
|
|
2010
|
-
event:
|
|
2010
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
2011
2011
|
} | {
|
|
2012
2012
|
type: "done loading";
|
|
2013
2013
|
} | {
|
|
@@ -2019,7 +2019,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2019
2019
|
data: unknown;
|
|
2020
2020
|
} | {
|
|
2021
2021
|
type: "focused";
|
|
2022
|
-
event:
|
|
2022
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
2023
2023
|
} | {
|
|
2024
2024
|
type: "invalid value";
|
|
2025
2025
|
resolution: InvalidValueResolution | null;
|
|
@@ -2890,7 +2890,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2890
2890
|
type: "drop";
|
|
2891
2891
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
2892
2892
|
type: "blurred";
|
|
2893
|
-
event:
|
|
2893
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
2894
2894
|
} | {
|
|
2895
2895
|
type: "done loading";
|
|
2896
2896
|
} | {
|
|
@@ -2902,7 +2902,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2902
2902
|
data: unknown;
|
|
2903
2903
|
} | {
|
|
2904
2904
|
type: "focused";
|
|
2905
|
-
event:
|
|
2905
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
2906
2906
|
} | {
|
|
2907
2907
|
type: "invalid value";
|
|
2908
2908
|
resolution: InvalidValueResolution | null;
|
package/lib/index.cjs
CHANGED
|
@@ -2255,8 +2255,12 @@ PortableTextEditable.displayName = "ForwardRef(PortableTextEditable)";
|
|
|
2255
2255
|
function validateSelection(slateEditor, activeElement) {
|
|
2256
2256
|
if (!slateEditor.selection)
|
|
2257
2257
|
return;
|
|
2258
|
-
|
|
2259
|
-
|
|
2258
|
+
let root;
|
|
2259
|
+
try {
|
|
2260
|
+
root = slateReact.ReactEditor.findDocumentOrShadowRoot(slateEditor);
|
|
2261
|
+
} catch {
|
|
2262
|
+
}
|
|
2263
|
+
if (!root || activeElement !== root.activeElement)
|
|
2260
2264
|
return;
|
|
2261
2265
|
const domSelection = slateReact.ReactEditor.getWindow(slateEditor).getSelection();
|
|
2262
2266
|
if (!domSelection || domSelection.rangeCount === 0)
|