@portabletext/editor 1.35.3 → 1.36.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 (34) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  2. package/lib/_chunks-cjs/editor-provider.cjs +211 -74
  3. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  4. package/lib/_chunks-es/behavior.core.js.map +1 -1
  5. package/lib/_chunks-es/editor-provider.js +212 -75
  6. package/lib/_chunks-es/editor-provider.js.map +1 -1
  7. package/lib/behaviors/index.d.cts +150 -354
  8. package/lib/behaviors/index.d.ts +150 -354
  9. package/lib/index.d.cts +145 -77
  10. package/lib/index.d.ts +145 -77
  11. package/lib/plugins/index.cjs +19 -19
  12. package/lib/plugins/index.cjs.map +1 -1
  13. package/lib/plugins/index.d.cts +134 -77
  14. package/lib/plugins/index.d.ts +134 -77
  15. package/lib/plugins/index.js +21 -21
  16. package/lib/plugins/index.js.map +1 -1
  17. package/lib/selectors/index.d.cts +123 -77
  18. package/lib/selectors/index.d.ts +123 -77
  19. package/lib/utils/index.d.cts +123 -77
  20. package/lib/utils/index.d.ts +123 -77
  21. package/package.json +6 -6
  22. package/src/behavior-actions/behavior.actions.ts +2 -2
  23. package/src/behaviors/behavior.types.ts +10 -7
  24. package/src/editor/PortableTextEditor.tsx +22 -0
  25. package/src/editor/__tests__/self-solving.test.tsx +33 -1
  26. package/src/editor/components/Synchronizer.tsx +17 -3
  27. package/src/editor/editor-machine.ts +31 -15
  28. package/src/editor/mutation-machine.ts +160 -46
  29. package/src/editor/plugins/create-with-event-listeners.ts +1 -0
  30. package/src/editor/plugins/createWithPatches.ts +10 -3
  31. package/src/editor/with-applying-behavior-actions.ts +8 -6
  32. package/src/plugins/index.ts +2 -1
  33. package/src/plugins/plugin.decorator-shortcut.ts +3 -0
  34. package/src/utils/util.slice-blocks.test.ts +64 -0
