@portabletext/editor 1.35.0 → 1.35.2

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 (48) hide show
  1. package/lib/_chunks-cjs/{plugin.event-listener.cjs → editor-provider.cjs} +50 -20
  2. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -0
  3. package/lib/_chunks-es/{plugin.event-listener.js → editor-provider.js} +51 -21
  4. package/lib/_chunks-es/editor-provider.js.map +1 -0
  5. package/lib/behaviors/index.d.cts +19377 -210
  6. package/lib/behaviors/index.d.ts +19377 -210
  7. package/lib/index.cjs +81 -51
  8. package/lib/index.cjs.map +1 -1
  9. package/lib/index.d.cts +318 -47
  10. package/lib/index.d.ts +318 -47
  11. package/lib/index.js +35 -4
  12. package/lib/index.js.map +1 -1
  13. package/lib/plugins/index.cjs +22 -7
  14. package/lib/plugins/index.cjs.map +1 -1
  15. package/lib/plugins/index.d.cts +313 -2
  16. package/lib/plugins/index.d.ts +313 -2
  17. package/lib/plugins/index.js +18 -3
  18. package/lib/plugins/index.js.map +1 -1
  19. package/lib/selectors/index.d.cts +19504 -1
  20. package/lib/selectors/index.d.ts +19504 -1
  21. package/lib/utils/index.d.cts +19506 -2
  22. package/lib/utils/index.d.ts +19506 -2
  23. package/package.json +3 -3
  24. package/src/behavior-actions/behavior.action.decorator.add.ts +1 -0
  25. package/src/behavior-actions/behavior.action.delete.text.ts +1 -0
  26. package/src/behaviors/behavior.decorator-pair.ts +1 -0
  27. package/src/converters/converter.portable-text.deserialize.test.ts +3 -7
  28. package/src/converters/converter.portable-text.ts +7 -1
  29. package/src/converters/converter.text-html.deserialize.test.ts +3 -7
  30. package/src/converters/converter.text-html.serialize.test.ts +5 -10
  31. package/src/converters/converter.text-plain.test.ts +4 -6
  32. package/src/editor/Editable.tsx +26 -0
  33. package/src/editor/editor-machine.ts +170 -147
  34. package/src/editor/editor-selector.ts +3 -0
  35. package/src/editor/editor-snapshot.ts +13 -0
  36. package/src/editor/mutation-machine.ts +2 -0
  37. package/src/editor-event-listener.tsx +30 -0
  38. package/src/index.ts +1 -1
  39. package/src/internal-utils/create-test-snapshot.ts +23 -0
  40. package/src/plugins/plugin.one-line.tsx +1 -1
  41. package/src/selectors/selector.get-active-annotations.test.ts +4 -13
  42. package/src/selectors/selector.get-caret-word-selection.test.ts +3 -7
  43. package/src/selectors/selector.get-selected-spans.test.ts +5 -9
  44. package/src/selectors/selector.get-selection-text.test.ts +5 -7
  45. package/src/selectors/selector.get-trimmed-selection.test.ts +3 -5
  46. package/src/selectors/selector.is-active-decorator.test.ts +5 -9
  47. package/lib/_chunks-cjs/plugin.event-listener.cjs.map +0 -1
  48. package/lib/_chunks-es/plugin.event-listener.js.map +0 -1
@@ -746,6 +746,15 @@ declare const editorMachine: StateMachine<
746
746
  | {
747
747
  type: 'notify.unset'
748
748
  previousValue: Array<PortableTextBlock>
749
+ }
750
+ | {
751
+ type: 'dragstart'
752
+ }
753
+ | {
754
+ type: 'dragend'
755
+ }
756
+ | {
757
+ type: 'drop'
749
758
  },
750
759
  {},
751
760
  never,
@@ -807,7 +816,9 @@ declare const editorMachine: StateMachine<
807
816
  never,
808
817
  {
809
818
  'edit mode':
810
- | 'editable'
819
+ | {
820
+ editable: 'dragging internally' | 'idle'
821
+ }
811
822
  | {
812
823
  'read only': 'read only' | 'determine initial edit mode'
813
824
  }
@@ -818,7 +829,7 @@ declare const editorMachine: StateMachine<
818
829
  pristine: 'normalizing' | 'idle'
819
830
  }
820
831
  },
