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