@portabletext/editor 1.17.0 → 1.18.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 (56) hide show
  1. package/README.md +228 -261
  2. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  3. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  4. package/lib/_chunks-cjs/selector.is-selection-collapsed.cjs.map +1 -1
  5. package/lib/_chunks-es/behavior.core.js.map +1 -1
  6. package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
  7. package/lib/_chunks-es/selector.is-selection-collapsed.js.map +1 -1
  8. package/lib/behaviors/index.cjs +40 -38
  9. package/lib/behaviors/index.cjs.map +1 -1
  10. package/lib/behaviors/index.d.cts +23 -23
  11. package/lib/behaviors/index.d.ts +23 -23
  12. package/lib/behaviors/index.js +40 -38
  13. package/lib/behaviors/index.js.map +1 -1
  14. package/lib/index.cjs +301 -351
  15. package/lib/index.cjs.map +1 -1
  16. package/lib/index.d.cts +123 -753
  17. package/lib/index.d.ts +123 -753
  18. package/lib/index.js +301 -351
  19. package/lib/index.js.map +1 -1
  20. package/lib/selectors/index.cjs.map +1 -1
  21. package/lib/selectors/index.d.cts +30 -30
  22. package/lib/selectors/index.d.ts +30 -30
  23. package/lib/selectors/index.js.map +1 -1
  24. package/package.json +10 -10
  25. package/src/behaviors/behavior.code-editor.ts +2 -2
  26. package/src/behaviors/behavior.core.ts +2 -2
  27. package/src/behaviors/behavior.emoji-picker.ts +52 -41
  28. package/src/behaviors/behavior.links.ts +2 -2
  29. package/src/behaviors/behavior.markdown.ts +2 -2
  30. package/src/behaviors/behavior.types.ts +10 -10
  31. package/src/editor/PortableTextEditor.tsx +2 -0
  32. package/src/editor/__tests__/self-solving.test.tsx +14 -0
  33. package/src/editor/components/Synchronizer.tsx +6 -1
  34. package/src/editor/create-editor.ts +14 -3
  35. package/src/editor/define-schema.ts +4 -4
  36. package/src/editor/editor-event-listener.tsx +1 -1
  37. package/src/editor/editor-machine.ts +42 -52
  38. package/src/editor/editor-provider.tsx +3 -3
  39. package/src/editor/editor-selector.ts +31 -14
  40. package/src/editor/editor-snapshot.ts +2 -2
  41. package/src/editor/get-value.ts +12 -5
  42. package/src/editor/hooks/usePortableTextEditor.ts +1 -0
  43. package/src/editor/hooks/usePortableTextEditorSelection.tsx +1 -0
  44. package/src/selectors/selector.get-active-list-item.ts +1 -1
  45. package/src/selectors/selector.get-active-style.ts +1 -1
  46. package/src/selectors/selector.get-selected-spans.ts +1 -1
  47. package/src/selectors/selector.get-selection-text.ts +1 -1
  48. package/src/selectors/selector.get-text-before.ts +1 -1
  49. package/src/selectors/selector.is-active-annotation.ts +1 -1
  50. package/src/selectors/selector.is-active-decorator.ts +1 -1
  51. package/src/selectors/selector.is-active-list-item.ts +1 -1
  52. package/src/selectors/selector.is-active-style.ts +1 -1
  53. package/src/selectors/selector.is-selection-collapsed.ts +1 -1
  54. package/src/selectors/selector.is-selection-expanded.ts +1 -1
  55. package/src/selectors/selectors.ts +13 -13
  56. package/src/types/editor.ts +2 -2
package/lib/index.d.cts CHANGED
@@ -43,7 +43,6 @@ import type {DOMNode} from 'slate-dom'
43
43
  import type {ReactEditor} from 'slate-react'
44
44
  import type {TextInsertTextOptions} from 'slate/dist/interfaces/transforms/text'
45
45
  import {
46
- ActionArgs,
47
46
  ActionFunction,
48
47
  ActorRef,
49
48
  ActorRefFrom,
@@ -82,7 +81,7 @@ export declare type AddedAnnotationPaths = {
82
81
  }
83
82
 
84
83
  /**
85
- * @alpha
84
+ * @public
86
85
  */
87
86
  export declare type BaseDefinition = {
88
87
  name: string
@@ -91,7 +90,7 @@ export declare type BaseDefinition = {
91
90
  }
92
91
 
93
92
  /**
94
- * @alpha
93
+ * @beta
95
94
  */
96
95
  export declare type Behavior<
97
96
  TBehaviorEventType extends BehaviorEvent['type'] = BehaviorEvent['type'],
@@ -117,7 +116,7 @@ export declare type Behavior<
117
116
  }
118
117
 
119
118
  /**
120
- * @alpha
119
+ * @beta
121
120
  */
122
121
  export declare type BehaviorActionIntend =
123
122
  | SyntheticBehaviorEvent
@@ -211,7 +210,7 @@ export declare type BehaviorActionIntend =
211
210
  }
212
211
 
213
212
  /**
214
- * @alpha
213
+ * @beta
215
214
  */
216
215
  export declare type BehaviorActionIntendSet<
217
216
  TBehaviorEventType extends BehaviorEvent['type'] = BehaviorEvent['type'],
@@ -228,12 +227,12 @@ export declare type BehaviorActionIntendSet<
228
227
  ) => Array<BehaviorActionIntend>
229
228
 
230
229
  /**
231
- * @alpha
230
+ * @beta
232
231
  */
233
232
  export declare type BehaviorEvent = SyntheticBehaviorEvent | NativeBehaviorEvent
234
233
 
235
234
  /**
236
- * @alpha
235
+ * @beta
237
236
  */
238
237
  export declare type BehaviorGuard<
239
238
  TBehaviorEvent extends BehaviorEvent,