821
- string,
832
+ 'dragging internally',
822
833
  {
823
834
  behaviors?: Array<Behavior>
824
835
  converters?: Array<Converter>
@@ -1492,6 +1503,15 @@ declare const editorMachine: StateMachine<
1492
1503
  | {
1493
1504
  type: 'notify.unset'
1494
1505
  previousValue: Array<PortableTextBlock>
1506
+ }
1507
+ | {
1508
+ type: 'dragstart'
1509
+ }
1510
+ | {
1511
+ type: 'dragend'
1512
+ }
1513
+ | {
1514
+ type: 'drop'
1495
1515
  },
1496
1516
  Record<string, AnyActorRef | undefined>,
1497
1517
  StateValue,
@@ -1840,6 +1860,15 @@ declare const editorMachine: StateMachine<
1840
1860
  | {
1841
1861
  type: 'notify.unset'
1842
1862
  previousValue: Array<PortableTextBlock>
1863
+ }
1864
+ | {
1865
+ type: 'dragstart'
1866
+ }
1867
+ | {
1868
+ type: 'dragend'
1869
+ }
1870
+ | {
1871
+ type: 'drop'
1843
1872
  },
1844
1873
  AnyEventObject
1845
1874
  >
@@ -2212,6 +2241,15 @@ declare const editorMachine: StateMachine<
2212
2241
  | {
2213
2242
  type: 'notify.unset'
2214
2243
  previousValue: Array<PortableTextBlock>
2244
+ }
2245
+ | {
2246
+ type: 'dragstart'
2247
+ }
2248
+ | {
2249
+ type: 'dragend'
2250
+ }
2251
+ | {
2252
+ type: 'drop'
2215
2253
  },
2216
2254
  undefined,
2217
2255
  never,
@@ -2849,6 +2887,15 @@ declare const editorMachine: StateMachine<
2849
2887
  | {
2850
2888
  type: 'notify.unset'
2851
2889
  previousValue: Array<PortableTextBlock>
2890
+ }
2891
+ | {
2892
+ type: 'dragstart'
2893
+ }
2894
+ | {
2895
+ type: 'dragend'
2896
+ }
2897
+ | {
2898
+ type: 'drop'
2852
2899
  },
2853
2900
  undefined,
2854
2901
  never,
@@ -3489,6 +3536,15 @@ declare const editorMachine: StateMachine<
3489
3536
  | {
3490
3537
  type: 'notify.unset'
3491
3538
  previousValue: Array<PortableTextBlock>
3539
+ }
3540
+ | {
3541
+ type: 'dragstart'
3542
+ }
3543
+ | {
3544
+ type: 'dragend'
3545
+ }
3546
+ | {
3547
+ type: 'drop'
3492
3548
  },
3493
3549
  undefined,
3494
3550
  never,
@@ -4128,6 +4184,15 @@ declare const editorMachine: StateMachine<
4128
4184
  | {
4129
4185
  type: 'notify.unset'
4130
4186
  previousValue: Array<PortableTextBlock>
4187
+ }
4188
+ | {
4189
+ type: 'dragstart'
4190
+ }
4191
+ | {
4192
+ type: 'dragend'
4193
+ }
4194
+ | {
4195
+ type: 'drop'
4131
4196
  },
4132
4197
  undefined,
4133
4198
  never,
@@ -4766,6 +4831,15 @@ declare const editorMachine: StateMachine<
4766
4831
  | {
4767
4832
  type: 'notify.unset'
4768
4833
  previousValue: Array<PortableTextBlock>
4834
+ }
4835
+ | {
4836
+ type: 'dragstart'
4837
+ }
4838
+ | {
4839
+ type: 'dragend'
4840
+ }
4841
+ | {
4842
+ type: 'drop'
4769
4843
  },
4770
4844
  undefined,
4771
4845
  never,
@@ -5405,6 +5479,15 @@ declare const editorMachine: StateMachine<
5405
5479
  | {
5406
5480
  type: 'notify.unset'
5407
5481
  previousValue: Array<PortableTextBlock>
5482
+ }
5483
+ | {
5484
+ type: 'dragstart'
5485
+ }
5486
+ | {
5487
+ type: 'dragend'
5488
+ }
5489
+ | {
5490
+ type: 'drop'
5408
5491
  },
5409
5492
  undefined,
5410
5493
  never,
@@ -5769,6 +5852,15 @@ declare const editorMachine: StateMachine<
5769
5852
  | {
5770
5853
  type: 'notify.unset'
5771
5854
  previousValue: Array<PortableTextBlock>
5855
+ }
5856
+ | {
5857
+ type: 'dragstart'
5858
+ }
5859
+ | {
5860
+ type: 'dragend'
5861
+ }
5862
+ | {
5863
+ type: 'drop'
5772
5864
  },
5773
5865
  undefined,
5774
5866
  never,
@@ -6408,6 +6500,15 @@ declare const editorMachine: StateMachine<
6408
6500
  | {
6409
6501
  type: 'notify.unset'
6410
6502
  previousValue: Array<PortableTextBlock>
6503
+ }
6504
+ | {
6505
+ type: 'dragstart'
6506
+ }
6507
+ | {
6508
+ type: 'dragend'
6509
+ }
6510
+ | {
6511
+ type: 'drop'
6411
6512
  },
6412
6513
  undefined,
6413
6514
  never,
@@ -7045,6 +7146,15 @@ declare const editorMachine: StateMachine<
7045
7146
  | {
7046
7147
  type: 'notify.unset'
7047
7148
  previousValue: Array<PortableTextBlock>
7149
+ }
7150
+ | {
7151
+ type: 'dragstart'
7152
+ }
7153
+ | {
7154
+ type: 'dragend'
7155
+ }
7156
+ | {
7157
+ type: 'drop'
7048
7158
  },
7049
7159
  undefined,
7050
7160
  never,
@@ -7683,6 +7793,15 @@ declare const editorMachine: StateMachine<
7683
7793
  | {
7684
7794
  type: 'notify.unset'
7685
7795
  previousValue: Array<PortableTextBlock>
7796
+ }
7797
+ | {
7798
+ type: 'dragstart'
7799
+ }
7800
+ | {
7801
+ type: 'dragend'
7802
+ }
7803
+ | {
7804
+ type: 'drop'
7686
7805
  },
7687
7806
  undefined,
7688
7807
  never,
@@ -8324,6 +8443,15 @@ declare const editorMachine: StateMachine<
8324
8443
  | {
8325
8444
  type: 'notify.unset'
8326
8445
  previousValue: Array<PortableTextBlock>
8446
+ }
8447
+ | {
8448
+ type: 'dragstart'
8449
+ }
8450
+ | {
8451
+ type: 'dragend'
8452
+ }
8453
+ | {
8454
+ type: 'drop'
8327
8455
  },
8328
8456
  undefined,
8329
8457
  never,
@@ -8965,6 +9093,15 @@ declare const editorMachine: StateMachine<
8965
9093
  | {
8966
9094
  type: 'notify.unset'
8967
9095
  previousValue: Array<PortableTextBlock>
9096
+ }
9097
+ | {
9098
+ type: 'dragstart'
9099
+ }
9100
+ | {
9101
+ type: 'dragend'
9102
+ }
9103
+ | {
9104
+ type: 'drop'
8968
9105
  },
8969
9106
  undefined,
8970
9107
  never,
@@ -9334,6 +9471,15 @@ declare const editorMachine: StateMachine<
9334
9471
  | {
9335
9472
  type: 'notify.unset'
9336
9473
  previousValue: Array<PortableTextBlock>
9474
+ }
9475
+ | {
9476
+ type: 'dragstart'
9477
+ }
9478
+ | {
9479
+ type: 'dragend'
9480
+ }
9481
+ | {
9482
+ type: 'drop'
9337
9483
  },
9338
9484
  undefined,
9339
9485
  never,
@@ -9700,6 +9846,15 @@ declare const editorMachine: StateMachine<
9700
9846
  | {
9701
9847
  type: 'notify.unset'
9702
9848
  previousValue: Array<PortableTextBlock>
9849
+ }
9850
+ | {
9851
+ type: 'dragstart'
9852
+ }
9853
+ | {
9854
+ type: 'dragend'
9855
+ }
9856
+ | {
9857
+ type: 'drop'
9703
9858
  },
9704
9859
  undefined,
9705
9860
  never,
@@ -10216,6 +10371,15 @@ declare const editorMachine: StateMachine<
10216
10371
  | {
10217
10372
  type: 'notify.unset'
10218
10373
  previousValue: Array<PortableTextBlock>
10374
+ }
10375
+ | {
10376
+ type: 'dragstart'
10377
+ }
10378
+ | {
10379
+ type: 'dragend'
10380
+ }
10381
+ | {
10382
+ type: 'drop'
10219
10383
  },
10220
10384
  undefined,
10221
10385
  never,
@@ -10862,6 +11026,15 @@ declare const editorMachine: StateMachine<
10862
11026
  | {
10863
11027
  type: 'notify.unset'
10864
11028
  previousValue: Array<PortableTextBlock>
11029
+ }
11030
+ | {
11031
+ type: 'dragstart'
11032
+ }
11033
+ | {
11034
+ type: 'dragend'
11035
+ }
11036
+ | {
11037
+ type: 'drop'
10865
11038
  },
10866
11039
  undefined,
10867
11040
  never,
@@ -11501,6 +11674,15 @@ declare const editorMachine: StateMachine<
11501
11674
  | {
11502
11675
  type: 'notify.unset'
11503
11676
  previousValue: Array<PortableTextBlock>
11677
+ }
11678
+ | {
11679
+ type: 'dragstart'
11680
+ }
11681
+ | {
11682
+ type: 'dragend'
11683
+ }
11684
+ | {
11685
+ type: 'drop'
11504
11686
  },
11505
11687
  undefined,
11506
11688
  never,
@@ -12140,6 +12322,15 @@ declare const editorMachine: StateMachine<
12140
12322
  | {
12141
12323
  type: 'notify.unset'
12142
12324
  previousValue: Array<PortableTextBlock>
12325
+ }
12326
+ | {
12327
+ type: 'dragstart'
12328
+ }
12329
+ | {
12330
+ type: 'dragend'
12331
+ }
12332
+ | {
12333
+ type: 'drop'
12143
12334
  },
12144
12335
  undefined,
12145
12336
  never,
@@ -12792,6 +12983,15 @@ declare const editorMachine: StateMachine<
12792
12983
  | {
12793
12984
  type: 'notify.unset'
12794
12985
  previousValue: Array<PortableTextBlock>
12986
+ }
12987
+ | {
12988
+ type: 'dragstart'
12989
+ }
12990
+ | {
12991
+ type: 'dragend'
12992
+ }
12993
+ | {
12994
+ type: 'drop'
12795
12995
  },
12796
12996
  undefined,
12797
12997
  never,
@@ -13445,6 +13645,15 @@ declare const editorMachine: StateMachine<
13445
13645
  | {
13446
13646
  type: 'notify.unset'
13447
13647
  previousValue: Array<PortableTextBlock>
13648
+ }
13649
+ | {
13650
+ type: 'dragstart'
13651
+ }
13652
+ | {
13653
+ type: 'dragend'
13654
+ }
13655
+ | {
13656
+ type: 'drop'
13448
13657
  },
13449
13658
  undefined,
13450
13659
  never,
@@ -14084,6 +14293,15 @@ declare const editorMachine: StateMachine<
14084
14293
  | {
14085
14294
  type: 'notify.unset'
14086
14295
  previousValue: Array<PortableTextBlock>
14296
+ }
14297
+ | {
14298
+ type: 'dragstart'
14299
+ }
14300
+ | {
14301
+ type: 'dragend'
14302
+ }
14303
+ | {
14304
+ type: 'drop'
14087
14305
  },
14088
14306
  undefined,
14089
14307
  never,
@@ -14726,6 +14944,15 @@ declare const editorMachine: StateMachine<
14726
14944
  | {
14727
14945
  type: 'notify.unset'
14728
14946
  previousValue: Array<PortableTextBlock>
14947
+ }
14948
+ | {
14949
+ type: 'dragstart'
14950
+ }
14951
+ | {
14952
+ type: 'dragend'
14953
+ }
14954
+ | {
14955
+ type: 'drop'
14729
14956
  },
14730
14957
  undefined,
14731
14958
  never,
@@ -15419,6 +15646,15 @@ declare const editorMachine: StateMachine<
15419
15646
  | {
15420
15647
  type: 'notify.unset'
15421
15648
  previousValue: Array<PortableTextBlock>
15649
+ }
15650
+ | {
15651
+ type: 'dragstart'
15652
+ }
15653
+ | {
15654
+ type: 'dragend'
15655
+ }
15656
+ | {
15657
+ type: 'drop'
15422
15658
  },
15423
15659
  undefined,
15424
15660
  never,
@@ -16067,6 +16303,15 @@ declare const editorMachine: StateMachine<
16067
16303
  | {
16068
16304
  type: 'notify.unset'
16069
16305
  previousValue: Array<PortableTextBlock>
16306
+ }
16307
+ | {
16308
+ type: 'dragstart'
16309
+ }
16310
+ | {
16311
+ type: 'dragend'
16312
+ }
16313
+ | {
16314
+ type: 'drop'
16070
16315
  },
16071
16316
  undefined,
16072
16317
  never,
@@ -16716,6 +16961,15 @@ declare const editorMachine: StateMachine<
16716
16961
  | {
16717
16962
  type: 'notify.unset'
16718
16963
  previousValue: Array<PortableTextBlock>
16964
+ }
16965
+ | {
16966
+ type: 'dragstart'
16967
+ }
16968
+ | {
16969
+ type: 'dragend'
16970
+ }
16971
+ | {
16972
+ type: 'drop'
16719
16973
  },
16720
16974
  undefined,
16721
16975
  never,
@@ -17356,6 +17610,15 @@ declare const editorMachine: StateMachine<
17356
17610
  | {
17357
17611
  type: 'notify.unset'
17358
17612
  previousValue: Array<PortableTextBlock>
17613
+ }
17614
+ | {
17615
+ type: 'dragstart'
17616
+ }
17617
+ | {
17618
+ type: 'dragend'
17619
+ }
17620
+ | {
17621
+ type: 'drop'
17359
17622
  },
17360
17623
  undefined,
17361
17624
  never,
@@ -17998,6 +18261,15 @@ declare const editorMachine: StateMachine<
17998
18261
  | {
17999
18262
  type: 'notify.unset'
18000
18263
  previousValue: Array<PortableTextBlock>
18264
+ }
18265
+ | {
18266
+ type: 'dragstart'
18267
+ }
18268
+ | {
18269
+ type: 'dragend'
18270
+ }
18271
+ | {
18272
+ type: 'drop'
18001
18273
  },
18002
18274
  undefined,
18003
18275
  never,
@@ -18646,6 +18918,15 @@ declare const editorMachine: StateMachine<
18646
18918
  | {
18647
18919
  type: 'notify.unset'
18648
18920
  previousValue: Array<PortableTextBlock>
18921
+ }
18922
+ | {
18923
+ type: 'dragstart'
18924
+ }
18925
+ | {
18926
+ type: 'dragend'
18927
+ }
18928
+ | {
18929
+ type: 'drop'
18649
18930
  },
18650
18931
  undefined,
18651
18932
  never,
@@ -18941,6 +19222,27 @@ declare const editorMachine: StateMachine<
18941
19222
  >
18942
19223
  }
