@portabletext/editor 1.36.5 → 1.37.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 (46) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  2. package/lib/_chunks-cjs/behavior.markdown.cjs +1 -1
  3. package/lib/_chunks-cjs/editor-provider.cjs +104 -7
  4. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  5. package/lib/_chunks-cjs/util.block-offsets-to-selection.cjs.map +1 -1
  6. package/lib/_chunks-es/behavior.core.js.map +1 -1
  7. package/lib/_chunks-es/behavior.markdown.js +1 -1
  8. package/lib/_chunks-es/editor-provider.js +108 -11
  9. package/lib/_chunks-es/editor-provider.js.map +1 -1
  10. package/lib/_chunks-es/util.block-offsets-to-selection.js.map +1 -1
  11. package/lib/behaviors/index.d.cts +59 -0
  12. package/lib/behaviors/index.d.ts +59 -0
  13. package/lib/index.d.cts +59 -0
  14. package/lib/index.d.ts +59 -0
  15. package/lib/plugins/index.cjs +1 -1
  16. package/lib/plugins/index.d.cts +59 -0
  17. package/lib/plugins/index.d.ts +59 -0
  18. package/lib/plugins/index.js +1 -1
  19. package/lib/selectors/index.cjs +69 -14
  20. package/lib/selectors/index.cjs.map +1 -1
  21. package/lib/selectors/index.d.cts +75 -0
  22. package/lib/selectors/index.d.ts +75 -0
  23. package/lib/selectors/index.js +63 -8
  24. package/lib/selectors/index.js.map +1 -1
  25. package/lib/utils/index.d.cts +59 -0
  26. package/lib/utils/index.d.ts +59 -0
  27. package/package.json +7 -7
  28. package/src/behavior-actions/behavior.action.decorator.add.ts +1 -0
  29. package/src/behavior-actions/behavior.action.delete.text.ts +1 -0
  30. package/src/behavior-actions/behavior.action.delete.ts +1 -3
  31. package/src/behavior-actions/behavior.action.insert-blocks.ts +98 -2
  32. package/src/behavior-actions/behavior.actions.ts +1 -0
  33. package/src/behaviors/behavior.default.ts +1 -0
  34. package/src/behaviors/behavior.types.ts +1 -0
  35. package/src/editor/editor-machine.ts +16 -3
  36. package/src/editor/editor-selector.ts +1 -0
  37. package/src/editor/editor-snapshot.ts +4 -0
  38. package/src/internal-utils/create-test-snapshot.ts +1 -0
  39. package/src/internal-utils/parse-blocks.ts +22 -0
  40. package/src/selectors/index.ts +2 -0
  41. package/src/selectors/selector.get-focus-inline-object.ts +21 -0
  42. package/src/selectors/selector.is-overlapping-selection.test.ts +171 -0
  43. package/src/selectors/selector.is-overlapping-selection.ts +108 -4
  44. package/src/selectors/selector.is-point-after-selection.ts +3 -1
  45. package/src/selectors/selector.is-point-before-selection.ts +3 -1
  46. package/src/selectors/selector.is-selecting-entire-blocks.ts +34 -0
