@portabletext/editor 1.21.6 → 1.23.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 (53) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  2. package/lib/_chunks-cjs/selector.get-text-before.cjs +4 -4
  3. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  4. package/lib/_chunks-cjs/{util.get-block-start-point.cjs → util.reverse-selection.cjs} +12 -12
  5. package/lib/_chunks-cjs/util.reverse-selection.cjs.map +1 -0
  6. package/lib/_chunks-cjs/util.slice-blocks.cjs +75 -0
  7. package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -0
  8. package/lib/_chunks-es/behavior.core.js.map +1 -1
  9. package/lib/_chunks-es/selector.get-text-before.js +1 -1
  10. package/lib/_chunks-es/{util.get-block-start-point.js → util.reverse-selection.js} +12 -12
  11. package/lib/_chunks-es/util.reverse-selection.js.map +1 -0
  12. package/lib/_chunks-es/util.slice-blocks.js +76 -0
  13. package/lib/_chunks-es/util.slice-blocks.js.map +1 -0
  14. package/lib/behaviors/index.cjs.map +1 -1
  15. package/lib/behaviors/index.d.cts +57 -0
  16. package/lib/behaviors/index.d.ts +57 -0
  17. package/lib/behaviors/index.js.map +1 -1
  18. package/lib/index.cjs +33 -12
  19. package/lib/index.cjs.map +1 -1
  20. package/lib/index.d.cts +418 -0
  21. package/lib/index.d.ts +418 -0
  22. package/lib/index.js +33 -12
  23. package/lib/index.js.map +1 -1
  24. package/lib/selectors/index.cjs +10 -4
  25. package/lib/selectors/index.cjs.map +1 -1
  26. package/lib/selectors/index.d.cts +5 -0
  27. package/lib/selectors/index.d.ts +5 -0
  28. package/lib/selectors/index.js +9 -2
  29. package/lib/selectors/index.js.map +1 -1
  30. package/lib/utils/index.cjs +4 -3
  31. package/lib/utils/index.cjs.map +1 -1
  32. package/lib/utils/index.d.cts +11 -0
  33. package/lib/utils/index.d.ts +11 -0
  34. package/lib/utils/index.js +3 -1
  35. package/lib/utils/index.js.map +1 -1
  36. package/package.json +16 -12
  37. package/src/behaviors/behavior.markdown.ts +42 -0
  38. package/src/behaviors/behavior.types.ts +15 -0
  39. package/src/editor/Editable.tsx +17 -0
  40. package/src/editor/create-editor.ts +1 -0
  41. package/src/editor/define-schema.ts +24 -1
  42. package/src/editor/editor-event-listener.tsx +45 -0
  43. package/src/editor/editor-machine.ts +13 -26
  44. package/src/editor/editor-provider.tsx +27 -0
  45. package/src/editor/editor-selector.ts +21 -0
  46. package/src/editor/editor-snapshot.ts +37 -1
  47. package/src/selectors/index.ts +1 -0
  48. package/src/selectors/selector.get-selected-slice.ts +12 -0
  49. package/src/utils/index.ts +1 -0
  50. package/src/utils/util.slice-blocks.test.ts +257 -0
  51. package/src/utils/util.slice-blocks.ts +153 -0
  52. package/lib/_chunks-cjs/util.get-block-start-point.cjs.map +0 -1
  53. package/lib/_chunks-es/util.get-block-start-point.js.map +0 -1
package/lib/index.d.cts CHANGED
@@ -377,6 +377,26 @@ declare type CustomBehaviorEvent<
377
377
 