18943
19224
  }
19225
+ readonly initial: 'idle'
19226
+ readonly states: {
19227
+ readonly 'idle': {
19228
+ readonly on: {
19229
+ readonly dragstart: {
19230
+ readonly target: 'dragging internally'
19231
+ }
19232
+ }
19233
+ }
19234
+ readonly 'dragging internally': {
19235
+ readonly tags: readonly ['dragging internally']
19236
+ readonly on: {
19237
+ readonly dragend: {
19238
+ readonly target: 'idle'
19239
+ }
19240
+ readonly drop: {
19241
+ readonly target: 'idle'
19242
+ }
19243
+ }
19244
+ }
19245
+ }
18944
19246
  }
18945
19247
  }
18946
19248
  }
@@ -19044,6 +19346,13 @@ declare type EditorSelectionPoint = {
19044
19346
  */
19045
19347
  declare type EditorSnapshot = {
19046
19348
  context: EditorContext
19349
+ /**
19350
+ * @beta
19351
+ * Do not rely on this externally
19352
+ */
19353
+ beta: {
19354
+ hasTag: HasTag
19355
+ }
19047
19356
  }
19048
19357
 
19049
19358
  /**
@@ -19137,6 +19446,8 @@ declare type ExternalEditorEvent =
19137
19446
  }
19138
19447
  | PatchesEvent
19139
19448
 
19449
+ declare type HasTag = ReturnType<EditorActor['getSnapshot']>['hasTag']
19450
+
19140
19451
  /** @internal */
19141
19452
  declare interface History_2 {
19142
19453
  redos: HistoryItem[]