@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,230 +1,11 @@
1
- import type {KeyedSegment as KeyedSegment_2, Patch} from '@portabletext/patches'
1
+ import type {KeyedSegment as KeyedSegment_2} from '@portabletext/patches'
2
+ import {KeyedSegment, PortableTextObject, PortableTextSpan} from '@sanity/types'
2
3
  import type {
3
- ArraySchemaType,
4
- BlockDecoratorDefinition,
5
- BlockListDefinition,
6
- BlockStyleDefinition,
7
- ObjectSchemaType,
8
4
  Path,
9
5
  PortableTextBlock,
10
- PortableTextChild,
11
6
  PortableTextListBlock,
12
7
  PortableTextTextBlock,
13
8
  } from '@sanity/types'
14
- import {KeyedSegment, PortableTextObject, PortableTextSpan} from '@sanity/types'
15
- import {FocusEvent as FocusEvent_2} from 'react'
16
- import type {KeyboardEvent as KeyboardEvent_2} from 'react'
17
- import type {Descendant, Operation} from 'slate'
18
- import type {DOMNode} from 'slate-dom'
19
- import type {ReactEditor} from 'slate-react'
20
- import {
21
- ActionArgs,
22
- ActionFunction,
23
- ActorRef,
24
- ActorRefFrom,
25
- ActorRefFromLogic,
26
- AnyActorLogic,
27
- AnyActorRef,
28
- AnyEventObject,
29
- ConditionalRequired,
30
- InputFrom,
31
- IsNotNever,
32
- MachineSnapshot,
33
- MetaObject,
34
- NonReducibleUnknown,
35
- RequiredLogicInput,
36
- StateMachine,
37
- StateValue,
38
- Values,
39
- } from 'xstate'
40
- import {GuardArgs} from 'xstate/guards'
41
- import {InvalidValueResolution} from '..'
42
-
43
- declare type AbstractBehaviorEvent =
44
- | {
45
- type: StrictExtract<SyntheticBehaviorEventType, 'annotation.toggle'>
46
- annotation: {
47
- name: string
48
- value: {
49
- [prop: string]: unknown
50
- }
51
- }
52
- }
53
- | {
54
- type: StrictExtract<SyntheticBehaviorEventType, 'decorator.toggle'>
55
- decorator: string
56
- at?: {
57
- anchor: BlockOffset
58
- focus: BlockOffset
59
- }
60
- }
61
- | {
62
- type: StrictExtract<SyntheticBehaviorEventType, 'delete.backward'>
63
- unit: 'character' | 'word' | 'line' | 'block'
64
- }
65
- | {
66
- type: StrictExtract<SyntheticBehaviorEventType, 'delete.block'>
67
- at: [KeyedSegment]
68
- }
69
- | {
70
- type: StrictExtract<SyntheticBehaviorEventType, 'delete.forward'>
71
- unit: 'character' | 'word' | 'line' | 'block'
72
- }
73
- | {
74
- type: StrictExtract<SyntheticBehaviorEventType, 'delete.text'>
75
- at: {
76
- anchor: BlockOffset
77
- focus: BlockOffset
78
- }
79
- }
80
- | {
81
- type: StrictExtract<SyntheticBehaviorEventType, 'deserialize'>
82
- originEvent:
83
- | PickFromUnion<
84
- NativeBehaviorEvent,
85
- 'type',
86
- 'drag.drop' | 'clipboard.paste'
87
- >
88
- | InputBehaviorEvent
89
- }
90
- | {
91
- type: StrictExtract<SyntheticBehaviorEventType, 'serialize'>
92
- originEvent: PickFromUnion<
93
- NativeBehaviorEvent,
94
- 'type',
95
- 'clipboard.copy' | 'clipboard.cut' | 'drag.dragstart'
96
- >
97
- }
98
- | {
99
- type: StrictExtract<SyntheticBehaviorEventType, 'deserialization.success'>
100
- mimeType: MIMEType
101
- data: Array<PortableTextBlock>
102
- originEvent:
103
- | PickFromUnion<
104
- NativeBehaviorEvent,
105
- 'type',
106
- 'drag.drop' | 'clipboard.paste'
107
- >
108
- | InputBehaviorEvent
109
- }
110
- | {
111
- type: StrictExtract<SyntheticBehaviorEventType, 'deserialization.failure'>
112
- mimeType: MIMEType
113
- reason: string
114
- originEvent:
115
- | PickFromUnion<
116
- NativeBehaviorEvent,
117
- 'type',
118
- 'drag.drop' | 'clipboard.paste'
119
- >
120
- | InputBehaviorEvent
121
- }
122
- | {
123
- type: StrictExtract<SyntheticBehaviorEventType, 'serialization.success'>
124
- mimeType: MIMEType
125
- data: string
126
- originEvent: PickFromUnion<
127
- NativeBehaviorEvent,
128
- 'type',
129
- 'clipboard.copy' | 'clipboard.cut' | 'drag.dragstart'
130
- >
131
- }
132
- | {
133
- type: StrictExtract<SyntheticBehaviorEventType, 'serialization.failure'>
134
- mimeType: MIMEType
135
- reason: string
136
- originEvent: PickFromUnion<
137
- NativeBehaviorEvent,
138
- 'type',
139
- 'clipboard.copy' | 'clipboard.cut' | 'drag.dragstart'
140
- >
141
- }
142
- | {
143
- type: StrictExtract<SyntheticBehaviorEventType, 'insert.blocks'>
144
- blocks: Array<BlockWithOptionalKey>
145
- placement: InsertPlacement
146
- }
147
- | {
148
- type: StrictExtract<SyntheticBehaviorEventType, 'insert.break'>
149
- }
150
- | {
151
- type: StrictExtract<SyntheticBehaviorEventType, 'insert.soft break'>
152
- }
153
- | {
154
- type: StrictExtract<SyntheticBehaviorEventType, 'list item.add'>
155
- listItem: string
156
- }
157
- | {
158
- type: StrictExtract<SyntheticBehaviorEventType, 'list item.remove'>
159
- listItem: string
160
- }
161
- | {
162
- type: StrictExtract<SyntheticBehaviorEventType, 'list item.toggle'>
163
- listItem: string
164
- }
165
- | {
166
- type: StrictExtract<SyntheticBehaviorEventType, 'move.block down'>
167
- at: [KeyedSegment]
168
- }
169
- | {
170
- type: StrictExtract<SyntheticBehaviorEventType, 'move.block up'>
171
- at: [KeyedSegment]
172
- }
173
- | {
174
- type: StrictExtract<SyntheticBehaviorEventType, 'select.previous block'>
175
- select?: 'start' | 'end'
176
- }
177
- | {
178
- type: StrictExtract<SyntheticBehaviorEventType, 'select.next block'>
179
- select?: 'start' | 'end'
180
- }
181
- | {
182
- type: StrictExtract<SyntheticBehaviorEventType, 'split'>
183
- }
184
- | {
185
- type: StrictExtract<SyntheticBehaviorEventType, 'style.add'>
186
- style: string
187
- }
188
- | {
189
- type: StrictExtract<SyntheticBehaviorEventType, 'style.remove'>
190
- style: string
191
- }
192
- | {
193
- type: StrictExtract<SyntheticBehaviorEventType, 'style.toggle'>
194
- style: string
195
- }
196
-
197
- /**************************************
198
- * Abstract events
199
- **************************************/
200
- declare const abstractBehaviorEventTypes: readonly [
201
- 'annotation.toggle',
202
- 'decorator.toggle',
203
- 'delete.backward',
204
- 'delete.block',
205
- 'delete.forward',
206
- 'delete.text',
207
- 'deserialize',
208
- 'deserialization.success',
209
- 'deserialization.failure',
210
- 'insert.blocks',
211
- 'insert.break',
212
- 'insert.soft break',
213
- 'list item.add',
214
- 'list item.remove',
215
- 'list item.toggle',
216
- 'move.block down',
217
- 'move.block up',
218
- 'select.previous block',
219
- 'select.next block',
220
- 'serialize',
221
- 'serialization.success',
222
- 'serialization.failure',
223
- 'split',
224
- 'style.add',
225
- 'style.remove',
226
- 'style.toggle',
227
- ]
228
9
 
229
10
  /**
230
11
  * @public
@@ -234,96 +15,6 @@ declare type BaseDefinition = {
234
15
  title?: string
235
16
  }
236
17
 
237
- /**
238
- * @beta
239
- */
240
- declare type Behavior<
241
- TBehaviorEventType extends
242
- | '*'
243
- | `${BehaviorEventTypeNamespace}.*`
244
- | BehaviorEvent['type'] =
245
- | '*'
246
- | `${BehaviorEventTypeNamespace}.*`
247
- | BehaviorEvent['type'],
248
- TGuardResponse = true,
249
- TBehaviorEvent extends
250
- ResolveBehaviorEvent<TBehaviorEventType> = ResolveBehaviorEvent<TBehaviorEventType>,
251
- > = {
252
- /**
253
- * Editor Event that triggers this Behavior.
254
- */
255
- on: TBehaviorEventType
256
- /**
257
- * Predicate function that determines if the Behavior should be executed.
258
- * Returning a non-nullable value from the guard will pass the value to the
259
- * actions and execute them.
260
- */
261
- guard?: BehaviorGuard<TBehaviorEvent, TGuardResponse>
262
- /**
263
- * Array of Behavior Action sets.
264
- * Each set represents a step in the history stack.
265
- */
266
- actions: Array<BehaviorActionSet<TBehaviorEvent, TGuardResponse>>
267
- }
268
-
269
- /**
270
- * @beta
271
- */
272
- declare type BehaviorAction =
273
- | {
274
- type: 'execute'
275
- event: SyntheticBehaviorEvent
276
- }
277
- | {
278
- type: 'forward'
279
- event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent
280
- }
281
- | {
282
- type: 'raise'
283
- event: SyntheticBehaviorEvent | CustomBehaviorEvent
284
- }
285
- | {
286
- type: 'effect'
287
- effect: () => void
288
- }
289
-
290
- /**
291
- * @beta
292
- */
293
- declare type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (
294
- payload: {
295
- snapshot: EditorSnapshot
296
- event: TBehaviorEvent
297
- },
298
- guardResponse: TGuardResponse,
299
- ) => Array<BehaviorAction>
300
-
301
- declare type BehaviorConfig = {
302
- behavior: Behavior
303
- priority: EditorPriority
304
- }
305
-
306
- /**
307
- * @beta
308
- */
309
- declare type BehaviorEvent =
310
- | SyntheticBehaviorEvent
311
- | NativeBehaviorEvent
312
- | CustomBehaviorEvent
313
-
314
- declare type BehaviorEventTypeNamespace =
315
- | SyntheticBehaviorEventNamespace
316
- | NativeBehaviorEventNamespace
317
- | CustomBehaviorEventNamespace
318
-
319
- /**
320
- * @beta
321
- */
322
- declare type BehaviorGuard<TBehaviorEvent, TGuardResponse> = (payload: {
323
- snapshot: EditorSnapshot
324
- event: TBehaviorEvent
325
- }) => TGuardResponse | false
326
-
327
18
  /**
328
19
  * @beta
329
20
  */
