@portabletext/editor 1.36.4 → 1.36.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +41 -3
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/util.block-offsets-to-selection.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +41 -3
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/util.block-offsets-to-selection.js.map +1 -1
- package/lib/behaviors/index.d.cts +58 -0
- package/lib/behaviors/index.d.ts +58 -0
- package/lib/index.d.cts +58 -0
- package/lib/index.d.ts +58 -0
- package/lib/plugins/index.d.cts +58 -0
- package/lib/plugins/index.d.ts +58 -0
- package/lib/selectors/index.d.cts +58 -0
- package/lib/selectors/index.d.ts +58 -0
- package/lib/utils/index.d.cts +58 -0
- package/lib/utils/index.d.ts +58 -0
- package/package.json +14 -11
- package/src/behavior-actions/behavior.action.insert-blocks.ts +32 -1
- package/src/behavior-actions/behavior.actions.ts +1 -0
- package/src/behaviors/behavior.default.ts +1 -0
- package/src/behaviors/behavior.types.ts +1 -0
- package/src/internal-utils/parse-blocks.ts +22 -0
- package/src/internal-utils/test-key-generator.ts +2 -2
package/lib/utils/index.d.ts
CHANGED
|
@@ -464,6 +464,7 @@ declare const editorMachine: StateMachine<
|
|
|
464
464
|
| {
|
|
465
465
|
type: 'insert.blocks'
|
|
466
466
|
blocks: Array<PortableTextBlock>
|
|
467
|
+
placement: 'auto' | 'after' | 'before'
|
|
467
468
|
}
|
|
468
469
|
| {
|
|
469
470
|
type: 'insert.block object'
|
|
@@ -898,6 +899,7 @@ declare const editorMachine: StateMachine<
|
|
|
898
899
|
| {
|
|
899
900
|
type: 'insert.blocks'
|
|
900
901
|
blocks: Array<PortableTextBlock>
|
|
902
|
+
placement: 'auto' | 'after' | 'before'
|
|
901
903
|
}
|
|
902
904
|
| {
|
|
903
905
|
type: 'insert.block object'
|
|
@@ -1222,6 +1224,7 @@ declare const editorMachine: StateMachine<
|
|
|
1222
1224
|
| {
|
|
1223
1225
|
type: 'insert.blocks'
|
|
1224
1226
|
blocks: Array<PortableTextBlock>
|
|
1227
|
+
placement: 'auto' | 'after' | 'before'
|
|
1225
1228
|
}
|
|
1226
1229
|
| {
|
|
1227
1230
|
type: 'insert.block object'
|
|
@@ -1579,6 +1582,7 @@ declare const editorMachine: StateMachine<
|
|
|
1579
1582
|
| {
|
|
1580
1583
|
type: 'insert.blocks'
|
|
1581
1584
|
blocks: Array<PortableTextBlock>
|
|
1585
|
+
placement: 'auto' | 'after' | 'before'
|
|
1582
1586
|
}
|
|
1583
1587
|
| {
|
|
1584
1588
|
type: 'insert.block object'
|
|
@@ -1960,6 +1964,7 @@ declare const editorMachine: StateMachine<
|
|
|
1960
1964
|
| {
|
|
1961
1965
|
type: 'insert.blocks'
|
|
1962
1966
|
blocks: Array<PortableTextBlock>
|
|
1967
|
+
placement: 'auto' | 'after' | 'before'
|
|
1963
1968
|
}
|
|
1964
1969
|
| {
|
|
1965
1970
|
type: 'insert.block object'
|
|
@@ -2315,6 +2320,7 @@ declare const editorMachine: StateMachine<
|
|
|
2315
2320
|
| {
|
|
2316
2321
|
type: 'insert.blocks'
|
|
2317
2322
|
blocks: Array<PortableTextBlock>
|
|
2323
|
+
placement: 'auto' | 'after' | 'before'
|
|
2318
2324
|
}
|
|
2319
2325
|
| {
|
|
2320
2326
|
type: 'insert.block object'
|
|
@@ -2607,6 +2613,7 @@ declare const editorMachine: StateMachine<
|
|
|
2607
2613
|
| {
|
|
2608
2614
|
type: 'insert.blocks'
|
|
2609
2615
|
blocks: Array<PortableTextBlock>
|
|
2616
|
+
placement: 'auto' | 'after' | 'before'
|
|
2610
2617
|
}
|
|
2611
2618
|
| {
|
|
2612
2619
|
type: 'insert.block object'
|
|
@@ -2962,6 +2969,7 @@ declare const editorMachine: StateMachine<
|
|
|
2962
2969
|
| {
|
|
2963
2970
|
type: 'insert.blocks'
|
|
2964
2971
|
blocks: Array<PortableTextBlock>
|
|
2972
|
+
placement: 'auto' | 'after' | 'before'
|
|
2965
2973
|
}
|
|
2966
2974
|
| {
|
|
2967
2975
|
type: 'insert.block object'
|
|
@@ -3257,6 +3265,7 @@ declare const editorMachine: StateMachine<
|
|
|
3257
3265
|
| {
|
|
3258
3266
|
type: 'insert.blocks'
|
|
3259
3267
|
blocks: Array<PortableTextBlock>
|
|
3268
|
+
placement: 'auto' | 'after' | 'before'
|
|
3260
3269
|
}
|
|
3261
3270
|
| {
|
|
3262
3271
|
type: 'insert.block object'
|
|
@@ -3612,6 +3621,7 @@ declare const editorMachine: StateMachine<
|
|
|
3612
3621
|
| {
|
|
3613
3622
|
type: 'insert.blocks'
|
|
3614
3623
|
blocks: Array<PortableTextBlock>
|
|
3624
|
+
placement: 'auto' | 'after' | 'before'
|
|
3615
3625
|
}
|
|
3616
3626
|
| {
|
|
3617
3627
|
type: 'insert.block object'
|
|
@@ -3906,6 +3916,7 @@ declare const editorMachine: StateMachine<
|
|
|
3906
3916
|
| {
|
|
3907
3917
|
type: 'insert.blocks'
|
|
3908
3918
|
blocks: Array<PortableTextBlock>
|
|
3919
|
+
placement: 'auto' | 'after' | 'before'
|
|
3909
3920
|
}
|
|
3910
3921
|
| {
|
|
3911
3922
|
type: 'insert.block object'
|
|
@@ -4261,6 +4272,7 @@ declare const editorMachine: StateMachine<
|
|
|
4261
4272
|
| {
|
|
4262
4273
|
type: 'insert.blocks'
|
|
4263
4274
|
blocks: Array<PortableTextBlock>
|
|
4275
|
+
placement: 'auto' | 'after' | 'before'
|
|
4264
4276
|
}
|
|
4265
4277
|
| {
|
|
4266
4278
|
type: 'insert.block object'
|
|
@@ -4554,6 +4566,7 @@ declare const editorMachine: StateMachine<
|
|
|
4554
4566
|
| {
|
|
4555
4567
|
type: 'insert.blocks'
|
|
4556
4568
|
blocks: Array<PortableTextBlock>
|
|
4569
|
+
placement: 'auto' | 'after' | 'before'
|
|
4557
4570
|
}
|
|
4558
4571
|
| {
|
|
4559
4572
|
type: 'insert.block object'
|
|
@@ -4909,6 +4922,7 @@ declare const editorMachine: StateMachine<
|
|
|
4909
4922
|
| {
|
|
4910
4923
|
type: 'insert.blocks'
|
|
4911
4924
|
blocks: Array<PortableTextBlock>
|
|
4925
|
+
placement: 'auto' | 'after' | 'before'
|
|
4912
4926
|
}
|
|
4913
4927
|
| {
|
|
4914
4928
|
type: 'insert.block object'
|
|
@@ -5203,6 +5217,7 @@ declare const editorMachine: StateMachine<
|
|
|
5203
5217
|
| {
|
|
5204
5218
|
type: 'insert.blocks'
|
|
5205
5219
|
blocks: Array<PortableTextBlock>
|
|
5220
|
+
placement: 'auto' | 'after' | 'before'
|
|
5206
5221
|
}
|
|
5207
5222
|
| {
|
|
5208
5223
|
type: 'insert.block object'
|
|
@@ -5576,6 +5591,7 @@ declare const editorMachine: StateMachine<
|
|
|
5576
5591
|
| {
|
|
5577
5592
|
type: 'insert.blocks'
|
|
5578
5593
|
blocks: Array<PortableTextBlock>
|
|
5594
|
+
placement: 'auto' | 'after' | 'before'
|
|
5579
5595
|
}
|
|
5580
5596
|
| {
|
|
5581
5597
|
type: 'insert.block object'
|
|
@@ -5931,6 +5947,7 @@ declare const editorMachine: StateMachine<
|
|
|
5931
5947
|
| {
|
|
5932
5948
|
type: 'insert.blocks'
|
|
5933
5949
|
blocks: Array<PortableTextBlock>
|
|
5950
|
+
placement: 'auto' | 'after' | 'before'
|
|
5934
5951
|
}
|
|
5935
5952
|
| {
|
|
5936
5953
|
type: 'insert.block object'
|
|
@@ -6225,6 +6242,7 @@ declare const editorMachine: StateMachine<
|
|
|
6225
6242
|
| {
|
|
6226
6243
|
type: 'insert.blocks'
|
|
6227
6244
|
blocks: Array<PortableTextBlock>
|
|
6245
|
+
placement: 'auto' | 'after' | 'before'
|
|
6228
6246
|
}
|
|
6229
6247
|
| {
|
|
6230
6248
|
type: 'insert.block object'
|
|
@@ -6580,6 +6598,7 @@ declare const editorMachine: StateMachine<
|
|
|
6580
6598
|
| {
|
|
6581
6599
|
type: 'insert.blocks'
|
|
6582
6600
|
blocks: Array<PortableTextBlock>
|
|
6601
|
+
placement: 'auto' | 'after' | 'before'
|
|
6583
6602
|
}
|
|
6584
6603
|
| {
|
|
6585
6604
|
type: 'insert.block object'
|
|
@@ -6872,6 +6891,7 @@ declare const editorMachine: StateMachine<
|
|
|
6872
6891
|
| {
|
|
6873
6892
|
type: 'insert.blocks'
|
|
6874
6893
|
blocks: Array<PortableTextBlock>
|
|
6894
|
+
placement: 'auto' | 'after' | 'before'
|
|
6875
6895
|
}
|
|
6876
6896
|
| {
|
|
6877
6897
|
type: 'insert.block object'
|
|
@@ -7227,6 +7247,7 @@ declare const editorMachine: StateMachine<
|
|
|
7227
7247
|
| {
|
|
7228
7248
|
type: 'insert.blocks'
|
|
7229
7249
|
blocks: Array<PortableTextBlock>
|
|
7250
|
+
placement: 'auto' | 'after' | 'before'
|
|
7230
7251
|
}
|
|
7231
7252
|
| {
|
|
7232
7253
|
type: 'insert.block object'
|
|
@@ -7520,6 +7541,7 @@ declare const editorMachine: StateMachine<
|
|
|
7520
7541
|
| {
|
|
7521
7542
|
type: 'insert.blocks'
|
|
7522
7543
|
blocks: Array<PortableTextBlock>
|
|
7544
|
+
placement: 'auto' | 'after' | 'before'
|
|
7523
7545
|
}
|
|
7524
7546
|
| {
|
|
7525
7547
|
type: 'insert.block object'
|
|
@@ -7875,6 +7897,7 @@ declare const editorMachine: StateMachine<
|
|
|
7875
7897
|
| {
|
|
7876
7898
|
type: 'insert.blocks'
|
|
7877
7899
|
blocks: Array<PortableTextBlock>
|
|
7900
|
+
placement: 'auto' | 'after' | 'before'
|
|
7878
7901
|
}
|
|
7879
7902
|
| {
|
|
7880
7903
|
type: 'insert.block object'
|
|
@@ -8171,6 +8194,7 @@ declare const editorMachine: StateMachine<
|
|
|
8171
8194
|
| {
|
|
8172
8195
|
type: 'insert.blocks'
|
|
8173
8196
|
blocks: Array<PortableTextBlock>
|
|
8197
|
+
placement: 'auto' | 'after' | 'before'
|
|
8174
8198
|
}
|
|
8175
8199
|
| {
|
|
8176
8200
|
type: 'insert.block object'
|
|
@@ -8526,6 +8550,7 @@ declare const editorMachine: StateMachine<
|
|
|
8526
8550
|
| {
|
|
8527
8551
|
type: 'insert.blocks'
|
|
8528
8552
|
blocks: Array<PortableTextBlock>
|
|
8553
|
+
placement: 'auto' | 'after' | 'before'
|
|
8529
8554
|
}
|
|
8530
8555
|
| {
|
|
8531
8556
|
type: 'insert.block object'
|
|
@@ -8822,6 +8847,7 @@ declare const editorMachine: StateMachine<
|
|
|
8822
8847
|
| {
|
|
8823
8848
|
type: 'insert.blocks'
|
|
8824
8849
|
blocks: Array<PortableTextBlock>
|
|
8850
|
+
placement: 'auto' | 'after' | 'before'
|
|
8825
8851
|
}
|
|
8826
8852
|
| {
|
|
8827
8853
|
type: 'insert.block object'
|
|
@@ -9200,6 +9226,7 @@ declare const editorMachine: StateMachine<
|
|
|
9200
9226
|
| {
|
|
9201
9227
|
type: 'insert.blocks'
|
|
9202
9228
|
blocks: Array<PortableTextBlock>
|
|
9229
|
+
placement: 'auto' | 'after' | 'before'
|
|
9203
9230
|
}
|
|
9204
9231
|
| {
|
|
9205
9232
|
type: 'insert.block object'
|
|
@@ -9575,6 +9602,7 @@ declare const editorMachine: StateMachine<
|
|
|
9575
9602
|
| {
|
|
9576
9603
|
type: 'insert.blocks'
|
|
9577
9604
|
blocks: Array<PortableTextBlock>
|
|
9605
|
+
placement: 'auto' | 'after' | 'before'
|
|
9578
9606
|
}
|
|
9579
9607
|
| {
|
|
9580
9608
|
type: 'insert.block object'
|
|
@@ -10100,6 +10128,7 @@ declare const editorMachine: StateMachine<
|
|
|
10100
10128
|
| {
|
|
10101
10129
|
type: 'insert.blocks'
|
|
10102
10130
|
blocks: Array<PortableTextBlock>
|
|
10131
|
+
placement: 'auto' | 'after' | 'before'
|
|
10103
10132
|
}
|
|
10104
10133
|
| {
|
|
10105
10134
|
type: 'insert.block object'
|
|
@@ -10457,6 +10486,7 @@ declare const editorMachine: StateMachine<
|
|
|
10457
10486
|
| {
|
|
10458
10487
|
type: 'insert.blocks'
|
|
10459
10488
|
blocks: Array<PortableTextBlock>
|
|
10489
|
+
placement: 'auto' | 'after' | 'before'
|
|
10460
10490
|
}
|
|
10461
10491
|
| {
|
|
10462
10492
|
type: 'insert.block object'
|
|
@@ -10756,6 +10786,7 @@ declare const editorMachine: StateMachine<
|
|
|
10756
10786
|
| {
|
|
10757
10787
|
type: 'insert.blocks'
|
|
10758
10788
|
blocks: Array<PortableTextBlock>
|
|
10789
|
+
placement: 'auto' | 'after' | 'before'
|
|
10759
10790
|
}
|
|
10760
10791
|
| {
|
|
10761
10792
|
type: 'insert.block object'
|
|
@@ -11113,6 +11144,7 @@ declare const editorMachine: StateMachine<
|
|
|
11113
11144
|
| {
|
|
11114
11145
|
type: 'insert.blocks'
|
|
11115
11146
|
blocks: Array<PortableTextBlock>
|
|
11147
|
+
placement: 'auto' | 'after' | 'before'
|
|
11116
11148
|
}
|
|
11117
11149
|
| {
|
|
11118
11150
|
type: 'insert.block object'
|
|
@@ -11405,6 +11437,7 @@ declare const editorMachine: StateMachine<
|
|
|
11405
11437
|
| {
|
|
11406
11438
|
type: 'insert.blocks'
|
|
11407
11439
|
blocks: Array<PortableTextBlock>
|
|
11440
|
+
placement: 'auto' | 'after' | 'before'
|
|
11408
11441
|
}
|
|
11409
11442
|
| {
|
|
11410
11443
|
type: 'insert.block object'
|
|
@@ -11762,6 +11795,7 @@ declare const editorMachine: StateMachine<
|
|
|
11762
11795
|
| {
|
|
11763
11796
|
type: 'insert.blocks'
|
|
11764
11797
|
blocks: Array<PortableTextBlock>
|
|
11798
|
+
placement: 'auto' | 'after' | 'before'
|
|
11765
11799
|
}
|
|
11766
11800
|
| {
|
|
11767
11801
|
type: 'insert.block object'
|
|
@@ -12054,6 +12088,7 @@ declare const editorMachine: StateMachine<
|
|
|
12054
12088
|
| {
|
|
12055
12089
|
type: 'insert.blocks'
|
|
12056
12090
|
blocks: Array<PortableTextBlock>
|
|
12091
|
+
placement: 'auto' | 'after' | 'before'
|
|
12057
12092
|
}
|
|
12058
12093
|
| {
|
|
12059
12094
|
type: 'insert.block object'
|
|
@@ -12411,6 +12446,7 @@ declare const editorMachine: StateMachine<
|
|
|
12411
12446
|
| {
|
|
12412
12447
|
type: 'insert.blocks'
|
|
12413
12448
|
blocks: Array<PortableTextBlock>
|
|
12449
|
+
placement: 'auto' | 'after' | 'before'
|
|
12414
12450
|
}
|
|
12415
12451
|
| {
|
|
12416
12452
|
type: 'insert.block object'
|
|
@@ -12716,6 +12752,7 @@ declare const editorMachine: StateMachine<
|
|
|
12716
12752
|
| {
|
|
12717
12753
|
type: 'insert.blocks'
|
|
12718
12754
|
blocks: Array<PortableTextBlock>
|
|
12755
|
+
placement: 'auto' | 'after' | 'before'
|
|
12719
12756
|
}
|
|
12720
12757
|
| {
|
|
12721
12758
|
type: 'insert.block object'
|
|
@@ -13073,6 +13110,7 @@ declare const editorMachine: StateMachine<
|
|
|
13073
13110
|
| {
|
|
13074
13111
|
type: 'insert.blocks'
|
|
13075
13112
|
blocks: Array<PortableTextBlock>
|
|
13113
|
+
placement: 'auto' | 'after' | 'before'
|
|
13076
13114
|
}
|
|
13077
13115
|
| {
|
|
13078
13116
|
type: 'insert.block object'
|
|
@@ -13379,6 +13417,7 @@ declare const editorMachine: StateMachine<
|
|
|
13379
13417
|
| {
|
|
13380
13418
|
type: 'insert.blocks'
|
|
13381
13419
|
blocks: Array<PortableTextBlock>
|
|
13420
|
+
placement: 'auto' | 'after' | 'before'
|
|
13382
13421
|
}
|
|
13383
13422
|
| {
|
|
13384
13423
|
type: 'insert.block object'
|
|
@@ -13736,6 +13775,7 @@ declare const editorMachine: StateMachine<
|
|
|
13736
13775
|
| {
|
|
13737
13776
|
type: 'insert.blocks'
|
|
13738
13777
|
blocks: Array<PortableTextBlock>
|
|
13778
|
+
placement: 'auto' | 'after' | 'before'
|
|
13739
13779
|
}
|
|
13740
13780
|
| {
|
|
13741
13781
|
type: 'insert.block object'
|
|
@@ -14028,6 +14068,7 @@ declare const editorMachine: StateMachine<
|
|
|
14028
14068
|
| {
|
|
14029
14069
|
type: 'insert.blocks'
|
|
14030
14070
|
blocks: Array<PortableTextBlock>
|
|
14071
|
+
placement: 'auto' | 'after' | 'before'
|
|
14031
14072
|
}
|
|
14032
14073
|
| {
|
|
14033
14074
|
type: 'insert.block object'
|
|
@@ -14385,6 +14426,7 @@ declare const editorMachine: StateMachine<
|
|
|
14385
14426
|
| {
|
|
14386
14427
|
type: 'insert.blocks'
|
|
14387
14428
|
blocks: Array<PortableTextBlock>
|
|
14429
|
+
placement: 'auto' | 'after' | 'before'
|
|
14388
14430
|
}
|
|
14389
14431
|
| {
|
|
14390
14432
|
type: 'insert.block object'
|
|
@@ -14680,6 +14722,7 @@ declare const editorMachine: StateMachine<
|
|
|
14680
14722
|
| {
|
|
14681
14723
|
type: 'insert.blocks'
|
|
14682
14724
|
blocks: Array<PortableTextBlock>
|
|
14725
|
+
placement: 'auto' | 'after' | 'before'
|
|
14683
14726
|
}
|
|
14684
14727
|
| {
|
|
14685
14728
|
type: 'insert.block object'
|
|
@@ -15037,6 +15080,7 @@ declare const editorMachine: StateMachine<
|
|
|
15037
15080
|
| {
|
|
15038
15081
|
type: 'insert.blocks'
|
|
15039
15082
|
blocks: Array<PortableTextBlock>
|
|
15083
|
+
placement: 'auto' | 'after' | 'before'
|
|
15040
15084
|
}
|
|
15041
15085
|
| {
|
|
15042
15086
|
type: 'insert.block object'
|
|
@@ -15237,6 +15281,7 @@ declare const editorMachine: StateMachine<
|
|
|
15237
15281
|
| {
|
|
15238
15282
|
type: 'insert.blocks'
|
|
15239
15283
|
blocks: Array<PortableTextBlock>
|
|
15284
|
+
placement: 'auto' | 'after' | 'before'
|
|
15240
15285
|
}
|
|
15241
15286
|
| {
|
|
15242
15287
|
type: 'insert.block object'
|
|
@@ -15383,6 +15428,7 @@ declare const editorMachine: StateMachine<
|
|
|
15383
15428
|
| {
|
|
15384
15429
|
type: 'insert.blocks'
|
|
15385
15430
|
blocks: Array<PortableTextBlock>
|
|
15431
|
+
placement: 'auto' | 'after' | 'before'
|
|
15386
15432
|
}
|
|
15387
15433
|
| {
|
|
15388
15434
|
type: 'insert.block object'
|
|
@@ -15740,6 +15786,7 @@ declare const editorMachine: StateMachine<
|
|
|
15740
15786
|
| {
|
|
15741
15787
|
type: 'insert.blocks'
|
|
15742
15788
|
blocks: Array<PortableTextBlock>
|
|
15789
|
+
placement: 'auto' | 'after' | 'before'
|
|
15743
15790
|
}
|
|
15744
15791
|
| {
|
|
15745
15792
|
type: 'insert.block object'
|
|
@@ -16041,6 +16088,7 @@ declare const editorMachine: StateMachine<
|
|
|
16041
16088
|
| {
|
|
16042
16089
|
type: 'insert.blocks'
|
|
16043
16090
|
blocks: Array<PortableTextBlock>
|
|
16091
|
+
placement: 'auto' | 'after' | 'before'
|
|
16044
16092
|
}
|
|
16045
16093
|
| {
|
|
16046
16094
|
type: 'insert.block object'
|
|
@@ -16398,6 +16446,7 @@ declare const editorMachine: StateMachine<
|
|
|
16398
16446
|
| {
|
|
16399
16447
|
type: 'insert.blocks'
|
|
16400
16448
|
blocks: Array<PortableTextBlock>
|
|
16449
|
+
placement: 'auto' | 'after' | 'before'
|
|
16401
16450
|
}
|
|
16402
16451
|
| {
|
|
16403
16452
|
type: 'insert.block object'
|
|
@@ -16700,6 +16749,7 @@ declare const editorMachine: StateMachine<
|
|
|
16700
16749
|
| {
|
|
16701
16750
|
type: 'insert.blocks'
|
|
16702
16751
|
blocks: Array<PortableTextBlock>
|
|
16752
|
+
placement: 'auto' | 'after' | 'before'
|
|
16703
16753
|
}
|
|
16704
16754
|
| {
|
|
16705
16755
|
type: 'insert.block object'
|
|
@@ -17057,6 +17107,7 @@ declare const editorMachine: StateMachine<
|
|
|
17057
17107
|
| {
|
|
17058
17108
|
type: 'insert.blocks'
|
|
17059
17109
|
blocks: Array<PortableTextBlock>
|
|
17110
|
+
placement: 'auto' | 'after' | 'before'
|
|
17060
17111
|
}
|
|
17061
17112
|
| {
|
|
17062
17113
|
type: 'insert.block object'
|
|
@@ -17350,6 +17401,7 @@ declare const editorMachine: StateMachine<
|
|
|
17350
17401
|
| {
|
|
17351
17402
|
type: 'insert.blocks'
|
|
17352
17403
|
blocks: Array<PortableTextBlock>
|
|
17404
|
+
placement: 'auto' | 'after' | 'before'
|
|
17353
17405
|
}
|
|
17354
17406
|
| {
|
|
17355
17407
|
type: 'insert.block object'
|
|
@@ -17707,6 +17759,7 @@ declare const editorMachine: StateMachine<
|
|
|
17707
17759
|
| {
|
|
17708
17760
|
type: 'insert.blocks'
|
|
17709
17761
|
blocks: Array<PortableTextBlock>
|
|
17762
|
+
placement: 'auto' | 'after' | 'before'
|
|
17710
17763
|
}
|
|
17711
17764
|
| {
|
|
17712
17765
|
type: 'insert.block object'
|
|
@@ -18002,6 +18055,7 @@ declare const editorMachine: StateMachine<
|
|
|
18002
18055
|
| {
|
|
18003
18056
|
type: 'insert.blocks'
|
|
18004
18057
|
blocks: Array<PortableTextBlock>
|
|
18058
|
+
placement: 'auto' | 'after' | 'before'
|
|
18005
18059
|
}
|
|
18006
18060
|
| {
|
|
18007
18061
|
type: 'insert.block object'
|
|
@@ -18359,6 +18413,7 @@ declare const editorMachine: StateMachine<
|
|
|
18359
18413
|
| {
|
|
18360
18414
|
type: 'insert.blocks'
|
|
18361
18415
|
blocks: Array<PortableTextBlock>
|
|
18416
|
+
placement: 'auto' | 'after' | 'before'
|
|
18362
18417
|
}
|
|
18363
18418
|
| {
|
|
18364
18419
|
type: 'insert.block object'
|
|
@@ -18660,6 +18715,7 @@ declare const editorMachine: StateMachine<
|
|
|
18660
18715
|
| {
|
|
18661
18716
|
type: 'insert.blocks'
|
|
18662
18717
|
blocks: Array<PortableTextBlock>
|
|
18718
|
+
placement: 'auto' | 'after' | 'before'
|
|
18663
18719
|
}
|
|
18664
18720
|
| {
|
|
18665
18721
|
type: 'insert.block object'
|
|
@@ -19017,6 +19073,7 @@ declare const editorMachine: StateMachine<
|
|
|
19017
19073
|
| {
|
|
19018
19074
|
type: 'insert.blocks'
|
|
19019
19075
|
blocks: Array<PortableTextBlock>
|
|
19076
|
+
placement: 'auto' | 'after' | 'before'
|
|
19020
19077
|
}
|
|
19021
19078
|
| {
|
|
19022
19079
|
type: 'insert.block object'
|
|
@@ -19747,6 +19804,7 @@ declare type SyntheticBehaviorEvent =
|
|
|
19747
19804
|
| {
|
|
19748
19805
|
type: 'insert.blocks'
|
|
19749
19806
|
blocks: Array<PortableTextBlock>
|
|
19807
|
+
placement: 'auto' | 'after' | 'before'
|
|
19750
19808
|
}
|
|
19751
19809
|
| {
|
|
19752
19810
|
type: 'insert.block object'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/editor",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.6",
|
|
4
4
|
"description": "Portable Text Editor made in React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"get-random-values-esm": "^1.0.2",
|
|
74
74
|
"lodash": "^4.17.21",
|
|
75
75
|
"lodash.startcase": "^4.4.0",
|
|
76
|
-
"react-compiler-runtime": "19.0.0-beta-
|
|
76
|
+
"react-compiler-runtime": "19.0.0-beta-40c6c23-20250301",
|
|
77
77
|
"slate": "0.112.0",
|
|
78
78
|
"slate-dom": "^0.112.2",
|
|
79
79
|
"slate-react": "0.112.1",
|
|
@@ -100,9 +100,9 @@
|
|
|
100
100
|
"@vitejs/plugin-react": "^4.3.4",
|
|
101
101
|
"@vitest/browser": "^3.0.7",
|
|
102
102
|
"@vitest/coverage-istanbul": "^3.0.7",
|
|
103
|
-
"babel-plugin-react-compiler": "19.0.0-beta-
|
|
103
|
+
"babel-plugin-react-compiler": "19.0.0-beta-40c6c23-20250301",
|
|
104
104
|
"eslint": "8.57.1",
|
|
105
|
-
"eslint-plugin-react-compiler": "19.0.0-beta-
|
|
105
|
+
"eslint-plugin-react-compiler": "19.0.0-beta-40c6c23-20250301",
|
|
106
106
|
"eslint-plugin-react-hooks": "experimental",
|
|
107
107
|
"jsdom": "^26.0.0",
|
|
108
108
|
"react": "^19.0.0",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"vite": "^6.2.0",
|
|
113
113
|
"vitest": "^3.0.7",
|
|
114
114
|
"vitest-browser-react": "^0.1.1",
|
|
115
|
-
"racejar": "1.2.
|
|
115
|
+
"racejar": "1.2.1"
|
|
116
116
|
},
|
|
117
117
|
"peerDependencies": {
|
|
118
118
|
"@sanity/schema": "^3.77.2",
|
|
@@ -137,12 +137,15 @@
|
|
|
137
137
|
"lint:fix": "biome lint --write .",
|
|
138
138
|
"test": "vitest --run",
|
|
139
139
|
"test:watch": "vitest",
|
|
140
|
-
"test:chromium": "vitest --run --project \"browser (chromium)\"",
|
|
141
|
-
"test:
|
|
142
|
-
"test:
|
|
143
|
-
"test:
|
|
144
|
-
"test:
|
|
145
|
-
"test:
|
|
140
|
+
"test:e2e:chromium": "vitest --run --project \"browser.bak (chromium)\"",
|
|
141
|
+
"test:browser": "vitest --run --project browser",
|
|
142
|
+
"test:browser:watch": "vitest --project browser",
|
|
143
|
+
"test:browser:chromium": "vitest --run --project \"browser (chromium)\"",
|
|
144
|
+
"test:browser:chromium:watch": "vitest --project \"browser (chromium)\"",
|
|
145
|
+
"test:browser:firefox": "vitest --run --project \"browser (firefox)\"",
|
|
146
|
+
"test:browser:firefox:watch": "vitest --project \"browser (firefox)\"",
|
|
147
|
+
"test:browser:webkit": "vitest --run --project \"browser (webkit)\"",
|
|
148
|
+
"test:browser:webkit:watch": "vitest --project \"browser (webkit)\"",
|
|
146
149
|
"test:unit": "vitest --run --project unit",
|
|
147
150
|
"test:unit:watch": "vitest --project unit"
|
|
148
151
|
}
|
|
@@ -9,9 +9,24 @@ export const insertBlocksActionImplementation: BehaviorActionImplementation<
|
|
|
9
9
|
const fragment = toSlateValue(action.blocks, {schemaTypes: context.schema})
|
|
10
10
|
|
|
11
11
|
if (!action.editor.selection) {
|
|
12
|
+
if (action.placement === 'before') {
|
|
13
|
+
action.editor.insertFragment(fragment, {
|
|
14
|
+
at: Editor.start(action.editor, []),
|
|
15
|
+
})
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (action.placement === 'after') {
|
|
20
|
+
action.editor.insertFragment(fragment, {
|
|
21
|
+
at: Editor.end(action.editor, []),
|
|
22
|
+
})
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
action.editor.insertFragment(fragment)
|
|
12
27
|
return
|
|
13
28
|
}
|
|
14
|
-
|
|
29
|
+
|
|
15
30
|
const [focusBlock, focusPath] = Editor.node(
|
|
16
31
|
action.editor,
|
|
17
32
|
action.editor.selection,
|
|
@@ -20,6 +35,22 @@ export const insertBlocksActionImplementation: BehaviorActionImplementation<
|
|
|
20
35
|
},
|
|
21
36
|
)
|
|
22
37
|
|
|
38
|
+
if (action.placement === 'before' && focusPath) {
|
|
39
|
+
Transforms.insertNodes(action.editor, fragment, {at: focusPath})
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (action.placement === 'after' && focusPath) {
|
|
44
|
+
const nextPath = [focusPath[0] + 1]
|
|
45
|
+
Transforms.insertNodes(action.editor, fragment, {at: nextPath})
|
|
46
|
+
Transforms.select(action.editor, {
|
|
47
|
+
anchor: {path: [nextPath[0], 0], offset: 0},
|
|
48
|
+
focus: {path: [nextPath[0], 0], offset: 0},
|
|
49
|
+
})
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Ensure that markDefs for any annotations inside this fragment are copied over to the focused text block.
|
|
23
54
|
if (
|
|
24
55
|
action.editor.isTextBlock(focusBlock) &&
|
|
25
56
|
action.editor.isTextBlock(fragment[0])
|
|
@@ -8,6 +8,28 @@ import type {EditorSchema} from '../editor/define-schema'
|
|
|
8
8
|
import type {EditorContext} from '../editor/editor-snapshot'
|
|
9
9
|
import {isTypedObject} from './asserters'
|
|
10
10
|
|
|
11
|
+
export function parseBlocks({
|
|
12
|
+
context,
|
|
13
|
+
blocks,
|
|
14
|
+
options,
|
|
15
|
+
}: {
|
|
16
|
+
context: Pick<EditorContext, 'keyGenerator' | 'schema'>
|
|
17
|
+
blocks: unknown
|
|
18
|
+
options: {
|
|
19
|
+
refreshKeys: boolean
|
|
20
|
+
}
|
|
21
|
+
}): Array<PortableTextBlock> {
|
|
22
|
+
if (!Array.isArray(blocks)) {
|
|
23
|
+
return []
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return blocks.flatMap((block) => {
|
|
27
|
+
const parsedBlock = parseBlock({context, block, options})
|
|
28
|
+
|
|
29
|
+
return parsedBlock ? [parsedBlock] : []
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
11
33
|
export function parseBlock({
|
|
12
34
|
context,
|
|
13
35
|
block,
|