@portabletext/editor 1.35.4 → 1.36.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.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +25 -3
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +25 -3
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/behaviors/index.d.cts +33 -282
- package/lib/behaviors/index.d.ts +33 -282
- package/lib/index.d.cts +28 -5
- package/lib/index.d.ts +28 -5
- package/lib/plugins/index.cjs +19 -19
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +17 -5
- package/lib/plugins/index.d.ts +17 -5
- package/lib/plugins/index.js +21 -21
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.d.cts +6 -5
- package/lib/selectors/index.d.ts +6 -5
- package/lib/utils/index.d.cts +6 -5
- package/lib/utils/index.d.ts +6 -5
- package/package.json +6 -6
- package/src/behavior-actions/behavior.actions.ts +2 -2
- package/src/behaviors/behavior.types.ts +10 -7
- package/src/editor/PortableTextEditor.tsx +22 -0
- package/src/editor/editor-machine.ts +4 -1
- package/src/plugins/index.ts +2 -1
- package/src/plugins/plugin.decorator-shortcut.ts +3 -0
- package/src/utils/util.slice-blocks.test.ts +64 -0
|
@@ -44,7 +44,6 @@ import {
|
|
|
44
44
|
Values,
|
|
45
45
|
} from 'xstate'
|
|
46
46
|
import {GuardArgs} from 'xstate/guards'
|
|
47
|
-
import {PickFromUnion as PickFromUnion_2} from '.'
|
|
48
47
|
import {
|
|
49
48
|
BlockOffset as BlockOffset_2,
|
|
50
49
|
PortableTextMemberSchemaTypes as PortableTextMemberSchemaTypes_2,
|
|
@@ -61,11 +60,9 @@ import {
|
|
|
61
60
|
export declare type Behavior<
|
|
62
61
|
TBehaviorEventType extends BehaviorEvent['type'] = BehaviorEvent['type'],
|
|
63
62
|
TGuardResponse = true,
|
|
64
|
-
TBehaviorEvent extends BehaviorEvent =
|
|
65
|
-
BehaviorEvent
|
|
66
|
-
'type',
|
|
67
|
-
TBehaviorEventType
|
|
68
|
-
>,
|
|
63
|
+
TBehaviorEvent extends BehaviorEvent = TBehaviorEventType extends '*'
|
|
64
|
+
? BehaviorEvent
|
|
65
|
+
: PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>,
|
|
69
66
|
> = {
|
|
70
67
|
/**
|
|
71
68
|
* The internal editor event that triggers this behavior.
|
|
@@ -123,6 +120,9 @@ export declare type BehaviorEvent =
|
|
|
123
120
|
| SyntheticBehaviorEvent
|
|
124
121
|
| NativeBehaviorEvent
|
|
125
122
|
| CustomBehaviorEvent
|
|
123
|
+
| {
|
|
124
|
+
type: '*'
|
|
125
|
+
}
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* @beta
|
|
@@ -244,62 +244,10 @@ export declare const coreBehaviors: Behavior_2<
|
|
|
244
244
|
| 'style.toggle'
|
|
245
245
|
| 'key.down'
|
|
246
246
|
| 'key.up'
|
|
247
|
-
| 'paste'
|
|
247
|
+
| 'paste'
|
|
248
|
+
| '*',
|
|
248
249
|
true,
|
|
249
|
-
|
|
250
|
-
BehaviorEvent_2,
|
|
251
|
-
'type',
|
|
252
|
-
| 'focus'
|
|
253
|
-
| 'delete'
|
|
254
|
-
| 'select'
|
|
255
|
-
| 'serialize'
|
|
256
|
-
| 'deserialize'
|
|
257
|
-
| 'serialization.failure'
|
|
258
|
-
| 'serialization.success'
|
|
259
|
-
| 'deserialization.failure'
|
|
260
|
-
| 'deserialization.success'
|
|
261
|
-
| 'copy'
|
|
262
|
-
| `custom.${string}`
|
|
263
|
-
| 'annotation.add'
|
|
264
|
-
| 'annotation.remove'
|
|
265
|
-
| 'annotation.toggle'
|
|
266
|
-
| 'block.set'
|
|
267
|
-
| 'block.unset'
|
|
268
|
-
| 'blur'
|
|
269
|
-
| 'data transfer.set'
|
|
270
|
-
| 'decorator.add'
|
|
271
|
-
| 'decorator.remove'
|
|
272
|
-
| 'decorator.toggle'
|
|
273
|
-
| 'delete.backward'
|
|
274
|
-
| 'delete.block'
|
|
275
|
-
| 'delete.forward'
|
|
276
|
-
| 'delete.text'
|
|
277
|
-
| 'history.redo'
|
|
278
|
-
| 'history.undo'
|
|
279
|
-
| 'insert.blocks'
|
|
280
|
-
| 'insert.block object'
|
|
281
|
-
| 'insert.inline object'
|
|
282
|
-
| 'insert.break'
|
|
283
|
-
| 'insert.soft break'
|
|
284
|
-
| 'insert.block'
|
|
285
|
-
| 'insert.span'
|
|
286
|
-
| 'insert.text'
|
|
287
|
-
| 'insert.text block'
|
|
288
|
-
| 'list item.add'
|
|
289
|
-
| 'list item.remove'
|
|
290
|
-
| 'list item.toggle'
|
|
291
|
-
| 'move.block'
|
|
292
|
-
| 'move.block down'
|
|
293
|
-
| 'move.block up'
|
|
294
|
-
| 'select.previous block'
|
|
295
|
-
| 'select.next block'
|
|
296
|
-
| 'style.add'
|
|
297
|
-
| 'style.remove'
|
|
298
|
-
| 'style.toggle'
|
|
299
|
-
| 'key.down'
|
|
300
|
-
| 'key.up'
|
|
301
|
-
| 'paste'
|
|
302
|
-
>
|
|
250
|
+
BehaviorEvent_2
|
|
303
251
|
>[]
|
|
304
252
|
|
|
305
253
|
/**
|
|
@@ -357,62 +305,10 @@ export declare function createCodeEditorBehaviors(
|
|
|
357
305
|
| 'style.toggle'
|
|
358
306
|
| 'key.down'
|
|
359
307
|
| 'key.up'
|
|
360
|
-
| 'paste'
|
|
308
|
+
| 'paste'
|
|
309
|
+
| '*',
|
|
361
310
|
true,
|
|
362
|
-
|
|
363
|
-
BehaviorEvent_2,
|
|
364
|
-
'type',
|
|
365
|
-
| 'focus'
|
|
366
|
-
| 'delete'
|
|
367
|
-
| 'select'
|
|
368
|
-
| 'serialize'
|
|
369
|
-
| 'deserialize'
|
|
370
|
-
| 'serialization.failure'
|
|
371
|
-
| 'serialization.success'
|
|
372
|
-
| 'deserialization.failure'
|
|
373
|
-
| 'deserialization.success'
|
|
374
|
-
| 'copy'
|
|
375
|
-
| `custom.${string}`
|
|
376
|
-
| 'annotation.add'
|
|
377
|
-
| 'annotation.remove'
|
|
378
|
-
| 'annotation.toggle'
|
|
379
|
-
| 'block.set'
|
|
380
|
-
| 'block.unset'
|
|
381
|
-
| 'blur'
|
|
382
|
-
| 'data transfer.set'
|
|
383
|
-
| 'decorator.add'
|
|
384
|
-
| 'decorator.remove'
|
|
385
|
-
| 'decorator.toggle'
|
|
386
|
-
| 'delete.backward'
|
|
387
|
-
| 'delete.block'
|
|
388
|
-
| 'delete.forward'
|
|
389
|
-
| 'delete.text'
|
|
390
|
-
| 'history.redo'
|
|
391
|
-
| 'history.undo'
|
|
392
|
-
| 'insert.blocks'
|
|
393
|
-
| 'insert.block object'
|
|
394
|
-
| 'insert.inline object'
|
|
395
|
-
| 'insert.break'
|
|
396
|
-
| 'insert.soft break'
|
|
397
|
-
| 'insert.block'
|
|
398
|
-
| 'insert.span'
|
|
399
|
-
| 'insert.text'
|
|
400
|
-
| 'insert.text block'
|
|
401
|
-
| 'list item.add'
|
|
402
|
-
| 'list item.remove'
|
|
403
|
-
| 'list item.toggle'
|
|
404
|
-
| 'move.block'
|
|
405
|
-
| 'move.block down'
|
|
406
|
-
| 'move.block up'
|
|
407
|
-
| 'select.previous block'
|
|
408
|
-
| 'select.next block'
|
|
409
|
-
| 'style.add'
|
|
410
|
-
| 'style.remove'
|
|
411
|
-
| 'style.toggle'
|
|
412
|
-
| 'key.down'
|
|
413
|
-
| 'key.up'
|
|
414
|
-
| 'paste'
|
|
415
|
-
>
|
|
311
|
+
BehaviorEvent_2
|
|
416
312
|
>[]
|
|
417
313
|
|
|
418
314
|
/**
|
|
@@ -470,62 +366,10 @@ export declare function createEmojiPickerBehaviors<TEmojiMatch>(
|
|
|
470
366
|
| 'style.toggle'
|
|
471
367
|
| 'key.down'
|
|
472
368
|
| 'key.up'
|
|
473
|
-
| 'paste'
|
|
369
|
+
| 'paste'
|
|
370
|
+
| '*',
|
|
474
371
|
true,
|
|
475
|
-
|
|
476
|
-
BehaviorEvent_2,
|
|
477
|
-
'type',
|
|
478
|
-
| 'focus'
|
|
479
|
-
| 'delete'
|
|
480
|
-
| 'select'
|
|
481
|
-
| 'serialize'
|
|
482
|
-
| 'deserialize'
|
|
483
|
-
| 'serialization.failure'
|
|
484
|
-
| 'serialization.success'
|
|
485
|
-
| 'deserialization.failure'
|
|
486
|
-
| 'deserialization.success'
|
|
487
|
-
| 'copy'
|
|
488
|
-
| `custom.${string}`
|
|
489
|
-
| 'annotation.add'
|
|
490
|
-
| 'annotation.remove'
|
|
491
|
-
| 'annotation.toggle'
|
|
492
|
-
| 'block.set'
|
|
493
|
-
| 'block.unset'
|
|
494
|
-
| 'blur'
|
|
495
|
-
| 'data transfer.set'
|
|
496
|
-
| 'decorator.add'
|
|
497
|
-
| 'decorator.remove'
|
|
498
|
-
| 'decorator.toggle'
|
|
499
|
-
| 'delete.backward'
|
|
500
|
-
| 'delete.block'
|
|
501
|
-
| 'delete.forward'
|
|
502
|
-
| 'delete.text'
|
|
503
|
-
| 'history.redo'
|
|
504
|
-
| 'history.undo'
|
|
505
|
-
| 'insert.blocks'
|
|
506
|
-
| 'insert.block object'
|
|
507
|
-
| 'insert.inline object'
|
|
508
|
-
| 'insert.break'
|
|
509
|
-
| 'insert.soft break'
|
|
510
|
-
| 'insert.block'
|
|
511
|
-
| 'insert.span'
|
|
512
|
-
| 'insert.text'
|
|
513
|
-
| 'insert.text block'
|
|
514
|
-
| 'list item.add'
|
|
515
|
-
| 'list item.remove'
|
|
516
|
-
| 'list item.toggle'
|
|
517
|
-
| 'move.block'
|
|
518
|
-
| 'move.block down'
|
|
519
|
-
| 'move.block up'
|
|
520
|
-
| 'select.previous block'
|
|
521
|
-
| 'select.next block'
|
|
522
|
-
| 'style.add'
|
|
523
|
-
| 'style.remove'
|
|
524
|
-
| 'style.toggle'
|
|
525
|
-
| 'key.down'
|
|
526
|
-
| 'key.up'
|
|
527
|
-
| 'paste'
|
|
528
|
-
>
|
|
372
|
+
BehaviorEvent_2
|
|
529
373
|
>[]
|
|
530
374
|
|
|
531
375
|
/**
|
|
@@ -583,62 +427,10 @@ export declare function createLinkBehaviors(
|
|
|
583
427
|
| 'style.toggle'
|
|
584
428
|
| 'key.down'
|
|
585
429
|
| 'key.up'
|
|
586
|
-
| 'paste'
|
|
430
|
+
| 'paste'
|
|
431
|
+
| '*',
|
|
587
432
|
true,
|
|
588
|
-
|
|
589
|
-
BehaviorEvent_2,
|
|
590
|
-
'type',
|
|
591
|
-
| 'focus'
|
|
592
|
-
| 'delete'
|
|
593
|
-
| 'select'
|
|
594
|
-
| 'serialize'
|
|
595
|
-
| 'deserialize'
|
|
596
|
-
| 'serialization.failure'
|
|
597
|
-
| 'serialization.success'
|
|
598
|
-
| 'deserialization.failure'
|
|
599
|
-
| 'deserialization.success'
|
|
600
|
-
| 'copy'
|
|
601
|
-
| `custom.${string}`
|
|
602
|
-
| 'annotation.add'
|
|
603
|
-
| 'annotation.remove'
|
|
604
|
-
| 'annotation.toggle'
|
|
605
|
-
| 'block.set'
|
|
606
|
-
| 'block.unset'
|
|
607
|
-
| 'blur'
|
|
608
|
-
| 'data transfer.set'
|
|
609
|
-
| 'decorator.add'
|
|
610
|
-
| 'decorator.remove'
|
|
611
|
-
| 'decorator.toggle'
|
|
612
|
-
| 'delete.backward'
|
|
613
|
-
| 'delete.block'
|
|
614
|
-
| 'delete.forward'
|
|
615
|
-
| 'delete.text'
|
|
616
|
-
| 'history.redo'
|
|
617
|
-
| 'history.undo'
|
|
618
|
-
| 'insert.blocks'
|
|
619
|
-
| 'insert.block object'
|
|
620
|
-
| 'insert.inline object'
|
|
621
|
-
| 'insert.break'
|
|
622
|
-
| 'insert.soft break'
|
|
623
|
-
| 'insert.block'
|
|
624
|
-
| 'insert.span'
|
|
625
|
-
| 'insert.text'
|
|
626
|
-
| 'insert.text block'
|
|
627
|
-
| 'list item.add'
|
|
628
|
-
| 'list item.remove'
|
|
629
|
-
| 'list item.toggle'
|
|
630
|
-
| 'move.block'
|
|
631
|
-
| 'move.block down'
|
|
632
|
-
| 'move.block up'
|
|
633
|
-
| 'select.previous block'
|
|
634
|
-
| 'select.next block'
|
|
635
|
-
| 'style.add'
|
|
636
|
-
| 'style.remove'
|
|
637
|
-
| 'style.toggle'
|
|
638
|
-
| 'key.down'
|
|
639
|
-
| 'key.up'
|
|
640
|
-
| 'paste'
|
|
641
|
-
>
|
|
433
|
+
BehaviorEvent_2
|
|
642
434
|
>[]
|
|
643
435
|
|
|
644
436
|
/**
|
|
@@ -738,62 +530,10 @@ export declare function createMarkdownBehaviors(
|
|
|
738
530
|
| 'style.toggle'
|
|
739
531
|
| 'key.down'
|
|
740
532
|
| 'key.up'
|
|
741
|
-
| 'paste'
|
|
533
|
+
| 'paste'
|
|
534
|
+
| '*',
|
|
742
535
|
true,
|
|
743
|
-
|
|
744
|
-
BehaviorEvent_2,
|
|
745
|
-
'type',
|
|
746
|
-
| 'focus'
|
|
747
|
-
| 'delete'
|
|
748
|
-
| 'select'
|
|
749
|
-
| 'serialize'
|
|
750
|
-
| 'deserialize'
|
|
751
|
-
| 'serialization.failure'
|
|
752
|
-
| 'serialization.success'
|
|
753
|
-
| 'deserialization.failure'
|
|
754
|
-
| 'deserialization.success'
|
|
755
|
-
| 'copy'
|
|
756
|
-
| `custom.${string}`
|
|
757
|
-
| 'annotation.add'
|
|
758
|
-
| 'annotation.remove'
|
|
759
|
-
| 'annotation.toggle'
|
|
760
|
-
| 'block.set'
|
|
761
|
-
| 'block.unset'
|
|
762
|
-
| 'blur'
|
|
763
|
-
| 'data transfer.set'
|
|
764
|
-
| 'decorator.add'
|
|
765
|
-
| 'decorator.remove'
|
|
766
|
-
| 'decorator.toggle'
|
|
767
|
-
| 'delete.backward'
|
|
768
|
-
| 'delete.block'
|
|
769
|
-
| 'delete.forward'
|
|
770
|
-
| 'delete.text'
|
|
771
|
-
| 'history.redo'
|
|
772
|
-
| 'history.undo'
|
|
773
|
-
| 'insert.blocks'
|
|
774
|
-
| 'insert.block object'
|
|
775
|
-
| 'insert.inline object'
|
|
776
|
-
| 'insert.break'
|
|
777
|
-
| 'insert.soft break'
|
|
778
|
-
| 'insert.block'
|
|
779
|
-
| 'insert.span'
|
|
780
|
-
| 'insert.text'
|
|
781
|
-
| 'insert.text block'
|
|
782
|
-
| 'list item.add'
|
|
783
|
-
| 'list item.remove'
|
|
784
|
-
| 'list item.toggle'
|
|
785
|
-
| 'move.block'
|
|
786
|
-
| 'move.block down'
|
|
787
|
-
| 'move.block up'
|
|
788
|
-
| 'select.previous block'
|
|
789
|
-
| 'select.next block'
|
|
790
|
-
| 'style.add'
|
|
791
|
-
| 'style.remove'
|
|
792
|
-
| 'style.toggle'
|
|
793
|
-
| 'key.down'
|
|
794
|
-
| 'key.up'
|
|
795
|
-
| 'paste'
|
|
796
|
-
>
|
|
536
|
+
BehaviorEvent_2
|
|
797
537
|
>[]
|
|
798
538
|
|
|
799
539
|
/**
|
|
@@ -836,7 +576,9 @@ export declare function defineBehavior<
|
|
|
836
576
|
TGuardResponse,
|
|
837
577
|
TBehaviorEventType extends `custom.${infer TType}`
|
|
838
578
|
? CustomBehaviorEvent<TPayload, TType>
|
|
839
|
-
:
|
|
579
|
+
: TBehaviorEventType extends '*'
|
|
580
|
+
? OmitFromUnion<BehaviorEvent, 'type', '*'>
|
|
581
|
+
: PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>
|
|
840
582
|
>,
|
|
841
583
|
): Behavior
|
|
842
584
|
|
|
@@ -20100,6 +19842,15 @@ export declare type NativeBehaviorEvent =
|
|
|
20100
19842
|
dataTransfer: DataTransfer
|
|
20101
19843
|
}
|
|
20102
19844
|
|
|
19845
|
+
/**
|
|
19846
|
+
* @internal
|
|
19847
|
+
*/
|
|
19848
|
+
declare type OmitFromUnion<
|
|
19849
|
+
TUnion,
|
|
19850
|
+
TTagKey extends keyof TUnion,
|
|
19851
|
+
TOmittedTags extends TUnion[TTagKey],
|
|
19852
|
+
> = TUnion extends Record<TTagKey, TOmittedTags> ? never : TUnion
|
|
19853
|
+
|
|
20103
19854
|
/**
|
|
20104
19855
|
* @public
|
|
20105
19856
|
*/
|