@portabletext/editor 7.10.19 → 7.11.0

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.
Files changed (40) hide show
  1. package/README.md +3 -0
  2. package/lib/{behavior.types.action-CYtiRDck.d.ts → behavior.types.action-DXkAaEGS.d.ts} +167 -95
  3. package/lib/behavior.types.action-DXkAaEGS.d.ts.map +1 -0
  4. package/lib/{behavior.types.behavior-B_77VtQR.js → behavior.types.behavior-BxSLb73I.js} +5 -5
  5. package/lib/behavior.types.behavior-BxSLb73I.js.map +1 -0
  6. package/lib/behaviors/index.d.ts +1 -1
  7. package/lib/behaviors/index.js +1 -1
  8. package/lib/{get-container-BeXYKpoi.js → get-container-D1nM_ww9.js} +14 -14
  9. package/lib/get-container-D1nM_ww9.js.map +1 -0
  10. package/lib/{get-parent-51Kzgaf9.js → get-parent-Ci5241qs.js} +3 -3
  11. package/lib/get-parent-Ci5241qs.js.map +1 -0
  12. package/lib/{get-path-sub-schema--2I4NJbG.js → get-path-sub-schema-CZd9VcVM.js} +10 -10
  13. package/lib/get-path-sub-schema-CZd9VcVM.js.map +1 -0
  14. package/lib/index.d.ts +2 -2
  15. package/lib/index.js +13 -12
  16. package/lib/index.js.map +1 -1
  17. package/lib/plugins/index.d.ts +4 -4
  18. package/lib/plugins/index.js +3 -3
  19. package/lib/plugins/index.js.map +1 -1
  20. package/lib/{selector.is-at-the-start-of-block-gJIMWRpU.js → selector.is-at-the-start-of-block-D0boZbDu.js} +4 -4
  21. package/lib/selector.is-at-the-start-of-block-D0boZbDu.js.map +1 -0
  22. package/lib/selectors/index.d.ts +6 -6
  23. package/lib/selectors/index.js +6 -6
  24. package/lib/selectors/index.js.map +1 -1
  25. package/lib/traversal/index.d.ts +31 -31
  26. package/lib/traversal/index.js +4 -4
  27. package/lib/traversal/index.js.map +1 -1
  28. package/lib/{util.is-equal-selections-BF4WJtz5.js → util.is-equal-selections-N1hxVUbE.js} +2 -2
  29. package/lib/{util.is-equal-selections-BF4WJtz5.js.map → util.is-equal-selections-N1hxVUbE.js.map} +1 -1
  30. package/lib/{util.slice-blocks-DQnr9X2s.js → util.slice-blocks-B2fZcNok.js} +2 -2
  31. package/lib/{util.slice-blocks-DQnr9X2s.js.map → util.slice-blocks-B2fZcNok.js.map} +1 -1
  32. package/lib/utils/index.d.ts +1 -1
  33. package/lib/utils/index.js +3 -3
  34. package/package.json +3 -3
  35. package/lib/behavior.types.action-CYtiRDck.d.ts.map +0 -1
  36. package/lib/behavior.types.behavior-B_77VtQR.js.map +0 -1
  37. package/lib/get-container-BeXYKpoi.js.map +0 -1
  38. package/lib/get-parent-51Kzgaf9.js.map +0 -1
  39. package/lib/get-path-sub-schema--2I4NJbG.js.map +0 -1
  40. package/lib/selector.is-at-the-start-of-block-gJIMWRpU.js.map +0 -1
@@ -1,5 +1,5 @@
1
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, 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";
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";
3
3
  import { ActorRefFrom } from "xstate";
4
4
  import { Patch, Patch as Patch$1 } from "@portabletext/patches";
5
5
  type MIMEType = `${string}/${string}`;
@@ -94,15 +94,7 @@ type AnnotationPath = Path;
94
94
  */
95
95
  type ChildPath = Path;
96
96
  /**
97
- * @alpha
98
- *
99
- * Narrow the container node type by the registered `_type`. Containers
100
- * always render portable text objects: `'span'` is always a leaf and
101
- * `'block'` is always a text block; both are excluded.
102
- */
103
- type ContainerNodeForType<TType extends string> = TType extends 'span' | 'block' ? never : PortableTextObject;
104
- /**
105
- * @alpha
97
+ * @public
106
98
  *
107
99
  * A container's render function receives a node and renders an element
108
100
  * that wraps its editable children. The render is positional: it fires for
@@ -136,11 +128,11 @@ type ContainerRenderProps = {
136
128
  renderDefault: (props: ContainerRenderProps) => ReactElement;
137
129
  };
138
130
  /**
139
- * @alpha
131
+ * @public
140
132
  */
141
133
  type ContainerRender = (props: ContainerRenderProps) => ReactElement;
142
134
  /**
143
- * @alpha
135
+ * @public
144
136
  *
145
137
  * A span's render function. Receives a portable text span node and
146
138
  * wraps it. `children` carries the styled text already decorated by
@@ -161,11 +153,11 @@ type SpanRenderProps = {
161
153
  renderDefault: (props: SpanRenderProps) => ReactElement;
162
154
  };
163
155
  /**
164
- * @alpha
156
+ * @public
165
157
  */
166
158
  type SpanRender = (props: SpanRenderProps) => ReactElement;
