@portabletext/editor 1.45.3 → 1.46.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 (45) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs +20 -0
  2. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  3. package/lib/_chunks-cjs/behavior.markdown.cjs +25 -25
  4. package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
  5. package/lib/_chunks-cjs/editor-provider.cjs +93 -59
  6. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  7. package/lib/_chunks-es/behavior.core.js +20 -0
  8. package/lib/_chunks-es/behavior.core.js.map +1 -1
  9. package/lib/_chunks-es/behavior.markdown.js +26 -26
  10. package/lib/_chunks-es/behavior.markdown.js.map +1 -1
  11. package/lib/_chunks-es/editor-provider.js +93 -59
  12. package/lib/_chunks-es/editor-provider.js.map +1 -1
  13. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +1 -1
  14. package/lib/behaviors/index.cjs +37 -53
  15. package/lib/behaviors/index.cjs.map +1 -1
  16. package/lib/behaviors/index.d.cts +52 -37
  17. package/lib/behaviors/index.d.ts +52 -37
  18. package/lib/behaviors/index.js +38 -54
  19. package/lib/behaviors/index.js.map +1 -1
  20. package/lib/index.d.cts +33 -37
  21. package/lib/index.d.ts +33 -37
  22. package/lib/plugins/index.cjs +23 -29
  23. package/lib/plugins/index.cjs.map +1 -1
  24. package/lib/plugins/index.d.cts +33 -37
  25. package/lib/plugins/index.d.ts +33 -37
  26. package/lib/plugins/index.js +24 -30
  27. package/lib/plugins/index.js.map +1 -1
  28. package/lib/selectors/index.d.cts +33 -37
  29. package/lib/selectors/index.d.ts +33 -37
  30. package/lib/utils/index.d.cts +33 -37
  31. package/lib/utils/index.d.ts +33 -37
  32. package/package.json +1 -1
  33. package/src/behaviors/behavior.decorator-pair.ts +16 -19
  34. package/src/behaviors/behavior.emoji-picker.ts +26 -45
  35. package/src/behaviors/behavior.links.ts +5 -4
  36. package/src/behaviors/behavior.markdown.ts +37 -34
  37. package/src/behaviors/behavior.perform-event.ts +67 -18
  38. package/src/behaviors/behavior.types.action.ts +39 -13
  39. package/src/behaviors/behavior.types.guard.ts +1 -6
  40. package/src/behaviors/index.ts +3 -0
  41. package/src/editor/components/Synchronizer.tsx +6 -3
  42. package/src/editor/create-editor.ts +1 -1
  43. package/src/editor/editor-machine.ts +8 -6
  44. package/src/plugins/plugin.decorator-shortcut.ts +6 -8
  45. package/src/plugins/plugin.one-line.tsx +4 -4
@@ -255,7 +255,13 @@ declare type Behavior<
255
255
  * @beta
256
256
  */
257
257
  declare type BehaviorAction =
