@portabletext/editor 1.45.3 → 1.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks-cjs/behavior.core.cjs +20 -0
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/behavior.markdown.cjs +25 -25
- package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +93 -59
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +20 -0
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/behavior.markdown.js +26 -26
- package/lib/_chunks-es/behavior.markdown.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +93 -59
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +1 -1
- package/lib/behaviors/index.cjs +37 -53
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +52 -37
- package/lib/behaviors/index.d.ts +52 -37
- package/lib/behaviors/index.js +38 -54
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.d.cts +33 -37
- package/lib/index.d.ts +33 -37
- package/lib/plugins/index.cjs +23 -29
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +33 -37
- package/lib/plugins/index.d.ts +33 -37
- package/lib/plugins/index.js +24 -30
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.d.cts +33 -37
- package/lib/selectors/index.d.ts +33 -37
- package/lib/utils/index.d.cts +33 -37
- package/lib/utils/index.d.ts +33 -37
- package/package.json +1 -1
- package/src/behaviors/behavior.decorator-pair.ts +16 -19
- package/src/behaviors/behavior.emoji-picker.ts +26 -45
- package/src/behaviors/behavior.links.ts +5 -4
- package/src/behaviors/behavior.markdown.ts +37 -34
- package/src/behaviors/behavior.perform-event.ts +67 -18
- package/src/behaviors/behavior.types.action.ts +39 -13
- package/src/behaviors/behavior.types.guard.ts +1 -6
- package/src/behaviors/index.ts +3 -0
- package/src/editor/components/Synchronizer.tsx +6 -3
- package/src/editor/create-editor.ts +1 -1
- package/src/editor/editor-machine.ts +8 -6
- package/src/plugins/plugin.decorator-shortcut.ts +6 -8
- package/src/plugins/plugin.one-line.tsx +4 -4
package/lib/index.d.cts
CHANGED
|
@@ -301,7 +301,13 @@ declare type Behavior<
|
|
|
301
301
|
* @beta
|
|
302
302
|
*/
|
|
303
303
|
declare type BehaviorAction =
|
|
304
|
-
|
|
|
304
|
+
| {
|
|
305
|
+
type: 'execute'
|
|
306
|
+
event:
|
|
307
|
+
| AbstractBehaviorEvent
|
|
308
|
+
| SyntheticBehaviorEvent
|
|
309
|
+
| CustomBehaviorEvent
|
|
310
|
+
}
|
|
305
311
|
| {
|
|
306
312
|
type: 'raise'
|
|
307
313
|
event:
|
|
@@ -322,11 +328,6 @@ declare type BehaviorAction =
|
|
|
322
328
|
*/
|
|
323
329
|
declare type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (
|
|
324
330
|
payload: {
|
|
325
|
-
/**
|
|
326
|
-
* @deprecated
|
|
327
|
-
* Use `snapshot` instead
|
|
328
|
-
*/
|
|
329
|
-
context: EditorContext
|
|
330
331
|
snapshot: EditorSnapshot
|
|
331
332
|
event: TBehaviorEvent
|
|
332
333
|
},
|
|
@@ -352,11 +353,6 @@ declare type BehaviorEventTypeNamespace =
|
|
|
352
353
|
* @beta
|
|
353
354
|
*/
|
|
354
355
|
declare type BehaviorGuard<TBehaviorEvent, TGuardResponse> = (payload: {
|
|
355
|
-
/**
|
|
356
|
-
* @deprecated
|
|
357
|
-
* Use `snapshot` instead
|
|
358
|
-
*/
|
|
359
|
-
context: EditorContext
|
|
360
356
|
snapshot: EditorSnapshot
|
|
361
357
|
event: TBehaviorEvent
|
|
362
358
|
}) => TGuardResponse | false
|
|
@@ -894,7 +890,7 @@ declare const editorMachine: StateMachine<
|
|
|
894
890
|
initialReadOnly: boolean
|
|
895
891
|
maxBlocks: number | undefined
|
|
896
892
|
selection: EditorSelection
|
|
897
|
-
|
|
893
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
898
894
|
internalDrag?: {
|
|
899
895
|
ghost?: HTMLElement
|
|
900
896
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -1101,7 +1097,7 @@ declare const editorMachine: StateMachine<
|
|
|
1101
1097
|
maxBlocks?: number
|
|
1102
1098
|
readOnly?: boolean
|
|
1103
1099
|
schema: EditorSchema
|
|
1104
|
-
|
|
1100
|
+
initialValue?: Array<PortableTextBlock>
|
|
1105
1101
|
},
|
|
1106
1102
|
NonReducibleUnknown,
|
|
1107
1103
|
| PatchEvent
|
|
@@ -1186,7 +1182,7 @@ declare const editorMachine: StateMachine<
|
|
|
1186
1182
|
maxBlocks?: number
|
|
1187
1183
|
readOnly?: boolean
|
|
1188
1184
|
schema: EditorSchema
|
|
1189
|
-
|
|
1185
|
+
initialValue?: Array<PortableTextBlock>
|
|
1190
1186
|
}
|
|
1191
1187
|
self: ActorRef<
|
|
1192
1188
|
MachineSnapshot<
|
|
@@ -1199,7 +1195,7 @@ declare const editorMachine: StateMachine<
|
|
|
1199
1195
|
initialReadOnly: boolean
|
|
1200
1196
|
maxBlocks: number | undefined
|
|
1201
1197
|
selection: EditorSelection
|
|
1202
|
-
|
|
1198
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
1203
1199
|
internalDrag?: {
|
|
1204
1200
|
ghost?: HTMLElement
|
|
1205
1201
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -1463,7 +1459,7 @@ declare const editorMachine: StateMachine<
|
|
|
1463
1459
|
selection: null
|
|
1464
1460
|
initialReadOnly: boolean
|
|
1465
1461
|
maxBlocks: number | undefined
|
|
1466
|
-
|
|
1462
|
+
incomingValue: PortableTextBlock[] | undefined
|
|
1467
1463
|
}
|
|
1468
1464
|
readonly on: {
|
|
1469
1465
|
readonly 'notify.blurred': {
|
|
@@ -1477,7 +1473,7 @@ declare const editorMachine: StateMachine<
|
|
|
1477
1473
|
initialReadOnly: boolean
|
|
1478
1474
|
maxBlocks: number | undefined
|
|
1479
1475
|
selection: EditorSelection
|
|
1480
|
-
|
|
1476
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
1481
1477
|
internalDrag?: {
|
|
1482
1478
|
ghost?: HTMLElement
|
|
1483
1479
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -1672,7 +1668,7 @@ declare const editorMachine: StateMachine<
|
|
|
1672
1668
|
initialReadOnly: boolean
|
|
1673
1669
|
maxBlocks: number | undefined
|
|
1674
1670
|
selection: EditorSelection
|
|
1675
|
-
|
|
1671
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
1676
1672
|
internalDrag?: {
|
|
1677
1673
|
ghost?: HTMLElement
|
|
1678
1674
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -1866,7 +1862,7 @@ declare const editorMachine: StateMachine<
|
|
|
1866
1862
|
initialReadOnly: boolean
|
|
1867
1863
|
maxBlocks: number | undefined
|
|
1868
1864
|
selection: EditorSelection
|
|
1869
|
-
|
|
1865
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
1870
1866
|
internalDrag?: {
|
|
1871
1867
|
ghost?: HTMLElement
|
|
1872
1868
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -2063,7 +2059,7 @@ declare const editorMachine: StateMachine<
|
|
|
2063
2059
|
initialReadOnly: boolean
|
|
2064
2060
|
maxBlocks: number | undefined
|
|
2065
2061
|
selection: EditorSelection
|
|
2066
|
-
|
|
2062
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
2067
2063
|
internalDrag?: {
|
|
2068
2064
|
ghost?: HTMLElement
|
|
2069
2065
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -2259,7 +2255,7 @@ declare const editorMachine: StateMachine<
|
|
|
2259
2255
|
initialReadOnly: boolean
|
|
2260
2256
|
maxBlocks: number | undefined
|
|
2261
2257
|
selection: EditorSelection
|
|
2262
|
-
|
|
2258
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
2263
2259
|
internalDrag?: {
|
|
2264
2260
|
ghost?: HTMLElement
|
|
2265
2261
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -2455,7 +2451,7 @@ declare const editorMachine: StateMachine<
|
|
|
2455
2451
|
initialReadOnly: boolean
|
|
2456
2452
|
maxBlocks: number | undefined
|
|
2457
2453
|
selection: EditorSelection
|
|
2458
|
-
|
|
2454
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
2459
2455
|
internalDrag?: {
|
|
2460
2456
|
ghost?: HTMLElement
|
|
2461
2457
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -2602,7 +2598,7 @@ declare const editorMachine: StateMachine<
|
|
|
2602
2598
|
initialReadOnly: boolean
|
|
2603
2599
|
maxBlocks: number | undefined
|
|
2604
2600
|
selection: EditorSelection
|
|
2605
|
-
|
|
2601
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
2606
2602
|
internalDrag?: {
|
|
2607
2603
|
ghost?: HTMLElement
|
|
2608
2604
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -2798,7 +2794,7 @@ declare const editorMachine: StateMachine<
|
|
|
2798
2794
|
initialReadOnly: boolean
|
|
2799
2795
|
maxBlocks: number | undefined
|
|
2800
2796
|
selection: EditorSelection
|
|
2801
|
-
|
|
2797
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
2802
2798
|
internalDrag?: {
|
|
2803
2799
|
ghost?: HTMLElement
|
|
2804
2800
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -2993,7 +2989,7 @@ declare const editorMachine: StateMachine<
|
|
|
2993
2989
|
initialReadOnly: boolean
|
|
2994
2990
|
maxBlocks: number | undefined
|
|
2995
2991
|
selection: EditorSelection
|
|
2996
|
-
|
|
2992
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
2997
2993
|
internalDrag?: {
|
|
2998
2994
|
ghost?: HTMLElement
|
|
2999
2995
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -3187,7 +3183,7 @@ declare const editorMachine: StateMachine<
|
|
|
3187
3183
|
initialReadOnly: boolean
|
|
3188
3184
|
maxBlocks: number | undefined
|
|
3189
3185
|
selection: EditorSelection
|
|
3190
|
-
|
|
3186
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
3191
3187
|
internalDrag?: {
|
|
3192
3188
|
ghost?: HTMLElement
|
|
3193
3189
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -3388,7 +3384,7 @@ declare const editorMachine: StateMachine<
|
|
|
3388
3384
|
initialReadOnly: boolean
|
|
3389
3385
|
maxBlocks: number | undefined
|
|
3390
3386
|
selection: EditorSelection
|
|
3391
|
-
|
|
3387
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
3392
3388
|
internalDrag?: {
|
|
3393
3389
|
ghost?: HTMLElement
|
|
3394
3390
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -3583,7 +3579,7 @@ declare const editorMachine: StateMachine<
|
|
|
3583
3579
|
initialReadOnly: boolean
|
|
3584
3580
|
maxBlocks: number | undefined
|
|
3585
3581
|
selection: EditorSelection
|
|
3586
|
-
|
|
3582
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
3587
3583
|
internalDrag?: {
|
|
3588
3584
|
ghost?: HTMLElement
|
|
3589
3585
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -3735,7 +3731,7 @@ declare const editorMachine: StateMachine<
|
|
|
3735
3731
|
initialReadOnly: boolean
|
|
3736
3732
|
maxBlocks: number | undefined
|
|
3737
3733
|
selection: EditorSelection
|
|
3738
|
-
|
|
3734
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
3739
3735
|
internalDrag?: {
|
|
3740
3736
|
ghost?: HTMLElement
|
|
3741
3737
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -3884,7 +3880,7 @@ declare const editorMachine: StateMachine<
|
|
|
3884
3880
|
initialReadOnly: boolean
|
|
3885
3881
|
maxBlocks: number | undefined
|
|
3886
3882
|
selection: EditorSelection
|
|
3887
|
-
|
|
3883
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
3888
3884
|
internalDrag?: {
|
|
3889
3885
|
ghost?: HTMLElement
|
|
3890
3886
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4045,7 +4041,7 @@ declare const editorMachine: StateMachine<
|
|
|
4045
4041
|
initialReadOnly: boolean
|
|
4046
4042
|
maxBlocks: number | undefined
|
|
4047
4043
|
selection: EditorSelection
|
|
4048
|
-
|
|
4044
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4049
4045
|
internalDrag?: {
|
|
4050
4046
|
ghost?: HTMLElement
|
|
4051
4047
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4083,7 +4079,7 @@ declare const editorMachine: StateMachine<
|
|
|
4083
4079
|
initialReadOnly: boolean
|
|
4084
4080
|
maxBlocks: number | undefined
|
|
4085
4081
|
selection: EditorSelection
|
|
4086
|
-
|
|
4082
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4087
4083
|
internalDrag?: {
|
|
4088
4084
|
ghost?: HTMLElement
|
|
4089
4085
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4115,7 +4111,7 @@ declare const editorMachine: StateMachine<
|
|
|
4115
4111
|
initialReadOnly: boolean
|
|
4116
4112
|
maxBlocks: number | undefined
|
|
4117
4113
|
selection: EditorSelection
|
|
4118
|
-
|
|
4114
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4119
4115
|
internalDrag?: {
|
|
4120
4116
|
ghost?: HTMLElement
|
|
4121
4117
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4148,7 +4144,7 @@ declare const editorMachine: StateMachine<
|
|
|
4148
4144
|
initialReadOnly: boolean
|
|
4149
4145
|
maxBlocks: number | undefined
|
|
4150
4146
|
selection: EditorSelection
|
|
4151
|
-
|
|
4147
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4152
4148
|
internalDrag?: {
|
|
4153
4149
|
ghost?: HTMLElement
|
|
4154
4150
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4184,7 +4180,7 @@ declare const editorMachine: StateMachine<
|
|
|
4184
4180
|
initialReadOnly: boolean
|
|
4185
4181
|
maxBlocks: number | undefined
|
|
4186
4182
|
selection: EditorSelection
|
|
4187
|
-
|
|
4183
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4188
4184
|
internalDrag?: {
|
|
4189
4185
|
ghost?: HTMLElement
|
|
4190
4186
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4341,7 +4337,7 @@ declare const editorMachine: StateMachine<
|
|
|
4341
4337
|
initialReadOnly: boolean
|
|
4342
4338
|
maxBlocks: number | undefined
|
|
4343
4339
|
selection: EditorSelection
|
|
4344
|
-
|
|
4340
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4345
4341
|
internalDrag?: {
|
|
4346
4342
|
ghost?: HTMLElement
|
|
4347
4343
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4598,7 +4594,7 @@ declare const editorMachine: StateMachine<
|
|
|
4598
4594
|
initialReadOnly: boolean
|
|
4599
4595
|
maxBlocks: number | undefined
|
|
4600
4596
|
selection: EditorSelection
|
|
4601
|
-
|
|
4597
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4602
4598
|
internalDrag?: {
|
|
4603
4599
|
ghost?: HTMLElement
|
|
4604
4600
|
origin: Pick<EventPosition, 'selection'>
|
package/lib/index.d.ts
CHANGED
|
@@ -301,7 +301,13 @@ declare type Behavior<
|
|
|
301
301
|
* @beta
|
|
302
302
|
*/
|
|
303
303
|
declare type BehaviorAction =
|
|
304
|
-
|
|
|
304
|
+
| {
|
|
305
|
+
type: 'execute'
|
|
306
|
+
event:
|
|
307
|
+
| AbstractBehaviorEvent
|
|
308
|
+
| SyntheticBehaviorEvent
|
|
309
|
+
| CustomBehaviorEvent
|
|
310
|
+
}
|
|
305
311
|
| {
|
|
306
312
|
type: 'raise'
|
|
307
313
|
event:
|
|
@@ -322,11 +328,6 @@ declare type BehaviorAction =
|
|
|
322
328
|
*/
|
|
323
329
|
declare type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (
|
|
324
330
|
payload: {
|
|
325
|
-
/**
|
|
326
|
-
* @deprecated
|
|
327
|
-
* Use `snapshot` instead
|
|
328
|
-
*/
|
|
329
|
-
context: EditorContext
|
|
330
331
|
snapshot: EditorSnapshot
|
|
331
332
|
event: TBehaviorEvent
|
|
332
333
|
},
|
|
@@ -352,11 +353,6 @@ declare type BehaviorEventTypeNamespace =
|
|
|
352
353
|
* @beta
|
|
353
354
|
*/
|
|
354
355
|
declare type BehaviorGuard<TBehaviorEvent, TGuardResponse> = (payload: {
|
|
355
|
-
/**
|
|
356
|
-
* @deprecated
|
|
357
|
-
* Use `snapshot` instead
|
|
358
|
-
*/
|
|
359
|
-
context: EditorContext
|
|
360
356
|
snapshot: EditorSnapshot
|
|
361
357
|
event: TBehaviorEvent
|
|
362
358
|
}) => TGuardResponse | false
|
|
@@ -894,7 +890,7 @@ declare const editorMachine: StateMachine<
|
|
|
894
890
|
initialReadOnly: boolean
|
|
895
891
|
maxBlocks: number | undefined
|
|
896
892
|
selection: EditorSelection
|
|
897
|
-
|
|
893
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
898
894
|
internalDrag?: {
|
|
899
895
|
ghost?: HTMLElement
|
|
900
896
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -1101,7 +1097,7 @@ declare const editorMachine: StateMachine<
|
|
|
1101
1097
|
maxBlocks?: number
|
|
1102
1098
|
readOnly?: boolean
|
|
1103
1099
|
schema: EditorSchema
|
|
1104
|
-
|
|
1100
|
+
initialValue?: Array<PortableTextBlock>
|
|
1105
1101
|
},
|
|
1106
1102
|
NonReducibleUnknown,
|
|
1107
1103
|
| PatchEvent
|
|
@@ -1186,7 +1182,7 @@ declare const editorMachine: StateMachine<
|
|
|
1186
1182
|
maxBlocks?: number
|
|
1187
1183
|
readOnly?: boolean
|
|
1188
1184
|
schema: EditorSchema
|
|
1189
|
-
|
|
1185
|
+
initialValue?: Array<PortableTextBlock>
|
|
1190
1186
|
}
|
|
1191
1187
|
self: ActorRef<
|
|
1192
1188
|
MachineSnapshot<
|
|
@@ -1199,7 +1195,7 @@ declare const editorMachine: StateMachine<
|
|
|
1199
1195
|
initialReadOnly: boolean
|
|
1200
1196
|
maxBlocks: number | undefined
|
|
1201
1197
|
selection: EditorSelection
|
|
1202
|
-
|
|
1198
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
1203
1199
|
internalDrag?: {
|
|
1204
1200
|
ghost?: HTMLElement
|
|
1205
1201
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -1463,7 +1459,7 @@ declare const editorMachine: StateMachine<
|
|
|
1463
1459
|
selection: null
|
|
1464
1460
|
initialReadOnly: boolean
|
|
1465
1461
|
maxBlocks: number | undefined
|
|
1466
|
-
|
|
1462
|
+
incomingValue: PortableTextBlock[] | undefined
|
|
1467
1463
|
}
|
|
1468
1464
|
readonly on: {
|
|
1469
1465
|
readonly 'notify.blurred': {
|
|
@@ -1477,7 +1473,7 @@ declare const editorMachine: StateMachine<
|
|
|
1477
1473
|
initialReadOnly: boolean
|
|
1478
1474
|
maxBlocks: number | undefined
|
|
1479
1475
|
selection: EditorSelection
|
|
1480
|
-
|
|
1476
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
1481
1477
|
internalDrag?: {
|
|
1482
1478
|
ghost?: HTMLElement
|
|
1483
1479
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -1672,7 +1668,7 @@ declare const editorMachine: StateMachine<
|
|
|
1672
1668
|
initialReadOnly: boolean
|
|
1673
1669
|
maxBlocks: number | undefined
|
|
1674
1670
|
selection: EditorSelection
|
|
1675
|
-
|
|
1671
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
1676
1672
|
internalDrag?: {
|
|
1677
1673
|
ghost?: HTMLElement
|
|
1678
1674
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -1866,7 +1862,7 @@ declare const editorMachine: StateMachine<
|
|
|
1866
1862
|
initialReadOnly: boolean
|
|
1867
1863
|
maxBlocks: number | undefined
|
|
1868
1864
|
selection: EditorSelection
|
|
1869
|
-
|
|
1865
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
1870
1866
|
internalDrag?: {
|
|
1871
1867
|
ghost?: HTMLElement
|
|
1872
1868
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -2063,7 +2059,7 @@ declare const editorMachine: StateMachine<
|
|
|
2063
2059
|
initialReadOnly: boolean
|
|
2064
2060
|
maxBlocks: number | undefined
|
|
2065
2061
|
selection: EditorSelection
|
|
2066
|
-
|
|
2062
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
2067
2063
|
internalDrag?: {
|
|
2068
2064
|
ghost?: HTMLElement
|
|
2069
2065
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -2259,7 +2255,7 @@ declare const editorMachine: StateMachine<
|
|
|
2259
2255
|
initialReadOnly: boolean
|
|
2260
2256
|
maxBlocks: number | undefined
|
|
2261
2257
|
selection: EditorSelection
|
|
2262
|
-
|
|
2258
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
2263
2259
|
internalDrag?: {
|
|
2264
2260
|
ghost?: HTMLElement
|
|
2265
2261
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -2455,7 +2451,7 @@ declare const editorMachine: StateMachine<
|
|
|
2455
2451
|
initialReadOnly: boolean
|
|
2456
2452
|
maxBlocks: number | undefined
|
|
2457
2453
|
selection: EditorSelection
|
|
2458
|
-
|
|
2454
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
2459
2455
|
internalDrag?: {
|
|
2460
2456
|
ghost?: HTMLElement
|
|
2461
2457
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -2602,7 +2598,7 @@ declare const editorMachine: StateMachine<
|
|
|
2602
2598
|
initialReadOnly: boolean
|
|
2603
2599
|
maxBlocks: number | undefined
|
|
2604
2600
|
selection: EditorSelection
|
|
2605
|
-
|
|
2601
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
2606
2602
|
internalDrag?: {
|
|
2607
2603
|
ghost?: HTMLElement
|
|
2608
2604
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -2798,7 +2794,7 @@ declare const editorMachine: StateMachine<
|
|
|
2798
2794
|
initialReadOnly: boolean
|
|
2799
2795
|
maxBlocks: number | undefined
|
|
2800
2796
|
selection: EditorSelection
|
|
2801
|
-
|
|
2797
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
2802
2798
|
internalDrag?: {
|
|
2803
2799
|
ghost?: HTMLElement
|
|
2804
2800
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -2993,7 +2989,7 @@ declare const editorMachine: StateMachine<
|
|
|
2993
2989
|
initialReadOnly: boolean
|
|
2994
2990
|
maxBlocks: number | undefined
|
|
2995
2991
|
selection: EditorSelection
|
|
2996
|
-
|
|
2992
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
2997
2993
|
internalDrag?: {
|
|
2998
2994
|
ghost?: HTMLElement
|
|
2999
2995
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -3187,7 +3183,7 @@ declare const editorMachine: StateMachine<
|
|
|
3187
3183
|
initialReadOnly: boolean
|
|
3188
3184
|
maxBlocks: number | undefined
|
|
3189
3185
|
selection: EditorSelection
|
|
3190
|
-
|
|
3186
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
3191
3187
|
internalDrag?: {
|
|
3192
3188
|
ghost?: HTMLElement
|
|
3193
3189
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -3388,7 +3384,7 @@ declare const editorMachine: StateMachine<
|
|
|
3388
3384
|
initialReadOnly: boolean
|
|
3389
3385
|
maxBlocks: number | undefined
|
|
3390
3386
|
selection: EditorSelection
|
|
3391
|
-
|
|
3387
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
3392
3388
|
internalDrag?: {
|
|
3393
3389
|
ghost?: HTMLElement
|
|
3394
3390
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -3583,7 +3579,7 @@ declare const editorMachine: StateMachine<
|
|
|
3583
3579
|
initialReadOnly: boolean
|
|
3584
3580
|
maxBlocks: number | undefined
|
|
3585
3581
|
selection: EditorSelection
|
|
3586
|
-
|
|
3582
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
3587
3583
|
internalDrag?: {
|
|
3588
3584
|
ghost?: HTMLElement
|
|
3589
3585
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -3735,7 +3731,7 @@ declare const editorMachine: StateMachine<
|
|
|
3735
3731
|
initialReadOnly: boolean
|
|
3736
3732
|
maxBlocks: number | undefined
|
|
3737
3733
|
selection: EditorSelection
|
|
3738
|
-
|
|
3734
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
3739
3735
|
internalDrag?: {
|
|
3740
3736
|
ghost?: HTMLElement
|
|
3741
3737
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -3884,7 +3880,7 @@ declare const editorMachine: StateMachine<
|
|
|
3884
3880
|
initialReadOnly: boolean
|
|
3885
3881
|
maxBlocks: number | undefined
|
|
3886
3882
|
selection: EditorSelection
|
|
3887
|
-
|
|
3883
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
3888
3884
|
internalDrag?: {
|
|
3889
3885
|
ghost?: HTMLElement
|
|
3890
3886
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4045,7 +4041,7 @@ declare const editorMachine: StateMachine<
|
|
|
4045
4041
|
initialReadOnly: boolean
|
|
4046
4042
|
maxBlocks: number | undefined
|
|
4047
4043
|
selection: EditorSelection
|
|
4048
|
-
|
|
4044
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4049
4045
|
internalDrag?: {
|
|
4050
4046
|
ghost?: HTMLElement
|
|
4051
4047
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4083,7 +4079,7 @@ declare const editorMachine: StateMachine<
|
|
|
4083
4079
|
initialReadOnly: boolean
|
|
4084
4080
|
maxBlocks: number | undefined
|
|
4085
4081
|
selection: EditorSelection
|
|
4086
|
-
|
|
4082
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4087
4083
|
internalDrag?: {
|
|
4088
4084
|
ghost?: HTMLElement
|
|
4089
4085
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4115,7 +4111,7 @@ declare const editorMachine: StateMachine<
|
|
|
4115
4111
|
initialReadOnly: boolean
|
|
4116
4112
|
maxBlocks: number | undefined
|
|
4117
4113
|
selection: EditorSelection
|
|
4118
|
-
|
|
4114
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4119
4115
|
internalDrag?: {
|
|
4120
4116
|
ghost?: HTMLElement
|
|
4121
4117
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4148,7 +4144,7 @@ declare const editorMachine: StateMachine<
|
|
|
4148
4144
|
initialReadOnly: boolean
|
|
4149
4145
|
maxBlocks: number | undefined
|
|
4150
4146
|
selection: EditorSelection
|
|
4151
|
-
|
|
4147
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4152
4148
|
internalDrag?: {
|
|
4153
4149
|
ghost?: HTMLElement
|
|
4154
4150
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4184,7 +4180,7 @@ declare const editorMachine: StateMachine<
|
|
|
4184
4180
|
initialReadOnly: boolean
|
|
4185
4181
|
maxBlocks: number | undefined
|
|
4186
4182
|
selection: EditorSelection
|
|
4187
|
-
|
|
4183
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4188
4184
|
internalDrag?: {
|
|
4189
4185
|
ghost?: HTMLElement
|
|
4190
4186
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4341,7 +4337,7 @@ declare const editorMachine: StateMachine<
|
|
|
4341
4337
|
initialReadOnly: boolean
|
|
4342
4338
|
maxBlocks: number | undefined
|
|
4343
4339
|
selection: EditorSelection
|
|
4344
|
-
|
|
4340
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4345
4341
|
internalDrag?: {
|
|
4346
4342
|
ghost?: HTMLElement
|
|
4347
4343
|
origin: Pick<EventPosition, 'selection'>
|
|
@@ -4598,7 +4594,7 @@ declare const editorMachine: StateMachine<
|
|
|
4598
4594
|
initialReadOnly: boolean
|
|
4599
4595
|
maxBlocks: number | undefined
|
|
4600
4596
|
selection: EditorSelection
|
|
4601
|
-
|
|
4597
|
+
incomingValue: Array<PortableTextBlock> | undefined
|
|
4602
4598
|
internalDrag?: {
|
|
4603
4599
|
ghost?: HTMLElement
|
|
4604
4600
|
origin: Pick<EventPosition, 'selection'>
|
package/lib/plugins/index.cjs
CHANGED
|
@@ -120,45 +120,42 @@ function createDecoratorPairBehavior(config) {
|
|
|
120
120
|
// Insert the text as usual in its own undo step
|
|
121
121
|
({
|
|
122
122
|
event
|
|
123
|
-
}) => [event],
|
|
123
|
+
}) => [behavior_core.execute(event)],
|
|
124
124
|
(_, {
|
|
125
125
|
prefixOffsets,
|
|
126
126
|
suffixOffsets,
|
|
127
127
|
decorator
|
|
128
128
|
}) => [
|
|
129
129
|
// Decorate the text between the prefix and suffix
|
|
130
|
-
{
|
|
130
|
+
behavior_core.execute({
|
|
131
131
|
type: "decorator.add",
|
|
132
132
|
decorator,
|
|
133
133
|
at: {
|
|
134
134
|
anchor: prefixOffsets.focus,
|
|
135
135
|
focus: suffixOffsets.anchor
|
|
136
136
|
}
|
|
137
|
-
},
|
|
137
|
+
}),
|
|
138
138
|
// Delete the suffix
|
|
139
|
-
behavior_core.
|
|
139
|
+
behavior_core.execute({
|
|
140
140
|
type: "delete.text",
|
|
141
141
|
at: suffixOffsets
|
|
142
142
|
}),
|
|
143
143
|
// Delete the prefix
|
|
144
|
-
behavior_core.
|
|
144
|
+
behavior_core.execute({
|
|
145
145
|
type: "delete.text",
|
|
146
146
|
at: prefixOffsets
|
|
147
147
|
}),
|
|
148
148
|
// Toggle the decorator off so the next inserted text isn't emphasized
|
|
149
|
-
{
|
|
149
|
+
behavior_core.execute({
|
|
150
150
|
type: "decorator.remove",
|
|
151
151
|
decorator
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
152
|
+
}),
|
|
153
|
+
behavior_core.effect(() => {
|
|
154
|
+
config.onDecorate({
|
|
155
|
+
...suffixOffsets.anchor,
|
|
156
|
+
offset: suffixOffsets.anchor.offset - (prefixOffsets.focus.offset - prefixOffsets.anchor.offset)
|
|
157
|
+
});
|
|
158
|
+
})
|
|
162
159
|
]
|
|
163
160
|
]
|
|
164
161
|
});
|
|
@@ -236,16 +233,13 @@ const emphasisListener = ({
|
|
|
236
233
|
}) => input.editor.registerBehavior({
|
|
237
234
|
behavior: behavior_core.defineBehavior({
|
|
238
235
|
on: "delete.backward",
|
|
239
|
-
actions: [() => [{
|
|
236
|
+
actions: [() => [behavior_core.execute({
|
|
240
237
|
type: "history.undo"
|
|
241
|
-
}, {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
}]]
|
|
238
|
+
}), behavior_core.effect(() => {
|
|
239
|
+
sendBack({
|
|
240
|
+
type: "delete.backward"
|
|
241
|
+
});
|
|
242
|
+
})]]
|
|
249
243
|
})
|
|
250
244
|
}), decoratorPairMachine = xstate.setup({
|
|
251
245
|
types: {
|
|
@@ -411,10 +405,10 @@ const oneLineBehaviors = [
|
|
|
411
405
|
} : !1,
|
|
412
406
|
actions: [(_, {
|
|
413
407
|
selection
|
|
414
|
-
}) => [{
|
|
408
|
+
}) => [behavior_core.execute({
|
|
415
409
|
type: "delete",
|
|
416
410
|
at: selection
|
|
417
|
-
}]]
|
|
411
|
+
})]]
|
|
418
412
|
}),
|
|
419
413
|
/**
|
|
420
414
|
* All other cases of `insert.break` should be aborted.
|
|
@@ -458,12 +452,12 @@ const oneLineBehaviors = [
|
|
|
458
452
|
}) => !(!selector_isOverlappingSelection.getFocusTextBlock(snapshot) || !util_mergeTextBlocks.isTextBlock(snapshot.context, event.block)),
|
|
459
453
|
actions: [({
|
|
460
454
|
event
|
|
461
|
-
}) => [{
|
|
455
|
+
}) => [behavior_core.execute({
|
|
462
456
|
type: "insert.block",
|
|
463
457
|
block: event.block,
|
|
464
458
|
placement: "auto",
|
|
465
459
|
select: "end"
|
|
466
|
-
}]]
|
|
460
|
+
})]]
|
|
467
461
|
}),
|
|
468
462
|
/**
|
|
469
463
|
* Fallback Behavior to avoid `insert.block` in case the Behaviors above all
|