167
159
  /**
168
- * @alpha
160
+ * @public
169
161
  *
170
162
  * A block object's render function. Receives a non-editable block-level
171
163
  * portable text object. `children` carries an engine-emitted void
@@ -188,11 +180,11 @@ type BlockObjectRenderProps = {
188
180
  renderDefault: (props: BlockObjectRenderProps) => ReactElement;
189
181
  };
190
182
  /**
191
- * @alpha
183
+ * @public
192
184
  */
193
185
  type BlockObjectRender = (props: BlockObjectRenderProps) => ReactElement;
194
186
  /**
195
- * @alpha
187
+ * @public
196
188
  *
197
189
  * An inline object's render function. Receives a non-editable inline
198
190
  * portable text object. `children` carries an engine-emitted void
@@ -215,11 +207,11 @@ type InlineObjectRenderProps = {
215
207
  renderDefault: (props: InlineObjectRenderProps) => ReactElement;
216
208
  };
217
209
  /**
218
- * @alpha
210
+ * @public
219
211
  */
220
212
  type InlineObjectRender = (props: InlineObjectRenderProps) => ReactElement;
221
213
  /**
222
- * @alpha
214
+ * @public
223
215
  *
224
216
  * A container registration. Identifies a block object `_type` whose value
225
217
  * holds editable children in `arrayField`. The optional `of` array carries
@@ -250,7 +242,7 @@ type Container = {
250
242
  of?: ReadonlyArray<Container | TextBlock | BlockObject>;
251
243
  };
252
244
  /**
253
- * @alpha
245
+ * @public
254
246
  *
255
247
  * A text block registration. The text block `_type` is `'block'` at the
256
248
  * top level. Positional overrides nested in a container's `of` array can
@@ -286,7 +278,7 @@ type TextBlock = {
286
278
  of?: ReadonlyArray<Span | InlineObject>;
287
279
  };
288
280
  /**
289
- * @alpha
281
+ * @public
290
282
  *
291
283
  * Text block render function. `children` carries the rendered spans -
292
284
  * `renderDecorator`, `renderAnnotation`, `renderPlaceholder`, and range
@@ -309,11 +301,11 @@ type TextBlockRenderProps = {
309
301
  renderDefault: (props: TextBlockRenderProps) => ReactElement;
310
302
  };
311
303
  /**
312
- * @alpha
304
+ * @public
313
305
  */
314
306
  type TextBlockRender = (props: TextBlockRenderProps) => ReactElement;
315
307
  /**
316
- * @alpha
308
+ * @public
317
309
  *
318
310
  * A span registration. The span `_type` is `'span'` at the top level.
319
311
  * Positional overrides nested in a container's `of` array can register
@@ -332,7 +324,7 @@ type Span = {
332
324
  render?: SpanRender;
333
325
  };
334
326
  /**
335
- * @alpha
327
+ * @public
336
328
  *
337
329
  * A non-editable block-level object registration. Identifies a `_type`
338
330
  * whose value renders as a block-level void node (image, embed, etc.).
@@ -349,7 +341,7 @@ type BlockObject = {
349
341
  render?: BlockObjectRender;
350
342
  };
351
343
  /**
352
- * @alpha
344
+ * @public
353
345
  *
354
346
  * A non-editable inline object registration. Identifies a `_type` whose
355
347
  * value renders as an inline void node (mention, inline image, etc.).
@@ -366,14 +358,14 @@ type InlineObject = {
366
358
  render?: InlineObjectRender;
367
359
  };
368
360
  /**
369
- * @alpha
361
+ * @public
370
362
  *
371
363
  * The discriminated union of every registration accepted by
372
364
  * `editor.registerNode` and the `<NodePlugin>` component.
373
365
  */
374
366
  type RegistrableNode = Container | TextBlock | Span | BlockObject | InlineObject;
375
367
  /**
376
- * @alpha
368
+ * @public
377
369
  *
378
370
  * Define a container renderer. The returned registration is mounted via
379
371
  * the `<NodePlugin>` component at the top level, or nested inside
@@ -411,7 +403,7 @@ declare function defineContainer<const TType extends string>(config: {
411
403
  attributes: Record<string, unknown>;
412
404
  children: ReactElement;
413
405
  focused: boolean;
414
- node: ContainerNodeForType<TType>;
406
+ node: TType extends 'span' | 'block' ? never : PortableTextObject;
415
407
  path: Path;
416
408
  readOnly: boolean;
417
409
  selected: boolean;
@@ -420,7 +412,7 @@ declare function defineContainer<const TType extends string>(config: {
420
412
  of?: ReadonlyArray<Container | TextBlock | BlockObject>;
421
413
  }): Container;
422
414
  /**
423
- * @alpha
415
+ * @public
424
416
  *
425
417
  * Define a span renderer. The returned registration is mounted via the
426
418
  * `<NodePlugin>` component at the top level, or nested inside a
@@ -446,7 +438,7 @@ declare function defineSpan<const TType extends string>(config: {
446
438
  render?: SpanRender;
447
439
  }): Span;
448
440
  /**
449
- * @alpha
441
+ * @public
450
442
  *
451
443
  * Define a non-editable block-level object renderer for a `_type`
452
444
  * declared in the schema's `blockObjects` array.
@@ -474,7 +466,7 @@ declare function defineBlockObject<const TType extends string>(config: {
474
466
  render?: BlockObjectRender;
475
467
  }): BlockObject;
476
468
  /**
477
- * @alpha
469
+ * @public
478
470
  *
479
471
  * Define a non-editable inline object renderer for a `_type` declared
480
472
  * in the schema's `inlineObjects` array.
@@ -502,7 +494,7 @@ declare function defineInlineObject<const TType extends string>(config: {
502
494
  render?: InlineObjectRender;
503
495
  }): InlineObject;
504
496
  /**
505
- * @alpha
497
+ * @public
506
498
  *
507
499
  * Define a text block renderer. The returned registration is mounted
508
500
  * via the `<NodePlugin>` component, or nested inside a container's
@@ -575,10 +567,6 @@ type TextBlockConfig = {
575
567
  textBlock: TextBlock;
576
568
  of?: ReadonlyArray<SpanConfig | InlineObjectConfig>;
577
569
  };
578
- type ChildArrayField = FieldDefinition & {
579
- type: 'array';
580
- of: ReadonlyArray<OfDefinition>;
581
- };
582
570
  /**
583
571
  * Public view of a registered editable container, surfaced on
584
572
  * {@link EditorContext.containers}.
@@ -597,8 +585,8 @@ type ChildArrayField = FieldDefinition & {
597
585
  * scoped to this parent.
598
586
  *
599
587
  * The full container registration (including the render callback)
600
- * lives on the editor's internal {@link ResolvedContainers} map and
601
- * is not exposed on the public context.
588
+ * lives on an engine-internal map and is not exposed on the public
589
+ * context.
602
590
  *
603
591
  * Two top-level entries with the same `_type` cannot coexist - the
604
592
  * register handler warns on duplicates. But the SAME `_type`
@@ -606,20 +594,24 @@ type ChildArrayField = FieldDefinition & {
606
594
  * a feature; `resolveContainerAt` walks the positional tree using
607
595
  * the path to return the entry that applies at a given position.
608
596
  *
609
- * @alpha
597
+ * @public
610
598
  */
