@portabletext/editor 7.12.2 → 8.0.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.
@@ -1,5 +1,5 @@
1
- import React$1, { BaseSyntheticEvent, ClipboardEvent as ClipboardEvent$1, FocusEvent, JSX, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
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, OfDefinition as OfDefinition$1, 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";
1
+ import React$1, { BaseSyntheticEvent, ClipboardEvent as ClipboardEvent$1, FocusEvent, JSX, PropsWithChildren, ReactElement, TextareaHTMLAttributes } from "react";
2
+ import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, DecoratorDefinition, DecoratorSchemaType, FieldDefinition, FieldDefinition as FieldDefinition$1, InlineObjectDefinition, InlineObjectSchemaType, ListDefinition, ListSchemaType, OfDefinition, OfDefinition as OfDefinition$1, 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, TypedObject, defineSchema } from "@portabletext/schema";
3
3
  import { ActorRefFrom } from "xstate";
4
4
  import { Patch, Patch as Patch$1 } from "@portabletext/patches";
5
5
  type MIMEType = `${string}/${string}`;
@@ -137,9 +137,8 @@ type ContainerRender = (props: ContainerRenderProps) => ReactElement;
137
137
  * A span's render function. Receives a portable text span node and
138
138
  * wraps it. `children` carries the styled text already decorated by
139
139
  * the decorator/annotation renders (registered via `defineDecorator`/
140
- * `defineAnnotation`, or the legacy `renderDecorator`/`renderAnnotation`
141
- * props). Range decorations wrap this render's output from the
142
- * outside, so they are not part of `children`.
140
+ * `defineAnnotation`). Range decorations wrap this render's output
141
+ * from the outside, so they are not part of `children`.
143
142
  */
