@portabletext/editor 1.10.2 → 1.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.
package/lib/index.d.mts CHANGED
@@ -32,6 +32,7 @@ import {
32
32
  JSX as JSX_2,
33
33
  MutableRefObject,
34
34
  PropsWithChildren,
35
+ default as React_2,
35
36
  RefAttributes,
36
37
  TextareaHTMLAttributes,
37
38
  } from 'react'
@@ -50,10 +51,12 @@ import {
50
51
  AnyActorLogic,
51
52
  AnyActorRef,
52
53
  AnyEventObject,
54
+ EventObject,
53
55
  InputFrom,
54
56
  MachineSnapshot,
55
57
  MetaObject,
56
58
  NonReducibleUnknown,
59
+ Snapshot,
57
60
  StateMachine,
58
61
  StateValue,
59
62
  Values,
@@ -703,8 +706,8 @@ export declare interface EditableAPIDeleteOptions {
703
706
  */
704
707
  export declare type Editor = {
705
708
  send: (event: EditorEvent) => void
706
- on: EditorActor['on']
707
- readOnly: boolean
709
+ on: ActorRef<Snapshot<unknown>, EventObject, EditorEmittedEvent>['on']
710
+ editable: EditableAPI
708
711
  _internal: {
709
712
  editorActor: EditorActor
710
713
  slateEditor: SlateEditor
@@ -746,6 +749,8 @@ export declare type EditorChanges = Subject<EditorChange>
746
749
  export declare type EditorConfig = {
747
750
  behaviors?: Array<Behavior>
748
751
  keyGenerator?: () => string
752
+ maxBlocks?: number
753
+ readOnly?: boolean
749
754
  initialValue?: Array<PortableTextBlock>
750
755
  } & (
751
756
  | {
@@ -758,6 +763,26 @@ export declare type EditorConfig = {
758
763
  }
759
764
  )
760
765
 
766
+ /**
767
+ * @alpha
768
+ */
769
+ export declare type EditorEmittedEvent = PickFromUnion<
770
+ InternalEditorEmittedEvent,
771
+ 'type',
772
+ | 'blur'
773
+ | 'done loading'
774
+ | 'error'
775
+ | 'focus'
776
+ | 'invalid value'
777
+ | 'loading'
778
+ | 'mutation'
779
+ | 'patch'
780
+ | 'readOnly toggled'
781
+ | 'ready'
782
+ | 'selection'
783
+ | 'value changed'
784
+ >
785
+
761
786
  /**
762
787
  * @alpha
763
788
  */
@@ -772,6 +797,13 @@ export declare type EditorEvent = PickFromUnion<
772
797
  | 'update value'
773
798
  >
774
799
 
800
+ /**
801
+ * @alpha
802
+ */
803
+ export declare function EditorEventListener(props: {
804
+ on: (event: EditorEmittedEvent) => void
805
+ }): null
806
+
775
807
  /**
776
808
  * @internal
777
809
  */
@@ -936,6 +968,8 @@ export declare const editorMachine: StateMachine<
936
968
  {
937
969
  behaviors?: Array<Behavior>
938
970
  keyGenerator: () => string
971
+ maxBlocks?: number
972
+ readOnly?: boolean
939
973
  schema: PortableTextMemberSchemaTypes
940
974
  value?: Array<PortableTextBlock>
941
975
  },
@@ -1009,6 +1043,10 @@ export declare const editorMachine: StateMachine<
1009
1043
  }
1010
1044
  | {
1011
1045
  type: 'done loading'
1046
+ }
1047
+ | {
1048
+ type: 'readOnly toggled'
1049
+ readOnly: boolean
1012
1050
  },
1013
1051
  MetaObject,
1014
1052
  {
@@ -1036,6 +1074,8 @@ export declare const editorMachine: StateMachine<
1036
1074
  input: {
1037
1075
  behaviors?: Array<Behavior>
1038
1076
  keyGenerator: () => string
1077
+ maxBlocks?: number
1078
+ readOnly?: boolean
1039
1079
  schema: PortableTextMemberSchemaTypes
1040
1080
  value?: Array<PortableTextBlock>
1041
1081
  }
@@ -1274,8 +1314,8 @@ export declare const editorMachine: StateMachine<
1274
1314
  keyGenerator: () => string
1275
1315
  pendingEvents: never[]
1276
1316
  schema: PortableTextMemberSchemaTypes
1277
- readOnly: false
1278
- maxBlocks: undefined
1317
+ readOnly: boolean
1318
+ maxBlocks: number | undefined
1279
1319
  value: PortableTextBlock[] | undefined
1280
1320
  }
1281
1321
  readonly on: {
@@ -1479,6 +1519,10 @@ export declare const editorMachine: StateMachine<
1479
1519
  | {
1480
1520
  type: 'done loading'
1481
1521
  }
1522
+ | {
1523
+ type: 'readOnly toggled'
1524
+ readOnly: boolean
1525
+ }
1482
1526
  >
1483
1527
  readonly guard: ({
1484
1528
  context,
@@ -1700,6 +1744,10 @@ export declare const editorMachine: StateMachine<
1700
1744
  | {
1701
1745
  type: 'done loading'
1702
1746
  }
1747
+ | {
1748
+ type: 'readOnly toggled'
1749
+ readOnly: boolean
1750
+ }
1703
1751
  >
1704
1752
  readonly guard: ({
1705
1753
  context,
@@ -1921,6 +1969,10 @@ export declare const editorMachine: StateMachine<
1921
1969
  | {
1922
1970
  type: 'done loading'
1923
1971
  }
1972
+ | {
1973
+ type: 'readOnly toggled'
1974
+ readOnly: boolean
1975
+ }
1924
1976
  >
1925
1977
  readonly guard: ({
1926
1978
  context,
@@ -2139,6 +2191,10 @@ export declare const editorMachine: StateMachine<
2139
2191
  | {
2140
2192
  type: 'done loading'
2141
2193
  }
2194
+ | {
2195
+ type: 'readOnly toggled'
2196
+ readOnly: boolean
2197
+ }
2142
2198
  >
2143
2199
  readonly guard: ({
2144
2200
  context,
@@ -2351,6 +2407,10 @@ export declare const editorMachine: StateMachine<
2351
2407
  | {
2352
2408
  type: 'done loading'
2353
2409
  }
2410
+ | {
2411
+ type: 'readOnly toggled'
2412
+ readOnly: boolean
2413
+ }
2354
2414
  >
2355
2415
  }
2356
2416
  readonly 'unset': {
@@ -2548,6 +2608,10 @@ export declare const editorMachine: StateMachine<
2548
2608
  | {
2549
2609
  type: 'done loading'
2550
2610
  }
2611
+ | {
2612
+ type: 'readOnly toggled'
2613
+ readOnly: boolean
2614
+ }
2551
2615
  >
2552
2616
  }
2553
2617
  readonly 'value changed': {
@@ -2745,6 +2809,10 @@ export declare const editorMachine: StateMachine<
2745
2809
  | {
2746
2810
  type: 'done loading'
2747
2811
  }
2812
+ | {
2813
+ type: 'readOnly toggled'
2814
+ readOnly: boolean
2815
+ }
2748
2816
  >
2749
2817
  }
2750
2818
  readonly 'invalid value': {
@@ -2943,6 +3011,10 @@ export declare const editorMachine: StateMachine<
2943
3011
  | {
2944
3012
  type: 'done loading'
2945
3013
  }
3014
+ | {
3015
+ type: 'readOnly toggled'
3016
+ readOnly: boolean
3017
+ }
2946
3018
  >
2947
3019
  }
2948
3020
  readonly 'error': {
@@ -3142,6 +3214,10 @@ export declare const editorMachine: StateMachine<
3142
3214
  | {
3143
3215
  type: 'done loading'
3144
3216
  }
3217
+ | {
3218
+ type: 'readOnly toggled'
3219
+ readOnly: boolean
3220
+ }
3145
3221
  >
3146
3222
  }
3147
3223
  readonly 'selection': {
@@ -3339,6 +3415,10 @@ export declare const editorMachine: StateMachine<
3339
3415
  | {
3340
3416
  type: 'done loading'
3341
3417
  }
3418
+ | {
3419
+ type: 'readOnly toggled'
3420
+ readOnly: boolean
3421
+ }
3342
3422
  >
3343
3423
  }
3344
3424
  readonly 'blur': {
@@ -3536,6 +3616,10 @@ export declare const editorMachine: StateMachine<
3536
3616
  | {
3537
3617
  type: 'done loading'
3538
3618
  }
3619
+ | {
3620
+ type: 'readOnly toggled'
3621
+ readOnly: boolean
3622
+ }
3539
3623
  >
3540
3624
  }
3541
3625
  readonly 'focused': {
@@ -3733,6 +3817,10 @@ export declare const editorMachine: StateMachine<
3733
3817
  | {
3734
3818
  type: 'done loading'
3735
3819
  }
3820
+ | {
3821
+ type: 'readOnly toggled'
3822
+ readOnly: boolean
3823
+ }
3736
3824
  >
3737
3825
  }
3738
3826
  readonly 'loading': {
@@ -3929,6 +4017,10 @@ export declare const editorMachine: StateMachine<
3929
4017
  | {
3930
4018
  type: 'done loading'
3931
4019
  }
4020
+ | {
4021
+ type: 'readOnly toggled'
4022
+ readOnly: boolean
4023
+ }
3932
4024
  >
3933
4025
  }
3934
4026
  readonly 'patches': {
@@ -4123,6 +4215,10 @@ export declare const editorMachine: StateMachine<
4123
4215
  | {
4124
4216
  type: 'done loading'
4125
4217
  }
4218
+ | {
4219
+ type: 'readOnly toggled'
4220
+ readOnly: boolean
4221
+ }
4126
4222
  >
4127
4223
  }
4128
4224
  readonly 'done loading': {
@@ -4319,6 +4415,10 @@ export declare const editorMachine: StateMachine<
4319
4415
  | {
4320
4416
  type: 'done loading'
4321
4417
  }
4418
+ | {
4419
+ type: 'readOnly toggled'
4420
+ readOnly: boolean
4421
+ }
4322
4422
  >
4323
4423
  }
4324
4424
  readonly 'update behaviors': {
@@ -4456,181 +4556,381 @@ export declare const editorMachine: StateMachine<
4456
4556
  >
4457
4557
  }
4458
4558
  readonly 'toggle readOnly': {
4459
- readonly actions: ActionFunction<
4460
- {
4461
- behaviors: Array<Behavior>
4462
- keyGenerator: () => string
4463
- pendingEvents: Array<PatchEvent | MutationEvent_2>
4464
- schema: PortableTextMemberSchemaTypes
4465
- readOnly: boolean
4466
- maxBlocks: number | undefined
4467
- value: Array<PortableTextBlock> | undefined
4468
- },
4469
- {
4470
- type: 'toggle readOnly'
4471
- },
4472
- | {
4473
- type: 'annotation.add'
4474
- annotation: {
4475
- name: string
4476
- value: {
4477
- [prop: string]: unknown
4478
- }
4479
- }
4480
- }
4481
- | {
4482
- type: 'annotation.remove'
4483
- annotation: {
4484
- name: string
4485
- }
4486
- }
4487
- | {
4488
- type: 'annotation.toggle'
4489
- annotation: {
4490
- name: string
4491
- value: {
4492
- [prop: string]: unknown
4493
- }
4494
- }
4495
- }
4496
- | {
4497
- type: 'focus'
4498
- }
4499
- | PatchEvent
4500
- | MutationEvent_2
4501
- | {
4502
- type: 'normalizing'
4503
- }
4504
- | {
4505
- type: 'done normalizing'
4506
- }
4507
- | {
4508
- type: 'behavior event'
4509
- behaviorEvent: BehaviorEvent
4510
- editor: PortableTextSlateEditor
4511
- }
4512
- | {
4513
- type: 'behavior action intends'
4514
- editor: PortableTextSlateEditor
4515
- actionIntends: Array<BehaviorActionIntend>
4516
- }
4517
- | {
4518
- type: 'update schema'
4519
- schema: PortableTextMemberSchemaTypes
4520
- }
4521
- | {
4522
- type: 'update behaviors'
4559
+ readonly actions: readonly [
4560
+ ActionFunction<
4561
+ {
4523
4562
  behaviors: Array<Behavior>
4524
- }
4525
- | {
4526
- type: 'update value'
4527
- value: Array<PortableTextBlock> | undefined
4528
- }
4529
- | {
4530
- type: 'toggle readOnly'
4531
- }
4532
- | {
4533
- type: 'update maxBlocks'
4563
+ keyGenerator: () => string
4564
+ pendingEvents: Array<PatchEvent | MutationEvent_2>
4565
+ schema: PortableTextMemberSchemaTypes
4566
+ readOnly: boolean
4534
4567
  maxBlocks: number | undefined
4535
- }
4536
- | {
4537
- type: 'ready'
4538
- }
4539
- | PatchesEvent
4540
- | {
4541
- type: 'unset'
4542
- previousValue: Array<PortableTextBlock>
4543
- }
4544
- | {
4545
- type: 'value changed'
4546
- value: Array<PortableTextBlock> | undefined
4547
- }
4548
- | {
4549
- type: 'invalid value'
4550
- resolution: InvalidValueResolution | null
4551
4568
  value: Array<PortableTextBlock> | undefined
4552
- }
4553
- | {
4554
- type: 'error'
4555
- name: string
4556
- description: string
4557
- data: unknown
4558
- }
4559
- | {
4560
- type: 'selection'
4561
- selection: EditorSelection
4562
- }
4563
- | {
4564
- type: 'blur'
4565
- event: FocusEvent_2<HTMLDivElement, Element>
4566
- }
4567
- | {
4568
- type: 'focused'
4569
- event: FocusEvent_2<HTMLDivElement, Element>
4570
- }
4571
- | {
4572
- type: 'loading'
4573
- }
4574
- | {
4575
- type: 'done loading'
4576
4569
  },
4577
- undefined,
4578
- never,
4579
- never,
4580
- never,
4581
- never,
4582
- never
4583
- >
4584
- }
4585
- readonly 'update maxBlocks': {
4586
- readonly actions: ActionFunction<
4587
- {
4588
- behaviors: Array<Behavior>
4589
- keyGenerator: () => string
4590
- pendingEvents: Array<PatchEvent | MutationEvent_2>
4591
- schema: PortableTextMemberSchemaTypes
4592
- readOnly: boolean
4593
- maxBlocks: number | undefined
4594
- value: Array<PortableTextBlock> | undefined
4595
- },
4596
- {
4597
- type: 'update maxBlocks'
4598
- maxBlocks: number | undefined
4599
- },
4600
- | {
4601
- type: 'annotation.add'
4602
- annotation: {
4603
- name: string
4604
- value: {
4605
- [prop: string]: unknown
4570
+ {
4571
+ type: 'toggle readOnly'
4572
+ },
4573
+ | {
4574
+ type: 'annotation.add'
4575
+ annotation: {
4576
+ name: string
4577
+ value: {
4578
+ [prop: string]: unknown
4579
+ }
4606
4580
  }
4607
4581
  }
4608
- }
4609
- | {
4610
- type: 'annotation.remove'
4611
- annotation: {
4612
- name: string
4582
+ | {
4583
+ type: 'annotation.remove'
4584
+ annotation: {
4585
+ name: string
4586
+ }
4613
4587
  }
4614
- }
4615
- | {
4616
- type: 'annotation.toggle'
4617
- annotation: {
4618
- name: string
4619
- value: {
4620
- [prop: string]: unknown
4588
+ | {
4589
+ type: 'annotation.toggle'
4590
+ annotation: {
4591
+ name: string
4592
+ value: {
4593
+ [prop: string]: unknown
4594
+ }
4621
4595
  }
4622
4596
  }
4623
- }
4624
- | {
4625
- type: 'focus'
4626
- }
4627
- | PatchEvent
4628
- | MutationEvent_2
4629
- | {
4630
- type: 'normalizing'
4631
- }
4632
- | {
4633
- type: 'done normalizing'
4597
+ | {
4598
+ type: 'focus'
4599
+ }
4600
+ | PatchEvent
4601
+ | MutationEvent_2
4602
+ | {
4603
+ type: 'normalizing'
4604
+ }
4605
+ | {
4606
+ type: 'done normalizing'
4607
+ }
4608
+ | {
4609
+ type: 'behavior event'
4610
+ behaviorEvent: BehaviorEvent
4611
+ editor: PortableTextSlateEditor
4612
+ }
4613
+ | {
4614
+ type: 'behavior action intends'
4615
+ editor: PortableTextSlateEditor
4616
+ actionIntends: Array<BehaviorActionIntend>
4617
+ }
4618
+ | {
4619
+ type: 'update schema'
4620
+ schema: PortableTextMemberSchemaTypes
4621
+ }
4622
+ | {
4623
+ type: 'update behaviors'
4624
+ behaviors: Array<Behavior>
4625
+ }
4626
+ | {
4627
+ type: 'update value'
4628
+ value: Array<PortableTextBlock> | undefined
4629
+ }
4630
+ | {
4631
+ type: 'toggle readOnly'
4632
+ }
4633
+ | {
4634
+ type: 'update maxBlocks'
4635
+ maxBlocks: number | undefined
4636
+ }
4637
+ | {
4638
+ type: 'ready'
4639
+ }
4640
+ | PatchesEvent
4641
+ | {
4642
+ type: 'unset'
4643
+ previousValue: Array<PortableTextBlock>
4644
+ }
4645
+ | {
4646
+ type: 'value changed'
4647
+ value: Array<PortableTextBlock> | undefined
4648
+ }
4649
+ | {
4650
+ type: 'invalid value'
4651
+ resolution: InvalidValueResolution | null
4652
+ value: Array<PortableTextBlock> | undefined
4653
+ }
4654
+ | {
4655
+ type: 'error'
4656
+ name: string
4657
+ description: string
4658
+ data: unknown
4659
+ }
4660
+ | {
4661
+ type: 'selection'
4662
+ selection: EditorSelection
4663
+ }
4664
+ | {
4665
+ type: 'blur'
4666
+ event: FocusEvent_2<HTMLDivElement, Element>
4667
+ }
4668
+ | {
4669
+ type: 'focused'
4670
+ event: FocusEvent_2<HTMLDivElement, Element>
4671
+ }
4672
+ | {
4673
+ type: 'loading'
4674
+ }
4675
+ | {
4676
+ type: 'done loading'
4677
+ },
4678
+ undefined,
4679
+ never,
4680
+ never,
4681
+ never,
4682
+ never,
4683
+ never
4684
+ >,
4685
+ ActionFunction<
4686
+ {
4687
+ behaviors: Array<Behavior>
4688
+ keyGenerator: () => string
4689
+ pendingEvents: Array<PatchEvent | MutationEvent_2>
4690
+ schema: PortableTextMemberSchemaTypes
4691
+ readOnly: boolean
4692
+ maxBlocks: number | undefined
4693
+ value: Array<PortableTextBlock> | undefined
4694
+ },
4695
+ {
4696
+ type: 'toggle readOnly'
4697
+ },
4698
+ | {
4699
+ type: 'annotation.add'
4700
+ annotation: {
4701
+ name: string
4702
+ value: {
4703
+ [prop: string]: unknown
4704
+ }
4705
+ }
4706
+ }
4707
+ | {
4708
+ type: 'annotation.remove'
4709
+ annotation: {
4710
+ name: string
4711
+ }
4712
+ }
4713
+ | {
4714
+ type: 'annotation.toggle'
4715
+ annotation: {
4716
+ name: string
4717
+ value: {
4718
+ [prop: string]: unknown
4719
+ }
4720
+ }
4721
+ }
4722
+ | {
4723
+ type: 'focus'
4724
+ }
4725
+ | PatchEvent
4726
+ | MutationEvent_2
4727
+ | {
4728
+ type: 'normalizing'
4729
+ }
4730
+ | {
4731
+ type: 'done normalizing'
4732
+ }
4733
+ | {
4734
+ type: 'behavior event'
4735
+ behaviorEvent: BehaviorEvent
4736
+ editor: PortableTextSlateEditor
4737
+ }
4738
+ | {
4739
+ type: 'behavior action intends'
4740
+ editor: PortableTextSlateEditor
4741
+ actionIntends: Array<BehaviorActionIntend>
4742
+ }
4743
+ | {
4744
+ type: 'update schema'
4745
+ schema: PortableTextMemberSchemaTypes
4746
+ }
4747
+ | {
4748
+ type: 'update behaviors'
4749
+ behaviors: Array<Behavior>
4750
+ }
4751
+ | {
4752
+ type: 'update value'
4753
+ value: Array<PortableTextBlock> | undefined
4754
+ }
4755
+ | {
4756
+ type: 'toggle readOnly'
4757
+ }
4758
+ | {
4759
+ type: 'update maxBlocks'
4760
+ maxBlocks: number | undefined
4761
+ }
4762
+ | {
4763
+ type: 'ready'
4764
+ }
4765
+ | PatchesEvent
4766
+ | {
4767
+ type: 'unset'
4768
+ previousValue: Array<PortableTextBlock>
4769
+ }
4770
+ | {
4771
+ type: 'value changed'
4772
+ value: Array<PortableTextBlock> | undefined
4773
+ }
4774
+ | {
4775
+ type: 'invalid value'
4776
+ resolution: InvalidValueResolution | null
4777
+ value: Array<PortableTextBlock> | undefined
4778
+ }
4779
+ | {
4780
+ type: 'error'
4781
+ name: string
4782
+ description: string
4783
+ data: unknown
4784
+ }
4785
+ | {
4786
+ type: 'selection'
4787
+ selection: EditorSelection
4788
+ }
4789
+ | {
4790
+ type: 'blur'
4791
+ event: FocusEvent_2<HTMLDivElement, Element>
4792
+ }
4793
+ | {
4794
+ type: 'focused'
4795
+ event: FocusEvent_2<HTMLDivElement, Element>
4796
+ }
4797
+ | {
4798
+ type: 'loading'
4799
+ }
4800
+ | {
4801
+ type: 'done loading'
4802
+ },
4803
+ undefined,
4804
+ never,
4805
+ never,
4806
+ never,
4807
+ never,
4808
+ | {
4809
+ type: 'annotation.add'
4810
+ annotation: {
4811
+ name: string
4812
+ value: {
4813
+ [prop: string]: unknown
4814
+ }
4815
+ }
4816
+ }
4817
+ | {
4818
+ type: 'annotation.remove'
4819
+ annotation: {
4820
+ name: string
4821
+ }
4822
+ }
4823
+ | {
4824
+ type: 'annotation.toggle'
4825
+ annotation: {
4826
+ name: string
4827
+ value: {
4828
+ [prop: string]: unknown
4829
+ }
4830
+ }
4831
+ }
4832
+ | {
4833
+ type: 'focus'
4834
+ }
4835
+ | PatchEvent
4836
+ | MutationEvent_2
4837
+ | {
4838
+ type: 'ready'
4839
+ }
4840
+ | PatchesEvent
4841
+ | {
4842
+ type: 'unset'
4843
+ previousValue: Array<PortableTextBlock>
4844
+ }
4845
+ | {
4846
+ type: 'value changed'
4847
+ value: Array<PortableTextBlock> | undefined
4848
+ }
4849
+ | {
4850
+ type: 'invalid value'
4851
+ resolution: InvalidValueResolution | null
4852
+ value: Array<PortableTextBlock> | undefined
4853
+ }
4854
+ | {
4855
+ type: 'error'
4856
+ name: string
4857
+ description: string
4858
+ data: unknown
4859
+ }
4860
+ | {
4861
+ type: 'selection'
4862
+ selection: EditorSelection
4863
+ }
4864
+ | {
4865
+ type: 'blur'
4866
+ event: FocusEvent_2<HTMLDivElement, Element>
4867
+ }
4868
+ | {
4869
+ type: 'focused'
4870
+ event: FocusEvent_2<HTMLDivElement, Element>
4871
+ }
4872
+ | {
4873
+ type: 'loading'
4874
+ }
4875
+ | {
4876
+ type: 'done loading'
4877
+ }
4878
+ | {
4879
+ type: 'readOnly toggled'
4880
+ readOnly: boolean
4881
+ }
4882
+ >,
4883
+ ]
4884
+ }
4885
+ readonly 'update maxBlocks': {
4886
+ readonly actions: ActionFunction<
4887
+ {
4888
+ behaviors: Array<Behavior>
4889
+ keyGenerator: () => string
4890
+ pendingEvents: Array<PatchEvent | MutationEvent_2>
4891
+ schema: PortableTextMemberSchemaTypes
4892
+ readOnly: boolean
4893
+ maxBlocks: number | undefined
4894
+ value: Array<PortableTextBlock> | undefined
4895
+ },
4896
+ {
4897
+ type: 'update maxBlocks'
4898
+ maxBlocks: number | undefined
4899
+ },
4900
+ | {
4901
+ type: 'annotation.add'
4902
+ annotation: {
4903
+ name: string
4904
+ value: {
4905
+ [prop: string]: unknown
4906
+ }
4907
+ }
4908
+ }
4909
+ | {
4910
+ type: 'annotation.remove'
4911
+ annotation: {
4912
+ name: string
4913
+ }
4914
+ }
4915
+ | {
4916
+ type: 'annotation.toggle'
4917
+ annotation: {
4918
+ name: string
4919
+ value: {
4920
+ [prop: string]: unknown
4921
+ }
4922
+ }
4923
+ }
4924
+ | {
4925
+ type: 'focus'
4926
+ }
4927
+ | PatchEvent
4928
+ | MutationEvent_2
4929
+ | {
4930
+ type: 'normalizing'
4931
+ }
4932
+ | {
4933
+ type: 'done normalizing'
4634
4934
  }
4635
4935
  | {
4636
4936
  type: 'behavior event'
@@ -5085,6 +5385,10 @@ export declare const editorMachine: StateMachine<
5085
5385
  | {
5086
5386
  type: 'done loading'
5087
5387
  }
5388
+ | {
5389
+ type: 'readOnly toggled'
5390
+ readOnly: boolean
5391
+ }
5088
5392
  >,
5089
5393
  ]
5090
5394
  }
@@ -5145,6 +5449,21 @@ export declare type EditorNode = Node_2 & {
5145
5449
  _type: string
5146
5450
  }
5147
5451
 
5452
+ /**
5453
+ * @alpha
5454
+ */
5455
+ export declare function EditorProvider(
5456
+ props: EditorProviderProps,
5457
+ ): React_2.JSX.Element
5458
+
5459
+ /**
5460
+ * @alpha
5461
+ */
5462
+ export declare type EditorProviderProps = {
5463
+ config: EditorConfig
5464
+ children?: React_2.ReactNode
5465
+ }
5466
+
5148
5467
  /** @beta */
5149
5468
  export declare type EditorSelection = {
5150
5469
  anchor: EditorSelectionPoint
@@ -5248,6 +5567,10 @@ export declare type InternalEditorEmittedEvent =
5248
5567
  | {
5249
5568
  type: 'done loading'
5250
5569
  }
5570
+ | {
5571
+ type: 'readOnly toggled'
5572
+ readOnly: boolean
5573
+ }
5251
5574
  | PickFromUnion<
5252
5575
  BehaviorEvent,
5253
5576
  'type',
@@ -5293,7 +5616,7 @@ export declare type InternalEditorEvent =
5293
5616
  type: 'update maxBlocks'
5294
5617
  maxBlocks: number | undefined
5295
5618
  }
5296
- | InternalEditorEmittedEvent
5619
+ | OmitFromUnion<InternalEditorEmittedEvent, 'type', 'readOnly toggled'>
5297
5620
 
5298
5621
  /**
5299
5622
  * The editor has an invalid value
@@ -5407,6 +5730,15 @@ declare type MutationEvent_2 = {
5407
5730
  }
5408
5731
  export {MutationEvent_2 as MutationEvent}
5409
5732
 
5733
+ /**
5734
+ * @alpha
5735
+ */
5736
+ export declare type OmitFromUnion<
5737
+ TUnion,
5738
+ TTagKey extends keyof TUnion,
5739
+ TOmittedTags extends TUnion[TTagKey],
5740
+ > = TUnion extends Record<TTagKey, TOmittedTags> ? never : TUnion
5741
+
5410
5742
  /** @beta */
5411
5743
  export declare type OnBeforeInputFn = (event: InputEvent) => void
5412
5744
 
@@ -5542,15 +5874,13 @@ export declare class PortableTextEditor extends Component<
5542
5874
  */
5543
5875
  schemaTypes: PortableTextMemberSchemaTypes
5544
5876
  /**
5545
- * The editor API (currently implemented with Slate).
5877
+ * The editor instance
5546
5878
  */
5547
- private editable?
5548
- private editorActor
5549
- private slateEditor
5879
+ private editor
5880
+ private editable
5550
5881
  constructor(props: PortableTextEditorProps)
5551
5882
  componentDidUpdate(prevProps: PortableTextEditorProps): void
5552
5883
  setEditable: (editable: EditableAPI) => void
5553
- private getValue
5554
5884
  render(): JSX_2.Element
5555
5885
  static activeAnnotations: (editor: PortableTextEditor) => PortableTextObject[]
5556
5886
  static isAnnotationActive: (
@@ -5573,7 +5903,7 @@ export declare class PortableTextEditor extends Component<
5573
5903
  editor: PortableTextEditor,
5574
5904
  selection: EditorSelection,
5575
5905
  options?: EditableAPIDeleteOptions,
5576
- ) => void | undefined
5906
+ ) => void
5577
5907
  static findDOMNode: (
5578
5908
  editor: PortableTextEditor,
5579
5909
  element: PortableTextBlock | PortableTextChild,
@@ -5581,17 +5911,15 @@ export declare class PortableTextEditor extends Component<
5581
5911
  static findByPath: (
5582
5912
  editor: PortableTextEditor,
5583
5913
  path: Path,
5584
- ) =>
5585
- | []
5586
- | [
5587
- (
5588
- | PortableTextTextBlock<PortableTextObject | PortableTextSpan>
5589
- | PortableTextObject
5590
- | PortableTextSpan
5591
- | undefined
5592
- ),
5593
- Path | undefined,
5594
- ]
5914
+ ) => [
5915
+ (
5916
+ | PortableTextTextBlock<PortableTextObject | PortableTextSpan>
5917
+ | PortableTextObject
5918
+ | PortableTextSpan
5919
+ | undefined
5920
+ ),
5921
+ Path | undefined,
5922
+ ]
5595
5923
  static focus: (editor: PortableTextEditor) => void
5596
5924
  static focusBlock: (
5597
5925
  editor: PortableTextEditor,
@@ -5606,21 +5934,14 @@ export declare class PortableTextEditor extends Component<
5606
5934
  static hasBlockStyle: (
5607
5935
  editor: PortableTextEditor,
5608
5936
  blockStyle: string,
5609
- ) => boolean | undefined
5937
+ ) => boolean
5610
5938
  static hasListStyle: (
5611
5939
  editor: PortableTextEditor,
5612
5940
  listStyle: string,
5613
- ) => boolean | undefined
5614
- static isCollapsedSelection: (
5615
- editor: PortableTextEditor,
5616
- ) => boolean | undefined
5617
- static isExpandedSelection: (
5618
- editor: PortableTextEditor,
5619
- ) => boolean | undefined
5620
- static isMarkActive: (
5621
- editor: PortableTextEditor,
5622
- mark: string,
5623
- ) => boolean | undefined
5941
+ ) => boolean
5942
+ static isCollapsedSelection: (editor: PortableTextEditor) => boolean
5943
+ static isExpandedSelection: (editor: PortableTextEditor) => boolean
5944
+ static isMarkActive: (editor: PortableTextEditor, mark: string) => boolean
5624
5945
  static insertChild: <
5625
5946
  TSchemaType extends {
5626
5947
  name: string
@@ -5647,9 +5968,9 @@ export declare class PortableTextEditor extends Component<
5647
5968
  static isVoid: (
5648
5969
  editor: PortableTextEditor,
5649
5970
  element: PortableTextBlock | PortableTextChild,
5650
- ) => boolean | undefined
5971
+ ) => boolean
5651
5972
  static isObjectPath: (_editor: PortableTextEditor, path: Path) => boolean
5652
- static marks: (editor: PortableTextEditor) => string[] | undefined
5973
+ static marks: (editor: PortableTextEditor) => string[]
5653
5974
  static select: (
5654
5975
  editor: PortableTextEditor,
5655
5976
  selection: EditorSelection | null,
@@ -5661,11 +5982,11 @@ export declare class PortableTextEditor extends Component<
5661
5982
  >(
5662
5983
  editor: PortableTextEditor,
5663
5984
  type: TSchemaType,
5664
- ) => void | undefined
5985
+ ) => void
5665
5986
  static toggleBlockStyle: (
5666
5987
  editor: PortableTextEditor,
5667
5988
  blockStyle: string,
5668
- ) => void | undefined
5989
+ ) => void
5669
5990
  static toggleList: (editor: PortableTextEditor, listStyle: string) => void
5670
5991
  static toggleMark: (editor: PortableTextEditor, mark: string) => void
5671
5992
  static getFragment: (
@@ -5677,7 +5998,7 @@ export declare class PortableTextEditor extends Component<
5677
5998
  editor: PortableTextEditor,
5678
5999
  selectionA: EditorSelection,
5679
6000
  selectionB: EditorSelection,
5680
- ) => boolean | undefined
6001
+ ) => boolean
5681
6002
  }
5682
6003
 
5683
6004
  /**
@@ -5755,7 +6076,6 @@ export declare type PortableTextMemberSchemaTypes = {
5755
6076
  export declare interface PortableTextSlateEditor extends ReactEditor {
5756
6077
  _key: 'editor'
5757
6078
  _type: 'editor'
5758
- destroy: () => void
5759
6079
  createPlaceholderBlock: () => Descendant
5760
6080
  editable: EditableAPI
5761
6081
  history: History_2
@@ -5995,6 +6315,11 @@ export declare type UnsetChange = {
5995
6315
  */
5996
6316
  export declare function useEditor(config: EditorConfig): Editor
5997
6317
 
6318
+ /**
6319
+ * @alpha
6320
+ */
6321
+ export declare function useEditorContext(): Editor
6322
+
5998
6323
  /**
5999
6324
  * @public
6000
6325
  * Get the current editor object from the React context.