@@ -301,7 +300,7 @@ export declare interface BlockListItemRenderProps {
301
300
  }
302
301
 
303
302
  /**
304
- * @alpha
303
+ * @beta
305
304
  */
306
305
  export declare type BlockOffset = {
307
306
  path: [KeyedSegment]
@@ -354,7 +353,7 @@ export declare type ConnectionChange = {
354
353
  }
355
354
 
356
355
  /**
357
- * @alpha
356
+ * @public
358
357
  */
359
358
  export declare function defineSchema<
360
359
  const TSchemaDefinition extends SchemaDefinition,
@@ -450,9 +449,10 @@ export declare interface EditableAPIDeleteOptions {
450
449
  }
451
450
 
452
451
  /**
453
- * @alpha
452
+ * @public
454
453
  */
455
454
  export declare type Editor = {
455
+ getSnapshot: () => EditorSnapshot
456
456
  send: (event: EditorEvent) => void
457
457
  on: ActorRef<Snapshot<unknown>, EventObject, EditorEmittedEvent>['on']
458
458
  _internal: {
@@ -492,9 +492,12 @@ export declare type EditorChange =
492
492
  export declare type EditorChanges = Subject<EditorChange>
493
493
 
494
494
  /**
495
- * @alpha
495
+ * @public
496
496
  */
497
497
  export declare type EditorConfig = {
498
+ /**
499
+ * @beta
500
+ */
498
501
  behaviors?: Array<Behavior>
499
502
  keyGenerator?: () => string
500
503
  /**
@@ -515,7 +518,7 @@ export declare type EditorConfig = {
515
518
  )
516
519
 
517
520
  /**
518
- * @alpha
521
+ * @public
519
522
  */
520
523
  export declare type EditorContext = {
521
524
  activeDecorators: Array<string>
@@ -526,7 +529,7 @@ export declare type EditorContext = {
526
529
  }
527
530
 
528
531
  /**
529
- * @alpha
532
+ * @public
530
533
  */
531
534
  export declare type EditorEmittedEvent = PickFromUnion<
532
535
  InternalEditorEmittedEvent,
@@ -547,7 +550,7 @@ export declare type EditorEmittedEvent = PickFromUnion<
547
550
  >
548
551
 
549
552
  /**
550
- * @alpha
553
+ * @public
551
554
  */
552
555
  export declare type EditorEvent = PickFromUnion<
553
556
  InternalEditorEvent,
@@ -571,7 +574,7 @@ export declare type EditorEvent = PickFromUnion<
571
574
  >
572
575
 
573
576
  /**
574
- * @alpha
577
+ * @public
575
578
  */
576
579
  export declare function EditorEventListener(props: {
577
580
  on: (event: EditorEmittedEvent) => void
@@ -679,11 +682,6 @@ export declare const editorMachine: StateMachine<
679
682
  preventDefault: () => void
680
683
  }
681
684
  }
682
- | {
683
- type: 'behavior action intends'
684
- editor: PortableTextSlateEditor
685
- actionIntends: Array<BehaviorActionIntend>
686
- }
687
685
  | {
688
686
  type: 'update readOnly'
689
687
  readOnly: boolean
@@ -1064,11 +1062,6 @@ export declare const editorMachine: StateMachine<
1064
1062
  preventDefault: () => void
1065
1063
  }
1066
1064
  }
1067
- | {
1068
- type: 'behavior action intends'
1069
- editor: PortableTextSlateEditor
1070
- actionIntends: Array<BehaviorActionIntend>
1071
- }
1072
1065
  | {
1073
1066
  type: 'update readOnly'
1074
1067
  readOnly: boolean
@@ -1222,11 +1215,6 @@ export declare const editorMachine: StateMachine<
1222
1215
  preventDefault: () => void
1223
1216
  }
1224
1217
  }
1225
- | {
1226
- type: 'behavior action intends'
1227
- editor: PortableTextSlateEditor
1228
- actionIntends: Array<BehaviorActionIntend>
1229
- }
1230
1218
  | {
1231
1219
  type: 'update readOnly'
1232
1220
  readOnly: boolean
@@ -1402,11 +1390,6 @@ export declare const editorMachine: StateMachine<
1402
1390
  preventDefault: () => void
1403
1391
  }
1404
1392
  }
1405
- | {
1406
- type: 'behavior action intends'
1407
- editor: PortableTextSlateEditor
1408
- actionIntends: Array<BehaviorActionIntend>
1409
- }
1410
1393
  | {
1411
1394
  type: 'update readOnly'
1412
1395
  readOnly: boolean
@@ -1694,11 +1677,6 @@ export declare const editorMachine: StateMachine<
1694
1677
  preventDefault: () => void
1695
1678
  }
1696
1679
  }
1697
- | {
1698
- type: 'behavior action intends'
1699
- editor: PortableTextSlateEditor
1700
- actionIntends: Array<BehaviorActionIntend>
1701
- }
1702
1680
  | {
1703
1681
  type: 'update readOnly'
1704
1682
  readOnly: boolean
@@ -1987,11 +1965,6 @@ export declare const editorMachine: StateMachine<
1987
1965
  preventDefault: () => void
1988
1966
  }
1989
1967
  }
1990
- | {
1991
- type: 'behavior action intends'
1992
- editor: PortableTextSlateEditor
1993
- actionIntends: Array<BehaviorActionIntend>
1994
- }
1995
1968
  | {
1996
1969
  type: 'update readOnly'
1997
1970
  readOnly: boolean
@@ -2281,11 +2254,6 @@ export declare const editorMachine: StateMachine<
2281
2254
  preventDefault: () => void
2282
2255
  }
2283
2256
  }
