@portabletext/editor 1.50.8 → 1.52.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.
Files changed (104) hide show
  1. package/lib/_chunks-cjs/{util.slice-blocks.cjs → selection-point.cjs} +26 -18
  2. package/lib/_chunks-cjs/selection-point.cjs.map +1 -0
  3. package/lib/_chunks-cjs/selector.get-text-before.cjs +13 -10
  4. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  5. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +46 -46
  6. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
  7. package/lib/_chunks-cjs/selector.is-selection-expanded.cjs +21 -17
  8. package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +1 -1
  9. package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +10 -10
  10. package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
  11. package/lib/_chunks-cjs/util.is-equal-selection-points.cjs +5 -5
  12. package/lib/_chunks-cjs/util.is-equal-selection-points.cjs.map +1 -1
  13. package/lib/_chunks-cjs/util.merge-text-blocks.cjs +3 -3
  14. package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
  15. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +7 -14
  16. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
  17. package/lib/_chunks-es/{util.slice-blocks.js → selection-point.js} +26 -18
  18. package/lib/_chunks-es/selection-point.js.map +1 -0
  19. package/lib/_chunks-es/selector.get-text-before.js +13 -10
  20. package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
  21. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +21 -21
  22. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
  23. package/lib/_chunks-es/selector.is-selection-expanded.js +14 -10
  24. package/lib/_chunks-es/selector.is-selection-expanded.js.map +1 -1
  25. package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +2 -2
  26. package/lib/_chunks-es/util.child-selection-point-to-block-offset.js.map +1 -1
  27. package/lib/_chunks-es/util.is-equal-selection-points.js +1 -1
  28. package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
  29. package/lib/_chunks-es/util.selection-point-to-block-offset.js +4 -11
  30. package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
  31. package/lib/behaviors/index.cjs.map +1 -1
  32. package/lib/behaviors/index.d.cts +25 -2010
  33. package/lib/behaviors/index.d.ts +25 -2010
  34. package/lib/behaviors/index.js.map +1 -1
  35. package/lib/index.cjs +515 -393
  36. package/lib/index.cjs.map +1 -1
  37. package/lib/index.d.cts +361 -34
  38. package/lib/index.d.ts +361 -34
  39. package/lib/index.js +471 -349
  40. package/lib/index.js.map +1 -1
  41. package/lib/plugins/index.cjs +11 -11
  42. package/lib/plugins/index.cjs.map +1 -1
  43. package/lib/plugins/index.d.cts +32 -1986
  44. package/lib/plugins/index.d.ts +32 -1986
  45. package/lib/plugins/index.js +1 -1
  46. package/lib/selectors/index.cjs +11 -7
  47. package/lib/selectors/index.cjs.map +1 -1
  48. package/lib/selectors/index.d.cts +2 -2648
  49. package/lib/selectors/index.d.ts +2 -2648
  50. package/lib/selectors/index.js +7 -3
  51. package/lib/selectors/index.js.map +1 -1
  52. package/lib/utils/index.cjs +25 -14
  53. package/lib/utils/index.cjs.map +1 -1
  54. package/lib/utils/index.d.cts +0 -2647
  55. package/lib/utils/index.d.ts +0 -2647
  56. package/lib/utils/index.js +14 -3
  57. package/lib/utils/index.js.map +1 -1
  58. package/package.json +14 -14
  59. package/src/behaviors/behavior.abstract.delete.ts +0 -2
  60. package/src/behaviors/behavior.abstract.insert.ts +8 -8
  61. package/src/behaviors/behavior.abstract.ts +0 -113
  62. package/src/behaviors/behavior.core.block-element.ts +9 -3
  63. package/src/behaviors/behavior.core.dnd.ts +328 -1
  64. package/src/behaviors/behavior.perform-event.ts +10 -0
  65. package/src/behaviors/behavior.types.action.ts +2 -0
  66. package/src/behaviors/behavior.types.event.ts +5 -0
  67. package/src/behaviors/behavior.types.guard.ts +2 -0
  68. package/src/converters/converter.portable-text.ts +2 -7
  69. package/src/converters/converter.text-html.ts +1 -3
  70. package/src/converters/converter.text-plain.ts +3 -5
  71. package/src/editor/Editable.tsx +6 -133
  72. package/src/editor/editor-machine.ts +15 -10
  73. package/src/editor/editor-selector.ts +0 -2
  74. package/src/editor/editor-snapshot.ts +0 -18
  75. package/src/internal-utils/create-test-snapshot.ts +0 -2
  76. package/src/internal-utils/event-position.ts +42 -30
  77. package/src/internal-utils/selection-block-keys.ts +7 -7
  78. package/src/internal-utils/selection-elements.ts +108 -0
  79. package/src/internal-utils/selection-focus-text.ts +13 -9
  80. package/src/internal-utils/selection-text.ts +9 -78
  81. package/src/internal-utils/terse-pt.test.ts +108 -26
  82. package/src/internal-utils/terse-pt.ts +132 -14
  83. package/src/operations/behavior.operation.decorator.add.ts +0 -2
  84. package/src/operations/behavior.operation.delete.ts +18 -13
  85. package/src/operations/behavior.operation.insert.block.ts +5 -1
  86. package/src/selection/selection-point.ts +22 -0
  87. package/src/selectors/selector.get-anchor-block.ts +6 -6
  88. package/src/selectors/selector.get-anchor-child.ts +6 -6
  89. package/src/selectors/selector.get-selected-spans.ts +16 -19
  90. package/src/selectors/selector.get-selected-text-blocks.ts +11 -19
  91. package/src/selectors/selector.get-selection-end-block.ts +30 -0
  92. package/src/selectors/selector.get-selection-start-block.ts +30 -0
  93. package/src/selectors/selector.get-text-before.ts +15 -16
  94. package/src/selectors/selector.get-trimmed-selection.ts +15 -21
  95. package/src/selectors/selector.is-point-after-selection.ts +11 -19
  96. package/src/selectors/selector.is-point-before-selection.ts +11 -19
  97. package/src/selectors/selectors.ts +23 -39
  98. package/src/utils/util.block-offset.ts +6 -7
  99. package/src/utils/util.child-selection-point-to-block-offset.ts +6 -7
  100. package/src/utils/util.selection-point-to-block-offset.ts +5 -6
  101. package/src/utils/util.slice-blocks.ts +11 -20
  102. package/lib/_chunks-cjs/util.slice-blocks.cjs.map +0 -1
  103. package/lib/_chunks-es/util.slice-blocks.js.map +0 -1
  104. package/src/internal-utils/inline-object-selection.ts +0 -115
@@ -1,46 +1,10 @@
1
- import type {Patch} from '@portabletext/patches'
2
1
  import type {
3
- ArraySchemaType,
4
- BlockDecoratorDefinition,
5
- BlockListDefinition,
6
- BlockStyleDefinition,
7
2
  KeyedSegment,
8
- ObjectSchemaType,
9
3
  Path,
10
4
  PortableTextBlock,
11
- PortableTextChild,
12
- PortableTextListBlock,
13
5
  PortableTextObject,
14
- PortableTextSpan,
15
6
  PortableTextTextBlock,
16
7
  } from '@sanity/types'
17
- import {FocusEvent as FocusEvent_2} from 'react'
18
- import type {KeyboardEvent as KeyboardEvent_2} from 'react'
19
- import type {Descendant, Operation} from 'slate'
20
- import type {DOMNode} from 'slate-dom'
21
- import type {ReactEditor} from 'slate-react'
22
- import {
23
- ActionArgs,
24
- ActionFunction,
25
- ActorRef,
26
- ActorRefFrom,
27
- ActorRefFromLogic,
28
- AnyActorLogic,
29
- AnyActorRef,
30
- AnyEventObject,
31
- ConditionalRequired,
32
- InputFrom,
33
- IsNotNever,
34
- MachineSnapshot,
35
- MetaObject,
36
- NonReducibleUnknown,
37
- RequiredLogicInput,
38
- StateMachine,
39
- StateValue,
40
- Values,
41
- } from 'xstate'
42
- import {GuardArgs} from 'xstate/guards'
43
- import {InvalidValueResolution} from '..'
44
8
 
45
9
  declare type AbstractBehaviorEvent =
46
10
  | {
@@ -145,6 +109,7 @@ declare type AbstractBehaviorEvent =
145
109
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.blocks'>
146
110
  blocks: Array<BlockWithOptionalKey>
147
111
  placement: InsertPlacement
112
+ select?: 'start' | 'end' | 'none'
148
113
  }
