@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
@@ -341,6 +341,7 @@ declare type EditorContext = {
341
341
  activeDecorators: Array<string>
342
342
  converters: Array<Converter>
343
343
  keyGenerator: () => string
344
+ readOnly: boolean
344
345
  schema: EditorSchema
345
346
  selection: EditorSelection
346
347
  value: Array<PortableTextBlock>
@@ -510,6 +511,7 @@ declare const editorMachine: StateMachine<
510
511
  | {
511
512
  type: 'insert.blocks'
512
513
  blocks: Array<PortableTextBlock>
514
+ placement: 'auto' | 'after' | 'before'
513
515
  }
514
516
  | {
515
517
  type: 'insert.block object'
@@ -944,6 +946,7 @@ declare const editorMachine: StateMachine<
944
946
  | {
945
947
  type: 'insert.blocks'
946
948
  blocks: Array<PortableTextBlock>
949
+ placement: 'auto' | 'after' | 'before'
947
950
  }
948
951
  | {
949
952
  type: 'insert.block object'
@@ -1268,6 +1271,7 @@ declare const editorMachine: StateMachine<
1268
1271
  | {
1269
1272
  type: 'insert.blocks'
1270
1273
  blocks: Array<PortableTextBlock>
1274
+ placement: 'auto' | 'after' | 'before'
1271
1275
  }
1272
1276
  | {
1273
1277
  type: 'insert.block object'
@@ -1625,6 +1629,7 @@ declare const editorMachine: StateMachine<
1625
1629
  | {
1626
1630
  type: 'insert.blocks'
1627
1631
  blocks: Array<PortableTextBlock>
1632
+ placement: 'auto' | 'after' | 'before'
1628
1633
  }
1629
1634
  | {
1630
1635
  type: 'insert.block object'
@@ -2006,6 +2011,7 @@ declare const editorMachine: StateMachine<
2006
2011
  | {
2007
2012
  type: 'insert.blocks'
2008
2013
  blocks: Array<PortableTextBlock>
2014
+ placement: 'auto' | 'after' | 'before'
2009
2015
  }
2010
2016
  | {
2011
2017
  type: 'insert.block object'
@@ -2361,6 +2367,7 @@ declare const editorMachine: StateMachine<
2361
2367
  | {
2362
2368
  type: 'insert.blocks'
2363
2369
  blocks: Array<PortableTextBlock>
2370
+ placement: 'auto' | 'after' | 'before'
2364
2371
  }
2365
2372
  | {
2366
2373
  type: 'insert.block object'
@@ -2653,6 +2660,7 @@ declare const editorMachine: StateMachine<
2653
2660
  | {
2654
2661
  type: 'insert.blocks'
2655
2662
  blocks: Array<PortableTextBlock>
2663
+ placement: 'auto' | 'after' | 'before'
2656
2664
  }
2657
2665
  | {
2658
2666
  type: 'insert.block object'
@@ -3008,6 +3016,7 @@ declare const editorMachine: StateMachine<
3008
3016
  | {
3009
3017
  type: 'insert.blocks'
3010
3018
  blocks: Array<PortableTextBlock>
3019
+ placement: 'auto' | 'after' | 'before'
3011
3020
  }
3012
3021
  | {
3013
3022
  type: 'insert.block object'
@@ -3303,6 +3312,7 @@ declare const editorMachine: StateMachine<
3303
3312
  | {
3304
3313
  type: 'insert.blocks'
3305
3314
  blocks: Array<PortableTextBlock>
3315
+ placement: 'auto' | 'after' | 'before'
3306
3316
  }
3307
3317
  | {
3308
3318
  type: 'insert.block object'
@@ -3658,6 +3668,7 @@ declare const editorMachine: StateMachine<
3658
3668
  | {
3659
3669
  type: 'insert.blocks'
3660
3670
  blocks: Array<PortableTextBlock>
3671
+ placement: 'auto' | 'after' | 'before'
3661
3672
  }
3662
3673
  | {
3663
3674
  type: 'insert.block object'
@@ -3952,6 +3963,7 @@ declare const editorMachine: StateMachine<
3952
3963
  | {
3953
3964
  type: 'insert.blocks'
3954
3965
  blocks: Array<PortableTextBlock>
3966
+ placement: 'auto' | 'after' | 'before'
3955
3967
  }
3956
3968
  | {
3957
3969
  type: 'insert.block object'
@@ -4307,6 +4319,7 @@ declare const editorMachine: StateMachine<
4307
4319
  | {
4308
4320
  type: 'insert.blocks'
4309
4321
  blocks: Array<PortableTextBlock>
4322
+ placement: 'auto' | 'after' | 'before'
4310
4323
  }
4311
4324
  | {
4312
4325
  type: 'insert.block object'
@@ -4600,6 +4613,7 @@ declare const editorMachine: StateMachine<
4600
4613
  | {
4601
4614
  type: 'insert.blocks'
4602
4615
  blocks: Array<PortableTextBlock>
4616
+ placement: 'auto' | 'after' | 'before'
4603
4617
  }
4604
4618
  | {
4605
4619
  type: 'insert.block object'
@@ -4955,6 +4969,7 @@ declare const editorMachine: StateMachine<
4955
4969
  | {
4956
4970
  type: 'insert.blocks'
4957
4971
  blocks: Array<PortableTextBlock>
4972
+ placement: 'auto' | 'after' | 'before'
4958
4973
  }
4959
4974
  | {
4960
4975
  type: 'insert.block object'
@@ -5249,6 +5264,7 @@ declare const editorMachine: StateMachine<
5249
5264
  | {
5250
5265
  type: 'insert.blocks'
5251
5266
  blocks: Array<PortableTextBlock>
5267
+ placement: 'auto' | 'after' | 'before'
5252
5268
  }
5253
5269
  | {
5254
5270
  type: 'insert.block object'
@@ -5622,6 +5638,7 @@ declare const editorMachine: StateMachine<
5622
5638
  | {
5623
5639
  type: 'insert.blocks'
5624
5640
  blocks: Array<PortableTextBlock>
5641
+ placement: 'auto' | 'after' | 'before'
5625
5642
  }
5626
5643
  | {
5627
5644
  type: 'insert.block object'
@@ -5977,6 +5994,7 @@ declare const editorMachine: StateMachine<
5977
5994
  | {
5978
5995
  type: 'insert.blocks'
5979
5996
  blocks: Array<PortableTextBlock>
5997
+ placement: 'auto' | 'after' | 'before'
5980
5998
  }
5981
5999
  | {
5982
6000
  type: 'insert.block object'
@@ -6271,6 +6289,7 @@ declare const editorMachine: StateMachine<
6271
6289
  | {
6272
6290
  type: 'insert.blocks'
6273
6291
  blocks: Array<PortableTextBlock>
6292
+ placement: 'auto' | 'after' | 'before'
6274
6293
  }
6275
6294
  | {
6276
6295
  type: 'insert.block object'
@@ -6626,6 +6645,7 @@ declare const editorMachine: StateMachine<
6626
6645
  | {
6627
6646
  type: 'insert.blocks'
6628
6647
  blocks: Array<PortableTextBlock>
6648
+ placement: 'auto' | 'after' | 'before'
6629
6649
  }
6630
6650
  | {
6631
6651
  type: 'insert.block object'
@@ -6918,6 +6938,7 @@ declare const editorMachine: StateMachine<
6918
6938
  | {
6919
6939
  type: 'insert.blocks'
6920
6940
  blocks: Array<PortableTextBlock>
6941
+ placement: 'auto' | 'after' | 'before'
6921
6942
  }
6922
6943
  | {
6923
6944
  type: 'insert.block object'
@@ -7273,6 +7294,7 @@ declare const editorMachine: StateMachine<
7273
7294
  | {
7274
7295
  type: 'insert.blocks'
7275
7296
  blocks: Array<PortableTextBlock>
7297
+ placement: 'auto' | 'after' | 'before'
7276
7298
  }
7277
7299
  | {
7278
7300
  type: 'insert.block object'
@@ -7566,6 +7588,7 @@ declare const editorMachine: StateMachine<
7566
7588
  | {
7567
7589
  type: 'insert.blocks'
7568
7590
  blocks: Array<PortableTextBlock>
7591
+ placement: 'auto' | 'after' | 'before'
7569
7592
  }
7570
7593
  | {
7571
7594
  type: 'insert.block object'
@@ -7921,6 +7944,7 @@ declare const editorMachine: StateMachine<
7921
7944
  | {
7922
7945
  type: 'insert.blocks'
7923
7946
  blocks: Array<PortableTextBlock>
7947
+ placement: 'auto' | 'after' | 'before'
7924
7948
  }
7925
7949
  | {
7926
7950
  type: 'insert.block object'
@@ -8217,6 +8241,7 @@ declare const editorMachine: StateMachine<
8217
8241
  | {
8218
8242
  type: 'insert.blocks'
8219
8243
  blocks: Array<PortableTextBlock>
8244
+ placement: 'auto' | 'after' | 'before'
8220
8245
  }
8221
8246
  | {
8222
8247
  type: 'insert.block object'
@@ -8572,6 +8597,7 @@ declare const editorMachine: StateMachine<
8572
8597
  | {
8573
8598
  type: 'insert.blocks'
8574
8599
  blocks: Array<PortableTextBlock>
8600
+ placement: 'auto' | 'after' | 'before'
8575
8601
  }
8576
8602
  | {
8577
8603
  type: 'insert.block object'
@@ -8868,6 +8894,7 @@ declare const editorMachine: StateMachine<
8868
8894
  | {
8869
8895
  type: 'insert.blocks'
8870
8896
  blocks: Array<PortableTextBlock>
8897
+ placement: 'auto' | 'after' | 'before'
8871
8898
  }
8872
8899
  | {
8873
8900
  type: 'insert.block object'
@@ -9246,6 +9273,7 @@ declare const editorMachine: StateMachine<
9246
9273
  | {
9247
9274
  type: 'insert.blocks'
9248
9275
  blocks: Array<PortableTextBlock>
9276
+ placement: 'auto' | 'after' | 'before'
9249
9277
  }
9250
9278
  | {
9251
9279
  type: 'insert.block object'
@@ -9621,6 +9649,7 @@ declare const editorMachine: StateMachine<
9621
9649
  | {
9622
9650
  type: 'insert.blocks'
9623
9651
  blocks: Array<PortableTextBlock>
9652
+ placement: 'auto' | 'after' | 'before'
9624
9653
  }
9625
9654
  | {
9626
9655
  type: 'insert.block object'
@@ -10146,6 +10175,7 @@ declare const editorMachine: StateMachine<
10146
10175
  | {
10147
10176
  type: 'insert.blocks'
10148
10177
  blocks: Array<PortableTextBlock>
10178
+ placement: 'auto' | 'after' | 'before'
10149
10179
  }
10150
10180
  | {
10151
10181
  type: 'insert.block object'
@@ -10503,6 +10533,7 @@ declare const editorMachine: StateMachine<
10503
10533
  | {
10504
10534
  type: 'insert.blocks'
10505
10535
  blocks: Array<PortableTextBlock>
10536
+ placement: 'auto' | 'after' | 'before'
10506
10537
  }
10507
10538
  | {
10508
10539
  type: 'insert.block object'
@@ -10802,6 +10833,7 @@ declare const editorMachine: StateMachine<
10802
10833
  | {
10803
10834
  type: 'insert.blocks'
10804
10835
  blocks: Array<PortableTextBlock>
10836
+ placement: 'auto' | 'after' | 'before'
10805
10837
  }
10806
10838
  | {
10807
10839
  type: 'insert.block object'
@@ -11159,6 +11191,7 @@ declare const editorMachine: StateMachine<
11159
11191
  | {
11160
11192
  type: 'insert.blocks'
11161
11193
  blocks: Array<PortableTextBlock>
11194
+ placement: 'auto' | 'after' | 'before'
11162
11195
  }
11163
11196
  | {
11164
11197
  type: 'insert.block object'
@@ -11451,6 +11484,7 @@ declare const editorMachine: StateMachine<
11451
11484
  | {
11452
11485
  type: 'insert.blocks'
11453
11486
  blocks: Array<PortableTextBlock>
11487
+ placement: 'auto' | 'after' | 'before'
11454
11488
  }
11455
11489
  | {
11456
11490
  type: 'insert.block object'
@@ -11808,6 +11842,7 @@ declare const editorMachine: StateMachine<
11808
11842
  | {
11809
11843
  type: 'insert.blocks'
11810
11844
  blocks: Array<PortableTextBlock>
11845
+ placement: 'auto' | 'after' | 'before'
11811
11846
  }
11812
11847
  | {
11813
11848
  type: 'insert.block object'
@@ -12100,6 +12135,7 @@ declare const editorMachine: StateMachine<
12100
12135
  | {
12101
12136
  type: 'insert.blocks'
12102
12137
  blocks: Array<PortableTextBlock>
12138
+ placement: 'auto' | 'after' | 'before'
12103
12139
  }
12104
12140
  | {
12105
12141
  type: 'insert.block object'
@@ -12457,6 +12493,7 @@ declare const editorMachine: StateMachine<
12457
12493
  | {
12458
12494
  type: 'insert.blocks'
12459
12495
  blocks: Array<PortableTextBlock>
12496
+ placement: 'auto' | 'after' | 'before'
12460
12497
  }
12461
12498
  | {
12462
12499
  type: 'insert.block object'
@@ -12762,6 +12799,7 @@ declare const editorMachine: StateMachine<
12762
12799
  | {
12763
12800
  type: 'insert.blocks'
12764
12801
  blocks: Array<PortableTextBlock>
12802
+ placement: 'auto' | 'after' | 'before'
12765
12803
  }
12766
12804
  | {
12767
12805
  type: 'insert.block object'
@@ -13119,6 +13157,7 @@ declare const editorMachine: StateMachine<
13119
13157
  | {
13120
13158
  type: 'insert.blocks'
13121
13159
  blocks: Array<PortableTextBlock>
13160
+ placement: 'auto' | 'after' | 'before'
13122
13161
  }
13123
13162
  | {
13124
13163
  type: 'insert.block object'
@@ -13425,6 +13464,7 @@ declare const editorMachine: StateMachine<
13425
13464
  | {
13426
13465
  type: 'insert.blocks'
13427
13466
  blocks: Array<PortableTextBlock>
13467
+ placement: 'auto' | 'after' | 'before'
13428
13468
  }
13429
13469
  | {
13430
13470
  type: 'insert.block object'
@@ -13782,6 +13822,7 @@ declare const editorMachine: StateMachine<
13782
13822
  | {
13783
13823
  type: 'insert.blocks'
13784
13824
  blocks: Array<PortableTextBlock>
13825
+ placement: 'auto' | 'after' | 'before'
13785
13826
  }
13786
13827
  | {
13787
13828
  type: 'insert.block object'
@@ -14074,6 +14115,7 @@ declare const editorMachine: StateMachine<
14074
14115
  | {
14075
14116
  type: 'insert.blocks'
14076
14117
  blocks: Array<PortableTextBlock>
14118
+ placement: 'auto' | 'after' | 'before'
14077
14119
  }
14078
14120
  | {
14079
14121
  type: 'insert.block object'
@@ -14431,6 +14473,7 @@ declare const editorMachine: StateMachine<
14431
14473
  | {
14432
14474
  type: 'insert.blocks'
14433
14475
  blocks: Array<PortableTextBlock>
14476
+ placement: 'auto' | 'after' | 'before'
14434
14477
  }
14435
14478
  | {
14436
14479
  type: 'insert.block object'
@@ -14726,6 +14769,7 @@ declare const editorMachine: StateMachine<
14726
14769
  | {
14727
14770
  type: 'insert.blocks'
14728
14771
  blocks: Array<PortableTextBlock>
14772
+ placement: 'auto' | 'after' | 'before'
14729
14773
  }
14730
14774
  | {
14731
14775
  type: 'insert.block object'
@@ -15083,6 +15127,7 @@ declare const editorMachine: StateMachine<
15083
15127
  | {
15084
15128
  type: 'insert.blocks'
15085
15129
  blocks: Array<PortableTextBlock>
15130
+ placement: 'auto' | 'after' | 'before'
15086
15131
  }
15087
15132
  | {
15088
15133
  type: 'insert.block object'
@@ -15283,6 +15328,7 @@ declare const editorMachine: StateMachine<
15283
15328
  | {
15284
15329
  type: 'insert.blocks'
15285
15330
  blocks: Array<PortableTextBlock>
15331
+ placement: 'auto' | 'after' | 'before'
15286
15332
  }
15287
15333
  | {
15288
15334
  type: 'insert.block object'
@@ -15429,6 +15475,7 @@ declare const editorMachine: StateMachine<
15429
15475
  | {
15430
15476
  type: 'insert.blocks'
15431
15477
  blocks: Array<PortableTextBlock>
15478
+ placement: 'auto' | 'after' | 'before'
15432
15479
  }
15433
15480
  | {
15434
15481
  type: 'insert.block object'
@@ -15786,6 +15833,7 @@ declare const editorMachine: StateMachine<
15786
15833
  | {
15787
15834
  type: 'insert.blocks'
15788
15835
  blocks: Array<PortableTextBlock>
15836
+ placement: 'auto' | 'after' | 'before'
15789
15837
  }
15790
15838
  | {
15791
15839
  type: 'insert.block object'
@@ -16087,6 +16135,7 @@ declare const editorMachine: StateMachine<
16087
16135
  | {
16088
16136
  type: 'insert.blocks'
16089
16137
  blocks: Array<PortableTextBlock>
16138
+ placement: 'auto' | 'after' | 'before'
16090
16139
  }
16091
16140
  | {
16092
16141
  type: 'insert.block object'
@@ -16444,6 +16493,7 @@ declare const editorMachine: StateMachine<
16444
16493
  | {
16445
16494
  type: 'insert.blocks'
16446
16495
  blocks: Array<PortableTextBlock>
16496
+ placement: 'auto' | 'after' | 'before'
16447
16497
  }
16448
16498
  | {
16449
16499
  type: 'insert.block object'
@@ -16746,6 +16796,7 @@ declare const editorMachine: StateMachine<
16746
16796
  | {
16747
16797
  type: 'insert.blocks'
16748
16798
  blocks: Array<PortableTextBlock>
16799
+ placement: 'auto' | 'after' | 'before'
16749
16800
  }
16750
16801
  | {
16751
16802
  type: 'insert.block object'
@@ -17103,6 +17154,7 @@ declare const editorMachine: StateMachine<
17103
17154
  | {
17104
17155
  type: 'insert.blocks'
17105
17156
  blocks: Array<PortableTextBlock>
17157
+ placement: 'auto' | 'after' | 'before'
17106
17158
  }
17107
17159
  | {
17108
17160
  type: 'insert.block object'
@@ -17396,6 +17448,7 @@ declare const editorMachine: StateMachine<
17396
17448
  | {
17397
17449
  type: 'insert.blocks'
17398
17450
  blocks: Array<PortableTextBlock>
17451
+ placement: 'auto' | 'after' | 'before'
17399
17452
  }
17400
17453
  | {
17401
17454
  type: 'insert.block object'
@@ -17753,6 +17806,7 @@ declare const editorMachine: StateMachine<
17753
17806
  | {
17754
17807
  type: 'insert.blocks'
17755
17808
  blocks: Array<PortableTextBlock>
17809
+ placement: 'auto' | 'after' | 'before'
17756
17810
  }
17757
17811
  | {
17758
17812
  type: 'insert.block object'
@@ -18048,6 +18102,7 @@ declare const editorMachine: StateMachine<
18048
18102
  | {
18049
18103
  type: 'insert.blocks'
18050
18104
  blocks: Array<PortableTextBlock>
18105
+ placement: 'auto' | 'after' | 'before'
18051
18106
  }
18052
18107
  | {
18053
18108
  type: 'insert.block object'
@@ -18405,6 +18460,7 @@ declare const editorMachine: StateMachine<
18405
18460
  | {
18406
18461
  type: 'insert.blocks'
18407
18462
  blocks: Array<PortableTextBlock>
18463
+ placement: 'auto' | 'after' | 'before'
18408
18464
  }
18409
18465
  | {
18410
18466
  type: 'insert.block object'
@@ -18706,6 +18762,7 @@ declare const editorMachine: StateMachine<
18706
18762
  | {
18707
18763
  type: 'insert.blocks'
18708
18764
  blocks: Array<PortableTextBlock>
18765
+ placement: 'auto' | 'after' | 'before'
18709
18766
  }
18710
18767
  | {
18711
18768
  type: 'insert.block object'
@@ -19063,6 +19120,7 @@ declare const editorMachine: StateMachine<
19063
19120
  | {
19064
19121
  type: 'insert.blocks'
19065
19122
  blocks: Array<PortableTextBlock>
19123
+ placement: 'auto' | 'after' | 'before'
19066
19124
  }
19067
19125
  | {
19068
19126
  type: 'insert.block object'
@@ -19871,6 +19929,7 @@ declare type SyntheticBehaviorEvent =
19871
19929
  | {
19872
19930
  type: 'insert.blocks'
19873
19931
  blocks: Array<PortableTextBlock>
19932
+ placement: 'auto' | 'after' | 'before'
19874
19933
  }
19875
19934
  | {
19876
19935
  type: 'insert.block object'