378
378
  /**
379
379
  * @public
380
+ * A helper wrapper that adds editor support, such as autocomplete and type checking, for a schema definition.
381
+ * @example
382
+ * ```ts
383
+ * import { defineSchema } from '@portabletext/editor'
384
+ *
385
+ * const schemaDefinition = defineSchema({
386
+ * decorators: [{name: 'strong'}, {name: 'em'}, {name: 'underline'}],
387
+ * annotations: [{name: 'link'}],
388
+ * styles: [
389
+ * {name: 'normal'},
390
+ * {name: 'h1'},
391
+ * {name: 'h2'},
392
+ * {name: 'h3'},
393
+ * {name: 'blockquote'},
394
+ * ],
395
+ * lists: [],
396
+ * inlineObjects: [],
397
+ * blockObjects: [],
398
+ * }
399
+ * ```
380
400
  */
381
401
  export declare function defineSchema<
382
402
  const TSchemaDefinition extends SchemaDefinition,
@@ -595,6 +615,7 @@ export declare type EditorEvent =
595
615
  | 'style.toggle'
596
616
  | 'patches'
597
617
  | 'update behaviors'
618
+ | 'update key generator'
598
619
  | 'update readOnly'
599
620
  | 'update value'
600
621
  >
@@ -602,6 +623,51 @@ export declare type EditorEvent =
602
623
 
603
624
  /**
604
625
  * @public
626
+ * Listen for events emitted by the editor. Must be used inside `EditorProvider`. Events available include:
627
+ * - 'blurred'
628
+ * - 'done loading'
629
+ * - 'editable'
630
+ * - 'error'
631
+ * - 'focused'
632
+ * - 'invalid value'
633
+ * - 'loading'
634
+ * - 'mutation'
635
+ * - 'patch'
636
+ * - 'read only'
637
+ * - 'ready'
638
+ * - 'selection'
639
+ * - 'value changed'
640
+ *
641
+ * @example
642
+ * Listen and log events.
643
+ * ```tsx
644
+ * import {EditorEventListener, EditorProvider} from '@portabletext/editor'
645
+ *
646
+ * function MyComponent() {
647
+ * return (
648
+ * <EditorProvider>
649
+ * <EditorEventListener
650
+ * on={(event) => {
651
+ * console.log(event)
652
+ * }
653
+ * } />
654
+ * { ... }
655
+ * </EditorProvider>
656
+ * )
657
+ * }
658
+ * ```
659
+ * @example
660
+ * Handle events when there is a mutation.
661
+ * ```tsx
662
+ * <EditorEventListener
663
+ * on={(event) => {
664
+ * if (event.type === 'mutation') {
665
+ * console.log('Value changed:', event.snapshot)
666
+ * }
667
+ * }}
668
+ * />
669
+ * ```
670
+ * @group Components
605
671
  */