@@ -695,6 +695,7 @@ declare type EditorContext = {
695
695
  activeDecorators: Array<string>
696
696
  converters: Array<Converter>
697
697
  keyGenerator: () => string
698
+ readOnly: boolean
698
699
  schema: EditorSchema
699
700
  selection: EditorSelection
700
701
  value: Array<PortableTextBlock>
@@ -807,6 +808,7 @@ declare const editorMachine: StateMachine<
807
808
  | {
808
809
  type: 'insert.blocks'
809
810
  blocks: Array<PortableTextBlock>
811
+ placement: 'auto' | 'after' | 'before'
810
812
  }
811
813
  | {
812
814
  type: 'insert.block object'
@@ -1241,6 +1243,7 @@ declare const editorMachine: StateMachine<
1241
1243
  | {
1242
1244
  type: 'insert.blocks'
1243
1245
  blocks: Array<PortableTextBlock>
1246
+ placement: 'auto' | 'after' | 'before'
1244
1247
  }
1245
1248
  | {
1246
1249
  type: 'insert.block object'
@@ -1565,6 +1568,7 @@ declare const editorMachine: StateMachine<
1565
1568
  | {
1566
1569
  type: 'insert.blocks'
1567
1570
  blocks: Array<PortableTextBlock>
1571
+ placement: 'auto' | 'after' | 'before'
1568
1572
  }
1569
1573
  | {
1570
1574
  type: 'insert.block object'
@@ -1922,6 +1926,7 @@ declare const editorMachine: StateMachine<
1922
1926
  | {
1923
1927
  type: 'insert.blocks'
1924
1928
  blocks: Array<PortableTextBlock>
1929
+ placement: 'auto' | 'after' | 'before'
1925
1930
  }
1926
1931
  | {
1927
1932
  type: 'insert.block object'
@@ -2303,6 +2308,7 @@ declare const editorMachine: StateMachine<
2303
2308
  | {
2304
2309
  type: 'insert.blocks'
2305
2310
  blocks: Array<PortableTextBlock>
2311
+ placement: 'auto' | 'after' | 'before'
2306
2312
  }
2307
2313
  | {
2308
2314
  type: 'insert.block object'
@@ -2658,6 +2664,7 @@ declare const editorMachine: StateMachine<
2658
2664
  | {
2659
2665
  type: 'insert.blocks'
2660
2666
  blocks: Array<PortableTextBlock>
2667
+ placement: 'auto' | 'after' | 'before'
2661
2668
  }
2662
2669
  | {
2663
2670
  type: 'insert.block object'
@@ -2950,6 +2957,7 @@ declare const editorMachine: StateMachine<
2950
2957
  | {
2951
2958
  type: 'insert.blocks'
2952
2959
  blocks: Array<PortableTextBlock>
2960
+ placement: 'auto' | 'after' | 'before'
2953
2961
  }
2954
2962
  | {
2955
2963
  type: 'insert.block object'
@@ -3305,6 +3313,7 @@ declare const editorMachine: StateMachine<
3305
3313
  | {
3306
3314
  type: 'insert.blocks'
3307
3315
  blocks: Array<PortableTextBlock>
3316
+ placement: 'auto' | 'after' | 'before'
3308
3317
  }
3309
3318
  | {
3310
3319
  type: 'insert.block object'
@@ -3600,6 +3609,7 @@ declare const editorMachine: StateMachine<
3600
3609
  | {
3601
3610
  type: 'insert.blocks'
3602
3611
  blocks: Array<PortableTextBlock>
3612
+ placement: 'auto' | 'after' | 'before'
3603
3613
  }
3604
3614
  | {
3605
3615
  type: 'insert.block object'
@@ -3955,6 +3965,7 @@ declare const editorMachine: StateMachine<
3955
3965
  | {
3956
3966
  type: 'insert.blocks'
3957
3967
  blocks: Array<PortableTextBlock>
3968
+ placement: 'auto' | 'after' | 'before'
3958
3969
  }
3959
3970
  | {
3960
3971
  type: 'insert.block object'
@@ -4249,6 +4260,7 @@ declare const editorMachine: StateMachine<
4249
4260
  | {
4250
4261
  type: 'insert.blocks'
4251
4262
  blocks: Array<PortableTextBlock>
4263
+ placement: 'auto' | 'after' | 'before'
4252
4264
  }
4253
4265
  | {
4254
4266
  type: 'insert.block object'
@@ -4604,6 +4616,7 @@ declare const editorMachine: StateMachine<
4604
4616
  | {
4605
4617
  type: 'insert.blocks'
4606
4618
  blocks: Array<PortableTextBlock>
4619
+ placement: 'auto' | 'after' | 'before'
4607
4620
  }
4608
4621
  | {
4609
4622
  type: 'insert.block object'
@@ -4897,6 +4910,7 @@ declare const editorMachine: StateMachine<
4897
4910
  | {
4898
4911
  type: 'insert.blocks'
4899
4912
  blocks: Array<PortableTextBlock>
4913
+ placement: 'auto' | 'after' | 'before'
4900
4914
  }
4901
4915
  | {
4902
4916
  type: 'insert.block object'
@@ -5252,6 +5266,7 @@ declare const editorMachine: StateMachine<
5252
5266
  | {
5253
5267
  type: 'insert.blocks'
5254
5268
  blocks: Array<PortableTextBlock>
5269
+ placement: 'auto' | 'after' | 'before'
5255
5270
  }
5256
5271
  | {
5257
5272
  type: 'insert.block object'
@@ -5546,6 +5561,7 @@ declare const editorMachine: StateMachine<
5546
5561
  | {
5547
5562
  type: 'insert.blocks'
5548
5563
  blocks: Array<PortableTextBlock>
5564
+ placement: 'auto' | 'after' | 'before'
5549
5565
  }
5550
5566
  | {
5551
5567
  type: 'insert.block object'
@@ -5919,6 +5935,7 @@ declare const editorMachine: StateMachine<
5919
5935
  | {
5920
5936
  type: 'insert.blocks'
5921
5937
  blocks: Array<PortableTextBlock>
5938
+ placement: 'auto' | 'after' | 'before'
5922
5939
  }
5923
5940
  | {
5924
5941
  type: 'insert.block object'
@@ -6274,6 +6291,7 @@ declare const editorMachine: StateMachine<
6274
6291
  | {
6275
6292
  type: 'insert.blocks'
6276
6293
  blocks: Array<PortableTextBlock>
6294
+ placement: 'auto' | 'after' | 'before'
6277
6295
  }
6278
6296
  | {
6279
6297
  type: 'insert.block object'
@@ -6568,6 +6586,7 @@ declare const editorMachine: StateMachine<
6568
6586
  | {
6569
6587
  type: 'insert.blocks'
6570
6588
  blocks: Array<PortableTextBlock>
6589
+ placement: 'auto' | 'after' | 'before'
6571
6590
  }
6572
6591
  | {
6573
6592
  type: 'insert.block object'
@@ -6923,6 +6942,7 @@ declare const editorMachine: StateMachine<
6923
6942
  | {
6924
6943
  type: 'insert.blocks'
6925
6944
  blocks: Array<PortableTextBlock>
6945
+ placement: 'auto' | 'after' | 'before'
6926
6946
  }
6927
6947
  | {
6928
6948
  type: 'insert.block object'
@@ -7215,6 +7235,7 @@ declare const editorMachine: StateMachine<
7215
7235
  | {
7216
7236
  type: 'insert.blocks'
7217
7237
  blocks: Array<PortableTextBlock>
7238
+ placement: 'auto' | 'after' | 'before'
7218
7239
  }
7219
7240
  | {
7220
7241
  type: 'insert.block object'
@@ -7570,6 +7591,7 @@ declare const editorMachine: StateMachine<
7570
7591
  | {
7571
7592
  type: 'insert.blocks'
7572
7593
  blocks: Array<PortableTextBlock>
7594
+ placement: 'auto' | 'after' | 'before'
7573
7595
  }
7574
7596
  | {
7575
7597
  type: 'insert.block object'
@@ -7863,6 +7885,7 @@ declare const editorMachine: StateMachine<
7863
7885
  | {
7864
7886
  type: 'insert.blocks'
7865
7887
  blocks: Array<PortableTextBlock>
7888
+ placement: 'auto' | 'after' | 'before'
7866
7889
  }
7867
7890
  | {
7868
7891
  type: 'insert.block object'
@@ -8218,6 +8241,7 @@ declare const editorMachine: StateMachine<
8218
8241
  | {
8219
8242
  type: 'insert.blocks'
8220
8243
  blocks: Array<PortableTextBlock>
8244
+ placement: 'auto' | 'after' | 'before'
8221
8245
  }
8222
8246
  | {
8223
8247
  type: 'insert.block object'
@@ -8514,6 +8538,7 @@ declare const editorMachine: StateMachine<
8514
8538
  | {
8515
8539
  type: 'insert.blocks'
8516
8540
  blocks: Array<PortableTextBlock>
8541
+ placement: 'auto' | 'after' | 'before'
8517
8542
  }
8518
8543
  | {
8519
8544
  type: 'insert.block object'
@@ -8869,6 +8894,7 @@ declare const editorMachine: StateMachine<
8869
8894
  | {
8870
8895
  type: 'insert.blocks'
8871
8896
  blocks: Array<PortableTextBlock>
8897
+ placement: 'auto' | 'after' | 'before'
8872
8898
  }
8873
8899
  | {
8874
8900
  type: 'insert.block object'
@@ -9165,6 +9191,7 @@ declare const editorMachine: StateMachine<
9165
9191
  | {
9166
9192
  type: 'insert.blocks'
9167
9193
  blocks: Array<PortableTextBlock>
9194
+ placement: 'auto' | 'after' | 'before'
9168
9195
  }
9169
9196
  | {
9170
9197
  type: 'insert.block object'
@@ -9543,6 +9570,7 @@ declare const editorMachine: StateMachine<
9543
9570
  | {
9544
9571
  type: 'insert.blocks'
9545
9572
  blocks: Array<PortableTextBlock>
9573
+ placement: 'auto' | 'after' | 'before'
9546
9574
  }
9547
9575
  | {
9548
9576
  type: 'insert.block object'
@@ -9918,6 +9946,7 @@ declare const editorMachine: StateMachine<
9918
9946
  | {
9919
9947
  type: 'insert.blocks'
9920
9948
  blocks: Array<PortableTextBlock>
9949
+ placement: 'auto' | 'after' | 'before'
9921
9950
  }
9922
9951
  | {
9923
9952
  type: 'insert.block object'
@@ -10443,6 +10472,7 @@ declare const editorMachine: StateMachine<
10443
10472
  | {
10444
10473
  type: 'insert.blocks'
10445
10474
  blocks: Array<PortableTextBlock>
10475
+ placement: 'auto' | 'after' | 'before'
10446
10476
  }
10447
10477
  | {
10448
10478
  type: 'insert.block object'
@@ -10800,6 +10830,7 @@ declare const editorMachine: StateMachine<
10800
10830
  | {
10801
10831
  type: 'insert.blocks'
10802
10832
  blocks: Array<PortableTextBlock>
10833
+ placement: 'auto' | 'after' | 'before'
10803
10834
  }
10804
10835
  | {
10805
10836
  type: 'insert.block object'
@@ -11099,6 +11130,7 @@ declare const editorMachine: StateMachine<
11099
11130
  | {
11100
11131
  type: 'insert.blocks'
11101
11132
  blocks: Array<PortableTextBlock>
11133
+ placement: 'auto' | 'after' | 'before'
11102
11134
  }
11103
11135
  | {
11104
11136
  type: 'insert.block object'
@@ -11456,6 +11488,7 @@ declare const editorMachine: StateMachine<
11456
11488
  | {
11457
11489
  type: 'insert.blocks'
11458
11490
  blocks: Array<PortableTextBlock>
11491
+ placement: 'auto' | 'after' | 'before'
11459
11492
  }
11460
11493
  | {
11461
11494
  type: 'insert.block object'
@@ -11748,6 +11781,7 @@ declare const editorMachine: StateMachine<
11748
11781
  | {
11749
11782
  type: 'insert.blocks'
11750
11783
  blocks: Array<PortableTextBlock>
11784
+ placement: 'auto' | 'after' | 'before'
11751
11785
  }
11752
11786
  | {
11753
11787
  type: 'insert.block object'
@@ -12105,6 +12139,7 @@ declare const editorMachine: StateMachine<
12105
12139
  | {
12106
12140
  type: 'insert.blocks'
12107
12141
  blocks: Array<PortableTextBlock>
12142
+ placement: 'auto' | 'after' | 'before'
12108
12143
  }
12109
12144
  | {
12110
12145
  type: 'insert.block object'
@@ -12397,6 +12432,7 @@ declare const editorMachine: StateMachine<
12397
12432
  | {
12398
12433
  type: 'insert.blocks'
12399
12434
  blocks: Array<PortableTextBlock>
12435
+ placement: 'auto' | 'after' | 'before'
12400
12436
  }
12401
12437
  | {
12402
12438
  type: 'insert.block object'
@@ -12754,6 +12790,7 @@ declare const editorMachine: StateMachine<
12754
12790
  | {
12755
12791
  type: 'insert.blocks'
12756
12792
  blocks: Array<PortableTextBlock>
12793
+ placement: 'auto' | 'after' | 'before'
12757
12794
  }
12758
12795
  | {
12759
12796
  type: 'insert.block object'
@@ -13059,6 +13096,7 @@ declare const editorMachine: StateMachine<
13059
13096
  | {
13060
13097
  type: 'insert.blocks'
13061
13098
  blocks: Array<PortableTextBlock>
13099
+ placement: 'auto' | 'after' | 'before'
13062
13100
  }
13063
13101
  | {
13064
13102
  type: 'insert.block object'
@@ -13416,6 +13454,7 @@ declare const editorMachine: StateMachine<
13416
13454
  | {
13417
13455
  type: 'insert.blocks'
13418
13456
  blocks: Array<PortableTextBlock>
13457
+ placement: 'auto' | 'after' | 'before'
13419
13458
  }
13420
13459
  | {
13421
13460
  type: 'insert.block object'
@@ -13722,6 +13761,7 @@ declare const editorMachine: StateMachine<
13722
13761
  | {
13723
13762
  type: 'insert.blocks'
13724
13763
  blocks: Array<PortableTextBlock>
13764
+ placement: 'auto' | 'after' | 'before'
13725
13765
  }
13726
13766
  | {
13727
13767
  type: 'insert.block object'
@@ -14079,6 +14119,7 @@ declare const editorMachine: StateMachine<
14079
14119
  | {
14080
14120
  type: 'insert.blocks'
14081
14121
  blocks: Array<PortableTextBlock>
14122
+ placement: 'auto' | 'after' | 'before'
14082
14123
  }
14083
14124
  | {
14084
14125
  type: 'insert.block object'
@@ -14371,6 +14412,7 @@ declare const editorMachine: StateMachine<
14371
14412
  | {
14372
14413
  type: 'insert.blocks'
14373
14414
  blocks: Array<PortableTextBlock>
14415
+ placement: 'auto' | 'after' | 'before'
14374
14416
  }
14375
14417
  | {
14376
14418
  type: 'insert.block object'
@@ -14728,6 +14770,7 @@ declare const editorMachine: StateMachine<
14728
14770
  | {
14729
14771
  type: 'insert.blocks'
14730
14772
  blocks: Array<PortableTextBlock>
14773
+ placement: 'auto' | 'after' | 'before'
14731
14774
  }
14732
14775
  | {
14733
14776
  type: 'insert.block object'
@@ -15023,6 +15066,7 @@ declare const editorMachine: StateMachine<
15023
15066
  | {
15024
15067
  type: 'insert.blocks'
15025
15068
  blocks: Array<PortableTextBlock>
15069
+ placement: 'auto' | 'after' | 'before'
15026
15070
  }
15027
15071
  | {
15028
15072
  type: 'insert.block object'
@@ -15380,6 +15424,7 @@ declare const editorMachine: StateMachine<
15380
15424
  | {
15381
15425
  type: 'insert.blocks'
15382
15426
  blocks: Array<PortableTextBlock>
15427
+ placement: 'auto' | 'after' | 'before'
15383
15428
  }
15384
15429
  | {
15385
15430
  type: 'insert.block object'
@@ -15580,6 +15625,7 @@ declare const editorMachine: StateMachine<
15580
15625
  | {
15581
15626
  type: 'insert.blocks'
15582
15627
  blocks: Array<PortableTextBlock>
15628
+ placement: 'auto' | 'after' | 'before'
15583
15629
  }
15584
15630
  | {
15585
15631
  type: 'insert.block object'
@@ -15726,6 +15772,7 @@ declare const editorMachine: StateMachine<
15726
15772
  | {
15727
15773
  type: 'insert.blocks'
15728
15774
  blocks: Array<PortableTextBlock>
15775
+ placement: 'auto' | 'after' | 'before'
15729
15776
  }
15730
15777
  | {
15731
15778
  type: 'insert.block object'
@@ -16083,6 +16130,7 @@ declare const editorMachine: StateMachine<
16083
16130
  | {
16084
16131
  type: 'insert.blocks'
16085
16132
  blocks: Array<PortableTextBlock>
16133
+ placement: 'auto' | 'after' | 'before'
16086
16134
  }
16087
16135
  | {
16088
16136
  type: 'insert.block object'
@@ -16384,6 +16432,7 @@ declare const editorMachine: StateMachine<
16384
16432
  | {
16385
16433
  type: 'insert.blocks'
16386
16434
  blocks: Array<PortableTextBlock>
16435
+ placement: 'auto' | 'after' | 'before'
16387
16436
  }
16388
16437
  | {
16389
16438
  type: 'insert.block object'
@@ -16741,6 +16790,7 @@ declare const editorMachine: StateMachine<
16741
16790
  | {
16742
16791
  type: 'insert.blocks'
16743
16792
  blocks: Array<PortableTextBlock>
16793
+ placement: 'auto' | 'after' | 'before'
16744
16794
  }
16745
16795
  | {
16746
16796
  type: 'insert.block object'
@@ -17043,6 +17093,7 @@ declare const editorMachine: StateMachine<
17043
17093
  | {
17044
17094
  type: 'insert.blocks'
17045
17095
  blocks: Array<PortableTextBlock>
17096
+ placement: 'auto' | 'after' | 'before'
17046
17097
  }
17047
17098
  | {
17048
17099
  type: 'insert.block object'
@@ -17400,6 +17451,7 @@ declare const editorMachine: StateMachine<
17400
17451
  | {
17401
17452
  type: 'insert.blocks'
17402
17453
  blocks: Array<PortableTextBlock>
17454
+ placement: 'auto' | 'after' | 'before'
17403
17455
  }
17404
17456
  | {
17405
17457
  type: 'insert.block object'
@@ -17693,6 +17745,7 @@ declare const editorMachine: StateMachine<
17693
17745
  | {
17694
17746
  type: 'insert.blocks'
17695
17747
  blocks: Array<PortableTextBlock>
17748
+ placement: 'auto' | 'after' | 'before'
17696
17749
  }
17697
17750
  | {
17698
17751
  type: 'insert.block object'
@@ -18050,6 +18103,7 @@ declare const editorMachine: StateMachine<
18050
18103
  | {
18051
18104
  type: 'insert.blocks'
18052
18105
  blocks: Array<PortableTextBlock>
18106
+ placement: 'auto' | 'after' | 'before'
18053
18107
  }
18054
18108
  | {
18055
18109
  type: 'insert.block object'
@@ -18345,6 +18399,7 @@ declare const editorMachine: StateMachine<
18345
18399
  | {
18346
18400
  type: 'insert.blocks'
18347
18401
  blocks: Array<PortableTextBlock>
18402
+ placement: 'auto' | 'after' | 'before'
18348
18403
  }
18349
18404
  | {
18350
18405
  type: 'insert.block object'
@@ -18702,6 +18757,7 @@ declare const editorMachine: StateMachine<
18702
18757
  | {
18703
18758
  type: 'insert.blocks'
18704
18759
  blocks: Array<PortableTextBlock>
18760
+ placement: 'auto' | 'after' | 'before'
18705
18761
  }
18706
18762
  | {
18707
18763
  type: 'insert.block object'
@@ -19003,6 +19059,7 @@ declare const editorMachine: StateMachine<
19003
19059
  | {
19004
19060
  type: 'insert.blocks'
19005
19061
  blocks: Array<PortableTextBlock>
19062
+ placement: 'auto' | 'after' | 'before'
19006
19063
  }
19007
19064
  | {
19008
19065
  type: 'insert.block object'
@@ -19360,6 +19417,7 @@ declare const editorMachine: StateMachine<
19360
19417
  | {
19361
19418
  type: 'insert.blocks'
19362
19419
  blocks: Array<PortableTextBlock>
19420
+ placement: 'auto' | 'after' | 'before'
19363
19421
  }
19364
19422
  | {
19365
19423
  type: 'insert.block object'
@@ -20035,6 +20093,7 @@ export declare type SyntheticBehaviorEvent =
20035
20093
  | {
20036
20094
  type: 'insert.blocks'
20037
20095
  blocks: Array<PortableTextBlock>
20096
+ placement: 'auto' | 'after' | 'before'
20038
20097
  }
20039
20098
  | {
20040
20099
  type: 'insert.block object'