@portabletext/editor 1.1.5 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/lib/index.d.mts +403 -0
- package/lib/index.d.ts +403 -0
- package/lib/index.esm.js +220 -105
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +213 -98
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +220 -105
- package/lib/index.mjs.map +1 -1
- package/package.json +18 -18
- package/src/editor/Editable.tsx +5 -0
- package/src/editor/PortableTextEditor.tsx +15 -6
- package/src/editor/__tests__/self-solving.test.tsx +1 -1
- package/src/editor/behavior/behavior.actions.ts +39 -0
- package/src/editor/behavior/behavior.core.ts +37 -0
- package/src/editor/behavior/behavior.types.ts +106 -0
- package/src/editor/behavior/behavior.utils.ts +34 -0
- package/src/editor/editor-machine.ts +113 -1
- package/src/editor/plugins/createWithHotKeys.ts +0 -32
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +81 -109
- package/src/index.ts +10 -1
- package/src/utils/sibling-utils.ts +55 -0
package/lib/index.d.mts
CHANGED
|
@@ -60,6 +60,66 @@ import {
|
|
|
60
60
|
Values,
|
|
61
61
|
} from 'xstate'
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* @alpha
|
|
65
|
+
*/
|
|
66
|
+
export declare type Behavior<
|
|
67
|
+
TBehaviorEventType extends BehaviorEvent['type'] = BehaviorEvent['type'],
|
|
68
|
+
TGuardResponse = true,
|
|
69
|
+
> = {
|
|
70
|
+
on: TBehaviorEventType
|
|
71
|
+
guard?: BehaviorGuard<
|
|
72
|
+
PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>,
|
|
73
|
+
TGuardResponse
|
|
74
|
+
>
|
|
75
|
+
actions: Array<RaiseBehaviorActionIntend<TBehaviorEventType, TGuardResponse>>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @alpha
|
|
80
|
+
*/
|
|
81
|
+
export declare type BehaviorActionIntend =
|
|
82
|
+
| {
|
|
83
|
+
type: 'insert text'
|
|
84
|
+
text: string
|
|
85
|
+
}
|
|
86
|
+
| {
|
|
87
|
+
type: 'insert text block'
|
|
88
|
+
decorators: Array<string>
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @alpha
|
|
93
|
+
*/
|
|
94
|
+
export declare type BehaviorContext = {
|
|
95
|
+
schema: PortableTextMemberSchemaTypes
|
|
96
|
+
value: Array<PortableTextBlock>
|
|
97
|
+
selection: NonNullable<EditorSelection>
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @alpha
|
|
102
|
+
*/
|
|
103
|
+
export declare type BehaviorEvent = {
|
|
104
|
+
type: 'key down'
|
|
105
|
+
nativeEvent: KeyboardEvent
|
|
106
|
+
editor: PortableTextSlateEditor
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @alpha
|
|
111
|
+
*/
|
|
112
|
+
export declare type BehaviorGuard<
|
|
113
|
+
TBehaviorEvent extends BehaviorEvent,
|
|
114
|
+
TGuardResponse,
|
|
115
|
+
> = ({
|
|
116
|
+
context,
|
|
117
|
+
event,
|
|
118
|
+
}: {
|
|
119
|
+
event: TBehaviorEvent
|
|
120
|
+
context: BehaviorContext
|
|
121
|
+
}) => TGuardResponse | false
|
|
122
|
+
|
|
63
123
|
/** @beta */
|
|
64
124
|
export declare interface BlockAnnotationRenderProps {
|
|
65
125
|
block: PortableTextBlock
|
|
@@ -274,9 +334,24 @@ export declare type EditorChanges = Subject<EditorChange>
|
|
|
274
334
|
*/
|
|
275
335
|
export declare const editorMachine: StateMachine<
|
|
276
336
|
{
|
|
337
|
+
behaviors: Array<Behavior>
|
|
277
338
|
keyGenerator: () => string
|
|
278
339
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
340
|
+
schema: PortableTextMemberSchemaTypes
|
|
279
341
|
},
|
|
342
|
+
| BehaviorEvent
|
|
343
|
+
| ({
|
|
344
|
+
type: 'insert text'
|
|
345
|
+
text: string
|
|
346
|
+
} & {
|
|
347
|
+
editor: PortableTextSlateEditor
|
|
348
|
+
})
|
|
349
|
+
| ({
|
|
350
|
+
type: 'insert text block'
|
|
351
|
+
decorators: Array<string>
|
|
352
|
+
} & {
|
|
353
|
+
editor: PortableTextSlateEditor
|
|
354
|
+
})
|
|
280
355
|
| PatchEvent
|
|
281
356
|
| MutationEvent_2
|
|
282
357
|
| {
|
|
@@ -285,6 +360,10 @@ export declare const editorMachine: StateMachine<
|
|
|
285
360
|
| {
|
|
286
361
|
type: 'done normalizing'
|
|
287
362
|
}
|
|
363
|
+
| {
|
|
364
|
+
type: 'update schema'
|
|
365
|
+
schema: PortableTextMemberSchemaTypes
|
|
366
|
+
}
|
|
288
367
|
| {
|
|
289
368
|
type: 'ready'
|
|
290
369
|
}
|
|
@@ -344,6 +423,18 @@ export declare const editorMachine: StateMachine<
|
|
|
344
423
|
id: string | undefined
|
|
345
424
|
},
|
|
346
425
|
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
|
+
'assign schema': {
|
|
435
|
+
type: 'assign schema'
|
|
436
|
+
params: NonReducibleUnknown
|
|
437
|
+
}
|
|
347
438
|
'emit patch event': {
|
|
348
439
|
type: 'emit patch event'
|
|
349
440
|
params: NonReducibleUnknown
|
|
@@ -364,6 +455,10 @@ export declare const editorMachine: StateMachine<
|
|
|
364
455
|
type: 'clear pending events'
|
|
365
456
|
params: NonReducibleUnknown
|
|
366
457
|
}
|
|
458
|
+
'handle behavior event': {
|
|
459
|
+
type: 'handle behavior event'
|
|
460
|
+
params: NonReducibleUnknown
|
|
461
|
+
}
|
|
367
462
|
}>,
|
|
368
463
|
never,
|
|
369
464
|
never,
|
|
@@ -373,7 +468,9 @@ export declare const editorMachine: StateMachine<
|
|
|
373
468
|
},
|
|
374
469
|
string,
|
|
375
470
|
{
|
|
471
|
+
behaviors: Array<Behavior>
|
|
376
472
|
keyGenerator: () => string
|
|
473
|
+
schema: PortableTextMemberSchemaTypes
|
|
377
474
|
},
|
|
378
475
|
NonReducibleUnknown,
|
|
379
476
|
| PatchEvent
|
|
@@ -498,14 +595,31 @@ export declare const editorMachine: StateMachine<
|
|
|
498
595
|
): ActorRefFromLogic<TLogic>
|
|
499
596
|
}
|
|
500
597
|
input: {
|
|
598
|
+
behaviors: Array<Behavior>
|
|
501
599
|
keyGenerator: () => string
|
|
600
|
+
schema: PortableTextMemberSchemaTypes
|
|
502
601
|
}
|
|
503
602
|
self: ActorRef<
|
|
504
603
|
MachineSnapshot<
|
|
505
604
|
{
|
|
605
|
+
behaviors: Array<Behavior>
|
|
506
606
|
keyGenerator: () => string
|
|
507
607
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
608
|
+
schema: PortableTextMemberSchemaTypes
|
|
508
609
|
},
|
|
610
|
+
| BehaviorEvent
|
|
611
|
+
| ({
|
|
612
|
+
type: 'insert text'
|
|
613
|
+
text: string
|
|
614
|
+
} & {
|
|
615
|
+
editor: PortableTextSlateEditor
|
|
616
|
+
})
|
|
617
|
+
| ({
|
|
618
|
+
type: 'insert text block'
|
|
619
|
+
decorators: Array<string>
|
|
620
|
+
} & {
|
|
621
|
+
editor: PortableTextSlateEditor
|
|
622
|
+
})
|
|
509
623
|
| PatchEvent
|
|
510
624
|
| MutationEvent_2
|
|
511
625
|
| {
|
|
@@ -514,6 +628,10 @@ export declare const editorMachine: StateMachine<
|
|
|
514
628
|
| {
|
|
515
629
|
type: 'done normalizing'
|
|
516
630
|
}
|
|
631
|
+
| {
|
|
632
|
+
type: 'update schema'
|
|
633
|
+
schema: PortableTextMemberSchemaTypes
|
|
634
|
+
}
|
|
517
635
|
| {
|
|
518
636
|
type: 'ready'
|
|
519
637
|
}
|
|
@@ -567,6 +685,19 @@ export declare const editorMachine: StateMachine<
|
|
|
567
685
|
any,
|
|
568
686
|
any
|
|
569
687
|
>,
|
|
688
|
+
| BehaviorEvent
|
|
689
|
+
| ({
|
|
690
|
+
type: 'insert text'
|
|
691
|
+
text: string
|
|
692
|
+
} & {
|
|
693
|
+
editor: PortableTextSlateEditor
|
|
694
|
+
})
|
|
695
|
+
| ({
|
|
696
|
+
type: 'insert text block'
|
|
697
|
+
decorators: Array<string>
|
|
698
|
+
} & {
|
|
699
|
+
editor: PortableTextSlateEditor
|
|
700
|
+
})
|
|
570
701
|
| PatchEvent
|
|
571
702
|
| MutationEvent_2
|
|
572
703
|
| {
|
|
@@ -575,6 +706,10 @@ export declare const editorMachine: StateMachine<
|
|
|
575
706
|
| {
|
|
576
707
|
type: 'done normalizing'
|
|
577
708
|
}
|
|
709
|
+
| {
|
|
710
|
+
type: 'update schema'
|
|
711
|
+
schema: PortableTextMemberSchemaTypes
|
|
712
|
+
}
|
|
578
713
|
| {
|
|
579
714
|
type: 'ready'
|
|
580
715
|
}
|
|
@@ -624,8 +759,10 @@ export declare const editorMachine: StateMachine<
|
|
|
624
759
|
AnyEventObject
|
|
625
760
|
>
|
|
626
761
|
}) => {
|
|
762
|
+
behaviors: Behavior[]
|
|
627
763
|
keyGenerator: () => string
|
|
628
764
|
pendingEvents: never[]
|
|
765
|
+
schema: PortableTextMemberSchemaTypes
|
|
629
766
|
}
|
|
630
767
|
readonly invoke: {
|
|
631
768
|
readonly id: 'networkLogic'
|
|
@@ -635,12 +772,27 @@ export declare const editorMachine: StateMachine<
|
|
|
635
772
|
readonly 'ready': {
|
|
636
773
|
readonly actions: ActionFunction<
|
|
637
774
|
{
|
|
775
|
+
behaviors: Array<Behavior>
|
|
638
776
|
keyGenerator: () => string
|
|
639
777
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
778
|
+
schema: PortableTextMemberSchemaTypes
|
|
640
779
|
},
|
|
641
780
|
{
|
|
642
781
|
type: 'ready'
|
|
643
782
|
},
|
|
783
|
+
| BehaviorEvent
|
|
784
|
+
| ({
|
|
785
|
+
type: 'insert text'
|
|
786
|
+
text: string
|
|
787
|
+
} & {
|
|
788
|
+
editor: PortableTextSlateEditor
|
|
789
|
+
})
|
|
790
|
+
| ({
|
|
791
|
+
type: 'insert text block'
|
|
792
|
+
decorators: Array<string>
|
|
793
|
+
} & {
|
|
794
|
+
editor: PortableTextSlateEditor
|
|
795
|
+
})
|
|
644
796
|
| PatchEvent
|
|
645
797
|
| MutationEvent_2
|
|
646
798
|
| {
|
|
@@ -649,6 +801,10 @@ export declare const editorMachine: StateMachine<
|
|
|
649
801
|
| {
|
|
650
802
|
type: 'done normalizing'
|
|
651
803
|
}
|
|
804
|
+
| {
|
|
805
|
+
type: 'update schema'
|
|
806
|
+
schema: PortableTextMemberSchemaTypes
|
|
807
|
+
}
|
|
652
808
|
| {
|
|
653
809
|
type: 'ready'
|
|
654
810
|
}
|
|
@@ -753,13 +909,28 @@ export declare const editorMachine: StateMachine<
|
|
|
753
909
|
readonly 'unset': {
|
|
754
910
|
readonly actions: ActionFunction<
|
|
755
911
|
{
|
|
912
|
+
behaviors: Array<Behavior>
|
|
756
913
|
keyGenerator: () => string
|
|
757
914
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
915
|
+
schema: PortableTextMemberSchemaTypes
|
|
758
916
|
},
|
|
759
917
|
{
|
|
760
918
|
type: 'unset'
|
|
761
919
|
previousValue: Array<PortableTextBlock>
|
|
762
920
|
},
|
|
921
|
+
| BehaviorEvent
|
|
922
|
+
| ({
|
|
923
|
+
type: 'insert text'
|
|
924
|
+
text: string
|
|
925
|
+
} & {
|
|
926
|
+
editor: PortableTextSlateEditor
|
|
927
|
+
})
|
|
928
|
+
| ({
|
|
929
|
+
type: 'insert text block'
|
|
930
|
+
decorators: Array<string>
|
|
931
|
+
} & {
|
|
932
|
+
editor: PortableTextSlateEditor
|
|
933
|
+
})
|
|
763
934
|
| PatchEvent
|
|
764
935
|
| MutationEvent_2
|
|
765
936
|
| {
|
|
@@ -768,6 +939,10 @@ export declare const editorMachine: StateMachine<
|
|
|
768
939
|
| {
|
|
769
940
|
type: 'done normalizing'
|
|
770
941
|
}
|
|
942
|
+
| {
|
|
943
|
+
type: 'update schema'
|
|
944
|
+
schema: PortableTextMemberSchemaTypes
|
|
945
|
+
}
|
|
771
946
|
| {
|
|
772
947
|
type: 'ready'
|
|
773
948
|
}
|
|
@@ -872,13 +1047,28 @@ export declare const editorMachine: StateMachine<
|
|
|
872
1047
|
readonly 'value changed': {
|
|
873
1048
|
readonly actions: ActionFunction<
|
|
874
1049
|
{
|
|
1050
|
+
behaviors: Array<Behavior>
|
|
875
1051
|
keyGenerator: () => string
|
|
876
1052
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
1053
|
+
schema: PortableTextMemberSchemaTypes
|
|
877
1054
|
},
|
|
878
1055
|
{
|
|
879
1056
|
type: 'value changed'
|
|
880
1057
|
value: Array<PortableTextBlock> | undefined
|
|
881
1058
|
},
|
|
1059
|
+
| BehaviorEvent
|
|
1060
|
+
| ({
|
|
1061
|
+
type: 'insert text'
|
|
1062
|
+
text: string
|
|
1063
|
+
} & {
|
|
1064
|
+
editor: PortableTextSlateEditor
|
|
1065
|
+
})
|
|
1066
|
+
| ({
|
|
1067
|
+
type: 'insert text block'
|
|
1068
|
+
decorators: Array<string>
|
|
1069
|
+
} & {
|
|
1070
|
+
editor: PortableTextSlateEditor
|
|
1071
|
+
})
|
|
882
1072
|
| PatchEvent
|
|
883
1073
|
| MutationEvent_2
|
|
884
1074
|
| {
|
|
@@ -887,6 +1077,10 @@ export declare const editorMachine: StateMachine<
|
|
|
887
1077
|
| {
|
|
888
1078
|
type: 'done normalizing'
|
|
889
1079
|
}
|
|
1080
|
+
| {
|
|
1081
|
+
type: 'update schema'
|
|
1082
|
+
schema: PortableTextMemberSchemaTypes
|
|
1083
|
+
}
|
|
890
1084
|
| {
|
|
891
1085
|
type: 'ready'
|
|
892
1086
|
}
|
|
@@ -991,14 +1185,29 @@ export declare const editorMachine: StateMachine<
|
|
|
991
1185
|
readonly 'invalid value': {
|
|
992
1186
|
readonly actions: ActionFunction<
|
|
993
1187
|
{
|
|
1188
|
+
behaviors: Array<Behavior>
|
|
994
1189
|
keyGenerator: () => string
|
|
995
1190
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
1191
|
+
schema: PortableTextMemberSchemaTypes
|
|
996
1192
|
},
|
|
997
1193
|
{
|
|
998
1194
|
type: 'invalid value'
|
|
999
1195
|
resolution: InvalidValueResolution | null
|
|
1000
1196
|
value: Array<PortableTextBlock> | undefined
|
|
1001
1197
|
},
|
|
1198
|
+
| BehaviorEvent
|
|
1199
|
+
| ({
|
|
1200
|
+
type: 'insert text'
|
|
1201
|
+
text: string
|
|
1202
|
+
} & {
|
|
1203
|
+
editor: PortableTextSlateEditor
|
|
1204
|
+
})
|
|
1205
|
+
| ({
|
|
1206
|
+
type: 'insert text block'
|
|
1207
|
+
decorators: Array<string>
|
|
1208
|
+
} & {
|
|
1209
|
+
editor: PortableTextSlateEditor
|
|
1210
|
+
})
|
|
1002
1211
|
| PatchEvent
|
|
1003
1212
|
| MutationEvent_2
|
|
1004
1213
|
| {
|
|
@@ -1007,6 +1216,10 @@ export declare const editorMachine: StateMachine<
|
|
|
1007
1216
|
| {
|
|
1008
1217
|
type: 'done normalizing'
|
|
1009
1218
|
}
|
|
1219
|
+
| {
|
|
1220
|
+
type: 'update schema'
|
|
1221
|
+
schema: PortableTextMemberSchemaTypes
|
|
1222
|
+
}
|
|
1010
1223
|
| {
|
|
1011
1224
|
type: 'ready'
|
|
1012
1225
|
}
|
|
@@ -1111,8 +1324,10 @@ export declare const editorMachine: StateMachine<
|
|
|
1111
1324
|
readonly 'error': {
|
|
1112
1325
|
readonly actions: ActionFunction<
|
|
1113
1326
|
{
|
|
1327
|
+
behaviors: Array<Behavior>
|
|
1114
1328
|
keyGenerator: () => string
|
|
1115
1329
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
1330
|
+
schema: PortableTextMemberSchemaTypes
|
|
1116
1331
|
},
|
|
1117
1332
|
{
|
|
1118
1333
|
type: 'error'
|
|
@@ -1120,6 +1335,19 @@ export declare const editorMachine: StateMachine<
|
|
|
1120
1335
|
description: string
|
|
1121
1336
|
data: unknown
|
|
1122
1337
|
},
|
|
1338
|
+
| BehaviorEvent
|
|
1339
|
+
| ({
|
|
1340
|
+
type: 'insert text'
|
|
1341
|
+
text: string
|
|
1342
|
+
} & {
|
|
1343
|
+
editor: PortableTextSlateEditor
|
|
1344
|
+
})
|
|
1345
|
+
| ({
|
|
1346
|
+
type: 'insert text block'
|
|
1347
|
+
decorators: Array<string>
|
|
1348
|
+
} & {
|
|
1349
|
+
editor: PortableTextSlateEditor
|
|
1350
|
+
})
|
|
1123
1351
|
| PatchEvent
|
|
1124
1352
|
| MutationEvent_2
|
|
1125
1353
|
| {
|
|
@@ -1128,6 +1356,10 @@ export declare const editorMachine: StateMachine<
|
|
|
1128
1356
|
| {
|
|
1129
1357
|
type: 'done normalizing'
|
|
1130
1358
|
}
|
|
1359
|
+
| {
|
|
1360
|
+
type: 'update schema'
|
|
1361
|
+
schema: PortableTextMemberSchemaTypes
|
|
1362
|
+
}
|
|
1131
1363
|
| {
|
|
1132
1364
|
type: 'ready'
|
|
1133
1365
|
}
|
|
@@ -1232,13 +1464,28 @@ export declare const editorMachine: StateMachine<
|
|
|
1232
1464
|
readonly 'selection': {
|
|
1233
1465
|
readonly actions: ActionFunction<
|
|
1234
1466
|
{
|
|
1467
|
+
behaviors: Array<Behavior>
|
|
1235
1468
|
keyGenerator: () => string
|
|
1236
1469
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
1470
|
+
schema: PortableTextMemberSchemaTypes
|
|
1237
1471
|
},
|
|
1238
1472
|
{
|
|
1239
1473
|
type: 'selection'
|
|
1240
1474
|
selection: EditorSelection
|
|
1241
1475
|
},
|
|
1476
|
+
| BehaviorEvent
|
|
1477
|
+
| ({
|
|
1478
|
+
type: 'insert text'
|
|
1479
|
+
text: string
|
|
1480
|
+
} & {
|
|
1481
|
+
editor: PortableTextSlateEditor
|
|
1482
|
+
})
|
|
1483
|
+
| ({
|
|
1484
|
+
type: 'insert text block'
|
|
1485
|
+
decorators: Array<string>
|
|
1486
|
+
} & {
|
|
1487
|
+
editor: PortableTextSlateEditor
|
|
1488
|
+
})
|
|
1242
1489
|
| PatchEvent
|
|
1243
1490
|
| MutationEvent_2
|
|
1244
1491
|
| {
|
|
@@ -1247,6 +1494,10 @@ export declare const editorMachine: StateMachine<
|
|
|
1247
1494
|
| {
|
|
1248
1495
|
type: 'done normalizing'
|
|
1249
1496
|
}
|
|
1497
|
+
| {
|
|
1498
|
+
type: 'update schema'
|
|
1499
|
+
schema: PortableTextMemberSchemaTypes
|
|
1500
|
+
}
|
|
1250
1501
|
| {
|
|
1251
1502
|
type: 'ready'
|
|
1252
1503
|
}
|
|
@@ -1351,13 +1602,28 @@ export declare const editorMachine: StateMachine<
|
|
|
1351
1602
|
readonly 'blur': {
|
|
1352
1603
|
readonly actions: ActionFunction<
|
|
1353
1604
|
{
|
|
1605
|
+
behaviors: Array<Behavior>
|
|
1354
1606
|
keyGenerator: () => string
|
|
1355
1607
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
1608
|
+
schema: PortableTextMemberSchemaTypes
|
|
1356
1609
|
},
|
|
1357
1610
|
{
|
|
1358
1611
|
type: 'blur'
|
|
1359
1612
|
event: FocusEvent_2<HTMLDivElement, Element>
|
|
1360
1613
|
},
|
|
1614
|
+
| BehaviorEvent
|
|
1615
|
+
| ({
|
|
1616
|
+
type: 'insert text'
|
|
1617
|
+
text: string
|
|
1618
|
+
} & {
|
|
1619
|
+
editor: PortableTextSlateEditor
|
|
1620
|
+
})
|
|
1621
|
+
| ({
|
|
1622
|
+
type: 'insert text block'
|
|
1623
|
+
decorators: Array<string>
|
|
1624
|
+
} & {
|
|
1625
|
+
editor: PortableTextSlateEditor
|
|
1626
|
+
})
|
|
1361
1627
|
| PatchEvent
|
|
1362
1628
|
| MutationEvent_2
|
|
1363
1629
|
| {
|
|
@@ -1366,6 +1632,10 @@ export declare const editorMachine: StateMachine<
|
|
|
1366
1632
|
| {
|
|
1367
1633
|
type: 'done normalizing'
|
|
1368
1634
|
}
|
|
1635
|
+
| {
|
|
1636
|
+
type: 'update schema'
|
|
1637
|
+
schema: PortableTextMemberSchemaTypes
|
|
1638
|
+
}
|
|
1369
1639
|
| {
|
|
1370
1640
|
type: 'ready'
|
|
1371
1641
|
}
|
|
@@ -1470,13 +1740,28 @@ export declare const editorMachine: StateMachine<
|
|
|
1470
1740
|
readonly 'focus': {
|
|
1471
1741
|
readonly actions: ActionFunction<
|
|
1472
1742
|
{
|
|
1743
|
+
behaviors: Array<Behavior>
|
|
1473
1744
|
keyGenerator: () => string
|
|
1474
1745
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
1746
|
+
schema: PortableTextMemberSchemaTypes
|
|
1475
1747
|
},
|
|
1476
1748
|
{
|
|
1477
1749
|
type: 'focus'
|
|
1478
1750
|
event: FocusEvent_2<HTMLDivElement, Element>
|
|
1479
1751
|
},
|
|
1752
|
+
| BehaviorEvent
|
|
1753
|
+
| ({
|
|
1754
|
+
type: 'insert text'
|
|
1755
|
+
text: string
|
|
1756
|
+
} & {
|
|
1757
|
+
editor: PortableTextSlateEditor
|
|
1758
|
+
})
|
|
1759
|
+
| ({
|
|
1760
|
+
type: 'insert text block'
|
|
1761
|
+
decorators: Array<string>
|
|
1762
|
+
} & {
|
|
1763
|
+
editor: PortableTextSlateEditor
|
|
1764
|
+
})
|
|
1480
1765
|
| PatchEvent
|
|
1481
1766
|
| MutationEvent_2
|
|
1482
1767
|
| {
|
|
@@ -1485,6 +1770,10 @@ export declare const editorMachine: StateMachine<
|
|
|
1485
1770
|
| {
|
|
1486
1771
|
type: 'done normalizing'
|
|
1487
1772
|
}
|
|
1773
|
+
| {
|
|
1774
|
+
type: 'update schema'
|
|
1775
|
+
schema: PortableTextMemberSchemaTypes
|
|
1776
|
+
}
|
|
1488
1777
|
| {
|
|
1489
1778
|
type: 'ready'
|
|
1490
1779
|
}
|
|
@@ -1589,12 +1878,27 @@ export declare const editorMachine: StateMachine<
|
|
|
1589
1878
|
readonly 'online': {
|
|
1590
1879
|
readonly actions: ActionFunction<
|
|
1591
1880
|
{
|
|
1881
|
+
behaviors: Array<Behavior>
|
|
1592
1882
|
keyGenerator: () => string
|
|
1593
1883
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
1884
|
+
schema: PortableTextMemberSchemaTypes
|
|
1594
1885
|
},
|
|
1595
1886
|
{
|
|
1596
1887
|
type: 'online'
|
|
1597
1888
|
},
|
|
1889
|
+
| BehaviorEvent
|
|
1890
|
+
| ({
|
|
1891
|
+
type: 'insert text'
|
|
1892
|
+
text: string
|
|
1893
|
+
} & {
|
|
1894
|
+
editor: PortableTextSlateEditor
|
|
1895
|
+
})
|
|
1896
|
+
| ({
|
|
1897
|
+
type: 'insert text block'
|
|
1898
|
+
decorators: Array<string>
|
|
1899
|
+
} & {
|
|
1900
|
+
editor: PortableTextSlateEditor
|
|
1901
|
+
})
|
|
1598
1902
|
| PatchEvent
|
|
1599
1903
|
| MutationEvent_2
|
|
1600
1904
|
| {
|
|
@@ -1603,6 +1907,10 @@ export declare const editorMachine: StateMachine<
|
|
|
1603
1907
|
| {
|
|
1604
1908
|
type: 'done normalizing'
|
|
1605
1909
|
}
|
|
1910
|
+
| {
|
|
1911
|
+
type: 'update schema'
|
|
1912
|
+
schema: PortableTextMemberSchemaTypes
|
|
1913
|
+
}
|
|
1606
1914
|
| {
|
|
1607
1915
|
type: 'ready'
|
|
1608
1916
|
}
|
|
@@ -1707,12 +2015,27 @@ export declare const editorMachine: StateMachine<
|
|
|
1707
2015
|
readonly 'offline': {
|
|
1708
2016
|
readonly actions: ActionFunction<
|
|
1709
2017
|
{
|
|
2018
|
+
behaviors: Array<Behavior>
|
|
1710
2019
|
keyGenerator: () => string
|
|
1711
2020
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
2021
|
+
schema: PortableTextMemberSchemaTypes
|
|
1712
2022
|
},
|
|
1713
2023
|
{
|
|
1714
2024
|
type: 'offline'
|
|
1715
2025
|
},
|
|
2026
|
+
| BehaviorEvent
|
|
2027
|
+
| ({
|
|
2028
|
+
type: 'insert text'
|
|
2029
|
+
text: string
|
|
2030
|
+
} & {
|
|
2031
|
+
editor: PortableTextSlateEditor
|
|
2032
|
+
})
|
|
2033
|
+
| ({
|
|
2034
|
+
type: 'insert text block'
|
|
2035
|
+
decorators: Array<string>
|
|
2036
|
+
} & {
|
|
2037
|
+
editor: PortableTextSlateEditor
|
|
2038
|
+
})
|
|
1716
2039
|
| PatchEvent
|
|
1717
2040
|
| MutationEvent_2
|
|
1718
2041
|
| {
|
|
@@ -1721,6 +2044,10 @@ export declare const editorMachine: StateMachine<
|
|
|
1721
2044
|
| {
|
|
1722
2045
|
type: 'done normalizing'
|
|
1723
2046
|
}
|
|
2047
|
+
| {
|
|
2048
|
+
type: 'update schema'
|
|
2049
|
+
schema: PortableTextMemberSchemaTypes
|
|
2050
|
+
}
|
|
1724
2051
|
| {
|
|
1725
2052
|
type: 'ready'
|
|
1726
2053
|
}
|
|
@@ -1825,12 +2152,27 @@ export declare const editorMachine: StateMachine<
|
|
|
1825
2152
|
readonly 'loading': {
|
|
1826
2153
|
readonly actions: ActionFunction<
|
|
1827
2154
|
{
|
|
2155
|
+
behaviors: Array<Behavior>
|
|
1828
2156
|
keyGenerator: () => string
|
|
1829
2157
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
2158
|
+
schema: PortableTextMemberSchemaTypes
|
|
1830
2159
|
},
|
|
1831
2160
|
{
|
|
1832
2161
|
type: 'loading'
|
|
1833
2162
|
},
|
|
2163
|
+
| BehaviorEvent
|
|
2164
|
+
| ({
|
|
2165
|
+
type: 'insert text'
|
|
2166
|
+
text: string
|
|
2167
|
+
} & {
|
|
2168
|
+
editor: PortableTextSlateEditor
|
|
2169
|
+
})
|
|
2170
|
+
| ({
|
|
2171
|
+
type: 'insert text block'
|
|
2172
|
+
decorators: Array<string>
|
|
2173
|
+
} & {
|
|
2174
|
+
editor: PortableTextSlateEditor
|
|
2175
|
+
})
|
|
1834
2176
|
| PatchEvent
|
|
1835
2177
|
| MutationEvent_2
|
|
1836
2178
|
| {
|
|
@@ -1839,6 +2181,10 @@ export declare const editorMachine: StateMachine<
|
|
|
1839
2181
|
| {
|
|
1840
2182
|
type: 'done normalizing'
|
|
1841
2183
|
}
|
|
2184
|
+
| {
|
|
2185
|
+
type: 'update schema'
|
|
2186
|
+
schema: PortableTextMemberSchemaTypes
|
|
2187
|
+
}
|
|
1842
2188
|
| {
|
|
1843
2189
|
type: 'ready'
|
|
1844
2190
|
}
|
|
@@ -1943,12 +2289,27 @@ export declare const editorMachine: StateMachine<
|
|
|
1943
2289
|
readonly 'done loading': {
|
|
1944
2290
|
readonly actions: ActionFunction<
|
|
1945
2291
|
{
|
|
2292
|
+
behaviors: Array<Behavior>
|
|
1946
2293
|
keyGenerator: () => string
|
|
1947
2294
|
pendingEvents: Array<PatchEvent | MutationEvent_2>
|
|
2295
|
+
schema: PortableTextMemberSchemaTypes
|
|
1948
2296
|
},
|
|
1949
2297
|
{
|
|
1950
2298
|
type: 'done loading'
|
|
1951
2299
|
},
|
|
2300
|
+
| BehaviorEvent
|
|
2301
|
+
| ({
|
|
2302
|
+
type: 'insert text'
|
|
2303
|
+
text: string
|
|
2304
|
+
} & {
|
|
2305
|
+
editor: PortableTextSlateEditor
|
|
2306
|
+
})
|
|
2307
|
+
| ({
|
|
2308
|
+
type: 'insert text block'
|
|
2309
|
+
decorators: Array<string>
|
|
2310
|
+
} & {
|
|
2311
|
+
editor: PortableTextSlateEditor
|
|
2312
|
+
})
|
|
1952
2313
|
| PatchEvent
|
|
1953
2314
|
| MutationEvent_2
|
|
1954
2315
|
| {
|
|
@@ -1957,6 +2318,10 @@ export declare const editorMachine: StateMachine<
|
|
|
1957
2318
|
| {
|
|
1958
2319
|
type: 'done normalizing'
|
|
1959
2320
|
}
|
|
2321
|
+
| {
|
|
2322
|
+
type: 'update schema'
|
|
2323
|
+
schema: PortableTextMemberSchemaTypes
|
|
2324
|
+
}
|
|
1960
2325
|
| {
|
|
1961
2326
|
type: 'ready'
|
|
1962
2327
|
}
|
|
@@ -2058,6 +2423,18 @@ export declare const editorMachine: StateMachine<
|
|
|
2058
2423
|
}
|
|
2059
2424
|
>
|
|
2060
2425
|
}
|
|
2426
|
+
readonly 'update schema': {
|
|
2427
|
+
readonly actions: 'assign schema'
|
|
2428
|
+
}
|
|
2429
|
+
readonly 'key down': {
|
|
2430
|
+
readonly actions: readonly ['handle behavior event']
|
|
2431
|
+
}
|
|
2432
|
+
readonly 'insert text': {
|
|
2433
|
+
readonly actions: readonly ['apply:insert text']
|
|
2434
|
+
}
|
|
2435
|
+
readonly 'insert text block': {
|
|
2436
|
+
readonly actions: readonly ['apply:insert text block']
|
|
2437
|
+
}
|
|
2061
2438
|
}
|
|
2062
2439
|
readonly initial: 'pristine'
|
|
2063
2440
|
readonly states: {
|
|
@@ -2299,6 +2676,15 @@ export declare type PatchObservable = Observable<{
|
|
|
2299
2676
|
snapshot: PortableTextBlock[] | undefined
|
|
2300
2677
|
}>
|
|
2301
2678
|
|
|
2679
|
+
/**
|
|
2680
|
+
* @alpha
|
|
2681
|
+
*/
|
|
2682
|
+
export declare type PickFromUnion<
|
|
2683
|
+
TUnion,
|
|
2684
|
+
TTagKey extends keyof TUnion,
|
|
2685
|
+
TPickedTags extends TUnion[TTagKey],
|
|
2686
|
+
> = TUnion extends Record<TTagKey, TPickedTags> ? TUnion : never
|
|
2687
|
+
|
|
2302
2688
|
/**
|
|
2303
2689
|
* @public
|
|
2304
2690
|
*/
|
|
@@ -2645,6 +3031,23 @@ export declare interface PortableTextSlateEditor extends ReactEditor {
|
|
|
2645
3031
|
redo: () => void
|
|
2646
3032
|
}
|
|
2647
3033
|
|
|
3034
|
+
/**
|
|
3035
|
+
* @alpha
|
|
3036
|
+
*/
|
|
3037
|
+
export declare type RaiseBehaviorActionIntend<
|
|
3038
|
+
TBehaviorEventType extends BehaviorEvent['type'] = BehaviorEvent['type'],
|
|
3039
|
+
TGuardResponse = true,
|
|
3040
|
+
> = (
|
|
3041
|
+
{
|
|
3042
|
+
context,
|
|
3043
|
+
event,
|
|
3044
|
+
}: {
|
|
3045
|
+
context: BehaviorContext
|
|
3046
|
+
event: PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>
|
|
3047
|
+
},
|
|
3048
|
+
guardResponse: TGuardResponse,
|
|
3049
|
+
) => BehaviorActionIntend | void
|
|
3050
|
+
|
|
2648
3051
|
/**
|
|
2649
3052
|
* A range decoration is a UI affordance that wraps a given selection range in the editor
|
|
2650
3053
|
* with a custom component. This can be used to highlight search results,
|