606
672
  export declare function EditorEventListener(props: {
607
673
  on: (event: EditorEmittedEvent) => void
@@ -722,6 +788,10 @@ export declare const editorMachine: StateMachine<
722
788
  type: 'update behaviors'
723
789
  behaviors: Array<Behavior>
724
790
  }
791
+ | {
792
+ type: 'update key generator'
793
+ keyGenerator: () => string
794
+ }
725
795
  | {
726
796
  type: 'update value'
727
797
  value: Array<PortableTextBlock> | undefined
@@ -1115,6 +1185,10 @@ export declare const editorMachine: StateMachine<
1115
1185
  type: 'update behaviors'
1116
1186
  behaviors: Array<Behavior>
1117
1187
  }
1188
+ | {
1189
+ type: 'update key generator'
1190
+ keyGenerator: () => string
1191
+ }
1118
1192
  | {
1119
1193
  type: 'update value'
1120
1194
  value: Array<PortableTextBlock> | undefined
@@ -1277,6 +1351,10 @@ export declare const editorMachine: StateMachine<
1277
1351
  type: 'update behaviors'
1278
1352
  behaviors: Array<Behavior>
1279
1353
  }
1354
+ | {
1355
+ type: 'update key generator'
1356
+ keyGenerator: () => string
1357
+ }
1280
1358
  | {
1281
1359
  type: 'update value'
1282
1360
  value: Array<PortableTextBlock> | undefined
@@ -1467,6 +1545,10 @@ export declare const editorMachine: StateMachine<
1467
1545
  type: 'update behaviors'
1468
1546
  behaviors: Array<Behavior>
1469
1547
  }
1548
+ | {
1549
+ type: 'update key generator'
1550
+ keyGenerator: () => string
1551
+ }
1470
1552
  | {
1471
1553
  type: 'update value'
1472
1554
  value: Array<PortableTextBlock> | undefined
@@ -1754,6 +1836,10 @@ export declare const editorMachine: StateMachine<
1754
1836
  type: 'update behaviors'
1755
1837
  behaviors: Array<Behavior>
1756
1838
  }
1839
+ | {
1840
+ type: 'update key generator'
1841
+ keyGenerator: () => string
1842
+ }
1757
1843
  | {
1758
1844
  type: 'update value'
1759
1845
  value: Array<PortableTextBlock> | undefined
@@ -2042,6 +2128,10 @@ export declare const editorMachine: StateMachine<
2042
2128
  type: 'update behaviors'
2043
2129
  behaviors: Array<Behavior>
2044
2130
  }
2131
+ | {
2132
+ type: 'update key generator'
2133
+ keyGenerator: () => string
2134
+ }
2045
2135
  | {
2046
2136
  type: 'update value'
2047
2137
  value: Array<PortableTextBlock> | undefined
@@ -2331,6 +2421,10 @@ export declare const editorMachine: StateMachine<
2331
2421
  type: 'update behaviors'
2332
2422
  behaviors: Array<Behavior>
2333
2423
  }
2424
+ | {
2425
+ type: 'update key generator'
2426
+ keyGenerator: () => string
2427
+ }
2334
2428
  | {
2335
2429
  type: 'update value'
2336
2430
  value: Array<PortableTextBlock> | undefined
@@ -2619,6 +2713,10 @@ export declare const editorMachine: StateMachine<
2619
2713
  type: 'update behaviors'
2620
2714
  behaviors: Array<Behavior>
2621
2715
  }
2716
+ | {
2717
+ type: 'update key generator'
2718
+ keyGenerator: () => string
2719
+ }
2622
2720
  | {
2623
2721
  type: 'update value'
2624
2722
  value: Array<PortableTextBlock> | undefined
@@ -2796,6 +2894,10 @@ export declare const editorMachine: StateMachine<
2796
2894
  type: 'update behaviors'
2797
2895
  behaviors: Array<Behavior>
2798
2896
  }
2897
+ | {
2898
+ type: 'update key generator'
2899
+ keyGenerator: () => string
2900
+ }
2799
2901
  | {
2800
2902
  type: 'update value'
2801
2903
  value: Array<PortableTextBlock> | undefined
@@ -3084,6 +3186,10 @@ export declare const editorMachine: StateMachine<
3084
3186
  type: 'update behaviors'
3085
3187
  behaviors: Array<Behavior>
3086
3188
  }
3189
+ | {
3190
+ type: 'update key generator'
3191
+ keyGenerator: () => string
3192
+ }
3087
3193
  | {
3088
3194
  type: 'update value'
3089
3195
  value: Array<PortableTextBlock> | undefined
@@ -3371,6 +3477,10 @@ export declare const editorMachine: StateMachine<
3371
3477
  type: 'update behaviors'
3372
3478
  behaviors: Array<Behavior>
3373
3479
  }
3480
+ | {
3481
+ type: 'update key generator'
3482
+ keyGenerator: () => string
3483
+ }
3374
3484
  | {
3375
3485
  type: 'update value'
3376
3486
  value: Array<PortableTextBlock> | undefined
@@ -3657,6 +3767,10 @@ export declare const editorMachine: StateMachine<
3657
3767
  type: 'update behaviors'
3658
3768
  behaviors: Array<Behavior>
3659
3769
  }
3770
+ | {
3771
+ type: 'update key generator'
3772
+ keyGenerator: () => string
3773
+ }
3660
3774
  | {
3661
3775
  type: 'update value'
3662
3776
  value: Array<PortableTextBlock> | undefined
@@ -3941,6 +4055,10 @@ export declare const editorMachine: StateMachine<
3941
4055
  type: 'update behaviors'
3942
4056
  behaviors: Array<Behavior>
3943
4057
  }
4058
+ | {
4059
+ type: 'update key generator'
4060
+ keyGenerator: () => string
4061
+ }
3944
4062
  | {
3945
4063
  type: 'update value'
3946
4064
  value: Array<PortableTextBlock> | undefined
@@ -4227,6 +4345,10 @@ export declare const editorMachine: StateMachine<
4227
4345
  type: 'update behaviors'
4228
4346
  behaviors: Array<Behavior>
4229
4347
  }
4348
+ | {
4349
+ type: 'update key generator'
4350
+ keyGenerator: () => string
4351
+ }
4230
4352
  | {
4231
4353
  type: 'update value'
4232
4354
  value: Array<PortableTextBlock> | undefined
@@ -4400,6 +4522,189 @@ export declare const editorMachine: StateMachine<
4400
4522
  readonly 'update behaviors': {
4401
4523
  readonly actions: 'assign behaviors'
4402
4524
  }
4525
+ readonly 'update key generator': {
4526
+ readonly actions: ActionFunction<
4527
+ {
4528
+ behaviors: Set<Behavior>
4529
+ keyGenerator: () => string
4530
+ pendingEvents: Array<PatchEvent | MutationEvent>
4531
+ schema: EditorSchema
4532
+ initialReadOnly: boolean
4533
+ maxBlocks: number | undefined
4534
+ selection: EditorSelection
4535
+ value: Array<PortableTextBlock> | undefined
4536
+ },
4537
+ {
4538
+ type: 'update key generator'
4539
+ keyGenerator: () => string
4540
+ },
4541
+ | {
4542
+ type: 'annotation.add'
4543
+ annotation: {
4544
+ name: string
4545
+ value: {
4546
+ [prop: string]: unknown
4547
+ }
4548
+ }
4549
+ }
4550
+ | {
4551
+ type: 'annotation.remove'
4552
+ annotation: {
4553
+ name: string
4554
+ }
4555
+ }
4556
+ | {
4557
+ type: 'blur'
4558
+ }
4559
+ | {
4560
+ type: 'decorator.toggle'
4561
+ decorator: string
4562
+ }
4563
+ | {
4564
+ type: 'focus'
4565
+ }
4566
+ | {
4567
+ type: 'insert.block object'
4568
+ placement: 'auto' | 'after' | 'before'
4569
+ blockObject: {
4570
+ name: string
4571
+ value?: {
4572
+ [prop: string]: unknown
4573
+ }
4574
+ }
4575
+ }
4576
+ | {
4577
+ type: 'insert.inline object'
4578
+ inlineObject: {
4579
+ name: string
4580
+ value?: {
4581
+ [prop: string]: unknown
4582
+ }
4583
+ }
4584
+ }
4585
+ | {
4586
+ type: 'list item.toggle'
4587
+ listItem: string
4588
+ }
4589
+ | {
4590
+ type: 'style.toggle'
4591
+ style: string
4592
+ }
4593
+ | PatchEvent
4594
+ | MutationEvent
4595
+ | {
4596
+ type: 'normalizing'
4597
+ }
4598
+ | {
4599
+ type: 'done normalizing'
4600
+ }
4601
+ | {
4602
+ type: 'done syncing initial value'
4603
+ }
4604
+ | {
4605
+ type: 'behavior event'
4606
+ behaviorEvent: SyntheticBehaviorEvent | NativeBehaviorEvent
4607
+ editor: PortableTextSlateEditor
4608
+ defaultActionCallback?: () => void
4609
+ nativeEvent?: {
4610
+ preventDefault: () => void
4611
+ }
4612
+ }
4613
+ | {
4614
+ type: 'custom behavior event'
4615
+ behaviorEvent: CustomBehaviorEvent
4616
+ editor: PortableTextSlateEditor
4617
+ nativeEvent?: {
4618
+ preventDefault: () => void
4619
+ }
4620
+ }
4621
+ | CustomBehaviorEvent
4622
+ | {
4623
+ type: 'add behavior'
4624
+ behavior: Behavior
4625
+ }
4626
+ | {
4627
+ type: 'remove behavior'
4628
+ behavior: Behavior
4629
+ }
4630
+ | {
4631
+ type: 'update readOnly'
4632
+ readOnly: boolean
4633
+ }
4634
+ | {
4635
+ type: 'update schema'
4636
+ schema: EditorSchema
4637
+ }
4638
+ | {
4639
+ type: 'update behaviors'
4640
+ behaviors: Array<Behavior>
4641
+ }
4642
+ | {
4643
+ type: 'update key generator'
4644
+ keyGenerator: () => string
4645
+ }
4646
+ | {
4647
+ type: 'update value'
4648
+ value: Array<PortableTextBlock> | undefined
4649
+ }
4650
+ | {
4651
+ type: 'update maxBlocks'
4652
+ maxBlocks: number | undefined
4653
+ }
4654
+ | PatchesEvent
4655
+ | {
4656
+ type: 'unset'
4657
+ previousValue: Array<PortableTextBlock>
4658
+ }
4659
+ | {
4660
+ type: 'value changed'
4661
+ value: Array<PortableTextBlock> | undefined
4662
+ }
4663
+ | {
4664
+ type: 'invalid value'
4665
+ resolution: InvalidValueResolution | null
4666
+ value: Array<PortableTextBlock> | undefined
4667
+ }
4668
+ | {
4669
+ type: 'error'
4670
+ name: string
4671
+ description: string
4672
+ data: unknown
4673
+ }
4674
+ | {
4675
+ type: 'select'
4676
+ selection: EditorSelection
4677
+ }
4678
+ | {
4679
+ type: 'selection'
4680
+ selection: EditorSelection
4681
+ }
4682
+ | {
4683
+ type: 'blurred'
4684
+ event: FocusEvent_2<HTMLDivElement, Element>
4685
+ }
4686
+ | {
4687
+ type: 'focused'
4688
+ event: FocusEvent_2<HTMLDivElement, Element>
4689
+ }
4690
+ | {
4691
+ type: 'loading'
4692
+ }
4693
+ | {
4694
+ type: 'done loading'
4695
+ }
4696
+ | {
4697
+ type: 'custom.*'
4698
+ event: CustomBehaviorEvent
4699
+ },
4700
+ undefined,
4701
+ never,
4702
+ never,
4703
+ never,
4704
+ never,
4705
+ never
4706
+ >
4707
+ }
4403
4708
  readonly 'update schema': {
4404
4709
  readonly actions: 'assign schema'
4405
4710
  }
@@ -4520,6 +4825,10 @@ export declare const editorMachine: StateMachine<
4520
4825
  type: 'update behaviors'
4521
4826
  behaviors: Array<Behavior>
4522
4827
  }
4828
+ | {
4829
+ type: 'update key generator'
4830
+ keyGenerator: () => string
4831
+ }
4523
4832
  | {
4524
4833
  type: 'update value'
4525
4834
  value: Array<PortableTextBlock> | undefined
@@ -4699,6 +5008,10 @@ export declare const editorMachine: StateMachine<
4699
5008
  type: 'update behaviors'
4700
5009
  behaviors: Array<Behavior>
4701
5010
  }
5011
+ | {
5012
+ type: 'update key generator'
5013
+ keyGenerator: () => string
5014
+ }
4702
5015
  | {
4703
5016
  type: 'update value'
4704
5017
  value: Array<PortableTextBlock> | undefined
@@ -4987,6 +5300,10 @@ export declare const editorMachine: StateMachine<
4987
5300
  type: 'update behaviors'
4988
5301
  behaviors: Array<Behavior>
4989
5302
  }
5303
+ | {
5304
+ type: 'update key generator'
5305
+ keyGenerator: () => string
5306
+ }
4990
5307
  | {
4991
5308
  type: 'update value'
4992
5309
  value: Array<PortableTextBlock> | undefined
@@ -5275,6 +5592,10 @@ export declare const editorMachine: StateMachine<
5275
5592
  type: 'update behaviors'
5276
5593
  behaviors: Array<Behavior>
5277
5594
  }
5595
+ | {
5596
+ type: 'update key generator'
5597
+ keyGenerator: () => string
5598
+ }
5278
5599
  | {
5279
5600
  type: 'update value'
5280
5601
  value: Array<PortableTextBlock> | undefined
@@ -5565,6 +5886,10 @@ export declare const editorMachine: StateMachine<
5565
5886
  type: 'update behaviors'
5566
5887
  behaviors: Array<Behavior>
5567
5888
  }
5889
+ | {
5890
+ type: 'update key generator'
5891
+ keyGenerator: () => string
5892
+ }
5568
5893
  | {
5569
5894
  type: 'update value'
5570
5895
  value: Array<PortableTextBlock> | undefined
@@ -5854,6 +6179,10 @@ export declare const editorMachine: StateMachine<
5854
6179
  type: 'update behaviors'
5855
6180
  behaviors: Array<Behavior>
5856
6181
  }
6182
+ | {
6183
+ type: 'update key generator'
6184
+ keyGenerator: () => string
6185
+ }
5857
6186
  | {
5858
6187
  type: 'update value'
5859
6188
  value: Array<PortableTextBlock> | undefined
@@ -6142,6 +6471,10 @@ export declare const editorMachine: StateMachine<
6142
6471
  type: 'update behaviors'
6143
6472
  behaviors: Array<Behavior>
6144
6473
  }
6474
+ | {
6475
+ type: 'update key generator'
6476
+ keyGenerator: () => string
6477
+ }
6145
6478
  | {
6146
6479
  type: 'update value'
6147
6480
  value: Array<PortableTextBlock> | undefined
@@ -6446,6 +6779,10 @@ export declare const editorMachine: StateMachine<
6446
6779
  type: 'update behaviors'
6447
6780
  behaviors: Array<Behavior>
6448
6781
  }
6782
+ | {
6783
+ type: 'update key generator'
6784
+ keyGenerator: () => string
6785
+ }
6449
6786
  | {
6450
6787
  type: 'update value'
6451
6788
  value: Array<PortableTextBlock> | undefined
@@ -6735,6 +7072,10 @@ export declare const editorMachine: StateMachine<
6735
7072
  type: 'update behaviors'
6736
7073
  behaviors: Array<Behavior>
6737
7074
  }
7075
+ | {
7076
+ type: 'update key generator'
7077
+ keyGenerator: () => string
7078
+ }
6738
7079
  | {
6739
7080
  type: 'update value'
6740
7081
  value: Array<PortableTextBlock> | undefined
@@ -7024,6 +7365,10 @@ export declare const editorMachine: StateMachine<
7024
7365
  type: 'update behaviors'
7025
7366
  behaviors: Array<Behavior>
7026
7367
  }
7368
+ | {
7369
+ type: 'update key generator'
7370
+ keyGenerator: () => string
7371
+ }
7027
7372
  | {
7028
7373
  type: 'update value'
7029
7374
  value: Array<PortableTextBlock> | undefined
@@ -7313,6 +7658,10 @@ export declare const editorMachine: StateMachine<
7313
7658
  type: 'update behaviors'
7314
7659
  behaviors: Array<Behavior>
7315
7660
  }
7661
+ | {
7662
+ type: 'update key generator'
7663
+ keyGenerator: () => string
7664
+ }
7316
7665
  | {
7317
7666
  type: 'update value'
7318
7667
  value: Array<PortableTextBlock> | undefined
@@ -7565,6 +7914,21 @@ export declare type EditorNode = Node_2 & {
7565
7914
 
7566
7915
  /**
7567
7916
  * @public
7917
+ * The EditorProvider component is used to set up the editor context and configure the Portable Text Editor.
7918
+ * @example
7919
+ * ```tsx
7920
+ * import {EditorProvider} from '@portabletext/editor'
7921
+ *
7922
+ * function App() {
7923
+ * return (
7924
+ * <EditorProvider initialConfig={{ ... }} >
7925
+ * ...
7926
+ * </EditorProvider>
7927
+ * )
7928
+ * }
7929
+ *
7930
+ * ```
7931
+ * @group Components
7568
7932
  */
7569
7933
  export declare function EditorProvider(
7570
7934
  props: EditorProviderProps,
@@ -7779,6 +8143,10 @@ export declare type InternalEditorEvent =
7779
8143
  type: 'update behaviors'
7780
8144
  behaviors: Array<Behavior>
7781
8145
  }
8146
+ | {
8147
+ type: 'update key generator'
8148
+ keyGenerator: () => string
8149
+ }
7782
8150
  | {
7783
8151
  type: 'update value'
7784
8152
  value: Array<PortableTextBlock> | undefined
@@ -7984,6 +8352,23 @@ export {PortableTextChild}
7984
8352
 
7985
8353
  /**
7986
8354
  * @public
8355
+ *
8356
+ *
8357
+ * The core component that renders the editor. Must be placed within the {@link EventProvider} component.
8358
+ *
8359
+ * @example
8360
+ * ```tsx
8361
+ * import { PortableTextEditable, EditorProvider } from '@portabletext/editor'
8362
+ *
8363
+ * function MyComponent() {
8364
+ * return (
8365
+ * <EditorProvider>
8366
+ * <PortableTextEditable />
8367
+ * </EditorProvider>
8368
+ * )
8369
+ * }
8370
+ * ```
8371
+ * @group Components
7987
8372
  */
7988
8373
  export declare const PortableTextEditable: ForwardRefExoticComponent<
7989
8374
  Omit<PortableTextEditableProps, 'ref'> &
@@ -8502,11 +8887,44 @@ export declare type UnsetChange = {
8502
8887
 
8503
8888
  /**
8504
8889
  * @public
8890
+ * Get the current editor context from the `EditorProvider`.
8891
+ * Must be used inside the `EditorProvider` component.
8892
+ * @returns The current editor object.
8893
+ * @example
8894
+ * ```tsx
8895
+ * import { useEditor } from '@portabletext/editor'
8896
+ *
8897
+ * function MyComponent() {
8898
+ * const editor = useEditor()
8899
+ * }
8900
+ * ```
8901
+ * @group Hooks
8505
8902
  */
8506
8903
  export declare function useEditor(): Editor
8507
8904
 
8508
8905
  /**
8509
8906
  * @public
8907
+ * Hook to select a value from the editor state.
8908
+ * @example
8909
+ * Pass a selector as the second argument
8910
+ * ```tsx
8911
+ * import { useEditorSelector } from '@portabletext/editor'
8912
+ *
8913
+ * function MyComponent(editor) {
8914
+ * const value = useEditorSelector(editor, selector)
8915
+ * }
8916
+ * ```
8917
+ * @example
8918
+ * Pass an inline selector as the second argument.
8919
+ * In this case, use the editor context to obtain the schema.
8920
+ * ```tsx
8921
+ * import { useEditorSelector } from '@portabletext/editor'
8922
+ *
8923
+ * function MyComponent(editor) {
8924
+ * const schema = useEditorSelector(editor, (snapshot) => snapshot.context.schema)
8925
+ * }
8926
+ * ```
8927
+ * @group Hooks
8510
8928
  */
8511
8929
  export declare function useEditorSelector<TSelected>(
8512
8930
  editor: Editor,