2284
- | {
2285
- type: 'behavior action intends'
2286
- editor: PortableTextSlateEditor
2287
- actionIntends: Array<BehaviorActionIntend>
2288
- }
2289
2257
  | {
2290
2258
  type: 'update readOnly'
2291
2259
  readOnly: boolean
@@ -2574,11 +2542,6 @@ export declare const editorMachine: StateMachine<
2574
2542
  preventDefault: () => void
2575
2543
  }
2576
2544
  }
2577
- | {
2578
- type: 'behavior action intends'
2579
- editor: PortableTextSlateEditor
2580
- actionIntends: Array<BehaviorActionIntend>
2581
- }
2582
2545
  | {
2583
2546
  type: 'update readOnly'
2584
2547
  readOnly: boolean
@@ -2747,11 +2710,6 @@ export declare const editorMachine: StateMachine<
2747
2710
  preventDefault: () => void
2748
2711
  }
2749
2712
  }
2750
- | {
2751
- type: 'behavior action intends'
2752
- editor: PortableTextSlateEditor
2753
- actionIntends: Array<BehaviorActionIntend>
2754
- }
2755
2713
  | {
2756
2714
  type: 'update readOnly'
2757
2715
  readOnly: boolean
@@ -3040,11 +2998,6 @@ export declare const editorMachine: StateMachine<
3040
2998
  preventDefault: () => void
3041
2999
  }
3042
3000
  }
3043
- | {
3044
- type: 'behavior action intends'
3045
- editor: PortableTextSlateEditor
3046
- actionIntends: Array<BehaviorActionIntend>
3047
- }
3048
3001
  | {
3049
3002
  type: 'update readOnly'
3050
3003
  readOnly: boolean
@@ -3332,11 +3285,6 @@ export declare const editorMachine: StateMachine<
3332
3285
  preventDefault: () => void
3333
3286
  }
3334
3287
  }
3335
- | {
3336
- type: 'behavior action intends'
3337
- editor: PortableTextSlateEditor
3338
- actionIntends: Array<BehaviorActionIntend>
3339
- }
3340
3288
  | {
3341
3289
  type: 'update readOnly'
3342
3290
  readOnly: boolean
@@ -3623,11 +3571,6 @@ export declare const editorMachine: StateMachine<
3623
3571
  preventDefault: () => void
3624
3572
  }
3625
3573
  }
3626
- | {
3627
- type: 'behavior action intends'
3628
- editor: PortableTextSlateEditor
3629
- actionIntends: Array<BehaviorActionIntend>
3630
- }
3631
3574
  | {
3632
3575
  type: 'update readOnly'
3633
3576
  readOnly: boolean
@@ -3912,11 +3855,6 @@ export declare const editorMachine: StateMachine<
3912
3855
  preventDefault: () => void
3913
3856
  }
3914
3857
  }
3915
- | {
3916
- type: 'behavior action intends'
3917
- editor: PortableTextSlateEditor
3918
- actionIntends: Array<BehaviorActionIntend>
3919
- }
3920
3858
  | {
3921
3859
  type: 'update readOnly'
3922
3860
  readOnly: boolean
@@ -4203,11 +4141,6 @@ export declare const editorMachine: StateMachine<
4203
4141
  preventDefault: () => void
4204
4142
  }
4205
4143
  }
4206
- | {
4207
- type: 'behavior action intends'
4208
- editor: PortableTextSlateEditor
4209
- actionIntends: Array<BehaviorActionIntend>
4210
- }
4211
4144
  | {
4212
4145
  type: 'update readOnly'
4213
4146
  readOnly: boolean
@@ -4501,11 +4434,6 @@ export declare const editorMachine: StateMachine<
4501
4434
  preventDefault: () => void
4502
4435
  }
4503
4436
  }
4504
- | {
4505
- type: 'behavior action intends'
4506
- editor: PortableTextSlateEditor
4507
- actionIntends: Array<BehaviorActionIntend>
4508
- }
4509
4437
  | {
4510
4438
  type: 'update readOnly'
4511
4439
  readOnly: boolean
@@ -4676,11 +4604,6 @@ export declare const editorMachine: StateMachine<
4676
4604
  preventDefault: () => void
4677
4605
  }
4678
4606
  }
4679
- | {
4680
- type: 'behavior action intends'
4681
- editor: PortableTextSlateEditor
4682
- actionIntends: Array<BehaviorActionIntend>
4683
- }
4684
4607
  | {
4685
4608
  type: 'update readOnly'
4686
4609
  readOnly: boolean
@@ -4747,609 +4670,98 @@ export declare const editorMachine: StateMachine<
4747
4670
  never
4748
4671
  >
4749
4672
  }