258
- | SyntheticBehaviorEvent
258
+ | {
259
+ type: 'execute'
260
+ event:
261
+ | AbstractBehaviorEvent
262
+ | SyntheticBehaviorEvent
263
+ | CustomBehaviorEvent
264
+ }
259
265
  | {
260
266
  type: 'raise'
261
267
  event:
@@ -276,11 +282,6 @@ declare type BehaviorAction =
276
282
  */
277
283
  declare type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (
278
284
  payload: {
279
- /**
280
- * @deprecated
281
- * Use `snapshot` instead
282
- */
283
- context: EditorContext
284
285
  snapshot: EditorSnapshot
285
286
  event: TBehaviorEvent
286
287
  },
@@ -306,11 +307,6 @@ declare type BehaviorEventTypeNamespace =
306
307
  * @beta
307
308
  */
308
309
  declare type BehaviorGuard<TBehaviorEvent, TGuardResponse> = (payload: {
309
- /**
310
- * @deprecated
311
- * Use `snapshot` instead
312
- */
313
- context: EditorContext
314
310
  snapshot: EditorSnapshot
315
311
  event: TBehaviorEvent
316
312
  }) => TGuardResponse | false
@@ -661,7 +657,7 @@ declare const editorMachine: StateMachine<
661
657
  initialReadOnly: boolean
662
658
  maxBlocks: number | undefined
663
659
  selection: EditorSelection
664
- value: Array<PortableTextBlock> | undefined
660
+ incomingValue: Array<PortableTextBlock> | undefined
665
661
  internalDrag?: {
666
662
  ghost?: HTMLElement
667
663
  origin: Pick<EventPosition, 'selection'>
@@ -868,7 +864,7 @@ declare const editorMachine: StateMachine<
868
864
  maxBlocks?: number
869
865
  readOnly?: boolean
870
866
  schema: EditorSchema
871
- value?: Array<PortableTextBlock>
867
+ initialValue?: Array<PortableTextBlock>
872
868
  },
873
869
  NonReducibleUnknown,
874
870
  | PatchEvent
@@ -953,7 +949,7 @@ declare const editorMachine: StateMachine<
953
949
  maxBlocks?: number
954
950
  readOnly?: boolean
955
951
  schema: EditorSchema
956
- value?: Array<PortableTextBlock>
952
+ initialValue?: Array<PortableTextBlock>
957
953
  }
958
954
  self: ActorRef<
959
955
  MachineSnapshot<
@@ -966,7 +962,7 @@ declare const editorMachine: StateMachine<
966
962
  initialReadOnly: boolean
967
963
  maxBlocks: number | undefined
968
964
  selection: EditorSelection
969
- value: Array<PortableTextBlock> | undefined
965
+ incomingValue: Array<PortableTextBlock> | undefined
970
966
  internalDrag?: {
971
967
  ghost?: HTMLElement
972
968
  origin: Pick<EventPosition, 'selection'>
@@ -1230,7 +1226,7 @@ declare const editorMachine: StateMachine<
1230
1226
  selection: null
1231
1227
  initialReadOnly: boolean
1232
1228
  maxBlocks: number | undefined
1233
- value: PortableTextBlock[] | undefined
1229
+ incomingValue: PortableTextBlock[] | undefined
1234
1230
  }
1235
1231
  readonly on: {
1236
1232
  readonly 'notify.blurred': {
@@ -1244,7 +1240,7 @@ declare const editorMachine: StateMachine<
1244
1240
  initialReadOnly: boolean
1245
1241
  maxBlocks: number | undefined
1246
1242
  selection: EditorSelection
1247
- value: Array<PortableTextBlock> | undefined
1243
+ incomingValue: Array<PortableTextBlock> | undefined
1248
1244
  internalDrag?: {
1249
1245
  ghost?: HTMLElement
1250
1246
  origin: Pick<EventPosition, 'selection'>
@@ -1439,7 +1435,7 @@ declare const editorMachine: StateMachine<
1439
1435
  initialReadOnly: boolean
1440
1436
  maxBlocks: number | undefined
1441
1437
  selection: EditorSelection
1442
- value: Array<PortableTextBlock> | undefined
1438
+ incomingValue: Array<PortableTextBlock> | undefined
1443
1439
  internalDrag?: {
1444
1440
  ghost?: HTMLElement
1445
1441
  origin: Pick<EventPosition, 'selection'>
@@ -1633,7 +1629,7 @@ declare const editorMachine: StateMachine<
1633
1629
  initialReadOnly: boolean
1634
1630
  maxBlocks: number | undefined
1635
1631
  selection: EditorSelection
1636
- value: Array<PortableTextBlock> | undefined
1632
+ incomingValue: Array<PortableTextBlock> | undefined
1637
1633
  internalDrag?: {
1638
1634
  ghost?: HTMLElement
1639
1635
  origin: Pick<EventPosition, 'selection'>
@@ -1830,7 +1826,7 @@ declare const editorMachine: StateMachine<
1830
1826
  initialReadOnly: boolean
1831
1827
  maxBlocks: number | undefined
1832
1828
  selection: EditorSelection
1833
- value: Array<PortableTextBlock> | undefined
1829
+ incomingValue: Array<PortableTextBlock> | undefined
1834
1830
  internalDrag?: {
1835
1831
  ghost?: HTMLElement
1836
1832
  origin: Pick<EventPosition, 'selection'>
@@ -2026,7 +2022,7 @@ declare const editorMachine: StateMachine<
2026
2022
  initialReadOnly: boolean
2027
2023
  maxBlocks: number | undefined
2028
2024
  selection: EditorSelection
2029
- value: Array<PortableTextBlock> | undefined
2025
+ incomingValue: Array<PortableTextBlock> | undefined
2030
2026
  internalDrag?: {
2031
2027
  ghost?: HTMLElement
2032
2028
  origin: Pick<EventPosition, 'selection'>
@@ -2222,7 +2218,7 @@ declare const editorMachine: StateMachine<
2222
2218
  initialReadOnly: boolean
2223
2219
  maxBlocks: number | undefined
2224
2220
  selection: EditorSelection
2225
- value: Array<PortableTextBlock> | undefined
2221
+ incomingValue: Array<PortableTextBlock> | undefined
2226
2222
  internalDrag?: {
2227
2223
  ghost?: HTMLElement
2228
2224
  origin: Pick<EventPosition, 'selection'>
@@ -2369,7 +2365,7 @@ declare const editorMachine: StateMachine<
2369
2365
  initialReadOnly: boolean
2370
2366
  maxBlocks: number | undefined
2371
2367
  selection: EditorSelection
2372
- value: Array<PortableTextBlock> | undefined
2368
+ incomingValue: Array<PortableTextBlock> | undefined
2373
2369
  internalDrag?: {
2374
2370
  ghost?: HTMLElement
2375
2371
  origin: Pick<EventPosition, 'selection'>
@@ -2565,7 +2561,7 @@ declare const editorMachine: StateMachine<
2565
2561
  initialReadOnly: boolean
2566
2562
  maxBlocks: number | undefined
2567
2563
  selection: EditorSelection
2568
- value: Array<PortableTextBlock> | undefined
2564
+ incomingValue: Array<PortableTextBlock> | undefined
2569
2565
  internalDrag?: {
2570
2566
  ghost?: HTMLElement
2571
2567
  origin: Pick<EventPosition, 'selection'>
@@ -2760,7 +2756,7 @@ declare const editorMachine: StateMachine<
2760
2756
  initialReadOnly: boolean
2761
2757
  maxBlocks: number | undefined
2762
2758
  selection: EditorSelection
2763
- value: Array<PortableTextBlock> | undefined
2759
+ incomingValue: Array<PortableTextBlock> | undefined
2764
2760
  internalDrag?: {
2765
2761
  ghost?: HTMLElement
2766
2762
  origin: Pick<EventPosition, 'selection'>
@@ -2954,7 +2950,7 @@ declare const editorMachine: StateMachine<
2954
2950
  initialReadOnly: boolean
2955
2951
  maxBlocks: number | undefined
2956
2952
  selection: EditorSelection
2957
- value: Array<PortableTextBlock> | undefined
2953
+ incomingValue: Array<PortableTextBlock> | undefined
2958
2954
  internalDrag?: {
2959
2955
  ghost?: HTMLElement
2960
2956
  origin: Pick<EventPosition, 'selection'>
@@ -3155,7 +3151,7 @@ declare const editorMachine: StateMachine<
3155
3151
  initialReadOnly: boolean
3156
3152
  maxBlocks: number | undefined
3157
3153
  selection: EditorSelection
3158
- value: Array<PortableTextBlock> | undefined
3154
+ incomingValue: Array<PortableTextBlock> | undefined
3159
3155
  internalDrag?: {
3160
3156
  ghost?: HTMLElement
3161
3157
  origin: Pick<EventPosition, 'selection'>
@@ -3350,7 +3346,7 @@ declare const editorMachine: StateMachine<
3350
3346
  initialReadOnly: boolean
3351
3347
  maxBlocks: number | undefined
3352
3348
  selection: EditorSelection
3353
- value: Array<PortableTextBlock> | undefined
3349
+ incomingValue: Array<PortableTextBlock> | undefined
3354
3350
  internalDrag?: {
3355
3351
  ghost?: HTMLElement
3356
3352
  origin: Pick<EventPosition, 'selection'>
@@ -3502,7 +3498,7 @@ declare const editorMachine: StateMachine<
3502
3498
  initialReadOnly: boolean
3503
3499
  maxBlocks: number | undefined
3504
3500
  selection: EditorSelection
3505
- value: Array<PortableTextBlock> | undefined
3501
+ incomingValue: Array<PortableTextBlock> | undefined
3506
3502
  internalDrag?: {
3507
3503
  ghost?: HTMLElement
3508
3504
  origin: Pick<EventPosition, 'selection'>
@@ -3651,7 +3647,7 @@ declare const editorMachine: StateMachine<
3651
3647
  initialReadOnly: boolean
3652
3648
  maxBlocks: number | undefined
3653
3649
  selection: EditorSelection
3654
- value: Array<PortableTextBlock> | undefined
3650
+ incomingValue: Array<PortableTextBlock> | undefined
3655
3651
  internalDrag?: {
3656
3652
  ghost?: HTMLElement
3657
3653
  origin: Pick<EventPosition, 'selection'>
@@ -3812,7 +3808,7 @@ declare const editorMachine: StateMachine<
3812
3808
  initialReadOnly: boolean
3813
3809
  maxBlocks: number | undefined
3814
3810
  selection: EditorSelection
3815
- value: Array<PortableTextBlock> | undefined
3811
+ incomingValue: Array<PortableTextBlock> | undefined
3816
3812
  internalDrag?: {
3817
3813
  ghost?: HTMLElement
3818
3814
  origin: Pick<EventPosition, 'selection'>
@@ -3850,7 +3846,7 @@ declare const editorMachine: StateMachine<
3850
3846
  initialReadOnly: boolean
3851
3847
  maxBlocks: number | undefined
3852
3848
  selection: EditorSelection
3853
- value: Array<PortableTextBlock> | undefined
3849
+ incomingValue: Array<PortableTextBlock> | undefined
3854
3850
  internalDrag?: {
3855
3851
  ghost?: HTMLElement
3856
3852
  origin: Pick<EventPosition, 'selection'>
@@ -3882,7 +3878,7 @@ declare const editorMachine: StateMachine<
3882
3878
  initialReadOnly: boolean
3883
3879
  maxBlocks: number | undefined
3884
3880
  selection: EditorSelection
3885
- value: Array<PortableTextBlock> | undefined
3881
+ incomingValue: Array<PortableTextBlock> | undefined
3886
3882
  internalDrag?: {
3887
3883
  ghost?: HTMLElement
3888
3884
  origin: Pick<EventPosition, 'selection'>
@@ -3915,7 +3911,7 @@ declare const editorMachine: StateMachine<
3915
3911
  initialReadOnly: boolean
3916
3912
  maxBlocks: number | undefined
3917
3913
  selection: EditorSelection
3918
- value: Array<PortableTextBlock> | undefined
3914
+ incomingValue: Array<PortableTextBlock> | undefined
3919
3915
  internalDrag?: {
3920
3916
  ghost?: HTMLElement
3921
3917
  origin: Pick<EventPosition, 'selection'>
@@ -3951,7 +3947,7 @@ declare const editorMachine: StateMachine<
3951
3947
  initialReadOnly: boolean
3952
3948
  maxBlocks: number | undefined
3953
3949
  selection: EditorSelection
3954
- value: Array<PortableTextBlock> | undefined
3950
+ incomingValue: Array<PortableTextBlock> | undefined
3955
3951
  internalDrag?: {
3956
3952
  ghost?: HTMLElement
3957
3953
  origin: Pick<EventPosition, 'selection'>
@@ -4108,7 +4104,7 @@ declare const editorMachine: StateMachine<
4108
4104
  initialReadOnly: boolean
4109
4105
  maxBlocks: number | undefined
4110
4106
  selection: EditorSelection
4111
- value: Array<PortableTextBlock> | undefined
4107
+ incomingValue: Array<PortableTextBlock> | undefined
4112
4108
  internalDrag?: {
4113
4109
  ghost?: HTMLElement
4114
4110
  origin: Pick<EventPosition, 'selection'>
@@ -4365,7 +4361,7 @@ declare const editorMachine: StateMachine<
4365
4361
  initialReadOnly: boolean
4366
4362
  maxBlocks: number | undefined
4367
4363
  selection: EditorSelection
4368
- value: Array<PortableTextBlock> | undefined
4364
+ incomingValue: Array<PortableTextBlock> | undefined
4369
4365
  internalDrag?: {
4370
4366
  ghost?: HTMLElement
4371
4367
  origin: Pick<EventPosition, 'selection'>
@@ -255,7 +255,13 @@ declare type Behavior<
255
255
  * @beta
256
256
  */
257
257
  declare type BehaviorAction =
258
- | SyntheticBehaviorEvent
258
+ | {
259
+ type: 'execute'
260
+ event:
261
+ | AbstractBehaviorEvent
262
+ | SyntheticBehaviorEvent
263
+ | CustomBehaviorEvent
264
+ }
259
265
  | {
260
266
  type: 'raise'
261
267
  event:
@@ -276,11 +282,6 @@ declare type BehaviorAction =
276
282
  */
277
283
  declare type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (
278
284
  payload: {
279
- /**
280
- * @deprecated
281
- * Use `snapshot` instead
282
- */
283
- context: EditorContext
284
285
  snapshot: EditorSnapshot
285
286
  event: TBehaviorEvent
286
287
  },
@@ -306,11 +307,6 @@ declare type BehaviorEventTypeNamespace =
306
307
  * @beta
307
308
  */
308
309
  declare type BehaviorGuard<TBehaviorEvent, TGuardResponse> = (payload: {
309
- /**
310
- * @deprecated
311
- * Use `snapshot` instead
312
- */
313
- context: EditorContext
314
310
  snapshot: EditorSnapshot
315
311
  event: TBehaviorEvent
316
312
  }) => TGuardResponse | false
@@ -661,7 +657,7 @@ declare const editorMachine: StateMachine<
661
657
  initialReadOnly: boolean
662
658
  maxBlocks: number | undefined
663
659
  selection: EditorSelection
664
- value: Array<PortableTextBlock> | undefined
660
+ incomingValue: Array<PortableTextBlock> | undefined
665
661
  internalDrag?: {
666
662
  ghost?: HTMLElement
667
663
  origin: Pick<EventPosition, 'selection'>
@@ -868,7 +864,7 @@ declare const editorMachine: StateMachine<
868
864
  maxBlocks?: number
869
865
  readOnly?: boolean
870
866
  schema: EditorSchema
871
- value?: Array<PortableTextBlock>
867
+ initialValue?: Array<PortableTextBlock>
872
868
  },
873
869
  NonReducibleUnknown,
874
870
  | PatchEvent
@@ -953,7 +949,7 @@ declare const editorMachine: StateMachine<
953
949
  maxBlocks?: number
954
950
  readOnly?: boolean
955
951
  schema: EditorSchema
956
- value?: Array<PortableTextBlock>
952
+ initialValue?: Array<PortableTextBlock>
957
953
  }
958
954
  self: ActorRef<
959
955
  MachineSnapshot<
@@ -966,7 +962,7 @@ declare const editorMachine: StateMachine<
966
962
  initialReadOnly: boolean
967
963
  maxBlocks: number | undefined
968
964
  selection: EditorSelection
969
- value: Array<PortableTextBlock> | undefined
965
+ incomingValue: Array<PortableTextBlock> | undefined
970
966
  internalDrag?: {
971
967
  ghost?: HTMLElement
972
968
  origin: Pick<EventPosition, 'selection'>
@@ -1230,7 +1226,7 @@ declare const editorMachine: StateMachine<
1230
1226
  selection: null
1231
1227
  initialReadOnly: boolean
1232
1228
  maxBlocks: number | undefined
1233
- value: PortableTextBlock[] | undefined
1229
+ incomingValue: PortableTextBlock[] | undefined
1234
1230
  }
1235
1231
  readonly on: {
1236
1232
  readonly 'notify.blurred': {
@@ -1244,7 +1240,7 @@ declare const editorMachine: StateMachine<
1244
1240
  initialReadOnly: boolean
1245
1241
  maxBlocks: number | undefined
1246
1242
  selection: EditorSelection
1247
- value: Array<PortableTextBlock> | undefined
1243
+ incomingValue: Array<PortableTextBlock> | undefined
1248
1244
  internalDrag?: {
1249
1245
  ghost?: HTMLElement
1250
1246
  origin: Pick<EventPosition, 'selection'>
@@ -1439,7 +1435,7 @@ declare const editorMachine: StateMachine<
1439
1435
  initialReadOnly: boolean
1440
1436
  maxBlocks: number | undefined
1441
1437
  selection: EditorSelection
1442
- value: Array<PortableTextBlock> | undefined
1438
+ incomingValue: Array<PortableTextBlock> | undefined
1443
1439
  internalDrag?: {
1444
1440
  ghost?: HTMLElement
1445
1441
  origin: Pick<EventPosition, 'selection'>
@@ -1633,7 +1629,7 @@ declare const editorMachine: StateMachine<
1633
1629
  initialReadOnly: boolean
1634
1630
  maxBlocks: number | undefined
1635
1631
  selection: EditorSelection
1636
- value: Array<PortableTextBlock> | undefined
1632
+ incomingValue: Array<PortableTextBlock> | undefined
1637
1633
  internalDrag?: {
1638
1634
  ghost?: HTMLElement
1639
1635
  origin: Pick<EventPosition, 'selection'>
@@ -1830,7 +1826,7 @@ declare const editorMachine: StateMachine<
1830
1826
  initialReadOnly: boolean
1831
1827
  maxBlocks: number | undefined
1832
1828
  selection: EditorSelection
1833
- value: Array<PortableTextBlock> | undefined
1829
+ incomingValue: Array<PortableTextBlock> | undefined
1834
1830
  internalDrag?: {
1835
1831
  ghost?: HTMLElement
1836
1832
  origin: Pick<EventPosition, 'selection'>
@@ -2026,7 +2022,7 @@ declare const editorMachine: StateMachine<
2026
2022
  initialReadOnly: boolean
2027
2023
  maxBlocks: number | undefined
2028
2024
  selection: EditorSelection
2029
- value: Array<PortableTextBlock> | undefined
2025
+ incomingValue: Array<PortableTextBlock> | undefined
2030
2026
  internalDrag?: {
2031
2027
  ghost?: HTMLElement
2032
2028
  origin: Pick<EventPosition, 'selection'>
@@ -2222,7 +2218,7 @@ declare const editorMachine: StateMachine<
2222
2218
  initialReadOnly: boolean
2223
2219
  maxBlocks: number | undefined
2224
2220
  selection: EditorSelection
2225
- value: Array<PortableTextBlock> | undefined
2221
+ incomingValue: Array<PortableTextBlock> | undefined
2226
2222
  internalDrag?: {
2227
2223
  ghost?: HTMLElement
2228
2224
  origin: Pick<EventPosition, 'selection'>
@@ -2369,7 +2365,7 @@ declare const editorMachine: StateMachine<
2369
2365
  initialReadOnly: boolean
2370
2366
  maxBlocks: number | undefined
2371
2367
  selection: EditorSelection
2372
- value: Array<PortableTextBlock> | undefined
2368
+ incomingValue: Array<PortableTextBlock> | undefined
2373
2369
  internalDrag?: {
2374
2370
  ghost?: HTMLElement
2375
2371
  origin: Pick<EventPosition, 'selection'>
@@ -2565,7 +2561,7 @@ declare const editorMachine: StateMachine<
2565
2561
  initialReadOnly: boolean
2566
2562
  maxBlocks: number | undefined
2567
2563
  selection: EditorSelection
2568
- value: Array<PortableTextBlock> | undefined
2564
+ incomingValue: Array<PortableTextBlock> | undefined
2569
2565
  internalDrag?: {
2570
2566
  ghost?: HTMLElement
2571
2567
  origin: Pick<EventPosition, 'selection'>
@@ -2760,7 +2756,7 @@ declare const editorMachine: StateMachine<
2760
2756
  initialReadOnly: boolean
2761
2757
  maxBlocks: number | undefined
2762
2758
  selection: EditorSelection
2763
- value: Array<PortableTextBlock> | undefined
2759
+ incomingValue: Array<PortableTextBlock> | undefined
2764
2760
  internalDrag?: {
2765
2761
  ghost?: HTMLElement
2766
2762
  origin: Pick<EventPosition, 'selection'>
@@ -2954,7 +2950,7 @@ declare const editorMachine: StateMachine<
2954
2950
  initialReadOnly: boolean
2955
2951
  maxBlocks: number | undefined
2956
2952
  selection: EditorSelection
2957
- value: Array<PortableTextBlock> | undefined
2953
+ incomingValue: Array<PortableTextBlock> | undefined
2958
2954
  internalDrag?: {
2959
2955
  ghost?: HTMLElement
2960
2956
  origin: Pick<EventPosition, 'selection'>
@@ -3155,7 +3151,7 @@ declare const editorMachine: StateMachine<
3155
3151
  initialReadOnly: boolean
3156
3152
  maxBlocks: number | undefined
3157
3153
  selection: EditorSelection
3158
- value: Array<PortableTextBlock> | undefined
3154
+ incomingValue: Array<PortableTextBlock> | undefined
3159
3155
  internalDrag?: {
3160
3156
  ghost?: HTMLElement
3161
3157
  origin: Pick<EventPosition, 'selection'>
@@ -3350,7 +3346,7 @@ declare const editorMachine: StateMachine<
3350
3346
  initialReadOnly: boolean
3351
3347
  maxBlocks: number | undefined
3352
3348
  selection: EditorSelection
3353
- value: Array<PortableTextBlock> | undefined
3349
+ incomingValue: Array<PortableTextBlock> | undefined
3354
3350
  internalDrag?: {
3355
3351
  ghost?: HTMLElement
3356
3352
  origin: Pick<EventPosition, 'selection'>
@@ -3502,7 +3498,7 @@ declare const editorMachine: StateMachine<
3502
3498
  initialReadOnly: boolean
3503
3499
  maxBlocks: number | undefined
3504
3500
  selection: EditorSelection
3505
- value: Array<PortableTextBlock> | undefined
3501
+ incomingValue: Array<PortableTextBlock> | undefined
3506
3502
  internalDrag?: {
3507
3503
  ghost?: HTMLElement
3508
3504
  origin: Pick<EventPosition, 'selection'>
@@ -3651,7 +3647,7 @@ declare const editorMachine: StateMachine<
3651
3647
  initialReadOnly: boolean
3652
3648
  maxBlocks: number | undefined
3653
3649
  selection: EditorSelection
3654
- value: Array<PortableTextBlock> | undefined
3650
+ incomingValue: Array<PortableTextBlock> | undefined
3655
3651
  internalDrag?: {
3656
3652
  ghost?: HTMLElement
3657
3653
  origin: Pick<EventPosition, 'selection'>
@@ -3812,7 +3808,7 @@ declare const editorMachine: StateMachine<
3812
3808
  initialReadOnly: boolean
3813
3809
  maxBlocks: number | undefined
3814
3810
  selection: EditorSelection
3815
- value: Array<PortableTextBlock> | undefined
3811
+ incomingValue: Array<PortableTextBlock> | undefined
3816
3812
  internalDrag?: {
3817
3813
  ghost?: HTMLElement
3818
3814
  origin: Pick<EventPosition, 'selection'>
@@ -3850,7 +3846,7 @@ declare const editorMachine: StateMachine<
3850
3846
  initialReadOnly: boolean
3851
3847
  maxBlocks: number | undefined
3852
3848
  selection: EditorSelection
3853
- value: Array<PortableTextBlock> | undefined
3849
+ incomingValue: Array<PortableTextBlock> | undefined
3854
3850
  internalDrag?: {
3855
3851
  ghost?: HTMLElement
3856
3852
  origin: Pick<EventPosition, 'selection'>
@@ -3882,7 +3878,7 @@ declare const editorMachine: StateMachine<
3882
3878
  initialReadOnly: boolean
3883
3879
  maxBlocks: number | undefined
3884
3880
  selection: EditorSelection
3885
- value: Array<PortableTextBlock> | undefined
3881
+ incomingValue: Array<PortableTextBlock> | undefined
3886
3882
  internalDrag?: {
3887
3883
  ghost?: HTMLElement
3888
3884
  origin: Pick<EventPosition, 'selection'>
@@ -3915,7 +3911,7 @@ declare const editorMachine: StateMachine<
3915
3911
  initialReadOnly: boolean
3916
3912
  maxBlocks: number | undefined
3917
3913
  selection: EditorSelection
3918
- value: Array<PortableTextBlock> | undefined
3914
+ incomingValue: Array<PortableTextBlock> | undefined
3919
3915
  internalDrag?: {
3920
3916
  ghost?: HTMLElement
3921
3917
  origin: Pick<EventPosition, 'selection'>
@@ -3951,7 +3947,7 @@ declare const editorMachine: StateMachine<
3951
3947
  initialReadOnly: boolean
3952
3948
  maxBlocks: number | undefined
3953
3949
  selection: EditorSelection
3954
- value: Array<PortableTextBlock> | undefined
3950
+ incomingValue: Array<PortableTextBlock> | undefined
3955
3951
  internalDrag?: {
3956
3952
  ghost?: HTMLElement
3957
3953
  origin: Pick<EventPosition, 'selection'>
@@ -4108,7 +4104,7 @@ declare const editorMachine: StateMachine<
4108
4104
  initialReadOnly: boolean
4109
4105
  maxBlocks: number | undefined
4110
4106
  selection: EditorSelection
4111
- value: Array<PortableTextBlock> | undefined
4107
+ incomingValue: Array<PortableTextBlock> | undefined
4112
4108
  internalDrag?: {
4113
4109
  ghost?: HTMLElement
4114
4110
  origin: Pick<EventPosition, 'selection'>
@@ -4365,7 +4361,7 @@ declare const editorMachine: StateMachine<
4365
4361
  initialReadOnly: boolean
4366
4362
  maxBlocks: number | undefined
4367
4363
  selection: EditorSelection
4368
- value: Array<PortableTextBlock> | undefined
4364
+ incomingValue: Array<PortableTextBlock> | undefined
4369
4365
  internalDrag?: {
4370
4366
  ghost?: HTMLElement
4371
4367
  origin: Pick<EventPosition, 'selection'>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.45.3",
3
+ "version": "1.46.0",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -3,7 +3,7 @@ import {createPairRegex} from '../internal-utils/get-text-to-emphasize'
3
3
  import * as selectors from '../selectors'
4
4
  import type {BlockOffset} from '../types/block-offset'
5
5
  import * as utils from '../utils'
6
- import {raise} from './behavior.types.action'
6
+ import {effect, execute} from './behavior.types.action'
7
7
  import {defineBehavior} from './behavior.types.behavior'
8
8
 
9
9
  export function createDecoratorPairBehavior(config: {
@@ -160,43 +160,40 @@ export function createDecoratorPairBehavior(config: {
160
160
  },
161
161
  actions: [
162
162
  // Insert the text as usual in its own undo step
163
- ({event}) => [event],
163
+ ({event}) => [execute(event)],
164
164
  (_, {prefixOffsets, suffixOffsets, decorator}) => [
165
165
  // Decorate the text between the prefix and suffix
166
- {
166
+ execute({
167
167
  type: 'decorator.add',
168
168
  decorator,
169
169
  at: {
170
170
  anchor: prefixOffsets.focus,
171
171
  focus: suffixOffsets.anchor,
172
172
  },
173
- },
173
+ }),
174
174
  // Delete the suffix
175
- raise({
175
+ execute({
176
176
  type: 'delete.text',
177
177
  at: suffixOffsets,
178
178
  }),
179
179
  // Delete the prefix
180
- raise({
180
+ execute({
181
181
  type: 'delete.text',
182
182
  at: prefixOffsets,
183
183
  }),
184
184
  // Toggle the decorator off so the next inserted text isn't emphasized
185
- {
185
+ execute({
186
186
  type: 'decorator.remove',
187
187
  decorator,
188
- },
189
- {
190
- type: 'effect',
191
- effect: () => {
192
- config.onDecorate({
193
- ...suffixOffsets.anchor,
194
- offset:
195
- suffixOffsets.anchor.offset -
196
- (prefixOffsets.focus.offset - prefixOffsets.anchor.offset),
197
- })
198
- },
199
- },
188
+ }),
189
+ effect(() => {
190
+ config.onDecorate({
191
+ ...suffixOffsets.anchor,
192
+ offset:
193
+ suffixOffsets.anchor.offset -
194
+ (prefixOffsets.focus.offset - prefixOffsets.anchor.offset),
195
+ })
196
+ }),
200
197
  ],
201
198
  ],
202
199
  })