611
599
  type RegisteredContainer = {
612
600
  kind: 'container';
613
601
  type: string;
614
- field: ChildArrayField;
602
+ field: FieldDefinition & {
603
+ type: 'array';
604
+ of: ReadonlyArray<OfDefinition>;
605
+ };
615
606
  of?: ReadonlyArray<RegisteredContainer | RegisteredPositional>;
616
607
  };
608
+ type ChildArrayField = RegisteredContainer['field'];
617
609
  /**
618
610
  * Public view of a registered span, surfaced inside a containing
619
611
  * {@link RegisteredContainer}'s `of` array as a positional
620
612
  * registration. The render function is engine-internal.
621
613
  *
622
- * @alpha
614
+ * @public
623
615
  */
624
616
  type RegisteredSpan = {
625
617
  kind: 'span';
@@ -630,7 +622,7 @@ type RegisteredSpan = {
630
622
  * containing {@link RegisteredContainer}'s `of` array as a positional
631
623
  * registration. The render function is engine-internal.
632
624
  *
633
- * @alpha
625
+ * @public
634
626
  */
635
627
  type RegisteredBlockObject = {
636
628
  kind: 'blockObject';
@@ -641,7 +633,7 @@ type RegisteredBlockObject = {
641
633
  * containing {@link RegisteredContainer}'s `of` array as a positional
642
634
  * registration. The render function is engine-internal.
643
635
  *
644
- * @alpha
636
+ * @public
645
637
  */
646
638
  type RegisteredInlineObject = {
647
639
  kind: 'inlineObject';
@@ -650,10 +642,9 @@ type RegisteredInlineObject = {
650
642
  /**
651
643
  * Union of non-container positional registrations that may appear in
652
644
  * a {@link RegisteredContainer}'s `of` array. Text-block registrations
653
- * are NOT included here; they surface on `EditorContext.textBlocks`,
654
- * not on the containers tree.
645
+ * are NOT included here and do not appear on the containers tree.
655
646
  *
656
- * @alpha
647
+ * @public
657
648
  */
658
649
  type RegisteredPositional = RegisteredSpan | RegisteredBlockObject | RegisteredInlineObject;
659
650
  /**
@@ -673,7 +664,7 @@ type RegisteredPositional = RegisteredSpan | RegisteredBlockObject | RegisteredI
673
664
  * does not find a positional override, the resolver falls back to the
674
665
  * top-level entry for the type if one is registered.
675
666
  *
676
- * @alpha
667
+ * @public
677
668
  */
678
669
  type Containers = ReadonlyMap<string, RegisteredContainer>;
679
670
  /**
@@ -1138,11 +1129,34 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
1138
1129
  onCopy?: OnCopyFn;
1139
1130
  rangeDecorations?: RangeDecoration[];
1140
1131
  renderAnnotation?: RenderAnnotationFunction;
1132
+ /**
1133
+ * @deprecated Register your block objects and text blocks with
1134
+ * `defineBlockObject` / `defineTextBlock` mounted through `NodePlugin`
1135
+ * instead. See the migration guide:
1136
+ * https://www.portabletext.org/editor/guides/migrate-render-props/
1137
+ */
1141
1138
  renderBlock?: RenderBlockFunction;
1139
+ /**
1140
+ * @deprecated Register your inline objects and spans with
1141
+ * `defineInlineObject` / `defineSpan` mounted through `NodePlugin`
1142
+ * instead. See the migration guide:
1143
+ * https://www.portabletext.org/editor/guides/migrate-render-props/
1144
+ */
1142
1145
  renderChild?: RenderChildFunction;
1143
1146
  renderDecorator?: RenderDecoratorFunction;
1147
+ /**
1148
+ * @deprecated Render list items with `defineTextBlock` mounted through
1149
+ * `NodePlugin`, with list numbering from
1150
+ * `@portabletext/plugin-list-index`. See the migration guide:
1151
+ * https://www.portabletext.org/editor/guides/migrate-render-props/
1152
+ */
1144
1153
  renderListItem?: RenderListItemFunction;
1145
1154
  renderPlaceholder?: RenderPlaceholderFunction;
1155
+ /**
1156
+ * @deprecated Render text-block styles with `defineTextBlock` mounted
1157
+ * through `NodePlugin` instead. See the migration guide:
1158
+ * https://www.portabletext.org/editor/guides/migrate-render-props/
1159
+ */
1146
1160
  renderStyle?: RenderStyleFunction;
1147
1161
  scrollSelectionIntoView?: ScrollSelectionIntoViewFunction;
1148
1162
  selection?: EditorSelection;
@@ -1169,7 +1183,12 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
1169
1183
  * @group Components
1170
1184
  */
1171
1185
  declare const PortableTextEditable: import("react").ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & import("react").RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
1172
- /** @beta */
1186
+ /**
1187
+ * @beta
1188
+ * @deprecated `EditableAPIDeleteOptions` is deprecated together with the
1189
+ * `PortableTextEditor.delete` static. Send a `delete` behavior event (with
1190
+ * an optional `unit`) or a `delete.block` event via `editor.send` instead.
1191
+ */
1173
1192
  interface EditableAPIDeleteOptions {
1174
1193
  mode?: 'blocks' | 'children' | 'selected';
1175
1194
  }
@@ -1190,7 +1209,7 @@ type AddedAnnotationPaths = {
1190
1209
  */
1191
1210
  spanPath: Path;
1192
1211
  };
1193
- /** @beta */
1212
+ /** @internal */
1194
1213
  interface EditableAPI {
1195
1214
  activeAnnotations: () => PortableTextObject[];
1196
1215
  isAnnotationActive: (annotationType: PortableTextObject['_type']) => boolean;
@@ -1251,7 +1270,7 @@ type EditorSelection = {
1251
1270
  } | null;
1252
1271
  /**
1253
1272
  * The editor has invalid data in the value that can be resolved by the user
1254
- * @beta */
1273
+ * @public */
1255
1274
  type InvalidValueResolution = {
1256
1275
  autoResolve?: boolean;
1257
1276
  patches: Patch[];
@@ -1296,7 +1315,14 @@ interface PasteData {
1296
1315
  type OnPasteFn = (data: PasteData) => OnPasteResultOrPromise;
1297
1316
  /** @beta */
1298
1317
  type OnCopyFn = (event: ClipboardEvent$1<HTMLDivElement | HTMLSpanElement>) => undefined | unknown;
1299
- /** @beta */
1318
+ /**
1319
+ * @beta
1320
+ * @deprecated `BlockRenderProps` is deprecated together with the
1321
+ * `renderBlock` render prop it serves. Type against
1322
+ * `BlockObjectRenderProps` / `TextBlockRenderProps` from the node
1323
+ * registration API instead. See the migration guide:
1324
+ * https://www.portabletext.org/editor/guides/migrate-render-props/
1325
+ */
1300
1326
  interface BlockRenderProps {
1301
1327
  children: ReactElement<any>;
1302
1328
  editorElementRef: RefObject<HTMLElement | null>;
@@ -1309,7 +1335,14 @@ interface BlockRenderProps {
1309
1335
  schemaType: BlockObjectSchemaType;
1310
1336
  value: PortableTextBlock;
1311
1337
  }
1312
- /** @beta */
1338
+ /**
1339
+ * @beta
1340
+ * @deprecated `BlockChildRenderProps` is deprecated together with the
1341
+ * `renderChild` render prop it serves. Type against
1342
+ * `InlineObjectRenderProps` / `SpanRenderProps` from the node
1343
+ * registration API instead. See the migration guide:
1344
+ * https://www.portabletext.org/editor/guides/migrate-render-props/
1345
+ */
1313
1346
  interface BlockChildRenderProps {
1314
1347
  annotations: PortableTextObject[];
1315
1348
  children: ReactElement<any>;
@@ -1341,7 +1374,14 @@ interface BlockDecoratorRenderProps {
1341
1374
  selected: boolean;
1342
1375
  value: string;
1343
1376
  }
1344
- /** @beta */
1377
+ /**
1378
+ * @beta
1379
+ * @deprecated `BlockListItemRenderProps` is deprecated together with the
1380
+ * `renderListItem` render prop it serves. Render list items with
1381
+ * `defineTextBlock` mounted through `NodePlugin` instead. See the
1382
+ * migration guide:
1383
+ * https://www.portabletext.org/editor/guides/migrate-render-props/
1384
+ */
1345
1385
  interface BlockListItemRenderProps {
1346
1386
  block: PortableTextTextBlock;
1347
1387
  children: ReactElement<any>;
@@ -1353,19 +1393,45 @@ interface BlockListItemRenderProps {
1353
1393
  selected: boolean;
1354
1394
  value: string;
1355
1395
  }
1356
- /** @beta */
1396
+ /**
1397
+ * @beta
1398
+ * @deprecated The `renderBlock` render prop is deprecated. Register your
1399
+ * block objects and text blocks with `defineBlockObject` /
1400
+ * `defineTextBlock` mounted through `NodePlugin` instead. See the
1401
+ * migration guide:
1402
+ * https://www.portabletext.org/editor/guides/migrate-render-props/
1403
+ */
1357
1404
  type RenderBlockFunction = (props: BlockRenderProps) => JSX.Element;
1358
- /** @beta */
1405
+ /**
1406
+ * @beta
1407
+ * @deprecated The `renderChild` render prop is deprecated. Register your
1408
+ * inline objects and spans with `defineInlineObject` / `defineSpan`
1409
+ * mounted through `NodePlugin` instead. See the migration guide:
1410
+ * https://www.portabletext.org/editor/guides/migrate-render-props/
1411
+ */
1359
1412
  type RenderChildFunction = (props: BlockChildRenderProps) => JSX.Element;
1360
- /** @beta */
1413
+ /** @public */
1361
1414
  type RenderEditableFunction = (props: PortableTextEditableProps) => JSX.Element;
1362
1415
  /** @beta */
1363
1416
  type RenderAnnotationFunction = (props: BlockAnnotationRenderProps) => JSX.Element;
1364
- /** @beta */
1417
+ /** @public */
1365
1418
  type RenderPlaceholderFunction = () => React.ReactNode;
1366
- /** @beta */
1419
+ /**
1420
+ * @beta
1421
+ * @deprecated The `renderStyle` render prop is deprecated. Render
1422
+ * text-block styles with `defineTextBlock` mounted through `NodePlugin`
1423
+ * instead. See the migration guide:
1424
+ * https://www.portabletext.org/editor/guides/migrate-render-props/
1425
+ */
1367
1426
  type RenderStyleFunction = (props: BlockStyleRenderProps) => JSX.Element;
1368
- /** @beta */
1427
+ /**
1428
+ * @beta
1429
+ * @deprecated `BlockStyleRenderProps` is deprecated together with the
1430
+ * `renderStyle` render prop it serves. Render text-block styles with
1431
+ * `defineTextBlock` mounted through `NodePlugin` instead. See the
1432
+ * migration guide:
1433
+ * https://www.portabletext.org/editor/guides/migrate-render-props/
1434
+ */
1369
1435
  interface BlockStyleRenderProps {
1370
1436
  block: PortableTextTextBlock;
1371
1437
  children: ReactElement<any>;
@@ -1376,32 +1442,39 @@ interface BlockStyleRenderProps {
1376
1442
  schemaType: StyleSchemaType;
1377
1443
  value: string;
1378
1444
  }
1379
- /** @beta */
1445
+ /**
1446
+ * @beta
1447
+ * @deprecated The `renderListItem` render prop is deprecated. Render list
1448
+ * items with `defineTextBlock` mounted through `NodePlugin`, with list
1449
+ * numbering from `@portabletext/plugin-list-index`. See the migration
1450
+ * guide:
1451
+ * https://www.portabletext.org/editor/guides/migrate-render-props/
1452
+ */
1380
1453
  type RenderListItemFunction = (props: BlockListItemRenderProps) => JSX.Element;
1381
1454
  /** @beta */
1382
1455
  type RenderDecoratorFunction = (props: BlockDecoratorRenderProps) => JSX.Element;
1383
- /** @beta */
1456
+ /** @public */
1384
1457
  type ScrollSelectionIntoViewFunction = (editor: PortableTextEditor, domRange: globalThis.Range) => void;
1385
1458
  /**
1386
- * Parameters for the callback that will be called for a RangeDecoration's onMoved.
1387
- * @alpha */
1459
+ * Details passed to a `RangeDecoration`'s `onMoved` callback.
1460
+ * @public */
1388
1461
  interface RangeDecorationOnMovedDetails {
1389
1462
  rangeDecoration: RangeDecoration;
1390
1463
  newSelection: EditorSelection;
1391
1464
  origin: 'remote' | 'local';
1392
1465
  }
1393
1466
  /**
1394
- * A range decoration is a UI affordance that wraps a given selection range in the editor
1395
- * with a custom component. This can be used to highlight search results,
1396
- * mark validation errors on specific words, draw user presence and similar.
1397
- * @alpha */
1467
+ * A UI affordance that wraps a selection range in the editor with a custom
1468
+ * component, for example to highlight search results, mark validation
1469
+ * errors on specific words, or draw user presence.
1470
+ * @public */
1398
1471
  interface RangeDecoration {
1399
1472
  /**
1400
- * A component for rendering the range decoration.
1401
- * The component will receive the children (text) of the range decoration as its children.
1473
+ * The component that renders the range decoration. It receives the
1474
+ * decorated text as its children.
1402
1475
  *
1403
1476
  * @example
1404
- * ```ts
1477
+ * ```tsx
1405
1478
  * (rangeComponentProps: PropsWithChildren) => (
1406
1479
  * <SearchResultHighlight>
1407
1480
  * {rangeComponentProps.children}
@@ -1411,15 +1484,17 @@ interface RangeDecoration {
1411
1484
  */
1412
1485
  component: (props: PropsWithChildren) => ReactElement<any>;
1413
1486
  /**
1414
- * The editor content selection range
1487
+ * The editor content selection range to decorate.
1415
1488
  */
1416
1489
  selection: EditorSelection;
1417
1490
  /**
1418
- * A optional callback that will be called when the range decoration potentially moves according to user edits.
1491
+ * Called when edits move the decorated range. The details carry the new
1492
+ * selection (`null` when the range is lost) and whether the edit was
1493
+ * `local` or `remote`.
1419
1494
  */
1420
1495
  onMoved?: (details: RangeDecorationOnMovedDetails) => void;
1421
1496
  /**
1422
- * A custom payload that can be set on the range decoration
1497
+ * A custom payload that can be set on the range decoration.
1423
1498
  */
1424
1499
  payload?: Record<string, unknown>;
1425
1500
  }
@@ -1959,7 +2034,7 @@ type EditorContext = {
1959
2034
  * `resolveContainerAt(containers, value, path)` for position-aware
1960
2035
  * resolution that handles both top-level and positional entries.
1961
2036
  *
1962
- * @alpha
2037
+ * @public
1963
2038
  */
1964
2039
  containers: Containers;
1965
2040
  };
@@ -1976,7 +2051,7 @@ type EditorSnapshot = {
1976
2051
  decoratorState: Record<string, boolean | undefined>;
1977
2052
  };
1978
2053
  /**
1979
- * @beta
2054
+ * @public
1980
2055
  */
1981
2056
  type BehaviorGuard<TBehaviorEvent, TGuardResponse> = (payload: {
1982
2057
  snapshot: EditorSnapshot;
@@ -1984,7 +2059,7 @@ type BehaviorGuard<TBehaviorEvent, TGuardResponse> = (payload: {
1984
2059
  dom: EditorDom;
1985
2060
  }) => TGuardResponse | false;
1986
2061
  /**
1987
- * @beta
2062
+ * @public
1988
2063
  */
1989
2064
  type Behavior<TBehaviorEventType extends '*' | `${BehaviorEventTypeNamespace}.*` | BehaviorEvent['type'] = '*' | `${BehaviorEventTypeNamespace}.*` | BehaviorEvent['type'], TGuardResponse = true, TBehaviorEvent extends ResolveBehaviorEvent<TBehaviorEventType> = ResolveBehaviorEvent<TBehaviorEventType>> = {
1990
2065
  /**
@@ -2004,7 +2079,7 @@ type Behavior<TBehaviorEventType extends '*' | `${BehaviorEventTypeNamespace}.*`
2004
2079
  actions: Array<BehaviorActionSet<TBehaviorEvent, TGuardResponse>>;
2005
2080
  };
2006
2081
  /**
2007
- * @beta
2082
+ * @public
2008
2083
  *
2009
2084
  * @example
2010
2085
  *
@@ -2134,9 +2209,6 @@ type PatchEvent = {
2134
2209
  * @public
2135
2210
  */
2136
2211
  type EditorConfig = {
2137
- /**
2138
- * @beta
2139
- */
2140
2212
  keyGenerator?: () => string;
2141
2213
  readOnly?: boolean;
2142
2214
  initialValue?: Array<PortableTextBlock>;
@@ -2176,7 +2248,7 @@ type Editor = {
2176
2248
  dom: EditorDom;
2177
2249
  getSnapshot: () => EditorSnapshot;
2178
2250
  /**
2179
- * @beta
2251
+ * @public
2180
2252
  */
2181
2253
  registerBehavior: (config: {
2182
2254
  behavior: Behavior;
@@ -2187,7 +2259,7 @@ type Editor = {
2187
2259
  * `defineSpan`, `defineBlockObject`, `defineInlineObject`). Returns
2188
2260
  * a function that unregisters the node when called.
2189
2261
  *
2190
- * @alpha
2262
+ * @public
2191
2263
  */
2192
2264
  registerNode: (config: {
2193
2265
  node: RegistrableNode;
@@ -2333,7 +2405,7 @@ declare const defaultKeyGenerator: () => string;
2333
2405
  */
2334
2406
  declare function useEditor(): Editor;
2335
2407
  /**
2336
- * @beta
2408
+ * @public
2337
2409
  */
2338
2410
  type BlockOffset = {
2339
2411
  path: BlockPath;
@@ -2652,7 +2724,7 @@ type SpanWithOptionalKey = Omit<PortableTextSpan, '_key'> & {
2652
2724
  };
2653
2725
  type ChildWithOptionalKey = SpanWithOptionalKey | ObjectBlockWithOptionalKey;
2654
2726
  /**
2655
- * @beta
2727
+ * @public
2656
2728
  */
2657
2729
  type BehaviorEvent = SyntheticBehaviorEvent | NativeBehaviorEvent | CustomBehaviorEvent;
2658
2730
  type BehaviorEventTypeNamespace = SyntheticBehaviorEventNamespace | NativeBehaviorEventNamespace | CustomBehaviorEventNamespace;
@@ -2683,7 +2755,7 @@ declare const syntheticBehaviorEventTypes: readonly ["annotation.add", "annotati
2683
2755
  type SyntheticBehaviorEventType = (typeof syntheticBehaviorEventTypes)[number] | (typeof abstractBehaviorEventTypes)[number];
2684
2756
  type SyntheticBehaviorEventNamespace = ExtractNamespace<SyntheticBehaviorEventType>;
2685
2757
  /**
2686
- * @beta
2758
+ * @public
2687
2759
  */
2688
2760
  type SyntheticBehaviorEvent = {
2689
2761
  type: StrictExtract<SyntheticBehaviorEventType, 'annotation.add'>;
@@ -2893,7 +2965,7 @@ type SyntheticBehaviorEvent = {
2893
2965
  at: Path;
2894
2966
  } | AbstractBehaviorEvent;
2895
2967
  /**
2896
- * @beta
2968
+ * @public
2897
2969
  */
2898
2970
  type InsertPlacement = 'auto' | 'after' | 'before';
2899
2971
  /**************************************
@@ -3043,7 +3115,7 @@ declare const nativeBehaviorEventTypes: readonly ["clipboard.copy", "clipboard.c
3043
3115
  type NativeBehaviorEventType = (typeof nativeBehaviorEventTypes)[number];
3044
3116
  type NativeBehaviorEventNamespace = ExtractNamespace<NativeBehaviorEventType>;
3045
3117
  /**
3046
- * @beta
3118
+ * @public
3047
3119
  */
3048
3120
  type NativeBehaviorEvent = ClipboardBehaviorEvent | DragBehaviorEvent | InputBehaviorEvent | KeyboardBehaviorEvent | MouseBehaviorEvent;
3049
3121
  type ClipboardBehaviorEvent = {
@@ -3143,7 +3215,7 @@ type MouseBehaviorEvent = {
3143
3215
  type CustomBehaviorEventNamespace = 'custom';
3144
3216
  type CustomBehaviorEventType<TNamespace extends CustomBehaviorEventNamespace, TType extends string = ''> = TType extends '' ? `${TNamespace}` : `${TNamespace}.${TType}`;
3145
3217
  /**
3146
- * @beta
3218
+ * @public
3147
3219
  */
3148
3220
  type CustomBehaviorEvent<TPayload extends Record<string, unknown> = Record<string, unknown>, TType extends string = string, TInternalType extends CustomBehaviorEventType<'custom', TType> = CustomBehaviorEventType<'custom', TType>> = {
3149
3221
  type: TInternalType;
@@ -3189,7 +3261,7 @@ type EditorDom = {
3189
3261
  }) => void;
3190
3262
  };
3191
3263
  /**
3192
- * @beta
3264
+ * @public
3193
3265
  */
3194
3266
  type BehaviorAction = {
3195
3267
  type: 'execute';
@@ -3243,7 +3315,7 @@ type BehaviorAction = {
3243
3315
  * })
3244
3316
  * ```
3245
3317
  *
3246
- * @beta
3318
+ * @public
3247
3319
  */
3248
3320
  declare function execute(event: SyntheticBehaviorEvent): PickFromUnion<BehaviorAction, 'type', 'execute'>;
3249
3321
  /**
@@ -3281,7 +3353,7 @@ declare function execute(event: SyntheticBehaviorEvent): PickFromUnion<BehaviorA
3281
3353
  * })
3282
3354
  * ```
3283
3355
  *
3284
- * @beta
3356
+ * @public
3285
3357
  */
3286
3358
  declare function forward(event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent): PickFromUnion<BehaviorAction, 'type', 'forward'>;
3287
3359
  /**
@@ -3315,7 +3387,7 @@ declare function forward(event: NativeBehaviorEvent | SyntheticBehaviorEvent | C
3315
3387
  * })
3316
3388
  * ```
3317
3389
  *
3318
- * @beta
3390
+ * @public
3319
3391
  */
3320
3392
  declare function raise$1(event: SyntheticBehaviorEvent | CustomBehaviorEvent): PickFromUnion<BehaviorAction, 'type', 'raise'>;
3321
3393
  /**
@@ -3358,16 +3430,16 @@ declare function raise$1(event: SyntheticBehaviorEvent | CustomBehaviorEvent): P
3358
3430
  * })
3359
3431
  * ```
3360
3432
  *
3361
- * @beta
3433
+ * @public
3362
3434
  */
3363
3435
  declare function effect(effect: PickFromUnion<BehaviorAction, 'type', 'effect'>['effect']): PickFromUnion<BehaviorAction, 'type', 'effect'>;
3364
3436
  /**
3365
- * @beta
3437
+ * @public
3366
3438
  */
3367
3439
  type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (payload: {
3368
3440
  snapshot: EditorSnapshot;
3369
3441
  event: TBehaviorEvent;
3370
3442
  dom: EditorDom;
3371
3443
  }, guardResponse: TGuardResponse) => Array<BehaviorAction>;
3372
- export { EditorContext as $, SpanRender as $t, PortableTextTextBlock$1 as A, HotkeyOptions as At, EditorSelector as B, RegisteredPositional as Bt, ListDefinition as C, RenderEditableFunction as Ct, PortableTextChild$1 as D, ScrollSelectionIntoViewFunction as Dt, PortableTextBlock$1 as E, RenderStyleFunction as Et, BlockOffset as F, EditorSchema as Ft, EditorConfig as G, Container as Gt, EditorProvider as H, BlockObject as Ht, useEditor as I, Containers as It, MutationEvent as J, InlineObject as Jt, EditorEvent as K, ContainerRender as Kt, defaultKeyGenerator as L, RegisteredBlockObject as Lt, StyleDefinition as M, resolveContainerAt as Mt, StyleSchemaType$1 as N, TraversalSnapshot as Nt, PortableTextObject$1 as O, PortableTextEditable as Ot, defineSchema as P, Node$1 as Pt, BehaviorGuard as Q, Span as Qt, usePortableTextEditorSelection as R, RegisteredContainer as Rt, InlineObjectSchemaType$1 as S, RenderDecoratorFunction as St, Patch$1 as T, RenderPlaceholderFunction as Tt, EditorProviderProps as U, BlockObjectRender as Ut, useEditorSelector as V, RegisteredSpan as Vt, Editor as W, BlockObjectRenderProps as Wt, Behavior as X, InlineObjectRenderProps as Xt, Operation as Y, InlineObjectRender as Yt, defineBehavior as Z, RegistrableNode as Zt, BlockObjectSchemaType$1 as _, RangeDecoration as _t, forward as a, defineContainer as an, BlockListItemRenderProps as at, FieldDefinition$1 as b, RenderBlockFunction as bt, CustomBehaviorEvent as c, defineTextBlock as cn, EditableAPIDeleteOptions as ct, SyntheticBehaviorEvent as d, ChildPath as dn, InvalidValueResolution as dt, SpanRenderProps as en, EditorSnapshot as et, PatchesEvent as f, KeyedSegment as fn, OnCopyFn as ft, BlockObjectDefinition as g, PasteData as gt, BaseDefinition as h, OnPasteResultOrPromise as ht, execute as i, defineBlockObject as in, BlockDecoratorRenderProps as it, SchemaDefinition$1 as j, PortableTextEditor as jt, PortableTextSpan$1 as k, PortableTextEditableProps as kt, InsertPlacement as l, AnnotationPath as ln, EditorSelection as lt, AnnotationSchemaType$1 as m, PathSegment as mn, OnPasteResult as mt, BehaviorActionSet as n, TextBlockRender as nn, BlockAnnotationRenderProps as nt, raise$1 as o, defineInlineObject as on, BlockRenderProps as ot, AnnotationDefinition as p, Path as pn, OnPasteFn as pt, EditorEmittedEvent as q, ContainerRenderProps as qt, effect as r, TextBlockRenderProps as rn, BlockChildRenderProps as rt, BehaviorEvent as s, defineSpan as sn, BlockStyleRenderProps as st, BehaviorAction as t, TextBlock as tn, AddedAnnotationPaths as tt, NativeBehaviorEvent as u, BlockPath as un, EditorSelectionPoint as ut, DecoratorDefinition as v, RangeDecorationOnMovedDetails as vt, ListSchemaType$1 as w, RenderListItemFunction as wt, InlineObjectDefinition as x, RenderChildFunction as xt, DecoratorSchemaType$1 as y, RenderAnnotationFunction as yt, usePortableTextEditor as z, RegisteredInlineObject as zt };
3373
- //# sourceMappingURL=behavior.types.action-CYtiRDck.d.ts.map
3444
+ export { BehaviorGuard as $, Span as $t, PortableTextSpan$1 as A, PortableTextEditableProps as At, usePortableTextEditor as B, RegisteredInlineObject as Bt, ListDefinition as C, 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, BlockObjectRenderProps as Gt, useEditorSelector as H, RegisteredSpan as Ht, BlockOffset as I, EditorSchema as It, EditorEmittedEvent as J, ContainerRenderProps as Jt, EditorConfig as K, Container 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, RegistrableNode as Qt, defaultKeyGenerator as R, RegisteredBlockObject as Rt, InlineObjectSchemaType$1 as S, RenderChildFunction as St, OfDefinition$1 as T, RenderListItemFunction as Tt, EditorProvider as U, BlockObject as Ut, EditorSelector as V, RegisteredPositional as Vt, EditorProviderProps as W, BlockObjectRender as Wt, Operation as X, InlineObjectRender as Xt, MutationEvent as Y, InlineObject as Yt, Behavior as Z, InlineObjectRenderProps as Zt, BlockObjectSchemaType$1 as _, PasteData as _t, forward as a, defineBlockObject as an, BlockDecoratorRenderProps as at, FieldDefinition$1 as b, RenderAnnotationFunction as bt, CustomBehaviorEvent as c, defineSpan as cn, BlockStyleRenderProps as ct, SyntheticBehaviorEvent as d, BlockPath as dn, EditorSelectionPoint as dt, SpanRender as en, EditorContext as et, PatchesEvent as f, ChildPath as fn, InvalidValueResolution as ft, BlockObjectDefinition as g, OnPasteResultOrPromise as gt, BaseDefinition as h, PathSegment as hn, OnPasteResult as ht, execute as i, TextBlockRenderProps as in, BlockChildRenderProps as it, PortableTextTextBlock$1 as j, HotkeyOptions as jt, PortableTextObject$1 as k, PortableTextEditable as kt, InsertPlacement as l, defineTextBlock as ln, EditableAPIDeleteOptions as lt, AnnotationSchemaType$1 as m, Path as mn, OnPasteFn as mt, BehaviorActionSet as n, TextBlock as nn, AddedAnnotationPaths as nt, raise$1 as o, defineContainer as on, BlockListItemRenderProps as ot, AnnotationDefinition as p, KeyedSegment as pn, OnCopyFn as pt, EditorEvent as q, ContainerRender as qt, effect as r, TextBlockRender as rn, BlockAnnotationRenderProps as rt, BehaviorEvent as s, defineInlineObject as sn, BlockRenderProps as st, BehaviorAction as t, SpanRenderProps as tn, EditorSnapshot as tt, NativeBehaviorEvent as u, AnnotationPath as un, EditorSelection as ut, DecoratorDefinition as v, RangeDecoration as vt, ListSchemaType$1 as w, RenderEditableFunction as wt, InlineObjectDefinition as x, RenderBlockFunction as xt, DecoratorSchemaType$1 as y, RangeDecorationOnMovedDetails as yt, usePortableTextEditorSelection as z, RegisteredContainer as zt };
3445
+ //# sourceMappingURL=behavior.types.action-DXkAaEGS.d.ts.map