@portabletext/editor 1.1.10 → 1.1.11

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/index.d.mts CHANGED
@@ -6,6 +6,7 @@ import type {
6
6
  BlockListDefinition,
7
7
  BlockSchemaType,
8
8
  BlockStyleDefinition,
9
+ KeyedSegment,
9
10
  ObjectSchemaType,
10
11
  Path,
11
12
  PortableTextBlock,
@@ -15,11 +16,7 @@ import type {
15
16
  SpanSchemaType,
16
17
  TypedObject,
17
18
  } from '@sanity/types'
18
- import {
19
- KeyedSegment,
20
- PortableTextSpan,
21
- PortableTextTextBlock,
22
- } from '@sanity/types'
19
+ import {PortableTextSpan, PortableTextTextBlock} from '@sanity/types'
23
20
  import type {
24
21
  BaseSyntheticEvent,
25
22
  ClipboardEvent as ClipboardEvent_2,
@@ -38,11 +35,12 @@ import {
38
35
  TextareaHTMLAttributes,
39
36
  } from 'react'
40
37
  import type {Observable, Subject} from 'rxjs'
41
- import type {Descendant, Node as Node_2, Operation} from 'slate'
42
- import {TextUnit} from 'slate'
38
+ import type {Descendant, Node as Node_2, Operation, TextUnit} from 'slate'
43
39
  import type {ReactEditor} from 'slate-react'
44
40
  import type {DOMNode} from 'slate-react/dist/utils/dom'
41
+ import type {TextInsertTextOptions} from 'slate/dist/interfaces/transforms/text'
45
42
  import {
43
+ ActionArgs,
46
44
  ActionFunction,
47
45
  ActorRef,
48
46
  ActorRefFrom,
@@ -72,37 +70,71 @@ export declare type Behavior<
72
70
  TBehaviorEventType extends BehaviorEvent['type'] = BehaviorEvent['type'],
73
71
  TGuardResponse = true,
74
72
  > = {
73
+ /**
74
+ * The internal editor event that triggers this behavior.
75
+ */
75
76
  on: TBehaviorEventType
77
+ /**
78
+ * Predicate function that determines if the behavior should be executed.
79
+ * Returning a non-nullable value from the guard will pass the value to the
80
+ * actions and execute them.
81
+ */
76
82
  guard?: BehaviorGuard<
77
83
  PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>,
78
84
  TGuardResponse
79
85
  >
80
- actions: Array<RaiseBehaviorActionIntend<TBehaviorEventType, TGuardResponse>>
86
+ /**
87
+ * Array of behavior action sets.
88
+ */
89
+ actions: Array<BehaviorActionIntendSet<TBehaviorEventType, TGuardResponse>>
81
90
  }
82
91
 
83
92
  /**
84
93
  * @alpha
85
94
  */
86
95
  export declare type BehaviorActionIntend =
87
- | {
88
- [TBehaviorEvent in BehaviorEvent as TBehaviorEvent['type']]: Omit<
89
- TBehaviorEvent,
90
- 'default'
91
- >
92
- }[BehaviorEvent['type']]
96
+ | BehaviorEvent
93
97
  | {
94
98
  type: 'insert text block'
95
99
  decorators: Array<string>
96
100
  }
97
101
  | {
98
- type: 'apply block style'
102
+ type: 'set block'
103
+ paths: Array<[KeyedSegment]>
104
+ style?: string
105
+ listItem?: string
106
+ level?: number
107
+ }
108
+ | {
109
+ type: 'unset block'
99
110
  paths: Array<[KeyedSegment]>
100
- style: string
111
+ props: Array<'style' | 'listItem' | 'level'>
101
112
  }
102
113
  | {
103
114
  type: 'delete text'
104
115
  selection: NonNullable<EditorSelection>
105
116
  }
117
+ | {
118
+ type: 'effect'
119
+ effect: () => void
120
+ }
121
+
122
+ /**
123
+ * @alpha
124
+ */
125
+ export declare type BehaviorActionIntendSet<
126
+ TBehaviorEventType extends BehaviorEvent['type'] = BehaviorEvent['type'],
127
+ TGuardResponse = true,
128
+ > = (
129
+ {
130
+ context,
131
+ event,
132
+ }: {
133
+ context: BehaviorContext
134
+ event: PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>
135
+ },
136
+ guardResponse: TGuardResponse,
137
+ ) => Array<BehaviorActionIntend>
106
138
 
107
139
  /**
108
140
  * @alpha
@@ -120,20 +152,17 @@ export declare type BehaviorEvent =
120
152
  | {
121
153
  type: 'delete backward'
122
154
  unit: TextUnit
123
- default: () => void
124
155
  }
125
156
  | {
126
157
  type: 'insert soft break'
127
- default: () => void
128
158
  }
129
159
  | {
130
160
  type: 'insert break'
131
- default: () => void
132
161
  }
133
162
  | {
134
163
  type: 'insert text'
135
164
  text: string
136
- default: () => void
165
+ options?: TextInsertTextOptions
137
166
  }
138
167
 
139
168
  /**
@@ -370,63 +399,6 @@ export declare const editorMachine: StateMachine<
370
399
  pendingEvents: Array<PatchEvent | MutationEvent_2>
371
400
  schema: PortableTextMemberSchemaTypes
372
401
  },
373
- | (Omit<
374
- {
375
- type: 'delete backward'
376
- unit: TextUnit
377
- default: () => void
378
- },
379
- 'default'
380
- > & {
381
- editor: PortableTextSlateEditor
382
- })
383
- | (Omit<
384
- {
385
- type: 'insert soft break'
386
- default: () => void
387
- },
388
- 'default'
389
- > & {
390
- editor: PortableTextSlateEditor
391
- })
392
- | (Omit<
393
- {
394
- type: 'insert break'
395
- default: () => void
396
- },
397
- 'default'
398
- > & {
399
- editor: PortableTextSlateEditor
400
- })
401
- | (Omit<
402
- {
403
- type: 'insert text'
404
- text: string
405
- default: () => void
406
- },
407
- 'default'
408
- > & {
409
- editor: PortableTextSlateEditor
410
- })
411
- | ({
412
- type: 'insert text block'
413
- decorators: Array<string>
414
- } & {
415
- editor: PortableTextSlateEditor
416
- })
417
- | ({
418
- type: 'apply block style'
419
- paths: Array<[KeyedSegment]>
420
- style: string
421
- } & {
422
- editor: PortableTextSlateEditor
423
- })
424
- | ({
425
- type: 'delete text'
426
- selection: NonNullable<EditorSelection>
427
- } & {
428
- editor: PortableTextSlateEditor
429
- })
430
402
  | PatchEvent
431
403
  | MutationEvent_2
432
404
  | {
@@ -440,6 +412,11 @@ export declare const editorMachine: StateMachine<
440
412
  behaviorEvent: BehaviorEvent
441
413
  editor: PortableTextSlateEditor
442
414
  }
415
+ | {
416
+ type: 'behavior action intends'
417
+ editor: PortableTextSlateEditor
418
+ actionIntends: Array<BehaviorActionIntend>
419
+ }
443
420
  | {
444
421
  type: 'update schema'
445
422
  schema: PortableTextMemberSchemaTypes
@@ -679,63 +656,6 @@ export declare const editorMachine: StateMachine<
679
656
  pendingEvents: Array<PatchEvent | MutationEvent_2>
680
657
  schema: PortableTextMemberSchemaTypes
681
658
  },
682
- | (Omit<
683
- {
684
- type: 'delete backward'
685
- unit: TextUnit
686
- default: () => void
687
- },
688
- 'default'
689
- > & {
690
- editor: PortableTextSlateEditor
691
- })
692
- | (Omit<
693
- {
694
- type: 'insert soft break'
695
- default: () => void
696
- },
697
- 'default'
698
- > & {
699
- editor: PortableTextSlateEditor
700
- })
701
- | (Omit<
702
- {
703
- type: 'insert break'
704
- default: () => void
705
- },
706
- 'default'
707
- > & {
708
- editor: PortableTextSlateEditor
709
- })
710
- | (Omit<
711
- {
712
- type: 'insert text'
713
- text: string
714
- default: () => void
715
- },
716
- 'default'
717
- > & {
718
- editor: PortableTextSlateEditor
719
- })
720
- | ({
721
- type: 'insert text block'
722
- decorators: Array<string>
723
- } & {
724
- editor: PortableTextSlateEditor
725
- })
726
- | ({
727
- type: 'apply block style'
728
- paths: Array<[KeyedSegment]>
729
- style: string
730
- } & {
731
- editor: PortableTextSlateEditor
732
- })
733
- | ({
734
- type: 'delete text'
735
- selection: NonNullable<EditorSelection>
736
- } & {
737
- editor: PortableTextSlateEditor
738
- })
739
659
  | PatchEvent
740
660
  | MutationEvent_2
741
661
  | {
@@ -749,6 +669,11 @@ export declare const editorMachine: StateMachine<
749
669
  behaviorEvent: BehaviorEvent
750
670
  editor: PortableTextSlateEditor
751
671
  }
672
+ | {
673
+ type: 'behavior action intends'
674
+ editor: PortableTextSlateEditor
675
+ actionIntends: Array<BehaviorActionIntend>
676
+ }
752
677
  | {
753
678
  type: 'update schema'
754
679
  schema: PortableTextMemberSchemaTypes
@@ -806,63 +731,6 @@ export declare const editorMachine: StateMachine<
806
731
  any,
807
732
  any
808
733
  >,
809
- | (Omit<
810
- {
811
- type: 'delete backward'
812
- unit: TextUnit
813
- default: () => void
814
- },
815
- 'default'
816
- > & {
817
- editor: PortableTextSlateEditor
818
- })
819
- | (Omit<
820
- {
821
- type: 'insert soft break'
822
- default: () => void
823
- },
824
- 'default'
825
- > & {
826
- editor: PortableTextSlateEditor
827
- })
828
- | (Omit<
829
- {
830
- type: 'insert break'
831
- default: () => void
832
- },
833
- 'default'
834
- > & {
835
- editor: PortableTextSlateEditor
836
- })
837
- | (Omit<
838
- {
839
- type: 'insert text'
840
- text: string
841
- default: () => void
842
- },
843
- 'default'
844
- > & {
845
- editor: PortableTextSlateEditor
846
- })
847
- | ({
848
- type: 'insert text block'
849
- decorators: Array<string>
850
- } & {
851
- editor: PortableTextSlateEditor
852
- })
853
- | ({
854
- type: 'apply block style'
855
- paths: Array<[KeyedSegment]>
856
- style: string
857
- } & {
858
- editor: PortableTextSlateEditor
859
- })
860
- | ({
861
- type: 'delete text'
862
- selection: NonNullable<EditorSelection>
863
- } & {
864
- editor: PortableTextSlateEditor
865
- })
866
734
  | PatchEvent
867
735
  | MutationEvent_2
868
736
  | {
@@ -876,6 +744,11 @@ export declare const editorMachine: StateMachine<
876
744
  behaviorEvent: BehaviorEvent
877
745
  editor: PortableTextSlateEditor
878
746
  }
747
+ | {
748
+ type: 'behavior action intends'
749
+ editor: PortableTextSlateEditor
750
+ actionIntends: Array<BehaviorActionIntend>
751
+ }
879
752
  | {
880
753
  type: 'update schema'
881
754
  schema: PortableTextMemberSchemaTypes
@@ -950,63 +823,6 @@ export declare const editorMachine: StateMachine<
950
823
  {
951
824
  type: 'ready'
952
825
  },
953
- | (Omit<
954
- {
955
- type: 'delete backward'
956
- unit: TextUnit
957
- default: () => void
958
- },
959
- 'default'
960
- > & {
961
- editor: PortableTextSlateEditor
962
- })
963
- | (Omit<
964
- {
965
- type: 'insert soft break'
966
- default: () => void
967
- },
968
- 'default'
969
- > & {
970
- editor: PortableTextSlateEditor
971
- })
972
- | (Omit<
973
- {
974
- type: 'insert break'
975
- default: () => void
976
- },
977
- 'default'
978
- > & {
979
- editor: PortableTextSlateEditor
980
- })
981
- | (Omit<
982
- {
983
- type: 'insert text'
984
- text: string
985
- default: () => void
986
- },
987
- 'default'
988
- > & {
989
- editor: PortableTextSlateEditor
990
- })
991
- | ({
992
- type: 'insert text block'
993
- decorators: Array<string>
994
- } & {
995
- editor: PortableTextSlateEditor
996
- })
997
- | ({
998
- type: 'apply block style'
999
- paths: Array<[KeyedSegment]>
1000
- style: string
1001
- } & {
1002
- editor: PortableTextSlateEditor
1003
- })
1004
- | ({
1005
- type: 'delete text'
1006
- selection: NonNullable<EditorSelection>
1007
- } & {
1008
- editor: PortableTextSlateEditor
1009
- })
1010
826
  | PatchEvent
1011
827
  | MutationEvent_2
1012
828
  | {
@@ -1020,6 +836,11 @@ export declare const editorMachine: StateMachine<
1020
836
  behaviorEvent: BehaviorEvent
1021
837
  editor: PortableTextSlateEditor
1022
838
  }
839
+ | {
840
+ type: 'behavior action intends'
841
+ editor: PortableTextSlateEditor
842
+ actionIntends: Array<BehaviorActionIntend>
843
+ }
1023
844
  | {
1024
845
  type: 'update schema'
1025
846
  schema: PortableTextMemberSchemaTypes
@@ -1137,63 +958,6 @@ export declare const editorMachine: StateMachine<
1137
958
  type: 'unset'
1138
959
  previousValue: Array<PortableTextBlock>
1139
960
  },
1140
- | (Omit<
1141
- {
1142
- type: 'delete backward'
1143
- unit: TextUnit
1144
- default: () => void
1145
- },
1146
- 'default'
1147
- > & {
1148
- editor: PortableTextSlateEditor
1149
- })
1150
- | (Omit<
1151
- {
1152
- type: 'insert soft break'
1153
- default: () => void
1154
- },
1155
- 'default'
1156
- > & {
1157
- editor: PortableTextSlateEditor
1158
- })
1159
- | (Omit<
1160
- {
1161
- type: 'insert break'
1162
- default: () => void
1163
- },
1164
- 'default'
1165
- > & {
1166
- editor: PortableTextSlateEditor
1167
- })
1168
- | (Omit<
1169
- {
1170
- type: 'insert text'
1171
- text: string
1172
- default: () => void
1173
- },
1174
- 'default'
1175
- > & {
1176
- editor: PortableTextSlateEditor
1177
- })
1178
- | ({
1179
- type: 'insert text block'
1180
- decorators: Array<string>
1181
- } & {
1182
- editor: PortableTextSlateEditor
1183
- })
1184
- | ({
1185
- type: 'apply block style'
1186
- paths: Array<[KeyedSegment]>
1187
- style: string
1188
- } & {
1189
- editor: PortableTextSlateEditor
1190
- })
1191
- | ({
1192
- type: 'delete text'
1193
- selection: NonNullable<EditorSelection>
1194
- } & {
1195
- editor: PortableTextSlateEditor
1196
- })
1197
961
  | PatchEvent
1198
962
  | MutationEvent_2
1199
963
  | {
@@ -1207,6 +971,11 @@ export declare const editorMachine: StateMachine<
1207
971
  behaviorEvent: BehaviorEvent
1208
972
  editor: PortableTextSlateEditor
1209
973
  }
974
+ | {
975
+ type: 'behavior action intends'
976
+ editor: PortableTextSlateEditor
977
+ actionIntends: Array<BehaviorActionIntend>
978
+ }
1210
979
  | {
1211
980
  type: 'update schema'
1212
981
  schema: PortableTextMemberSchemaTypes
@@ -1324,63 +1093,6 @@ export declare const editorMachine: StateMachine<
1324
1093
  type: 'value changed'
1325
1094
  value: Array<PortableTextBlock> | undefined
1326
1095
  },
1327
- | (Omit<
1328
- {
1329
- type: 'delete backward'
1330
- unit: TextUnit
1331
- default: () => void
1332
- },
1333
- 'default'
1334
- > & {
1335
- editor: PortableTextSlateEditor
1336
- })
1337
- | (Omit<
1338
- {
1339
- type: 'insert soft break'
1340
- default: () => void
1341
- },
1342
- 'default'
1343
- > & {
1344
- editor: PortableTextSlateEditor
1345
- })
1346
- | (Omit<
1347
- {
1348
- type: 'insert break'
1349
- default: () => void
1350
- },
1351
- 'default'
1352
- > & {
1353
- editor: PortableTextSlateEditor
1354
- })
1355
- | (Omit<
1356
- {
1357
- type: 'insert text'
1358
- text: string
1359
- default: () => void
1360
- },
1361
- 'default'
1362
- > & {
1363
- editor: PortableTextSlateEditor
1364
- })
1365
- | ({
1366
- type: 'insert text block'
1367
- decorators: Array<string>
1368
- } & {
1369
- editor: PortableTextSlateEditor
1370
- })
1371
- | ({
1372
- type: 'apply block style'
1373
- paths: Array<[KeyedSegment]>
1374
- style: string
1375
- } & {
1376
- editor: PortableTextSlateEditor
1377
- })
1378
- | ({
1379
- type: 'delete text'
1380
- selection: NonNullable<EditorSelection>
1381
- } & {
1382
- editor: PortableTextSlateEditor
1383
- })
1384
1096
  | PatchEvent
1385
1097
  | MutationEvent_2
1386
1098
  | {
@@ -1394,6 +1106,11 @@ export declare const editorMachine: StateMachine<
1394
1106
  behaviorEvent: BehaviorEvent
1395
1107
  editor: PortableTextSlateEditor
1396
1108
  }
1109
+ | {
1110
+ type: 'behavior action intends'
1111
+ editor: PortableTextSlateEditor
1112
+ actionIntends: Array<BehaviorActionIntend>
1113
+ }
1397
1114
  | {
1398
1115
  type: 'update schema'
1399
1116
  schema: PortableTextMemberSchemaTypes
@@ -1512,63 +1229,6 @@ export declare const editorMachine: StateMachine<
1512
1229
  resolution: InvalidValueResolution | null
1513
1230
  value: Array<PortableTextBlock> | undefined
1514
1231
  },
1515
- | (Omit<
1516
- {
1517
- type: 'delete backward'
1518
- unit: TextUnit
1519
- default: () => void
1520
- },
1521
- 'default'
1522
- > & {
1523
- editor: PortableTextSlateEditor
1524
- })
1525
- | (Omit<
1526
- {
1527
- type: 'insert soft break'
1528
- default: () => void
1529
- },
1530
- 'default'
1531
- > & {
1532
- editor: PortableTextSlateEditor
1533
- })
1534
- | (Omit<
1535
- {
1536
- type: 'insert break'
1537
- default: () => void
1538
- },
1539
- 'default'
1540
- > & {
1541
- editor: PortableTextSlateEditor
1542
- })
1543
- | (Omit<
1544
- {
1545
- type: 'insert text'
1546
- text: string
1547
- default: () => void
1548
- },
1549
- 'default'
1550
- > & {
1551
- editor: PortableTextSlateEditor
1552
- })
1553
- | ({
1554
- type: 'insert text block'
1555
- decorators: Array<string>
1556
- } & {
1557
- editor: PortableTextSlateEditor
1558
- })
1559
- | ({
1560
- type: 'apply block style'
1561
- paths: Array<[KeyedSegment]>
1562
- style: string
1563
- } & {
1564
- editor: PortableTextSlateEditor
1565
- })
1566
- | ({
1567
- type: 'delete text'
1568
- selection: NonNullable<EditorSelection>
1569
- } & {
1570
- editor: PortableTextSlateEditor
1571
- })
1572
1232
  | PatchEvent
1573
1233
  | MutationEvent_2
1574
1234
  | {
@@ -1582,6 +1242,11 @@ export declare const editorMachine: StateMachine<
1582
1242
  behaviorEvent: BehaviorEvent
1583
1243
  editor: PortableTextSlateEditor
1584
1244
  }
1245
+ | {
1246
+ type: 'behavior action intends'
1247
+ editor: PortableTextSlateEditor
1248
+ actionIntends: Array<BehaviorActionIntend>
1249
+ }
1585
1250
  | {
1586
1251
  type: 'update schema'
1587
1252
  schema: PortableTextMemberSchemaTypes
@@ -1701,63 +1366,6 @@ export declare const editorMachine: StateMachine<
1701
1366
  description: string
1702
1367
  data: unknown
1703
1368
  },
1704
- | (Omit<
1705
- {
1706
- type: 'delete backward'
1707
- unit: TextUnit
1708
- default: () => void
1709
- },
1710
- 'default'
1711
- > & {
1712
- editor: PortableTextSlateEditor
1713
- })
1714
- | (Omit<
1715
- {
1716
- type: 'insert soft break'
1717
- default: () => void
1718
- },
1719
- 'default'
1720
- > & {
1721
- editor: PortableTextSlateEditor
1722
- })
1723
- | (Omit<
1724
- {
1725
- type: 'insert break'
1726
- default: () => void
1727
- },
1728
- 'default'
1729
- > & {
1730
- editor: PortableTextSlateEditor
1731
- })
1732
- | (Omit<
1733
- {
1734
- type: 'insert text'
1735
- text: string
1736
- default: () => void
1737
- },
1738
- 'default'
1739
- > & {
1740
- editor: PortableTextSlateEditor
1741
- })
1742
- | ({
1743
- type: 'insert text block'
1744
- decorators: Array<string>
1745
- } & {
1746
- editor: PortableTextSlateEditor
1747
- })
1748
- | ({
1749
- type: 'apply block style'
1750
- paths: Array<[KeyedSegment]>
1751
- style: string
1752
- } & {
1753
- editor: PortableTextSlateEditor
1754
- })
1755
- | ({
1756
- type: 'delete text'
1757
- selection: NonNullable<EditorSelection>
1758
- } & {
1759
- editor: PortableTextSlateEditor
1760
- })
1761
1369
  | PatchEvent
1762
1370
  | MutationEvent_2
1763
1371
  | {
@@ -1771,6 +1379,11 @@ export declare const editorMachine: StateMachine<
1771
1379
  behaviorEvent: BehaviorEvent
1772
1380
  editor: PortableTextSlateEditor
1773
1381
  }
1382
+ | {
1383
+ type: 'behavior action intends'
1384
+ editor: PortableTextSlateEditor
1385
+ actionIntends: Array<BehaviorActionIntend>
1386
+ }
1774
1387
  | {
1775
1388
  type: 'update schema'
1776
1389
  schema: PortableTextMemberSchemaTypes
@@ -1888,63 +1501,6 @@ export declare const editorMachine: StateMachine<
1888
1501
  type: 'selection'
1889
1502
  selection: EditorSelection
1890
1503
  },
1891
- | (Omit<
1892
- {
1893
- type: 'delete backward'
1894
- unit: TextUnit
1895
- default: () => void
1896
- },
1897
- 'default'
1898
- > & {
1899
- editor: PortableTextSlateEditor
1900
- })
1901
- | (Omit<
1902
- {
1903
- type: 'insert soft break'
1904
- default: () => void
1905
- },
1906
- 'default'
1907
- > & {
1908
- editor: PortableTextSlateEditor
1909
- })
1910
- | (Omit<
1911
- {
1912
- type: 'insert break'
1913
- default: () => void
1914
- },
1915
- 'default'
1916
- > & {
1917
- editor: PortableTextSlateEditor
1918
- })
1919
- | (Omit<
1920
- {
1921
- type: 'insert text'
1922
- text: string
1923
- default: () => void
1924
- },
1925
- 'default'
1926
- > & {
1927
- editor: PortableTextSlateEditor
1928
- })
1929
- | ({
1930
- type: 'insert text block'
1931
- decorators: Array<string>
1932
- } & {
1933
- editor: PortableTextSlateEditor
1934
- })
1935
- | ({
1936
- type: 'apply block style'
1937
- paths: Array<[KeyedSegment]>
1938
- style: string
1939
- } & {
1940
- editor: PortableTextSlateEditor
1941
- })
1942
- | ({
1943
- type: 'delete text'
1944
- selection: NonNullable<EditorSelection>
1945
- } & {
1946
- editor: PortableTextSlateEditor
1947
- })
1948
1504
  | PatchEvent
1949
1505
  | MutationEvent_2
1950
1506
  | {
@@ -1958,6 +1514,11 @@ export declare const editorMachine: StateMachine<
1958
1514
  behaviorEvent: BehaviorEvent
1959
1515
  editor: PortableTextSlateEditor
1960
1516
  }
1517
+ | {
1518
+ type: 'behavior action intends'
1519
+ editor: PortableTextSlateEditor
1520
+ actionIntends: Array<BehaviorActionIntend>
1521
+ }
1961
1522
  | {
1962
1523
  type: 'update schema'
1963
1524
  schema: PortableTextMemberSchemaTypes
@@ -2075,63 +1636,6 @@ export declare const editorMachine: StateMachine<
2075
1636
  type: 'blur'
2076
1637
  event: FocusEvent_2<HTMLDivElement, Element>
2077
1638
  },
2078
- | (Omit<
2079
- {
2080
- type: 'delete backward'
2081
- unit: TextUnit
2082
- default: () => void
2083
- },
2084
- 'default'
2085
- > & {
2086
- editor: PortableTextSlateEditor
2087
- })
2088
- | (Omit<
2089
- {
2090
- type: 'insert soft break'
2091
- default: () => void
2092
- },
2093
- 'default'
2094
- > & {
2095
- editor: PortableTextSlateEditor
2096
- })
2097
- | (Omit<
2098
- {
2099
- type: 'insert break'
2100
- default: () => void
2101
- },
2102
- 'default'
2103
- > & {
2104
- editor: PortableTextSlateEditor
2105
- })
2106
- | (Omit<
2107
- {
2108
- type: 'insert text'
2109
- text: string
2110
- default: () => void
2111
- },
2112
- 'default'
2113
- > & {
2114
- editor: PortableTextSlateEditor
2115
- })
2116
- | ({
2117
- type: 'insert text block'
2118
- decorators: Array<string>
2119
- } & {
2120
- editor: PortableTextSlateEditor
2121
- })
2122
- | ({
2123
- type: 'apply block style'
2124
- paths: Array<[KeyedSegment]>
2125
- style: string
2126
- } & {
2127
- editor: PortableTextSlateEditor
2128
- })
2129
- | ({
2130
- type: 'delete text'
2131
- selection: NonNullable<EditorSelection>
2132
- } & {
2133
- editor: PortableTextSlateEditor
2134
- })
2135
1639
  | PatchEvent
2136
1640
  | MutationEvent_2
2137
1641
  | {
@@ -2145,6 +1649,11 @@ export declare const editorMachine: StateMachine<
2145
1649
  behaviorEvent: BehaviorEvent
2146
1650
  editor: PortableTextSlateEditor
2147
1651
  }
1652
+ | {
1653
+ type: 'behavior action intends'
1654
+ editor: PortableTextSlateEditor
1655
+ actionIntends: Array<BehaviorActionIntend>
1656
+ }
2148
1657
  | {
2149
1658
  type: 'update schema'
2150
1659
  schema: PortableTextMemberSchemaTypes
@@ -2262,63 +1771,6 @@ export declare const editorMachine: StateMachine<
2262
1771
  type: 'focus'
2263
1772
  event: FocusEvent_2<HTMLDivElement, Element>
2264
1773
  },
2265
- | (Omit<
2266
- {
2267
- type: 'delete backward'
2268
- unit: TextUnit
2269
- default: () => void
2270
- },
2271
- 'default'
2272
- > & {
2273
- editor: PortableTextSlateEditor
2274
- })
2275
- | (Omit<
2276
- {
2277
- type: 'insert soft break'
2278
- default: () => void
2279
- },
2280
- 'default'
2281
- > & {
2282
- editor: PortableTextSlateEditor
2283
- })
2284
- | (Omit<
2285
- {
2286
- type: 'insert break'
2287
- default: () => void
2288
- },
2289
- 'default'
2290
- > & {
2291
- editor: PortableTextSlateEditor
2292
- })
2293
- | (Omit<
2294
- {
2295
- type: 'insert text'
2296
- text: string
2297
- default: () => void
2298
- },
2299
- 'default'
2300
- > & {
2301
- editor: PortableTextSlateEditor
2302
- })
2303
- | ({
2304
- type: 'insert text block'
2305
- decorators: Array<string>
2306
- } & {
2307
- editor: PortableTextSlateEditor
2308
- })
2309
- | ({
2310
- type: 'apply block style'
2311
- paths: Array<[KeyedSegment]>
2312
- style: string
2313
- } & {
2314
- editor: PortableTextSlateEditor
2315
- })
2316
- | ({
2317
- type: 'delete text'
2318
- selection: NonNullable<EditorSelection>
2319
- } & {
2320
- editor: PortableTextSlateEditor
2321
- })
2322
1774
  | PatchEvent
2323
1775
  | MutationEvent_2
2324
1776
  | {
@@ -2332,6 +1784,11 @@ export declare const editorMachine: StateMachine<
2332
1784
  behaviorEvent: BehaviorEvent
2333
1785
  editor: PortableTextSlateEditor
2334
1786
  }
1787
+ | {
1788
+ type: 'behavior action intends'
1789
+ editor: PortableTextSlateEditor
1790
+ actionIntends: Array<BehaviorActionIntend>
1791
+ }
2335
1792
  | {
2336
1793
  type: 'update schema'
2337
1794
  schema: PortableTextMemberSchemaTypes
@@ -2448,63 +1905,6 @@ export declare const editorMachine: StateMachine<
2448
1905
  {
2449
1906
  type: 'online'
2450
1907
  },
2451
- | (Omit<
2452
- {
2453
- type: 'delete backward'
2454
- unit: TextUnit
2455
- default: () => void
2456
- },
2457
- 'default'
2458
- > & {
2459
- editor: PortableTextSlateEditor
2460
- })
2461
- | (Omit<
2462
- {
2463
- type: 'insert soft break'
2464
- default: () => void
2465
- },
2466
- 'default'
2467
- > & {
2468
- editor: PortableTextSlateEditor
2469
- })
2470
- | (Omit<
2471
- {
2472
- type: 'insert break'
2473
- default: () => void
2474
- },
2475
- 'default'
2476
- > & {
2477
- editor: PortableTextSlateEditor
2478
- })
2479
- | (Omit<
2480
- {
2481
- type: 'insert text'
2482
- text: string
2483
- default: () => void
2484
- },
2485
- 'default'
2486
- > & {
2487
- editor: PortableTextSlateEditor
2488
- })
2489
- | ({
2490
- type: 'insert text block'
2491
- decorators: Array<string>
2492
- } & {
2493
- editor: PortableTextSlateEditor
2494
- })
2495
- | ({
2496
- type: 'apply block style'
2497
- paths: Array<[KeyedSegment]>
2498
- style: string
2499
- } & {
2500
- editor: PortableTextSlateEditor
2501
- })
2502
- | ({
2503
- type: 'delete text'
2504
- selection: NonNullable<EditorSelection>
2505
- } & {
2506
- editor: PortableTextSlateEditor
2507
- })
2508
1908
  | PatchEvent
2509
1909
  | MutationEvent_2
2510
1910
  | {
@@ -2518,6 +1918,11 @@ export declare const editorMachine: StateMachine<
2518
1918
  behaviorEvent: BehaviorEvent
2519
1919
  editor: PortableTextSlateEditor
2520
1920
  }
1921
+ | {
1922
+ type: 'behavior action intends'
1923
+ editor: PortableTextSlateEditor
1924
+ actionIntends: Array<BehaviorActionIntend>
1925
+ }
2521
1926
  | {
2522
1927
  type: 'update schema'
2523
1928
  schema: PortableTextMemberSchemaTypes
@@ -2634,63 +2039,6 @@ export declare const editorMachine: StateMachine<
2634
2039
  {
2635
2040
  type: 'offline'
2636
2041
  },
2637
- | (Omit<
2638
- {
2639
- type: 'delete backward'
2640
- unit: TextUnit
2641
- default: () => void
2642
- },
2643
- 'default'
2644
- > & {
2645
- editor: PortableTextSlateEditor
2646
- })
2647
- | (Omit<
2648
- {
2649
- type: 'insert soft break'
2650
- default: () => void
2651
- },
2652
- 'default'
2653
- > & {
2654
- editor: PortableTextSlateEditor
2655
- })
2656
- | (Omit<
2657
- {
2658
- type: 'insert break'
2659
- default: () => void
2660
- },
2661
- 'default'
2662
- > & {
2663
- editor: PortableTextSlateEditor
2664
- })
2665
- | (Omit<
2666
- {
2667
- type: 'insert text'
2668
- text: string
2669
- default: () => void
2670
- },
2671
- 'default'
2672
- > & {
2673
- editor: PortableTextSlateEditor
2674
- })
2675
- | ({
2676
- type: 'insert text block'
2677
- decorators: Array<string>
2678
- } & {
2679
- editor: PortableTextSlateEditor
2680
- })
2681
- | ({
2682
- type: 'apply block style'
2683
- paths: Array<[KeyedSegment]>
2684
- style: string
2685
- } & {
2686
- editor: PortableTextSlateEditor
2687
- })
2688
- | ({
2689
- type: 'delete text'
2690
- selection: NonNullable<EditorSelection>
2691
- } & {
2692
- editor: PortableTextSlateEditor
2693
- })
2694
2042
  | PatchEvent
2695
2043
  | MutationEvent_2
2696
2044
  | {
@@ -2704,6 +2052,11 @@ export declare const editorMachine: StateMachine<
2704
2052
  behaviorEvent: BehaviorEvent
2705
2053
  editor: PortableTextSlateEditor
2706
2054
  }
2055
+ | {
2056
+ type: 'behavior action intends'
2057
+ editor: PortableTextSlateEditor
2058
+ actionIntends: Array<BehaviorActionIntend>
2059
+ }
2707
2060
  | {
2708
2061
  type: 'update schema'
2709
2062
  schema: PortableTextMemberSchemaTypes
@@ -2820,63 +2173,6 @@ export declare const editorMachine: StateMachine<
2820
2173
  {
2821
2174
  type: 'loading'
2822
2175
  },
2823
- | (Omit<
2824
- {
2825
- type: 'delete backward'
2826
- unit: TextUnit
2827
- default: () => void
2828
- },
2829
- 'default'
2830
- > & {
2831
- editor: PortableTextSlateEditor
2832
- })
2833
- | (Omit<
2834
- {
2835
- type: 'insert soft break'
2836
- default: () => void
2837
- },
2838
- 'default'
2839
- > & {
2840
- editor: PortableTextSlateEditor
2841
- })
2842
- | (Omit<
2843
- {
2844
- type: 'insert break'
2845
- default: () => void
2846
- },
2847
- 'default'
2848
- > & {
2849
- editor: PortableTextSlateEditor
2850
- })
2851
- | (Omit<
2852
- {
2853
- type: 'insert text'
2854
- text: string
2855
- default: () => void
2856
- },
2857
- 'default'
2858
- > & {
2859
- editor: PortableTextSlateEditor
2860
- })
2861
- | ({
2862
- type: 'insert text block'
2863
- decorators: Array<string>
2864
- } & {
2865
- editor: PortableTextSlateEditor
2866
- })
2867
- | ({
2868
- type: 'apply block style'
2869
- paths: Array<[KeyedSegment]>
2870
- style: string
2871
- } & {
2872
- editor: PortableTextSlateEditor
2873
- })
2874
- | ({
2875
- type: 'delete text'
2876
- selection: NonNullable<EditorSelection>
2877
- } & {
2878
- editor: PortableTextSlateEditor
2879
- })
2880
2176
  | PatchEvent
2881
2177
  | MutationEvent_2
2882
2178
  | {
@@ -2890,6 +2186,11 @@ export declare const editorMachine: StateMachine<
2890
2186
  behaviorEvent: BehaviorEvent
2891
2187
  editor: PortableTextSlateEditor
2892
2188
  }
2189
+ | {
2190
+ type: 'behavior action intends'
2191
+ editor: PortableTextSlateEditor
2192
+ actionIntends: Array<BehaviorActionIntend>
2193
+ }
2893
2194
  | {
2894
2195
  type: 'update schema'
2895
2196
  schema: PortableTextMemberSchemaTypes
@@ -3006,63 +2307,6 @@ export declare const editorMachine: StateMachine<
3006
2307
  {
3007
2308
  type: 'done loading'
3008
2309
  },
3009
- | (Omit<
3010
- {
3011
- type: 'delete backward'
3012
- unit: TextUnit
3013
- default: () => void
3014
- },
3015
- 'default'
3016
- > & {
3017
- editor: PortableTextSlateEditor
3018
- })
3019
- | (Omit<
3020
- {
3021
- type: 'insert soft break'
3022
- default: () => void
3023
- },
3024
- 'default'
3025
- > & {
3026
- editor: PortableTextSlateEditor
3027
- })
3028
- | (Omit<
3029
- {
3030
- type: 'insert break'
3031
- default: () => void
3032
- },
3033
- 'default'
3034
- > & {
3035
- editor: PortableTextSlateEditor
3036
- })
3037
- | (Omit<
3038
- {
3039
- type: 'insert text'
3040
- text: string
3041
- default: () => void
3042
- },
3043
- 'default'
3044
- > & {
3045
- editor: PortableTextSlateEditor
3046
- })
3047
- | ({
3048
- type: 'insert text block'
3049
- decorators: Array<string>
3050
- } & {
3051
- editor: PortableTextSlateEditor
3052
- })
3053
- | ({
3054
- type: 'apply block style'
3055
- paths: Array<[KeyedSegment]>
3056
- style: string
3057
- } & {
3058
- editor: PortableTextSlateEditor
3059
- })
3060
- | ({
3061
- type: 'delete text'
3062
- selection: NonNullable<EditorSelection>
3063
- } & {
3064
- editor: PortableTextSlateEditor
3065
- })
3066
2310
  | PatchEvent
3067
2311
  | MutationEvent_2
3068
2312
  | {
@@ -3076,6 +2320,11 @@ export declare const editorMachine: StateMachine<
3076
2320
  behaviorEvent: BehaviorEvent
3077
2321
  editor: PortableTextSlateEditor
3078
2322
  }
2323
+ | {
2324
+ type: 'behavior action intends'
2325
+ editor: PortableTextSlateEditor
2326
+ actionIntends: Array<BehaviorActionIntend>
2327
+ }
3079
2328
  | {
3080
2329
  type: 'update schema'
3081
2330
  schema: PortableTextMemberSchemaTypes
@@ -3187,152 +2436,92 @@ export declare const editorMachine: StateMachine<
3187
2436
  readonly 'behavior event': {
3188
2437
  readonly actions: 'handle behavior event'
3189
2438
  }
3190
- readonly 'apply block style': {
3191
- readonly actions: readonly [
3192
- ({
3193
- context,
3194
- event,
3195
- }: {
3196
- context: {
3197
- keyGenerator: () => string
3198
- schema: PortableTextMemberSchemaTypes
3199
- }
3200
- event: {
3201
- type: 'apply block style'
3202
- paths: Array<[KeyedSegment]>
3203
- style: string
3204
- } & {
3205
- editor: PortableTextSlateEditor
3206
- }
3207
- }) => void,
3208
- ]
3209
- }
3210
- readonly 'delete backward': {
3211
- readonly actions: readonly [
3212
- ({
3213
- context,
3214
- event,
3215
- }: {
3216
- context: {
3217
- keyGenerator: () => string
3218
- schema: PortableTextMemberSchemaTypes
3219
- }
3220
- event: Omit<
3221
- {
3222
- type: 'delete backward'
3223
- unit: TextUnit
3224
- default: () => void
3225
- },
3226
- 'default'
3227
- > & {
3228
- editor: PortableTextSlateEditor
3229
- }
3230
- }) => void,
3231
- ]
3232
- }
3233
- readonly 'delete text': {
3234
- readonly actions: readonly [
3235
- ({
3236
- context,
3237
- event,
3238
- }: {
3239
- context: {
3240
- keyGenerator: () => string
3241
- schema: PortableTextMemberSchemaTypes
3242
- }
3243
- event: {
3244
- type: 'delete text'
3245
- selection: NonNullable<EditorSelection>
3246
- } & {
3247
- editor: PortableTextSlateEditor
3248
- }
3249
- }) => void,
3250
- ]
3251
- }
3252
- readonly 'insert break': {
3253
- readonly actions: readonly [
3254
- ({
3255
- context,
3256
- event,
3257
- }: {
3258
- context: {
3259
- keyGenerator: () => string
3260
- schema: PortableTextMemberSchemaTypes
3261
- }
3262
- event: Omit<
3263
- {
3264
- type: 'insert break'
3265
- default: () => void
3266
- },
3267
- 'default'
3268
- > & {
3269
- editor: PortableTextSlateEditor
3270
- }
3271
- }) => void,
3272
- ]
3273
- }
3274
- readonly 'insert soft break': {
3275
- readonly actions: readonly [
3276
- ({
3277
- context,
3278
- event,
3279
- }: {
3280
- context: {
3281
- keyGenerator: () => string
3282
- schema: PortableTextMemberSchemaTypes
3283
- }
3284
- event: Omit<
3285
- {
3286
- type: 'insert soft break'
3287
- default: () => void
3288
- },
3289
- 'default'
3290
- > & {
3291
- editor: PortableTextSlateEditor
3292
- }
3293
- }) => void,
3294
- ]
3295
- }
3296
- readonly 'insert text': {
3297
- readonly actions: readonly [
3298
- ({
3299
- context,
3300
- event,
3301
- }: {
3302
- context: {
3303
- keyGenerator: () => string
3304
- schema: PortableTextMemberSchemaTypes
3305
- }
3306
- event: Omit<
3307
- {
3308
- type: 'insert text'
3309
- text: string
3310
- default: () => void
3311
- },
3312
- 'default'
3313
- > & {
3314
- editor: PortableTextSlateEditor
3315
- }
3316
- }) => void,
3317
- ]
3318
- }
3319
- readonly 'insert text block': {
2439
+ readonly 'behavior action intends': {
3320
2440
  readonly actions: readonly [
3321
2441
  ({
3322
2442
  context,
3323
2443
  event,
3324
- }: {
3325
- context: {
2444
+ }: ActionArgs<
2445
+ {
2446
+ behaviors: Array<Behavior>
3326
2447
  keyGenerator: () => string
2448
+ pendingEvents: Array<PatchEvent | MutationEvent_2>
3327
2449
  schema: PortableTextMemberSchemaTypes
3328
- }
3329
- event: {
3330
- type: 'insert text block'
3331
- decorators: Array<string>
3332
- } & {
2450
+ },
2451
+ {
2452
+ type: 'behavior action intends'
3333
2453
  editor: PortableTextSlateEditor
3334
- }
3335
- }) => void,
2454
+ actionIntends: Array<BehaviorActionIntend>
2455
+ },
2456
+ | PatchEvent
2457
+ | MutationEvent_2
2458
+ | {
2459
+ type: 'normalizing'
2460
+ }
2461
+ | {
2462
+ type: 'done normalizing'
2463
+ }
2464
+ | {
2465
+ type: 'behavior event'
2466
+ behaviorEvent: BehaviorEvent
2467
+ editor: PortableTextSlateEditor
2468
+ }
2469
+ | {
2470
+ type: 'behavior action intends'
2471
+ editor: PortableTextSlateEditor
2472
+ actionIntends: Array<BehaviorActionIntend>
2473
+ }
2474
+ | {
2475
+ type: 'update schema'
2476
+ schema: PortableTextMemberSchemaTypes
2477
+ }
2478
+ | {
2479
+ type: 'ready'
2480
+ }
2481
+ | {
2482
+ type: 'unset'
2483
+ previousValue: Array<PortableTextBlock>
2484
+ }
2485
+ | {
2486
+ type: 'value changed'
2487
+ value: Array<PortableTextBlock> | undefined
2488
+ }
2489
+ | {
2490
+ type: 'invalid value'
2491
+ resolution: InvalidValueResolution | null
2492
+ value: Array<PortableTextBlock> | undefined
2493
+ }
2494
+ | {
2495
+ type: 'error'
2496
+ name: string
2497
+ description: string
2498
+ data: unknown
2499
+ }
2500
+ | {
2501
+ type: 'selection'
2502
+ selection: EditorSelection
2503
+ }
2504
+ | {
2505
+ type: 'blur'
2506
+ event: FocusEvent_2<HTMLDivElement, Element>
2507
+ }
2508
+ | {
2509
+ type: 'focus'
2510
+ event: FocusEvent_2<HTMLDivElement, Element>
2511
+ }
2512
+ | {
2513
+ type: 'online'
2514
+ }
2515
+ | {
2516
+ type: 'offline'
2517
+ }
2518
+ | {
2519
+ type: 'loading'
2520
+ }
2521
+ | {
2522
+ type: 'done loading'
2523
+ }
2524
+ >) => void,
3336
2525
  ]
3337
2526
  }
3338
2527
  }
@@ -3931,23 +3120,6 @@ export declare interface PortableTextSlateEditor extends ReactEditor {
3931
3120
  redo: () => void
3932
3121
  }
3933
3122
 
3934
- /**
3935
- * @alpha
3936
- */
3937
- export declare type RaiseBehaviorActionIntend<
3938
- TBehaviorEventType extends BehaviorEvent['type'] = BehaviorEvent['type'],
3939
- TGuardResponse = true,
3940
- > = (
3941
- {
3942
- context,
3943
- event,
3944
- }: {
3945
- context: BehaviorContext
3946
- event: PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>
3947
- },
3948
- guardResponse: TGuardResponse,
3949
- ) => BehaviorActionIntend | void
3950
-
3951
3123
  /**
3952
3124
  * A range decoration is a UI affordance that wraps a given selection range in the editor
3953
3125
  * with a custom component. This can be used to highlight search results,