149
114
  | {
150
115
  type: StrictExtract<SyntheticBehaviorEventType, 'insert.break'>
@@ -296,15 +261,11 @@ export declare type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (
296
261
  payload: {
297
262
  snapshot: EditorSnapshot
298
263
  event: TBehaviorEvent
264
+ dom: EditorDom
299
265
  },
300
266
  guardResponse: TGuardResponse,
301
267
  ) => Array<BehaviorAction>
302
268
 
303
- declare type BehaviorConfig = {
304
- behavior: Behavior
305
- priority: EditorPriority
306
- }
307
-
308
269
  /**
309
270
  * @beta
310
271
  */
@@ -324,6 +285,7 @@ declare type BehaviorEventTypeNamespace =
324
285
  export declare type BehaviorGuard<TBehaviorEvent, TGuardResponse> = (payload: {
325
286
  snapshot: EditorSnapshot
326
287
  event: TBehaviorEvent
288
+ dom: EditorDom
327
289
  }) => TGuardResponse | false
328
290
 
329
291
  /**
@@ -468,6 +430,8 @@ declare type DragBehaviorEvent =
468
430
  | {
469
431
  type: StrictExtract<NativeBehaviorEventType, 'drag.dragstart'>
470
432
  originEvent: {
433
+ clientX: number
434
+ clientY: number
471
435
  dataTransfer: DataTransfer
472
436
  }
473
437
  position: Pick<EventPosition, 'selection'>
@@ -496,6 +460,7 @@ declare type DragBehaviorEvent =
496
460
  originEvent: {
497
461
  dataTransfer: DataTransfer
498
462
  }
463
+ dragOrigin?: Pick<EventPosition, 'selection'>
499
464
  position: EventPosition
500
465
  }
501
466
  | {
@@ -503,6 +468,7 @@ declare type DragBehaviorEvent =
503
468
  originEvent: {
504
469
  dataTransfer: DataTransfer
505
470
  }
471
+ dragOrigin?: Pick<EventPosition, 'selection'>
506
472
  position: EventPosition
507
473
  }
508
474
  | {
@@ -512,100 +478,6 @@ declare type DragBehaviorEvent =
512
478
  }
513
479
  }
514
480
 
515
- /** @beta */
516
- declare interface EditableAPI {
517
- activeAnnotations: () => PortableTextObject[]
518
- isAnnotationActive: (annotationType: PortableTextObject['_type']) => boolean
519
- addAnnotation: <
520
- TSchemaType extends {
521
- name: string
522
- },
523
- >(
524
- type: TSchemaType,
525
- value?: {
526
- [prop: string]: unknown
527
- },
528
- ) =>
529
- | {
530
- markDefPath: Path
531
- markDefPaths: Array<Path>
532
- spanPath: Path
533
- }
534
- | undefined
535
- blur: () => void
536
- delete: (
537
- selection: EditorSelection,
538
- options?: EditableAPIDeleteOptions,
539
- ) => void
540
- findByPath: (
541
- path: Path,
542
- ) => [PortableTextBlock | PortableTextChild | undefined, Path | undefined]
543
- findDOMNode: (
544
- element: PortableTextBlock | PortableTextChild,
545
- ) => DOMNode | undefined
546
- focus: () => void
547
- focusBlock: () => PortableTextBlock | undefined
548
- focusChild: () => PortableTextChild | undefined
549
- getSelection: () => EditorSelection
550
- getFragment: () => PortableTextBlock[] | undefined
551
- getValue: () => PortableTextBlock[] | undefined
552
- hasBlockStyle: (style: string) => boolean
553
- hasListStyle: (listStyle: string) => boolean
554
- insertBlock: <
555
- TSchemaType extends {
556
- name: string
557
- },
558
- >(
559
- type: TSchemaType,
560
- value?: {
561
- [prop: string]: unknown
562
- },
563
- ) => Path
564
- insertChild: <
565
- TSchemaType extends {
566
- name: string
567
- },
568
- >(
569
- type: TSchemaType,
570
- value?: {
571
- [prop: string]: unknown
572
- },
573
- ) => Path
574
- insertBreak: () => void
575
- isCollapsedSelection: () => boolean
576
- isExpandedSelection: () => boolean
577
- isMarkActive: (mark: string) => boolean
578
- isSelectionsOverlapping: (
579
- selectionA: EditorSelection,
580
- selectionB: EditorSelection,
581
- ) => boolean
582
- isVoid: (element: PortableTextBlock | PortableTextChild) => boolean
583
- marks: () => string[]
584
- redo: () => void
585
- removeAnnotation: <
586
- TSchemaType extends {
587
- name: string
588
- },
589
- >(
590
- type: TSchemaType,
591
- ) => void
592
- select: (selection: EditorSelection) => void
593
- toggleBlockStyle: (blockStyle: string) => void
594
- toggleList: (listStyle: string) => void
595
- toggleMark: (mark: string) => void
596
- undo: () => void
597
- }
598
-
599
- /** @beta */
600
- declare interface EditableAPIDeleteOptions {
601
- mode?: 'blocks' | 'children' | 'selected'
602
- }
603
-
604
- /**
605
- * @internal
606
- */
607
- declare type EditorActor = ActorRefFrom<typeof editorMachine>
608
-
609
481
  /**
610
482
  * @public
611
483
  */
@@ -618,1762 +490,24 @@ declare type EditorContext = {
618
490
  value: Array<PortableTextBlock>
619
491
  }
620
492
 
621
- /**
622
- * @internal
623
- */
624
- declare const editorMachine: StateMachine<
625
- {
626
- behaviors: Set<BehaviorConfig>
627
- converters: Set<Converter>
628
- getLegacySchema: () => PortableTextMemberSchemaTypes
629
- keyGenerator: () => string
630
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
631
- pendingIncomingPatchesEvents: Array<PatchesEvent>
632
- schema: EditorSchema
633
- initialReadOnly: boolean
634
- maxBlocks: number | undefined
635
- selection: EditorSelection
636
- initialValue: Array<PortableTextBlock> | undefined
637
- internalDrag?: {
638
- ghost?: HTMLElement
639
- origin: Pick<EventPosition, 'selection'>
640
- }
641
- slateEditor?: PortableTextSlateEditor
642
- },
643
- | InternalPatchEvent
644
- | MutationEvent
645
- | PatchesEvent
646
- | {
647
- type: 'update readOnly'
648
- readOnly: boolean
649
- }
650
- | {
651
- type: 'update maxBlocks'
652
- maxBlocks: number | undefined
653
- }
654
- | {
655
- type: 'add behavior'
656
- behaviorConfig: BehaviorConfig
657
- }
658
- | {
659
- type: 'remove behavior'
660
- behaviorConfig: BehaviorConfig
661
- }
662
- | {
663
- type: 'blur'
664
- editor: PortableTextSlateEditor
665
- }
666
- | {
667
- type: 'focus'
668
- editor: PortableTextSlateEditor
669
- }
670
- | {
671
- type: 'normalizing'
672
- }
673
- | {
674
- type: 'update selection'
675
- selection: EditorSelection
676
- }
677
- | {
678
- type: 'done normalizing'
679
- }
680
- | {
681
- type: 'done syncing value'
682
- }
683
- | {
684
- type: 'syncing value'
685
- }
686
- | {
687
- type: 'behavior event'
688
- behaviorEvent: BehaviorEvent
689
- editor: PortableTextSlateEditor
690
- nativeEvent?: {
691
- preventDefault: () => void
692
- }
693
- }
694
- | {
695
- type: 'dragstart'
696
- origin: Pick<EventPosition, 'selection'>
697
- ghost?: HTMLElement
698
- }
699
- | {
700
- type: 'dragend'
701
- }
702
- | {
703
- type: 'drop'
704
- },
705
- {},
706
- never,
707
- Values<{
708
- 'add behavior to context': {
709
- type: 'add behavior to context'
710
- params: NonReducibleUnknown
711
- }
712
- 'remove behavior from context': {
713
- type: 'remove behavior from context'
714
- params: NonReducibleUnknown
715
- }
716
- 'emit patch event': {
717
- type: 'emit patch event'
718
- params: NonReducibleUnknown
719
- }
720
- 'emit mutation event': {
721
- type: 'emit mutation event'
722
- params: NonReducibleUnknown
723
- }
724
- 'emit read only': {
725
- type: 'emit read only'
726
- params: NonReducibleUnknown
727
- }
728
- 'emit editable': {
729
- type: 'emit editable'
730
- params: NonReducibleUnknown
731
- }
732
- 'defer event': {
733
- type: 'defer event'
734
- params: NonReducibleUnknown
735
- }
736
- 'emit pending events': {
737
- type: 'emit pending events'
738
- params: NonReducibleUnknown
739
- }
740
- 'emit ready': {
741
- type: 'emit ready'
742
- params: NonReducibleUnknown
743
- }
744
- 'clear pending events': {
745
- type: 'clear pending events'
746
- params: NonReducibleUnknown
747
- }
748
- 'defer incoming patches': {
749
- type: 'defer incoming patches'
750
- params: NonReducibleUnknown
751
- }
752
- 'emit pending incoming patches': {
753
- type: 'emit pending incoming patches'
754
- params: NonReducibleUnknown
755
- }
756
- 'clear pending incoming patches': {
757
- type: 'clear pending incoming patches'
758
- params: NonReducibleUnknown
759
- }
760
- 'handle blur': {
761
- type: 'handle blur'
762
- params: unknown
763
- }
764
- 'handle focus': {
765
- type: 'handle focus'
766
- params: unknown
767
- }
768
- 'handle behavior event': {
769
- type: 'handle behavior event'
770
- params: unknown
771
- }
772
- }>,
773
- {
774
- type: 'slate is busy'
775
- params: unknown
776
- },
777
- never,
778
- {
779
- 'edit mode':
780
- | {
781
- editable:
782
- | 'dragging internally'
783
- | 'idle'
784
- | {
785
- focusing: 'checking if busy' | 'busy'
786
- }
787
- }
788
- | {
789
- 'read only': 'read only' | 'determine initial edit mode'
790
- }
791
- 'setup':
792
- | 'setting up'
793
- | {
794
- 'set up': {
795
- 'value sync': 'syncing value' | 'idle'
796
- 'writing':
797
- | 'dirty'
798
- | {
799
- pristine: 'normalizing' | 'idle'
800
- }
801
- }
802
- }
803
- },
804
- 'dragging internally',
805
- {
806
- converters?: Array<Converter>
807
- getLegacySchema: () => PortableTextMemberSchemaTypes
808
- keyGenerator: () => string
809
- maxBlocks?: number
810
- readOnly?: boolean
811
- schema: EditorSchema
812
- initialValue?: Array<PortableTextBlock>
813
- },
814
- NonReducibleUnknown,
815
- | InternalPatchEvent
816
- | MutationEvent
817
- | PatchesEvent
818
- | {
819
- type: 'blurred'
820
- event: FocusEvent_2<HTMLDivElement, Element>
821
- }
822
- | {
823
- type: 'done loading'
824
- }
825
- | {
826
- type: 'editable'
827
- }
828
- | {
829
- type: 'error'
830
- name: string
831
- description: string
832
- data: unknown
833
- }
834
- | {
835
- type: 'focused'
836
- event: FocusEvent_2<HTMLDivElement, Element>
837
- }
838
- | {
839
- type: 'invalid value'
840
- resolution: InvalidValueResolution | null
841
- value: Array<PortableTextBlock> | undefined
842
- }
843
- | {
844
- type: 'loading'
845
- }
846
- | {
847
- type: 'read only'
848
- }
849
- | {
850
- type: 'ready'
851
- }
852
- | {
853
- type: 'selection'
854
- selection: EditorSelection
855
- }
856
- | {
857
- type: 'value changed'
858
- value: Array<PortableTextBlock> | undefined
859
- },
860
- MetaObject,
861
- {
862
- readonly id: 'editor'
863
- readonly context: ({
864
- input,
865
- }: {
866
- spawn: {
867
- <TSrc extends never>(
868
- logic: TSrc,
869
- ...[options]: never
870
- ): ActorRefFromLogic<never>
871
- <TLogic extends AnyActorLogic>(
872
- src: TLogic,
873
- ...[options]: ConditionalRequired<
874
- [
875
- options?:
876
- | ({
877
- id?: never
878
- systemId?: string
879
- input?: InputFrom<TLogic> | undefined
880
- syncSnapshot?: boolean
881
- } & {[K in RequiredLogicInput<TLogic>]: unknown})
882
- | undefined,
883
- ],
884
- IsNotNever<RequiredLogicInput<TLogic>>
885
- >
886
- ): ActorRefFromLogic<TLogic>
887
- }
888
- input: {
889
- converters?: Array<Converter>
890
- getLegacySchema: () => PortableTextMemberSchemaTypes
891
- keyGenerator: () => string
892
- maxBlocks?: number
893
- readOnly?: boolean
894
- schema: EditorSchema
895
- initialValue?: Array<PortableTextBlock>
896
- }
897
- self: ActorRef<
898
- MachineSnapshot<
899
- {
900
- behaviors: Set<BehaviorConfig>
901
- converters: Set<Converter>
902
- getLegacySchema: () => PortableTextMemberSchemaTypes
903
- keyGenerator: () => string
904
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
905
- pendingIncomingPatchesEvents: Array<PatchesEvent>
906
- schema: EditorSchema
907
- initialReadOnly: boolean
908
- maxBlocks: number | undefined
909
- selection: EditorSelection
910
- initialValue: Array<PortableTextBlock> | undefined
911
- internalDrag?: {
912
- ghost?: HTMLElement
913
- origin: Pick<EventPosition, 'selection'>
914
- }
915
- slateEditor?: PortableTextSlateEditor
916
- },
917
- | InternalPatchEvent
918
- | MutationEvent
919
- | PatchesEvent
920
- | {
921
- type: 'update readOnly'
922
- readOnly: boolean
923
- }
924
- | {
925
- type: 'update maxBlocks'
926
- maxBlocks: number | undefined
927
- }
928
- | {
929
- type: 'add behavior'
930
- behaviorConfig: BehaviorConfig
931
- }
932
- | {
933
- type: 'remove behavior'
934
- behaviorConfig: BehaviorConfig
935
- }
936
- | {
937
- type: 'blur'
938
- editor: PortableTextSlateEditor
939
- }
940
- | {
941
- type: 'focus'
942
- editor: PortableTextSlateEditor
943
- }
944
- | {
945
- type: 'normalizing'
946
- }
947
- | {
948
- type: 'update selection'
949
- selection: EditorSelection
950
- }
951
- | {
952
- type: 'done normalizing'
953
- }
954
- | {
955
- type: 'done syncing value'
956
- }
957
- | {
958
- type: 'syncing value'
959
- }
960
- | {
961
- type: 'behavior event'
962
- behaviorEvent: BehaviorEvent
963
- editor: PortableTextSlateEditor
964
- nativeEvent?: {
965
- preventDefault: () => void
966
- }
967
- }
968
- | {
969
- type: 'dragstart'
970
- origin: Pick<EventPosition, 'selection'>
971
- ghost?: HTMLElement
972
- }
973
- | {
974
- type: 'dragend'
975
- }
976
- | {
977
- type: 'drop'
978
- },
979
- Record<string, AnyActorRef | undefined>,
980
- StateValue,
981
- string,
982
- unknown,
983
- any,
984
- any
985
- >,
986
- | InternalPatchEvent
987
- | MutationEvent
988
- | PatchesEvent
989
- | {
990
- type: 'update readOnly'
991
- readOnly: boolean
992
- }
993
- | {
994
- type: 'update maxBlocks'
995
- maxBlocks: number | undefined
996
- }
997
- | {
998
- type: 'add behavior'
999
- behaviorConfig: BehaviorConfig
1000
- }
1001
- | {
1002
- type: 'remove behavior'
1003
- behaviorConfig: BehaviorConfig
1004
- }
1005
- | {
1006
- type: 'blur'
1007
- editor: PortableTextSlateEditor
1008
- }
1009
- | {
1010
- type: 'focus'
1011
- editor: PortableTextSlateEditor
1012
- }
1013
- | {
1014
- type: 'normalizing'
1015
- }
1016
- | {
1017
- type: 'update selection'
1018
- selection: EditorSelection
1019
- }
1020
- | {
1021
- type: 'done normalizing'
1022
- }
1023
- | {
1024
- type: 'done syncing value'
1025
- }
1026
- | {
1027
- type: 'syncing value'
1028
- }
1029
- | {
1030
- type: 'behavior event'
1031
- behaviorEvent: BehaviorEvent
1032
- editor: PortableTextSlateEditor
1033
- nativeEvent?: {
1034
- preventDefault: () => void
1035
- }
1036
- }
1037
- | {
1038
- type: 'dragstart'
1039
- origin: Pick<EventPosition, 'selection'>
1040
- ghost?: HTMLElement
1041
- }
1042
- | {
1043
- type: 'dragend'
1044
- }
1045
- | {
1046
- type: 'drop'
1047
- },
1048
- AnyEventObject
1049
- >
1050
- }) => {
1051
- behaviors: Set<never>
1052
- converters: Set<Converter>
1053
- getLegacySchema: () => PortableTextMemberSchemaTypes
1054
- keyGenerator: () => string
1055
- pendingEvents: never[]
1056
- pendingIncomingPatchesEvents: never[]
1057
- schema: EditorSchema
1058
- selection: null
1059
- initialReadOnly: boolean
1060
- maxBlocks: number | undefined
1061
- initialValue: PortableTextBlock[] | undefined
1062
- }
1063
- readonly on: {
1064
- readonly 'add behavior': {
1065
- readonly actions: 'add behavior to context'
1066
- }
1067
- readonly 'remove behavior': {
1068
- readonly actions: 'remove behavior from context'
1069
- }
1070
- readonly 'update maxBlocks': {
1071
- readonly actions: ActionFunction<
1072
- {
1073
- behaviors: Set<BehaviorConfig>
1074
- converters: Set<Converter>
1075
- getLegacySchema: () => PortableTextMemberSchemaTypes
1076
- keyGenerator: () => string
1077
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1078
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1079
- schema: EditorSchema
1080
- initialReadOnly: boolean
1081
- maxBlocks: number | undefined
1082
- selection: EditorSelection
1083
- initialValue: Array<PortableTextBlock> | undefined
1084
- internalDrag?: {
1085
- ghost?: HTMLElement
1086
- origin: Pick<EventPosition, 'selection'>
1087
- }
1088
- slateEditor?: PortableTextSlateEditor
1089
- },
1090
- {
1091
- type: 'update maxBlocks'
1092
- maxBlocks: number | undefined
1093
- },
1094
- | InternalPatchEvent
1095
- | MutationEvent
1096
- | PatchesEvent
1097
- | {
1098
- type: 'update readOnly'
1099
- readOnly: boolean
1100
- }
1101
- | {
1102
- type: 'update maxBlocks'
1103
- maxBlocks: number | undefined
1104
- }
1105
- | {
1106
- type: 'add behavior'
1107
- behaviorConfig: BehaviorConfig
1108
- }
1109
- | {
1110
- type: 'remove behavior'
1111
- behaviorConfig: BehaviorConfig
1112
- }
1113
- | {
1114
- type: 'blur'
1115
- editor: PortableTextSlateEditor
1116
- }
1117
- | {
1118
- type: 'focus'
1119
- editor: PortableTextSlateEditor
1120
- }
1121
- | {
1122
- type: 'normalizing'
1123
- }
1124
- | {
1125
- type: 'update selection'
1126
- selection: EditorSelection
1127
- }
1128
- | {
1129
- type: 'done normalizing'
1130
- }
1131
- | {
1132
- type: 'done syncing value'
1133
- }
1134
- | {
1135
- type: 'syncing value'
1136
- }
1137
- | {
1138
- type: 'behavior event'
1139
- behaviorEvent: BehaviorEvent
1140
- editor: PortableTextSlateEditor
1141
- nativeEvent?: {
1142
- preventDefault: () => void
1143
- }
1144
- }
1145
- | {
1146
- type: 'dragstart'
1147
- origin: Pick<EventPosition, 'selection'>
1148
- ghost?: HTMLElement
1149
- }
1150
- | {
1151
- type: 'dragend'
1152
- }
1153
- | {
1154
- type: 'drop'
1155
- },
1156
- undefined,
1157
- never,
1158
- never,
1159
- never,
1160
- never,
1161
- never
1162
- >
1163
- }
1164
- readonly 'update selection': {
1165
- readonly actions: readonly [
1166
- ActionFunction<
1167
- {
1168
- behaviors: Set<BehaviorConfig>
1169
- converters: Set<Converter>
1170
- getLegacySchema: () => PortableTextMemberSchemaTypes
1171
- keyGenerator: () => string
1172
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1173
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1174
- schema: EditorSchema
1175
- initialReadOnly: boolean
1176
- maxBlocks: number | undefined
1177
- selection: EditorSelection
1178
- initialValue: Array<PortableTextBlock> | undefined
1179
- internalDrag?: {
1180
- ghost?: HTMLElement
1181
- origin: Pick<EventPosition, 'selection'>
1182
- }
1183
- slateEditor?: PortableTextSlateEditor
1184
- },
1185
- {
1186
- type: 'update selection'
1187
- selection: EditorSelection
1188
- },
1189
- | InternalPatchEvent
1190
- | MutationEvent
1191
- | PatchesEvent
1192
- | {
1193
- type: 'update readOnly'
1194
- readOnly: boolean
1195
- }
1196
- | {
1197
- type: 'update maxBlocks'
1198
- maxBlocks: number | undefined
1199
- }
1200
- | {
1201
- type: 'add behavior'
1202
- behaviorConfig: BehaviorConfig
1203
- }
1204
- | {
1205
- type: 'remove behavior'
1206
- behaviorConfig: BehaviorConfig
1207
- }
1208
- | {
1209
- type: 'blur'
1210
- editor: PortableTextSlateEditor
1211
- }
1212
- | {
1213
- type: 'focus'
1214
- editor: PortableTextSlateEditor
1215
- }
1216
- | {
1217
- type: 'normalizing'
1218
- }
1219
- | {
1220
- type: 'update selection'
1221
- selection: EditorSelection
1222
- }
1223
- | {
1224
- type: 'done normalizing'
1225
- }
1226
- | {
1227
- type: 'done syncing value'
1228
- }
1229
- | {
1230
- type: 'syncing value'
1231
- }
1232
- | {
1233
- type: 'behavior event'
1234
- behaviorEvent: BehaviorEvent
1235
- editor: PortableTextSlateEditor
1236
- nativeEvent?: {
1237
- preventDefault: () => void
1238
- }
1239
- }
1240
- | {
1241
- type: 'dragstart'
1242
- origin: Pick<EventPosition, 'selection'>
1243
- ghost?: HTMLElement
1244
- }
1245
- | {
1246
- type: 'dragend'
1247
- }
1248
- | {
1249
- type: 'drop'
1250
- },
1251
- undefined,
1252
- never,
1253
- never,
1254
- never,
1255
- never,
1256
- never
1257
- >,
1258
- ActionFunction<
1259
- {
1260
- behaviors: Set<BehaviorConfig>
1261
- converters: Set<Converter>
1262
- getLegacySchema: () => PortableTextMemberSchemaTypes
1263
- keyGenerator: () => string
1264
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1265
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1266
- schema: EditorSchema
1267
- initialReadOnly: boolean
1268
- maxBlocks: number | undefined
1269
- selection: EditorSelection
1270
- initialValue: Array<PortableTextBlock> | undefined
1271
- internalDrag?: {
1272
- ghost?: HTMLElement
1273
- origin: Pick<EventPosition, 'selection'>
1274
- }
1275
- slateEditor?: PortableTextSlateEditor
1276
- },
1277
- {
1278
- type: 'update selection'
1279
- selection: EditorSelection
1280
- },
1281
- | InternalPatchEvent
1282
- | MutationEvent
1283
- | PatchesEvent
1284
- | {
1285
- type: 'update readOnly'
1286
- readOnly: boolean
1287
- }
1288
- | {
1289
- type: 'update maxBlocks'
1290
- maxBlocks: number | undefined
1291
- }
1292
- | {
1293
- type: 'add behavior'
1294
- behaviorConfig: BehaviorConfig
1295
- }
1296
- | {
1297
- type: 'remove behavior'
1298
- behaviorConfig: BehaviorConfig
1299
- }
1300
- | {
1301
- type: 'blur'
1302
- editor: PortableTextSlateEditor
1303
- }
1304
- | {
1305
- type: 'focus'
1306
- editor: PortableTextSlateEditor
1307
- }
1308
- | {
1309
- type: 'normalizing'
1310
- }
1311
- | {
1312
- type: 'update selection'
1313
- selection: EditorSelection
1314
- }
1315
- | {
1316
- type: 'done normalizing'
1317
- }
1318
- | {
1319
- type: 'done syncing value'
1320
- }
1321
- | {
1322
- type: 'syncing value'
1323
- }
1324
- | {
1325
- type: 'behavior event'
1326
- behaviorEvent: BehaviorEvent
1327
- editor: PortableTextSlateEditor
1328
- nativeEvent?: {
1329
- preventDefault: () => void
1330
- }
1331
- }
1332
- | {
1333
- type: 'dragstart'
1334
- origin: Pick<EventPosition, 'selection'>
1335
- ghost?: HTMLElement
1336
- }
1337
- | {
1338
- type: 'dragend'
1339
- }
1340
- | {
1341
- type: 'drop'
1342
- },
1343
- undefined,
1344
- never,
1345
- never,
1346
- never,
1347
- never,
1348
- | InternalPatchEvent
1349
- | MutationEvent
1350
- | PatchesEvent
1351
- | {
1352
- type: 'blurred'
1353
- event: FocusEvent_2<HTMLDivElement, Element>
1354
- }
1355
- | {
1356
- type: 'done loading'
1357
- }
1358
- | {
1359
- type: 'editable'
1360
- }
1361
- | {
1362
- type: 'error'
1363
- name: string
1364
- description: string
1365
- data: unknown
1366
- }
1367
- | {
1368
- type: 'focused'
1369
- event: FocusEvent_2<HTMLDivElement, Element>
1370
- }
1371
- | {
1372
- type: 'invalid value'
1373
- resolution: InvalidValueResolution | null
1374
- value: Array<PortableTextBlock> | undefined
1375
- }
1376
- | {
1377
- type: 'loading'
1378
- }
1379
- | {
1380
- type: 'read only'
1381
- }
1382
- | {
1383
- type: 'ready'
1384
- }
1385
- | {
1386
- type: 'selection'
1387
- selection: EditorSelection
1388
- }
1389
- | {
1390
- type: 'value changed'
1391
- value: Array<PortableTextBlock> | undefined
1392
- }
1393
- >,
1394
- ]
1395
- }
1396
- }
1397
- readonly type: 'parallel'
1398
- readonly states: {
1399
- readonly 'edit mode': {
1400
- readonly initial: 'read only'
1401
- readonly states: {
1402
- readonly 'read only': {
1403
- readonly initial: 'determine initial edit mode'
1404
- readonly on: {
1405
- readonly 'behavior event': {
1406
- readonly actions: 'handle behavior event'
1407
- readonly guard: ({
1408
- event,
1409
- }: GuardArgs<
1410
- {
1411
- behaviors: Set<BehaviorConfig>
1412
- converters: Set<Converter>
1413
- getLegacySchema: () => PortableTextMemberSchemaTypes
1414
- keyGenerator: () => string
1415
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1416
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1417
- schema: EditorSchema
1418
- initialReadOnly: boolean
1419
- maxBlocks: number | undefined
1420
- selection: EditorSelection
1421
- initialValue: Array<PortableTextBlock> | undefined
1422
- internalDrag?: {
1423
- ghost?: HTMLElement
1424
- origin: Pick<EventPosition, 'selection'>
1425
- }
1426
- slateEditor?: PortableTextSlateEditor
1427
- },
1428
- {
1429
- type: 'behavior event'
1430
- behaviorEvent: BehaviorEvent
1431
- editor: PortableTextSlateEditor
1432
- nativeEvent?: {
1433
- preventDefault: () => void
1434
- }
1435
- }
1436
- >) => boolean
1437
- }
1438
- }
1439
- readonly states: {
1440
- readonly 'determine initial edit mode': {
1441
- readonly entry: readonly [() => void]
1442
- readonly exit: readonly [() => void]
1443
- readonly on: {
1444
- readonly 'done syncing value': readonly [
1445
- {
1446
- readonly target: '#editor.edit mode.read only.read only'
1447
- readonly guard: ({
1448
- context,
1449
- }: GuardArgs<
1450
- {
1451
- behaviors: Set<BehaviorConfig>
1452
- converters: Set<Converter>
1453
- getLegacySchema: () => PortableTextMemberSchemaTypes
1454
- keyGenerator: () => string
1455
- pendingEvents: Array<
1456
- InternalPatchEvent | MutationEvent
1457
- >
1458
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1459
- schema: EditorSchema
1460
- initialReadOnly: boolean
1461
- maxBlocks: number | undefined
1462
- selection: EditorSelection
1463
- initialValue: Array<PortableTextBlock> | undefined
1464
- internalDrag?: {
1465
- ghost?: HTMLElement
1466
- origin: Pick<EventPosition, 'selection'>
1467
- }
1468
- slateEditor?: PortableTextSlateEditor
1469
- },
1470
- {
1471
- type: 'done syncing value'
1472
- }
1473
- >) => boolean
1474
- },
1475
- {
1476
- readonly target: '#editor.edit mode.editable'
1477
- },
1478
- ]
1479
- }
1480
- }
1481
- readonly 'read only': {
1482
- readonly entry: readonly [() => void]
1483
- readonly exit: readonly [() => void]
1484
- readonly on: {
1485
- readonly 'update readOnly': {
1486
- readonly guard: ({
1487
- event,
1488
- }: GuardArgs<
1489
- {
1490
- behaviors: Set<BehaviorConfig>
1491
- converters: Set<Converter>
1492
- getLegacySchema: () => PortableTextMemberSchemaTypes
1493
- keyGenerator: () => string
1494
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1495
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1496
- schema: EditorSchema
1497
- initialReadOnly: boolean
1498
- maxBlocks: number | undefined
1499
- selection: EditorSelection
1500
- initialValue: Array<PortableTextBlock> | undefined
1501
- internalDrag?: {
1502
- ghost?: HTMLElement
1503
- origin: Pick<EventPosition, 'selection'>
1504
- }
1505
- slateEditor?: PortableTextSlateEditor
1506
- },
1507
- {
1508
- type: 'update readOnly'
1509
- readOnly: boolean
1510
- }
1511
- >) => boolean
1512
- readonly target: '#editor.edit mode.editable'
1513
- readonly actions: readonly ['emit editable']
1514
- }
1515
- }
1516
- }
1517
- }
1518
- }
1519
- readonly 'editable': {
1520
- readonly on: {
1521
- readonly 'update readOnly': {
1522
- readonly guard: ({
1523
- event,
1524
- }: GuardArgs<
1525
- {
1526
- behaviors: Set<BehaviorConfig>
1527
- converters: Set<Converter>
1528
- getLegacySchema: () => PortableTextMemberSchemaTypes
1529
- keyGenerator: () => string
1530
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1531
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1532
- schema: EditorSchema
1533
- initialReadOnly: boolean
1534
- maxBlocks: number | undefined
1535
- selection: EditorSelection
1536
- initialValue: Array<PortableTextBlock> | undefined
1537
- internalDrag?: {
1538
- ghost?: HTMLElement
1539
- origin: Pick<EventPosition, 'selection'>
1540
- }
1541
- slateEditor?: PortableTextSlateEditor
1542
- },
1543
- {
1544
- type: 'update readOnly'
1545
- readOnly: boolean
1546
- }
1547
- >) => boolean
1548
- readonly target: '#editor.edit mode.read only.read only'
1549
- readonly actions: readonly ['emit read only']
1550
- }
1551
- readonly 'behavior event': {
1552
- readonly actions: 'handle behavior event'
1553
- }
1554
- readonly 'blur': {
1555
- readonly actions: 'handle blur'
1556
- }
1557
- readonly 'focus': {
1558
- readonly target: '.focusing'
1559
- readonly actions: readonly [
1560
- ActionFunction<
1561
- {
1562
- behaviors: Set<BehaviorConfig>
1563
- converters: Set<Converter>
1564
- getLegacySchema: () => PortableTextMemberSchemaTypes
1565
- keyGenerator: () => string
1566
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1567
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1568
- schema: EditorSchema
1569
- initialReadOnly: boolean
1570
- maxBlocks: number | undefined
1571
- selection: EditorSelection
1572
- initialValue: Array<PortableTextBlock> | undefined
1573
- internalDrag?: {
1574
- ghost?: HTMLElement
1575
- origin: Pick<EventPosition, 'selection'>
1576
- }
1577
- slateEditor?: PortableTextSlateEditor
1578
- },
1579
- {
1580
- type: 'focus'
1581
- editor: PortableTextSlateEditor
1582
- },
1583
- | InternalPatchEvent
1584
- | MutationEvent
1585
- | PatchesEvent
1586
- | {
1587
- type: 'update readOnly'
1588
- readOnly: boolean
1589
- }
1590
- | {
1591
- type: 'update maxBlocks'
1592
- maxBlocks: number | undefined
1593
- }
1594
- | {
1595
- type: 'add behavior'
1596
- behaviorConfig: BehaviorConfig
1597
- }
1598
- | {
1599
- type: 'remove behavior'
1600
- behaviorConfig: BehaviorConfig
1601
- }
1602
- | {
1603
- type: 'blur'
1604
- editor: PortableTextSlateEditor
1605
- }
1606
- | {
1607
- type: 'focus'
1608
- editor: PortableTextSlateEditor
1609
- }
1610
- | {
1611
- type: 'normalizing'
1612
- }
1613
- | {
1614
- type: 'update selection'
1615
- selection: EditorSelection
1616
- }
1617
- | {
1618
- type: 'done normalizing'
1619
- }
1620
- | {
1621
- type: 'done syncing value'
1622
- }
1623
- | {
1624
- type: 'syncing value'
1625
- }
1626
- | {
1627
- type: 'behavior event'
1628
- behaviorEvent: BehaviorEvent
1629
- editor: PortableTextSlateEditor
1630
- nativeEvent?: {
1631
- preventDefault: () => void
1632
- }
1633
- }
1634
- | {
1635
- type: 'dragstart'
1636
- origin: Pick<EventPosition, 'selection'>
1637
- ghost?: HTMLElement
1638
- }
1639
- | {
1640
- type: 'dragend'
1641
- }
1642
- | {
1643
- type: 'drop'
1644
- },
1645
- undefined,
1646
- never,
1647
- never,
1648
- never,
1649
- never,
1650
- never
1651
- >,
1652
- ]
1653
- }
1654
- }
1655
- readonly initial: 'idle'
1656
- readonly states: {
1657
- readonly 'idle': {
1658
- readonly entry: readonly [() => void]
1659
- readonly exit: readonly [() => void]
1660
- readonly on: {
1661
- readonly dragstart: {
1662
- readonly actions: readonly [
1663
- ActionFunction<
1664
- {
1665
- behaviors: Set<BehaviorConfig>
1666
- converters: Set<Converter>
1667
- getLegacySchema: () => PortableTextMemberSchemaTypes
1668
- keyGenerator: () => string
1669
- pendingEvents: Array<
1670
- InternalPatchEvent | MutationEvent
1671
- >
1672
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1673
- schema: EditorSchema
1674
- initialReadOnly: boolean
1675
- maxBlocks: number | undefined
1676
- selection: EditorSelection
1677
- initialValue: Array<PortableTextBlock> | undefined
1678
- internalDrag?: {
1679
- ghost?: HTMLElement
1680
- origin: Pick<EventPosition, 'selection'>
1681
- }
1682
- slateEditor?: PortableTextSlateEditor
1683
- },
1684
- {
1685
- type: 'dragstart'
1686
- origin: Pick<EventPosition, 'selection'>
1687
- ghost?: HTMLElement
1688
- },
1689
- | InternalPatchEvent
1690
- | MutationEvent
1691
- | PatchesEvent
1692
- | {
1693
- type: 'update readOnly'
1694
- readOnly: boolean
1695
- }
1696
- | {
1697
- type: 'update maxBlocks'
1698
- maxBlocks: number | undefined
1699
- }
1700
- | {
1701
- type: 'add behavior'
1702
- behaviorConfig: BehaviorConfig
1703
- }
1704
- | {
1705
- type: 'remove behavior'
1706
- behaviorConfig: BehaviorConfig
1707
- }
1708
- | {
1709
- type: 'blur'
1710
- editor: PortableTextSlateEditor
1711
- }
1712
- | {
1713
- type: 'focus'
1714
- editor: PortableTextSlateEditor
1715
- }
1716
- | {
1717
- type: 'normalizing'
1718
- }
1719
- | {
1720
- type: 'update selection'
1721
- selection: EditorSelection
1722
- }
1723
- | {
1724
- type: 'done normalizing'
1725
- }
1726
- | {
1727
- type: 'done syncing value'
1728
- }
1729
- | {
1730
- type: 'syncing value'
1731
- }
1732
- | {
1733
- type: 'behavior event'
1734
- behaviorEvent: BehaviorEvent
1735
- editor: PortableTextSlateEditor
1736
- nativeEvent?: {
1737
- preventDefault: () => void
1738
- }
1739
- }
1740
- | {
1741
- type: 'dragstart'
1742
- origin: Pick<EventPosition, 'selection'>
1743
- ghost?: HTMLElement
1744
- }
1745
- | {
1746
- type: 'dragend'
1747
- }
1748
- | {
1749
- type: 'drop'
1750
- },
1751
- undefined,
1752
- never,
1753
- never,
1754
- never,
1755
- never,
1756
- never
1757
- >,
1758
- ]
1759
- readonly target: 'dragging internally'
1760
- }
1761
- }
1762
- }
1763
- readonly 'focusing': {
1764
- readonly initial: 'checking if busy'
1765
- readonly states: {
1766
- readonly 'checking if busy': {
1767
- readonly entry: readonly [() => void]
1768
- readonly exit: readonly [() => void]
1769
- readonly always: readonly [
1770
- {
1771
- readonly guard: 'slate is busy'
1772
- readonly target: 'busy'
1773
- },
1774
- {
1775
- readonly target: '#editor.edit mode.editable.idle'
1776
- readonly actions: readonly ['handle focus']
1777
- },
1778
- ]
1779
- }
1780
- readonly 'busy': {
1781
- readonly entry: readonly [() => void]
1782
- readonly exit: readonly [() => void]
1783
- readonly after: {
1784
- readonly 10: {
1785
- readonly target: 'checking if busy'
1786
- }
1787
- }
1788
- }
1789
- }
1790
- }
1791
- readonly 'dragging internally': {
1792
- readonly entry: readonly [() => void]
1793
- readonly exit: readonly [
1794
- () => void,
1795
- ({
1796
- context,
1797
- }: ActionArgs<
1798
- {
1799
- behaviors: Set<BehaviorConfig>
1800
- converters: Set<Converter>
1801
- getLegacySchema: () => PortableTextMemberSchemaTypes
1802
- keyGenerator: () => string
1803
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1804
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1805
- schema: EditorSchema
1806
- initialReadOnly: boolean
1807
- maxBlocks: number | undefined
1808
- selection: EditorSelection
1809
- initialValue: Array<PortableTextBlock> | undefined
1810
- internalDrag?: {
1811
- ghost?: HTMLElement
1812
- origin: Pick<EventPosition, 'selection'>
1813
- }
1814
- slateEditor?: PortableTextSlateEditor
1815
- },
1816
- | InternalPatchEvent
1817
- | MutationEvent
1818
- | PatchesEvent
1819
- | {
1820
- type: 'update readOnly'
1821
- readOnly: boolean
1822
- }
1823
- | {
1824
- type: 'update maxBlocks'
1825
- maxBlocks: number | undefined
1826
- }
1827
- | {
1828
- type: 'add behavior'
1829
- behaviorConfig: BehaviorConfig
1830
- }
1831
- | {
1832
- type: 'remove behavior'
1833
- behaviorConfig: BehaviorConfig
1834
- }
1835
- | {
1836
- type: 'blur'
1837
- editor: PortableTextSlateEditor
1838
- }
1839
- | {
1840
- type: 'focus'
1841
- editor: PortableTextSlateEditor
1842
- }
1843
- | {
1844
- type: 'normalizing'
1845
- }
1846
- | {
1847
- type: 'update selection'
1848
- selection: EditorSelection
1849
- }
1850
- | {
1851
- type: 'done normalizing'
1852
- }
1853
- | {
1854
- type: 'done syncing value'
1855
- }
1856
- | {
1857
- type: 'syncing value'
1858
- }
1859
- | {
1860
- type: 'behavior event'
1861
- behaviorEvent: BehaviorEvent
1862
- editor: PortableTextSlateEditor
1863
- nativeEvent?: {
1864
- preventDefault: () => void
1865
- }
1866
- }
1867
- | {
1868
- type: 'dragstart'
1869
- origin: Pick<EventPosition, 'selection'>
1870
- ghost?: HTMLElement
1871
- }
1872
- | {
1873
- type: 'dragend'
1874
- }
1875
- | {
1876
- type: 'drop'
1877
- },
1878
- | InternalPatchEvent
1879
- | MutationEvent
1880
- | PatchesEvent
1881
- | {
1882
- type: 'update readOnly'
1883
- readOnly: boolean
1884
- }
1885
- | {
1886
- type: 'update maxBlocks'
1887
- maxBlocks: number | undefined
1888
- }
1889
- | {
1890
- type: 'add behavior'
1891
- behaviorConfig: BehaviorConfig
1892
- }
1893
- | {
1894
- type: 'remove behavior'
1895
- behaviorConfig: BehaviorConfig
1896
- }
1897
- | {
1898
- type: 'blur'
1899
- editor: PortableTextSlateEditor
1900
- }
1901
- | {
1902
- type: 'focus'
1903
- editor: PortableTextSlateEditor
1904
- }
1905
- | {
1906
- type: 'normalizing'
1907
- }
1908
- | {
1909
- type: 'update selection'
1910
- selection: EditorSelection
1911
- }
1912
- | {
1913
- type: 'done normalizing'
1914
- }
1915
- | {
1916
- type: 'done syncing value'
1917
- }
1918
- | {
1919
- type: 'syncing value'
1920
- }
1921
- | {
1922
- type: 'behavior event'
1923
- behaviorEvent: BehaviorEvent
1924
- editor: PortableTextSlateEditor
1925
- nativeEvent?: {
1926
- preventDefault: () => void
1927
- }
1928
- }
1929
- | {
1930
- type: 'dragstart'
1931
- origin: Pick<EventPosition, 'selection'>
1932
- ghost?: HTMLElement
1933
- }
1934
- | {
1935
- type: 'dragend'
1936
- }
1937
- | {
1938
- type: 'drop'
1939
- }
1940
- >) => void,
1941
- ActionFunction<
1942
- {
1943
- behaviors: Set<BehaviorConfig>
1944
- converters: Set<Converter>
1945
- getLegacySchema: () => PortableTextMemberSchemaTypes
1946
- keyGenerator: () => string
1947
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1948
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1949
- schema: EditorSchema
1950
- initialReadOnly: boolean
1951
- maxBlocks: number | undefined
1952
- selection: EditorSelection
1953
- initialValue: Array<PortableTextBlock> | undefined
1954
- internalDrag?: {
1955
- ghost?: HTMLElement
1956
- origin: Pick<EventPosition, 'selection'>
1957
- }
1958
- slateEditor?: PortableTextSlateEditor
1959
- },
1960
- | InternalPatchEvent
1961
- | MutationEvent
1962
- | PatchesEvent
1963
- | {
1964
- type: 'update readOnly'
1965
- readOnly: boolean
1966
- }
1967
- | {
1968
- type: 'update maxBlocks'
1969
- maxBlocks: number | undefined
1970
- }
1971
- | {
1972
- type: 'add behavior'
1973
- behaviorConfig: BehaviorConfig
1974
- }
1975
- | {
1976
- type: 'remove behavior'
1977
- behaviorConfig: BehaviorConfig
1978
- }
1979
- | {
1980
- type: 'blur'
1981
- editor: PortableTextSlateEditor
1982
- }
1983
- | {
1984
- type: 'focus'
1985
- editor: PortableTextSlateEditor
1986
- }
1987
- | {
1988
- type: 'normalizing'
1989
- }
1990
- | {
1991
- type: 'update selection'
1992
- selection: EditorSelection
1993
- }
1994
- | {
1995
- type: 'done normalizing'
1996
- }
1997
- | {
1998
- type: 'done syncing value'
1999
- }
2000
- | {
2001
- type: 'syncing value'
2002
- }
2003
- | {
2004
- type: 'behavior event'
2005
- behaviorEvent: BehaviorEvent
2006
- editor: PortableTextSlateEditor
2007
- nativeEvent?: {
2008
- preventDefault: () => void
2009
- }
2010
- }
2011
- | {
2012
- type: 'dragstart'
2013
- origin: Pick<EventPosition, 'selection'>
2014
- ghost?: HTMLElement
2015
- }
2016
- | {
2017
- type: 'dragend'
2018
- }
2019
- | {
2020
- type: 'drop'
2021
- },
2022
- | InternalPatchEvent
2023
- | MutationEvent
2024
- | PatchesEvent
2025
- | {
2026
- type: 'update readOnly'
2027
- readOnly: boolean
2028
- }
2029
- | {
2030
- type: 'update maxBlocks'
2031
- maxBlocks: number | undefined
2032
- }
2033
- | {
2034
- type: 'add behavior'
2035
- behaviorConfig: BehaviorConfig
2036
- }
2037
- | {
2038
- type: 'remove behavior'
2039
- behaviorConfig: BehaviorConfig
2040
- }
2041
- | {
2042
- type: 'blur'
2043
- editor: PortableTextSlateEditor
2044
- }
2045
- | {
2046
- type: 'focus'
2047
- editor: PortableTextSlateEditor
2048
- }
2049
- | {
2050
- type: 'normalizing'
2051
- }
2052
- | {
2053
- type: 'update selection'
2054
- selection: EditorSelection
2055
- }
2056
- | {
2057
- type: 'done normalizing'
2058
- }
2059
- | {
2060
- type: 'done syncing value'
2061
- }
2062
- | {
2063
- type: 'syncing value'
2064
- }
2065
- | {
2066
- type: 'behavior event'
2067
- behaviorEvent: BehaviorEvent
2068
- editor: PortableTextSlateEditor
2069
- nativeEvent?: {
2070
- preventDefault: () => void
2071
- }
2072
- }
2073
- | {
2074
- type: 'dragstart'
2075
- origin: Pick<EventPosition, 'selection'>
2076
- ghost?: HTMLElement
2077
- }
2078
- | {
2079
- type: 'dragend'
2080
- }
2081
- | {
2082
- type: 'drop'
2083
- },
2084
- undefined,
2085
- never,
2086
- never,
2087
- never,
2088
- never,
2089
- never
2090
- >,
2091
- ]
2092
- readonly tags: readonly ['dragging internally']
2093
- readonly on: {
2094
- readonly dragend: {
2095
- readonly target: 'idle'
2096
- }
2097
- readonly drop: {
2098
- readonly target: 'idle'
2099
- }
2100
- }
2101
- }
2102
- }
2103
- }
2104
- }
2105
- }
2106
- readonly 'setup': {
2107
- readonly initial: 'setting up'
2108
- readonly states: {
2109
- readonly 'setting up': {
2110
- readonly entry: readonly [() => void]
2111
- readonly exit: readonly [
2112
- () => void,
2113
- 'emit ready',
2114
- 'emit pending incoming patches',
2115
- 'clear pending incoming patches',
2116
- ]
2117
- readonly on: {
2118
- readonly 'internal.patch': {
2119
- readonly actions: 'defer event'
2120
- }
2121
- readonly 'mutation': {
2122
- readonly actions: 'defer event'
2123
- }
2124
- readonly 'done syncing value': {
2125
- readonly target: 'set up'
2126
- }
2127
- readonly 'patches': {
2128
- readonly actions: readonly ['defer incoming patches']
2129
- }
2130
- }
2131
- }
2132
- readonly 'set up': {
2133
- readonly type: 'parallel'
2134
- readonly states: {
2135
- readonly 'value sync': {
2136
- readonly initial: 'idle'
2137
- readonly states: {
2138
- readonly 'idle': {
2139
- readonly entry: readonly [() => void]
2140
- readonly exit: readonly [() => void]
2141
- readonly on: {
2142
- readonly 'patches': {
2143
- readonly actions: readonly [
2144
- ActionFunction<
2145
- {
2146
- behaviors: Set<BehaviorConfig>
2147
- converters: Set<Converter>
2148
- getLegacySchema: () => PortableTextMemberSchemaTypes
2149
- keyGenerator: () => string
2150
- pendingEvents: Array<
2151
- InternalPatchEvent | MutationEvent
2152
- >
2153
- pendingIncomingPatchesEvents: Array<PatchesEvent>
2154
- schema: EditorSchema
2155
- initialReadOnly: boolean
2156
- maxBlocks: number | undefined
2157
- selection: EditorSelection
2158
- initialValue: Array<PortableTextBlock> | undefined
2159
- internalDrag?: {
2160
- ghost?: HTMLElement
2161
- origin: Pick<EventPosition, 'selection'>
2162
- }
2163
- slateEditor?: PortableTextSlateEditor
2164
- },
2165
- PatchesEvent,
2166
- | InternalPatchEvent
2167
- | MutationEvent
2168
- | PatchesEvent
2169
- | {
2170
- type: 'update readOnly'
2171
- readOnly: boolean
2172
- }
2173
- | {
2174
- type: 'update maxBlocks'
2175
- maxBlocks: number | undefined
2176
- }
2177
- | {
2178
- type: 'add behavior'
2179
- behaviorConfig: BehaviorConfig
2180
- }
2181
- | {
2182
- type: 'remove behavior'
2183
- behaviorConfig: BehaviorConfig
2184
- }
2185
- | {
2186
- type: 'blur'
2187
- editor: PortableTextSlateEditor
2188
- }
2189
- | {
2190
- type: 'focus'
2191
- editor: PortableTextSlateEditor
2192
- }
2193
- | {
2194
- type: 'normalizing'
2195
- }
2196
- | {
2197
- type: 'update selection'
2198
- selection: EditorSelection
2199
- }
2200
- | {
2201
- type: 'done normalizing'
2202
- }
2203
- | {
2204
- type: 'done syncing value'
2205
- }
2206
- | {
2207
- type: 'syncing value'
2208
- }
2209
- | {
2210
- type: 'behavior event'
2211
- behaviorEvent: BehaviorEvent
2212
- editor: PortableTextSlateEditor
2213
- nativeEvent?: {
2214
- preventDefault: () => void
2215
- }
2216
- }
2217
- | {
2218
- type: 'dragstart'
2219
- origin: Pick<EventPosition, 'selection'>
2220
- ghost?: HTMLElement
2221
- }
2222
- | {
2223
- type: 'dragend'
2224
- }
2225
- | {
2226
- type: 'drop'
2227
- },
2228
- undefined,
2229
- never,
2230
- never,
2231
- never,
2232
- never,
2233
- | InternalPatchEvent
2234
- | MutationEvent
2235
- | PatchesEvent
2236
- | {
2237
- type: 'blurred'
2238
- event: FocusEvent_2<HTMLDivElement, Element>
2239
- }
2240
- | {
2241
- type: 'done loading'
2242
- }
2243
- | {
2244
- type: 'editable'
2245
- }
2246
- | {
2247
- type: 'error'
2248
- name: string
2249
- description: string
2250
- data: unknown
2251
- }
2252
- | {
2253
- type: 'focused'
2254
- event: FocusEvent_2<HTMLDivElement, Element>
2255
- }
2256
- | {
2257
- type: 'invalid value'
2258
- resolution: InvalidValueResolution | null
2259
- value: Array<PortableTextBlock> | undefined
2260
- }
2261
- | {
2262
- type: 'loading'
2263
- }
2264
- | {
2265
- type: 'read only'
2266
- }
2267
- | {
2268
- type: 'ready'
2269
- }
2270
- | {
2271
- type: 'selection'
2272
- selection: EditorSelection
2273
- }
2274
- | {
2275
- type: 'value changed'
2276
- value: Array<PortableTextBlock> | undefined
2277
- }
2278
- >,
2279
- ]
2280
- }
2281
- readonly 'syncing value': {
2282
- readonly target: 'syncing value'
2283
- }
2284
- }
2285
- }
2286
- readonly 'syncing value': {
2287
- readonly entry: readonly [() => void]
2288
- readonly exit: readonly [
2289
- () => void,
2290
- 'emit pending incoming patches',
2291
- 'clear pending incoming patches',
2292
- ]
2293
- readonly on: {
2294
- readonly 'patches': {
2295
- readonly actions: readonly ['defer incoming patches']
2296
- }
2297
- readonly 'done syncing value': {
2298
- readonly target: 'idle'
2299
- }
2300
- }
2301
- }
2302
- }
2303
- }
2304
- readonly 'writing': {
2305
- readonly initial: 'pristine'
2306
- readonly states: {
2307
- readonly pristine: {
2308
- readonly initial: 'idle'
2309
- readonly states: {
2310
- readonly idle: {
2311
- readonly entry: readonly [() => void]
2312
- readonly exit: readonly [() => void]
2313
- readonly on: {
2314
- readonly 'normalizing': {
2315
- readonly target: 'normalizing'
2316
- }
2317
- readonly 'internal.patch': {
2318
- readonly actions: 'defer event'
2319
- readonly target: '#editor.setup.set up.writing.dirty'
2320
- }
2321
- readonly 'mutation': {
2322
- readonly actions: 'defer event'
2323
- readonly target: '#editor.setup.set up.writing.dirty'
2324
- }
2325
- }
2326
- }
2327
- readonly normalizing: {
2328
- readonly entry: readonly [() => void]
2329
- readonly exit: readonly [() => void]
2330
- readonly on: {
2331
- readonly 'done normalizing': {
2332
- readonly target: 'idle'
2333
- }
2334
- readonly 'internal.patch': {
2335
- readonly actions: 'defer event'
2336
- }
2337
- readonly 'mutation': {
2338
- readonly actions: 'defer event'
2339
- }
2340
- }
2341
- }
2342
- }
2343
- }
2344
- readonly dirty: {
2345
- readonly entry: readonly [
2346
- () => void,
2347
- 'emit pending events',
2348
- 'clear pending events',
2349
- ]
2350
- readonly exit: readonly [() => void]
2351
- readonly on: {
2352
- readonly 'internal.patch': {
2353
- readonly actions: 'emit patch event'
2354
- }
2355
- readonly 'mutation': {
2356
- readonly actions: 'emit mutation event'
2357
- }
2358
- }
2359
- }
2360
- }
2361
- }
2362
- }
2363
- }
2364
- }
2365
- }
2366
- }
2367
- }
2368
- >
2369
-
2370
- declare type EditorPriority = {
2371
- id: string
2372
- name?: string
2373
- reference?: {
2374
- priority: EditorPriority
2375
- importance: 'higher' | 'lower'
2376
- }
493
+ declare type EditorDom = {
494
+ getBlockNodes: (snapshot: EditorSnapshot) => Array<Node>
495
+ getChildNodes: (snapshot: EditorSnapshot) => Array<Node>
496
+ /**
497
+ * Let the Editor set the drag ghost. This is to be sure that it will get
498
+ * properly removed again when the drag ends.
499
+ */
500
+ setDragGhost: ({
501
+ event,
502
+ ghost,
503
+ }: {
504
+ event: PickFromUnion<BehaviorEvent, 'type', 'drag.dragstart'>
505
+ ghost: {
506
+ element: HTMLElement
507
+ x: number
508
+ y: number
509
+ }
510
+ }) => void
2377
511
  }
2378
512
 
2379
513
  /**
@@ -2464,12 +598,6 @@ declare type EditorSnapshot = {
2464
598
  beta: {
2465
599
  activeAnnotations: Array<string>
2466
600
  activeDecorators: Array<string>
2467
- hasTag: HasTag
2468
- internalDrag:
2469
- | {
2470
- origin: Pick<EventPosition, 'selection'>
2471
- }
2472
- | undefined
2473
601
  }
2474
602
  }
2475
603
 
@@ -2506,18 +634,6 @@ export declare function forward(
2506
634
  event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent,
2507
635
  ): PickFromUnion<BehaviorAction, 'type', 'forward'>
2508
636
 
2509
- declare type HasTag = ReturnType<EditorActor['getSnapshot']>['hasTag']
2510
-
2511
- declare interface History_2 {
2512
- redos: HistoryItem[]
2513
- undos: HistoryItem[]
2514
- }
2515
-
2516
- declare type HistoryItem = {
2517
- operations: Operation[]
2518
- timestamp: Date
2519
- }
2520
-
2521
637
  /**
2522
638
  * Used to represent native InputEvents that hold a DataTransfer object.
2523
639
  *
@@ -2538,11 +654,6 @@ declare type InputBehaviorEvent = {
2538
654
 
2539
655
  declare type InsertPlacement = 'auto' | 'after' | 'before'
2540
656
 
2541
- declare type InternalPatchEvent = NamespaceEvent<PatchEvent, 'internal'> & {
2542
- operationId?: string
2543
- value: Array<PortableTextBlock>
2544
- }
2545
-
2546
657
  declare type KeyboardBehaviorEvent =
2547
658
  | {
2548
659
  type: StrictExtract<NativeBehaviorEventType, 'keyboard.keydown'>
@@ -2559,11 +670,6 @@ declare type KeyboardBehaviorEvent =
2559
670
  >
2560
671
  }
2561
672
 
2562
- declare type MarkState = {
2563
- state: 'changed' | 'unchanged'
2564
- marks: Array<string>
2565
- }
2566
-
2567
673
  declare type MIMEType = `${string}/${string}`
2568
674
 
2569
675
  declare type MouseBehaviorEvent = {
@@ -2571,38 +677,12 @@ declare type MouseBehaviorEvent = {
2571
677
  position: EventPosition
2572
678
  }
2573
679
 
2574
- /**
2575
- * @public
2576
- */
2577
- declare type MutationEvent = {
2578
- type: 'mutation'
2579
- patches: Array<Patch>
2580
- /**
2581
- * @deprecated Use `value` instead
2582
- */
2583
- snapshot: Array<PortableTextBlock> | undefined
2584
- value: Array<PortableTextBlock> | undefined
2585
- }
2586
-
2587
680
  declare type NamespacedBehaviorEventType<
2588
681
  TNamespace extends BehaviorEventTypeNamespace | '',
2589
682
  > = TNamespace extends ''
2590
683
  ? BehaviorEvent['type']
2591
684
  : Extract<BehaviorEvent['type'], TNamespace | `${TNamespace}.${string}`>
2592
685
 
2593
- declare type NamespaceEvent<
2594
- TEvent,
2595
- TNamespace extends string,
2596
- > = TEvent extends {
2597
- type: infer TEventType
2598
- }
2599
- ? {
2600
- [K in keyof TEvent]: K extends 'type'
2601
- ? `${TNamespace}.${TEventType & string}`
2602
- : TEvent[K]
2603
- }
2604
- : never
2605
-
2606
686
  /**
2607
687
  * @beta
2608
688
  */
@@ -2642,20 +722,6 @@ declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
2642
722
  _key?: PortableTextObject['_key']
2643
723
  }
2644
724
 
2645
- /**
2646
- * @public
2647
- */
2648
- declare type PatchesEvent = {
2649
- type: 'patches'
2650
- patches: Array<Patch>
2651
- snapshot: Array<PortableTextBlock> | undefined
2652
- }
2653
-
2654
- declare type PatchEvent = {
2655
- type: 'patch'
2656
- patch: Patch
2657
- }
2658
-
2659
725
  /**
2660
726
  * @internal
2661
727
  */
@@ -2665,57 +731,6 @@ declare type PickFromUnion<
2665
731
  TPickedTags extends TUnion[TTagKey],
2666
732
  > = TUnion extends Record<TTagKey, TPickedTags> ? TUnion : never
2667
733
 
2668
- /** @beta */
2669
- declare type PortableTextMemberSchemaTypes = {
2670
- annotations: (ObjectSchemaType & {
2671
- i18nTitleKey?: string
2672
- })[]
2673
- block: ObjectSchemaType
2674
- blockObjects: ObjectSchemaType[]
2675
- decorators: BlockDecoratorDefinition[]
2676
- inlineObjects: ObjectSchemaType[]
2677
- portableText: ArraySchemaType<PortableTextBlock>
2678
- span: ObjectSchemaType
2679
- styles: BlockStyleDefinition[]
2680
- lists: BlockListDefinition[]
2681
- }
2682
-
2683
- declare interface PortableTextSlateEditor extends ReactEditor {
2684
- _key: 'editor'
2685
- _type: 'editor'
2686
- createPlaceholderBlock: () => Descendant
2687
- editable: EditableAPI
2688
- history: History_2
2689
- insertPortableTextData: (data: DataTransfer) => boolean
2690
- insertTextOrHTMLData: (data: DataTransfer) => boolean
2691
- isTextBlock: (value: unknown) => value is PortableTextTextBlock
2692
- isTextSpan: (value: unknown) => value is PortableTextSpan
2693
- isListBlock: (value: unknown) => value is PortableTextListBlock
2694
- value: Array<PortableTextBlock>
2695
- decoratorState: Record<string, boolean | undefined>
2696
- markState: MarkState | undefined
2697
- /**
2698
- * Use hotkeys
2699
- */
2700
- pteWithHotKeys: (event: KeyboardEvent_2<HTMLDivElement>) => void
2701
- /**
2702
- * Helper function that creates a text block
2703
- */
2704
- pteCreateTextBlock: (options: {
2705
- decorators: Array<string>
2706
- listItem?: string
2707
- level?: number
2708
- }) => Descendant
2709
- /**
2710
- * Undo
2711
- */
2712
- undo: () => void
2713
- /**
2714
- * Redo
2715
- */
2716
- redo: () => void
2717
- }
2718
-
2719
734
  /**
2720
735
  * @beta
2721
736
  */