@portabletext/editor 4.1.5 → 4.2.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.
@@ -3,8 +3,8 @@ import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObject
3
3
  import { BaseRange, Descendant, Operation, Range } from "slate";
4
4
  import * as xstate71 from "xstate";
5
5
  import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
6
- import * as react6 from "react";
7
- import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, KeyboardEvent as KeyboardEvent$1, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
6
+ import * as react10 from "react";
7
+ import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
8
8
  import { Patch, Patch as Patch$1 } from "@portabletext/patches";
9
9
  import { Observable, Subject } from "rxjs";
10
10
  import { ArrayDefinition, ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition, ObjectSchemaType } from "@sanity/types";
@@ -134,7 +134,6 @@ type RemotePatch = {
134
134
  interface PortableTextSlateEditor extends ReactEditor {
135
135
  _key: 'editor';
136
136
  _type: 'editor';
137
- createPlaceholderBlock: () => Descendant;
138
137
  isTextBlock: (value: unknown) => value is PortableTextTextBlock;
139
138
  isTextSpan: (value: unknown) => value is PortableTextSpan;
140
139
  isListBlock: (value: unknown) => value is PortableTextListBlock;
@@ -156,10 +155,6 @@ interface PortableTextSlateEditor extends ReactEditor {
156
155
  isRedoing: boolean;
157
156
  isUndoing: boolean;
158
157
  withHistory: boolean;
159
- /**
160
- * Use hotkeys
161
- */
162
- pteWithHotKeys: (event: KeyboardEvent$1<HTMLDivElement>) => void;
163
158
  /**
164
159
  * Undo
165
160
  */
@@ -311,7 +306,7 @@ declare class PortableTextEditor extends Component<PortableTextEditorProps<Inter
311
306
  componentDidUpdate(prevProps: PortableTextEditorProps): void;
312
307
  componentWillUnmount(): void;
313
308
  setEditable: (editable: EditableAPI) => void;
314
- render(): react6.JSX.Element;
309
+ render(): react10.JSX.Element;
315
310
  /**
316
311
  * @deprecated
317
312
  * Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
@@ -720,7 +715,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
720
715
  * ```
721
716
  * @group Components
722
717
  */
723
- declare const PortableTextEditable: react6.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react6.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
718
+ declare const PortableTextEditable: react10.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react10.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
724
719
  /** @beta */
725
720
  interface EditableAPIDeleteOptions {
726
721
  mode?: 'blocks' | 'children' | 'selected';
@@ -1340,6 +1335,20 @@ type BehaviorConfig = {
1340
1335
  behavior: Behavior;
1341
1336
  priority: EditorPriority;
1342
1337
  };
1338
+ type BehaviorIndex = {
1339
+ global: Array<SortedBehavior>;
1340
+ namespaced: Map<string, Array<SortedBehavior>>;
1341
+ exact: Map<string, Array<SortedBehavior>>;
1342
+ };
1343
+ type SortedBehavior = {
1344
+ behavior: Behavior;
1345
+ sortOrder: number;
1346
+ };
1347
+ /**
1348
+ * Given an array of Behaviors, build a `BehaviorIndex` where the `sortOrder`
1349
+ * of each Behavior is preserved.
1350
+ */
1351
+
1343
1352
  /**
1344
1353
  * @public
1345
1354
  */
@@ -1368,7 +1377,9 @@ type EditorActor = ActorRefFrom<typeof editorMachine>;
1368
1377
  */
1369
1378
  declare const editorMachine: xstate71.StateMachine<{
1370
1379
  behaviors: Set<BehaviorConfig>;
1371
- behaviorsSorted: boolean;
1380
+ behaviorIndex: BehaviorIndex;
1381
+ abstractBehaviorIndex: BehaviorIndex;
1382
+ behaviorsIndexed: boolean;
1372
1383
  converters: Set<Converter>;
1373
1384
  getLegacySchema: () => PortableTextMemberSchemaTypes;
1374
1385
  keyGenerator: () => string;
@@ -1478,7 +1489,7 @@ declare const editorMachine: xstate71.StateMachine<{
1478
1489
  type: "handle behavior event";
1479
1490
  params: unknown;
1480
1491
  } | {
1481
- type: "sort behaviors";
1492
+ type: "index behaviors";
1482
1493
  params: xstate71.NonReducibleUnknown;
1483
1494
  }, {
1484
1495
  type: "slate is busy";
@@ -1511,7 +1522,7 @@ declare const editorMachine: xstate71.StateMachine<{
1511
1522
  initialValue?: Array<PortableTextBlock>;
1512
1523
  }, xstate71.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
1513
1524
  type: "blurred";
1514
- event: react6.FocusEvent<HTMLDivElement, Element>;
1525
+ event: react10.FocusEvent<HTMLDivElement, Element>;
1515
1526
  } | {
1516
1527
  type: "done loading";
1517
1528
  } | {
@@ -1523,7 +1534,7 @@ declare const editorMachine: xstate71.StateMachine<{
1523
1534
  data: unknown;
1524
1535
  } | {
1525
1536
  type: "focused";
1526
- event: react6.FocusEvent<HTMLDivElement, Element>;
1537
+ event: react10.FocusEvent<HTMLDivElement, Element>;
1527
1538
  } | {
1528
1539
  type: "invalid value";
1529
1540
  resolution: InvalidValueResolution | null;
@@ -1804,6 +1815,7 @@ type AbstractBehaviorEvent = {
1804
1815
  blocks: Array<BlockWithOptionalKey>;
1805
1816
  placement: InsertPlacement;
1806
1817
  select?: 'start' | 'end' | 'none';
1818
+ at?: NonNullable<EditorSelection>;
1807
1819
  } | {
1808
1820
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.break'>;
1809
1821
  } | {