4750
- readonly 'behavior action intends': {
4751
- readonly actions: readonly [
4752
- ({
4753
- context,
4754
- event,
4755
- }: ActionArgs<
4756
- {
4757
- behaviors: Array<Behavior>
4758
- keyGenerator: () => string
4759
- pendingEvents: Array<PatchEvent | MutationEvent_2>
4760
- schema: EditorSchema
4761
- initialReadOnly: boolean
4762
- maxBlocks: number | undefined
4763
- selection: EditorSelection
4764
- value: Array<PortableTextBlock> | undefined
4765
- },
4766
- {
4767
- type: 'behavior action intends'
4768
- editor: PortableTextSlateEditor
4769
- actionIntends: Array<BehaviorActionIntend>
4770
- },
4771
- | {
4772
- type: 'annotation.add'
4773
- annotation: {
4774
- name: string
4775
- value: {
4776
- [prop: string]: unknown
4777
- }
4778
- }
4779
- }
4780
- | {
4781
- type: 'annotation.remove'
4782
- annotation: {
4783
- name: string
4784
- }
4785
- }
4786
- | {
4787
- type: 'annotation.toggle'
4788
- annotation: {
4789
- name: string
4790
- value: {
4791
- [prop: string]: unknown
4792
- }
4673
+ }
4674
+ readonly type: 'parallel'
4675
+ readonly states: {
4676
+ readonly 'edit mode': {
4677
+ readonly initial: 'read only'
4678
+ readonly states: {
4679
+ readonly 'read only': {
4680
+ readonly initial: 'determine initial edit mode'
4681
+ readonly states: {
4682
+ readonly 'determine initial edit mode': {
4683
+ readonly on: {
4684
+ readonly 'done syncing initial value': readonly [
4685
+ {
4686
+ readonly target: '#editor.edit mode.read only.read only'
4687
+ readonly guard: ({
4688
+ context,
4689
+ }: GuardArgs<
4690
+ {
4691
+ behaviors: Array<Behavior>
4692
+ keyGenerator: () => string
4693
+ pendingEvents: Array<PatchEvent | MutationEvent_2>
4694
+ schema: EditorSchema
4695
+ initialReadOnly: boolean
4696
+ maxBlocks: number | undefined
4697
+ selection: EditorSelection
4698
+ value: Array<PortableTextBlock> | undefined
4699
+ },
4700
+ {
4701
+ type: 'done syncing initial value'
4702
+ }
4703
+ >) => boolean
4704
+ },
4705
+ {
4706
+ readonly target: '#editor.edit mode.editable'
4707
+ },
4708
+ ]
4793
4709
  }
4794
4710
  }
4795
- | {
4796
- type: 'blur'
4797
- }
4798
- | {
4799
- type: 'decorator.add'
4800
- decorator: string
4801
- }
4802
- | {
4803
- type: 'decorator.remove'
4804
- decorator: string
4805
- }
4806
- | {
4807
- type: 'decorator.toggle'
4808
- decorator: string
4809
- }
4810
- | {
4811
- type: 'focus'
4812
- }
4813
- | {
4814
- type: 'insert.block object'
4815
- placement: 'auto' | 'after' | 'before'
4816
- blockObject: {
4817
- name: string
4818
- value?: {
4819
- [prop: string]: unknown
4711
+ readonly 'read only': {
4712
+ readonly on: {
4713
+ readonly 'update readOnly': {
4714
+ readonly guard: ({
4715
+ event,
4716
+ }: GuardArgs<
4717
+ {
4718
+ behaviors: Array<Behavior>
4719
+ keyGenerator: () => string
4720
+ pendingEvents: Array<PatchEvent | MutationEvent_2>
4721
+ schema: EditorSchema
4722
+ initialReadOnly: boolean
4723
+ maxBlocks: number | undefined
4724
+ selection: EditorSelection
4725
+ value: Array<PortableTextBlock> | undefined
4726
+ },
4727
+ {
4728
+ type: 'update readOnly'
4729
+ readOnly: boolean
4730
+ }
4731
+ >) => boolean
4732
+ readonly target: '#editor.edit mode.editable'
4733
+ readonly actions: readonly ['emit editable']
4820
4734
  }
4821
4735
  }
4822
4736
  }
4823
- | {
4824
- type: 'insert.inline object'
4825
- inlineObject: {
4826
- name: string
4827
- value?: {
4828
- [prop: string]: unknown
4737
+ }
4738
+ }
4739
+ readonly 'editable': {
4740
+ readonly on: {
4741
+ readonly 'update readOnly': {
4742
+ readonly guard: ({
4743
+ event,
4744
+ }: GuardArgs<
4745
+ {
4746
+ behaviors: Array<Behavior>
4747
+ keyGenerator: () => string
4748
+ pendingEvents: Array<PatchEvent | MutationEvent_2>
4749
+ schema: EditorSchema
4750
+ initialReadOnly: boolean
4751
+ maxBlocks: number | undefined
4752
+ selection: EditorSelection
4753
+ value: Array<PortableTextBlock> | undefined
4754
+ },
4755
+ {
4756
+ type: 'update readOnly'
4757
+ readOnly: boolean
4829
4758
  }
4830
- }
4831
- }
4832
- | {
4833
- type: 'list item.toggle'
4834
- listItem: string
4835
- }
4836
- | {
4837
- type: 'style.toggle'
4838
- style: string
4839
- }
4840
- | PatchEvent
4841
- | MutationEvent_2
4842
- | {
4843
- type: 'normalizing'
4844
- }
4845
- | {
4846
- type: 'done normalizing'
4759
+ >) => boolean
4760
+ readonly target: '#editor.edit mode.read only.read only'
4761
+ readonly actions: readonly ['emit read only']
4847
4762
  }
4848
- | {
4849
- type: 'done syncing initial value'
4850
- }
4851
- | {
4852
- type: 'behavior event'
4853
- behaviorEvent: SyntheticBehaviorEvent | NativeBehaviorEvent
4854
- editor: PortableTextSlateEditor
4855
- nativeEvent?: {
4856
- preventDefault: () => void
4857
- }
4858
- }
4859
- | {
4860
- type: 'behavior action intends'
4861
- editor: PortableTextSlateEditor
4862
- actionIntends: Array<BehaviorActionIntend>
4863
- }
4864
- | {
4865
- type: 'update readOnly'
4866
- readOnly: boolean
4867
- }
4868
- | {
4869
- type: 'update schema'
4870
- schema: EditorSchema
4871
- }
4872
- | {
4873
- type: 'update behaviors'
4874
- behaviors: Array<Behavior>
4875
- }
4876
- | {
4877
- type: 'update value'
4878
- value: Array<PortableTextBlock> | undefined
4879
- }
4880
- | {
4881
- type: 'update maxBlocks'
4882
- maxBlocks: number | undefined
4883
- }
4884
- | PatchesEvent
4885
- | {
4886
- type: 'unset'
4887
- previousValue: Array<PortableTextBlock>
4888
- }
4889
- | {
4890
- type: 'value changed'
4891
- value: Array<PortableTextBlock> | undefined
4892
- }
4893
- | {
4894
- type: 'invalid value'
4895
- resolution: InvalidValueResolution | null
4896
- value: Array<PortableTextBlock> | undefined
4897
- }
4898
- | {
4899
- type: 'error'
4900
- name: string
4901
- description: string
4902
- data: unknown
4903
- }
4904
- | {
4905
- type: 'selection'
4906
- selection: EditorSelection
4907
- }
4908
- | {
4909
- type: 'blurred'
4910
- event: FocusEvent_2<HTMLDivElement, Element>
4911
- }
4912
- | {
4913
- type: 'focused'
4914
- event: FocusEvent_2<HTMLDivElement, Element>
4915
- }
4916
- | {
4917
- type: 'loading'
4918
- }
4919
- | {
4920
- type: 'done loading'
4921
- }
4922
- >) => void,
4923
- ActionFunction<
4924
- {
4925
- behaviors: Array<Behavior>
4926
- keyGenerator: () => string
4927
- pendingEvents: Array<PatchEvent | MutationEvent_2>
4928
- schema: EditorSchema
4929
- initialReadOnly: boolean
4930
- maxBlocks: number | undefined
4931
- selection: EditorSelection
4932
- value: Array<PortableTextBlock> | undefined
4933
- },
4934
- {
4935
- type: 'behavior action intends'
4936
- editor: PortableTextSlateEditor
4937
- actionIntends: Array<BehaviorActionIntend>
4938
- },
4939
- | {
4940
- type: 'annotation.add'
4941
- annotation: {
4942
- name: string
4943
- value: {
4944
- [prop: string]: unknown
4945
- }
4946
- }
4947
- }
4948
- | {
4949
- type: 'annotation.remove'
4950
- annotation: {
4951
- name: string
4952
- }
4953
- }
4954
- | {
4955
- type: 'annotation.toggle'
4956
- annotation: {
4957
- name: string
4958
- value: {
4959
- [prop: string]: unknown
4960
- }
4961
- }
4962
- }
4963
- | {
4964
- type: 'blur'
4965
- }
4966
- | {
4967
- type: 'decorator.add'
4968
- decorator: string
4969
- }
4970
- | {
4971
- type: 'decorator.remove'
4972
- decorator: string
4973
- }
4974
- | {
4975
- type: 'decorator.toggle'
4976
- decorator: string
4977
- }
4978
- | {
4979
- type: 'focus'
4980
- }
4981
- | {
4982
- type: 'insert.block object'
4983
- placement: 'auto' | 'after' | 'before'
4984
- blockObject: {
4985
- name: string
4986
- value?: {
4987
- [prop: string]: unknown
4988
- }
4989
- }
4990
- }
4991
- | {
4992
- type: 'insert.inline object'
4993
- inlineObject: {
4994
- name: string
4995
- value?: {
4996
- [prop: string]: unknown
4997
- }
4998
- }
4999
- }
5000
- | {
5001
- type: 'list item.toggle'
5002
- listItem: string
5003
- }
5004
- | {
5005
- type: 'style.toggle'
5006
- style: string
5007
- }
5008
- | PatchEvent
5009
- | MutationEvent_2
5010
- | {
5011
- type: 'normalizing'
5012
- }
5013
- | {
5014
- type: 'done normalizing'
5015
- }
5016
- | {
5017
- type: 'done syncing initial value'
5018
- }
5019
- | {
5020
- type: 'behavior event'
5021
- behaviorEvent: SyntheticBehaviorEvent | NativeBehaviorEvent
5022
- editor: PortableTextSlateEditor
5023
- nativeEvent?: {
5024
- preventDefault: () => void
5025
- }
5026
- }
5027
- | {
5028
- type: 'behavior action intends'
5029
- editor: PortableTextSlateEditor
5030
- actionIntends: Array<BehaviorActionIntend>
5031
- }
5032
- | {
5033
- type: 'update readOnly'
5034
- readOnly: boolean
5035
- }
5036
- | {
5037
- type: 'update schema'
5038
- schema: EditorSchema
5039
- }
5040
- | {
5041
- type: 'update behaviors'
5042
- behaviors: Array<Behavior>
5043
- }
5044
- | {
5045
- type: 'update value'
5046
- value: Array<PortableTextBlock> | undefined
5047
- }
5048
- | {
5049
- type: 'update maxBlocks'
5050
- maxBlocks: number | undefined
5051
- }
5052
- | PatchesEvent
5053
- | {
5054
- type: 'unset'
5055
- previousValue: Array<PortableTextBlock>
5056
- }
5057
- | {
5058
- type: 'value changed'
5059
- value: Array<PortableTextBlock> | undefined
5060
- }
5061
- | {
5062
- type: 'invalid value'
5063
- resolution: InvalidValueResolution | null
5064
- value: Array<PortableTextBlock> | undefined
5065
- }
5066
- | {
5067
- type: 'error'
5068
- name: string
5069
- description: string
5070
- data: unknown
5071
- }
5072
- | {
5073
- type: 'selection'
5074
- selection: EditorSelection
5075
- }
5076
- | {
5077
- type: 'blurred'
5078
- event: FocusEvent_2<HTMLDivElement, Element>
5079
- }
5080
- | {
5081
- type: 'focused'
5082
- event: FocusEvent_2<HTMLDivElement, Element>
5083
- }
5084
- | {
5085
- type: 'loading'
5086
- }
5087
- | {
5088
- type: 'done loading'
5089
- },
5090
- undefined,
5091
- never,
5092
- Values<{
5093
- 'assign behaviors': {
5094
- type: 'assign behaviors'
5095
- params: NonReducibleUnknown
5096
- }
5097
- 'assign schema': {
5098
- type: 'assign schema'
5099
- params: NonReducibleUnknown
5100
- }
5101
- 'emit patch event': {
5102
- type: 'emit patch event'
5103
- params: NonReducibleUnknown
5104
- }
5105
- 'emit mutation event': {
5106
- type: 'emit mutation event'
5107
- params: NonReducibleUnknown
5108
- }
5109
- 'emit read only': {
5110
- type: 'emit read only'
5111
- params: NonReducibleUnknown
5112
- }
5113
- 'emit editable': {
5114
- type: 'emit editable'
5115
- params: NonReducibleUnknown
5116
- }
5117
- 'defer event': {
5118
- type: 'defer event'
5119
- params: NonReducibleUnknown
5120
- }
5121
- 'emit pending events': {
5122
- type: 'emit pending events'
5123
- params: NonReducibleUnknown
5124
- }
5125
- 'emit ready': {
5126
- type: 'emit ready'
5127
- params: NonReducibleUnknown
5128
- }
5129
- 'clear pending events': {
5130
- type: 'clear pending events'
5131
- params: NonReducibleUnknown
5132
- }
5133
- 'handle behavior event': {
5134
- type: 'handle behavior event'
5135
- params: NonReducibleUnknown
5136
- }
5137
- }>,
5138
- never,
5139
- never,
5140
- | {
5141
- type: 'annotation.add'
5142
- annotation: {
5143
- name: string
5144
- value: {
5145
- [prop: string]: unknown
5146
- }
5147
- }
5148
- }
5149
- | {
5150
- type: 'annotation.remove'
5151
- annotation: {
5152
- name: string
5153
- }
5154
- }
5155
- | {
5156
- type: 'annotation.toggle'
5157
- annotation: {
5158
- name: string
5159
- value: {
5160
- [prop: string]: unknown
5161
- }
5162
- }
5163
- }
5164
- | {
5165
- type: 'blur'
5166
- }
5167
- | {
5168
- type: 'decorator.add'
5169
- decorator: string
5170
- }
5171
- | {
5172
- type: 'decorator.remove'
5173
- decorator: string
5174
- }
5175
- | {
5176
- type: 'decorator.toggle'
5177
- decorator: string
5178
- }
5179
- | {
5180
- type: 'focus'
5181
- }
5182
- | {
5183
- type: 'insert.block object'
5184
- placement: 'auto' | 'after' | 'before'
5185
- blockObject: {
5186
- name: string
5187
- value?: {
5188
- [prop: string]: unknown
5189
- }
5190
- }
5191
- }
5192
- | {
5193
- type: 'insert.inline object'
5194
- inlineObject: {
5195
- name: string
5196
- value?: {
5197
- [prop: string]: unknown
5198
- }
5199
- }
5200
- }
5201
- | {
5202
- type: 'list item.toggle'
5203
- listItem: string
5204
- }
5205
- | {
5206
- type: 'style.toggle'
5207
- style: string
5208
- }
5209
- | PatchEvent
5210
- | MutationEvent_2
5211
- | {
5212
- type: 'ready'
5213
- }
5214
- | PatchesEvent
5215
- | {
5216
- type: 'unset'
5217
- previousValue: Array<PortableTextBlock>
5218
- }
5219
- | {
5220
- type: 'value changed'
5221
- value: Array<PortableTextBlock> | undefined
5222
- }
5223
- | {
5224
- type: 'invalid value'
5225
- resolution: InvalidValueResolution | null
5226
- value: Array<PortableTextBlock> | undefined
5227
- }
5228
- | {
5229
- type: 'error'
5230
- name: string
5231
- description: string
5232
- data: unknown
5233
- }
5234
- | {
5235
- type: 'selection'
5236
- selection: EditorSelection
5237
- }
5238
- | {
5239
- type: 'blurred'
5240
- event: FocusEvent_2<HTMLDivElement, Element>
5241
- }
5242
- | {
5243
- type: 'focused'
5244
- event: FocusEvent_2<HTMLDivElement, Element>
5245
- }
5246
- | {
5247
- type: 'loading'
5248
- }
5249
- | {
5250
- type: 'done loading'
5251
- }
5252
- | {
5253
- type: 'read only'
5254
- }
5255
- | {
5256
- type: 'editable'
5257
- }
5258
- >,
5259
- ]
5260
- }
5261
- }
5262
- readonly type: 'parallel'
5263
- readonly states: {
5264
- readonly 'edit mode': {
5265
- readonly initial: 'read only'
5266
- readonly states: {
5267
- readonly 'read only': {
5268
- readonly initial: 'determine initial edit mode'
5269
- readonly states: {
5270
- readonly 'determine initial edit mode': {
5271
- readonly on: {
5272
- readonly 'done syncing initial value': readonly [
5273
- {
5274
- readonly target: '#editor.edit mode.read only.read only'
5275
- readonly guard: ({
5276
- context,
5277
- }: GuardArgs<
5278
- {
5279
- behaviors: Array<Behavior>
5280
- keyGenerator: () => string
5281
- pendingEvents: Array<PatchEvent | MutationEvent_2>
5282
- schema: EditorSchema
5283
- initialReadOnly: boolean
5284
- maxBlocks: number | undefined
5285
- selection: EditorSelection
5286
- value: Array<PortableTextBlock> | undefined
5287
- },
5288
- {
5289
- type: 'done syncing initial value'
5290
- }
5291
- >) => boolean
5292
- },
5293
- {
5294
- readonly target: '#editor.edit mode.editable'
5295
- },
5296
- ]
5297
- }
5298
- }
5299
- readonly 'read only': {
5300
- readonly on: {
5301
- readonly 'update readOnly': {
5302
- readonly guard: ({
5303
- event,
5304
- }: GuardArgs<
5305
- {
5306
- behaviors: Array<Behavior>
5307
- keyGenerator: () => string
5308
- pendingEvents: Array<PatchEvent | MutationEvent_2>
5309
- schema: EditorSchema
5310
- initialReadOnly: boolean
5311
- maxBlocks: number | undefined
5312
- selection: EditorSelection
5313
- value: Array<PortableTextBlock> | undefined
5314
- },
5315
- {
5316
- type: 'update readOnly'
5317
- readOnly: boolean
5318
- }
5319
- >) => boolean
5320
- readonly target: '#editor.edit mode.editable'
5321
- readonly actions: readonly ['emit editable']
5322
- }
5323
- }
5324
- }
5325
- }
5326
- }
5327
- readonly 'editable': {
5328
- readonly on: {
5329
- readonly 'update readOnly': {
5330
- readonly guard: ({
5331
- event,
5332
- }: GuardArgs<
5333
- {
5334
- behaviors: Array<Behavior>
5335
- keyGenerator: () => string
5336
- pendingEvents: Array<PatchEvent | MutationEvent_2>
5337
- schema: EditorSchema
5338
- initialReadOnly: boolean
5339
- maxBlocks: number | undefined
5340
- selection: EditorSelection
5341
- value: Array<PortableTextBlock> | undefined
5342
- },
5343
- {
5344
- type: 'update readOnly'
5345
- readOnly: boolean
5346
- }
5347
- >) => boolean
5348
- readonly target: '#editor.edit mode.read only.read only'
5349
- readonly actions: readonly ['emit read only']
5350
- }
5351
- readonly 'behavior event': {
5352
- readonly actions: 'handle behavior event'
4763
+ readonly 'behavior event': {
4764
+ readonly actions: 'handle behavior event'
5353
4765
  }
5354
4766
  readonly 'annotation.add': {
5355
4767
  readonly actions: ActionFunction<
@@ -5462,11 +4874,6 @@ export declare const editorMachine: StateMachine<
5462
4874
  preventDefault: () => void
5463
4875
  }
5464
4876
  }
5465
- | {
5466
- type: 'behavior action intends'
5467
- editor: PortableTextSlateEditor
5468
- actionIntends: Array<BehaviorActionIntend>
5469
- }
5470
4877
  | {
5471
4878
  type: 'update readOnly'
5472
4879
  readOnly: boolean
@@ -5758,11 +5165,6 @@ export declare const editorMachine: StateMachine<
5758
5165
  preventDefault: () => void
5759
5166
  }
5760
5167
  }
5761
- | {
5762
- type: 'behavior action intends'
5763
- editor: PortableTextSlateEditor
5764
- actionIntends: Array<BehaviorActionIntend>
5765
- }
5766
5168
  | {
5767
5169
  type: 'update readOnly'
5768
5170
  readOnly: boolean
@@ -6057,11 +5459,6 @@ export declare const editorMachine: StateMachine<
6057
5459
  preventDefault: () => void
6058
5460
  }
6059
5461
  }
6060
- | {
6061
- type: 'behavior action intends'
6062
- editor: PortableTextSlateEditor
6063
- actionIntends: Array<BehaviorActionIntend>
6064
- }
6065
5462
  | {
6066
5463
  type: 'update readOnly'
6067
5464
  readOnly: boolean
@@ -6350,11 +5747,6 @@ export declare const editorMachine: StateMachine<
6350
5747
  preventDefault: () => void
6351
5748
  }
6352
5749
  }
6353
- | {
6354
- type: 'behavior action intends'
6355
- editor: PortableTextSlateEditor
6356
- actionIntends: Array<BehaviorActionIntend>
6357
- }
6358
5750
  | {
6359
5751
  type: 'update readOnly'
6360
5752
  readOnly: boolean
@@ -6652,11 +6044,6 @@ export declare const editorMachine: StateMachine<
6652
6044
  preventDefault: () => void
6653
6045
  }
6654
6046
  }
6655
- | {
6656
- type: 'behavior action intends'
6657
- editor: PortableTextSlateEditor
6658
- actionIntends: Array<BehaviorActionIntend>
6659
- }
6660
6047
  | {
6661
6048
  type: 'update readOnly'
6662
6049
  readOnly: boolean
@@ -6945,11 +6332,6 @@ export declare const editorMachine: StateMachine<
6945
6332
  preventDefault: () => void
6946
6333
  }
6947
6334
  }
6948
- | {
6949
- type: 'behavior action intends'
6950
- editor: PortableTextSlateEditor
6951
- actionIntends: Array<BehaviorActionIntend>
6952
- }
6953
6335
  | {
6954
6336
  type: 'update readOnly'
6955
6337
  readOnly: boolean
@@ -7254,11 +6636,6 @@ export declare const editorMachine: StateMachine<
7254
6636
  preventDefault: () => void
7255
6637
  }
7256
6638
  }
7257
- | {
7258
- type: 'behavior action intends'
7259
- editor: PortableTextSlateEditor
7260
- actionIntends: Array<BehaviorActionIntend>
7261
- }
7262
6639
  | {
7263
6640
  type: 'update readOnly'
7264
6641
  readOnly: boolean
@@ -7548,11 +6925,6 @@ export declare const editorMachine: StateMachine<
7548
6925
  preventDefault: () => void
7549
6926
  }
7550
6927
  }
7551
- | {
7552
- type: 'behavior action intends'
7553
- editor: PortableTextSlateEditor
7554
- actionIntends: Array<BehaviorActionIntend>
7555
- }
7556
6928
  | {
7557
6929
  type: 'update readOnly'
7558
6930
  readOnly: boolean
@@ -7842,11 +7214,6 @@ export declare const editorMachine: StateMachine<
7842
7214
  preventDefault: () => void
7843
7215
  }
7844
7216
  }
7845
- | {
7846
- type: 'behavior action intends'
7847
- editor: PortableTextSlateEditor
7848
- actionIntends: Array<BehaviorActionIntend>
7849
- }
7850
7217
  | {
7851
7218
  type: 'update readOnly'
7852
7219
  readOnly: boolean
@@ -8111,14 +7478,14 @@ export declare type EditorNode = Node_2 & {
8111
7478
  }
8112
7479
 
8113
7480
  /**
8114
- * @alpha
7481
+ * @public
8115
7482
  */
8116
7483
  export declare function EditorProvider(
8117
7484
  props: EditorProviderProps,
8118
7485
  ): React_2.JSX.Element
8119
7486
 
8120
7487
  /**
8121
- * @alpha
7488
+ * @public
8122
7489
  */
8123
7490
  export declare type EditorProviderProps = {
8124
7491
  initialConfig: EditorConfig
@@ -8126,32 +7493,32 @@ export declare type EditorProviderProps = {
8126
7493
  }
8127
7494
 
8128
7495
  /**
8129
- * @alpha
7496
+ * @public
8130
7497
  */
8131
7498
  export declare type EditorSchema = PortableTextMemberSchemaTypes
8132
7499
 
8133
- /** @beta */
7500
+ /** @public */
8134
7501
  export declare type EditorSelection = {
8135
7502
  anchor: EditorSelectionPoint
8136
7503
  focus: EditorSelectionPoint
8137
7504
  backward?: boolean
8138
7505
  } | null
8139
7506
 
8140
- /** @beta */
7507
+ /** @public */
8141
7508
  export declare type EditorSelectionPoint = {
8142
7509
  path: Path
8143
7510
  offset: number
8144
7511
  }
8145
7512
 
8146
7513
  /**
8147
- * @alpha
7514
+ * @public
8148
7515
  */
8149
7516
  export declare type EditorSelector<TSelected> = (
8150
7517
  snapshot: EditorSnapshot,
8151
7518
  ) => TSelected
8152
7519
 
8153
7520
  /**
8154
- * @alpha
7521
+ * @public
8155
7522
  */
8156
7523
  export declare type EditorSnapshot = {
8157
7524
  context: EditorContext
@@ -8291,11 +7658,6 @@ export declare type InternalEditorEvent =
8291
7658
  preventDefault: () => void
8292
7659
  }
8293
7660
  }
8294
- | {
8295
- type: 'behavior action intends'
8296
- editor: PortableTextSlateEditor
8297
- actionIntends: Array<BehaviorActionIntend>
8298
- }
8299
7661
  | {
8300
7662
  type: 'update readOnly'
8301
7663
  readOnly: boolean
@@ -8383,12 +7745,16 @@ export declare type MutationChange = {
8383
7745
  declare type MutationEvent_2 = {
8384
7746
  type: 'mutation'
8385
7747
  patches: Array<Patch>
7748
+ /**
7749
+ * @deprecated Use `value` instead
7750
+ */
8386
7751
  snapshot: Array<PortableTextBlock> | undefined
7752
+ value: Array<PortableTextBlock> | undefined
8387
7753
  }
8388
7754
  export {MutationEvent_2 as MutationEvent}
8389
7755
 
8390
7756
  /**
8391
- * @alpha
7757
+ * @beta
8392
7758
  */
8393
7759
  export declare type NativeBehaviorEvent =
8394
7760
  | {
@@ -8544,6 +7910,7 @@ export declare type PortableTextEditableProps = Omit<
8544
7910
  /**
8545
7911
  * The main Portable Text Editor component.
8546
7912
  * @public
7913
+ * @deprecated Use `EditorProvider` instead
8547
7914
  */
8548
7915
  export declare class PortableTextEditor extends Component<
8549
7916
  PortableTextEditorProps<Editor | undefined>
@@ -8689,6 +8056,7 @@ export declare class PortableTextEditor extends Component<
8689
8056
  * Props for the PortableTextEditor component
8690
8057
  *
8691
8058
  * @public
8059
+ * @deprecated Use `EditorProvider` instead
8692
8060
  */
8693
8061
  export declare type PortableTextEditorProps<
8694
8062
  TEditor extends Editor | undefined = undefined,
@@ -8892,7 +8260,7 @@ export declare type RenderStyleFunction = (
8892
8260
  ) => JSX.Element
8893
8261
 
8894
8262
  /**
8895
- * @alpha
8263
+ * @public
8896
8264
  */
8897
8265
  export declare type SchemaDefinition<
8898
8266
  TBaseDefinition extends BaseDefinition = BaseDefinition,
@@ -8928,7 +8296,7 @@ export declare type SlateEditor = {
8928
8296
  }
8929
8297
 
8930
8298
  /**
8931
- * @alpha
8299
+ * @beta
8932
8300
  */
8933
8301
  export declare type SyntheticBehaviorEvent =
8934
8302
  | {
@@ -9036,12 +8404,12 @@ export declare type UnsetChange = {
9036
8404
  }
9037
8405
 
9038
8406
  /**
9039
- * @alpha
8407
+ * @public
9040
8408
  */
9041
8409
  export declare function useEditor(): Editor
9042
8410
 
9043
8411
  /**
9044
- * @alpha
8412
+ * @public
9045
8413
  */
9046
8414
  export declare function useEditorSelector<TSelected>(
9047
8415
  editor: Editor,
@@ -9050,12 +8418,14 @@ export declare function useEditorSelector<TSelected>(
9050
8418
  ): TSelected
9051
8419
 
9052
8420
  /**
8421
+ * @deprecated Use `useEditor` to get the current editor instance.
9053
8422
  * @public
9054
8423
  * Get the current editor object from the React context.
9055
8424
  */
9056
8425
  export declare const usePortableTextEditor: () => PortableTextEditor
9057
8426
 
9058
8427
  /**
8428
+ * @deprecated Use `useEditorSelector` to get the current editor selection.
9059
8429
  * @public
9060
8430
  * Get the current editor selection from the React context.
9061
8431
  */