@@ -338,33 +29,6 @@ declare type BlockPath = [
338
29
  },
339
30
  ]
340
31
 
341
- declare type BlockWithOptionalKey =
342
- | TextBlockWithOptionalKey
343
- | ObjectBlockWithOptionalKey
344
-
345
- declare type ClipboardBehaviorEvent =
346
- | {
347
- type: StrictExtract<NativeBehaviorEventType, 'clipboard.copy'>
348
- originEvent: {
349
- dataTransfer: DataTransfer
350
- }
351
- position: Pick<EventPosition, 'selection'>
352
- }
353
- | {
354
- type: StrictExtract<NativeBehaviorEventType, 'clipboard.cut'>
355
- originEvent: {
356
- dataTransfer: DataTransfer
357
- }
358
- position: Pick<EventPosition, 'selection'>
359
- }
360
- | {
361
- type: StrictExtract<NativeBehaviorEventType, 'clipboard.paste'>
362
- originEvent: {
363
- dataTransfer: DataTransfer
364
- }
365
- position: Pick<EventPosition, 'selection'>
366
- }
367
-
368
32
  declare type Converter<TMIMEType extends MIMEType = MIMEType> = {
369
33
  mimeType: TMIMEType
370
34
  serialize: Serializer<TMIMEType>
@@ -403,30 +67,6 @@ declare type ConverterEvent<TMIMEType extends MIMEType = MIMEType> =
403
67
  mimeType: TMIMEType
404
68
  }
405
69
 
