@portabletext/editor 1.1.6 → 1.1.8
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 +450 -38
- package/lib/index.d.ts +450 -38
- package/lib/index.esm.js +109 -102
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +108 -101
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +109 -102
- package/lib/index.mjs.map +1 -1
- package/package.json +12 -12
- package/src/editor/Editable.tsx +15 -3
- package/src/editor/PortableTextEditor.tsx +33 -31
- package/src/editor/behavior/behavior.actions.ts +45 -25
- package/src/editor/behavior/behavior.types.ts +24 -6
- package/src/editor/behavior/behavior.utils.ts +68 -0
- package/src/editor/components/Leaf.tsx +17 -17
- package/src/editor/components/SlateContainer.tsx +5 -1
- package/src/editor/editor-actor-context.ts +4 -0
- package/src/editor/editor-machine.ts +13 -12
- package/src/editor/hooks/useSyncValue.ts +1 -1
- package/src/editor/plugins/createWithHotKeys.ts +1 -24
- package/src/editor/plugins/createWithInsertBreak.ts +16 -28
- package/src/editor/plugins/index.ts +3 -2
- package/src/types/options.ts +2 -0
- package/src/utils/__tests__/operationToPatches.test.ts +15 -1
- package/src/utils/__tests__/patchToOperations.test.ts +11 -1
package/lib/index.d.mts
CHANGED
|
@@ -15,7 +15,11 @@ import type {
|
|
|
15
15
|
SpanSchemaType,
|
|
16
16
|
TypedObject,
|
|
17
17
|
} from '@sanity/types'
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
KeyedSegment,
|
|
20
|
+
PortableTextSpan,
|
|
21
|
+
PortableTextTextBlock,
|
|
22
|
+
} from '@sanity/types'
|
|
19
23
|
import type {
|
|
20
24
|
BaseSyntheticEvent,
|
|
21
25
|
ClipboardEvent as ClipboardEvent_2,
|
|
@@ -87,6 +91,15 @@ export declare type BehaviorActionIntend =
|
|
|
87
91
|
type: 'insert text block'
|
|
88
92
|
decorators: Array<string>
|
|
89
93
|
}
|
|
94
|
+
| {
|
|
95
|
+
type: 'apply block style'
|
|
96
|
+
paths: Array<[KeyedSegment]>
|
|
97
|
+
style: string
|
|
98
|
+
}
|
|
99
|
+
| {
|
|
100
|
+
type: 'delete text'
|
|
101
|
+
selection: NonNullable<EditorSelection>
|
|
102
|
+
}
|
|
90
103
|
|
|
91
104
|
/**
|
|
92
105
|
* @alpha
|
|
@@ -100,11 +113,17 @@ export declare type BehaviorContext = {
|
|
|
100
113
|
/**
|
|
101
114
|
* @alpha
|
|
102
115
|
*/
|
|
103
|
-
export declare type BehaviorEvent =
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
116
|
+
export declare type BehaviorEvent =
|
|
117
|
+
| {
|
|
118
|
+
type: 'key down'
|
|
119
|
+
nativeEvent: KeyboardEvent
|
|
120
|
+
editor: PortableTextSlateEditor
|
|
121
|
+
}
|
|
122
|
+
| {
|
|
123
|
+
type: 'before insert text'
|
|
124
|
+
nativeEvent: InputEvent
|
|
125
|
+
editor: PortableTextSlateEditor
|
|
126
|
+
}
|
|
108
127
|
|
|
109
128
|
/**
|
|
110
129
|
* @alpha
|
|
@@ -223,6 +242,7 @@ export declare type ConnectionChange = {
|
|
|
223
242
|
* @internal
|
|
224
243
|
*/
|
|
225
244
|
export declare type createEditorOptions = {
|
|
245
|
+
editorActor: EditorActor
|
|
226
246
|
patches$?: PatchObservable
|
|
227
247
|
portableTextEditor: PortableTextEditor
|
|
228
248
|
readOnly: boolean
|
|
@@ -339,7 +359,6 @@ export declare const editorMachine: StateMachine<
|
|
|
339
359
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
340
360
|
schema: PortableTextMemberSchemaTypes
|
|
341
361
|
},
|
|
342
|
-
| BehaviorEvent
|
|
343
362
|
| ({
|
|
344
363
|
type: 'insert text'
|
|
345
364
|
text: string
|
|
@@ -352,6 +371,29 @@ export declare const editorMachine: StateMachine<
|
|
|
352
371
|
} & {
|
|
353
372
|
editor: PortableTextSlateEditor
|
|
354
373
|
})
|
|
374
|
+
| ({
|
|
375
|
+
type: 'apply block style'
|
|
376
|
+
paths: Array<[KeyedSegment]>
|
|
377
|
+
style: string
|
|
378
|
+
} & {
|
|
379
|
+
editor: PortableTextSlateEditor
|
|
380
|
+
})
|
|
381
|
+
| ({
|
|
382
|
+
type: 'delete text'
|
|
383
|
+
selection: NonNullable<EditorSelection>
|
|
384
|
+
} & {
|
|
385
|
+
editor: PortableTextSlateEditor
|
|
386
|
+
})
|
|
387
|
+
| {
|
|
388
|
+
type: 'key down'
|
|
389
|
+
nativeEvent: KeyboardEvent
|
|
390
|
+
editor: PortableTextSlateEditor
|
|
391
|
+
}
|
|
392
|
+
| {
|
|
393
|
+
type: 'before insert text'
|
|
394
|
+
nativeEvent: InputEvent
|
|
395
|
+
editor: PortableTextSlateEditor
|
|
396
|
+
}
|
|
355
397
|
| PatchEvent
|
|
356
398
|
| MutationEvent_2
|
|
357
399
|
| {
|
|
@@ -423,14 +465,6 @@ export declare const editorMachine: StateMachine<
|
|
|
423
465
|
id: string | undefined
|
|
424
466
|
},
|
|
425
467
|
Values<{
|
|
426
|
-
'apply:insert text': {
|
|
427
|
-
type: 'apply:insert text'
|
|
428
|
-
params: unknown
|
|
429
|
-
}
|
|
430
|
-
'apply:insert text block': {
|
|
431
|
-
type: 'apply:insert text block'
|
|
432
|
-
params: unknown
|
|
433
|
-
}
|
|
434
468
|
'assign schema': {
|
|
435
469
|
type: 'assign schema'
|
|
436
470
|
params: NonReducibleUnknown
|
|
@@ -607,7 +641,6 @@ export declare const editorMachine: StateMachine<
|
|
|
607
641
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
608
642
|
schema: PortableTextMemberSchemaTypes
|
|
609
643
|
},
|
|
610
|
-
| BehaviorEvent
|
|
611
644
|
| ({
|
|
612
645
|
type: 'insert text'
|
|
613
646
|
text: string
|
|
@@ -620,6 +653,29 @@ export declare const editorMachine: StateMachine<
|
|
|
620
653
|
} & {
|
|
621
654
|
editor: PortableTextSlateEditor
|
|
622
655
|
})
|
|
656
|
+
| ({
|
|
657
|
+
type: 'apply block style'
|
|
658
|
+
paths: Array<[KeyedSegment]>
|
|
659
|
+
style: string
|
|
660
|
+
} & {
|
|
661
|
+
editor: PortableTextSlateEditor
|
|
662
|
+
})
|
|
663
|
+
| ({
|
|
664
|
+
type: 'delete text'
|
|
665
|
+
selection: NonNullable<EditorSelection>
|
|
666
|
+
} & {
|
|
667
|
+
editor: PortableTextSlateEditor
|
|
668
|
+
})
|
|
669
|
+
| {
|
|
670
|
+
type: 'key down'
|
|
671
|
+
nativeEvent: KeyboardEvent
|
|
672
|
+
editor: PortableTextSlateEditor
|
|
673
|
+
}
|
|
674
|
+
| {
|
|
675
|
+
type: 'before insert text'
|
|
676
|
+
nativeEvent: InputEvent
|
|
677
|
+
editor: PortableTextSlateEditor
|
|
678
|
+
}
|
|
623
679
|
| PatchEvent
|
|
624
680
|
| MutationEvent_2
|
|
625
681
|
| {
|
|
@@ -685,7 +741,6 @@ export declare const editorMachine: StateMachine<
|
|
|
685
741
|
any,
|
|
686
742
|
any
|
|
687
743
|
>,
|
|
688
|
-
| BehaviorEvent
|
|
689
744
|
| ({
|
|
690
745
|
type: 'insert text'
|
|
691
746
|
text: string
|
|
@@ -698,6 +753,29 @@ export declare const editorMachine: StateMachine<
|
|
|
698
753
|
} & {
|
|
699
754
|
editor: PortableTextSlateEditor
|
|
700
755
|
})
|
|
756
|
+
| ({
|
|
757
|
+
type: 'apply block style'
|
|
758
|
+
paths: Array<[KeyedSegment]>
|
|
759
|
+
style: string
|
|
760
|
+
} & {
|
|
761
|
+
editor: PortableTextSlateEditor
|
|
762
|
+
})
|
|
763
|
+
| ({
|
|
764
|
+
type: 'delete text'
|
|
765
|
+
selection: NonNullable<EditorSelection>
|
|
766
|
+
} & {
|
|
767
|
+
editor: PortableTextSlateEditor
|
|
768
|
+
})
|
|
769
|
+
| {
|
|
770
|
+
type: 'key down'
|
|
771
|
+
nativeEvent: KeyboardEvent
|
|
772
|
+
editor: PortableTextSlateEditor
|
|
773
|
+
}
|
|
774
|
+
| {
|
|
775
|
+
type: 'before insert text'
|
|
776
|
+
nativeEvent: InputEvent
|
|
777
|
+
editor: PortableTextSlateEditor
|
|
778
|
+
}
|
|
701
779
|
| PatchEvent
|
|
702
780
|
| MutationEvent_2
|
|
703
781
|
| {
|
|
@@ -780,7 +858,6 @@ export declare const editorMachine: StateMachine<
|
|
|
780
858
|
{
|
|
781
859
|
type: 'ready'
|
|
782
860
|
},
|
|
783
|
-
| BehaviorEvent
|
|
784
861
|
| ({
|
|
785
862
|
type: 'insert text'
|
|
786
863
|
text: string
|
|
@@ -793,6 +870,29 @@ export declare const editorMachine: StateMachine<
|
|
|
793
870
|
} & {
|
|
794
871
|
editor: PortableTextSlateEditor
|
|
795
872
|
})
|
|
873
|
+
| ({
|
|
874
|
+
type: 'apply block style'
|
|
875
|
+
paths: Array<[KeyedSegment]>
|
|
876
|
+
style: string
|
|
877
|
+
} & {
|
|
878
|
+
editor: PortableTextSlateEditor
|
|
879
|
+
})
|
|
880
|
+
| ({
|
|
881
|
+
type: 'delete text'
|
|
882
|
+
selection: NonNullable<EditorSelection>
|
|
883
|
+
} & {
|
|
884
|
+
editor: PortableTextSlateEditor
|
|
885
|
+
})
|
|
886
|
+
| {
|
|
887
|
+
type: 'key down'
|
|
888
|
+
nativeEvent: KeyboardEvent
|
|
889
|
+
editor: PortableTextSlateEditor
|
|
890
|
+
}
|
|
891
|
+
| {
|
|
892
|
+
type: 'before insert text'
|
|
893
|
+
nativeEvent: InputEvent
|
|
894
|
+
editor: PortableTextSlateEditor
|
|
895
|
+
}
|
|
796
896
|
| PatchEvent
|
|
797
897
|
| MutationEvent_2
|
|
798
898
|
| {
|
|
@@ -918,7 +1018,6 @@ export declare const editorMachine: StateMachine<
|
|
|
918
1018
|
type: 'unset'
|
|
919
1019
|
previousValue: Array<PortableTextBlock>
|
|
920
1020
|
},
|
|
921
|
-
| BehaviorEvent
|
|
922
1021
|
| ({
|
|
923
1022
|
type: 'insert text'
|
|
924
1023
|
text: string
|
|
@@ -931,6 +1030,29 @@ export declare const editorMachine: StateMachine<
|
|
|
931
1030
|
} & {
|
|
932
1031
|
editor: PortableTextSlateEditor
|
|
933
1032
|
})
|
|
1033
|
+
| ({
|
|
1034
|
+
type: 'apply block style'
|
|
1035
|
+
paths: Array<[KeyedSegment]>
|
|
1036
|
+
style: string
|
|
1037
|
+
} & {
|
|
1038
|
+
editor: PortableTextSlateEditor
|
|
1039
|
+
})
|
|
1040
|
+
| ({
|
|
1041
|
+
type: 'delete text'
|
|
1042
|
+
selection: NonNullable<EditorSelection>
|
|
1043
|
+
} & {
|
|
1044
|
+
editor: PortableTextSlateEditor
|
|
1045
|
+
})
|
|
1046
|
+
| {
|
|
1047
|
+
type: 'key down'
|
|
1048
|
+
nativeEvent: KeyboardEvent
|
|
1049
|
+
editor: PortableTextSlateEditor
|
|
1050
|
+
}
|
|
1051
|
+
| {
|
|
1052
|
+
type: 'before insert text'
|
|
1053
|
+
nativeEvent: InputEvent
|
|
1054
|
+
editor: PortableTextSlateEditor
|
|
1055
|
+
}
|
|
934
1056
|
| PatchEvent
|
|
935
1057
|
| MutationEvent_2
|
|
936
1058
|
| {
|
|
@@ -1056,7 +1178,6 @@ export declare const editorMachine: StateMachine<
|
|
|
1056
1178
|
type: 'value changed'
|
|
1057
1179
|
value: Array<PortableTextBlock> | undefined
|
|
1058
1180
|
},
|
|
1059
|
-
| BehaviorEvent
|
|
1060
1181
|
| ({
|
|
1061
1182
|
type: 'insert text'
|
|
1062
1183
|
text: string
|
|
@@ -1069,6 +1190,29 @@ export declare const editorMachine: StateMachine<
|
|
|
1069
1190
|
} & {
|
|
1070
1191
|
editor: PortableTextSlateEditor
|
|
1071
1192
|
})
|
|
1193
|
+
| ({
|
|
1194
|
+
type: 'apply block style'
|
|
1195
|
+
paths: Array<[KeyedSegment]>
|
|
1196
|
+
style: string
|
|
1197
|
+
} & {
|
|
1198
|
+
editor: PortableTextSlateEditor
|
|
1199
|
+
})
|
|
1200
|
+
| ({
|
|
1201
|
+
type: 'delete text'
|
|
1202
|
+
selection: NonNullable<EditorSelection>
|
|
1203
|
+
} & {
|
|
1204
|
+
editor: PortableTextSlateEditor
|
|
1205
|
+
})
|
|
1206
|
+
| {
|
|
1207
|
+
type: 'key down'
|
|
1208
|
+
nativeEvent: KeyboardEvent
|
|
1209
|
+
editor: PortableTextSlateEditor
|
|
1210
|
+
}
|
|
1211
|
+
| {
|
|
1212
|
+
type: 'before insert text'
|
|
1213
|
+
nativeEvent: InputEvent
|
|
1214
|
+
editor: PortableTextSlateEditor
|
|
1215
|
+
}
|
|
1072
1216
|
| PatchEvent
|
|
1073
1217
|
| MutationEvent_2
|
|
1074
1218
|
| {
|
|
@@ -1195,7 +1339,6 @@ export declare const editorMachine: StateMachine<
|
|
|
1195
1339
|
resolution: InvalidValueResolution | null
|
|
1196
1340
|
value: Array<PortableTextBlock> | undefined
|
|
1197
1341
|
},
|
|
1198
|
-
| BehaviorEvent
|
|
1199
1342
|
| ({
|
|
1200
1343
|
type: 'insert text'
|
|
1201
1344
|
text: string
|
|
@@ -1208,6 +1351,29 @@ export declare const editorMachine: StateMachine<
|
|
|
1208
1351
|
} & {
|
|
1209
1352
|
editor: PortableTextSlateEditor
|
|
1210
1353
|
})
|
|
1354
|
+
| ({
|
|
1355
|
+
type: 'apply block style'
|
|
1356
|
+
paths: Array<[KeyedSegment]>
|
|
1357
|
+
style: string
|
|
1358
|
+
} & {
|
|
1359
|
+
editor: PortableTextSlateEditor
|
|
1360
|
+
})
|
|
1361
|
+
| ({
|
|
1362
|
+
type: 'delete text'
|
|
1363
|
+
selection: NonNullable<EditorSelection>
|
|
1364
|
+
} & {
|
|
1365
|
+
editor: PortableTextSlateEditor
|
|
1366
|
+
})
|
|
1367
|
+
| {
|
|
1368
|
+
type: 'key down'
|
|
1369
|
+
nativeEvent: KeyboardEvent
|
|
1370
|
+
editor: PortableTextSlateEditor
|
|
1371
|
+
}
|
|
1372
|
+
| {
|
|
1373
|
+
type: 'before insert text'
|
|
1374
|
+
nativeEvent: InputEvent
|
|
1375
|
+
editor: PortableTextSlateEditor
|
|
1376
|
+
}
|
|
1211
1377
|
| PatchEvent
|
|
1212
1378
|
| MutationEvent_2
|
|
1213
1379
|
| {
|
|
@@ -1335,7 +1501,6 @@ export declare const editorMachine: StateMachine<
|
|
|
1335
1501
|
description: string
|
|
1336
1502
|
data: unknown
|
|
1337
1503
|
},
|
|
1338
|
-
| BehaviorEvent
|
|
1339
1504
|
| ({
|
|
1340
1505
|
type: 'insert text'
|
|
1341
1506
|
text: string
|
|
@@ -1348,6 +1513,29 @@ export declare const editorMachine: StateMachine<
|
|
|
1348
1513
|
} & {
|
|
1349
1514
|
editor: PortableTextSlateEditor
|
|
1350
1515
|
})
|
|
1516
|
+
| ({
|
|
1517
|
+
type: 'apply block style'
|
|
1518
|
+
paths: Array<[KeyedSegment]>
|
|
1519
|
+
style: string
|
|
1520
|
+
} & {
|
|
1521
|
+
editor: PortableTextSlateEditor
|
|
1522
|
+
})
|
|
1523
|
+
| ({
|
|
1524
|
+
type: 'delete text'
|
|
1525
|
+
selection: NonNullable<EditorSelection>
|
|
1526
|
+
} & {
|
|
1527
|
+
editor: PortableTextSlateEditor
|
|
1528
|
+
})
|
|
1529
|
+
| {
|
|
1530
|
+
type: 'key down'
|
|
1531
|
+
nativeEvent: KeyboardEvent
|
|
1532
|
+
editor: PortableTextSlateEditor
|
|
1533
|
+
}
|
|
1534
|
+
| {
|
|
1535
|
+
type: 'before insert text'
|
|
1536
|
+
nativeEvent: InputEvent
|
|
1537
|
+
editor: PortableTextSlateEditor
|
|
1538
|
+
}
|
|
1351
1539
|
| PatchEvent
|
|
1352
1540
|
| MutationEvent_2
|
|
1353
1541
|
| {
|
|
@@ -1473,7 +1661,6 @@ export declare const editorMachine: StateMachine<
|
|
|
1473
1661
|
type: 'selection'
|
|
1474
1662
|
selection: EditorSelection
|
|
1475
1663
|
},
|
|
1476
|
-
| BehaviorEvent
|
|
1477
1664
|
| ({
|
|
1478
1665
|
type: 'insert text'
|
|
1479
1666
|
text: string
|
|
@@ -1486,6 +1673,29 @@ export declare const editorMachine: StateMachine<
|
|
|
1486
1673
|
} & {
|
|
1487
1674
|
editor: PortableTextSlateEditor
|
|
1488
1675
|
})
|
|
1676
|
+
| ({
|
|
1677
|
+
type: 'apply block style'
|
|
1678
|
+
paths: Array<[KeyedSegment]>
|
|
1679
|
+
style: string
|
|
1680
|
+
} & {
|
|
1681
|
+
editor: PortableTextSlateEditor
|
|
1682
|
+
})
|
|
1683
|
+
| ({
|
|
1684
|
+
type: 'delete text'
|
|
1685
|
+
selection: NonNullable<EditorSelection>
|
|
1686
|
+
} & {
|
|
1687
|
+
editor: PortableTextSlateEditor
|
|
1688
|
+
})
|
|
1689
|
+
| {
|
|
1690
|
+
type: 'key down'
|
|
1691
|
+
nativeEvent: KeyboardEvent
|
|
1692
|
+
editor: PortableTextSlateEditor
|
|
1693
|
+
}
|
|
1694
|
+
| {
|
|
1695
|
+
type: 'before insert text'
|
|
1696
|
+
nativeEvent: InputEvent
|
|
1697
|
+
editor: PortableTextSlateEditor
|
|
1698
|
+
}
|
|
1489
1699
|
| PatchEvent
|
|
1490
1700
|
| MutationEvent_2
|
|
1491
1701
|
| {
|
|
@@ -1611,7 +1821,6 @@ export declare const editorMachine: StateMachine<
|
|
|
1611
1821
|
type: 'blur'
|
|
1612
1822
|
event: FocusEvent_2<HTMLDivElement, Element>
|
|
1613
1823
|
},
|
|
1614
|
-
| BehaviorEvent
|
|
1615
1824
|
| ({
|
|
1616
1825
|
type: 'insert text'
|
|
1617
1826
|
text: string
|
|
@@ -1624,6 +1833,29 @@ export declare const editorMachine: StateMachine<
|
|
|
1624
1833
|
} & {
|
|
1625
1834
|
editor: PortableTextSlateEditor
|
|
1626
1835
|
})
|
|
1836
|
+
| ({
|
|
1837
|
+
type: 'apply block style'
|
|
1838
|
+
paths: Array<[KeyedSegment]>
|
|
1839
|
+
style: string
|
|
1840
|
+
} & {
|
|
1841
|
+
editor: PortableTextSlateEditor
|
|
1842
|
+
})
|
|
1843
|
+
| ({
|
|
1844
|
+
type: 'delete text'
|
|
1845
|
+
selection: NonNullable<EditorSelection>
|
|
1846
|
+
} & {
|
|
1847
|
+
editor: PortableTextSlateEditor
|
|
1848
|
+
})
|
|
1849
|
+
| {
|
|
1850
|
+
type: 'key down'
|
|
1851
|
+
nativeEvent: KeyboardEvent
|
|
1852
|
+
editor: PortableTextSlateEditor
|
|
1853
|
+
}
|
|
1854
|
+
| {
|
|
1855
|
+
type: 'before insert text'
|
|
1856
|
+
nativeEvent: InputEvent
|
|
1857
|
+
editor: PortableTextSlateEditor
|
|
1858
|
+
}
|
|
1627
1859
|
| PatchEvent
|
|
1628
1860
|
| MutationEvent_2
|
|
1629
1861
|
| {
|
|
@@ -1749,7 +1981,6 @@ export declare const editorMachine: StateMachine<
|
|
|
1749
1981
|
type: 'focus'
|
|
1750
1982
|
event: FocusEvent_2<HTMLDivElement, Element>
|
|
1751
1983
|
},
|
|
1752
|
-
| BehaviorEvent
|
|
1753
1984
|
| ({
|
|
1754
1985
|
type: 'insert text'
|
|
1755
1986
|
text: string
|
|
@@ -1762,6 +1993,29 @@ export declare const editorMachine: StateMachine<
|
|
|
1762
1993
|
} & {
|
|
1763
1994
|
editor: PortableTextSlateEditor
|
|
1764
1995
|
})
|
|
1996
|
+
| ({
|
|
1997
|
+
type: 'apply block style'
|
|
1998
|
+
paths: Array<[KeyedSegment]>
|
|
1999
|
+
style: string
|
|
2000
|
+
} & {
|
|
2001
|
+
editor: PortableTextSlateEditor
|
|
2002
|
+
})
|
|
2003
|
+
| ({
|
|
2004
|
+
type: 'delete text'
|
|
2005
|
+
selection: NonNullable<EditorSelection>
|
|
2006
|
+
} & {
|
|
2007
|
+
editor: PortableTextSlateEditor
|
|
2008
|
+
})
|
|
2009
|
+
| {
|
|
2010
|
+
type: 'key down'
|
|
2011
|
+
nativeEvent: KeyboardEvent
|
|
2012
|
+
editor: PortableTextSlateEditor
|
|
2013
|
+
}
|
|
2014
|
+
| {
|
|
2015
|
+
type: 'before insert text'
|
|
2016
|
+
nativeEvent: InputEvent
|
|
2017
|
+
editor: PortableTextSlateEditor
|
|
2018
|
+
}
|
|
1765
2019
|
| PatchEvent
|
|
1766
2020
|
| MutationEvent_2
|
|
1767
2021
|
| {
|
|
@@ -1886,7 +2140,6 @@ export declare const editorMachine: StateMachine<
|
|
|
1886
2140
|
{
|
|
1887
2141
|
type: 'online'
|
|
1888
2142
|
},
|
|
1889
|
-
| BehaviorEvent
|
|
1890
2143
|
| ({
|
|
1891
2144
|
type: 'insert text'
|
|
1892
2145
|
text: string
|
|
@@ -1899,6 +2152,29 @@ export declare const editorMachine: StateMachine<
|
|
|
1899
2152
|
} & {
|
|
1900
2153
|
editor: PortableTextSlateEditor
|
|
1901
2154
|
})
|
|
2155
|
+
| ({
|
|
2156
|
+
type: 'apply block style'
|
|
2157
|
+
paths: Array<[KeyedSegment]>
|
|
2158
|
+
style: string
|
|
2159
|
+
} & {
|
|
2160
|
+
editor: PortableTextSlateEditor
|
|
2161
|
+
})
|
|
2162
|
+
| ({
|
|
2163
|
+
type: 'delete text'
|
|
2164
|
+
selection: NonNullable<EditorSelection>
|
|
2165
|
+
} & {
|
|
2166
|
+
editor: PortableTextSlateEditor
|
|
2167
|
+
})
|
|
2168
|
+
| {
|
|
2169
|
+
type: 'key down'
|
|
2170
|
+
nativeEvent: KeyboardEvent
|
|
2171
|
+
editor: PortableTextSlateEditor
|
|
2172
|
+
}
|
|
2173
|
+
| {
|
|
2174
|
+
type: 'before insert text'
|
|
2175
|
+
nativeEvent: InputEvent
|
|
2176
|
+
editor: PortableTextSlateEditor
|
|
2177
|
+
}
|
|
1902
2178
|
| PatchEvent
|
|
1903
2179
|
| MutationEvent_2
|
|
1904
2180
|
| {
|
|
@@ -2023,7 +2299,6 @@ export declare const editorMachine: StateMachine<
|
|
|
2023
2299
|
{
|
|
2024
2300
|
type: 'offline'
|
|
2025
2301
|
},
|
|
2026
|
-
| BehaviorEvent
|
|
2027
2302
|
| ({
|
|
2028
2303
|
type: 'insert text'
|
|
2029
2304
|
text: string
|
|
@@ -2036,6 +2311,29 @@ export declare const editorMachine: StateMachine<
|
|
|
2036
2311
|
} & {
|
|
2037
2312
|
editor: PortableTextSlateEditor
|
|
2038
2313
|
})
|
|
2314
|
+
| ({
|
|
2315
|
+
type: 'apply block style'
|
|
2316
|
+
paths: Array<[KeyedSegment]>
|
|
2317
|
+
style: string
|
|
2318
|
+
} & {
|
|
2319
|
+
editor: PortableTextSlateEditor
|
|
2320
|
+
})
|
|
2321
|
+
| ({
|
|
2322
|
+
type: 'delete text'
|
|
2323
|
+
selection: NonNullable<EditorSelection>
|
|
2324
|
+
} & {
|
|
2325
|
+
editor: PortableTextSlateEditor
|
|
2326
|
+
})
|
|
2327
|
+
| {
|
|
2328
|
+
type: 'key down'
|
|
2329
|
+
nativeEvent: KeyboardEvent
|
|
2330
|
+
editor: PortableTextSlateEditor
|
|
2331
|
+
}
|
|
2332
|
+
| {
|
|
2333
|
+
type: 'before insert text'
|
|
2334
|
+
nativeEvent: InputEvent
|
|
2335
|
+
editor: PortableTextSlateEditor
|
|
2336
|
+
}
|
|
2039
2337
|
| PatchEvent
|
|
2040
2338
|
| MutationEvent_2
|
|
2041
2339
|
| {
|
|
@@ -2160,7 +2458,6 @@ export declare const editorMachine: StateMachine<
|
|
|
2160
2458
|
{
|
|
2161
2459
|
type: 'loading'
|
|
2162
2460
|
},
|
|
2163
|
-
| BehaviorEvent
|
|
2164
2461
|
| ({
|
|
2165
2462
|
type: 'insert text'
|
|
2166
2463
|
text: string
|
|
@@ -2173,6 +2470,29 @@ export declare const editorMachine: StateMachine<
|
|
|
2173
2470
|
} & {
|
|
2174
2471
|
editor: PortableTextSlateEditor
|
|
2175
2472
|
})
|
|
2473
|
+
| ({
|
|
2474
|
+
type: 'apply block style'
|
|
2475
|
+
paths: Array<[KeyedSegment]>
|
|
2476
|
+
style: string
|
|
2477
|
+
} & {
|
|
2478
|
+
editor: PortableTextSlateEditor
|
|
2479
|
+
})
|
|
2480
|
+
| ({
|
|
2481
|
+
type: 'delete text'
|
|
2482
|
+
selection: NonNullable<EditorSelection>
|
|
2483
|
+
} & {
|
|
2484
|
+
editor: PortableTextSlateEditor
|
|
2485
|
+
})
|
|
2486
|
+
| {
|
|
2487
|
+
type: 'key down'
|
|
2488
|
+
nativeEvent: KeyboardEvent
|
|
2489
|
+
editor: PortableTextSlateEditor
|
|
2490
|
+
}
|
|
2491
|
+
| {
|
|
2492
|
+
type: 'before insert text'
|
|
2493
|
+
nativeEvent: InputEvent
|
|
2494
|
+
editor: PortableTextSlateEditor
|
|
2495
|
+
}
|
|
2176
2496
|
| PatchEvent
|
|
2177
2497
|
| MutationEvent_2
|
|
2178
2498
|
| {
|
|
@@ -2297,7 +2617,6 @@ export declare const editorMachine: StateMachine<
|
|
|
2297
2617
|
{
|
|
2298
2618
|
type: 'done loading'
|
|
2299
2619
|
},
|
|
2300
|
-
| BehaviorEvent
|
|
2301
2620
|
| ({
|
|
2302
2621
|
type: 'insert text'
|
|
2303
2622
|
text: string
|
|
@@ -2310,6 +2629,29 @@ export declare const editorMachine: StateMachine<
|
|
|
2310
2629
|
} & {
|
|
2311
2630
|
editor: PortableTextSlateEditor
|
|
2312
2631
|
})
|
|
2632
|
+
| ({
|
|
2633
|
+
type: 'apply block style'
|
|
2634
|
+
paths: Array<[KeyedSegment]>
|
|
2635
|
+
style: string
|
|
2636
|
+
} & {
|
|
2637
|
+
editor: PortableTextSlateEditor
|
|
2638
|
+
})
|
|
2639
|
+
| ({
|
|
2640
|
+
type: 'delete text'
|
|
2641
|
+
selection: NonNullable<EditorSelection>
|
|
2642
|
+
} & {
|
|
2643
|
+
editor: PortableTextSlateEditor
|
|
2644
|
+
})
|
|
2645
|
+
| {
|
|
2646
|
+
type: 'key down'
|
|
2647
|
+
nativeEvent: KeyboardEvent
|
|
2648
|
+
editor: PortableTextSlateEditor
|
|
2649
|
+
}
|
|
2650
|
+
| {
|
|
2651
|
+
type: 'before insert text'
|
|
2652
|
+
nativeEvent: InputEvent
|
|
2653
|
+
editor: PortableTextSlateEditor
|
|
2654
|
+
}
|
|
2313
2655
|
| PatchEvent
|
|
2314
2656
|
| MutationEvent_2
|
|
2315
2657
|
| {
|
|
@@ -2429,11 +2771,85 @@ export declare const editorMachine: StateMachine<
|
|
|
2429
2771
|
readonly 'key down': {
|
|
2430
2772
|
readonly actions: readonly ['handle behavior event']
|
|
2431
2773
|
}
|
|
2774
|
+
readonly 'before insert text': {
|
|
2775
|
+
readonly actions: readonly ['handle behavior event']
|
|
2776
|
+
}
|
|
2777
|
+
readonly 'apply block style': {
|
|
2778
|
+
readonly actions: readonly [
|
|
2779
|
+
({
|
|
2780
|
+
context,
|
|
2781
|
+
event,
|
|
2782
|
+
}: {
|
|
2783
|
+
context: {
|
|
2784
|
+
keyGenerator: () => string
|
|
2785
|
+
schema: PortableTextMemberSchemaTypes
|
|
2786
|
+
}
|
|
2787
|
+
event: {
|
|
2788
|
+
type: 'apply block style'
|
|
2789
|
+
paths: Array<[KeyedSegment]>
|
|
2790
|
+
style: string
|
|
2791
|
+
} & {
|
|
2792
|
+
editor: PortableTextSlateEditor
|
|
2793
|
+
}
|
|
2794
|
+
}) => void,
|
|
2795
|
+
]
|
|
2796
|
+
}
|
|
2797
|
+
readonly 'delete text': {
|
|
2798
|
+
readonly actions: readonly [
|
|
2799
|
+
({
|
|
2800
|
+
context,
|
|
2801
|
+
event,
|
|
2802
|
+
}: {
|
|
2803
|
+
context: {
|
|
2804
|
+
keyGenerator: () => string
|
|
2805
|
+
schema: PortableTextMemberSchemaTypes
|
|
2806
|
+
}
|
|
2807
|
+
event: {
|
|
2808
|
+
type: 'delete text'
|
|
2809
|
+
selection: NonNullable<EditorSelection>
|
|
2810
|
+
} & {
|
|
2811
|
+
editor: PortableTextSlateEditor
|
|
2812
|
+
}
|
|
2813
|
+
}) => void,
|
|
2814
|
+
]
|
|
2815
|
+
}
|
|
2432
2816
|
readonly 'insert text': {
|
|
2433
|
-
readonly actions: readonly [
|
|
2817
|
+
readonly actions: readonly [
|
|
2818
|
+
({
|
|
2819
|
+
context,
|
|
2820
|
+
event,
|
|
2821
|
+
}: {
|
|
2822
|
+
context: {
|
|
2823
|
+
keyGenerator: () => string
|
|
2824
|
+
schema: PortableTextMemberSchemaTypes
|
|
2825
|
+
}
|
|
2826
|
+
event: {
|
|
2827
|
+
type: 'insert text'
|
|
2828
|
+
text: string
|
|
2829
|
+
} & {
|
|
2830
|
+
editor: PortableTextSlateEditor
|
|
2831
|
+
}
|
|
2832
|
+
}) => void,
|
|
2833
|
+
]
|
|
2434
2834
|
}
|
|
2435
2835
|
readonly 'insert text block': {
|
|
2436
|
-
readonly actions: readonly [
|
|
2836
|
+
readonly actions: readonly [
|
|
2837
|
+
({
|
|
2838
|
+
context,
|
|
2839
|
+
event,
|
|
2840
|
+
}: {
|
|
2841
|
+
context: {
|
|
2842
|
+
keyGenerator: () => string
|
|
2843
|
+
schema: PortableTextMemberSchemaTypes
|
|
2844
|
+
}
|
|
2845
|
+
event: {
|
|
2846
|
+
type: 'insert text block'
|
|
2847
|
+
decorators: Array<string>
|
|
2848
|
+
} & {
|
|
2849
|
+
editor: PortableTextSlateEditor
|
|
2850
|
+
}
|
|
2851
|
+
}) => void,
|
|
2852
|
+
]
|
|
2437
2853
|
}
|
|
2438
2854
|
}
|
|
2439
2855
|
readonly initial: 'pristine'
|
|
@@ -2723,11 +3139,6 @@ export declare type PortableTextEditableProps = Omit<
|
|
|
2723
3139
|
* @public
|
|
2724
3140
|
*/
|
|
2725
3141
|
export declare class PortableTextEditor extends Component<PortableTextEditorProps> {
|
|
2726
|
-
/**
|
|
2727
|
-
* @internal
|
|
2728
|
-
* Don't use this API directly. It's subject to change.
|
|
2729
|
-
*/
|
|
2730
|
-
editorActor: EditorActor
|
|
2731
3142
|
/**
|
|
2732
3143
|
* An observable of all the editor changes.
|
|
2733
3144
|
*/
|
|
@@ -2740,6 +3151,7 @@ export declare class PortableTextEditor extends Component<PortableTextEditorProp
|
|
|
2740
3151
|
* The editor API (currently implemented with Slate).
|
|
2741
3152
|
*/
|
|
2742
3153
|
private editable?
|
|
3154
|
+
private editorActor
|
|
2743
3155
|
constructor(props: PortableTextEditorProps)
|
|
2744
3156
|
componentDidUpdate(prevProps: PortableTextEditorProps): void
|
|
2745
3157
|
setEditable: (editable: EditableAPI) => void
|
|
@@ -2789,9 +3201,9 @@ export declare class PortableTextEditor extends Component<PortableTextEditorProp
|
|
|
2789
3201
|
| []
|
|
2790
3202
|
| [
|
|
2791
3203
|
(
|
|
2792
|
-
| PortableTextTextBlock<PortableTextObject | PortableTextSpan>
|
|
2793
|
-
| PortableTextObject
|
|
2794
3204
|
| PortableTextSpan
|
|
3205
|
+
| PortableTextObject
|
|
3206
|
+
| PortableTextTextBlock<PortableTextSpan | PortableTextObject>
|
|
2795
3207
|
| undefined
|
|
2796
3208
|
),
|
|
2797
3209
|
Path | undefined,
|