package/lib/index.d.cts CHANGED
@@ -103,11 +103,9 @@ export declare type BaseDefinition = {
103
103
  export declare type Behavior<
104
104
  TBehaviorEventType extends BehaviorEvent['type'] = BehaviorEvent['type'],
105
105
  TGuardResponse = true,
106
- TBehaviorEvent extends BehaviorEvent = PickFromUnion<
107
- BehaviorEvent,
108
- 'type',
109
- TBehaviorEventType
110
- >,
106
+ TBehaviorEvent extends BehaviorEvent = TBehaviorEventType extends '*'
107
+ ? BehaviorEvent
108
+ : PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>,
111
109
  > = {
112
110
  /**
113
111
  * The internal editor event that triggers this behavior.
@@ -165,6 +163,9 @@ export declare type BehaviorEvent =
165
163
  | SyntheticBehaviorEvent
166
164
  | NativeBehaviorEvent
167
165
  | CustomBehaviorEvent
166
+ | {
167
+ type: '*'
168
+ }
168
169
 
169
170
  /**
170
171
  * @beta
@@ -626,7 +627,7 @@ declare const editorMachine: StateMachine<
626
627
  behaviors: Set<Behavior>
627
628
  converters: Set<Converter>
628
629
  keyGenerator: () => string
629
- pendingEvents: Array<PatchEvent | MutationEvent>
630
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
630
631
  schema: EditorSchema
631
632
  initialReadOnly: boolean
632
633
  maxBlocks: number | undefined
@@ -856,7 +857,7 @@ declare const editorMachine: StateMachine<
856
857
  } & {
857
858
  dataTransfer: DataTransfer
858
859
  })
859
- | PatchEvent
860
+ | InternalPatchEvent
860
861
  | MutationEvent
861
862
  | {
862
863
  type: 'normalizing'
@@ -1291,6 +1292,7 @@ declare const editorMachine: StateMachine<
1291
1292
  dataTransfer: DataTransfer
1292
1293
  })
1293
1294
  | PatchEvent
1295
+ | InternalPatchEvent
1294
1296
  | MutationEvent
1295
1297
  | PatchesEvent
1296
1298
  | {
@@ -1383,7 +1385,7 @@ declare const editorMachine: StateMachine<
1383
1385
  behaviors: Set<Behavior>
1384
1386
  converters: Set<Converter>
1385
1387
  keyGenerator: () => string
1386
- pendingEvents: Array<PatchEvent | MutationEvent>
1388
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
1387
1389
  schema: EditorSchema
1388
1390
  initialReadOnly: boolean
1389
1391
  maxBlocks: number | undefined
@@ -1613,7 +1615,7 @@ declare const editorMachine: StateMachine<
1613
1615
  } & {
1614
1616
  dataTransfer: DataTransfer
1615
1617
  })
1616
- | PatchEvent
1618
+ | InternalPatchEvent
1617
1619
  | MutationEvent
1618
1620
  | {
1619
1621
  type: 'normalizing'
@@ -1970,7 +1972,7 @@ declare const editorMachine: StateMachine<
1970
1972
  } & {
1971
1973
  dataTransfer: DataTransfer
1972
1974
  })
1973
- | PatchEvent
1975
+ | InternalPatchEvent
1974
1976
  | MutationEvent
1975
1977
  | {
1976
1978
  type: 'normalizing'
@@ -2117,7 +2119,7 @@ declare const editorMachine: StateMachine<
2117
2119
  behaviors: Set<Behavior>
2118
2120
  converters: Set<Converter>
2119
2121
  keyGenerator: () => string
2120
- pendingEvents: Array<PatchEvent | MutationEvent>
2122
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
2121
2123
  schema: EditorSchema
2122
2124
  initialReadOnly: boolean
2123
2125
  maxBlocks: number | undefined
@@ -2351,7 +2353,7 @@ declare const editorMachine: StateMachine<
2351
2353
  } & {
2352
2354
  dataTransfer: DataTransfer
2353
2355
  })
2354
- | PatchEvent
2356
+ | InternalPatchEvent
2355
2357
  | MutationEvent
2356
2358
  | {
2357
2359
  type: 'normalizing'
@@ -2707,6 +2709,7 @@ declare const editorMachine: StateMachine<
2707
2709
  dataTransfer: DataTransfer
2708
2710
  })
2709
2711
  | PatchEvent
2712
+ | InternalPatchEvent
2710
2713
  | MutationEvent
2711
2714
  | PatchesEvent
2712
2715
  | {
@@ -2764,7 +2767,7 @@ declare const editorMachine: StateMachine<
2764
2767
  behaviors: Set<Behavior>
2765
2768
  converters: Set<Converter>
2766
2769
  keyGenerator: () => string
2767
- pendingEvents: Array<PatchEvent | MutationEvent>
2770
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
2768
2771
  schema: EditorSchema
2769
2772
  initialReadOnly: boolean
2770
2773
  maxBlocks: number | undefined
@@ -2997,7 +3000,7 @@ declare const editorMachine: StateMachine<
2997
3000
  } & {
2998
3001
  dataTransfer: DataTransfer
2999
3002
  })
3000
- | PatchEvent
3003
+ | InternalPatchEvent
3001
3004
  | MutationEvent
3002
3005
  | {
3003
3006
  type: 'normalizing'
@@ -3353,6 +3356,7 @@ declare const editorMachine: StateMachine<
3353
3356
  dataTransfer: DataTransfer
3354
3357
  })
3355
3358
  | PatchEvent
3359
+ | InternalPatchEvent
3356
3360
  | MutationEvent
3357
3361
  | PatchesEvent
3358
3362
  | {
@@ -3410,7 +3414,7 @@ declare const editorMachine: StateMachine<
3410
3414
  behaviors: Set<Behavior>
3411
3415
  converters: Set<Converter>
3412
3416
  keyGenerator: () => string
3413
- pendingEvents: Array<PatchEvent | MutationEvent>
3417
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
3414
3418
  schema: EditorSchema
3415
3419
  initialReadOnly: boolean
3416
3420
  maxBlocks: number | undefined
@@ -3646,7 +3650,7 @@ declare const editorMachine: StateMachine<
3646
3650
  } & {
3647
3651
  dataTransfer: DataTransfer
3648
3652
  })
3649
- | PatchEvent
3653
+ | InternalPatchEvent
3650
3654
  | MutationEvent
3651
3655
  | {
3652
3656
  type: 'normalizing'
@@ -4002,6 +4006,7 @@ declare const editorMachine: StateMachine<
4002
4006
  dataTransfer: DataTransfer
4003
4007
  })
4004
4008
  | PatchEvent
4009
+ | InternalPatchEvent
4005
4010
  | MutationEvent
4006
4011
  | PatchesEvent
4007
4012
  | {
@@ -4059,7 +4064,7 @@ declare const editorMachine: StateMachine<
4059
4064
  behaviors: Set<Behavior>
4060
4065
  converters: Set<Converter>
4061
4066
  keyGenerator: () => string
4062
- pendingEvents: Array<PatchEvent | MutationEvent>
4067
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
4063
4068
  schema: EditorSchema
4064
4069
  initialReadOnly: boolean
4065
4070
  maxBlocks: number | undefined
@@ -4294,7 +4299,7 @@ declare const editorMachine: StateMachine<
4294
4299
  } & {
4295
4300
  dataTransfer: DataTransfer
4296
4301
  })
4297
- | PatchEvent
4302
+ | InternalPatchEvent
4298
4303
  | MutationEvent
4299
4304
  | {
4300
4305
  type: 'normalizing'
@@ -4650,6 +4655,7 @@ declare const editorMachine: StateMachine<
4650
4655
  dataTransfer: DataTransfer
4651
4656
  })
4652
4657
  | PatchEvent
4658
+ | InternalPatchEvent
4653
4659
  | MutationEvent
4654
4660
  | PatchesEvent
4655
4661
  | {
@@ -4707,7 +4713,7 @@ declare const editorMachine: StateMachine<
4707
4713
  behaviors: Set<Behavior>
4708
4714
  converters: Set<Converter>
4709
4715
  keyGenerator: () => string
4710
- pendingEvents: Array<PatchEvent | MutationEvent>
4716
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
4711
4717
  schema: EditorSchema
4712
4718
  initialReadOnly: boolean
4713
4719
  maxBlocks: number | undefined
@@ -4941,7 +4947,7 @@ declare const editorMachine: StateMachine<
4941
4947
  } & {
4942
4948
  dataTransfer: DataTransfer
4943
4949
  })
4944
- | PatchEvent
4950
+ | InternalPatchEvent
4945
4951
  | MutationEvent
4946
4952
  | {
4947
4953
  type: 'normalizing'
@@ -5297,6 +5303,7 @@ declare const editorMachine: StateMachine<
5297
5303
  dataTransfer: DataTransfer
5298
5304
  })
5299
5305
  | PatchEvent
5306
+ | InternalPatchEvent
5300
5307
  | MutationEvent
5301
5308
  | PatchesEvent
5302
5309
  | {
@@ -5355,7 +5362,7 @@ declare const editorMachine: StateMachine<
5355
5362
  behaviors: Set<Behavior>
5356
5363
  converters: Set<Converter>
5357
5364
  keyGenerator: () => string
5358
- pendingEvents: Array<PatchEvent | MutationEvent>
5365
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
5359
5366
  schema: EditorSchema
5360
5367
  initialReadOnly: boolean
5361
5368
  maxBlocks: number | undefined
@@ -5589,7 +5596,7 @@ declare const editorMachine: StateMachine<
5589
5596
  } & {
5590
5597
  dataTransfer: DataTransfer
5591
5598
  })
5592
- | PatchEvent
5599
+ | InternalPatchEvent
5593
5600
  | MutationEvent
5594
5601
  | {
5595
5602
  type: 'normalizing'
@@ -5728,7 +5735,7 @@ declare const editorMachine: StateMachine<
5728
5735
  behaviors: Set<Behavior>
5729
5736
  converters: Set<Converter>
5730
5737
  keyGenerator: () => string
5731
- pendingEvents: Array<PatchEvent | MutationEvent>
5738
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
5732
5739
  schema: EditorSchema
5733
5740
  initialReadOnly: boolean
5734
5741
  maxBlocks: number | undefined
@@ -5962,7 +5969,7 @@ declare const editorMachine: StateMachine<
5962
5969
  } & {
5963
5970
  dataTransfer: DataTransfer
5964
5971
  })
5965
- | PatchEvent
5972
+ | InternalPatchEvent
5966
5973
  | MutationEvent
5967
5974
  | {
5968
5975
  type: 'normalizing'
@@ -6318,6 +6325,7 @@ declare const editorMachine: StateMachine<
6318
6325
  dataTransfer: DataTransfer
6319
6326
  })
6320
6327
  | PatchEvent
6328
+ | InternalPatchEvent
6321
6329
  | MutationEvent
6322
6330
  | PatchesEvent
6323
6331
  | {
@@ -6376,7 +6384,7 @@ declare const editorMachine: StateMachine<
6376
6384
  behaviors: Set<Behavior>
6377
6385
  converters: Set<Converter>
6378
6386
  keyGenerator: () => string
6379
- pendingEvents: Array<PatchEvent | MutationEvent>
6387
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
6380
6388
  schema: EditorSchema
6381
6389
  initialReadOnly: boolean
6382
6390
  maxBlocks: number | undefined
@@ -6610,7 +6618,7 @@ declare const editorMachine: StateMachine<
6610
6618
  } & {
6611
6619
  dataTransfer: DataTransfer
6612
6620
  })
6613
- | PatchEvent
6621
+ | InternalPatchEvent
6614
6622
  | MutationEvent
6615
6623
  | {
6616
6624
  type: 'normalizing'
@@ -6966,6 +6974,7 @@ declare const editorMachine: StateMachine<
6966
6974
  dataTransfer: DataTransfer
6967
6975
  })
6968
6976
  | PatchEvent
6977
+ | InternalPatchEvent
6969
6978
  | MutationEvent
6970
6979
  | PatchesEvent
6971
6980
  | {
@@ -7023,7 +7032,7 @@ declare const editorMachine: StateMachine<
7023
7032
  behaviors: Set<Behavior>
7024
7033
  converters: Set<Converter>
7025
7034
  keyGenerator: () => string
7026
- pendingEvents: Array<PatchEvent | MutationEvent>
7035
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
7027
7036
  schema: EditorSchema
7028
7037
  initialReadOnly: boolean
7029
7038
  maxBlocks: number | undefined
@@ -7256,7 +7265,7 @@ declare const editorMachine: StateMachine<
7256
7265
  } & {
7257
7266
  dataTransfer: DataTransfer
7258
7267
  })
7259
- | PatchEvent
7268
+ | InternalPatchEvent
7260
7269
  | MutationEvent
7261
7270
  | {
7262
7271
  type: 'normalizing'
@@ -7612,6 +7621,7 @@ declare const editorMachine: StateMachine<
7612
7621
  dataTransfer: DataTransfer
7613
7622
  })
7614
7623
  | PatchEvent
7624
+ | InternalPatchEvent
7615
7625
  | MutationEvent
7616
7626
  | PatchesEvent
7617
7627
  | {
@@ -7669,7 +7679,7 @@ declare const editorMachine: StateMachine<
7669
7679
  behaviors: Set<Behavior>
7670
7680
  converters: Set<Converter>
7671
7681
  keyGenerator: () => string
7672
- pendingEvents: Array<PatchEvent | MutationEvent>
7682
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
7673
7683
  schema: EditorSchema
7674
7684
  initialReadOnly: boolean
7675
7685
  maxBlocks: number | undefined
@@ -7903,7 +7913,7 @@ declare const editorMachine: StateMachine<
7903
7913
  } & {
7904
7914
  dataTransfer: DataTransfer
7905
7915
  })
7906
- | PatchEvent
7916
+ | InternalPatchEvent
7907
7917
  | MutationEvent
7908
7918
  | {
7909
7919
  type: 'normalizing'
@@ -8259,6 +8269,7 @@ declare const editorMachine: StateMachine<
8259
8269
  dataTransfer: DataTransfer
8260
8270
  })
8261
8271
  | PatchEvent
8272
+ | InternalPatchEvent
8262
8273
  | MutationEvent
8263
8274
  | PatchesEvent
8264
8275
  | {
@@ -8322,7 +8333,7 @@ declare const editorMachine: StateMachine<
8322
8333
  behaviors: Set<Behavior>
8323
8334
  converters: Set<Converter>
8324
8335
  keyGenerator: () => string
8325
- pendingEvents: Array<PatchEvent | MutationEvent>
8336
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
8326
8337
  schema: EditorSchema
8327
8338
  initialReadOnly: boolean
8328
8339
  maxBlocks: number | undefined
@@ -8553,7 +8564,7 @@ declare const editorMachine: StateMachine<
8553
8564
  } & {
8554
8565
  dataTransfer: DataTransfer
8555
8566
  })
8556
- | PatchEvent
8567
+ | InternalPatchEvent
8557
8568
  | MutationEvent
8558
8569
  | {
8559
8570
  type: 'normalizing'
@@ -8909,6 +8920,7 @@ declare const editorMachine: StateMachine<
8909
8920
  dataTransfer: DataTransfer
8910
8921
  })
8911
8922
  | PatchEvent
8923
+ | InternalPatchEvent
8912
8924
  | MutationEvent
8913
8925
  | PatchesEvent
8914
8926
  | {
@@ -8969,7 +8981,7 @@ declare const editorMachine: StateMachine<
8969
8981
  behaviors: Set<Behavior>
8970
8982
  converters: Set<Converter>
8971
8983
  keyGenerator: () => string
8972
- pendingEvents: Array<PatchEvent | MutationEvent>
8984
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
8973
8985
  schema: EditorSchema
8974
8986
  initialReadOnly: boolean
8975
8987
  maxBlocks: number | undefined
@@ -9203,7 +9215,7 @@ declare const editorMachine: StateMachine<
9203
9215
  } & {
9204
9216
  dataTransfer: DataTransfer
9205
9217
  })
9206
- | PatchEvent
9218
+ | InternalPatchEvent
9207
9219
  | MutationEvent
9208
9220
  | {
9209
9221
  type: 'normalizing'
@@ -9347,7 +9359,7 @@ declare const editorMachine: StateMachine<
9347
9359
  behaviors: Set<Behavior>
9348
9360
  converters: Set<Converter>
9349
9361
  keyGenerator: () => string
9350
- pendingEvents: Array<PatchEvent | MutationEvent>
9362
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
9351
9363
  schema: EditorSchema
9352
9364
  initialReadOnly: boolean
9353
9365
  maxBlocks: number | undefined
@@ -9581,7 +9593,7 @@ declare const editorMachine: StateMachine<
9581
9593
  } & {
9582
9594
  dataTransfer: DataTransfer
9583
9595
  })
9584
- | PatchEvent
9596
+ | InternalPatchEvent
9585
9597
  | MutationEvent
9586
9598
  | {
9587
9599
  type: 'normalizing'
@@ -9722,7 +9734,7 @@ declare const editorMachine: StateMachine<
9722
9734
  behaviors: Set<Behavior>
9723
9735
  converters: Set<Converter>
9724
9736
  keyGenerator: () => string
9725
- pendingEvents: Array<PatchEvent | MutationEvent>
9737
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
9726
9738
  schema: EditorSchema
9727
9739
  initialReadOnly: boolean
9728
9740
  maxBlocks: number | undefined
@@ -9956,7 +9968,7 @@ declare const editorMachine: StateMachine<
9956
9968
  } & {
9957
9969
  dataTransfer: DataTransfer
9958
9970
  })
9959
- | PatchEvent
9971
+ | InternalPatchEvent
9960
9972
  | MutationEvent
9961
9973
  | {
9962
9974
  type: 'normalizing'
@@ -10109,7 +10121,7 @@ declare const editorMachine: StateMachine<
10109
10121
  behaviors: Set<Behavior>
10110
10122
  converters: Set<Converter>
10111
10123
  keyGenerator: () => string
10112
- pendingEvents: Array<PatchEvent | MutationEvent>
10124
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
10113
10125
  schema: EditorSchema
10114
10126
  initialReadOnly: boolean
10115
10127
  maxBlocks: number | undefined
@@ -10141,7 +10153,9 @@ declare const editorMachine: StateMachine<
10141
10153
  behaviors: Set<Behavior>
10142
10154
  converters: Set<Converter>
10143
10155
  keyGenerator: () => string
10144
- pendingEvents: Array<PatchEvent | MutationEvent>
10156
+ pendingEvents: Array<
10157
+ InternalPatchEvent | MutationEvent
10158
+ >
10145
10159
  schema: EditorSchema
10146
10160
  initialReadOnly: boolean
10147
10161
  maxBlocks: number | undefined
@@ -10169,7 +10183,7 @@ declare const editorMachine: StateMachine<
10169
10183
  behaviors: Set<Behavior>
10170
10184
  converters: Set<Converter>
10171
10185
  keyGenerator: () => string
10172
- pendingEvents: Array<PatchEvent | MutationEvent>
10186
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
10173
10187
  schema: EditorSchema
10174
10188
  initialReadOnly: boolean
10175
10189
  maxBlocks: number | undefined
@@ -10198,7 +10212,7 @@ declare const editorMachine: StateMachine<
10198
10212
  behaviors: Set<Behavior>
10199
10213
  converters: Set<Converter>
10200
10214
  keyGenerator: () => string
10201
- pendingEvents: Array<PatchEvent | MutationEvent>
10215
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
10202
10216
  schema: EditorSchema
10203
10217
  initialReadOnly: boolean
10204
10218
  maxBlocks: number | undefined
@@ -10225,7 +10239,7 @@ declare const editorMachine: StateMachine<
10225
10239
  behaviors: Set<Behavior>
10226
10240
  converters: Set<Converter>
10227
10241
  keyGenerator: () => string
10228
- pendingEvents: Array<PatchEvent | MutationEvent>
10242
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
10229
10243
  schema: EditorSchema
10230
10244
  initialReadOnly: boolean
10231
10245
  maxBlocks: number | undefined
@@ -10479,7 +10493,7 @@ declare const editorMachine: StateMachine<
10479
10493
  } & {
10480
10494
  dataTransfer: DataTransfer
10481
10495
  })
10482
- | PatchEvent
10496
+ | InternalPatchEvent
10483
10497
  | MutationEvent
10484
10498
  | {
10485
10499
  type: 'normalizing'
@@ -10837,6 +10851,7 @@ declare const editorMachine: StateMachine<
10837
10851
  dataTransfer: DataTransfer
10838
10852
  })
10839
10853
  | PatchEvent
10854
+ | InternalPatchEvent
10840
10855
  | MutationEvent
10841
10856
  | PatchesEvent
10842
10857
  | {
@@ -10894,7 +10909,7 @@ declare const editorMachine: StateMachine<
10894
10909
  behaviors: Set<Behavior>
10895
10910
  converters: Set<Converter>
10896
10911
  keyGenerator: () => string
10897
- pendingEvents: Array<PatchEvent | MutationEvent>
10912
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
10898
10913
  schema: EditorSchema
10899
10914
  initialReadOnly: boolean
10900
10915
  maxBlocks: number | undefined
@@ -11134,7 +11149,7 @@ declare const editorMachine: StateMachine<
11134
11149
  } & {
11135
11150
  dataTransfer: DataTransfer
11136
11151
  })
11137
- | PatchEvent
11152
+ | InternalPatchEvent
11138
11153
  | MutationEvent
11139
11154
  | {
11140
11155
  type: 'normalizing'
@@ -11492,6 +11507,7 @@ declare const editorMachine: StateMachine<
11492
11507
  dataTransfer: DataTransfer
11493
11508
  })
11494
11509
  | PatchEvent
11510
+ | InternalPatchEvent
11495
11511
  | MutationEvent
11496
11512
  | PatchesEvent
11497
11513
  | {
@@ -11549,7 +11565,7 @@ declare const editorMachine: StateMachine<
11549
11565
  behaviors: Set<Behavior>
11550
11566
  converters: Set<Converter>
11551
11567
  keyGenerator: () => string
11552
- pendingEvents: Array<PatchEvent | MutationEvent>
11568
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
11553
11569
  schema: EditorSchema
11554
11570
  initialReadOnly: boolean
11555
11571
  maxBlocks: number | undefined
@@ -11782,7 +11798,7 @@ declare const editorMachine: StateMachine<
11782
11798
  } & {
11783
11799
  dataTransfer: DataTransfer
11784
11800
  })
11785
- | PatchEvent
11801
+ | InternalPatchEvent
11786
11802
  | MutationEvent
11787
11803
  | {
11788
11804
  type: 'normalizing'
@@ -12140,6 +12156,7 @@ declare const editorMachine: StateMachine<
12140
12156
  dataTransfer: DataTransfer
12141
12157
  })
12142
12158
  | PatchEvent
12159
+ | InternalPatchEvent
12143
12160
  | MutationEvent
12144
12161
  | PatchesEvent
12145
12162
  | {
@@ -12197,7 +12214,7 @@ declare const editorMachine: StateMachine<
12197
12214
  behaviors: Set<Behavior>
12198
12215
  converters: Set<Converter>
12199
12216
  keyGenerator: () => string
12200
- pendingEvents: Array<PatchEvent | MutationEvent>
12217
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
12201
12218
  schema: EditorSchema
12202
12219
  initialReadOnly: boolean
12203
12220
  maxBlocks: number | undefined
@@ -12430,7 +12447,7 @@ declare const editorMachine: StateMachine<
12430
12447
  } & {
12431
12448
  dataTransfer: DataTransfer
12432
12449
  })
12433
- | PatchEvent
12450
+ | InternalPatchEvent
12434
12451
  | MutationEvent
12435
12452
  | {
12436
12453
  type: 'normalizing'
@@ -12788,6 +12805,7 @@ declare const editorMachine: StateMachine<
12788
12805
  dataTransfer: DataTransfer
12789
12806
  })
12790
12807
  | PatchEvent
12808
+ | InternalPatchEvent
12791
12809
  | MutationEvent
12792
12810
  | PatchesEvent
12793
12811
  | {
@@ -12845,7 +12863,7 @@ declare const editorMachine: StateMachine<
12845
12863
  behaviors: Set<Behavior>
12846
12864
  converters: Set<Converter>
12847
12865
  keyGenerator: () => string
12848
- pendingEvents: Array<PatchEvent | MutationEvent>
12866
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
12849
12867
  schema: EditorSchema
12850
12868
  initialReadOnly: boolean
12851
12869
  maxBlocks: number | undefined
@@ -13091,7 +13109,7 @@ declare const editorMachine: StateMachine<
13091
13109
  } & {
13092
13110
  dataTransfer: DataTransfer
13093
13111
  })
13094
- | PatchEvent
13112
+ | InternalPatchEvent
13095
13113
  | MutationEvent
13096
13114
  | {
13097
13115
  type: 'normalizing'
@@ -13449,6 +13467,7 @@ declare const editorMachine: StateMachine<
13449
13467
  dataTransfer: DataTransfer
13450
13468
  })
13451
13469
  | PatchEvent
13470
+ | InternalPatchEvent
13452
13471
  | MutationEvent
13453
13472
  | PatchesEvent
13454
13473
  | {
@@ -13506,7 +13525,7 @@ declare const editorMachine: StateMachine<
13506
13525
  behaviors: Set<Behavior>
13507
13526
  converters: Set<Converter>
13508
13527
  keyGenerator: () => string
13509
- pendingEvents: Array<PatchEvent | MutationEvent>
13528
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
13510
13529
  schema: EditorSchema
13511
13530
  initialReadOnly: boolean
13512
13531
  maxBlocks: number | undefined
@@ -13753,7 +13772,7 @@ declare const editorMachine: StateMachine<
13753
13772
  } & {
13754
13773
  dataTransfer: DataTransfer
13755
13774
  })
13756
- | PatchEvent
13775
+ | InternalPatchEvent
13757
13776
  | MutationEvent
13758
13777
  | {
13759
13778
  type: 'normalizing'
@@ -14111,6 +14130,7 @@ declare const editorMachine: StateMachine<
14111
14130
  dataTransfer: DataTransfer
14112
14131
  })
14113
14132
  | PatchEvent
14133
+ | InternalPatchEvent
14114
14134
  | MutationEvent
14115
14135
  | PatchesEvent
14116
14136
  | {
@@ -14168,7 +14188,7 @@ declare const editorMachine: StateMachine<
14168
14188
  behaviors: Set<Behavior>
14169
14189
  converters: Set<Converter>
14170
14190
  keyGenerator: () => string
14171
- pendingEvents: Array<PatchEvent | MutationEvent>
14191
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
14172
14192
  schema: EditorSchema
14173
14193
  initialReadOnly: boolean
14174
14194
  maxBlocks: number | undefined
@@ -14401,7 +14421,7 @@ declare const editorMachine: StateMachine<
14401
14421
  } & {
14402
14422
  dataTransfer: DataTransfer
14403
14423
  })
14404
- | PatchEvent
14424
+ | InternalPatchEvent
14405
14425
  | MutationEvent
14406
14426
  | {
14407
14427
  type: 'normalizing'
@@ -14759,6 +14779,7 @@ declare const editorMachine: StateMachine<
14759
14779
  dataTransfer: DataTransfer
14760
14780
  })
14761
14781
  | PatchEvent
14782
+ | InternalPatchEvent
14762
14783
  | MutationEvent
14763
14784
  | PatchesEvent
14764
14785
  | {
@@ -14816,7 +14837,7 @@ declare const editorMachine: StateMachine<
14816
14837
  behaviors: Set<Behavior>
14817
14838
  converters: Set<Converter>
14818
14839
  keyGenerator: () => string
14819
- pendingEvents: Array<PatchEvent | MutationEvent>
14840
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
14820
14841
  schema: EditorSchema
14821
14842
  initialReadOnly: boolean
14822
14843
  maxBlocks: number | undefined
@@ -15052,7 +15073,7 @@ declare const editorMachine: StateMachine<
15052
15073
  } & {
15053
15074
  dataTransfer: DataTransfer
15054
15075
  })
15055
- | PatchEvent
15076
+ | InternalPatchEvent
15056
15077
  | MutationEvent
15057
15078
  | {
15058
15079
  type: 'normalizing'
@@ -15410,6 +15431,7 @@ declare const editorMachine: StateMachine<
15410
15431
  dataTransfer: DataTransfer
15411
15432
  })
15412
15433
  | PatchEvent
15434
+ | InternalPatchEvent
15413
15435
  | MutationEvent
15414
15436
  | PatchesEvent
15415
15437
  | {
@@ -15467,7 +15489,7 @@ declare const editorMachine: StateMachine<
15467
15489
  behaviors: Set<Behavior>
15468
15490
  converters: Set<Converter>
15469
15491
  keyGenerator: () => string
15470
- pendingEvents: Array<PatchEvent | MutationEvent>
15492
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
15471
15493
  schema: EditorSchema
15472
15494
  initialReadOnly: boolean
15473
15495
  maxBlocks: number | undefined
@@ -15754,7 +15776,7 @@ declare const editorMachine: StateMachine<
15754
15776
  } & {
15755
15777
  dataTransfer: DataTransfer
15756
15778
  })
15757
- | PatchEvent
15779
+ | InternalPatchEvent
15758
15780
  | MutationEvent
15759
15781
  | {
15760
15782
  type: 'normalizing'
@@ -16112,6 +16134,7 @@ declare const editorMachine: StateMachine<
16112
16134
  dataTransfer: DataTransfer
16113
16135
  })
16114
16136
  | PatchEvent
16137
+ | InternalPatchEvent
16115
16138
  | MutationEvent
16116
16139
  | PatchesEvent
16117
16140
  | {
@@ -16169,7 +16192,7 @@ declare const editorMachine: StateMachine<
16169
16192
  behaviors: Set<Behavior>
16170
16193
  converters: Set<Converter>
16171
16194
  keyGenerator: () => string
16172
- pendingEvents: Array<PatchEvent | MutationEvent>
16195
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
16173
16196
  schema: EditorSchema
16174
16197
  initialReadOnly: boolean
16175
16198
  maxBlocks: number | undefined
@@ -16411,7 +16434,7 @@ declare const editorMachine: StateMachine<
16411
16434
  } & {
16412
16435
  dataTransfer: DataTransfer
16413
16436
  })
16414
- | PatchEvent
16437
+ | InternalPatchEvent
16415
16438
  | MutationEvent
16416
16439
  | {
16417
16440
  type: 'normalizing'
@@ -16769,6 +16792,7 @@ declare const editorMachine: StateMachine<
16769
16792
  dataTransfer: DataTransfer
16770
16793
  })
16771
16794
  | PatchEvent
16795
+ | InternalPatchEvent
16772
16796
  | MutationEvent
16773
16797
  | PatchesEvent
16774
16798
  | {
@@ -16826,7 +16850,7 @@ declare const editorMachine: StateMachine<
16826
16850
  behaviors: Set<Behavior>
16827
16851
  converters: Set<Converter>
16828
16852
  keyGenerator: () => string
16829
- pendingEvents: Array<PatchEvent | MutationEvent>
16853
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
16830
16854
  schema: EditorSchema
16831
16855
  initialReadOnly: boolean
16832
16856
  maxBlocks: number | undefined
@@ -17069,7 +17093,7 @@ declare const editorMachine: StateMachine<
17069
17093
  } & {
17070
17094
  dataTransfer: DataTransfer
17071
17095
  })
17072
- | PatchEvent
17096
+ | InternalPatchEvent
17073
17097
  | MutationEvent
17074
17098
  | {
17075
17099
  type: 'normalizing'
@@ -17427,6 +17451,7 @@ declare const editorMachine: StateMachine<
17427
17451
  dataTransfer: DataTransfer
17428
17452
  })
17429
17453
  | PatchEvent
17454
+ | InternalPatchEvent
17430
17455
  | MutationEvent
17431
17456
  | PatchesEvent
17432
17457
  | {
@@ -17484,7 +17509,7 @@ declare const editorMachine: StateMachine<
17484
17509
  behaviors: Set<Behavior>
17485
17510
  converters: Set<Converter>
17486
17511
  keyGenerator: () => string
17487
- pendingEvents: Array<PatchEvent | MutationEvent>
17512
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
17488
17513
  schema: EditorSchema
17489
17514
  initialReadOnly: boolean
17490
17515
  maxBlocks: number | undefined
@@ -17718,7 +17743,7 @@ declare const editorMachine: StateMachine<
17718
17743
  } & {
17719
17744
  dataTransfer: DataTransfer
17720
17745
  })
17721
- | PatchEvent
17746
+ | InternalPatchEvent
17722
17747
  | MutationEvent
17723
17748
  | {
17724
17749
  type: 'normalizing'
@@ -18076,6 +18101,7 @@ declare const editorMachine: StateMachine<
18076
18101
  dataTransfer: DataTransfer
18077
18102
  })
18078
18103
  | PatchEvent
18104
+ | InternalPatchEvent
18079
18105
  | MutationEvent
18080
18106
  | PatchesEvent
18081
18107
  | {
@@ -18133,7 +18159,7 @@ declare const editorMachine: StateMachine<
18133
18159
  behaviors: Set<Behavior>
18134
18160
  converters: Set<Converter>
18135
18161
  keyGenerator: () => string
18136
- pendingEvents: Array<PatchEvent | MutationEvent>
18162
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
18137
18163
  schema: EditorSchema
18138
18164
  initialReadOnly: boolean
18139
18165
  maxBlocks: number | undefined
@@ -18369,7 +18395,7 @@ declare const editorMachine: StateMachine<
18369
18395
  } & {
18370
18396
  dataTransfer: DataTransfer
18371
18397
  })
18372
- | PatchEvent
18398
+ | InternalPatchEvent
18373
18399
  | MutationEvent
18374
18400
  | {
18375
18401
  type: 'normalizing'
@@ -18727,6 +18753,7 @@ declare const editorMachine: StateMachine<
18727
18753
  dataTransfer: DataTransfer
18728
18754
  })
18729
18755
  | PatchEvent
18756
+ | InternalPatchEvent
18730
18757
  | MutationEvent
18731
18758
  | PatchesEvent
18732
18759
  | {
@@ -18784,7 +18811,7 @@ declare const editorMachine: StateMachine<
18784
18811
  behaviors: Set<Behavior>
18785
18812
  converters: Set<Converter>
18786
18813
  keyGenerator: () => string
18787
- pendingEvents: Array<PatchEvent | MutationEvent>
18814
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
18788
18815
  schema: EditorSchema
18789
18816
  initialReadOnly: boolean
18790
18817
  maxBlocks: number | undefined
@@ -19026,7 +19053,7 @@ declare const editorMachine: StateMachine<
19026
19053
  } & {
19027
19054
  dataTransfer: DataTransfer
19028
19055
  })
19029
- | PatchEvent
19056
+ | InternalPatchEvent
19030
19057
  | MutationEvent
19031
19058
  | {
19032
19059
  type: 'normalizing'
@@ -19384,6 +19411,7 @@ declare const editorMachine: StateMachine<
19384
19411
  dataTransfer: DataTransfer
19385
19412
  })
19386
19413
  | PatchEvent
19414
+ | InternalPatchEvent
19387
19415
  | MutationEvent
19388
19416
  | PatchesEvent
19389
19417
  | {
@@ -19479,7 +19507,7 @@ declare const editorMachine: StateMachine<
19479
19507
  readonly 'setting up': {
19480
19508
  readonly exit: readonly ['emit ready']
19481
19509
  readonly on: {
19482
- readonly 'patch': {
19510
+ readonly 'internal.patch': {
19483
19511
  readonly actions: 'defer event'
19484
19512
  }
19485
19513
  readonly 'mutation': {
@@ -19495,14 +19523,14 @@ declare const editorMachine: StateMachine<
19495
19523
  readonly states: {
19496
19524
  readonly idle: {
19497
19525
  readonly on: {
19498
- readonly normalizing: {
19526
+ readonly 'normalizing': {
19499
19527
  readonly target: 'normalizing'
19500
19528
  }
19501
- readonly patch: {
19529
+ readonly 'internal.patch': {
19502
19530
  readonly actions: 'defer event'
19503
19531
  readonly target: '#editor.setup.dirty'
19504
19532
  }
19505
- readonly mutation: {
19533
+ readonly 'mutation': {
19506
19534
  readonly actions: 'defer event'
19507
19535
  readonly target: '#editor.setup.dirty'
19508
19536
  }
@@ -19513,7 +19541,7 @@ declare const editorMachine: StateMachine<
19513
19541
  readonly 'done normalizing': {
19514
19542
  readonly target: 'idle'
19515
19543
  }
19516
- readonly 'patch': {
19544
+ readonly 'internal.patch': {
19517
19545
  readonly actions: 'defer event'
19518
19546
  }
19519
19547
  readonly 'mutation': {
@@ -19529,10 +19557,10 @@ declare const editorMachine: StateMachine<
19529
19557
  'clear pending events',
19530
19558
  ]
19531
19559
  readonly on: {
19532
- readonly patch: {
19560
+ readonly 'internal.patch': {
19533
19561
  readonly actions: 'emit patch event'
19534
19562
  }
19535
- readonly mutation: {
19563
+ readonly 'mutation': {
19536
19564
  readonly actions: 'emit mutation event'
19537
19565
  }
19538
19566
  }
@@ -19701,6 +19729,11 @@ export declare type HotkeyOptions = {
19701
19729
  >
19702
19730
  }
19703
19731
 
19732
+ declare type InternalPatchEvent = NamespaceEvent<PatchEvent, 'internal'> & {
19733
+ actionId?: string
19734
+ value: Array<PortableTextBlock>
19735
+ }
19736
+
19704
19737
  /**
19705
19738
  * The editor has an invalid value
19706
19739
  * @beta */
@@ -19771,6 +19804,19 @@ export declare type MutationEvent = {
19771
19804
  value: Array<PortableTextBlock> | undefined
19772
19805
  }
19773
19806
 
19807
+ declare type NamespaceEvent<
19808
+ TEvent,
19809
+ TNamespace extends string,
19810
+ > = TEvent extends {
19811
+ type: infer TEventType
19812
+ }
19813
+ ? {
19814
+ [K in keyof TEvent]: K extends 'type'
19815
+ ? `${TNamespace}.${TEventType & string}`
19816
+ : TEvent[K]
19817
+ }
19818
+ : never
19819
+
19774
19820
  /**
19775
19821
  * @beta
19776
19822
  */
@@ -20342,7 +20388,29 @@ export declare class PortableTextEditor extends Component<
20342
20388
  static getFragment: (
20343
20389
  editor: PortableTextEditor,
20344
20390
  ) => PortableTextBlock[] | undefined
20391
+ /**
20392
+ * @deprecated
20393
+ * Use `editor.send(...)` instead
20394
+ *
20395
+ * ```
20396
+ * const editor = useEditor()
20397
+ * editor.send({
20398
+ * type: 'history.undo',
20399
+ * })
20400
+ * ```
20401
+ */
20345
20402
  static undo: (editor: PortableTextEditor) => void
20403
+ /**
20404
+ * @deprecated
20405
+ * Use `editor.send(...)` instead
20406
+ *
20407
+ * ```
20408
+ * const editor = useEditor()
20409
+ * editor.send({
20410
+ * type: 'history.redo',
20411
+ * })
20412
+ * ```
20413
+ */
20346
20414
  static redo: (editor: PortableTextEditor) => void
20347
20415
  /**
20348
20416
  * @deprecated