144
143
  type SpanRenderProps = {
145
144
  attributes: Record<string, unknown>;
@@ -166,8 +165,7 @@ type SpanRender = (props: SpanRenderProps) => ReactElement;
166
165
  * wraps the styled text it applies to. Range and selection decorations
167
166
  * can split one span into several leaves, so this fires once per
168
167
  * decorator on each leaf, not once per span, nested in the span's
169
- * `marks` order alongside any decorators still rendered by the legacy
170
- * `renderDecorator` prop.
168
+ * `marks` order.
171
169
  *
172
170
  * The render is a plain function call, not a component: do not call
173
171
  * hooks in it. When you need hooks, return an element of your own
@@ -204,9 +202,7 @@ type DecoratorRender = (props: DecoratorRenderProps) => ReactElement;
204
202
  * An annotation's render function. Receives the annotation's `markDef`
205
203
  * object and wraps the styled text it applies to. The engine anchors
206
204
  * the text in a `<span>` outside this render regardless of whether a
207
- * render is registered, kept for structural parity with the legacy
208
- * `renderAnnotation` path (which hands that anchor to consumers as
209
- * `editorElementRef`); this render's job is the styling wrapper only.
205
+ * render is registered; this render's job is the styling wrapper only.
210
206
  *
211
207
  * The render is a plain function call, not a component: do not call
212
208
  * hooks in it. When you need hooks, return an element of your own
@@ -329,16 +325,14 @@ type Container = {
329
325
  * register a different `_type` to render at that lexical scope.
330
326
  *
331
327
  * `defineTextBlock` opts the text block into the new render pipeline.
332
- * The consumer's `render` callback owns the outer wrapper entirely:
333
- * the engine emits `data-pt-*` attributes only - no `pt-*` CSS classes,
334
- * no legacy `data-block-*` attributes - and the block-level
335
- * `renderStyle`/`renderListItem`/`renderBlock` props on
336
- * `<PortableTextEditable>` do not compose under this registration.
328
+ * The consumer's `render` callback owns the outer wrapper entirely: the
329
+ * engine emits `data-pt-*` attributes only, no `pt-*` CSS classes and no
330
+ * legacy `data-block-*` attributes.
337
331
  *
338
- * Span-level render props - `renderDecorator`, `renderAnnotation`,
339
- * `renderPlaceholder`, and range decorations - keep working. They fire
340
- * on the spans inside `children` regardless of which text block outer
341
- * wrapper renders them.
332
+ * Span-level rendering - decorator and annotation registrations,
333
+ * `renderPlaceholder`, and range decorations - keeps working. It
334
+ * fires on the spans inside `children` regardless of which text
335
+ * block outer wrapper renders them.
342
336
  */
343
337
  type TextBlock = {
344
338
  kind: 'textBlock';
@@ -356,9 +350,8 @@ type TextBlock = {
356
350
  * text block of this `type` if registered at the top level).
357
351
  * `Decorator` and `Annotation` entries scope those renders the
358
352
  * same way: the decorator or annotation renders through this entry
359
- * inside the text block, and through the global registration (or
360
- * the legacy `renderDecorator`/`renderAnnotation` prop) everywhere
361
- * else.
353
+ * inside the text block, and through the global registration
354
+ * everywhere else.
362
355
  */
363
356
  of?: ReadonlyArray<Span | InlineObject | Decorator | Annotation>;
364
357
  };
@@ -366,10 +359,10 @@ type TextBlock = {
366
359
  * @public
367
360
  *
368
361
  * Text block render function. `children` carries the rendered spans -
369
- * `renderDecorator`, `renderAnnotation`, `renderPlaceholder`, and range
370
- * decorations have already fired at the leaf level. The render's job
371
- * is the outer wrapper element and any block-level composition (style,
372
- * list-item) the consumer wants.
362
+ * decorator and annotation registrations, `renderPlaceholder`, and
363
+ * range decorations have already fired at the leaf level. The render's
364
+ * job is the outer wrapper element and any block-level composition
365
+ * (style, list-item) the consumer wants.
373
366
  */
374
367
  type TextBlockRenderProps = {
375
368
  attributes: Record<string, unknown>;
@@ -884,34 +877,6 @@ type TraversalSnapshot = {
884
877
  };
885
878
  blockIndexMap: ReadonlyMap<string, number>;
886
879
  };
887
- /**
888
- * Walk the editor value following `path` and return the
889
- * {@link RegisteredContainer} or {@link RegisteredPositional} that applies
890
- * at `path`'s target position.
891
- *
892
- * Resolution rules at each step:
893
- *
894
- * 1. **Positional override.** If the current parent declares the
895
- * child's `_type` in its `of`, the positional entry wins.
896
- * Used to resolve same-`_type` registered under different
897
- * parents with different `field` values.
898
- *
899
- * 2. **Global fallback.** If the parent has no positional override,
900
- * fall back to the top-level entry for `_type` in
901
- * `containers`.
902
- *
903
- * 3. **Chain validity.** If any ancestor along the path has no
904
- * resolved container entry (unregistered or not reachable as a
905
- * container at its position), return `undefined`.
906
- *
907
- * Returns `undefined` when the target's `_type` is not registered
908
- * at this position. Returns a {@link RegisteredPositional} when the target
909
- * resolves to a leaf in a positional `of` (terminal node with no
910
- * editable children).
911
- *
912
- * @alpha
913
- */
914
- declare function resolveContainerAt(containers: Containers, value: ReadonlyArray<Node$1>, path: Path): RegisteredContainer | RegisteredPositional | undefined;
915
880
  /**
916
881
  * @public
917
882
  * @deprecated Use `useEditor()` instead
@@ -961,7 +926,7 @@ declare class PortableTextEditor {
961
926
  * const isActive = useEditorSelector(editor, selectors.isActiveAnnotation(...))
962
927
  * ```
963
928
  */
964
- static isAnnotationActive: (editor: PortableTextEditor, annotationType: PortableTextObject["_type"]) => boolean;
929
+ static isAnnotationActive: (editor: PortableTextEditor, annotationType: PortableTextObject['_type']) => boolean;
965
930
  /**
966
931
  * @deprecated
967
932
  * Use `editor.send(...)` instead
@@ -1010,7 +975,7 @@ declare class PortableTextEditor {
1010
975
  */
1011
976
  static delete: (editor: PortableTextEditor, selection: EditorSelection, options?: EditableAPIDeleteOptions) => void;
1012
977
  static findDOMNode: (editor: PortableTextEditor, element: PortableTextBlock | PortableTextChild) => Node | undefined;
1013
- static findByPath: (editor: PortableTextEditor, path: Path) => [import("@portabletext/schema").PortableTextTextBlock<PortableTextObject | import("@portabletext/schema").PortableTextSpan> | PortableTextObject | import("@portabletext/schema").PortableTextSpan | undefined, Path | undefined];
978
+ static findByPath: (editor: PortableTextEditor, path: Path) => [PortableTextObject | import("@portabletext/schema").PortableTextSpan | import("@portabletext/schema").PortableTextTextBlock<PortableTextObject | import("@portabletext/schema").PortableTextSpan> | undefined, Path | undefined];
1014
979
  /**
1015
980
  * @deprecated
1016
981
  * Use `editor.send(...)` instead
@@ -1317,46 +1282,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
1317
1282
  onPaste?: OnPasteFn;
1318
1283
  onCopy?: OnCopyFn;
1319
1284
  rangeDecorations?: RangeDecoration[];
1320
- /**
1321
- * @deprecated Register your annotations with `defineAnnotation`
1322
- * mounted through `NodePlugin` instead. See the migration guide:
1323
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1324
- */
1325
- renderAnnotation?: RenderAnnotationFunction;
1326
- /**
1327
- * @deprecated Register your block objects and text blocks with
1328
- * `defineBlockObject` / `defineTextBlock` mounted through `NodePlugin`
1329
- * instead. See the migration guide:
1330
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1331
- */
1332
- renderBlock?: RenderBlockFunction;
1333
- /**
1334
- * @deprecated Register your inline objects and spans with
1335
- * `defineInlineObject` / `defineSpan` mounted through `NodePlugin`
1336
- * instead. See the migration guide:
1337
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1338
- */
1339
- renderChild?: RenderChildFunction;
1340
- /**
1341
- * @deprecated Register your decorators with `defineDecorator` mounted
1342
- * through `NodePlugin` instead. See the migration guide:
1343
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1344
- */
1345
- renderDecorator?: RenderDecoratorFunction;
1346
- /**
1347
- * @deprecated Render list items with `defineTextBlock` mounted through
1348
- * `NodePlugin`, with list numbering from
1349
- * `@portabletext/plugin-list-index`. See the migration guide:
1350
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1351
- */
1352
- renderListItem?: RenderListItemFunction;
1353
1285
  renderPlaceholder?: RenderPlaceholderFunction;
1354
- /**
1355
- * @deprecated Render text-block styles with `defineTextBlock` mounted
1356
- * through `NodePlugin` instead. See the migration guide:
1357
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1358
- */
1359
- renderStyle?: RenderStyleFunction;
1360
1286
  scrollSelectionIntoView?: ScrollSelectionIntoViewFunction;
1361
1287
  selection?: EditorSelection;
1362
1288
  spellCheck?: boolean;
@@ -1381,7 +1307,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
1381
1307
  * ```
1382
1308
  * @group Components
1383
1309
  */
1384
- declare const PortableTextEditable: import("react").ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & import("react").RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
1310
+ declare const PortableTextEditable: import("react").ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & import("react").RefAttributes<Omit<HTMLDivElement, "as" | "onBeforeInput" | "onPaste">>>;
1385
1311
  /**
1386
1312
  * @beta
1387
1313
  * @deprecated `EditableAPIDeleteOptions` is deprecated together with the
@@ -1514,170 +1440,10 @@ interface PasteData {
1514
1440
  type OnPasteFn = (data: PasteData) => OnPasteResultOrPromise;
1515
1441
  /** @beta */
1516
1442
  type OnCopyFn = (event: ClipboardEvent$1<HTMLDivElement | HTMLSpanElement>) => undefined | unknown;
1517
- /**
1518
- * @beta
1519
- * @deprecated `BlockRenderProps` is deprecated together with the
1520
- * `renderBlock` render prop it serves. Type against
1521
- * `BlockObjectRenderProps` / `TextBlockRenderProps` from the node
1522
- * registration API instead. See the migration guide:
1523
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1524
- */
1525
- interface BlockRenderProps {
1526
- children: ReactElement<any>;
1527
- editorElementRef: RefObject<HTMLElement | null>;
1528
- focused: boolean;
1529
- level?: number;
1530
- listItem?: string;
1531
- path: BlockPath;
1532
- selected: boolean;
1533
- style?: string;
1534
- schemaType: BlockObjectSchemaType;
1535
- value: PortableTextBlock;
1536
- }
1537
- /**
1538
- * @beta
1539
- * @deprecated `BlockChildRenderProps` is deprecated together with the
1540
- * `renderChild` render prop it serves. Type against
1541
- * `InlineObjectRenderProps` / `SpanRenderProps` from the node
1542
- * registration API instead. See the migration guide:
1543
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1544
- */
1545
- interface BlockChildRenderProps {
1546
- annotations: PortableTextObject[];
1547
- children: ReactElement<any>;
1548
- editorElementRef: RefObject<HTMLElement | null>;
1549
- focused: boolean;
1550
- path: Path;
1551
- selected: boolean;
1552
- schemaType: InlineObjectSchemaType;
1553
- value: PortableTextChild;
1554
- }
1555
- /**
1556
- * @beta
1557
- * @deprecated `BlockAnnotationRenderProps` is deprecated together with the
1558
- * `renderAnnotation` render prop it serves. Type against
1559
- * `AnnotationRenderProps` from the node registration API instead. See the
1560
- * migration guide:
1561
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1562
- */
1563
- interface BlockAnnotationRenderProps {
1564
- block: PortableTextBlock;
1565
- children: ReactElement<any>;
1566
- editorElementRef: RefObject<HTMLElement | null>;
1567
- focused: boolean;
1568
- path: Path;
1569
- schemaType: AnnotationSchemaType;
1570
- selected: boolean;
1571
- value: PortableTextObject;
1572
- }
1573
- /**
1574
- * @beta
1575
- * @deprecated `BlockDecoratorRenderProps` is deprecated together with the
1576
- * `renderDecorator` render prop it serves. Type against
1577
- * `DecoratorRenderProps` from the node registration API instead. See the
1578
- * migration guide:
1579
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1580
- */
1581
- interface BlockDecoratorRenderProps {
1582
- children: ReactElement<any>;
1583
- editorElementRef: RefObject<HTMLElement | null>;
1584
- focused: boolean;
1585
- path: Path;
1586
- schemaType: DecoratorSchemaType;
1587
- selected: boolean;
1588
- value: string;
1589
- }
1590
- /**
1591
- * @beta
1592
- * @deprecated `BlockListItemRenderProps` is deprecated together with the
1593
- * `renderListItem` render prop it serves. Render list items with
1594
- * `defineTextBlock` mounted through `NodePlugin` instead. See the
1595
- * migration guide:
1596
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1597
- */
1598
- interface BlockListItemRenderProps {
1599
- block: PortableTextTextBlock;
1600
- children: ReactElement<any>;
1601
- editorElementRef: RefObject<HTMLElement | null>;
1602
- focused: boolean;
1603
- level: number;
1604
- path: Path;
1605
- schemaType: ListSchemaType;
1606
- selected: boolean;
1607
- value: string;
1608
- }
1609
- /**
1610
- * @beta
1611
- * @deprecated The `renderBlock` render prop is deprecated. Register your
1612
- * block objects and text blocks with `defineBlockObject` /
1613
- * `defineTextBlock` mounted through `NodePlugin` instead. See the
1614
- * migration guide:
1615
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1616
- */
1617
- type RenderBlockFunction = (props: BlockRenderProps) => JSX.Element;
1618
- /**
1619
- * @beta
1620
- * @deprecated The `renderChild` render prop is deprecated. Register your
1621
- * inline objects and spans with `defineInlineObject` / `defineSpan`
1622
- * mounted through `NodePlugin` instead. See the migration guide:
1623
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1624
- */
1625
- type RenderChildFunction = (props: BlockChildRenderProps) => JSX.Element;
1626
1443
  /** @public */
1627
1444
  type RenderEditableFunction = (props: PortableTextEditableProps) => JSX.Element;
1628
- /**
1629
- * @beta
1630
- * @deprecated The `renderAnnotation` render prop is deprecated. Register
1631
- * your annotations with `defineAnnotation` mounted through `NodePlugin`
1632
- * instead. See the migration guide:
1633
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1634
- */
1635
- type RenderAnnotationFunction = (props: BlockAnnotationRenderProps) => JSX.Element;
1636
1445
  /** @public */
1637
1446
  type RenderPlaceholderFunction = () => React.ReactNode;
1638
- /**
1639
- * @beta
1640
- * @deprecated The `renderStyle` render prop is deprecated. Render
1641
- * text-block styles with `defineTextBlock` mounted through `NodePlugin`
1642
- * instead. See the migration guide:
1643
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1644
- */
1645
- type RenderStyleFunction = (props: BlockStyleRenderProps) => JSX.Element;
1646
- /**
1647
- * @beta
1648
- * @deprecated `BlockStyleRenderProps` is deprecated together with the
1649
- * `renderStyle` render prop it serves. Render text-block styles with
1650
- * `defineTextBlock` mounted through `NodePlugin` instead. See the
1651
- * migration guide:
1652
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1653
- */
1654
- interface BlockStyleRenderProps {
1655
- block: PortableTextTextBlock;
1656
- children: ReactElement<any>;
1657
- editorElementRef: RefObject<HTMLElement | null>;
1658
- focused: boolean;
1659
- path: Path;
1660
- selected: boolean;
1661
- schemaType: StyleSchemaType;
1662
- value: string;
1663
- }
1664
- /**
1665
- * @beta
1666
- * @deprecated The `renderListItem` render prop is deprecated. Render list
1667
- * items with `defineTextBlock` mounted through `NodePlugin`, with list
1668
- * numbering from `@portabletext/plugin-list-index`. See the migration
1669
- * guide:
1670
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1671
- */
1672
- type RenderListItemFunction = (props: BlockListItemRenderProps) => JSX.Element;
1673
- /**
1674
- * @beta
1675
- * @deprecated The `renderDecorator` render prop is deprecated. Register
1676
- * your decorators with `defineDecorator` mounted through `NodePlugin`
1677
- * instead. See the migration guide:
1678
- * https://www.portabletext.org/editor/guides/migrate-render-props/
1679
- */
1680
- type RenderDecoratorFunction = (props: BlockDecoratorRenderProps) => JSX.Element;
1681
1447
  /** @public */
1682
1448
  type ScrollSelectionIntoViewFunction = (editor: PortableTextEditor, domRange: globalThis.Range) => void;
1683
1449
  /**
@@ -2163,28 +1929,15 @@ interface PortableTextEditorEngine extends DOMEditor {
2163
1929
  decoratedRanges: Array<DecoratedRange>;
2164
1930
  blockIndexMap: Map<string, number>;
2165
1931
  history: History;
2166
- listIndexMap: Map<string, number>;
2167
- /**
2168
- * `listIndexMap` is derived from the whole value (list-item numbering
2169
- * depends on block adjacency), so structural operations invalidate it
2170
- * rather than rebuild it. The only reader is the text-block renderer,
2171
- * which rebuilds on demand via `getListIndexMap`. Deferring the rebuild
2172
- * to read time collapses a per-operation O(value) walk into one rebuild
2173
- * per render, regardless of how many operations a batch applied.
2174
- */
2175
- listIndexMapDirty: boolean;
2176
1932
  /**
2177
1933
  * Per-notify pending flags for the segmented selector channels
2178
1934
  * (`EngineSelectorChannel`). Set where the corresponding state mutates
2179
- * (registration map swaps in `register-node-on-engine.ts`, list-index
2180
- * invalidation in the update-value subscriber) and consumed by the
2181
- * React layer's `onContextChange` dispatch. Separate from
2182
- * `listIndexMapDirty`, which any read clears via `getListIndexMap`;
2183
- * these are cleared only when the notification is delivered.
1935
+ * (registration map swaps in `register-node-on-engine.ts`) and consumed
1936
+ * by the React layer's `onContextChange` dispatch; cleared only when
1937
+ * the notification is delivered.
2184
1938
  */
2185
1939
  selectorChannelsPending: {
2186
1940
  registrations: boolean;
2187
- listIndex: boolean;
2188
1941
  };
2189
1942
  /**
2190
1943
  * Serialized paths of sibling groups (a node's keyed child array, or the
@@ -2251,15 +2004,15 @@ type EditorContext = {
2251
2004
  *
2252
2005
  * Each entry is a {@link RegisteredContainer} carrying `type`,
2253
2006
  * the array `field` that holds the container's editable children,
2254
- * and (when present) the nested positional `of` registrations
2255
- * consulted by {@link resolveContainerAt}. The render callback is
2256
- * engine-internal and not surfaced here.
2007
+ * and (when present) the nested positional `of` registrations the
2008
+ * engine consults when it descends into the container. The render
2009
+ * callback is engine-internal and not surfaced here.
2257
2010
  *
2258
2011
  * Only top-level registrations appear as flat entries. A `_type`
2259
2012
  * registered only inside a parent's `of` is reachable through that
2260
- * parent's `of`, not as a top-level entry. Use
2261
- * `resolveContainerAt(containers, value, path)` for position-aware
2262
- * resolution that handles both top-level and positional entries.
2013
+ * parent's `of`, not as a top-level entry. For position-aware descent,
2014
+ * walk the entries with `getContainerChildren` from
2015
+ * `@portabletext/editor/traversal`.
2263
2016
  *
2264
2017
  * @public
2265
2018
  */
@@ -2359,25 +2112,15 @@ type Operation = InsertOperation | InsertTextOperation | RemoveTextOperation | S
2359
2112
  type EditorEmittedEvent = {
2360
2113
  type: 'blurred';
2361
2114
  event: FocusEvent<HTMLDivElement, Element>;
2362
- } | {
2363
- /**
2364
- * @deprecated Will be removed in the next major version
2365
- */
2366
- type: 'done loading';
2367
2115
  } | {
2368
2116
  type: 'editable';
2369
- } | ErrorEvent | {
2117
+ } | {
2370
2118
  type: 'focused';
2371
2119
  event: FocusEvent<HTMLDivElement, Element>;
2372
2120
  } | {
2373
2121
  type: 'invalid value';
2374
2122
  resolution: InvalidValueResolution | null;
2375
2123
  value: Array<PortableTextBlock> | undefined;
2376
- } | {
2377
- /**
2378
- * @deprecated Will be removed in the next major version
2379
- */
2380
- type: 'loading';
2381
2124
  } | MutationEvent | {
2382
2125
  /**
2383
2126
  * @beta
@@ -2411,15 +2154,6 @@ type EditorEmittedEvent = {
2411
2154
  type: 'value changed';
2412
2155
  value: Array<PortableTextBlock> | undefined;
2413
2156
  };
2414
- /**
2415
- * @deprecated The event is no longer emitted
2416
- */
2417
- type ErrorEvent = {
2418
- type: 'error';
2419
- name: string;
2420
- description: string;
2421
- data: unknown;
2422
- };
2423
2157
  /**
2424
2158
  * @public
2425
2159
  */
@@ -2689,71 +2423,62 @@ declare const editorMachine: import("xstate").StateMachine<{
2689
2423
  initialReadOnly: boolean;
2690
2424
  initialValue: Array<PortableTextBlock> | undefined;
2691
2425
  internalDrag?: {
2692
- origin: Pick<EventPosition, "selection">;
2426
+ origin: Pick<EventPosition, 'selection'>;
2693
2427
  };
2694
2428
  dragGhost?: HTMLElement;
2695
2429
  editorEngine?: PortableTextEditorEngine;
2696
- }, InternalPatchEvent | MutationEvent | PatchesEvent | {
2697
- type: "update readOnly";
2430
+ }, MutationEvent | PatchesEvent | {
2431
+ type: 'update readOnly';
2698
2432
  readOnly: boolean;
2699
2433
  } | {
2700
- type: "add behavior";
2434
+ type: 'add behavior';
2701
2435
  behaviorConfig: BehaviorConfig;
2702
2436
  } | {
2703
- type: "remove behavior";
2437
+ type: 'remove behavior';
2704
2438
  behaviorConfig: BehaviorConfig;
2705
2439
  } | {
2706
- type: "blur";
2440
+ type: 'blur';
2707
2441
  editor: PortableTextEditorEngine;
2708
2442
  } | {
2709
- type: "focus";
2443
+ type: 'focus';
2710
2444
  editor: PortableTextEditorEngine;
2711
2445
  } | {
2712
- type: "update selection";
2446
+ type: 'update selection';
2713
2447
  selection: EditorSelection;
2714
2448
  } | {
2715
- type: "done syncing value";
2449
+ type: 'done syncing value';
2716
2450
  } | {
2717
- type: "syncing value";
2451
+ type: 'syncing value';
2718
2452
  } | {
2719
- type: "behavior event";
2453
+ type: 'behavior event';
2720
2454
  behaviorEvent: BehaviorEvent;
2721
2455
  editor: PortableTextEditorEngine;
2722
2456
  nativeEvent?: {
2723
2457
  preventDefault: () => void;
2724
2458
  };
2725
2459
  } | {
2726
- type: "set drag ghost";
2460
+ type: 'set drag ghost';
2727
2461
  ghost: HTMLElement;
2728
2462
  } | {
2729
- type: "dragstart";
2463
+ type: 'dragstart';
2730
2464
  ghost?: HTMLElement;
2731
- origin: Pick<EventPosition, "selection">;
2465
+ origin: Pick<EventPosition, 'selection'>;
2732
2466
  } | {
2733
- type: "dragend";
2467
+ type: 'dragend';
2734
2468
  } | {
2735
- type: "drop";
2469
+ type: 'drop';
2736
2470
  } | {
2737
- type: "register";
2471
+ type: 'register';
2738
2472
  node: RegistrableNode;
2739
2473
  } | {
2740
- type: "unregister";
2474
+ type: 'unregister';
2741
2475
  node: RegistrableNode;
2742
2476
  } | {
2743
- type: "add editor engine";
2477
+ type: 'add editor engine';
2744
2478
  editor: PortableTextEditorEngine;
2745
- }, {}, never, {
2746
- type: "register";
2747
- params: unknown;
2748
- } | {
2749
- type: "unregister";
2750
- params: unknown;
2751
- } | {
2479
+ } | InternalPatchEvent, {}, never, {
2752
2480
  type: "add behavior to context";
2753
2481
  params: import("xstate").NonReducibleUnknown;
2754
- } | {
2755
- type: "remove behavior from context";
2756
- params: import("xstate").NonReducibleUnknown;
2757
2482
  } | {
2758
2483
  type: "add editor engine to context";
2759
2484
  params: import("xstate").NonReducibleUnknown;
@@ -2761,44 +2486,47 @@ declare const editorMachine: import("xstate").StateMachine<{
2761
2486
  type: "attach maps to editor engine";
2762
2487
  params: unknown;
2763
2488
  } | {
2764
- type: "emit patch event";
2489
+ type: "clear pending events";
2765
2490
  params: import("xstate").NonReducibleUnknown;
2766
2491
  } | {
2767
- type: "emit mutation event";
2492
+ type: "clear pending incoming patches";
2768
2493
  params: import("xstate").NonReducibleUnknown;
2769
2494
  } | {
2770
- type: "emit read only";
2495
+ type: "defer event";
2771
2496
  params: import("xstate").NonReducibleUnknown;
2772
2497
  } | {
2773
- type: "emit editable";
2498
+ type: "defer incoming patches";
2774
2499
  params: import("xstate").NonReducibleUnknown;
2775
2500
  } | {
2776
- type: "defer event";
2501
+ type: "discard all pending events";
2777
2502
  params: import("xstate").NonReducibleUnknown;
2778
2503
  } | {
2779
- type: "emit pending events";
2504
+ type: "discard conflicting pending patches";
2780
2505
  params: import("xstate").NonReducibleUnknown;
2781
2506
  } | {
2782
- type: "emit ready";
2507
+ type: "emit editable";
2783
2508
  params: import("xstate").NonReducibleUnknown;
2784
2509
  } | {
2785
- type: "clear pending events";
2510
+ type: "emit mutation event";
2786
2511
  params: import("xstate").NonReducibleUnknown;
2787
2512
  } | {
2788
- type: "discard conflicting pending patches";
2513
+ type: "emit patch event";
2789
2514
  params: import("xstate").NonReducibleUnknown;
2790
2515
  } | {
2791
- type: "discard all pending events";
2516
+ type: "emit pending events";
2792
2517
  params: import("xstate").NonReducibleUnknown;
2793
2518
  } | {
2794
- type: "defer incoming patches";
2519
+ type: "emit pending incoming patches";
2795
2520
  params: import("xstate").NonReducibleUnknown;
2796
2521
  } | {
2797
- type: "emit pending incoming patches";
2522
+ type: "emit read only";
2798
2523
  params: import("xstate").NonReducibleUnknown;
2799
2524
  } | {
2800
- type: "clear pending incoming patches";
2525
+ type: "emit ready";
2801
2526
  params: import("xstate").NonReducibleUnknown;
2527
+ } | {
2528
+ type: "handle behavior event";
2529
+ params: unknown;
2802
2530
  } | {
2803
2531
  type: "handle blur";
2804
2532
  params: unknown;
@@ -2806,11 +2534,17 @@ declare const editorMachine: import("xstate").StateMachine<{
2806
2534
  type: "handle focus";
2807
2535
  params: unknown;
2808
2536
  } | {
2809
- type: "handle behavior event";
2537
+ type: "register";
2810
2538
  params: unknown;
2539
+ } | {
2540
+ type: "remove behavior from context";
2541
+ params: import("xstate").NonReducibleUnknown;
2811
2542
  } | {
2812
2543
  type: "sort behaviors";
2813
2544
  params: import("xstate").NonReducibleUnknown;
2545
+ } | {
2546
+ type: "unregister";
2547
+ params: unknown;
2814
2548
  }, {
2815
2549
  type: "engine is busy";
2816
2550
  params: unknown;
@@ -2820,14 +2554,14 @@ declare const editorMachine: import("xstate").StateMachine<{
2820
2554
  }, never, {
2821
2555
  "edit mode": {
2822
2556
  editable: "dragging internally" | "idle" | {
2823
- focusing: "checking if busy" | "busy";
2557
+ focusing: "busy" | "checking if busy";
2824
2558
  };
2825
2559
  } | {
2826
- "read only": "read only" | "determine initial edit mode";
2560
+ "read only": "determine initial edit mode" | "read only";
2827
2561
  };
2828
2562
  setup: "setting up" | {
2829
2563
  "set up": {
2830
- "value sync": "syncing value" | "idle";
2564
+ "value sync": "idle" | "syncing value";
2831
2565
  writing: "dirty" | {
2832
2566
  pristine: "idle";
2833
2567
  };
@@ -2839,41 +2573,32 @@ declare const editorMachine: import("xstate").StateMachine<{
2839
2573
  readOnly?: boolean;
2840
2574
  schema: EditorSchema;
2841
2575
  initialValue?: Array<PortableTextBlock>;
2842
- }, import("xstate").NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
2843
- type: "blurred";
2576
+ }, import("xstate").NonReducibleUnknown, MutationEvent | PatchesEvent | {
2577
+ type: 'blurred';
2844
2578
  event: import("react").FocusEvent<HTMLDivElement, Element>;
2845
2579
  } | {
2846
- type: "done loading";
2847
- } | {
2848
- type: "editable";
2849
- } | {
2850
- type: "error";
2851
- name: string;
2852
- description: string;
2853
- data: unknown;
2580
+ type: 'editable';
2854
2581
  } | {
2855
- type: "focused";
2582
+ type: 'focused';
2856
2583
  event: import("react").FocusEvent<HTMLDivElement, Element>;
2857
2584
  } | {
2858
- type: "invalid value";
2585
+ type: 'invalid value';
2859
2586
  resolution: InvalidValueResolution | null;
2860
2587
  value: Array<PortableTextBlock> | undefined;
2861
2588
  } | {
2862
- type: "loading";
2863
- } | {
2864
- type: "operation";
2589
+ type: 'operation';
2865
2590
  operation: Operation;
2866
2591
  } | {
2867
- type: "read only";
2592
+ type: 'read only';
2868
2593
  } | {
2869
- type: "ready";
2594
+ type: 'ready';
2870
2595
  } | {
2871
- type: "selection";
2596
+ type: 'selection';
2872
2597
  selection: EditorSelection;
2873
2598
  } | {
2874
- type: "value changed";
2599
+ type: 'value changed';
2875
2600
  value: Array<PortableTextBlock> | undefined;
2876
- }, import("xstate").MetaObject, {
2601
+ } | InternalPatchEvent, import("xstate").MetaObject, {
2877
2602
  id: "editor";
2878
2603
  states: {
2879
2604
  readonly 'edit mode': {
@@ -2979,7 +2704,7 @@ type ExternalBehaviorEvent = {
2979
2704
  /**************************************
2980
2705
  * Synthetic events
2981
2706
  **************************************/
2982
- declare const syntheticBehaviorEventTypes: readonly ["annotation.add", "annotation.remove", "block.set", "block.unset", "child.set", "child.unset", "decorator.add", "decorator.remove", "delete", "history.redo", "history.undo", "insert", "insert.block", "insert.child", "insert.text", "move.backward", "move.forward", "remove.text", "select", "set", "unset"];
2707
+ declare const syntheticBehaviorEventTypes: readonly ['annotation.add', 'annotation.remove', 'block.set', 'block.unset', 'child.set', 'child.unset', 'decorator.add', 'decorator.remove', 'delete', 'history.redo', 'history.undo', 'insert', 'insert.block', 'insert.child', 'insert.text', 'move.backward', 'move.forward', 'remove.text', 'select', 'set', 'unset'];
2983
2708
  type SyntheticBehaviorEventType = (typeof syntheticBehaviorEventTypes)[number] | (typeof abstractBehaviorEventTypes)[number];
2984
2709
  type SyntheticBehaviorEventNamespace = ExtractNamespace<SyntheticBehaviorEventType>;
2985
2710
  /**
@@ -3199,7 +2924,7 @@ type InsertPlacement = 'auto' | 'after' | 'before';
3199
2924
  /**************************************
3200
2925
  * Abstract events
3201
2926
  **************************************/
3202
- declare const abstractBehaviorEventTypes: readonly ["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", "move.block down", "move.block up", "select.block", "select.previous block", "select.next block", "serialize", "serialize.data", "serialization.success", "serialization.failure", "split", "style.add", "style.remove", "style.toggle"];
2927
+ declare const abstractBehaviorEventTypes: readonly ['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', 'move.block down', 'move.block up', 'select.block', 'select.previous block', 'select.next block', 'serialize', 'serialize.data', 'serialization.success', 'serialization.failure', 'split', 'style.add', 'style.remove', 'style.toggle'];
3203
2928
  type AbstractBehaviorEvent = {
3204
2929
  type: StrictExtract<SyntheticBehaviorEventType, 'annotation.set'>;
3205
2930
  at: AnnotationPath;
@@ -3339,7 +3064,7 @@ type AbstractBehaviorEvent = {
3339
3064
  /**************************************
3340
3065
  * Native events
3341
3066
  **************************************/
3342
- declare const nativeBehaviorEventTypes: readonly ["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"];
3067
+ declare const nativeBehaviorEventTypes: readonly ['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'];
3343
3068
  type NativeBehaviorEventType = (typeof nativeBehaviorEventTypes)[number];
3344
3069
  type NativeBehaviorEventNamespace = ExtractNamespace<NativeBehaviorEventType>;
3345
3070
  /**
@@ -3669,5 +3394,5 @@ type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (payload: {
3669
3394
  event: TBehaviorEvent;
3670
3395
  dom: EditorDom;
3671
3396
  }, guardResponse: TGuardResponse) => Array<BehaviorAction>;
3672
- export { BehaviorGuard as $, DecoratorRender as $t, PortableTextSpan$1 as A, PortableTextEditableProps as At, usePortableTextEditor as B, RegisteredInlineObject as Bt, ListDefinition as C, PathSegment as Cn, RenderDecoratorFunction as Ct, PortableTextBlock$1 as D, RenderStyleFunction as Dt, Patch$1 as E, RenderPlaceholderFunction as Et, defineSchema as F, Node$1 as Ft, Editor as G, AnnotationRenderProps as Gt, useEditorSelector as H, RegisteredSpan as Ht, BlockOffset as I, EditorSchema as It, EditorEmittedEvent as J, BlockObjectRenderProps as Jt, EditorConfig as K, BlockObject as Kt, useEditor as L, Containers as Lt, SchemaDefinition$1 as M, PortableTextEditor as Mt, StyleDefinition as N, resolveContainerAt as Nt, PortableTextChild$1 as O, ScrollSelectionIntoViewFunction as Ot, StyleSchemaType$1 as P, TraversalSnapshot as Pt, defineBehavior as Q, Decorator as Qt, defaultKeyGenerator as R, RegisteredBlockObject as Rt, InlineObjectSchemaType$1 as S, Path as Sn, RenderChildFunction as St, OfDefinition$1 as T, RenderListItemFunction as Tt, EditorProvider as U, Annotation as Ut, EditorSelector as V, RegisteredPositional as Vt, EditorProviderProps as W, AnnotationRender as Wt, Operation as X, ContainerRender as Xt, MutationEvent as Y, Container as Yt, Behavior as Z, ContainerRenderProps as Zt, BlockObjectSchemaType$1 as _, defineTextBlock as _n, PasteData as _t, forward as a, Span as an, BlockDecoratorRenderProps as at, FieldDefinition$1 as b, ChildPath as bn, RenderAnnotationFunction as bt, CustomBehaviorEvent as c, TextBlock as cn, BlockStyleRenderProps as ct, SyntheticBehaviorEvent as d, defineAnnotation as dn, EditorSelectionPoint as dt, DecoratorRenderProps as en, EditorContext as et, PatchesEvent as f, defineBlockObject as fn, InvalidValueResolution as ft, BlockObjectDefinition as g, defineSpan as gn, OnPasteResultOrPromise as gt, BaseDefinition as h, defineInlineObject as hn, OnPasteResult as ht, execute as i, RegistrableNode as in, BlockChildRenderProps as it, PortableTextTextBlock$1 as j, HotkeyOptions as jt, PortableTextObject$1 as k, PortableTextEditable as kt, InsertPlacement as l, TextBlockRender as ln, EditableAPIDeleteOptions as lt, AnnotationSchemaType$1 as m, defineDecorator as mn, OnPasteFn as mt, BehaviorActionSet as n, InlineObjectRender as nn, AddedAnnotationPaths as nt, raise$1 as o, SpanRender as on, BlockListItemRenderProps as ot, AnnotationDefinition as p, defineContainer as pn, OnCopyFn as pt, EditorEvent as q, BlockObjectRender as qt, effect as r, InlineObjectRenderProps as rn, BlockAnnotationRenderProps as rt, BehaviorEvent as s, SpanRenderProps as sn, BlockRenderProps as st, BehaviorAction as t, InlineObject as tn, EditorSnapshot as tt, NativeBehaviorEvent as u, TextBlockRenderProps as un, EditorSelection as ut, DecoratorDefinition as v, AnnotationPath as vn, RangeDecoration as vt, ListSchemaType$1 as w, RenderEditableFunction as wt, InlineObjectDefinition as x, KeyedSegment as xn, RenderBlockFunction as xt, DecoratorSchemaType$1 as y, BlockPath as yn, RangeDecorationOnMovedDetails as yt, usePortableTextEditorSelection as z, RegisteredContainer as zt };
3673
- //# sourceMappingURL=behavior.types.action-DH6ujvaH.d.ts.map
3397
+ export { BehaviorGuard as $, defineBlockObject as $t, PortableTextSpan$1 as A, Annotation as At, usePortableTextEditor as B, DecoratorRender as Bt, ListDefinition as C, EditorSchema as Ct, PortableTextBlock$1 as D, RegisteredInlineObject as Dt, Patch$1 as E, RegisteredContainer as Et, defineSchema as F, BlockObjectRenderProps as Ft, Editor as G, RegistrableNode as Gt, useEditorSelector as H, InlineObject as Ht, BlockOffset as I, Container as It, EditorEmittedEvent as J, SpanRenderProps as Jt, EditorConfig as K, Span as Kt, useEditor as L, ContainerRender as Lt, SchemaDefinition$1 as M, AnnotationRenderProps as Mt, StyleDefinition as N, BlockObject as Nt, PortableTextChild$1 as O, RegisteredPositional as Ot, StyleSchemaType as P, BlockObjectRender as Pt, defineBehavior as Q, defineAnnotation as Qt, defaultKeyGenerator as R, ContainerRenderProps as Rt, InlineObjectSchemaType as S, Node$1 as St, OfDefinition$1 as T, RegisteredBlockObject as Tt, EditorProvider as U, InlineObjectRender as Ut, EditorSelector as V, DecoratorRenderProps as Vt, EditorProviderProps as W, InlineObjectRenderProps as Wt, Operation as X, TextBlockRender as Xt, MutationEvent as Y, TextBlock as Yt, Behavior as Z, TextBlockRenderProps as Zt, BlockObjectSchemaType as _, PortableTextEditable as _t, forward as a, AnnotationPath as an, EditorSelectionPoint as at, FieldDefinition$1 as b, PortableTextEditor as bt, CustomBehaviorEvent as c, KeyedSegment as cn, OnPasteFn as ct, SyntheticBehaviorEvent as d, PasteData as dt, defineContainer as en, EditorContext as et, PatchesEvent as f, RangeDecoration as ft, BlockObjectDefinition as g, ScrollSelectionIntoViewFunction as gt, BaseDefinition as h, RenderPlaceholderFunction as ht, execute as i, defineTextBlock as in, EditorSelection as it, PortableTextTextBlock$1 as j, AnnotationRender as jt, PortableTextObject$1 as k, RegisteredSpan as kt, InsertPlacement as l, Path as ln, OnPasteResult as lt, AnnotationSchemaType as m, RenderEditableFunction as mt, BehaviorActionSet as n, defineInlineObject as nn, AddedAnnotationPaths as nt, raise$1 as o, BlockPath as on, InvalidValueResolution as ot, AnnotationDefinition as p, RangeDecorationOnMovedDetails as pt, EditorEvent as q, SpanRender as qt, effect as r, defineSpan as rn, EditableAPIDeleteOptions as rt, BehaviorEvent as s, ChildPath as sn, OnCopyFn as st, BehaviorAction as t, defineDecorator as tn, EditorSnapshot as tt, NativeBehaviorEvent as u, PathSegment as un, OnPasteResultOrPromise as ut, DecoratorDefinition as v, PortableTextEditableProps as vt, ListSchemaType as w, Containers as wt, InlineObjectDefinition as x, TraversalSnapshot as xt, DecoratorSchemaType as y, HotkeyOptions as yt, usePortableTextEditorSelection as z, Decorator as zt };
3398
+ //# sourceMappingURL=behavior.types.action-CcO4rAdL.d.ts.map