406
- /**
407
- * @beta
408
- */
409
- declare type CustomBehaviorEvent<
410
- TPayload extends Record<string, unknown> = Record<string, unknown>,
411
- TType extends string = string,
412
- TInternalType extends CustomBehaviorEventType<
413
- 'custom',
414
- TType
415
- > = CustomBehaviorEventType<'custom', TType>,
416
- > = {
417
- type: TInternalType
418
- } & TPayload
419
-
420
- /**************************************
421
- * Custom events
422
- **************************************/
423
- declare type CustomBehaviorEventNamespace = 'custom'
424
-
425
- declare type CustomBehaviorEventType<
426
- TNamespace extends CustomBehaviorEventNamespace,
427
- TType extends string = '',
428
- > = TType extends '' ? `${TNamespace}` : `${TNamespace}.${TType}`
429
-
430
70
  declare type Deserializer<TMIMEType extends MIMEType> = ({
431
71
  snapshot,
432
72
  event,
@@ -439,148 +79,6 @@ declare type Deserializer<TMIMEType extends MIMEType> = ({
439
79
  'deserialization.success' | 'deserialization.failure'
440
80
  >
441
81
 
442
- declare type DragBehaviorEvent =
443
- | {
444
- type: StrictExtract<NativeBehaviorEventType, 'drag.dragstart'>
445
- originEvent: {
446
- dataTransfer: DataTransfer
447
- }
448
- position: Pick<EventPosition, 'selection'>
449
- }
450
- | {
451
- type: StrictExtract<NativeBehaviorEventType, 'drag.drag'>
452
- originEvent: {
453
- dataTransfer: DataTransfer
454
- }
455
- }
456
- | {
457
- type: StrictExtract<NativeBehaviorEventType, 'drag.dragend'>
458
- originEvent: {
459
- dataTransfer: DataTransfer
460
- }
461
- }
462
- | {
463
- type: StrictExtract<NativeBehaviorEventType, 'drag.dragenter'>
464
- originEvent: {
465
- dataTransfer: DataTransfer
466
- }
467
- position: EventPosition
468
- }
469
- | {
470
- type: StrictExtract<NativeBehaviorEventType, 'drag.dragover'>
471
- originEvent: {
472
- dataTransfer: DataTransfer
473
- }
474
- position: EventPosition
475
- }
476
- | {
477
- type: StrictExtract<NativeBehaviorEventType, 'drag.drop'>
478
- originEvent: {
479
- dataTransfer: DataTransfer
480
- }
481
- position: EventPosition
482
- }
483
- | {
484
- type: StrictExtract<NativeBehaviorEventType, 'drag.dragleave'>
485
- originEvent: {
486
- dataTransfer: DataTransfer
487
- }
488
- }
489
-
490
- /** @beta */
491
- declare interface EditableAPI {
492
- activeAnnotations: () => PortableTextObject[]
493
- isAnnotationActive: (annotationType: PortableTextObject['_type']) => boolean
494
- addAnnotation: <
495
- TSchemaType extends {
496
- name: string
497
- },
498
- >(
499
- type: TSchemaType,
500
- value?: {
501
- [prop: string]: unknown
502
- },
503
- ) =>
504
- | {
505
- markDefPath: Path
506
- markDefPaths: Array<Path>
507
- spanPath: Path
508
- }
509
- | undefined
510
- blur: () => void
511
- delete: (
512
- selection: EditorSelection,
513
- options?: EditableAPIDeleteOptions,
514
- ) => void
515
- findByPath: (
516
- path: Path,
517
- ) => [PortableTextBlock | PortableTextChild | undefined, Path | undefined]
518
- findDOMNode: (
519
- element: PortableTextBlock | PortableTextChild,
520
- ) => DOMNode | undefined
521
- focus: () => void
522
- focusBlock: () => PortableTextBlock | undefined
523
- focusChild: () => PortableTextChild | undefined
524
- getSelection: () => EditorSelection
525
- getFragment: () => PortableTextBlock[] | undefined
526
- getValue: () => PortableTextBlock[] | undefined
527
- hasBlockStyle: (style: string) => boolean
528
- hasListStyle: (listStyle: string) => boolean
529
- insertBlock: <
530
- TSchemaType extends {
531
- name: string
532
- },
533
- >(
534
- type: TSchemaType,
535
- value?: {
536
- [prop: string]: unknown
537
- },
538
- ) => Path
539
- insertChild: <
540
- TSchemaType extends {
541
- name: string
542
- },
543
- >(
544
- type: TSchemaType,
545
- value?: {
546
- [prop: string]: unknown
547
- },
548
- ) => Path
549
- insertBreak: () => void
550
- isCollapsedSelection: () => boolean
551
- isExpandedSelection: () => boolean
552
- isMarkActive: (mark: string) => boolean
553
- isSelectionsOverlapping: (
554
- selectionA: EditorSelection,
555
- selectionB: EditorSelection,
556
- ) => boolean
557
- isVoid: (element: PortableTextBlock | PortableTextChild) => boolean
558
- marks: () => string[]
559
- redo: () => void
560
- removeAnnotation: <
561
- TSchemaType extends {
562
- name: string
563
- },
564
- >(
565
- type: TSchemaType,
566
- ) => void
567
- select: (selection: EditorSelection) => void
568
- toggleBlockStyle: (blockStyle: string) => void
569
- toggleList: (listStyle: string) => void
570
- toggleMark: (mark: string) => void
571
- undo: () => void
572
- }
573
-
574
- /** @beta */
575
- declare interface EditableAPIDeleteOptions {
576
- mode?: 'blocks' | 'children' | 'selected'
577
- }
578
-
579
- /**
580
- * @internal
581
- */
582
- declare type EditorActor = ActorRefFrom<typeof editorMachine>
583
-
584
82
  /**
585
83
  * @public
586
84
  */
@@ -593,1764 +91,6 @@ declare type EditorContext = {
593
91
  value: Array<PortableTextBlock>
594
92
  }
595
93
 
596
- /**
597
- * @internal
598
- */
599
- declare const editorMachine: StateMachine<
600
- {
601
- behaviors: Set<BehaviorConfig>
602
- converters: Set<Converter>
603
- getLegacySchema: () => PortableTextMemberSchemaTypes
604
- keyGenerator: () => string
605
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
606
- pendingIncomingPatchesEvents: Array<PatchesEvent>
607
- schema: EditorSchema
608
- initialReadOnly: boolean
609
- maxBlocks: number | undefined
610
- selection: EditorSelection
611
- initialValue: Array<PortableTextBlock> | undefined
612
- internalDrag?: {
613
- ghost?: HTMLElement
614
- origin: Pick<EventPosition, 'selection'>
615
- }
616
- slateEditor?: PortableTextSlateEditor
617
- },
618
- | InternalPatchEvent
619
- | MutationEvent
620
- | PatchesEvent
621
- | {
622
- type: 'update readOnly'
623
- readOnly: boolean
624
- }
625
- | {
626
- type: 'update maxBlocks'
627
- maxBlocks: number | undefined
628
- }
629
- | {
630
- type: 'add behavior'
631
- behaviorConfig: BehaviorConfig
632
- }
633
- | {
634
- type: 'remove behavior'
635
- behaviorConfig: BehaviorConfig
636
- }
637
- | {
638
- type: 'blur'
639
- editor: PortableTextSlateEditor
640
- }
641
- | {
642
- type: 'focus'
643
- editor: PortableTextSlateEditor
644
- }
645
- | {
646
- type: 'normalizing'
647
- }
648
- | {
649
- type: 'update selection'
650
- selection: EditorSelection
651
- }
652
- | {
653
- type: 'done normalizing'
654
- }
655
- | {
656
- type: 'done syncing value'
657
- }
658
- | {
659
- type: 'syncing value'
660
- }
661
- | {
662
- type: 'behavior event'
663
- behaviorEvent: BehaviorEvent
664
- editor: PortableTextSlateEditor
665
- nativeEvent?: {
666
- preventDefault: () => void
667
- }
668
- }
669
- | {
670
- type: 'dragstart'
671
- origin: Pick<EventPosition, 'selection'>
672
- ghost?: HTMLElement
673
- }
674
- | {
675
- type: 'dragend'
676
- }
677
- | {
678
- type: 'drop'
679
- },
680
- {},
681
- never,
682
- Values<{
683
- 'add behavior to context': {
684
- type: 'add behavior to context'
685
- params: NonReducibleUnknown
686
- }
687
- 'remove behavior from context': {
688
- type: 'remove behavior from context'
689
- params: NonReducibleUnknown
690
- }
691
- 'emit patch event': {
692
- type: 'emit patch event'
693
- params: NonReducibleUnknown
694
- }
695
- 'emit mutation event': {
696
- type: 'emit mutation event'
697
- params: NonReducibleUnknown
698
- }
699
- 'emit read only': {
700
- type: 'emit read only'
701
- params: NonReducibleUnknown
702
- }
703
- 'emit editable': {
704
- type: 'emit editable'
705
- params: NonReducibleUnknown
706
- }
707
- 'defer event': {
708
- type: 'defer event'
709
- params: NonReducibleUnknown
710
- }
711
- 'emit pending events': {
712
- type: 'emit pending events'
713
- params: NonReducibleUnknown
714
- }
715
- 'emit ready': {
716
- type: 'emit ready'
717
- params: NonReducibleUnknown
718
- }
719
- 'clear pending events': {
720
- type: 'clear pending events'
721
- params: NonReducibleUnknown
722
- }
723
- 'defer incoming patches': {
724
- type: 'defer incoming patches'
725
- params: NonReducibleUnknown
726
- }
727
- 'emit pending incoming patches': {
728
- type: 'emit pending incoming patches'
729
- params: NonReducibleUnknown
730
- }
731
- 'clear pending incoming patches': {
732
- type: 'clear pending incoming patches'
733
- params: NonReducibleUnknown
734
- }
735
- 'handle blur': {
736
- type: 'handle blur'
737
- params: unknown
738
- }
739
- 'handle focus': {
740
- type: 'handle focus'
741
- params: unknown
742
- }
743
- 'handle behavior event': {
744
- type: 'handle behavior event'
745
- params: unknown
746
- }
747
- }>,
748
- {
749
- type: 'slate is busy'
750
- params: unknown
751
- },
752
- never,
753
- {
754
- 'edit mode':
755
- | {
756
- editable:
757
- | 'dragging internally'
758
- | 'idle'
759
- | {
760
- focusing: 'checking if busy' | 'busy'
761
- }
762
- }
763
- | {
764
- 'read only': 'read only' | 'determine initial edit mode'
765
- }
766
- 'setup':
767
- | 'setting up'
768
- | {
769
- 'set up': {
770
- 'value sync': 'syncing value' | 'idle'
771
- 'writing':
772
- | 'dirty'
773
- | {
774
- pristine: 'normalizing' | 'idle'
775
- }
776
- }
777
- }
778
- },
779
- 'dragging internally',
780
- {
781
- converters?: Array<Converter>
782
- getLegacySchema: () => PortableTextMemberSchemaTypes
783
- keyGenerator: () => string
784
- maxBlocks?: number
785
- readOnly?: boolean
786
- schema: EditorSchema
787
- initialValue?: Array<PortableTextBlock>
788
- },
789
- NonReducibleUnknown,
790
- | InternalPatchEvent
791
- | MutationEvent
792
- | PatchesEvent
793
- | {
794
- type: 'blurred'
795
- event: FocusEvent_2<HTMLDivElement, Element>
796
- }
797
- | {
798
- type: 'done loading'
799
- }
800
- | {
801
- type: 'editable'
802
- }
803
- | {
804
- type: 'error'
805
- name: string
806
- description: string
807
- data: unknown
808
- }
809
- | {
810
- type: 'focused'
811
- event: FocusEvent_2<HTMLDivElement, Element>
812
- }
813
- | {
814
- type: 'invalid value'
815
- resolution: InvalidValueResolution | null
816
- value: Array<PortableTextBlock> | undefined
817
- }
818
- | {
819
- type: 'loading'
820
- }
821
- | {
822
- type: 'read only'
823
- }
824
- | {
825
- type: 'ready'
826
- }
827
- | {
828
- type: 'selection'
829
- selection: EditorSelection
830
- }
831
- | {
832
- type: 'value changed'
833
- value: Array<PortableTextBlock> | undefined
834
- },
835
- MetaObject,
836
- {
837
- readonly id: 'editor'
838
- readonly context: ({
839
- input,
840
- }: {
841
- spawn: {
842
- <TSrc extends never>(
843
- logic: TSrc,
844
- ...[options]: never
845
- ): ActorRefFromLogic<never>
846
- <TLogic extends AnyActorLogic>(
847
- src: TLogic,
848
- ...[options]: ConditionalRequired<
849
- [
850
- options?:
851
- | ({
852
- id?: never
853
- systemId?: string
854
- input?: InputFrom<TLogic> | undefined
855
- syncSnapshot?: boolean
856
- } & {[K in RequiredLogicInput<TLogic>]: unknown})
857
- | undefined,
858
- ],
859
- IsNotNever<RequiredLogicInput<TLogic>>
860
- >
861
- ): ActorRefFromLogic<TLogic>
862
- }
863
- input: {
864
- converters?: Array<Converter>
865
- getLegacySchema: () => PortableTextMemberSchemaTypes
866
- keyGenerator: () => string
867
- maxBlocks?: number
868
- readOnly?: boolean
869
- schema: EditorSchema
870
- initialValue?: Array<PortableTextBlock>
871
- }
872
- self: ActorRef<
873
- MachineSnapshot<
874
- {
875
- behaviors: Set<BehaviorConfig>
876
- converters: Set<Converter>
877
- getLegacySchema: () => PortableTextMemberSchemaTypes
878
- keyGenerator: () => string
879
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
880
- pendingIncomingPatchesEvents: Array<PatchesEvent>
881
- schema: EditorSchema
882
- initialReadOnly: boolean
883
- maxBlocks: number | undefined
884
- selection: EditorSelection
885
- initialValue: Array<PortableTextBlock> | undefined
886
- internalDrag?: {
887
- ghost?: HTMLElement
888
- origin: Pick<EventPosition, 'selection'>
889
- }
890
- slateEditor?: PortableTextSlateEditor
891
- },
892
- | InternalPatchEvent
893
- | MutationEvent
894
- | PatchesEvent
895
- | {
896
- type: 'update readOnly'
897
- readOnly: boolean
898
- }
899
- | {
900
- type: 'update maxBlocks'
901
- maxBlocks: number | undefined
902
- }
903
- | {
904
- type: 'add behavior'
905
- behaviorConfig: BehaviorConfig
906
- }
907
- | {
908
- type: 'remove behavior'
909
- behaviorConfig: BehaviorConfig
910
- }
911
- | {
912
- type: 'blur'
913
- editor: PortableTextSlateEditor
914
- }
915
- | {
916
- type: 'focus'
917
- editor: PortableTextSlateEditor
918
- }
919
- | {
920
- type: 'normalizing'
921
- }
922
- | {
923
- type: 'update selection'
924
- selection: EditorSelection
925
- }
926
- | {
927
- type: 'done normalizing'
928
- }
929
- | {
930
- type: 'done syncing value'
931
- }
932
- | {
933
- type: 'syncing value'
934
- }
935
- | {
936
- type: 'behavior event'
937
- behaviorEvent: BehaviorEvent
938
- editor: PortableTextSlateEditor
939
- nativeEvent?: {
940
- preventDefault: () => void
941
- }
942
- }
943
- | {
944
- type: 'dragstart'
945
- origin: Pick<EventPosition, 'selection'>
946
- ghost?: HTMLElement
947
- }
948
- | {
949
- type: 'dragend'
950
- }
951
- | {
952
- type: 'drop'
953
- },
954
- Record<string, AnyActorRef | undefined>,
955
- StateValue,
956
- string,
957
- unknown,
958
- any,
959
- any
960
- >,
961
- | InternalPatchEvent
962
- | MutationEvent
963
- | PatchesEvent
964
- | {
965
- type: 'update readOnly'
966
- readOnly: boolean
967
- }
968
- | {
969
- type: 'update maxBlocks'
970
- maxBlocks: number | undefined
971
- }
972
- | {
973
- type: 'add behavior'
974
- behaviorConfig: BehaviorConfig
975
- }
976
- | {
977
- type: 'remove behavior'
978
- behaviorConfig: BehaviorConfig
979
- }
980
- | {
981
- type: 'blur'
982
- editor: PortableTextSlateEditor
983
- }
984
- | {
985
- type: 'focus'
986
- editor: PortableTextSlateEditor
987
- }
988
- | {
989
- type: 'normalizing'
990
- }
991
- | {
992
- type: 'update selection'
993
- selection: EditorSelection
994
- }
995
- | {
996
- type: 'done normalizing'
997
- }
998
- | {
999
- type: 'done syncing value'
1000
- }
1001
- | {
1002
- type: 'syncing value'
1003
- }
1004
- | {
1005
- type: 'behavior event'
1006
- behaviorEvent: BehaviorEvent
1007
- editor: PortableTextSlateEditor
1008
- nativeEvent?: {
1009
- preventDefault: () => void
1010
- }
1011
- }
1012
- | {
1013
- type: 'dragstart'
1014
- origin: Pick<EventPosition, 'selection'>
1015
- ghost?: HTMLElement
1016
- }
1017
- | {
1018
- type: 'dragend'
1019
- }
1020
- | {
1021
- type: 'drop'
1022
- },
1023
- AnyEventObject
1024
- >
1025
- }) => {
1026
- behaviors: Set<never>
1027
- converters: Set<Converter>
1028
- getLegacySchema: () => PortableTextMemberSchemaTypes
1029
- keyGenerator: () => string
1030
- pendingEvents: never[]
1031
- pendingIncomingPatchesEvents: never[]
1032
- schema: EditorSchema
1033
- selection: null
1034
- initialReadOnly: boolean
1035
- maxBlocks: number | undefined
1036
- initialValue: PortableTextBlock[] | undefined
1037
- }
1038
- readonly on: {
1039
- readonly 'add behavior': {
1040
- readonly actions: 'add behavior to context'
1041
- }
1042
- readonly 'remove behavior': {
1043
- readonly actions: 'remove behavior from context'
1044
- }
1045
- readonly 'update maxBlocks': {
1046
- readonly actions: ActionFunction<
1047
- {
1048
- behaviors: Set<BehaviorConfig>
1049
- converters: Set<Converter>
1050
- getLegacySchema: () => PortableTextMemberSchemaTypes
1051
- keyGenerator: () => string
1052
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1053
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1054
- schema: EditorSchema
1055
- initialReadOnly: boolean
1056
- maxBlocks: number | undefined
1057
- selection: EditorSelection
1058
- initialValue: Array<PortableTextBlock> | undefined
1059
- internalDrag?: {
1060
- ghost?: HTMLElement
1061
- origin: Pick<EventPosition, 'selection'>
1062
- }
1063
- slateEditor?: PortableTextSlateEditor
1064
- },
1065
- {
1066
- type: 'update maxBlocks'
1067
- maxBlocks: number | undefined
1068
- },
1069
- | InternalPatchEvent
1070
- | MutationEvent
1071
- | PatchesEvent
1072
- | {
1073
- type: 'update readOnly'
1074
- readOnly: boolean
1075
- }
1076
- | {
1077
- type: 'update maxBlocks'
1078
- maxBlocks: number | undefined
1079
- }
1080
- | {
1081
- type: 'add behavior'
1082
- behaviorConfig: BehaviorConfig
1083
- }
1084
- | {
1085
- type: 'remove behavior'
1086
- behaviorConfig: BehaviorConfig
1087
- }
1088
- | {
1089
- type: 'blur'
1090
- editor: PortableTextSlateEditor
1091
- }
1092
- | {
1093
- type: 'focus'
1094
- editor: PortableTextSlateEditor
1095
- }
1096
- | {
1097
- type: 'normalizing'
1098
- }
1099
- | {
1100
- type: 'update selection'
1101
- selection: EditorSelection
1102
- }
1103
- | {
1104
- type: 'done normalizing'
1105
- }
1106
- | {
1107
- type: 'done syncing value'
1108
- }
1109
- | {
1110
- type: 'syncing value'
1111
- }
1112
- | {
1113
- type: 'behavior event'
1114
- behaviorEvent: BehaviorEvent
1115
- editor: PortableTextSlateEditor
1116
- nativeEvent?: {
1117
- preventDefault: () => void
1118
- }
1119
- }
1120
- | {
1121
- type: 'dragstart'
1122
- origin: Pick<EventPosition, 'selection'>
1123
- ghost?: HTMLElement
1124
- }
1125
- | {
1126
- type: 'dragend'
1127
- }
1128
- | {
1129
- type: 'drop'
1130
- },
1131
- undefined,
1132
- never,
1133
- never,
1134
- never,
1135
- never,
1136
- never
1137
- >
1138
- }
1139
- readonly 'update selection': {
1140
- readonly actions: readonly [
1141
- ActionFunction<
1142
- {
1143
- behaviors: Set<BehaviorConfig>
1144
- converters: Set<Converter>
1145
- getLegacySchema: () => PortableTextMemberSchemaTypes
1146
- keyGenerator: () => string
1147
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1148
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1149
- schema: EditorSchema
1150
- initialReadOnly: boolean
1151
- maxBlocks: number | undefined
1152
- selection: EditorSelection
1153
- initialValue: Array<PortableTextBlock> | undefined
1154
- internalDrag?: {
1155
- ghost?: HTMLElement
1156
- origin: Pick<EventPosition, 'selection'>
1157
- }
1158
- slateEditor?: PortableTextSlateEditor
1159
- },
1160
- {
1161
- type: 'update selection'
1162
- selection: EditorSelection
1163
- },
1164
- | InternalPatchEvent
1165
- | MutationEvent
1166
- | PatchesEvent
1167
- | {
1168
- type: 'update readOnly'
1169
- readOnly: boolean
1170
- }
1171
- | {
1172
- type: 'update maxBlocks'
1173
- maxBlocks: number | undefined
1174
- }
1175
- | {
1176
- type: 'add behavior'
1177
- behaviorConfig: BehaviorConfig
1178
- }
1179
- | {
1180
- type: 'remove behavior'
1181
- behaviorConfig: BehaviorConfig
1182
- }
1183
- | {
1184
- type: 'blur'
1185
- editor: PortableTextSlateEditor
1186
- }
1187
- | {
1188
- type: 'focus'
1189
- editor: PortableTextSlateEditor
1190
- }
1191
- | {
1192
- type: 'normalizing'
1193
- }
1194
- | {
1195
- type: 'update selection'
1196
- selection: EditorSelection
1197
- }
1198
- | {
1199
- type: 'done normalizing'
1200
- }
1201
- | {
1202
- type: 'done syncing value'
1203
- }
1204
- | {
1205
- type: 'syncing value'
1206
- }
1207
- | {
1208
- type: 'behavior event'
1209
- behaviorEvent: BehaviorEvent
1210
- editor: PortableTextSlateEditor
1211
- nativeEvent?: {
1212
- preventDefault: () => void
1213
- }
1214
- }
1215
- | {
1216
- type: 'dragstart'
1217
- origin: Pick<EventPosition, 'selection'>
1218
- ghost?: HTMLElement
1219
- }
1220
- | {
1221
- type: 'dragend'
1222
- }
1223
- | {
1224
- type: 'drop'
1225
- },
1226
- undefined,
1227
- never,
1228
- never,
1229
- never,
1230
- never,
1231
- never
1232
- >,
1233
- ActionFunction<
1234
- {
1235
- behaviors: Set<BehaviorConfig>
1236
- converters: Set<Converter>
1237
- getLegacySchema: () => PortableTextMemberSchemaTypes
1238
- keyGenerator: () => string
1239
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1240
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1241
- schema: EditorSchema
1242
- initialReadOnly: boolean
1243
- maxBlocks: number | undefined
1244
- selection: EditorSelection
1245
- initialValue: Array<PortableTextBlock> | undefined
1246
- internalDrag?: {
1247
- ghost?: HTMLElement
1248
- origin: Pick<EventPosition, 'selection'>
1249
- }
1250
- slateEditor?: PortableTextSlateEditor
1251
- },
1252
- {
1253
- type: 'update selection'
1254
- selection: EditorSelection
1255
- },
1256
- | InternalPatchEvent
1257
- | MutationEvent
1258
- | PatchesEvent
1259
- | {
1260
- type: 'update readOnly'
1261
- readOnly: boolean
1262
- }
1263
- | {
1264
- type: 'update maxBlocks'
1265
- maxBlocks: number | undefined
1266
- }
1267
- | {
1268
- type: 'add behavior'
1269
- behaviorConfig: BehaviorConfig
1270
- }
1271
- | {
1272
- type: 'remove behavior'
1273
- behaviorConfig: BehaviorConfig
1274
- }
1275
- | {
1276
- type: 'blur'
1277
- editor: PortableTextSlateEditor
1278
- }
1279
- | {
1280
- type: 'focus'
1281
- editor: PortableTextSlateEditor
1282
- }
1283
- | {
1284
- type: 'normalizing'
1285
- }
1286
- | {
1287
- type: 'update selection'
1288
- selection: EditorSelection
1289
- }
1290
- | {
1291
- type: 'done normalizing'
1292
- }
1293
- | {
1294
- type: 'done syncing value'
1295
- }
1296
- | {
1297
- type: 'syncing value'
1298
- }
1299
- | {
1300
- type: 'behavior event'
1301
- behaviorEvent: BehaviorEvent
1302
- editor: PortableTextSlateEditor
1303
- nativeEvent?: {
1304
- preventDefault: () => void
1305
- }
1306
- }
1307
- | {
1308
- type: 'dragstart'
1309
- origin: Pick<EventPosition, 'selection'>
1310
- ghost?: HTMLElement
1311
- }
1312
- | {
1313
- type: 'dragend'
1314
- }
1315
- | {
1316
- type: 'drop'
1317
- },
1318
- undefined,
1319
- never,
1320
- never,
1321
- never,
1322
- never,
1323
- | InternalPatchEvent
1324
- | MutationEvent
1325
- | PatchesEvent
1326
- | {
1327
- type: 'blurred'
1328
- event: FocusEvent_2<HTMLDivElement, Element>
1329
- }
1330
- | {
1331
- type: 'done loading'
1332
- }
1333
- | {
1334
- type: 'editable'
1335
- }
1336
- | {
1337
- type: 'error'
1338
- name: string
1339
- description: string
1340
- data: unknown
1341
- }
1342
- | {
1343
- type: 'focused'
1344
- event: FocusEvent_2<HTMLDivElement, Element>
1345
- }
1346
- | {
1347
- type: 'invalid value'
1348
- resolution: InvalidValueResolution | null
1349
- value: Array<PortableTextBlock> | undefined
1350
- }
1351
- | {
1352
- type: 'loading'
1353
- }
1354
- | {
1355
- type: 'read only'
1356
- }
1357
- | {
1358
- type: 'ready'
1359
- }
1360
- | {
1361
- type: 'selection'
1362
- selection: EditorSelection
1363
- }
1364
- | {
1365
- type: 'value changed'
1366
- value: Array<PortableTextBlock> | undefined
1367
- }
1368
- >,
1369
- ]
1370
- }
1371
- }
1372
- readonly type: 'parallel'
1373
- readonly states: {
1374
- readonly 'edit mode': {
1375
- readonly initial: 'read only'
1376
- readonly states: {
1377
- readonly 'read only': {
1378
- readonly initial: 'determine initial edit mode'
1379
- readonly on: {
1380
- readonly 'behavior event': {
1381
- readonly actions: 'handle behavior event'
1382
- readonly guard: ({
1383
- event,
1384
- }: GuardArgs<
1385
- {
1386
- behaviors: Set<BehaviorConfig>
1387
- converters: Set<Converter>
1388
- getLegacySchema: () => PortableTextMemberSchemaTypes
1389
- keyGenerator: () => string
1390
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1391
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1392
- schema: EditorSchema
1393
- initialReadOnly: boolean
1394
- maxBlocks: number | undefined
1395
- selection: EditorSelection
1396
- initialValue: Array<PortableTextBlock> | undefined
1397
- internalDrag?: {
1398
- ghost?: HTMLElement
1399
- origin: Pick<EventPosition, 'selection'>
1400
- }
1401
- slateEditor?: PortableTextSlateEditor
1402
- },
1403
- {
1404
- type: 'behavior event'
1405
- behaviorEvent: BehaviorEvent
1406
- editor: PortableTextSlateEditor
1407
- nativeEvent?: {
1408
- preventDefault: () => void
1409
- }
1410
- }
1411
- >) => boolean
1412
- }
1413
- }
1414
- readonly states: {
1415
- readonly 'determine initial edit mode': {
1416
- readonly entry: readonly [() => void]
1417
- readonly exit: readonly [() => void]
1418
- readonly on: {
1419
- readonly 'done syncing value': readonly [
1420
- {
1421
- readonly target: '#editor.edit mode.read only.read only'
1422
- readonly guard: ({
1423
- context,
1424
- }: GuardArgs<
1425
- {
1426
- behaviors: Set<BehaviorConfig>
1427
- converters: Set<Converter>
1428
- getLegacySchema: () => PortableTextMemberSchemaTypes
1429
- keyGenerator: () => string
1430
- pendingEvents: Array<
1431
- InternalPatchEvent | MutationEvent
1432
- >
1433
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1434
- schema: EditorSchema
1435
- initialReadOnly: boolean
1436
- maxBlocks: number | undefined
1437
- selection: EditorSelection
1438
- initialValue: Array<PortableTextBlock> | undefined
1439
- internalDrag?: {
1440
- ghost?: HTMLElement
1441
- origin: Pick<EventPosition, 'selection'>
1442
- }
1443
- slateEditor?: PortableTextSlateEditor
1444
- },
1445
- {
1446
- type: 'done syncing value'
1447
- }
1448
- >) => boolean
1449
- },
1450
- {
1451
- readonly target: '#editor.edit mode.editable'
1452
- },
1453
- ]
1454
- }
1455
- }
1456
- readonly 'read only': {
1457
- readonly entry: readonly [() => void]
1458
- readonly exit: readonly [() => void]
1459
- readonly on: {
1460
- readonly 'update readOnly': {
1461
- readonly guard: ({
1462
- event,
1463
- }: GuardArgs<
1464
- {
1465
- behaviors: Set<BehaviorConfig>
1466
- converters: Set<Converter>
1467
- getLegacySchema: () => PortableTextMemberSchemaTypes
1468
- keyGenerator: () => string
1469
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1470
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1471
- schema: EditorSchema
1472
- initialReadOnly: boolean
1473
- maxBlocks: number | undefined
1474
- selection: EditorSelection
1475
- initialValue: Array<PortableTextBlock> | undefined
1476
- internalDrag?: {
1477
- ghost?: HTMLElement
1478
- origin: Pick<EventPosition, 'selection'>
1479
- }
1480
- slateEditor?: PortableTextSlateEditor
1481
- },
1482
- {
1483
- type: 'update readOnly'
1484
- readOnly: boolean
1485
- }
1486
- >) => boolean
1487
- readonly target: '#editor.edit mode.editable'
1488
- readonly actions: readonly ['emit editable']
1489
- }
1490
- }
1491
- }
1492
- }
1493
- }
1494
- readonly 'editable': {
1495
- readonly on: {
1496
- readonly 'update readOnly': {
1497
- readonly guard: ({
1498
- event,
1499
- }: GuardArgs<
1500
- {
1501
- behaviors: Set<BehaviorConfig>
1502
- converters: Set<Converter>
1503
- getLegacySchema: () => PortableTextMemberSchemaTypes
1504
- keyGenerator: () => string
1505
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1506
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1507
- schema: EditorSchema
1508
- initialReadOnly: boolean
1509
- maxBlocks: number | undefined
1510
- selection: EditorSelection
1511
- initialValue: Array<PortableTextBlock> | undefined
1512
- internalDrag?: {
1513
- ghost?: HTMLElement
1514
- origin: Pick<EventPosition, 'selection'>
1515
- }
1516
- slateEditor?: PortableTextSlateEditor
1517
- },
1518
- {
1519
- type: 'update readOnly'
1520
- readOnly: boolean
1521
- }
1522
- >) => boolean
1523
- readonly target: '#editor.edit mode.read only.read only'
1524
- readonly actions: readonly ['emit read only']
1525
- }
1526
- readonly 'behavior event': {
1527
- readonly actions: 'handle behavior event'
1528
- }
1529
- readonly 'blur': {
1530
- readonly actions: 'handle blur'
1531
- }
1532
- readonly 'focus': {
1533
- readonly target: '.focusing'
1534
- readonly actions: readonly [
1535
- ActionFunction<
1536
- {
1537
- behaviors: Set<BehaviorConfig>
1538
- converters: Set<Converter>
1539
- getLegacySchema: () => PortableTextMemberSchemaTypes
1540
- keyGenerator: () => string
1541
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1542
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1543
- schema: EditorSchema
1544
- initialReadOnly: boolean
1545
- maxBlocks: number | undefined
1546
- selection: EditorSelection
1547
- initialValue: Array<PortableTextBlock> | undefined
1548
- internalDrag?: {
1549
- ghost?: HTMLElement
1550
- origin: Pick<EventPosition, 'selection'>
1551
- }
1552
- slateEditor?: PortableTextSlateEditor
1553
- },
1554
- {
1555
- type: 'focus'
1556
- editor: PortableTextSlateEditor
1557
- },
1558
- | InternalPatchEvent
1559
- | MutationEvent
1560
- | PatchesEvent
1561
- | {
1562
- type: 'update readOnly'
1563
- readOnly: boolean
1564
- }
1565
- | {
1566
- type: 'update maxBlocks'
1567
- maxBlocks: number | undefined
1568
- }
1569
- | {
1570
- type: 'add behavior'
1571
- behaviorConfig: BehaviorConfig
1572
- }
1573
- | {
1574
- type: 'remove behavior'
1575
- behaviorConfig: BehaviorConfig
1576
- }
1577
- | {
1578
- type: 'blur'
1579
- editor: PortableTextSlateEditor
1580
- }
1581
- | {
1582
- type: 'focus'
1583
- editor: PortableTextSlateEditor
1584
- }
1585
- | {
1586
- type: 'normalizing'
1587
- }
1588
- | {
1589
- type: 'update selection'
1590
- selection: EditorSelection
1591
- }
1592
- | {
1593
- type: 'done normalizing'
1594
- }
1595
- | {
1596
- type: 'done syncing value'
1597
- }
1598
- | {
1599
- type: 'syncing value'
1600
- }
1601
- | {
1602
- type: 'behavior event'
1603
- behaviorEvent: BehaviorEvent
1604
- editor: PortableTextSlateEditor
1605
- nativeEvent?: {
1606
- preventDefault: () => void
1607
- }
1608
- }
1609
- | {
1610
- type: 'dragstart'
1611
- origin: Pick<EventPosition, 'selection'>
1612
- ghost?: HTMLElement
1613
- }
1614
- | {
1615
- type: 'dragend'
1616
- }
1617
- | {
1618
- type: 'drop'
1619
- },
1620
- undefined,
1621
- never,
1622
- never,
1623
- never,
1624
- never,
1625
- never
1626
- >,
1627
- ]
1628
- }
1629
- }
1630
- readonly initial: 'idle'
1631
- readonly states: {
1632
- readonly 'idle': {
1633
- readonly entry: readonly [() => void]
1634
- readonly exit: readonly [() => void]
1635
- readonly on: {
1636
- readonly dragstart: {
1637
- readonly actions: readonly [
1638
- ActionFunction<
1639
- {
1640
- behaviors: Set<BehaviorConfig>
1641
- converters: Set<Converter>
1642
- getLegacySchema: () => PortableTextMemberSchemaTypes
1643
- keyGenerator: () => string
1644
- pendingEvents: Array<
1645
- InternalPatchEvent | MutationEvent
1646
- >
1647
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1648
- schema: EditorSchema
1649
- initialReadOnly: boolean
1650
- maxBlocks: number | undefined
1651
- selection: EditorSelection
1652
- initialValue: Array<PortableTextBlock> | undefined
1653
- internalDrag?: {
1654
- ghost?: HTMLElement
1655
- origin: Pick<EventPosition, 'selection'>
1656
- }
1657
- slateEditor?: PortableTextSlateEditor
1658
- },
1659
- {
1660
- type: 'dragstart'
1661
- origin: Pick<EventPosition, 'selection'>
1662
- ghost?: HTMLElement
1663
- },
1664
- | InternalPatchEvent
1665
- | MutationEvent
1666
- | PatchesEvent
1667
- | {
1668
- type: 'update readOnly'
1669
- readOnly: boolean
1670
- }
1671
- | {
1672
- type: 'update maxBlocks'
1673
- maxBlocks: number | undefined
1674
- }
1675
- | {
1676
- type: 'add behavior'
1677
- behaviorConfig: BehaviorConfig
1678
- }
1679
- | {
1680
- type: 'remove behavior'
1681
- behaviorConfig: BehaviorConfig
1682
- }
1683
- | {
1684
- type: 'blur'
1685
- editor: PortableTextSlateEditor
1686
- }
1687
- | {
1688
- type: 'focus'
1689
- editor: PortableTextSlateEditor
1690
- }
1691
- | {
1692
- type: 'normalizing'
1693
- }
1694
- | {
1695
- type: 'update selection'
1696
- selection: EditorSelection
1697
- }
1698
- | {
1699
- type: 'done normalizing'
1700
- }
1701
- | {
1702
- type: 'done syncing value'
1703
- }
1704
- | {
1705
- type: 'syncing value'
1706
- }
1707
- | {
1708
- type: 'behavior event'
1709
- behaviorEvent: BehaviorEvent
1710
- editor: PortableTextSlateEditor
1711
- nativeEvent?: {
1712
- preventDefault: () => void
1713
- }
1714
- }
1715
- | {
1716
- type: 'dragstart'
1717
- origin: Pick<EventPosition, 'selection'>
1718
- ghost?: HTMLElement
1719
- }
1720
- | {
1721
- type: 'dragend'
1722
- }
1723
- | {
1724
- type: 'drop'
1725
- },
1726
- undefined,
1727
- never,
1728
- never,
1729
- never,
1730
- never,
1731
- never
1732
- >,
1733
- ]
1734
- readonly target: 'dragging internally'
1735
- }
1736
- }
1737
- }
1738
- readonly 'focusing': {
1739
- readonly initial: 'checking if busy'
1740
- readonly states: {
1741
- readonly 'checking if busy': {
1742
- readonly entry: readonly [() => void]
1743
- readonly exit: readonly [() => void]
1744
- readonly always: readonly [
1745
- {
1746
- readonly guard: 'slate is busy'
1747
- readonly target: 'busy'
1748
- },
1749
- {
1750
- readonly target: '#editor.edit mode.editable.idle'
1751
- readonly actions: readonly ['handle focus']
1752
- },
1753
- ]
1754
- }
1755
- readonly 'busy': {
1756
- readonly entry: readonly [() => void]
1757
- readonly exit: readonly [() => void]
1758
- readonly after: {
1759
- readonly 10: {
1760
- readonly target: 'checking if busy'
1761
- }
1762
- }
1763
- }
1764
- }
1765
- }
1766
- readonly 'dragging internally': {
1767
- readonly entry: readonly [() => void]
1768
- readonly exit: readonly [
1769
- () => void,
1770
- ({
1771
- context,
1772
- }: ActionArgs<
1773
- {
1774
- behaviors: Set<BehaviorConfig>
1775
- converters: Set<Converter>
1776
- getLegacySchema: () => PortableTextMemberSchemaTypes
1777
- keyGenerator: () => string
1778
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1779
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1780
- schema: EditorSchema
1781
- initialReadOnly: boolean
1782
- maxBlocks: number | undefined
1783
- selection: EditorSelection
1784
- initialValue: Array<PortableTextBlock> | undefined
1785
- internalDrag?: {
1786
- ghost?: HTMLElement
1787
- origin: Pick<EventPosition, 'selection'>
1788
- }
1789
- slateEditor?: PortableTextSlateEditor
1790
- },
1791
- | InternalPatchEvent
1792
- | MutationEvent
1793
- | PatchesEvent
1794
- | {
1795
- type: 'update readOnly'
1796
- readOnly: boolean
1797
- }
1798
- | {
1799
- type: 'update maxBlocks'
1800
- maxBlocks: number | undefined
1801
- }
1802
- | {
1803
- type: 'add behavior'
1804
- behaviorConfig: BehaviorConfig
1805
- }
1806
- | {
1807
- type: 'remove behavior'
1808
- behaviorConfig: BehaviorConfig
1809
- }
1810
- | {
1811
- type: 'blur'
1812
- editor: PortableTextSlateEditor
1813
- }
1814
- | {
1815
- type: 'focus'
1816
- editor: PortableTextSlateEditor
1817
- }
1818
- | {
1819
- type: 'normalizing'
1820
- }
1821
- | {
1822
- type: 'update selection'
1823
- selection: EditorSelection
1824
- }
1825
- | {
1826
- type: 'done normalizing'
1827
- }
1828
- | {
1829
- type: 'done syncing value'
1830
- }
1831
- | {
1832
- type: 'syncing value'
1833
- }
1834
- | {
1835
- type: 'behavior event'
1836
- behaviorEvent: BehaviorEvent
1837
- editor: PortableTextSlateEditor
1838
- nativeEvent?: {
1839
- preventDefault: () => void
1840
- }
1841
- }
1842
- | {
1843
- type: 'dragstart'
1844
- origin: Pick<EventPosition, 'selection'>
1845
- ghost?: HTMLElement
1846
- }
1847
- | {
1848
- type: 'dragend'
1849
- }
1850
- | {
1851
- type: 'drop'
1852
- },
1853
- | InternalPatchEvent
1854
- | MutationEvent
1855
- | PatchesEvent
1856
- | {
1857
- type: 'update readOnly'
1858
- readOnly: boolean
1859
- }
1860
- | {
1861
- type: 'update maxBlocks'
1862
- maxBlocks: number | undefined
1863
- }
1864
- | {
1865
- type: 'add behavior'
1866
- behaviorConfig: BehaviorConfig
1867
- }
1868
- | {
1869
- type: 'remove behavior'
1870
- behaviorConfig: BehaviorConfig
1871
- }
1872
- | {
1873
- type: 'blur'
1874
- editor: PortableTextSlateEditor
1875
- }
1876
- | {
1877
- type: 'focus'
1878
- editor: PortableTextSlateEditor
1879
- }
1880
- | {
1881
- type: 'normalizing'
1882
- }
1883
- | {
1884
- type: 'update selection'
1885
- selection: EditorSelection
1886
- }
1887
- | {
1888
- type: 'done normalizing'
1889
- }
1890
- | {
1891
- type: 'done syncing value'
1892
- }
1893
- | {
1894
- type: 'syncing value'
1895
- }
1896
- | {
1897
- type: 'behavior event'
1898
- behaviorEvent: BehaviorEvent
1899
- editor: PortableTextSlateEditor
1900
- nativeEvent?: {
1901
- preventDefault: () => void
1902
- }
1903
- }
1904
- | {
1905
- type: 'dragstart'
1906
- origin: Pick<EventPosition, 'selection'>
1907
- ghost?: HTMLElement
1908
- }
1909
- | {
1910
- type: 'dragend'
1911
- }
1912
- | {
1913
- type: 'drop'
1914
- }
1915
- >) => void,
1916
- ActionFunction<
1917
- {
1918
- behaviors: Set<BehaviorConfig>
1919
- converters: Set<Converter>
1920
- getLegacySchema: () => PortableTextMemberSchemaTypes
1921
- keyGenerator: () => string
1922
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
1923
- pendingIncomingPatchesEvents: Array<PatchesEvent>
1924
- schema: EditorSchema
1925
- initialReadOnly: boolean
1926
- maxBlocks: number | undefined
1927
- selection: EditorSelection
1928
- initialValue: Array<PortableTextBlock> | undefined
1929
- internalDrag?: {
1930
- ghost?: HTMLElement
1931
- origin: Pick<EventPosition, 'selection'>
1932
- }
1933
- slateEditor?: PortableTextSlateEditor
1934
- },
1935
- | InternalPatchEvent
1936
- | MutationEvent
1937
- | PatchesEvent
1938
- | {
1939
- type: 'update readOnly'
1940
- readOnly: boolean
1941
- }
1942
- | {
1943
- type: 'update maxBlocks'
1944
- maxBlocks: number | undefined
1945
- }
1946
- | {
1947
- type: 'add behavior'
1948
- behaviorConfig: BehaviorConfig
1949
- }
1950
- | {
1951
- type: 'remove behavior'
1952
- behaviorConfig: BehaviorConfig
1953
- }
1954
- | {
1955
- type: 'blur'
1956
- editor: PortableTextSlateEditor
1957
- }
1958
- | {
1959
- type: 'focus'
1960
- editor: PortableTextSlateEditor
1961
- }
1962
- | {
1963
- type: 'normalizing'
1964
- }
1965
- | {
1966
- type: 'update selection'
1967
- selection: EditorSelection
1968
- }
1969
- | {
1970
- type: 'done normalizing'
1971
- }
1972
- | {
1973
- type: 'done syncing value'
1974
- }
1975
- | {
1976
- type: 'syncing value'
1977
- }
1978
- | {
1979
- type: 'behavior event'
1980
- behaviorEvent: BehaviorEvent
1981
- editor: PortableTextSlateEditor
1982
- nativeEvent?: {
1983
- preventDefault: () => void
1984
- }
1985
- }
1986
- | {
1987
- type: 'dragstart'
1988
- origin: Pick<EventPosition, 'selection'>
1989
- ghost?: HTMLElement
1990
- }
1991
- | {
1992
- type: 'dragend'
1993
- }
1994
- | {
1995
- type: 'drop'
1996
- },
1997
- | InternalPatchEvent
1998
- | MutationEvent
1999
- | PatchesEvent
2000
- | {
2001
- type: 'update readOnly'
2002
- readOnly: boolean
2003
- }
2004
- | {
2005
- type: 'update maxBlocks'
2006
- maxBlocks: number | undefined
2007
- }
2008
- | {
2009
- type: 'add behavior'
2010
- behaviorConfig: BehaviorConfig
2011
- }
2012
- | {
2013
- type: 'remove behavior'
2014
- behaviorConfig: BehaviorConfig
2015
- }
2016
- | {
2017
- type: 'blur'
2018
- editor: PortableTextSlateEditor
2019
- }
2020
- | {
2021
- type: 'focus'
2022
- editor: PortableTextSlateEditor
2023
- }
2024
- | {
2025
- type: 'normalizing'
2026
- }
2027
- | {
2028
- type: 'update selection'
2029
- selection: EditorSelection
2030
- }
2031
- | {
2032
- type: 'done normalizing'
2033
- }
2034
- | {
2035
- type: 'done syncing value'
2036
- }
2037
- | {
2038
- type: 'syncing value'
2039
- }
2040
- | {
2041
- type: 'behavior event'
2042
- behaviorEvent: BehaviorEvent
2043
- editor: PortableTextSlateEditor
2044
- nativeEvent?: {
2045
- preventDefault: () => void
2046
- }
2047
- }
2048
- | {
2049
- type: 'dragstart'
2050
- origin: Pick<EventPosition, 'selection'>
2051
- ghost?: HTMLElement
2052
- }
2053
- | {
2054
- type: 'dragend'
2055
- }
2056
- | {
2057
- type: 'drop'
2058
- },
2059
- undefined,
2060
- never,
2061
- never,
2062
- never,
2063
- never,
2064
- never
2065
- >,
2066
- ]
2067
- readonly tags: readonly ['dragging internally']
2068
- readonly on: {
2069
- readonly dragend: {
2070
- readonly target: 'idle'
2071
- }
2072
- readonly drop: {
2073
- readonly target: 'idle'
2074
- }
2075
- }
2076
- }
2077
- }
2078
- }
2079
- }
2080
- }
2081
- readonly 'setup': {
2082
- readonly initial: 'setting up'
2083
- readonly states: {
2084
- readonly 'setting up': {
2085
- readonly entry: readonly [() => void]
2086
- readonly exit: readonly [
2087
- () => void,
2088
- 'emit ready',
2089
- 'emit pending incoming patches',
2090
- 'clear pending incoming patches',
2091
- ]
2092
- readonly on: {
2093
- readonly 'internal.patch': {
2094
- readonly actions: 'defer event'
2095
- }
2096
- readonly 'mutation': {
2097
- readonly actions: 'defer event'
2098
- }
2099
- readonly 'done syncing value': {
2100
- readonly target: 'set up'
2101
- }
2102
- readonly 'patches': {
2103
- readonly actions: readonly ['defer incoming patches']
2104
- }
2105
- }
2106
- }
2107
- readonly 'set up': {
2108
- readonly type: 'parallel'
2109
- readonly states: {
2110
- readonly 'value sync': {
2111
- readonly initial: 'idle'
2112
- readonly states: {
2113
- readonly 'idle': {
2114
- readonly entry: readonly [() => void]
2115
- readonly exit: readonly [() => void]
2116
- readonly on: {
2117
- readonly 'patches': {
2118
- readonly actions: readonly [
2119
- ActionFunction<
2120
- {
2121
- behaviors: Set<BehaviorConfig>
2122
- converters: Set<Converter>
2123
- getLegacySchema: () => PortableTextMemberSchemaTypes
2124
- keyGenerator: () => string
2125
- pendingEvents: Array<
2126
- InternalPatchEvent | MutationEvent
2127
- >
2128
- pendingIncomingPatchesEvents: Array<PatchesEvent>
2129
- schema: EditorSchema
2130
- initialReadOnly: boolean
2131
- maxBlocks: number | undefined
2132
- selection: EditorSelection
2133
- initialValue: Array<PortableTextBlock> | undefined
2134
- internalDrag?: {
2135
- ghost?: HTMLElement
2136
- origin: Pick<EventPosition, 'selection'>
2137
- }
2138
- slateEditor?: PortableTextSlateEditor
2139
- },
2140
- PatchesEvent,
2141
- | InternalPatchEvent
2142
- | MutationEvent
2143
- | PatchesEvent
2144
- | {
2145
- type: 'update readOnly'
2146
- readOnly: boolean
2147
- }
2148
- | {
2149
- type: 'update maxBlocks'
2150
- maxBlocks: number | undefined
2151
- }
2152
- | {
2153
- type: 'add behavior'
2154
- behaviorConfig: BehaviorConfig
2155
- }
2156
- | {
2157
- type: 'remove behavior'
2158
- behaviorConfig: BehaviorConfig
2159
- }
2160
- | {
2161
- type: 'blur'
2162
- editor: PortableTextSlateEditor
2163
- }
2164
- | {
2165
- type: 'focus'
2166
- editor: PortableTextSlateEditor
2167
- }
2168
- | {
2169
- type: 'normalizing'
2170
- }
2171
- | {
2172
- type: 'update selection'
2173
- selection: EditorSelection
2174
- }
2175
- | {
2176
- type: 'done normalizing'
2177
- }
2178
- | {
2179
- type: 'done syncing value'
2180
- }
2181
- | {
2182
- type: 'syncing value'
2183
- }
2184
- | {
2185
- type: 'behavior event'
2186
- behaviorEvent: BehaviorEvent
2187
- editor: PortableTextSlateEditor
2188
- nativeEvent?: {
2189
- preventDefault: () => void
2190
- }
2191
- }
2192
- | {
2193
- type: 'dragstart'
2194
- origin: Pick<EventPosition, 'selection'>
2195
- ghost?: HTMLElement
2196
- }
2197
- | {
2198
- type: 'dragend'
2199
- }
2200
- | {
2201
- type: 'drop'
2202
- },
2203
- undefined,
2204
- never,
2205
- never,
2206
- never,
2207
- never,
2208
- | InternalPatchEvent
2209
- | MutationEvent
2210
- | PatchesEvent
2211
- | {
2212
- type: 'blurred'
2213
- event: FocusEvent_2<HTMLDivElement, Element>
2214
- }
2215
- | {
2216
- type: 'done loading'
2217
- }
2218
- | {
2219
- type: 'editable'
2220
- }
2221
- | {
2222
- type: 'error'
2223
- name: string
2224
- description: string
2225
- data: unknown
2226
- }
2227
- | {
2228
- type: 'focused'
2229
- event: FocusEvent_2<HTMLDivElement, Element>
2230
- }
2231
- | {
2232
- type: 'invalid value'
2233
- resolution: InvalidValueResolution | null
2234
- value: Array<PortableTextBlock> | undefined
2235
- }
2236
- | {
2237
- type: 'loading'
2238
- }
2239
- | {
2240
- type: 'read only'
2241
- }
2242
- | {
2243
- type: 'ready'
2244
- }
2245
- | {
2246
- type: 'selection'
2247
- selection: EditorSelection
2248
- }
2249
- | {
2250
- type: 'value changed'
2251
- value: Array<PortableTextBlock> | undefined
2252
- }
2253
- >,
2254
- ]
2255
- }
2256
- readonly 'syncing value': {
2257
- readonly target: 'syncing value'
2258
- }
2259
- }
2260
- }
2261
- readonly 'syncing value': {
2262
- readonly entry: readonly [() => void]
2263
- readonly exit: readonly [
2264
- () => void,
2265
- 'emit pending incoming patches',
2266
- 'clear pending incoming patches',
2267
- ]
2268
- readonly on: {
2269
- readonly 'patches': {
2270
- readonly actions: readonly ['defer incoming patches']
2271
- }
2272
- readonly 'done syncing value': {
2273
- readonly target: 'idle'
2274
- }
2275
- }
2276
- }
2277
- }
2278
- }
2279
- readonly 'writing': {
2280
- readonly initial: 'pristine'
2281
- readonly states: {
2282
- readonly pristine: {
2283
- readonly initial: 'idle'
2284
- readonly states: {
2285
- readonly idle: {
2286
- readonly entry: readonly [() => void]
2287
- readonly exit: readonly [() => void]
2288
- readonly on: {
2289
- readonly 'normalizing': {
2290
- readonly target: 'normalizing'
2291
- }
2292
- readonly 'internal.patch': {
2293
- readonly actions: 'defer event'
2294
- readonly target: '#editor.setup.set up.writing.dirty'
2295
- }
2296
- readonly 'mutation': {
2297
- readonly actions: 'defer event'
2298
- readonly target: '#editor.setup.set up.writing.dirty'
2299
- }
2300
- }
2301
- }
2302
- readonly normalizing: {
2303
- readonly entry: readonly [() => void]
2304
- readonly exit: readonly [() => void]
2305
- readonly on: {
2306
- readonly 'done normalizing': {
2307
- readonly target: 'idle'
2308
- }
2309
- readonly 'internal.patch': {
2310
- readonly actions: 'defer event'
2311
- }
2312
- readonly 'mutation': {
2313
- readonly actions: 'defer event'
2314
- }
2315
- }
2316
- }
2317
- }
2318
- }
2319
- readonly dirty: {
2320
- readonly entry: readonly [
2321
- () => void,
2322
- 'emit pending events',
2323
- 'clear pending events',
2324
- ]
2325
- readonly exit: readonly [() => void]
2326
- readonly on: {
2327
- readonly 'internal.patch': {
2328
- readonly actions: 'emit patch event'
2329
- }
2330
- readonly 'mutation': {
2331
- readonly actions: 'emit mutation event'
2332
- }
2333
- }
2334
- }
2335
- }
2336
- }
2337
- }
2338
- }
2339
- }
2340
- }
2341
- }
2342
- }
2343
- >
2344
-
2345
- declare type EditorPriority = {
2346
- id: string
2347
- name?: string
2348
- reference?: {
2349
- priority: EditorPriority
2350
- importance: 'higher' | 'lower'
2351
- }
2352
- }
2353
-
2354
94
  /**
2355
95
  * @public
2356
96
  */
@@ -2444,27 +184,9 @@ declare type EditorSnapshot = {
2444
184
  beta: {
2445
185
  activeAnnotations: Array<string>
2446
186
  activeDecorators: Array<string>
2447
- hasTag: HasTag
2448
- internalDrag:
2449
- | {
2450
- origin: Pick<EventPosition, 'selection'>
2451
- }
2452
- | undefined
2453
187
  }
2454
188
  }
2455
189
 
2456
- declare type EventPosition = {
2457
- block: 'start' | 'end'
2458
- /**
2459
- * Did the event origin from the editor DOM node itself or from a child node?
2460
- */
2461
- isEditor: boolean
2462
- selection: NonNullable<EditorSelection>
2463
- }
2464
-
2465
- declare type ExtractNamespace<TType extends string> =
2466
- TType extends `${infer Namespace}.${string}` ? Namespace : TType
2467
-
2468
190
  /**
2469
191
  * @public
2470
192
  */
@@ -2799,43 +521,6 @@ export declare const getTrimmedSelection: EditorSelector<EditorSelection>
2799
521
  */
2800
522
  export declare const getValue: EditorSelector<Array<PortableTextBlock>>
2801
523
 
2802
- declare type HasTag = ReturnType<EditorActor['getSnapshot']>['hasTag']
2803
-
2804
- declare interface History_2 {
2805
- redos: HistoryItem[]
2806
- undos: HistoryItem[]
2807
- }
2808
-
2809
- declare type HistoryItem = {
2810
- operations: Operation[]
2811
- timestamp: Date
2812
- }
2813
-
2814
- /**
2815
- * Used to represent native InputEvents that hold a DataTransfer object.
2816
- *
2817
- * These can either be one of:
2818
- *
2819
- * - insertFromPaste
2820
- * - insertFromPasteAsQuotation
2821
- * - insertFromDrop
2822
- * - insertReplacementText
2823
- * - insertFromYank
2824
- */
2825
- declare type InputBehaviorEvent = {
2826
- type: StrictExtract<NativeBehaviorEventType, 'input.*'>
2827
- originEvent: {
2828
- dataTransfer: DataTransfer
2829
- }
2830
- }
2831
-
2832
- declare type InsertPlacement = 'auto' | 'after' | 'before'
2833
-
2834
- declare type InternalPatchEvent = NamespaceEvent<PatchEvent, 'internal'> & {
2835
- operationId?: string
2836
- value: Array<PortableTextBlock>
2837
- }
2838
-
2839
524
  /**
2840
525
  * @public
2841
526
  */
@@ -2914,119 +599,8 @@ export declare const isSelectionCollapsed: EditorSelector<boolean>
2914
599
  */
2915
600
  export declare const isSelectionExpanded: EditorSelector<boolean>
2916
601
 
2917
- declare type KeyboardBehaviorEvent =
2918
- | {
2919
- type: StrictExtract<NativeBehaviorEventType, 'keyboard.keydown'>
2920
- originEvent: Pick<
2921
- KeyboardEvent,
2922
- 'key' | 'code' | 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'
2923
- >
2924
- }
2925
- | {
2926
- type: StrictExtract<NativeBehaviorEventType, 'keyboard.keyup'>
2927
- originEvent: Pick<
2928
- KeyboardEvent,
2929
- 'key' | 'code' | 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'
2930
- >
2931
- }
2932
-
2933
- declare type MarkState = {
2934
- state: 'changed' | 'unchanged'
2935
- marks: Array<string>
2936
- }
2937
-
2938
602
  declare type MIMEType = `${string}/${string}`
2939
603
 
2940
- declare type MouseBehaviorEvent = {
2941
- type: StrictExtract<NativeBehaviorEventType, 'mouse.click'>
2942
- position: EventPosition
2943
- }
2944
-
2945
- /**
2946
- * @public
2947
- */
2948
- declare type MutationEvent = {
2949
- type: 'mutation'
2950
- patches: Array<Patch>
2951
- /**
2952
- * @deprecated Use `value` instead
2953
- */
2954
- snapshot: Array<PortableTextBlock> | undefined
2955
- value: Array<PortableTextBlock> | undefined
2956
- }
2957
-
2958
- declare type NamespacedBehaviorEventType<
2959
- TNamespace extends BehaviorEventTypeNamespace | '',
2960
- > = TNamespace extends ''
2961
- ? BehaviorEvent['type']
2962
- : Extract<BehaviorEvent['type'], TNamespace | `${TNamespace}.${string}`>
2963
-
2964
- declare type NamespaceEvent<
2965
- TEvent,
2966
- TNamespace extends string,
2967
- > = TEvent extends {
2968
- type: infer TEventType
2969
- }
2970
- ? {
2971
- [K in keyof TEvent]: K extends 'type'
2972
- ? `${TNamespace}.${TEventType & string}`
2973
- : TEvent[K]
2974
- }
2975
- : never
2976
-
2977
- /**
2978
- * @beta
2979
- */
2980
- declare type NativeBehaviorEvent =
2981
- | ClipboardBehaviorEvent
2982
- | DragBehaviorEvent
2983
- | InputBehaviorEvent
2984
- | KeyboardBehaviorEvent
2985
- | MouseBehaviorEvent
2986
-
2987
- declare type NativeBehaviorEventNamespace =
2988
- ExtractNamespace<NativeBehaviorEventType>
2989
-
2990
- declare type NativeBehaviorEventType = (typeof nativeBehaviorEventTypes)[number]
2991
-
2992
- /**************************************
2993
- * Native events
2994
- **************************************/
2995
- declare const nativeBehaviorEventTypes: readonly [
2996
- 'clipboard.copy',
2997
- 'clipboard.cut',
2998
- 'clipboard.paste',
2999
- 'drag.dragstart',
3000
- 'drag.drag',
3001
- 'drag.dragend',
3002
- 'drag.dragenter',
3003
- 'drag.dragover',
3004
- 'drag.dragleave',
3005
- 'drag.drop',
3006
- 'input.*',
3007
- 'keyboard.keydown',
3008
- 'keyboard.keyup',
3009
- 'mouse.click',
3010
- ]
3011
-
3012
- declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
3013
- _key?: PortableTextObject['_key']
3014
- }
3015
-
3016
- /**
3017
- * @public
3018
- */
3019
- declare type PatchesEvent = {
3020
- type: 'patches'
3021
- patches: Array<Patch>
3022
- snapshot: Array<PortableTextBlock> | undefined
3023
- }
3024
-
3025
- declare type PatchEvent = {
3026
- type: 'patch'
3027
- patch: Patch
3028
- }
3029
-
3030
604
  /**
3031
605
  * @internal
3032
606
  */
@@ -3036,82 +610,6 @@ declare type PickFromUnion<
3036
610
  TPickedTags extends TUnion[TTagKey],
3037
611
  > = TUnion extends Record<TTagKey, TPickedTags> ? TUnion : never
3038
612
 
3039
- /** @beta */
3040
- declare type PortableTextMemberSchemaTypes = {
3041
- annotations: (ObjectSchemaType & {
3042
- i18nTitleKey?: string
3043
- })[]
3044
- block: ObjectSchemaType
3045
- blockObjects: ObjectSchemaType[]
3046
- decorators: BlockDecoratorDefinition[]
3047
- inlineObjects: ObjectSchemaType[]
3048
- portableText: ArraySchemaType<PortableTextBlock>
3049
- span: ObjectSchemaType
3050
- styles: BlockStyleDefinition[]
3051
- lists: BlockListDefinition[]
3052
- }
3053
-
3054
- declare interface PortableTextSlateEditor extends ReactEditor {
3055
- _key: 'editor'
3056
- _type: 'editor'
3057
- createPlaceholderBlock: () => Descendant
3058
- editable: EditableAPI
3059
- history: History_2
3060
- insertPortableTextData: (data: DataTransfer) => boolean
3061
- insertTextOrHTMLData: (data: DataTransfer) => boolean
3062
- isTextBlock: (value: unknown) => value is PortableTextTextBlock
3063
- isTextSpan: (value: unknown) => value is PortableTextSpan
3064
- isListBlock: (value: unknown) => value is PortableTextListBlock
3065
- value: Array<PortableTextBlock>
3066
- decoratorState: Record<string, boolean | undefined>
3067
- markState: MarkState | undefined
3068
- /**
3069
- * Use hotkeys
3070
- */
3071
- pteWithHotKeys: (event: KeyboardEvent_2<HTMLDivElement>) => void
3072
- /**
3073
- * Helper function that creates a text block
3074
- */
3075
- pteCreateTextBlock: (options: {
3076
- decorators: Array<string>
3077
- listItem?: string
3078
- level?: number
3079
- }) => Descendant
3080
- /**
3081
- * Undo
3082
- */
3083
- undo: () => void
3084
- /**
3085
- * Redo
3086
- */
3087
- redo: () => void
3088
- }
3089
-
3090
- /**************************************
3091
- * Resolve behavior event
3092
- **************************************/
3093
- declare type ResolveBehaviorEvent<
3094
- TBehaviorEventType extends
3095
- | '*'
3096
- | `${BehaviorEventTypeNamespace}.*`
3097
- | BehaviorEvent['type'],
3098
- TPayload extends Record<string, unknown> = Record<string, unknown>,
3099
- > = TBehaviorEventType extends '*'
3100
- ? BehaviorEvent
3101
- : TBehaviorEventType extends `${infer TNamespace}.*`
3102
- ? TNamespace extends BehaviorEventTypeNamespace
3103
- ? PickFromUnion<
3104
- BehaviorEvent,
3105
- 'type',
3106
- NamespacedBehaviorEventType<TNamespace>
3107
- >
3108
- : never
3109
- : TBehaviorEventType extends `custom.${infer TType}`
3110
- ? CustomBehaviorEvent<TPayload, TType>
3111
- : TBehaviorEventType extends BehaviorEvent['type']
3112
- ? PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>
3113
- : never
3114
-
3115
613
  declare type Serializer<TMIMEType extends MIMEType> = ({
3116
614
  snapshot,
3117
615
  event,
@@ -3124,148 +622,4 @@ declare type Serializer<TMIMEType extends MIMEType> = ({
3124
622
  'serialization.success' | 'serialization.failure'
3125
623
  >
3126
624
 
3127
- declare type StrictExtract<T, U extends T> = U
3128
-
3129
- /**
3130
- * @beta
3131
- */
3132
- declare type SyntheticBehaviorEvent =
3133
- | {
3134
- type: StrictExtract<SyntheticBehaviorEventType, 'annotation.add'>
3135
- annotation: {
3136
- name: string
3137
- value: {
3138
- [prop: string]: unknown
3139
- }
3140
- }
3141
- }
3142
- | {
3143
- type: StrictExtract<SyntheticBehaviorEventType, 'annotation.remove'>
3144
- annotation: {
3145
- name: string
3146
- }
3147
- }
3148
- | {
3149
- type: StrictExtract<SyntheticBehaviorEventType, 'block.set'>
3150
- at: [KeyedSegment]
3151
- props: Record<string, unknown>
3152
- }
3153
- | {
3154
- type: StrictExtract<SyntheticBehaviorEventType, 'block.unset'>
3155
- at: [KeyedSegment]
3156
- props: Array<string>
3157
- }
3158
- | {
3159
- type: StrictExtract<SyntheticBehaviorEventType, 'decorator.add'>
3160
- decorator: string
3161
- at?: {
3162
- anchor: BlockOffset
3163
- focus: BlockOffset
3164
- }
3165
- }
3166
- | {
3167
- type: StrictExtract<SyntheticBehaviorEventType, 'decorator.remove'>
3168
- decorator: string
3169
- }
3170
- | {
3171
- type: StrictExtract<SyntheticBehaviorEventType, 'delete'>
3172
- at: NonNullable<EditorSelection>
3173
- /**
3174
- * Defaults to forward deletion.
3175
- */
3176
- direction?: 'backward' | 'forward'
3177
- /**
3178
- * Defaults to character deletion.
3179
- */
3180
- unit?: 'character' | 'word' | 'line' | 'block'
3181
- }
3182
- | {
3183
- type: StrictExtract<SyntheticBehaviorEventType, 'history.redo'>
3184
- }
3185
- | {
3186
- type: StrictExtract<SyntheticBehaviorEventType, 'history.undo'>
3187
- }
3188
- | {
3189
- type: StrictExtract<SyntheticBehaviorEventType, 'insert.inline object'>
3190
- inlineObject: {
3191
- name: string
3192
- value?: {
3193
- [prop: string]: unknown
3194
- }
3195
- }
3196
- }
3197
- | {
3198
- type: StrictExtract<SyntheticBehaviorEventType, 'insert.block'>
3199
- block: BlockWithOptionalKey
3200
- placement: InsertPlacement
3201
- select?: 'start' | 'end' | 'none'
3202
- }
3203
- | {
3204
- type: StrictExtract<SyntheticBehaviorEventType, 'insert.span'>
3205
- text: string
3206
- annotations?: Array<{
3207
- name: string
3208
- value: {
3209
- [prop: string]: unknown
3210
- }
3211
- }>
3212
- decorators?: Array<string>
3213
- }
3214
- | {
3215
- type: StrictExtract<SyntheticBehaviorEventType, 'insert.text'>
3216
- text: string
3217
- }
3218
- | {
3219
- type: StrictExtract<SyntheticBehaviorEventType, 'move.backward'>
3220
- distance: number
3221
- }
3222
- | {
3223
- type: StrictExtract<SyntheticBehaviorEventType, 'move.block'>
3224
- at: [KeyedSegment]
3225
- to: [KeyedSegment]
3226
- }
3227
- | {
3228
- type: StrictExtract<SyntheticBehaviorEventType, 'move.forward'>
3229
- distance: number
3230
- }
3231
- | {
3232
- type: StrictExtract<SyntheticBehaviorEventType, 'select'>
3233
- at: EditorSelection
3234
- }
3235
- | AbstractBehaviorEvent
3236
-
3237
- declare type SyntheticBehaviorEventNamespace =
3238
- ExtractNamespace<SyntheticBehaviorEventType>
3239
-
3240
- declare type SyntheticBehaviorEventType =
3241
- | (typeof syntheticBehaviorEventTypes)[number]
3242
- | (typeof abstractBehaviorEventTypes)[number]
3243
-
3244
- /**************************************
3245
- * Synthetic events
3246
- **************************************/
3247
- declare const syntheticBehaviorEventTypes: readonly [
3248
- 'annotation.add',
3249
- 'annotation.remove',
3250
- 'block.set',
3251
- 'block.unset',
3252
- 'decorator.add',
3253
- 'decorator.remove',
3254
- 'delete',
3255
- 'history.redo',
3256
- 'history.undo',
3257
- 'insert.inline object',
3258
- 'insert.block',
3259
- 'insert.span',
3260
- 'insert.text',
3261
- 'move.backward',
3262
- 'move.block',
3263
- 'move.forward',
3264
- 'select',
3265
- ]
3266
-
3267
- declare type TextBlockWithOptionalKey = Omit<PortableTextTextBlock, '_key'> & {
3268
- _key?: PortableTextTextBlock['_key']
3269
- }
3270
-
3271
625
  export {}