@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.
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/behavior.markdown.cjs +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +104 -7
- 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/behavior.markdown.js +1 -1
- package/lib/_chunks-es/editor-provider.js +108 -11
- 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 +59 -0
- package/lib/behaviors/index.d.ts +59 -0
- package/lib/index.d.cts +59 -0
- package/lib/index.d.ts +59 -0
- package/lib/plugins/index.cjs +1 -1
- package/lib/plugins/index.d.cts +59 -0
- package/lib/plugins/index.d.ts +59 -0
- package/lib/plugins/index.js +1 -1
- package/lib/selectors/index.cjs +69 -14
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +75 -0
- package/lib/selectors/index.d.ts +75 -0
- package/lib/selectors/index.js +63 -8
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.d.cts +59 -0
- package/lib/utils/index.d.ts +59 -0
- package/package.json +7 -7
- package/src/behavior-actions/behavior.action.decorator.add.ts +1 -0
- package/src/behavior-actions/behavior.action.delete.text.ts +1 -0
- package/src/behavior-actions/behavior.action.delete.ts +1 -3
- package/src/behavior-actions/behavior.action.insert-blocks.ts +98 -2
- 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/editor/editor-machine.ts +16 -3
- package/src/editor/editor-selector.ts +1 -0
- package/src/editor/editor-snapshot.ts +4 -0
- package/src/internal-utils/create-test-snapshot.ts +1 -0
- package/src/internal-utils/parse-blocks.ts +22 -0
- package/src/selectors/index.ts +2 -0
- package/src/selectors/selector.get-focus-inline-object.ts +21 -0
- package/src/selectors/selector.is-overlapping-selection.test.ts +171 -0
- package/src/selectors/selector.is-overlapping-selection.ts +108 -4
- package/src/selectors/selector.is-point-after-selection.ts +3 -1
- package/src/selectors/selector.is-point-before-selection.ts +3 -1
- package/src/selectors/selector.is-selecting-entire-blocks.ts +34 -0
package/lib/plugins/index.d.ts
CHANGED
|
@@ -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'
|
package/lib/plugins/index.js
CHANGED
|
@@ -4,10 +4,10 @@ import { useEditor } from "../_chunks-es/editor-provider.js";
|
|
|
4
4
|
import { useActorRef } from "@xstate/react";
|
|
5
5
|
import isEqual from "lodash/isEqual.js";
|
|
6
6
|
import { setup, fromCallback, assign } from "xstate";
|
|
7
|
-
import { getFocusTextBlock, getPreviousInlineObject, getSelectionStartPoint, isSelectionExpanded, getSelectionEndPoint } from "../_chunks-es/selector.is-at-the-start-of-block.js";
|
|
8
7
|
import { spanSelectionPointToBlockOffset, getBlockStartPoint, getBlockEndPoint, isEqualSelectionPoints } from "../_chunks-es/util.slice-blocks.js";
|
|
9
8
|
import { blockOffsetsToSelection } from "../_chunks-es/util.block-offsets-to-selection.js";
|
|
10
9
|
import { childSelectionPointToBlockOffset, isTextBlock, splitTextBlock, mergeTextBlocks } from "../utils/index.js";
|
|
10
|
+
import { getFocusTextBlock, getPreviousInlineObject, getSelectionStartPoint, isSelectionExpanded, getSelectionEndPoint } from "../_chunks-es/selector.is-at-the-start-of-block.js";
|
|
11
11
|
import { getBlockTextBefore } from "../_chunks-es/selector.get-text-before.js";
|
|
12
12
|
import { defineBehavior, raise } from "../_chunks-es/behavior.core.js";
|
|
13
13
|
import { useEffectEvent } from "use-effect-event";
|
package/lib/selectors/index.cjs
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var
|
|
4
|
-
const
|
|
3
|
+
var util_sliceBlocks = require("../_chunks-cjs/util.slice-blocks.cjs"), selector_isAtTheStartOfBlock = require("../_chunks-cjs/selector.is-at-the-start-of-block.cjs"), types = require("@sanity/types"), selector_isActiveStyle = require("../_chunks-cjs/selector.is-active-style.cjs"), selector_getTextBefore = require("../_chunks-cjs/selector.get-text-before.cjs"), util_reverseSelection = require("../_chunks-cjs/util.reverse-selection.cjs");
|
|
4
|
+
const isSelectingEntireBlocks = (snapshot) => {
|
|
5
|
+
if (!snapshot.context.selection)
|
|
6
|
+
return !1;
|
|
7
|
+
const startPoint = snapshot.context.selection.backward ? snapshot.context.selection.focus : snapshot.context.selection.anchor, endPoint = snapshot.context.selection.backward ? snapshot.context.selection.anchor : snapshot.context.selection.focus, startBlock = selector_isAtTheStartOfBlock.getSelectionStartBlock(snapshot), endBlock = selector_isAtTheStartOfBlock.getSelectionEndBlock(snapshot);
|
|
8
|
+
if (!startBlock || !endBlock)
|
|
9
|
+
return !1;
|
|
10
|
+
const startBlockStartPoint = util_sliceBlocks.getBlockStartPoint(startBlock), endBlockEndPoint = util_sliceBlocks.getBlockEndPoint(endBlock);
|
|
11
|
+
return util_sliceBlocks.isEqualSelectionPoints(startBlockStartPoint, startPoint) && util_sliceBlocks.isEqualSelectionPoints(endBlockEndPoint, endPoint);
|
|
12
|
+
}, getActiveAnnotations = (snapshot) => {
|
|
5
13
|
if (!snapshot.context.selection)
|
|
6
14
|
return [];
|
|
7
15
|
const selectedBlocks = selector_isAtTheStartOfBlock.getSelectedBlocks(snapshot), selectedSpans = selector_isActiveStyle.getSelectedSpans(snapshot);
|
|
@@ -54,12 +62,18 @@ const getActiveAnnotations = (snapshot) => {
|
|
|
54
62
|
start,
|
|
55
63
|
end
|
|
56
64
|
} : void 0;
|
|
65
|
+
}, getFocusInlineObject = (snapshot) => {
|
|
66
|
+
const focusChild = selector_isAtTheStartOfBlock.getFocusChild(snapshot);
|
|
67
|
+
return focusChild && !types.isPortableTextSpan(focusChild.node) ? {
|
|
68
|
+
node: focusChild.node,
|
|
69
|
+
path: focusChild.path
|
|
70
|
+
} : void 0;
|
|
57
71
|
}, getSelection = (snapshot) => snapshot.context.selection, getValue = (snapshot) => snapshot.context.value;
|
|
58
72
|
function isPointAfterSelection(point) {
|
|
59
73
|
return (snapshot) => {
|
|
60
74
|
if (!snapshot.context.selection)
|
|
61
75
|
return !1;
|
|
62
|
-
const selection = util_reverseSelection.reverseSelection(snapshot.context.selection), pointBlockKey = types.isKeySegment(point.path[0]) ? point.path[0]._key : void 0, pointChildKey = types.isKeySegment(point.path[2]) ? point.path[2]._key : void 0, endBlockKey = types.isKeySegment(selection.focus.path[0]) ? selection.focus.path[0]._key : void 0, endChildKey = types.isKeySegment(selection.focus.path[2]) ? selection.focus.path[2]._key : void 0;
|
|
76
|
+
const selection = snapshot.context.selection.backward ? util_reverseSelection.reverseSelection(snapshot.context.selection) : snapshot.context.selection, pointBlockKey = types.isKeySegment(point.path[0]) ? point.path[0]._key : void 0, pointChildKey = types.isKeySegment(point.path[2]) ? point.path[2]._key : void 0, endBlockKey = types.isKeySegment(selection.focus.path[0]) ? selection.focus.path[0]._key : void 0, endChildKey = types.isKeySegment(selection.focus.path[2]) ? selection.focus.path[2]._key : void 0;
|
|
63
77
|
if (!pointBlockKey || !endBlockKey)
|
|
64
78
|
return !1;
|
|
65
79
|
let after = !1;
|
|
@@ -94,7 +108,7 @@ function isPointBeforeSelection(point) {
|
|
|
94
108
|
return (snapshot) => {
|
|
95
109
|
if (!snapshot.context.selection)
|
|
96
110
|
return !1;
|
|
97
|
-
const selection = util_reverseSelection.reverseSelection(snapshot.context.selection), pointBlockKey = types.isKeySegment(point.path[0]) ? point.path[0]._key : void 0, pointChildKey = types.isKeySegment(point.path[2]) ? point.path[2]._key : void 0, startBlockKey = types.isKeySegment(selection.anchor.path[0]) ? selection.anchor.path[0]._key : void 0, startChildKey = types.isKeySegment(selection.anchor.path[2]) ? selection.anchor.path[2]._key : void 0;
|
|
111
|
+
const selection = snapshot.context.selection.backward ? util_reverseSelection.reverseSelection(snapshot.context.selection) : snapshot.context.selection, pointBlockKey = types.isKeySegment(point.path[0]) ? point.path[0]._key : void 0, pointChildKey = types.isKeySegment(point.path[2]) ? point.path[2]._key : void 0, startBlockKey = types.isKeySegment(selection.anchor.path[0]) ? selection.anchor.path[0]._key : void 0, startChildKey = types.isKeySegment(selection.anchor.path[2]) ? selection.anchor.path[2]._key : void 0;
|
|
98
112
|
if (!pointBlockKey || !startBlockKey)
|
|
99
113
|
return !1;
|
|
100
114
|
let before = !1;
|
|
@@ -141,18 +155,49 @@ function isOverlappingSelection(selection) {
|
|
|
141
155
|
...snapshot.context,
|
|
142
156
|
selection
|
|
143
157
|
}
|
|
144
|
-
});
|
|
145
|
-
|
|
158
|
+
}), originalSelectionStartPoint = selector_isAtTheStartOfBlock.getSelectionStartPoint(snapshot), originalSelectionEndPoint = selector_isAtTheStartOfBlock.getSelectionEndPoint(snapshot);
|
|
159
|
+
if (!selectionStartPoint || !selectionEndPoint || !originalSelectionStartPoint || !originalSelectionEndPoint)
|
|
160
|
+
return !1;
|
|
161
|
+
const startPointBeforeSelection = isPointBeforeSelection(selectionStartPoint)(snapshot), startPointAfterSelection = isPointAfterSelection(selectionStartPoint)(snapshot), endPointBeforeSelection = isPointBeforeSelection(selectionEndPoint)(snapshot), endPointAfterSelection = isPointAfterSelection(selectionEndPoint)(snapshot), originalStartPointBeforeStartPoint = isPointBeforeSelection(originalSelectionStartPoint)({
|
|
162
|
+
...snapshot,
|
|
163
|
+
context: {
|
|
164
|
+
...snapshot.context,
|
|
165
|
+
selection: {
|
|
166
|
+
anchor: selectionStartPoint,
|
|
167
|
+
focus: selectionStartPoint
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}), originalStartPointAfterStartPoint = isPointAfterSelection(originalSelectionStartPoint)({
|
|
171
|
+
...snapshot,
|
|
172
|
+
context: {
|
|
173
|
+
...snapshot.context,
|
|
174
|
+
selection: {
|
|
175
|
+
anchor: selectionStartPoint,
|
|
176
|
+
focus: selectionStartPoint
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}), originalEndPointBeforeEndPoint = isPointBeforeSelection(originalSelectionEndPoint)({
|
|
180
|
+
...snapshot,
|
|
181
|
+
context: {
|
|
182
|
+
...snapshot.context,
|
|
183
|
+
selection: {
|
|
184
|
+
anchor: selectionEndPoint,
|
|
185
|
+
focus: selectionEndPoint
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}), originalEndPointAfterEndPoint = isPointAfterSelection(originalSelectionEndPoint)({
|
|
189
|
+
...snapshot,
|
|
190
|
+
context: {
|
|
191
|
+
...snapshot.context,
|
|
192
|
+
selection: {
|
|
193
|
+
anchor: selectionEndPoint,
|
|
194
|
+
focus: selectionEndPoint
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}), endPointEqualToOriginalStartPoint = util_sliceBlocks.isEqualSelectionPoints(selectionEndPoint, originalSelectionStartPoint), startPointEqualToOriginalEndPoint = util_sliceBlocks.isEqualSelectionPoints(selectionStartPoint, originalSelectionEndPoint);
|
|
198
|
+
return endPointBeforeSelection && !endPointEqualToOriginalStartPoint || startPointAfterSelection && !startPointEqualToOriginalEndPoint ? !1 : !originalStartPointBeforeStartPoint && originalStartPointAfterStartPoint && !originalEndPointBeforeEndPoint && originalEndPointAfterEndPoint ? !endPointEqualToOriginalStartPoint : originalStartPointBeforeStartPoint && !originalStartPointAfterStartPoint && originalEndPointBeforeEndPoint && !originalEndPointAfterEndPoint ? !startPointEqualToOriginalEndPoint : !startPointAfterSelection || !startPointBeforeSelection || !endPointAfterSelection || !endPointBeforeSelection;
|
|
146
199
|
};
|
|
147
200
|
}
|
|
148
|
-
exports.getActiveListItem = selector_isActiveStyle.getActiveListItem;
|
|
149
|
-
exports.getActiveStyle = selector_isActiveStyle.getActiveStyle;
|
|
150
|
-
exports.getSelectedSpans = selector_isActiveStyle.getSelectedSpans;
|
|
151
|
-
exports.getTrimmedSelection = selector_isActiveStyle.getTrimmedSelection;
|
|
152
|
-
exports.isActiveAnnotation = selector_isActiveStyle.isActiveAnnotation;
|
|
153
|
-
exports.isActiveDecorator = selector_isActiveStyle.isActiveDecorator;
|
|
154
|
-
exports.isActiveListItem = selector_isActiveStyle.isActiveListItem;
|
|
155
|
-
exports.isActiveStyle = selector_isActiveStyle.isActiveStyle;
|
|
156
201
|
exports.getCaretWordSelection = selector_isAtTheStartOfBlock.getCaretWordSelection;
|
|
157
202
|
exports.getFirstBlock = selector_isAtTheStartOfBlock.getFirstBlock;
|
|
158
203
|
exports.getFocusBlock = selector_isAtTheStartOfBlock.getFocusBlock;
|
|
@@ -177,6 +222,14 @@ exports.isAtTheEndOfBlock = selector_isAtTheStartOfBlock.isAtTheEndOfBlock;
|
|
|
177
222
|
exports.isAtTheStartOfBlock = selector_isAtTheStartOfBlock.isAtTheStartOfBlock;
|
|
178
223
|
exports.isSelectionCollapsed = selector_isAtTheStartOfBlock.isSelectionCollapsed;
|
|
179
224
|
exports.isSelectionExpanded = selector_isAtTheStartOfBlock.isSelectionExpanded;
|
|
225
|
+
exports.getActiveListItem = selector_isActiveStyle.getActiveListItem;
|
|
226
|
+
exports.getActiveStyle = selector_isActiveStyle.getActiveStyle;
|
|
227
|
+
exports.getSelectedSpans = selector_isActiveStyle.getSelectedSpans;
|
|
228
|
+
exports.getTrimmedSelection = selector_isActiveStyle.getTrimmedSelection;
|
|
229
|
+
exports.isActiveAnnotation = selector_isActiveStyle.isActiveAnnotation;
|
|
230
|
+
exports.isActiveDecorator = selector_isActiveStyle.isActiveDecorator;
|
|
231
|
+
exports.isActiveListItem = selector_isActiveStyle.isActiveListItem;
|
|
232
|
+
exports.isActiveStyle = selector_isActiveStyle.isActiveStyle;
|
|
180
233
|
exports.getBlockTextBefore = selector_getTextBefore.getBlockTextBefore;
|
|
181
234
|
exports.getActiveAnnotations = getActiveAnnotations;
|
|
182
235
|
exports.getAnchorBlock = getAnchorBlock;
|
|
@@ -184,9 +237,11 @@ exports.getAnchorChild = getAnchorChild;
|
|
|
184
237
|
exports.getAnchorSpan = getAnchorSpan;
|
|
185
238
|
exports.getAnchorTextBlock = getAnchorTextBlock;
|
|
186
239
|
exports.getBlockOffsets = getBlockOffsets;
|
|
240
|
+
exports.getFocusInlineObject = getFocusInlineObject;
|
|
187
241
|
exports.getSelection = getSelection;
|
|
188
242
|
exports.getValue = getValue;
|
|
189
243
|
exports.isOverlappingSelection = isOverlappingSelection;
|
|
190
244
|
exports.isPointAfterSelection = isPointAfterSelection;
|
|
191
245
|
exports.isPointBeforeSelection = isPointBeforeSelection;
|
|
246
|
+
exports.isSelectingEntireBlocks = isSelectingEntireBlocks;
|
|
192
247
|
//# sourceMappingURL=index.cjs.map
|