@portabletext/editor 1.48.8 → 1.48.10

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.
@@ -1,16 +1,24 @@
1
1
  import type {Patch} from '@portabletext/patches'
2
- import {ClientPerspective, SanityClient} from '@sanity/client'
3
- import {
4
- ComponentType,
5
- ElementType,
6
- JSX,
7
- default as React_2,
8
- ReactNode,
9
- } from 'react'
2
+ import type {
3
+ ArraySchemaType,
4
+ BlockDecoratorDefinition,
5
+ BlockListDefinition,
6
+ BlockStyleDefinition,
7
+ KeyedSegment,
8
+ ObjectSchemaType,
9
+ Path,
10
+ PortableTextBlock,
11
+ PortableTextChild,
12
+ PortableTextListBlock,
13
+ PortableTextObject,
14
+ PortableTextSpan,
15
+ PortableTextTextBlock,
16
+ } from '@sanity/types'
10
17
  import type {
11
18
  FocusEvent as FocusEvent_2,
12
19
  KeyboardEvent as KeyboardEvent_2,
13
20
  } from 'react'
21
+ import {JSX, default as React_2} from 'react'
14
22
  import type {Descendant, Operation, TextUnit} from 'slate'
15
23
  import type {DOMNode} from 'slate-dom'
16
24
  import type {ReactEditor} from 'slate-react'
@@ -208,277 +216,6 @@ declare const abstractBehaviorEventTypes: readonly [
208
216
  'style.toggle',
209
217
  ]
210
218
 
211
- /**
212
- * Types of array actions that can be performed
213
- * @beta
214
- */
215
- declare type ArrayActionName =
216
- /**
217
- * Add any item to the array at any position
218
- */
219
- | 'add'
220
- /**
221
- * Add item after an existing item
222
- */
223
- | 'addBefore'
224
- /**
225
- * Add item after an existing item
226
- */
227
- | 'addAfter'
228
- /**
229
- * Remove any item
230
- */
231
- | 'remove'
232
- /**
233
- * Duplicate item
234
- */
235
- | 'duplicate'
236
- /**
237
- * Copy item
238
- */
239
- | 'copy'
240
-
241
- /** @public */
242
- declare interface ArrayDefinition extends BaseSchemaDefinition {
243
- type: 'array'
244
- of: ArrayOfType[]
245
- initialValue?: InitialValueProperty<any, unknown[]>
246
- validation?: ValidationBuilder<ArrayRule<unknown[]>, unknown[]>
247
- options?: ArrayOptions
248
- }
249
-
250
- /** @public */
251
- declare type ArrayOfEntry<T> = Omit<T, 'name' | 'hidden'> & {
252
- name?: string
253
- }
254
-
255
- /** @public */
256
- declare type ArrayOfType<
257
- TType extends IntrinsicTypeName = IntrinsicTypeName,
258
- TAlias extends IntrinsicTypeName | undefined = undefined,
259
- > =
260
- | IntrinsicArrayOfDefinition[TType]
261
- | ArrayOfEntry<TypeAliasDefinition<string, TAlias>>
262
-
263
- /** @public */
264
- declare interface ArrayOptions<V = unknown>
265
- extends SearchConfiguration,
266
- BaseSchemaTypeOptions {
267
- list?: TitledListValue<V>[] | V[]
268
- layout?: 'list' | 'tags' | 'grid'
269
- /** @deprecated This option does not have any effect anymore */
270
- direction?: 'horizontal' | 'vertical'
271
- sortable?: boolean
272
- modal?: {
273
- type?: 'dialog' | 'popover'
274
- width?: number | 'auto'
275
- }
276
- /** @alpha This API may change */
277
- insertMenu?: InsertMenuOptions
278
- /**
279
- * A boolean flag to enable or disable tree editing for the array.
280
- * If there are any nested arrays, they will inherit this value.
281
- * @deprecated tree editing beta feature has been disabled
282
- */
283
- treeEditing?: boolean
284
- /**
285
- * A list of array actions to disable
286
- * Possible options are defined by {@link ArrayActionName}
287
- * @beta
288
- */
289
- disableActions?: ArrayActionName[]
290
- }
291
-
292
- /** @public */
293
- declare interface ArrayRule<Value> extends RuleDef<ArrayRule<Value>, Value> {
294
- min: (length: number | FieldReference) => ArrayRule<Value>
295
- max: (length: number | FieldReference) => ArrayRule<Value>
296
- length: (length: number | FieldReference) => ArrayRule<Value>
297
- unique: () => ArrayRule<Value>
298
- }
299
-
300
- /** @public */
301
- declare interface ArraySchemaType<V = unknown> extends BaseSchemaType {
302
- jsonType: 'array'
303
- of: (Exclude<SchemaType, ArraySchemaType> | ReferenceSchemaType)[]
304
- options?: ArrayOptions<V> & {
305
- layout?: V extends string ? 'tag' : 'grid'
306
- }
307
- }
308
-
309
- /** @public */
310
- declare interface Asset extends SanityDocument {
311
- url: string
312
- path: string
313
- assetId: string
314
- extension: string
315
- mimeType: string
316
- sha1hash: string
317
- size: number
318
- originalFilename?: string
319
- label?: string
320
- title?: string
321
- description?: string
322
- creditLine?: string
323
- source?: AssetSourceSpec
324
- }
325
-
326
- /** @public */
327
- declare type AssetFromSource = {
328
- kind: 'assetDocumentId' | 'file' | 'base64' | 'url'
329
- value: string | File_2
330
- assetDocumentProps?: ImageAsset
331
- mediaLibraryProps?: {
332
- mediaLibraryId: string
333
- assetId: string
334
- assetInstanceId: string
335
- }
336
- }
337
-
338
- /** @public */
339
- declare interface AssetSource {
340
- name: string
341
- /** @deprecated provide `i18nKey` instead */
342
- title?: string
343
- i18nKey?: string
344
- component: ComponentType<AssetSourceComponentProps>
345
- icon?: ComponentType<EmptyProps>
346
- /** @beta */
347
- uploader?: AssetSourceUploader
348
- }
349
-
350
- /** @public */
351
- declare interface AssetSourceComponentProps {
352
- action?: 'select' | 'upload'
353
- assetSource: AssetSource
354
- assetType?: 'file' | 'image'
355
- accept: string
356
- selectionType: 'single'
357
- dialogHeaderTitle?: React.ReactNode
358
- selectedAssets: Asset[]
359
- onClose: () => void
360
- onSelect: (assetFromSource: AssetFromSource[]) => void
361
- }
362
-
363
- /** @public */
364
- declare interface AssetSourceSpec {
365
- id: string
366
- name: string
367
- url?: string
368
- }
369
-
370
- /** @beta */
371
- declare interface AssetSourceUploader {
372
- upload(
373
- files: globalThis.File[],
374
- options?: {
375
- /**
376
- * The schema type of the field the asset is being uploaded to.
377
- * May be of interest to the uploader to read file and image options.
378
- */
379
- schemaType?: SchemaType
380
- /**
381
- * The uploader may send patches directly to the field
382
- * Typed 'unknown' as we don't have patch definitions in sanity/types yet.
383
- */
384
- onChange?: (patch: unknown) => void
385
- },
386
- ): AssetSourceUploadFile[]
387
- /**
388
- * Abort the upload of a file
389
- */
390
- abort(file?: AssetSourceUploadFile): void
391
- /**
392
- * Get the files that are currently being uploaded
393
- */
394
- getFiles(): AssetSourceUploadFile[]
395
- /**
396
- * Subscribe to upload events from the uploader
397
- */
398
- subscribe(subscriber: (event: AssetSourceUploadEvent) => void): () => void
399
- /**
400
- * Update the status of a file. Will be emitted to subscribers.
401
- */
402
- updateFile(
403
- fileId: string,
404
- data: {
405
- progress?: number
406
- status?: string
407
- error?: Error
408
- },
409
- ): void
410
- /**
411
- * Reset the uploader (clear files). Should be called by the uploader when all files are done.
412
- */
413
- reset(): void
414
- }
415
-
416
- /** @beta */
417
- declare type AssetSourceUploadEvent =
418
- | AssetSourceUploadEventProgress
419
- | AssetSourceUploadEventStatus
420
- | AssetSourceUploadEventAllComplete
421
- | AssetSourceUploadEventError
422
- | AssetSourceUploadEventAbort
423
-
424
- /**
425
- * Emitted when all files are done, either successfully, aborted or with errors
426
- * @beta */
427
- declare type AssetSourceUploadEventAbort = {
428
- type: 'abort'
429
- /**
430
- * Files aborted
431
- */
432
- files: AssetSourceUploadFile[]
433
- }
434
-
435
- /**
436
- * Emitted when all files are done, either successfully, aborted or with errors
437
- * @beta */
438
- declare type AssetSourceUploadEventAllComplete = {
439
- type: 'all-complete'
440
- files: AssetSourceUploadFile[]
441
- }
442
-
443
- /**
444
- * Emitted when all files are done, either successfully, aborted or with errors
445
- * @beta */
446
- declare type AssetSourceUploadEventError = {
447
- type: 'error'
448
- /**
449
- * Files errored
450
- */
451
- files: AssetSourceUploadFile[]
452
- }
453
-
454
- /**
455
- * Emitted when a file upload is progressing
456
- * @beta */
457
- declare type AssetSourceUploadEventProgress = {
458
- type: 'progress'
459
- file: AssetSourceUploadFile
460
- progress: number
461
- }
462
-
463
- /**
464
- * Emitted when a file upload is changing status
465
- * @beta */
466
- declare type AssetSourceUploadEventStatus = {
467
- type: 'status'
468
- file: AssetSourceUploadFile
469
- status: AssetSourceUploadFile['status']
470
- }
471
-
472
- /** @beta */
473
- declare interface AssetSourceUploadFile {
474
- id: string
475
- file: globalThis.File
476
- progress: number
477
- status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted'
478
- error?: Error
479
- result?: unknown
480
- }
481
-
482
219
  /**
483
220
  * @public
484
221
  */
@@ -487,60 +224,6 @@ declare type BaseDefinition = {
487
224
  title?: string
488
225
  }
489
226
 
490
- /** @public */
491
- declare interface BaseSchemaDefinition {
492
- name: string
493
- title?: string
494
- description?: string | React.JSX.Element
495
- hidden?: ConditionalProperty
496
- readOnly?: ConditionalProperty
497
- icon?: ComponentType | ReactNode
498
- validation?: unknown
499
- initialValue?: unknown
500
- deprecated?: DeprecatedProperty
501
- }
502
-
503
- /** @public */
504
- declare interface BaseSchemaType extends Partial<DeprecationConfiguration> {
505
- name: string
506
- title?: string
507
- description?: string
508
- type?: SchemaType
509
- liveEdit?: boolean
510
- readOnly?: ConditionalProperty
511
- hidden?: ConditionalProperty
512
- icon?: ComponentType
513
- initialValue?: InitialValueProperty<any, any>
514
- validation?: SchemaValidationValue
515
- preview?: PreviewConfig
516
- /** @beta */
517
- components?: {
518
- block?: ComponentType<any>
519
- inlineBlock?: ComponentType<any>
520
- annotation?: ComponentType<any>
521
- diff?: ComponentType<any>
522
- field?: ComponentType<any>
523
- input?: ComponentType<any>
524
- item?: ComponentType<any>
525
- preview?: ComponentType<any>
526
- }
527
- /**
528
- * @deprecated This will be removed.
529
- */
530
- placeholder?: string
531
- }
532
-
533
- /**
534
- * `BaseOptions` applies to all type options.
535
- *
536
- * It can be extended by interface declaration merging in plugins to provide generic options to all types and fields.
537
- *
538
- * @public
539
- * */
540
- declare interface BaseSchemaTypeOptions {
541
- sanityCreate?: SanityCreateOptions
542
- }
543
-
544
227
  /**
545
228
  * @beta
546
229
  */
@@ -633,142 +316,6 @@ export declare function BehaviorPlugin(props: {
633
316
  behaviors: Array<Behavior>
634
317
  }): null
635
318
 
636
- /**
637
- * Schema definition for text block decorators.
638
- *
639
- * @public
640
- * @example The default set of decorators
641
- * ```ts
642
- * {
643
- * name: 'blockContent',
644
- * title: 'Content',
645
- * type: 'array',
646
- * of: [
647
- * {
648
- * type: 'block',
649
- * marks: {
650
- * decorators: [
651
- * {title: 'Strong', value: 'strong'},
652
- * {title: 'Emphasis', value: 'em'},
653
- * {title: 'Underline', value: 'underline'},
654
- * {title: 'Strike', value: 'strike'},
655
- * {title: 'Code', value: 'code'},
656
- * ]
657
- * }
658
- * }
659
- * ]
660
- * }
661
- * ```
662
- */
663
- declare interface BlockDecoratorDefinition {
664
- title: string
665
- i18nTitleKey?: string
666
- value: string
667
- icon?: ReactNode | ComponentType
668
- }
669
-
670
- /**
671
- * Schema definition for text blocks.
672
- *
673
- * @public
674
- * @example the default block definition
675
- * ```ts
676
- * {
677
- * name: 'blockContent',
678
- * title: 'Content',
679
- * type: 'array',
680
- * of: [
681
- * {
682
- * type: 'block',
683
- * marks: {
684
- * decorators: [
685
- * {title: 'Strong', value: 'strong'},
686
- * {title: 'Emphasis', value: 'em'},
687
- * {title: 'Underline', value: 'underline'},
688
- * {title: 'Strike', value: 'strike'},
689
- * {title: 'Code', value: 'code'},
690
- * ],
691
- * annotations: [
692
- * {
693
- * type: 'object',
694
- * name: 'link',
695
- * fields: [
696
- * {
697
- * type: 'string',
698
- * name: 'href',
699
- * },
700
- * ],
701
- * },
702
- * ]
703
- * },
704
- * styles: [
705
- * {title: 'Normal', value: 'normal'},
706
- * {title: 'H1', value: 'h1'},
707
- * {title: 'H2', value: 'h2'},
708
- * {title: 'H3', value: 'h3'},
709
- * {title: 'H4', value: 'h4'},
710
- * {title: 'H5', value: 'h5'},
711
- * {title: 'H6', value: 'h6'},
712
- * {title: 'Quote', value: 'blockquote'}
713
- * ],
714
- * lists: [
715
- * {title: 'Bullet', value: 'bullet'},
716
- * {title: 'Number', value: 'number'},
717
- * ],
718
- * },
719
- * ]
720
- * }
721
- * ```
722
- */
723
- declare interface BlockDefinition extends BaseSchemaDefinition {
724
- type: 'block'
725
- styles?: BlockStyleDefinition[]
726
- lists?: BlockListDefinition[]
727
- marks?: BlockMarksDefinition
728
- of?: ArrayOfType<'object' | 'reference'>[]
729
- initialValue?: InitialValueProperty<any, any[]>
730
- options?: BlockOptions
731
- validation?: ValidationBuilder<BlockRule, any[]>
732
- }
733
-
734
- /**
735
- * Schema definition for a text block list style.
736
- *
737
- * @public
738
- * @example The defaults lists
739
- * ```ts
740
- * {
741
- * name: 'blockContent',
742
- * title: 'Content',
743
- * type: 'array',
744
- * of: [
745
- * {
746
- * type: 'block',
747
- * lists: [
748
- * {title: 'Bullet', value: 'bullet'},
749
- * {title: 'Number', value: 'number'},
750
- * ]
751
- * }
752
- * ]
753
- * }
754
- * ```
755
- */
756
- declare interface BlockListDefinition {
757
- title: string
758
- i18nTitleKey?: string
759
- value: string
760
- icon?: ReactNode | ComponentType
761
- }
762
-
763
- /**
764
- * Schema definition for text block marks (decorators and annotations).
765
- *
766
- * @public */
767
- declare interface BlockMarksDefinition {
768
- decorators?: BlockDecoratorDefinition[]
769
- annotations?: ArrayOfType<'object' | 'reference'>[]
770
- }
771
-
772
319
  /**
773
320
  * @beta
774
321
  */
@@ -777,108 +324,10 @@ declare type BlockOffset = {
777
324
  offset: number
778
325
  }
779
326
 
780
- /**
781
- * Schema options for a Block schema definition
782
- * @public */
783
- declare interface BlockOptions extends BaseSchemaTypeOptions {
784
- /**
785
- * Turn on or off the builtin browser spellchecking. Default is on.
786
- */
787
- spellCheck?: boolean
788
- unstable_whitespaceOnPasteMode?: 'preserve' | 'normalize' | 'remove'
789
- }
790
-
791
- /** @public */
792
- declare interface BlockRule extends RuleDef<BlockRule, any[]> {}
793
-
794
- /**
795
- * Schema definition for a text block style.
796
- * A text block may have a block style like 'header', 'normal', 'lead'
797
- * attached to it, which is stored on the `.style` property for that block.
798
- *
799
- * @public
800
- * @remarks The first defined style will become the default style.´´
801
- * @example The default set of styles
802
- * ```ts
803
- * {
804
- * name: 'blockContent',
805
- * title: 'Content',
806
- * type: 'array',
807
- * of: [
808
- * {
809
- * type: 'block',
810
- * styles: [
811
- * {title: 'Normal', value: 'normal'},
812
- * {title: 'H1', value: 'h1'},
813
- * {title: 'H2', value: 'h2'},
814
- * {title: 'H3', value: 'h3'},
815
- * {title: 'H4', value: 'h4'},
816
- * {title: 'H5', value: 'h5'},
817
- * {title: 'H6', value: 'h6'},
818
- * {title: 'Quote', value: 'blockquote'}
819
- * ]
820
- * }
821
- * ]
822
- * }
823
- * ```
824
- * @example Example of defining a block type with custom styles and render components.
825
- * ```ts
826
- * defineArrayMember({
827
- * type: 'block',
828
- * styles: [
829
- * {
830
- * title: 'Paragraph',
831
- * value: 'paragraph',
832
- * component: ParagraphStyle,
833
- * },
834
- * {
835
- * title: 'Lead',
836
- * value: 'lead',
837
- * component: LeadStyle,
838
- * },
839
- * {
840
- * title: 'Heading',
841
- * value: 'heading',
842
- * component: HeadingStyle,
843
- * },
844
- * ],
845
- * })
846
- * ```
847
- */
848
- declare interface BlockStyleDefinition {
849
- title: string
850
- value: string
851
- i18nTitleKey?: string
852
- icon?: ReactNode | ComponentType
853
- }
854
-
855
327
  declare type BlockWithOptionalKey =
856
328
  | TextBlockWithOptionalKey
857
329
  | ObjectBlockWithOptionalKey
858
330
 
859
- /** @public */
860
- declare interface BooleanDefinition extends BaseSchemaDefinition {
861
- type: 'boolean'
862
- options?: BooleanOptions
863
- initialValue?: InitialValueProperty<any, boolean>
864
- validation?: ValidationBuilder<BooleanRule, boolean>
865
- }
866
-
867
- /** @public */
868
- declare interface BooleanOptions extends BaseSchemaTypeOptions {
869
- layout?: 'switch' | 'checkbox'
870
- }
871
-
872
- /** @public */
873
- declare interface BooleanRule extends RuleDef<BooleanRule, boolean> {}
874
-
875
- /** @public */
876
- declare interface BooleanSchemaType extends BaseSchemaType {
877
- jsonType: 'boolean'
878
- options?: BooleanOptions
879
- initialValue?: InitialValueProperty<any, boolean>
880
- }
881
-
882
331
  declare type ClipboardBehaviorEvent =
883
332
  | {
884
333
  type: StrictExtract<NativeBehaviorEventType, 'clipboard.copy'>
@@ -902,35 +351,6 @@ declare type ClipboardBehaviorEvent =
902
351
  position: Pick<EventPosition, 'selection'>
903
352
  }
904
353
 
905
- /** @public */
906
- declare interface CollapseOptions {
907
- collapsed?: boolean
908
- collapsible?: boolean
909
- /**
910
- * @deprecated Use `collapsible` instead
911
- */
912
- collapsable?: boolean
913
- }
914
-
915
- /** @public */
916
- declare type ConditionalProperty =
917
- | boolean
918
- | ConditionalPropertyCallback
919
- | undefined
920
-
921
- /** @public */
922
- declare type ConditionalPropertyCallback = (
923
- context: ConditionalPropertyCallbackContext,
924
- ) => boolean
925
-
926
- /** @public */
927
- declare interface ConditionalPropertyCallbackContext {
928
- document: SanityDocument | undefined
929
- parent: any
930
- value: any
931
- currentUser: Omit<CurrentUser, 'role'> | null
932
- }
933
-
934
354
  declare type Converter<TMIMEType extends MIMEType = MIMEType> = {
935
355
  mimeType: TMIMEType
936
356
  serialize: Serializer<TMIMEType>
@@ -974,46 +394,6 @@ declare type ConverterEvent<TMIMEType extends MIMEType = MIMEType> =
974
394
  */
975
395
  export declare function CoreBehaviorsPlugin(): JSX.Element
976
396
 
977
- /** @public */
978
- declare interface CrossDatasetReferenceDefinition extends BaseSchemaDefinition {
979
- type: 'crossDatasetReference'
980
- weak?: boolean
981
- to: {
982
- type: string
983
- title?: string
984
- icon?: ComponentType
985
- preview?: PreviewConfig
986
- /**
987
- * @deprecated Unused. Configuring search is no longer supported.
988
- */
989
- __experimental_search?: {
990
- path: string | string[]
991
- weight?: number
992
- mapWith?: string
993
- }[]
994
- }[]
995
- dataset: string
996
- studioUrl?: (document: {id: string; type?: string}) => string | null
997
- tokenId?: string
998
- options?: ReferenceOptions
999
- /**
1000
- * @deprecated Cross-project references are no longer supported, only cross-dataset
1001
- */
1002
- projectId?: string
1003
- }
1004
-
1005
- /** @public */
1006
- declare interface CurrentUser {
1007
- id: string
1008
- name: string
1009
- email: string
1010
- profileImage?: string
1011
- provider?: string
1012
- /** @deprecated use `roles` instead */
1013
- role: string
1014
- roles: Role[]
1015
- }
1016
-
1017
397
  /**
1018
398
  * @beta
1019
399
  */
@@ -1038,77 +418,6 @@ declare type CustomBehaviorEventType<
1038
418
  TType extends string = '',
1039
419
  > = TType extends '' ? `${TNamespace}` : `${TNamespace}.${TType}`
1040
420
 
1041
- /** @public */
1042
- declare interface CustomValidator<T = unknown> {
1043
- (
1044
- value: T,
1045
- context: ValidationContext,
1046
- ): CustomValidatorResult | Promise<CustomValidatorResult>
1047
- bypassConcurrencyLimit?: boolean
1048
- }
1049
-
1050
- /** @public */
1051
- declare type CustomValidatorResult =
1052
- | true
1053
- | string
1054
- | ValidationError
1055
- | ValidationError[]
1056
- | LocalizedValidationMessages
1057
-
1058
- /** @public */
1059
- declare interface DateDefinition extends BaseSchemaDefinition {
1060
- type: 'date'
1061
- options?: DateOptions
1062
- placeholder?: string
1063
- validation?: ValidationBuilder<DateRule, string>
1064
- initialValue?: InitialValueProperty<any, string>
1065
- }
1066
-
1067
- /** @public */
1068
- declare interface DateOptions extends BaseSchemaTypeOptions {
1069
- dateFormat?: string
1070
- }
1071
-
1072
- /** @public */
1073
- declare interface DateRule extends RuleDef<DateRule, string> {
1074
- /**
1075
- * @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
1076
- */
1077
- min: (minDate: string | FieldReference) => DateRule
1078
- /**
1079
- * @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
1080
- */
1081
- max: (maxDate: string | FieldReference) => DateRule
1082
- }
1083
-
1084
- /** @public */
1085
- declare interface DatetimeDefinition extends BaseSchemaDefinition {
1086
- type: 'datetime'
1087
- options?: DatetimeOptions
1088
- placeholder?: string
1089
- validation?: ValidationBuilder<DatetimeRule, string>
1090
- initialValue?: InitialValueProperty<any, string>
1091
- }
1092
-
1093
- /** @public */
1094
- declare interface DatetimeOptions extends BaseSchemaTypeOptions {
1095
- dateFormat?: string
1096
- timeFormat?: string
1097
- timeStep?: number
1098
- }
1099
-
1100
- /** @public */
1101
- declare interface DatetimeRule extends RuleDef<DatetimeRule, string> {
1102
- /**
1103
- * @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
1104
- */
1105
- min: (minDate: string | FieldReference) => DatetimeRule
1106
- /**
1107
- * @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
1108
- */
1109
- max: (maxDate: string | FieldReference) => DatetimeRule
1110
- }
1111
-
1112
421
  /**
1113
422
  * @beta
1114
423
  * @deprecated Install the plugin from `@portabletext/plugin-character-pair-decorator`
@@ -1121,18 +430,6 @@ export declare function DecoratorShortcutPlugin(config: {
1121
430
  }
1122
431
  }): null
1123
432
 
1124
- /** @public */
1125
- declare interface DeprecatedProperty {
1126
- reason: string
1127
- }
1128
-
1129
- /**
1130
- * @public
1131
- */
1132
- declare interface DeprecationConfiguration {
1133
- deprecated: DeprecatedProperty
1134
- }
1135
-
1136
433
  declare type Deserializer<TMIMEType extends MIMEType> = ({
1137
434
  snapshot,
1138
435
  event,
@@ -1145,40 +442,6 @@ declare type Deserializer<TMIMEType extends MIMEType> = ({
1145
442
  'deserialization.success' | 'deserialization.failure'
1146
443
  >
1147
444
 
1148
- /** @public */
1149
- declare interface DocumentDefinition extends Omit<ObjectDefinition, 'type'> {
1150
- type: 'document'
1151
- liveEdit?: boolean
1152
- /** @beta */
1153
- orderings?: SortOrdering[]
1154
- options?: DocumentOptions
1155
- validation?: ValidationBuilder<DocumentRule, SanityDocument>
1156
- initialValue?: InitialValueProperty<any, Record<string, unknown>>
1157
- /** @deprecated Unused. Use the new field-level search config. */
1158
- __experimental_search?: {
1159
- path: string
1160
- weight: number
1161
- mapWith?: string
1162
- }[]
1163
- /** @alpha */
1164
- __experimental_omnisearch_visibility?: boolean
1165
- /**
1166
- * Determines whether the large preview title is displayed in the document pane form
1167
- * @alpha
1168
- * */
1169
- __experimental_formPreviewTitle?: boolean
1170
- }
1171
-
1172
- /**
1173
- * This exists only to allow for extensions using declaration-merging.
1174
- *
1175
- * @public
1176
- */
1177
- declare interface DocumentOptions extends BaseSchemaTypeOptions {}
1178
-
1179
- /** @public */
1180
- declare interface DocumentRule extends RuleDef<DocumentRule, SanityDocument> {}
1181
-
1182
445
  declare type DragBehaviorEvent =
1183
446
  | {
1184
447
  type: StrictExtract<NativeBehaviorEventType, 'drag.dragstart'>
@@ -1411,6 +674,7 @@ declare const editorMachine: StateMachine<
1411
674
  getLegacySchema: () => PortableTextMemberSchemaTypes
1412
675
  keyGenerator: () => string
1413
676
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
677
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
1414
678
  schema: EditorSchema
1415
679
  initialReadOnly: boolean
1416
680
  maxBlocks: number | undefined
@@ -1424,6 +688,7 @@ declare const editorMachine: StateMachine<
1424
688
  },
1425
689
  | InternalPatchEvent
1426
690
  | MutationEvent
691
+ | PatchesEvent
1427
692
  | {
1428
693
  type: 'add behavior'
1429
694
  behavior: Behavior
@@ -1456,7 +721,6 @@ declare const editorMachine: StateMachine<
1456
721
  type: 'update maxBlocks'
1457
722
  maxBlocks: number | undefined
1458
723
  }
1459
- | PatchesEvent
1460
724
  | {
1461
725
  type: 'blur'
1462
726
  editor: PortableTextSlateEditor
@@ -1472,7 +736,10 @@ declare const editorMachine: StateMachine<
1472
736
  type: 'done normalizing'
1473
737
  }
1474
738
  | {
1475
- type: 'done syncing initial value'
739
+ type: 'done syncing value'
740
+ }
741
+ | {
742
+ type: 'syncing value'
1476
743
  }
1477
744
  | {
1478
745
  type: 'behavior event'
@@ -1600,6 +867,18 @@ declare const editorMachine: StateMachine<
1600
867
  type: 'clear pending events'
1601
868
  params: NonReducibleUnknown
1602
869
  }
870
+ 'defer incoming patches': {
871
+ type: 'defer incoming patches'
872
+ params: NonReducibleUnknown
873
+ }
874
+ 'emit pending incoming patches': {
875
+ type: 'emit pending incoming patches'
876
+ params: NonReducibleUnknown
877
+ }
878
+ 'clear pending incoming patches': {
879
+ type: 'clear pending incoming patches'
880
+ params: NonReducibleUnknown
881
+ }
1603
882
  'handle blur': {
1604
883
  type: 'handle blur'
1605
884
  params: unknown
@@ -1633,9 +912,15 @@ declare const editorMachine: StateMachine<
1633
912
  }
1634
913
  'setup':
1635
914
  | 'setting up'
1636
- | 'dirty'
1637
915
  | {
1638
- pristine: 'normalizing' | 'idle'
916
+ 'set up': {
917
+ 'value sync': 'syncing value' | 'idle'
918
+ 'writing':
919
+ | 'dirty'
920
+ | {
921
+ pristine: 'normalizing' | 'idle'
922
+ }
923
+ }
1639
924
  }
1640
925
  },
1641
926
  'dragging internally',
@@ -1743,6 +1028,7 @@ declare const editorMachine: StateMachine<
1743
1028
  getLegacySchema: () => PortableTextMemberSchemaTypes
1744
1029
  keyGenerator: () => string
1745
1030
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1031
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
1746
1032
  schema: EditorSchema
1747
1033
  initialReadOnly: boolean
1748
1034
  maxBlocks: number | undefined
@@ -1756,6 +1042,7 @@ declare const editorMachine: StateMachine<
1756
1042
  },
1757
1043
  | InternalPatchEvent
1758
1044
  | MutationEvent
1045
+ | PatchesEvent
1759
1046
  | {
1760
1047
  type: 'add behavior'
1761
1048
  behavior: Behavior
@@ -1788,7 +1075,6 @@ declare const editorMachine: StateMachine<
1788
1075
  type: 'update maxBlocks'
1789
1076
  maxBlocks: number | undefined
1790
1077
  }
1791
- | PatchesEvent
1792
1078
  | {
1793
1079
  type: 'blur'
1794
1080
  editor: PortableTextSlateEditor
@@ -1804,7 +1090,10 @@ declare const editorMachine: StateMachine<
1804
1090
  type: 'done normalizing'
1805
1091
  }
1806
1092
  | {
1807
- type: 'done syncing initial value'
1093
+ type: 'done syncing value'
1094
+ }
1095
+ | {
1096
+ type: 'syncing value'
1808
1097
  }
1809
1098
  | {
1810
1099
  type: 'behavior event'
@@ -1890,6 +1179,7 @@ declare const editorMachine: StateMachine<
1890
1179
  >,
1891
1180
  | InternalPatchEvent
1892
1181
  | MutationEvent
1182
+ | PatchesEvent
1893
1183
  | {
1894
1184
  type: 'add behavior'
1895
1185
  behavior: Behavior
@@ -1922,7 +1212,6 @@ declare const editorMachine: StateMachine<
1922
1212
  type: 'update maxBlocks'
1923
1213
  maxBlocks: number | undefined
1924
1214
  }
1925
- | PatchesEvent
1926
1215
  | {
1927
1216
  type: 'blur'
1928
1217
  editor: PortableTextSlateEditor
@@ -1938,7 +1227,10 @@ declare const editorMachine: StateMachine<
1938
1227
  type: 'done normalizing'
1939
1228
  }
1940
1229
  | {
1941
- type: 'done syncing initial value'
1230
+ type: 'done syncing value'
1231
+ }
1232
+ | {
1233
+ type: 'syncing value'
1942
1234
  }
1943
1235
  | {
1944
1236
  type: 'behavior event'
@@ -2023,6 +1315,7 @@ declare const editorMachine: StateMachine<
2023
1315
  getLegacySchema: () => PortableTextMemberSchemaTypes
2024
1316
  keyGenerator: () => string
2025
1317
  pendingEvents: never[]
1318
+ pendingIncomingPatchesEvents: never[]
2026
1319
  schema: EditorSchema
2027
1320
  selection: null
2028
1321
  initialReadOnly: boolean
@@ -2038,6 +1331,7 @@ declare const editorMachine: StateMachine<
2038
1331
  getLegacySchema: () => PortableTextMemberSchemaTypes
2039
1332
  keyGenerator: () => string
2040
1333
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1334
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
2041
1335
  schema: EditorSchema
2042
1336
  initialReadOnly: boolean
2043
1337
  maxBlocks: number | undefined
@@ -2055,6 +1349,7 @@ declare const editorMachine: StateMachine<
2055
1349
  },
2056
1350
  | InternalPatchEvent
2057
1351
  | MutationEvent
1352
+ | PatchesEvent
2058
1353
  | {
2059
1354
  type: 'add behavior'
2060
1355
  behavior: Behavior
@@ -2087,7 +1382,6 @@ declare const editorMachine: StateMachine<
2087
1382
  type: 'update maxBlocks'
2088
1383
  maxBlocks: number | undefined
2089
1384
  }
2090
- | PatchesEvent
2091
1385
  | {
2092
1386
  type: 'blur'
2093
1387
  editor: PortableTextSlateEditor
@@ -2103,7 +1397,10 @@ declare const editorMachine: StateMachine<
2103
1397
  type: 'done normalizing'
2104
1398
  }
2105
1399
  | {
2106
- type: 'done syncing initial value'
1400
+ type: 'done syncing value'
1401
+ }
1402
+ | {
1403
+ type: 'syncing value'
2107
1404
  }
2108
1405
  | {
2109
1406
  type: 'behavior event'
@@ -2242,6 +1539,7 @@ declare const editorMachine: StateMachine<
2242
1539
  getLegacySchema: () => PortableTextMemberSchemaTypes
2243
1540
  keyGenerator: () => string
2244
1541
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1542
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
2245
1543
  schema: EditorSchema
2246
1544
  initialReadOnly: boolean
2247
1545
  maxBlocks: number | undefined
@@ -2258,6 +1556,7 @@ declare const editorMachine: StateMachine<
2258
1556
  },
2259
1557
  | InternalPatchEvent
2260
1558
  | MutationEvent
1559
+ | PatchesEvent
2261
1560
  | {
2262
1561
  type: 'add behavior'
2263
1562
  behavior: Behavior
@@ -2290,7 +1589,6 @@ declare const editorMachine: StateMachine<
2290
1589
  type: 'update maxBlocks'
2291
1590
  maxBlocks: number | undefined
2292
1591
  }
2293
- | PatchesEvent
2294
1592
  | {
2295
1593
  type: 'blur'
2296
1594
  editor: PortableTextSlateEditor
@@ -2306,7 +1604,10 @@ declare const editorMachine: StateMachine<
2306
1604
  type: 'done normalizing'
2307
1605
  }
2308
1606
  | {
2309
- type: 'done syncing initial value'
1607
+ type: 'done syncing value'
1608
+ }
1609
+ | {
1610
+ type: 'syncing value'
2310
1611
  }
2311
1612
  | {
2312
1613
  type: 'behavior event'
@@ -2445,6 +1746,7 @@ declare const editorMachine: StateMachine<
2445
1746
  getLegacySchema: () => PortableTextMemberSchemaTypes
2446
1747
  keyGenerator: () => string
2447
1748
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1749
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
2448
1750
  schema: EditorSchema
2449
1751
  initialReadOnly: boolean
2450
1752
  maxBlocks: number | undefined
@@ -2464,6 +1766,7 @@ declare const editorMachine: StateMachine<
2464
1766
  },
2465
1767
  | InternalPatchEvent
2466
1768
  | MutationEvent
1769
+ | PatchesEvent
2467
1770
  | {
2468
1771
  type: 'add behavior'
2469
1772
  behavior: Behavior
@@ -2496,7 +1799,6 @@ declare const editorMachine: StateMachine<
2496
1799
  type: 'update maxBlocks'
2497
1800
  maxBlocks: number | undefined
2498
1801
  }
2499
- | PatchesEvent
2500
1802
  | {
2501
1803
  type: 'blur'
2502
1804
  editor: PortableTextSlateEditor
@@ -2512,7 +1814,10 @@ declare const editorMachine: StateMachine<
2512
1814
  type: 'done normalizing'
2513
1815
  }
2514
1816
  | {
2515
- type: 'done syncing initial value'
1817
+ type: 'done syncing value'
1818
+ }
1819
+ | {
1820
+ type: 'syncing value'
2516
1821
  }
2517
1822
  | {
2518
1823
  type: 'behavior event'
@@ -2651,6 +1956,7 @@ declare const editorMachine: StateMachine<
2651
1956
  getLegacySchema: () => PortableTextMemberSchemaTypes
2652
1957
  keyGenerator: () => string
2653
1958
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1959
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
2654
1960
  schema: EditorSchema
2655
1961
  initialReadOnly: boolean
2656
1962
  maxBlocks: number | undefined
@@ -2669,6 +1975,7 @@ declare const editorMachine: StateMachine<
2669
1975
  },
2670
1976
  | InternalPatchEvent
2671
1977
  | MutationEvent
1978
+ | PatchesEvent
2672
1979
  | {
2673
1980
  type: 'add behavior'
2674
1981
  behavior: Behavior
@@ -2701,7 +2008,6 @@ declare const editorMachine: StateMachine<
2701
2008
  type: 'update maxBlocks'
2702
2009
  maxBlocks: number | undefined
2703
2010
  }
2704
- | PatchesEvent
2705
2011
  | {
2706
2012
  type: 'blur'
2707
2013
  editor: PortableTextSlateEditor
@@ -2717,7 +2023,10 @@ declare const editorMachine: StateMachine<
2717
2023
  type: 'done normalizing'
2718
2024
  }
2719
2025
  | {
2720
- type: 'done syncing initial value'
2026
+ type: 'done syncing value'
2027
+ }
2028
+ | {
2029
+ type: 'syncing value'
2721
2030
  }
2722
2031
  | {
2723
2032
  type: 'behavior event'
@@ -2856,6 +2165,7 @@ declare const editorMachine: StateMachine<
2856
2165
  getLegacySchema: () => PortableTextMemberSchemaTypes
2857
2166
  keyGenerator: () => string
2858
2167
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2168
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
2859
2169
  schema: EditorSchema
2860
2170
  initialReadOnly: boolean
2861
2171
  maxBlocks: number | undefined
@@ -2873,6 +2183,7 @@ declare const editorMachine: StateMachine<
2873
2183
  },
2874
2184
  | InternalPatchEvent
2875
2185
  | MutationEvent
2186
+ | PatchesEvent
2876
2187
  | {
2877
2188
  type: 'add behavior'
2878
2189
  behavior: Behavior
@@ -2905,7 +2216,6 @@ declare const editorMachine: StateMachine<
2905
2216
  type: 'update maxBlocks'
2906
2217
  maxBlocks: number | undefined
2907
2218
  }
2908
- | PatchesEvent
2909
2219
  | {
2910
2220
  type: 'blur'
2911
2221
  editor: PortableTextSlateEditor
@@ -2921,7 +2231,10 @@ declare const editorMachine: StateMachine<
2921
2231
  type: 'done normalizing'
2922
2232
  }
2923
2233
  | {
2924
- type: 'done syncing initial value'
2234
+ type: 'done syncing value'
2235
+ }
2236
+ | {
2237
+ type: 'syncing value'
2925
2238
  }
2926
2239
  | {
2927
2240
  type: 'behavior event'
@@ -3061,6 +2374,7 @@ declare const editorMachine: StateMachine<
3061
2374
  getLegacySchema: () => PortableTextMemberSchemaTypes
3062
2375
  keyGenerator: () => string
3063
2376
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2377
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
3064
2378
  schema: EditorSchema
3065
2379
  initialReadOnly: boolean
3066
2380
  maxBlocks: number | undefined
@@ -3078,6 +2392,7 @@ declare const editorMachine: StateMachine<
3078
2392
  },
3079
2393
  | InternalPatchEvent
3080
2394
  | MutationEvent
2395
+ | PatchesEvent
3081
2396
  | {
3082
2397
  type: 'add behavior'
3083
2398
  behavior: Behavior
@@ -3110,7 +2425,6 @@ declare const editorMachine: StateMachine<
3110
2425
  type: 'update maxBlocks'
3111
2426
  maxBlocks: number | undefined
3112
2427
  }
3113
- | PatchesEvent
3114
2428
  | {
3115
2429
  type: 'blur'
3116
2430
  editor: PortableTextSlateEditor
@@ -3126,7 +2440,10 @@ declare const editorMachine: StateMachine<
3126
2440
  type: 'done normalizing'
3127
2441
  }
3128
2442
  | {
3129
- type: 'done syncing initial value'
2443
+ type: 'done syncing value'
2444
+ }
2445
+ | {
2446
+ type: 'syncing value'
3130
2447
  }
3131
2448
  | {
3132
2449
  type: 'behavior event'
@@ -3217,6 +2534,7 @@ declare const editorMachine: StateMachine<
3217
2534
  getLegacySchema: () => PortableTextMemberSchemaTypes
3218
2535
  keyGenerator: () => string
3219
2536
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2537
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
3220
2538
  schema: EditorSchema
3221
2539
  initialReadOnly: boolean
3222
2540
  maxBlocks: number | undefined
@@ -3234,6 +2552,7 @@ declare const editorMachine: StateMachine<
3234
2552
  },
3235
2553
  | InternalPatchEvent
3236
2554
  | MutationEvent
2555
+ | PatchesEvent
3237
2556
  | {
3238
2557
  type: 'add behavior'
3239
2558
  behavior: Behavior
@@ -3266,7 +2585,6 @@ declare const editorMachine: StateMachine<
3266
2585
  type: 'update maxBlocks'
3267
2586
  maxBlocks: number | undefined
3268
2587
  }
3269
- | PatchesEvent
3270
2588
  | {
3271
2589
  type: 'blur'
3272
2590
  editor: PortableTextSlateEditor
@@ -3282,7 +2600,10 @@ declare const editorMachine: StateMachine<
3282
2600
  type: 'done normalizing'
3283
2601
  }
3284
2602
  | {
3285
- type: 'done syncing initial value'
2603
+ type: 'done syncing value'
2604
+ }
2605
+ | {
2606
+ type: 'syncing value'
3286
2607
  }
3287
2608
  | {
3288
2609
  type: 'behavior event'
@@ -3422,6 +2743,7 @@ declare const editorMachine: StateMachine<
3422
2743
  getLegacySchema: () => PortableTextMemberSchemaTypes
3423
2744
  keyGenerator: () => string
3424
2745
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2746
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
3425
2747
  schema: EditorSchema
3426
2748
  initialReadOnly: boolean
3427
2749
  maxBlocks: number | undefined
@@ -3439,6 +2761,7 @@ declare const editorMachine: StateMachine<
3439
2761
  },
3440
2762
  | InternalPatchEvent
3441
2763
  | MutationEvent
2764
+ | PatchesEvent
3442
2765
  | {
3443
2766
  type: 'add behavior'
3444
2767
  behavior: Behavior
@@ -3471,7 +2794,6 @@ declare const editorMachine: StateMachine<
3471
2794
  type: 'update maxBlocks'
3472
2795
  maxBlocks: number | undefined
3473
2796
  }
3474
- | PatchesEvent
3475
2797
  | {
3476
2798
  type: 'blur'
3477
2799
  editor: PortableTextSlateEditor
@@ -3487,7 +2809,10 @@ declare const editorMachine: StateMachine<
3487
2809
  type: 'done normalizing'
3488
2810
  }
3489
2811
  | {
3490
- type: 'done syncing initial value'
2812
+ type: 'done syncing value'
2813
+ }
2814
+ | {
2815
+ type: 'syncing value'
3491
2816
  }
3492
2817
  | {
3493
2818
  type: 'behavior event'
@@ -3626,6 +2951,7 @@ declare const editorMachine: StateMachine<
3626
2951
  getLegacySchema: () => PortableTextMemberSchemaTypes
3627
2952
  keyGenerator: () => string
3628
2953
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2954
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
3629
2955
  schema: EditorSchema
3630
2956
  initialReadOnly: boolean
3631
2957
  maxBlocks: number | undefined
@@ -3642,6 +2968,7 @@ declare const editorMachine: StateMachine<
3642
2968
  },
3643
2969
  | InternalPatchEvent
3644
2970
  | MutationEvent
2971
+ | PatchesEvent
3645
2972
  | {
3646
2973
  type: 'add behavior'
3647
2974
  behavior: Behavior
@@ -3674,7 +3001,6 @@ declare const editorMachine: StateMachine<
3674
3001
  type: 'update maxBlocks'
3675
3002
  maxBlocks: number | undefined
3676
3003
  }
3677
- | PatchesEvent
3678
3004
  | {
3679
3005
  type: 'blur'
3680
3006
  editor: PortableTextSlateEditor
@@ -3690,7 +3016,10 @@ declare const editorMachine: StateMachine<
3690
3016
  type: 'done normalizing'
3691
3017
  }
3692
3018
  | {
3693
- type: 'done syncing initial value'
3019
+ type: 'done syncing value'
3020
+ }
3021
+ | {
3022
+ type: 'syncing value'
3694
3023
  }
3695
3024
  | {
3696
3025
  type: 'behavior event'
@@ -3829,6 +3158,7 @@ declare const editorMachine: StateMachine<
3829
3158
  getLegacySchema: () => PortableTextMemberSchemaTypes
3830
3159
  keyGenerator: () => string
3831
3160
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3161
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
3832
3162
  schema: EditorSchema
3833
3163
  initialReadOnly: boolean
3834
3164
  maxBlocks: number | undefined
@@ -3846,6 +3176,7 @@ declare const editorMachine: StateMachine<
3846
3176
  },
3847
3177
  | InternalPatchEvent
3848
3178
  | MutationEvent
3179
+ | PatchesEvent
3849
3180
  | {
3850
3181
  type: 'add behavior'
3851
3182
  behavior: Behavior
@@ -3878,7 +3209,6 @@ declare const editorMachine: StateMachine<
3878
3209
  type: 'update maxBlocks'
3879
3210
  maxBlocks: number | undefined
3880
3211
  }
3881
- | PatchesEvent
3882
3212
  | {
3883
3213
  type: 'blur'
3884
3214
  editor: PortableTextSlateEditor
@@ -3894,7 +3224,10 @@ declare const editorMachine: StateMachine<
3894
3224
  type: 'done normalizing'
3895
3225
  }
3896
3226
  | {
3897
- type: 'done syncing initial value'
3227
+ type: 'done syncing value'
3228
+ }
3229
+ | {
3230
+ type: 'syncing value'
3898
3231
  }
3899
3232
  | {
3900
3233
  type: 'behavior event'
@@ -4031,7 +3364,10 @@ declare const editorMachine: StateMachine<
4031
3364
  readonly 'remove behavior': {
4032
3365
  readonly actions: 'remove behavior from context'
4033
3366
  }
4034
- readonly 'patches': {
3367
+ readonly 'update behaviors': {
3368
+ readonly actions: 'assign behaviors'
3369
+ }
3370
+ readonly 'update key generator': {
4035
3371
  readonly actions: ActionFunction<
4036
3372
  {
4037
3373
  behaviors: Set<Behavior>
@@ -4039,6 +3375,7 @@ declare const editorMachine: StateMachine<
4039
3375
  getLegacySchema: () => PortableTextMemberSchemaTypes
4040
3376
  keyGenerator: () => string
4041
3377
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3378
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4042
3379
  schema: EditorSchema
4043
3380
  initialReadOnly: boolean
4044
3381
  maxBlocks: number | undefined
@@ -4050,9 +3387,13 @@ declare const editorMachine: StateMachine<
4050
3387
  }
4051
3388
  slateEditor?: PortableTextSlateEditor
4052
3389
  },
4053
- PatchesEvent,
3390
+ {
3391
+ type: 'update key generator'
3392
+ keyGenerator: () => string
3393
+ },
4054
3394
  | InternalPatchEvent
4055
3395
  | MutationEvent
3396
+ | PatchesEvent
4056
3397
  | {
4057
3398
  type: 'add behavior'
4058
3399
  behavior: Behavior
@@ -4085,7 +3426,6 @@ declare const editorMachine: StateMachine<
4085
3426
  type: 'update maxBlocks'
4086
3427
  maxBlocks: number | undefined
4087
3428
  }
4088
- | PatchesEvent
4089
3429
  | {
4090
3430
  type: 'blur'
4091
3431
  editor: PortableTextSlateEditor
@@ -4101,7 +3441,10 @@ declare const editorMachine: StateMachine<
4101
3441
  type: 'done normalizing'
4102
3442
  }
4103
3443
  | {
4104
- type: 'done syncing initial value'
3444
+ type: 'done syncing value'
3445
+ }
3446
+ | {
3447
+ type: 'syncing value'
4105
3448
  }
4106
3449
  | {
4107
3450
  type: 'behavior event'
@@ -4183,59 +3526,13 @@ declare const editorMachine: StateMachine<
4183
3526
  never,
4184
3527
  never,
4185
3528
  never,
4186
- | PatchEvent
4187
- | InternalPatchEvent
4188
- | MutationEvent
4189
- | PatchesEvent
4190
- | {
4191
- type: 'blurred'
4192
- event: FocusEvent_2<HTMLDivElement, Element>
4193
- }
4194
- | {
4195
- type: 'done loading'
4196
- }
4197
- | {
4198
- type: 'editable'
4199
- }
4200
- | {
4201
- type: 'error'
4202
- name: string
4203
- description: string
4204
- data: unknown
4205
- }
4206
- | {
4207
- type: 'focused'
4208
- event: FocusEvent_2<HTMLDivElement, Element>
4209
- }
4210
- | {
4211
- type: 'invalid value'
4212
- resolution: InvalidValueResolution | null
4213
- value: Array<PortableTextBlock> | undefined
4214
- }
4215
- | {
4216
- type: 'loading'
4217
- }
4218
- | {
4219
- type: 'read only'
4220
- }
4221
- | {
4222
- type: 'ready'
4223
- }
4224
- | {
4225
- type: 'selection'
4226
- selection: EditorSelection
4227
- }
4228
- | {
4229
- type: 'value changed'
4230
- value: Array<PortableTextBlock> | undefined
4231
- }
4232
- | UnsetEvent
3529
+ never
4233
3530
  >
4234
3531
  }
4235
- readonly 'update behaviors': {
4236
- readonly actions: 'assign behaviors'
3532
+ readonly 'update schema': {
3533
+ readonly actions: 'assign schema'
4237
3534
  }
4238
- readonly 'update key generator': {
3535
+ readonly 'update value': {
4239
3536
  readonly actions: ActionFunction<
4240
3537
  {
4241
3538
  behaviors: Set<Behavior>
@@ -4243,6 +3540,7 @@ declare const editorMachine: StateMachine<
4243
3540
  getLegacySchema: () => PortableTextMemberSchemaTypes
4244
3541
  keyGenerator: () => string
4245
3542
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3543
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4246
3544
  schema: EditorSchema
4247
3545
  initialReadOnly: boolean
4248
3546
  maxBlocks: number | undefined
@@ -4255,11 +3553,12 @@ declare const editorMachine: StateMachine<
4255
3553
  slateEditor?: PortableTextSlateEditor
4256
3554
  },
4257
3555
  {
4258
- type: 'update key generator'
4259
- keyGenerator: () => string
3556
+ type: 'update value'
3557
+ value: Array<PortableTextBlock> | undefined
4260
3558
  },
4261
3559
  | InternalPatchEvent
4262
3560
  | MutationEvent
3561
+ | PatchesEvent
4263
3562
  | {
4264
3563
  type: 'add behavior'
4265
3564
  behavior: Behavior
@@ -4292,7 +3591,6 @@ declare const editorMachine: StateMachine<
4292
3591
  type: 'update maxBlocks'
4293
3592
  maxBlocks: number | undefined
4294
3593
  }
4295
- | PatchesEvent
4296
3594
  | {
4297
3595
  type: 'blur'
4298
3596
  editor: PortableTextSlateEditor
@@ -4308,7 +3606,10 @@ declare const editorMachine: StateMachine<
4308
3606
  type: 'done normalizing'
4309
3607
  }
4310
3608
  | {
4311
- type: 'done syncing initial value'
3609
+ type: 'done syncing value'
3610
+ }
3611
+ | {
3612
+ type: 'syncing value'
4312
3613
  }
4313
3614
  | {
4314
3615
  type: 'behavior event'
@@ -4393,10 +3694,7 @@ declare const editorMachine: StateMachine<
4393
3694
  never
4394
3695
  >
4395
3696
  }
4396
- readonly 'update schema': {
4397
- readonly actions: 'assign schema'
4398
- }
4399
- readonly 'update value': {
3697
+ readonly 'update maxBlocks': {
4400
3698
  readonly actions: ActionFunction<
4401
3699
  {
4402
3700
  behaviors: Set<Behavior>
@@ -4404,6 +3702,7 @@ declare const editorMachine: StateMachine<
4404
3702
  getLegacySchema: () => PortableTextMemberSchemaTypes
4405
3703
  keyGenerator: () => string
4406
3704
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3705
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4407
3706
  schema: EditorSchema
4408
3707
  initialReadOnly: boolean
4409
3708
  maxBlocks: number | undefined
@@ -4416,11 +3715,12 @@ declare const editorMachine: StateMachine<
4416
3715
  slateEditor?: PortableTextSlateEditor
4417
3716
  },
4418
3717
  {
4419
- type: 'update value'
4420
- value: Array<PortableTextBlock> | undefined
3718
+ type: 'update maxBlocks'
3719
+ maxBlocks: number | undefined
4421
3720
  },
4422
3721
  | InternalPatchEvent
4423
3722
  | MutationEvent
3723
+ | PatchesEvent
4424
3724
  | {
4425
3725
  type: 'add behavior'
4426
3726
  behavior: Behavior
@@ -4453,7 +3753,6 @@ declare const editorMachine: StateMachine<
4453
3753
  type: 'update maxBlocks'
4454
3754
  maxBlocks: number | undefined
4455
3755
  }
4456
- | PatchesEvent
4457
3756
  | {
4458
3757
  type: 'blur'
4459
3758
  editor: PortableTextSlateEditor
@@ -4469,7 +3768,10 @@ declare const editorMachine: StateMachine<
4469
3768
  type: 'done normalizing'
4470
3769
  }
4471
3770
  | {
4472
- type: 'done syncing initial value'
3771
+ type: 'done syncing value'
3772
+ }
3773
+ | {
3774
+ type: 'syncing value'
4473
3775
  }
4474
3776
  | {
4475
3777
  type: 'behavior event'
@@ -4554,210 +3856,53 @@ declare const editorMachine: StateMachine<
4554
3856
  never
4555
3857
  >
4556
3858
  }
4557
- readonly 'update maxBlocks': {
4558
- readonly actions: ActionFunction<
4559
- {
4560
- behaviors: Set<Behavior>
4561
- converters: Set<Converter>
4562
- getLegacySchema: () => PortableTextMemberSchemaTypes
4563
- keyGenerator: () => string
4564
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
4565
- schema: EditorSchema
4566
- initialReadOnly: boolean
4567
- maxBlocks: number | undefined
4568
- selection: EditorSelection
4569
- incomingValue: Array<PortableTextBlock> | undefined
4570
- internalDrag?: {
4571
- ghost?: HTMLElement
4572
- origin: Pick<EventPosition, 'selection'>
4573
- }
4574
- slateEditor?: PortableTextSlateEditor
4575
- },
4576
- {
4577
- type: 'update maxBlocks'
4578
- maxBlocks: number | undefined
4579
- },
4580
- | InternalPatchEvent
4581
- | MutationEvent
4582
- | {
4583
- type: 'add behavior'
4584
- behavior: Behavior
4585
- }
4586
- | {
4587
- type: 'remove behavior'
4588
- behavior: Behavior
4589
- }
4590
- | {
4591
- type: 'update readOnly'
4592
- readOnly: boolean
4593
- }
4594
- | {
4595
- type: 'update schema'
4596
- schema: EditorSchema
4597
- }
4598
- | {
4599
- type: 'update behaviors'
4600
- behaviors: Array<Behavior>
4601
- }
4602
- | {
4603
- type: 'update key generator'
4604
- keyGenerator: () => string
4605
- }
4606
- | {
4607
- type: 'update value'
4608
- value: Array<PortableTextBlock> | undefined
4609
- }
4610
- | {
4611
- type: 'update maxBlocks'
4612
- maxBlocks: number | undefined
4613
- }
4614
- | PatchesEvent
4615
- | {
4616
- type: 'blur'
4617
- editor: PortableTextSlateEditor
4618
- }
4619
- | {
4620
- type: 'focus'
4621
- editor: PortableTextSlateEditor
4622
- }
4623
- | {
4624
- type: 'normalizing'
4625
- }
4626
- | {
4627
- type: 'done normalizing'
4628
- }
4629
- | {
4630
- type: 'done syncing initial value'
4631
- }
4632
- | {
4633
- type: 'behavior event'
4634
- behaviorEvent: BehaviorEvent
4635
- editor: PortableTextSlateEditor
4636
- nativeEvent?: {
4637
- preventDefault: () => void
4638
- }
4639
- }
4640
- | {
4641
- type: 'notify.patch'
4642
- patch: Patch
4643
- }
4644
- | {
4645
- type: 'notify.mutation'
4646
- patches: Array<Patch>
4647
- snapshot: Array<PortableTextBlock> | undefined
4648
- value: Array<PortableTextBlock> | undefined
4649
- }
4650
- | {
4651
- type: 'notify.blurred'
4652
- event: FocusEvent_2<HTMLDivElement, Element>
4653
- }
4654
- | {
4655
- type: 'notify.done loading'
4656
- }
4657
- | {
4658
- type: 'notify.editable'
4659
- }
4660
- | {
4661
- type: 'notify.error'
4662
- name: string
4663
- description: string
4664
- data: unknown
4665
- }
4666
- | {
4667
- type: 'notify.focused'
4668
- event: FocusEvent_2<HTMLDivElement, Element>
4669
- }
4670
- | {
4671
- type: 'notify.invalid value'
4672
- resolution: InvalidValueResolution | null
4673
- value: Array<PortableTextBlock> | undefined
4674
- }
4675
- | {
4676
- type: 'notify.loading'
4677
- }
4678
- | {
4679
- type: 'notify.read only'
4680
- }
4681
- | {
4682
- type: 'notify.ready'
4683
- }
4684
- | {
4685
- type: 'notify.selection'
4686
- selection: EditorSelection
4687
- }
4688
- | {
4689
- type: 'notify.value changed'
4690
- value: Array<PortableTextBlock> | undefined
4691
- }
4692
- | {
4693
- type: 'notify.unset'
4694
- previousValue: Array<PortableTextBlock>
4695
- }
4696
- | {
4697
- type: 'dragstart'
4698
- origin: Pick<EventPosition, 'selection'>
4699
- ghost?: HTMLElement
4700
- }
4701
- | {
4702
- type: 'dragend'
4703
- }
4704
- | {
4705
- type: 'drop'
4706
- },
4707
- undefined,
4708
- never,
4709
- never,
4710
- never,
4711
- never,
4712
- never
4713
- >
4714
- }
4715
- }
4716
- readonly type: 'parallel'
4717
- readonly states: {
4718
- readonly 'edit mode': {
4719
- readonly initial: 'read only'
4720
- readonly states: {
4721
- readonly 'read only': {
4722
- readonly initial: 'determine initial edit mode'
4723
- readonly on: {
4724
- readonly 'behavior event': {
4725
- readonly actions: 'handle behavior event'
4726
- readonly guard: ({
4727
- event,
4728
- }: GuardArgs<
4729
- {
4730
- behaviors: Set<Behavior>
4731
- converters: Set<Converter>
4732
- getLegacySchema: () => PortableTextMemberSchemaTypes
4733
- keyGenerator: () => string
4734
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
4735
- schema: EditorSchema
4736
- initialReadOnly: boolean
4737
- maxBlocks: number | undefined
4738
- selection: EditorSelection
4739
- incomingValue: Array<PortableTextBlock> | undefined
4740
- internalDrag?: {
4741
- ghost?: HTMLElement
4742
- origin: Pick<EventPosition, 'selection'>
4743
- }
4744
- slateEditor?: PortableTextSlateEditor
4745
- },
4746
- {
4747
- type: 'behavior event'
4748
- behaviorEvent: BehaviorEvent
4749
- editor: PortableTextSlateEditor
4750
- nativeEvent?: {
4751
- preventDefault: () => void
4752
- }
4753
- }
4754
- >) => boolean
4755
- }
3859
+ }
3860
+ readonly type: 'parallel'
3861
+ readonly states: {
3862
+ readonly 'edit mode': {
3863
+ readonly initial: 'read only'
3864
+ readonly states: {
3865
+ readonly 'read only': {
3866
+ readonly initial: 'determine initial edit mode'
3867
+ readonly on: {
3868
+ readonly 'behavior event': {
3869
+ readonly actions: 'handle behavior event'
3870
+ readonly guard: ({
3871
+ event,
3872
+ }: GuardArgs<
3873
+ {
3874
+ behaviors: Set<Behavior>
3875
+ converters: Set<Converter>
3876
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3877
+ keyGenerator: () => string
3878
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
3879
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
3880
+ schema: EditorSchema
3881
+ initialReadOnly: boolean
3882
+ maxBlocks: number | undefined
3883
+ selection: EditorSelection
3884
+ incomingValue: Array<PortableTextBlock> | undefined
3885
+ internalDrag?: {
3886
+ ghost?: HTMLElement
3887
+ origin: Pick<EventPosition, 'selection'>
3888
+ }
3889
+ slateEditor?: PortableTextSlateEditor
3890
+ },
3891
+ {
3892
+ type: 'behavior event'
3893
+ behaviorEvent: BehaviorEvent
3894
+ editor: PortableTextSlateEditor
3895
+ nativeEvent?: {
3896
+ preventDefault: () => void
3897
+ }
3898
+ }
3899
+ >) => boolean
3900
+ }
4756
3901
  }
4757
3902
  readonly states: {
4758
3903
  readonly 'determine initial edit mode': {
4759
3904
  readonly on: {
4760
- readonly 'done syncing initial value': readonly [
3905
+ readonly 'done syncing value': readonly [
4761
3906
  {
4762
3907
  readonly target: '#editor.edit mode.read only.read only'
4763
3908
  readonly guard: ({
@@ -4771,6 +3916,7 @@ declare const editorMachine: StateMachine<
4771
3916
  pendingEvents: Array<
4772
3917
  InternalPatchEvent | MutationEvent
4773
3918
  >
3919
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4774
3920
  schema: EditorSchema
4775
3921
  initialReadOnly: boolean
4776
3922
  maxBlocks: number | undefined
@@ -4783,7 +3929,7 @@ declare const editorMachine: StateMachine<
4783
3929
  slateEditor?: PortableTextSlateEditor
4784
3930
  },
4785
3931
  {
4786
- type: 'done syncing initial value'
3932
+ type: 'done syncing value'
4787
3933
  }
4788
3934
  >) => boolean
4789
3935
  },
@@ -4805,6 +3951,7 @@ declare const editorMachine: StateMachine<
4805
3951
  getLegacySchema: () => PortableTextMemberSchemaTypes
4806
3952
  keyGenerator: () => string
4807
3953
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3954
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4808
3955
  schema: EditorSchema
4809
3956
  initialReadOnly: boolean
4810
3957
  maxBlocks: number | undefined
@@ -4840,6 +3987,7 @@ declare const editorMachine: StateMachine<
4840
3987
  getLegacySchema: () => PortableTextMemberSchemaTypes
4841
3988
  keyGenerator: () => string
4842
3989
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3990
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4843
3991
  schema: EditorSchema
4844
3992
  initialReadOnly: boolean
4845
3993
  maxBlocks: number | undefined
@@ -4875,6 +4023,7 @@ declare const editorMachine: StateMachine<
4875
4023
  getLegacySchema: () => PortableTextMemberSchemaTypes
4876
4024
  keyGenerator: () => string
4877
4025
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4026
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4878
4027
  schema: EditorSchema
4879
4028
  initialReadOnly: boolean
4880
4029
  maxBlocks: number | undefined
@@ -4892,6 +4041,7 @@ declare const editorMachine: StateMachine<
4892
4041
  },
4893
4042
  | InternalPatchEvent
4894
4043
  | MutationEvent
4044
+ | PatchesEvent
4895
4045
  | {
4896
4046
  type: 'add behavior'
4897
4047
  behavior: Behavior
@@ -4924,7 +4074,6 @@ declare const editorMachine: StateMachine<
4924
4074
  type: 'update maxBlocks'
4925
4075
  maxBlocks: number | undefined
4926
4076
  }
4927
- | PatchesEvent
4928
4077
  | {
4929
4078
  type: 'blur'
4930
4079
  editor: PortableTextSlateEditor
@@ -4940,7 +4089,10 @@ declare const editorMachine: StateMachine<
4940
4089
  type: 'done normalizing'
4941
4090
  }
4942
4091
  | {
4943
- type: 'done syncing initial value'
4092
+ type: 'done syncing value'
4093
+ }
4094
+ | {
4095
+ type: 'syncing value'
4944
4096
  }
4945
4097
  | {
4946
4098
  type: 'behavior event'
@@ -5042,6 +4194,7 @@ declare const editorMachine: StateMachine<
5042
4194
  pendingEvents: Array<
5043
4195
  InternalPatchEvent | MutationEvent
5044
4196
  >
4197
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
5045
4198
  schema: EditorSchema
5046
4199
  initialReadOnly: boolean
5047
4200
  maxBlocks: number | undefined
@@ -5060,6 +4213,7 @@ declare const editorMachine: StateMachine<
5060
4213
  },
5061
4214
  | InternalPatchEvent
5062
4215
  | MutationEvent
4216
+ | PatchesEvent
5063
4217
  | {
5064
4218
  type: 'add behavior'
5065
4219
  behavior: Behavior
@@ -5092,7 +4246,6 @@ declare const editorMachine: StateMachine<
5092
4246
  type: 'update maxBlocks'
5093
4247
  maxBlocks: number | undefined
5094
4248
  }
5095
- | PatchesEvent
5096
4249
  | {
5097
4250
  type: 'blur'
5098
4251
  editor: PortableTextSlateEditor
@@ -5108,7 +4261,10 @@ declare const editorMachine: StateMachine<
5108
4261
  type: 'done normalizing'
5109
4262
  }
5110
4263
  | {
5111
- type: 'done syncing initial value'
4264
+ type: 'done syncing value'
4265
+ }
4266
+ | {
4267
+ type: 'syncing value'
5112
4268
  }
5113
4269
  | {
5114
4270
  type: 'behavior event'
@@ -5232,6 +4388,7 @@ declare const editorMachine: StateMachine<
5232
4388
  getLegacySchema: () => PortableTextMemberSchemaTypes
5233
4389
  keyGenerator: () => string
5234
4390
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4391
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
5235
4392
  schema: EditorSchema
5236
4393
  initialReadOnly: boolean
5237
4394
  maxBlocks: number | undefined
@@ -5245,6 +4402,7 @@ declare const editorMachine: StateMachine<
5245
4402
  },
5246
4403
  | InternalPatchEvent
5247
4404
  | MutationEvent
4405
+ | PatchesEvent
5248
4406
  | {
5249
4407
  type: 'add behavior'
5250
4408
  behavior: Behavior
@@ -5277,7 +4435,6 @@ declare const editorMachine: StateMachine<
5277
4435
  type: 'update maxBlocks'
5278
4436
  maxBlocks: number | undefined
5279
4437
  }
5280
- | PatchesEvent
5281
4438
  | {
5282
4439
  type: 'blur'
5283
4440
  editor: PortableTextSlateEditor
@@ -5293,7 +4450,10 @@ declare const editorMachine: StateMachine<
5293
4450
  type: 'done normalizing'
5294
4451
  }
5295
4452
  | {
5296
- type: 'done syncing initial value'
4453
+ type: 'done syncing value'
4454
+ }
4455
+ | {
4456
+ type: 'syncing value'
5297
4457
  }
5298
4458
  | {
5299
4459
  type: 'behavior event'
@@ -5372,6 +4532,7 @@ declare const editorMachine: StateMachine<
5372
4532
  },
5373
4533
  | InternalPatchEvent
5374
4534
  | MutationEvent
4535
+ | PatchesEvent
5375
4536
  | {
5376
4537
  type: 'add behavior'
5377
4538
  behavior: Behavior
@@ -5404,7 +4565,6 @@ declare const editorMachine: StateMachine<
5404
4565
  type: 'update maxBlocks'
5405
4566
  maxBlocks: number | undefined
5406
4567
  }
5407
- | PatchesEvent
5408
4568
  | {
5409
4569
  type: 'blur'
5410
4570
  editor: PortableTextSlateEditor
@@ -5420,7 +4580,10 @@ declare const editorMachine: StateMachine<
5420
4580
  type: 'done normalizing'
5421
4581
  }
5422
4582
  | {
5423
- type: 'done syncing initial value'
4583
+ type: 'done syncing value'
4584
+ }
4585
+ | {
4586
+ type: 'syncing value'
5424
4587
  }
5425
4588
  | {
5426
4589
  type: 'behavior event'
@@ -5505,6 +4668,7 @@ declare const editorMachine: StateMachine<
5505
4668
  getLegacySchema: () => PortableTextMemberSchemaTypes
5506
4669
  keyGenerator: () => string
5507
4670
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4671
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
5508
4672
  schema: EditorSchema
5509
4673
  initialReadOnly: boolean
5510
4674
  maxBlocks: number | undefined
@@ -5518,6 +4682,7 @@ declare const editorMachine: StateMachine<
5518
4682
  },
5519
4683
  | InternalPatchEvent
5520
4684
  | MutationEvent
4685
+ | PatchesEvent
5521
4686
  | {
5522
4687
  type: 'add behavior'
5523
4688
  behavior: Behavior
@@ -5550,7 +4715,6 @@ declare const editorMachine: StateMachine<
5550
4715
  type: 'update maxBlocks'
5551
4716
  maxBlocks: number | undefined
5552
4717
  }
5553
- | PatchesEvent
5554
4718
  | {
5555
4719
  type: 'blur'
5556
4720
  editor: PortableTextSlateEditor
@@ -5566,7 +4730,10 @@ declare const editorMachine: StateMachine<
5566
4730
  type: 'done normalizing'
5567
4731
  }
5568
4732
  | {
5569
- type: 'done syncing initial value'
4733
+ type: 'done syncing value'
4734
+ }
4735
+ | {
4736
+ type: 'syncing value'
5570
4737
  }
5571
4738
  | {
5572
4739
  type: 'behavior event'
@@ -5645,6 +4812,7 @@ declare const editorMachine: StateMachine<
5645
4812
  },
5646
4813
  | InternalPatchEvent
5647
4814
  | MutationEvent
4815
+ | PatchesEvent
5648
4816
  | {
5649
4817
  type: 'add behavior'
5650
4818
  behavior: Behavior
@@ -5677,7 +4845,6 @@ declare const editorMachine: StateMachine<
5677
4845
  type: 'update maxBlocks'
5678
4846
  maxBlocks: number | undefined
5679
4847
  }
5680
- | PatchesEvent
5681
4848
  | {
5682
4849
  type: 'blur'
5683
4850
  editor: PortableTextSlateEditor
@@ -5693,7 +4860,10 @@ declare const editorMachine: StateMachine<
5693
4860
  type: 'done normalizing'
5694
4861
  }
5695
4862
  | {
5696
- type: 'done syncing initial value'
4863
+ type: 'done syncing value'
4864
+ }
4865
+ | {
4866
+ type: 'syncing value'
5697
4867
  }
5698
4868
  | {
5699
4869
  type: 'behavior event'
@@ -5796,7 +4966,11 @@ declare const editorMachine: StateMachine<
5796
4966
  readonly initial: 'setting up'
5797
4967
  readonly states: {
5798
4968
  readonly 'setting up': {
5799
- readonly exit: readonly ['emit ready']
4969
+ readonly exit: readonly [
4970
+ 'emit ready',
4971
+ 'emit pending incoming patches',
4972
+ 'clear pending incoming patches',
4973
+ ]
5800
4974
  readonly on: {
5801
4975
  readonly 'internal.patch': {
5802
4976
  readonly actions: 'defer event'
@@ -5804,58 +4978,308 @@ declare const editorMachine: StateMachine<
5804
4978
  readonly 'mutation': {
5805
4979
  readonly actions: 'defer event'
5806
4980
  }
5807
- readonly 'done syncing initial value': {
5808
- readonly target: 'pristine'
4981
+ readonly 'done syncing value': {
4982
+ readonly target: 'set up'
4983
+ }
4984
+ readonly 'patches': {
4985
+ readonly actions: readonly ['defer incoming patches']
5809
4986
  }
5810
4987
  }
5811
4988
  }
5812
- readonly 'pristine': {
5813
- readonly initial: 'idle'
4989
+ readonly 'set up': {
4990
+ readonly type: 'parallel'
5814
4991
  readonly states: {
5815
- readonly idle: {
5816
- readonly on: {
5817
- readonly 'normalizing': {
5818
- readonly target: 'normalizing'
5819
- }
5820
- readonly 'internal.patch': {
5821
- readonly actions: 'defer event'
5822
- readonly target: '#editor.setup.dirty'
4992
+ readonly 'value sync': {
4993
+ readonly initial: 'idle'
4994
+ readonly states: {
4995
+ readonly 'idle': {
4996
+ readonly on: {
4997
+ readonly 'patches': {
4998
+ readonly actions: readonly [
4999
+ ActionFunction<
5000
+ {
5001
+ behaviors: Set<Behavior>
5002
+ converters: Set<Converter>
5003
+ getLegacySchema: () => PortableTextMemberSchemaTypes
5004
+ keyGenerator: () => string
5005
+ pendingEvents: Array<
5006
+ InternalPatchEvent | MutationEvent
5007
+ >
5008
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
5009
+ schema: EditorSchema
5010
+ initialReadOnly: boolean
5011
+ maxBlocks: number | undefined
5012
+ selection: EditorSelection
5013
+ incomingValue:
5014
+ | Array<PortableTextBlock>
5015
+ | undefined
5016
+ internalDrag?: {
5017
+ ghost?: HTMLElement
5018
+ origin: Pick<EventPosition, 'selection'>
5019
+ }
5020
+ slateEditor?: PortableTextSlateEditor
5021
+ },
5022
+ PatchesEvent,
5023
+ | InternalPatchEvent
5024
+ | MutationEvent
5025
+ | PatchesEvent
5026
+ | {
5027
+ type: 'add behavior'
5028
+ behavior: Behavior
5029
+ }
5030
+ | {
5031
+ type: 'remove behavior'
5032
+ behavior: Behavior
5033
+ }
5034
+ | {
5035
+ type: 'update readOnly'
5036
+ readOnly: boolean
5037
+ }
5038
+ | {
5039
+ type: 'update schema'
5040
+ schema: EditorSchema
5041
+ }
5042
+ | {
5043
+ type: 'update behaviors'
5044
+ behaviors: Array<Behavior>
5045
+ }
5046
+ | {
5047
+ type: 'update key generator'
5048
+ keyGenerator: () => string
5049
+ }
5050
+ | {
5051
+ type: 'update value'
5052
+ value: Array<PortableTextBlock> | undefined
5053
+ }
5054
+ | {
5055
+ type: 'update maxBlocks'
5056
+ maxBlocks: number | undefined
5057
+ }
5058
+ | {
5059
+ type: 'blur'
5060
+ editor: PortableTextSlateEditor
5061
+ }
5062
+ | {
5063
+ type: 'focus'
5064
+ editor: PortableTextSlateEditor
5065
+ }
5066
+ | {
5067
+ type: 'normalizing'
5068
+ }
5069
+ | {
5070
+ type: 'done normalizing'
5071
+ }
5072
+ | {
5073
+ type: 'done syncing value'
5074
+ }
5075
+ | {
5076
+ type: 'syncing value'
5077
+ }
5078
+ | {
5079
+ type: 'behavior event'
5080
+ behaviorEvent: BehaviorEvent
5081
+ editor: PortableTextSlateEditor
5082
+ nativeEvent?: {
5083
+ preventDefault: () => void
5084
+ }
5085
+ }
5086
+ | {
5087
+ type: 'notify.patch'
5088
+ patch: Patch
5089
+ }
5090
+ | {
5091
+ type: 'notify.mutation'
5092
+ patches: Array<Patch>
5093
+ snapshot: Array<PortableTextBlock> | undefined
5094
+ value: Array<PortableTextBlock> | undefined
5095
+ }
5096
+ | {
5097
+ type: 'notify.blurred'
5098
+ event: FocusEvent_2<HTMLDivElement, Element>
5099
+ }
5100
+ | {
5101
+ type: 'notify.done loading'
5102
+ }
5103
+ | {
5104
+ type: 'notify.editable'
5105
+ }
5106
+ | {
5107
+ type: 'notify.error'
5108
+ name: string
5109
+ description: string
5110
+ data: unknown
5111
+ }
5112
+ | {
5113
+ type: 'notify.focused'
5114
+ event: FocusEvent_2<HTMLDivElement, Element>
5115
+ }
5116
+ | {
5117
+ type: 'notify.invalid value'
5118
+ resolution: InvalidValueResolution | null
5119
+ value: Array<PortableTextBlock> | undefined
5120
+ }
5121
+ | {
5122
+ type: 'notify.loading'
5123
+ }
5124
+ | {
5125
+ type: 'notify.read only'
5126
+ }
5127
+ | {
5128
+ type: 'notify.ready'
5129
+ }
5130
+ | {
5131
+ type: 'notify.selection'
5132
+ selection: EditorSelection
5133
+ }
5134
+ | {
5135
+ type: 'notify.value changed'
5136
+ value: Array<PortableTextBlock> | undefined
5137
+ }
5138
+ | {
5139
+ type: 'notify.unset'
5140
+ previousValue: Array<PortableTextBlock>
5141
+ }
5142
+ | {
5143
+ type: 'dragstart'
5144
+ origin: Pick<EventPosition, 'selection'>
5145
+ ghost?: HTMLElement
5146
+ }
5147
+ | {
5148
+ type: 'dragend'
5149
+ }
5150
+ | {
5151
+ type: 'drop'
5152
+ },
5153
+ undefined,
5154
+ never,
5155
+ never,
5156
+ never,
5157
+ never,
5158
+ | PatchEvent
5159
+ | InternalPatchEvent
5160
+ | MutationEvent
5161
+ | PatchesEvent
5162
+ | {
5163
+ type: 'blurred'
5164
+ event: FocusEvent_2<HTMLDivElement, Element>
5165
+ }
5166
+ | {
5167
+ type: 'done loading'
5168
+ }
5169
+ | {
5170
+ type: 'editable'
5171
+ }
5172
+ | {
5173
+ type: 'error'
5174
+ name: string
5175
+ description: string
5176
+ data: unknown
5177
+ }
5178
+ | {
5179
+ type: 'focused'
5180
+ event: FocusEvent_2<HTMLDivElement, Element>
5181
+ }
5182
+ | {
5183
+ type: 'invalid value'
5184
+ resolution: InvalidValueResolution | null
5185
+ value: Array<PortableTextBlock> | undefined
5186
+ }
5187
+ | {
5188
+ type: 'loading'
5189
+ }
5190
+ | {
5191
+ type: 'read only'
5192
+ }
5193
+ | {
5194
+ type: 'ready'
5195
+ }
5196
+ | {
5197
+ type: 'selection'
5198
+ selection: EditorSelection
5199
+ }
5200
+ | {
5201
+ type: 'value changed'
5202
+ value: Array<PortableTextBlock> | undefined
5203
+ }
5204
+ | UnsetEvent
5205
+ >,
5206
+ ]
5207
+ }
5208
+ readonly 'syncing value': {
5209
+ readonly target: 'syncing value'
5210
+ }
5211
+ }
5823
5212
  }
5824
- readonly 'mutation': {
5825
- readonly actions: 'defer event'
5826
- readonly target: '#editor.setup.dirty'
5213
+ readonly 'syncing value': {
5214
+ readonly exit: readonly [
5215
+ 'emit pending incoming patches',
5216
+ 'clear pending incoming patches',
5217
+ ]
5218
+ readonly on: {
5219
+ readonly 'patches': {
5220
+ readonly actions: readonly ['defer incoming patches']
5221
+ }
5222
+ readonly 'done syncing value': {
5223
+ readonly target: 'idle'
5224
+ }
5225
+ }
5827
5226
  }
5828
5227
  }
5829
5228
  }
5830
- readonly normalizing: {
5831
- readonly on: {
5832
- readonly 'done normalizing': {
5833
- readonly target: 'idle'
5834
- }
5835
- readonly 'internal.patch': {
5836
- readonly actions: 'defer event'
5229
+ readonly 'writing': {
5230
+ readonly initial: 'pristine'
5231
+ readonly states: {
5232
+ readonly pristine: {
5233
+ readonly initial: 'idle'
5234
+ readonly states: {
5235
+ readonly idle: {
5236
+ readonly on: {
5237
+ readonly 'normalizing': {
5238
+ readonly target: 'normalizing'
5239
+ }
5240
+ readonly 'internal.patch': {
5241
+ readonly actions: 'defer event'
5242
+ readonly target: '#editor.setup.set up.writing.dirty'
5243
+ }
5244
+ readonly 'mutation': {
5245
+ readonly actions: 'defer event'
5246
+ readonly target: '#editor.setup.set up.writing.dirty'
5247
+ }
5248
+ }
5249
+ }
5250
+ readonly normalizing: {
5251
+ readonly on: {
5252
+ readonly 'done normalizing': {
5253
+ readonly target: 'idle'
5254
+ }
5255
+ readonly 'internal.patch': {
5256
+ readonly actions: 'defer event'
5257
+ }
5258
+ readonly 'mutation': {
5259
+ readonly actions: 'defer event'
5260
+ }
5261
+ }
5262
+ }
5263
+ }
5837
5264
  }
5838
- readonly 'mutation': {
5839
- readonly actions: 'defer event'
5265
+ readonly dirty: {
5266
+ readonly entry: readonly [
5267
+ 'emit pending events',
5268
+ 'clear pending events',
5269
+ ]
5270
+ readonly on: {
5271
+ readonly 'internal.patch': {
5272
+ readonly actions: 'emit patch event'
5273
+ }
5274
+ readonly 'mutation': {
5275
+ readonly actions: 'emit mutation event'
5276
+ }
5277
+ }
5840
5278
  }
5841
5279
  }
5842
5280
  }
5843
5281
  }
5844
5282
  }
5845
- readonly 'dirty': {
5846
- readonly entry: readonly [
5847
- 'emit pending events',
5848
- 'clear pending events',
5849
- ]
5850
- readonly on: {
5851
- readonly 'internal.patch': {
5852
- readonly actions: 'emit patch event'
5853
- }
5854
- readonly 'mutation': {
5855
- readonly actions: 'emit mutation event'
5856
- }
5857
- }
5858
- }
5859
5283
  }
5860
5284
  }
5861
5285
  }
@@ -5964,31 +5388,6 @@ declare type EditorSnapshot = {
5964
5388
  }
5965
5389
  }
5966
5390
 
5967
- /** @public */
5968
- declare interface EmailDefinition extends BaseSchemaDefinition {
5969
- type: 'email'
5970
- options?: EmailOptions
5971
- placeholder?: string
5972
- validation?: ValidationBuilder<EmailRule, string>
5973
- initialValue?: InitialValueProperty<any, string>
5974
- }
5975
-
5976
- /** @public */
5977
- declare interface EmailOptions extends BaseSchemaTypeOptions {}
5978
-
5979
- /** @public */
5980
- declare interface EmailRule extends RuleDef<EmailRule, string> {}
5981
-
5982
- /** @public */
5983
- declare interface EmptyProps {}
5984
-
5985
- /** @public */
5986
- declare interface EnumListProps<V = unknown> {
5987
- list?: Array<TitledListValue<V> | V>
5988
- layout?: 'radio' | 'dropdown'
5989
- direction?: 'horizontal' | 'vertical'
5990
- }
5991
-
5992
5391
  /**
5993
5392
  * @public
5994
5393
  * Listen for events emitted by the editor. Must be used inside `EditorProvider`. Events available include:
@@ -6122,488 +5521,43 @@ declare type ExternalEditorEvent =
6122
5521
  declare type ExtractNamespace<TType extends string> =
6123
5522
  TType extends `${infer Namespace}.${string}` ? Namespace : TType
6124
5523
 
6125
- /**
6126
- * The shape of a field definition. Note, it's recommended to use the
6127
- * `defineField` function instead of using this type directly.
6128
- *
6129
- * Where `defineField` infers the exact field type,
6130
- * FieldDefinition is a compromise union of all types a field can have.
6131
- *
6132
- * A field definition can be a reference to another registered top-level type
6133
- * or a inline type definition.
6134
- *
6135
- * @public
6136
- */
6137
- declare type FieldDefinition<
6138
- TType extends IntrinsicTypeName = IntrinsicTypeName,
6139
- TAlias extends IntrinsicTypeName | undefined = undefined,
6140
- > = (InlineFieldDefinition[TType] | TypeAliasDefinition<string, TAlias>) &
6141
- FieldDefinitionBase
6142
-
6143
- /** @public */
6144
- declare interface FieldDefinitionBase {
6145
- fieldset?: string
6146
- group?: string | string[]
6147
- }
5524
+ declare type HasTag = ReturnType<EditorActor['getSnapshot']>['hasTag']
6148
5525
 
6149
- /** @public */
6150
- declare interface FieldGroup {
6151
- name: string
6152
- icon?: ComponentType
6153
- title?: string
6154
- description?: string
6155
- i18n?: I18nTextRecord<'title'>
6156
- hidden?: ConditionalProperty
6157
- default?: boolean
6158
- fields?: ObjectField[]
5526
+ declare interface History_2 {
5527
+ redos: HistoryItem[]
5528
+ undos: HistoryItem[]
6159
5529
  }
6160
5530
 
6161
- /** @public */
6162
- declare type FieldGroupDefinition = {
6163
- name: string
6164
- title?: string
6165
- hidden?: ConditionalProperty
6166
- icon?: ComponentType
6167
- default?: boolean
6168
- i18n?: I18nTextRecord<'title'>
5531
+ declare type HistoryItem = {
5532
+ operations: Operation[]
5533
+ timestamp: Date
6169
5534
  }
6170
5535
 
6171
5536
  /**
6172
- * Holds a reference to a different field
6173
- * NOTE: Only use this through {@link Rule.valueOfField}
5537
+ * Used to represent native InputEvents that hold a DataTransfer object.
6174
5538
  *
6175
- * @public
5539
+ * These can either be one of:
5540
+ *
5541
+ * - insertFromPaste
5542
+ * - insertFromPasteAsQuotation
5543
+ * - insertFromDrop
5544
+ * - insertReplacementText
5545
+ * - insertFromYank
6176
5546
  */
6177
- declare interface FieldReference {
6178
- type: symbol
6179
- path: string | string[]
6180
- }
6181
-
6182
- /** @public */
6183
- declare type FieldRules = {
6184
- [fieldKey: string]: SchemaValidationValue
5547
+ declare type InputBehaviorEvent = {
5548
+ type: StrictExtract<NativeBehaviorEventType, 'input.*'>
5549
+ originEvent: {
5550
+ dataTransfer: DataTransfer
5551
+ }
6185
5552
  }
6186
5553
 
6187
- /** @public */
6188
- declare type Fieldset = SingleFieldSet | MultiFieldSet
5554
+ declare type InsertPlacement = 'auto' | 'after' | 'before'
6189
5555
 
6190
- /** @public */
6191
- declare type FieldsetDefinition = {
6192
- name: string
6193
- title?: string
6194
- description?: string
6195
- group?: string
6196
- hidden?: ConditionalProperty
6197
- readOnly?: ConditionalProperty
6198
- options?: ObjectOptions
5556
+ declare type InternalPatchEvent = NamespaceEvent<PatchEvent, 'internal'> & {
5557
+ actionId?: string
5558
+ value: Array<PortableTextBlock>
6199
5559
  }
6200
5560
 
6201
- /** @public */
6202
- declare interface File_2 {
6203
- [key: string]: unknown
6204
- asset?: Reference
6205
- }
6206
-
6207
- /** @public */
6208
- declare interface FileDefinition
6209
- extends Omit<
6210
- ObjectDefinition,
6211
- 'type' | 'fields' | 'options' | 'groups' | 'validation'
6212
- > {
6213
- type: 'file'
6214
- fields?: ObjectDefinition['fields']
6215
- options?: FileOptions
6216
- validation?: ValidationBuilder<FileRule, FileValue>
6217
- initialValue?: InitialValueProperty<any, FileValue>
6218
- }
6219
-
6220
- /** @public */
6221
- declare interface FileOptions extends ObjectOptions {
6222
- storeOriginalFilename?: boolean
6223
- accept?: string
6224
- sources?: AssetSource[]
6225
- }
6226
-
6227
- /** @public */
6228
- declare interface FileRule extends RuleDef<FileRule, FileValue> {
6229
- /**
6230
- * Require a file field has an asset.
6231
- *
6232
- * @example
6233
- * ```ts
6234
- * defineField({
6235
- * name: 'file',
6236
- * title: 'File',
6237
- * type: 'file',
6238
- * validation: (Rule) => Rule.required().assetRequired(),
6239
- * })
6240
- * ```
6241
- */
6242
- assetRequired(): FileRule
6243
- }
6244
-
6245
- /** @public */
6246
- declare interface FileSchemaType extends Omit<ObjectSchemaType, 'options'> {
6247
- options?: FileOptions
6248
- }
6249
-
6250
- /** @public */
6251
- declare interface FileValue {
6252
- asset?: Reference
6253
- [index: string]: unknown
6254
- }
6255
-
6256
- /** @public */
6257
- declare interface GeopointDefinition extends BaseSchemaDefinition {
6258
- type: 'geopoint'
6259
- options?: GeopointOptions
6260
- validation?: ValidationBuilder<GeopointRule, GeopointValue>
6261
- initialValue?: InitialValueProperty<any, Omit<GeopointValue, '_type'>>
6262
- }
6263
-
6264
- /** @public */
6265
- declare interface GeopointOptions extends BaseSchemaTypeOptions {}
6266
-
6267
- /** @public */
6268
- declare interface GeopointRule extends RuleDef<GeopointRule, GeopointValue> {}
6269
-
6270
- /**
6271
- * Geographical point representing a pair of latitude and longitude coordinates,
6272
- * stored as degrees, in the World Geodetic System 1984 (WGS 84) format. Also
6273
- * includes an optional `alt` property representing the altitude in meters.
6274
- *
6275
- * @public
6276
- */
6277
- declare interface GeopointValue {
6278
- /**
6279
- * Type of the object. Must be `geopoint`.
6280
- */
6281
- _type: 'geopoint'
6282
- /**
6283
- * Latitude in degrees
6284
- */
6285
- lat: number
6286
- /**
6287
- * Longitude in degrees
6288
- */
6289
- lng: number
6290
- /**
6291
- * Altitude in meters
6292
- */
6293
- alt?: number
6294
- }
6295
-
6296
- /** @public */
6297
- declare interface GlobalDocumentReferenceDefinition
6298
- extends BaseSchemaDefinition {
6299
- type: 'globalDocumentReference'
6300
- weak?: boolean
6301
- to: {
6302
- type: string
6303
- title?: string
6304
- icon?: ComponentType
6305
- preview?: PreviewConfig
6306
- }[]
6307
- resourceType: string
6308
- resourceId: string
6309
- options?: ReferenceOptions
6310
- studioUrl?: (document: {id: string; type?: string}) => string | null
6311
- }
6312
-
6313
- declare type HasTag = ReturnType<EditorActor['getSnapshot']>['hasTag']
6314
-
6315
- declare interface History_2 {
6316
- redos: HistoryItem[]
6317
- undos: HistoryItem[]
6318
- }
6319
-
6320
- declare type HistoryItem = {
6321
- operations: Operation[]
6322
- timestamp: Date
6323
- }
6324
-
6325
- /** @public */
6326
- declare interface HotspotOptions {
6327
- previews?: HotspotPreview[]
6328
- }
6329
-
6330
- /** @public */
6331
- declare interface HotspotPreview {
6332
- title: string
6333
- aspectRatio: number
6334
- }
6335
-
6336
- /** @public */
6337
- declare type I18nTextRecord<K extends string> = {
6338
- [P in K]?: {
6339
- key: string
6340
- ns: string
6341
- }
6342
- }
6343
-
6344
- /** @public */
6345
- declare interface ImageAsset extends Asset {
6346
- _type: 'sanity.imageAsset'
6347
- metadata: ImageMetadata
6348
- }
6349
-
6350
- /** @public */
6351
- declare interface ImageCrop {
6352
- _type?: 'sanity.imageCrop'
6353
- left: number
6354
- bottom: number
6355
- right: number
6356
- top: number
6357
- }
6358
-
6359
- /** @public */
6360
- declare interface ImageDefinition
6361
- extends Omit<
6362
- ObjectDefinition,
6363
- 'type' | 'fields' | 'options' | 'groups' | 'validation'
6364
- > {
6365
- type: 'image'
6366
- fields?: FieldDefinition[]
6367
- options?: ImageOptions
6368
- validation?: ValidationBuilder<ImageRule, ImageValue>
6369
- initialValue?: InitialValueProperty<any, ImageValue>
6370
- }
6371
-
6372
- /** @public */
6373
- declare interface ImageDimensions {
6374
- _type: 'sanity.imageDimensions'
6375
- height: number
6376
- width: number
6377
- aspectRatio: number
6378
- }
6379
-
6380
- /** @public */
6381
- declare interface ImageHotspot {
6382
- _type?: 'sanity.imageHotspot'
6383
- width: number
6384
- height: number
6385
- x: number
6386
- y: number
6387
- }
6388
-
6389
- /** @public */
6390
- declare interface ImageMetadata {
6391
- [key: string]: unknown
6392
- _type: 'sanity.imageMetadata'
6393
- dimensions: ImageDimensions
6394
- palette?: ImagePalette
6395
- lqip?: string
6396
- blurHash?: string
6397
- hasAlpha: boolean
6398
- isOpaque: boolean
6399
- }
6400
-
6401
- /** @public */
6402
- declare type ImageMetadataType =
6403
- | 'blurhash'
6404
- | 'lqip'
6405
- | 'palette'
6406
- | 'exif'
6407
- | 'image'
6408
- | 'location'
6409
-
6410
- /** @public */
6411
- declare interface ImageOptions extends FileOptions {
6412
- metadata?: ImageMetadataType[]
6413
- hotspot?: boolean | HotspotOptions
6414
- }
6415
-
6416
- /** @public */
6417
- declare interface ImagePalette {
6418
- _type: 'sanity.imagePalette'
6419
- darkMuted?: ImageSwatch
6420
- darkVibrant?: ImageSwatch
6421
- dominant?: ImageSwatch
6422
- lightMuted?: ImageSwatch
6423
- lightVibrant?: ImageSwatch
6424
- muted?: ImageSwatch
6425
- vibrant?: ImageSwatch
6426
- }
6427
-
6428
- /** @public */
6429
- declare interface ImageRule extends RuleDef<ImageRule, ImageValue> {
6430
- /**
6431
- * Require an image field has an asset.
6432
- *
6433
- * @example
6434
- * ```ts
6435
- * defineField({
6436
- * name: 'image',
6437
- * title: 'Image',
6438
- * type: 'image',
6439
- * validation: (Rule) => Rule.required().assetRequired(),
6440
- * })
6441
- * ```
6442
- */
6443
- assetRequired(): ImageRule
6444
- }
6445
-
6446
- /** @public */
6447
- declare interface ImageSwatch {
6448
- _type: 'sanity.imagePaletteSwatch'
6449
- background: string
6450
- foreground: string
6451
- population: number
6452
- title?: string
6453
- }
6454
-
6455
- /** @public */
6456
- declare interface ImageValue extends FileValue {
6457
- crop?: ImageCrop
6458
- hotspot?: ImageHotspot
6459
- [index: string]: unknown
6460
- }
6461
-
6462
- /** @public */
6463
- declare type IndexTuple = [number | '', number | '']
6464
-
6465
- /** @public */
6466
- declare type InitialValueProperty<Params, Value> =
6467
- | Value
6468
- | InitialValueResolver<Params, Value>
6469
- | undefined
6470
-
6471
- /** @public */
6472
- declare type InitialValueResolver<Params, Value> = (
6473
- params: Params | undefined,
6474
- context: InitialValueResolverContext,
6475
- ) => Promise<Value> | Value
6476
-
6477
- /** @public */
6478
- declare interface InitialValueResolverContext {
6479
- projectId: string
6480
- dataset: string
6481
- schema: Schema
6482
- currentUser: CurrentUser | null
6483
- getClient: (options: {apiVersion: string}) => SanityClient
6484
- }
6485
-
6486
- /** @public */
6487
- declare type InlineFieldDefinition = {
6488
- [K in keyof IntrinsicDefinitions]: Omit<
6489
- IntrinsicDefinitions[K],
6490
- 'initialValue' | 'validation'
6491
- > & {
6492
- validation?: SchemaValidationValue
6493
- initialValue?: InitialValueProperty<any, any>
6494
- }
6495
- }
6496
-
6497
- /**
6498
- * Used to represent native InputEvents that hold a DataTransfer object.
6499
- *
6500
- * These can either be one of:
6501
- *
6502
- * - insertFromPaste
6503
- * - insertFromPasteAsQuotation
6504
- * - insertFromDrop
6505
- * - insertReplacementText
6506
- * - insertFromYank
6507
- */
6508
- declare type InputBehaviorEvent = {
6509
- type: StrictExtract<NativeBehaviorEventType, 'input.*'>
6510
- originEvent: {
6511
- dataTransfer: DataTransfer
6512
- }
6513
- }
6514
-
6515
- /** @alpha This API may change */
6516
- declare interface InsertMenuOptions {
6517
- /**
6518
- * @defaultValue `'auto'`
6519
- * `filter: 'auto'` automatically turns on filtering if there are more than 5
6520
- * schema types added to the menu.
6521
- */
6522
- filter?: 'auto' | boolean
6523
- groups?: Array<{
6524
- name: string
6525
- title?: string
6526
- of?: Array<string>
6527
- }>
6528
- /** defaultValue `true` */
6529
- showIcons?: boolean
6530
- /** @defaultValue `[{name: 'list'}]` */
6531
- views?: Array<
6532
- | {
6533
- name: 'list'
6534
- }
6535
- | {
6536
- name: 'grid'
6537
- previewImageUrl?: (schemaTypeName: string) => string | undefined
6538
- }
6539
- >
6540
- }
6541
-
6542
- declare type InsertPlacement = 'auto' | 'after' | 'before'
6543
-
6544
- declare type InternalPatchEvent = NamespaceEvent<PatchEvent, 'internal'> & {
6545
- actionId?: string
6546
- value: Array<PortableTextBlock>
6547
- }
6548
-
6549
- /** @public */
6550
- declare type IntrinsicArrayOfDefinition = {
6551
- [K in keyof IntrinsicDefinitions]: Omit<
6552
- ArrayOfEntry<IntrinsicDefinitions[K]>,
6553
- 'validation' | 'initialValue'
6554
- > & {
6555
- validation?: SchemaValidationValue
6556
- initialValue?: InitialValueProperty<any, any>
6557
- }
6558
- }
6559
-
6560
- /**
6561
- * `IntrinsicDefinitions` is a lookup map for "predefined" schema definitions.
6562
- * Schema types in `IntrinsicDefinitions` will have good type-completion and type-safety in {@link defineType},
6563
- * {@link defineField} and {@link defineArrayMember} once the `type` property is provided.
6564
- *
6565
- * By default, `IntrinsicDefinitions` contains all standard Sanity schema types (`array`, `string`, `number` ect),
6566
- * but it is an interface and as such, open for extension.
6567
- *
6568
- * This type can be extended using declaration merging; this way new entries can be added.
6569
- * See {@link defineType} for examples on how this can be accomplished.
6570
- *
6571
- * @see defineType
6572
- *
6573
- * @public
6574
- */
6575
- declare interface IntrinsicDefinitions {
6576
- array: ArrayDefinition
6577
- block: BlockDefinition
6578
- boolean: BooleanDefinition
6579
- date: DateDefinition
6580
- datetime: DatetimeDefinition
6581
- document: DocumentDefinition
6582
- file: FileDefinition
6583
- geopoint: GeopointDefinition
6584
- image: ImageDefinition
6585
- number: NumberDefinition
6586
- object: ObjectDefinition
6587
- reference: ReferenceDefinition
6588
- crossDatasetReference: CrossDatasetReferenceDefinition
6589
- globalDocumentReference: GlobalDocumentReferenceDefinition
6590
- slug: SlugDefinition
6591
- string: StringDefinition
6592
- text: TextDefinition
6593
- url: UrlDefinition
6594
- email: EmailDefinition
6595
- }
6596
-
6597
- /**
6598
- * A union of all intrinsic types allowed natively in the schema.
6599
- *
6600
- * @see IntrinsicDefinitions
6601
- *
6602
- * @public
6603
- */
6604
- declare type IntrinsicTypeName =
6605
- IntrinsicDefinitions[keyof IntrinsicDefinitions]['type']
6606
-
6607
5561
  /**
6608
5562
  * The editor has invalid data in the value that can be resolved by the user
6609
5563
  * @beta */
@@ -6643,27 +5597,6 @@ declare type KeyboardBehaviorEvent =
6643
5597
  >
6644
5598
  }
6645
5599
 
6646
- /** @public */
6647
- declare type KeyedSegment = {
6648
- _key: string
6649
- }
6650
-
6651
- /**
6652
- * Holds localized validation messages for a given field.
6653
- *
6654
- * @example Custom message for English (US) and Norwegian (Bokmål):
6655
- * ```
6656
- * {
6657
- * 'en-US': 'Needs to start with a capital letter',
6658
- * 'no-NB': 'Må starte med stor bokstav',
6659
- * }
6660
- * ```
6661
- * @public
6662
- */
6663
- declare interface LocalizedValidationMessages {
6664
- [locale: string]: string
6665
- }
6666
-
6667
5600
  /**
6668
5601
  * @beta
6669
5602
  */
@@ -6761,21 +5694,6 @@ declare type MouseBehaviorEvent = {
6761
5694
  position: EventPosition
6762
5695
  }
6763
5696
 
6764
- /** @public */
6765
- declare interface MultiFieldSet {
6766
- name: string
6767
- title?: string
6768
- description?: string
6769
- single?: false
6770
- group?: string | string[]
6771
- options?: CollapseOptions & {
6772
- columns?: number
6773
- }
6774
- fields: ObjectField[]
6775
- hidden?: ConditionalProperty
6776
- readOnly?: ConditionalProperty
6777
- }
6778
-
6779
5697
  /**
6780
5698
  * @public
6781
5699
  */
@@ -6843,114 +5761,10 @@ declare const nativeBehaviorEventTypes: readonly [
6843
5761
  'mouse.click',
6844
5762
  ]
6845
5763
 
6846
- /** @public */
6847
- declare interface NumberDefinition extends BaseSchemaDefinition {
6848
- type: 'number'
6849
- options?: NumberOptions
6850
- placeholder?: string
6851
- validation?: ValidationBuilder<NumberRule, number>
6852
- initialValue?: InitialValueProperty<any, number>
6853
- }
6854
-
6855
- /** @public */
6856
- declare interface NumberOptions
6857
- extends EnumListProps<number>,
6858
- BaseSchemaTypeOptions {}
6859
-
6860
- /** @public */
6861
- declare interface NumberRule extends RuleDef<NumberRule, number> {
6862
- min: (minNumber: number | FieldReference) => NumberRule
6863
- max: (maxNumber: number | FieldReference) => NumberRule
6864
- lessThan: (limit: number | FieldReference) => NumberRule
6865
- greaterThan: (limit: number | FieldReference) => NumberRule
6866
- integer: () => NumberRule
6867
- precision: (limit: number | FieldReference) => NumberRule
6868
- positive: () => NumberRule
6869
- negative: () => NumberRule
6870
- }
6871
-
6872
- /** @public */
6873
- declare interface NumberSchemaType extends BaseSchemaType {
6874
- jsonType: 'number'
6875
- options?: NumberOptions
6876
- initialValue?: InitialValueProperty<any, number>
6877
- }
6878
-
6879
5764
  declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
6880
5765
  _key?: PortableTextObject['_key']
6881
5766
  }
6882
5767
 
6883
- /** @public */
6884
- declare interface ObjectDefinition extends BaseSchemaDefinition {
6885
- type: 'object'
6886
- /**
6887
- * Object must have at least one field. This is validated at Studio startup.
6888
- */
6889
- fields: FieldDefinition[]
6890
- groups?: FieldGroupDefinition[]
6891
- fieldsets?: FieldsetDefinition[]
6892
- preview?: PreviewConfig
6893
- options?: ObjectOptions
6894
- validation?: ValidationBuilder<ObjectRule, Record<string, unknown>>
6895
- initialValue?: InitialValueProperty<any, Record<string, unknown>>
6896
- }
6897
-
6898
- /** @public */
6899
- declare interface ObjectField<T extends SchemaType = SchemaType> {
6900
- name: string
6901
- fieldset?: string
6902
- group?: string | string[]
6903
- type: ObjectFieldType<T>
6904
- }
6905
-
6906
- /** @public */
6907
- declare type ObjectFieldType<T extends SchemaType = SchemaType> = T & {
6908
- hidden?: ConditionalProperty
6909
- readOnly?: ConditionalProperty
6910
- }
6911
-
6912
- /** @public */
6913
- declare interface ObjectOptions extends BaseSchemaTypeOptions {
6914
- collapsible?: boolean
6915
- collapsed?: boolean
6916
- columns?: number
6917
- modal?: {
6918
- type?: 'dialog' | 'popover'
6919
- width?: number | number[] | 'auto'
6920
- }
6921
- }
6922
-
6923
- /** @public */
6924
- declare interface ObjectRule
6925
- extends RuleDef<ObjectRule, Record<string, unknown>> {}
6926
-
6927
- /** @public */
6928
- declare interface ObjectSchemaType extends BaseSchemaType {
6929
- jsonType: 'object'
6930
- fields: ObjectField[]
6931
- groups?: FieldGroup[]
6932
- fieldsets?: Fieldset[]
6933
- initialValue?: InitialValueProperty<any, Record<string, unknown>>
6934
- weak?: boolean
6935
- /** @deprecated Unused. Use the new field-level search config. */
6936
- __experimental_search?: {
6937
- path: (string | number)[]
6938
- weight: number
6939
- mapWith?: string
6940
- }[]
6941
- /** @alpha */
6942
- __experimental_omnisearch_visibility?: boolean
6943
- /** @alpha */
6944
- __experimental_actions?: string[]
6945
- /** @alpha */
6946
- __experimental_formPreviewTitle?: boolean
6947
- /**
6948
- * @beta
6949
- */
6950
- orderings?: SortOrdering[]
6951
- options?: any
6952
- }
6953
-
6954
5768
  /**
6955
5769
  * @beta
6956
5770
  * Restrict the editor to one line. The plugin takes care of blocking
@@ -6977,12 +5791,6 @@ declare type PatchEvent = {
6977
5791
  patch: Patch
6978
5792
  }
6979
5793
 
6980
- /** @public */
6981
- declare type Path = PathSegment[]
6982
-
6983
- /** @public */
6984
- declare type PathSegment = string | number | KeyedSegment | IndexTuple
6985
-
6986
5794
  /**
6987
5795
  * @internal
6988
5796
  */
@@ -6992,18 +5800,6 @@ declare type PickFromUnion<
6992
5800
  TPickedTags extends TUnion[TTagKey],
6993
5801
  > = TUnion extends Record<TTagKey, TPickedTags> ? TUnion : never
6994
5802
 
6995
- /** @alpha */
6996
- declare type PortableTextBlock = PortableTextTextBlock | PortableTextObject
6997
-
6998
- /** @alpha */
6999
- declare type PortableTextChild = PortableTextObject | PortableTextSpan
7000
-
7001
- /** @alpha */
7002
- declare interface PortableTextListBlock extends PortableTextTextBlock {
7003
- listItem: string
7004
- level: number
7005
- }
7006
-
7007
5803
  /** @beta */
7008
5804
  declare type PortableTextMemberSchemaTypes = {
7009
5805
  annotations: (ObjectSchemaType & {
@@ -7019,13 +5815,6 @@ declare type PortableTextMemberSchemaTypes = {
7019
5815
  lists: BlockListDefinition[]
7020
5816
  }
7021
5817
 
7022
- /** @alpha */
7023
- declare interface PortableTextObject {
7024
- _type: string
7025
- _key: string
7026
- [other: string]: unknown
7027
- }
7028
-
7029
5818
  declare interface PortableTextSlateEditor extends ReactEditor {
7030
5819
  _key: 'editor'
7031
5820
  _type: 'editor'
@@ -7059,162 +5848,6 @@ declare interface PortableTextSlateEditor extends ReactEditor {
7059
5848
  redo: () => void
7060
5849
  }
7061
5850
 
7062
- /** @alpha */
7063
- declare interface PortableTextSpan {
7064
- _key: string
7065
- _type: 'span'
7066
- text: string
7067
- marks?: string[]
7068
- }
7069
-
7070
- /** @alpha */
7071
- declare interface PortableTextTextBlock<
7072
- TChild = PortableTextSpan | PortableTextObject,
7073
- > {
7074
- _type: string
7075
- _key: string
7076
- children: TChild[]
7077
- markDefs?: PortableTextObject[]
7078
- listItem?: string
7079
- style?: string
7080
- level?: number
7081
- }
7082
-
7083
- /** @public */
7084
- declare interface PrepareViewOptions {
7085
- /** @beta */
7086
- ordering?: SortOrdering
7087
- }
7088
-
7089
- /** @public */
7090
- declare interface PreviewConfig<
7091
- Select extends Record<string, string> = Record<string, string>,
7092
- PrepareValue extends Record<keyof Select, any> = Record<keyof Select, any>,
7093
- > {
7094
- select?: Select
7095
- prepare?: (
7096
- value: PrepareValue,
7097
- viewOptions?: PrepareViewOptions,
7098
- ) => PreviewValue
7099
- }
7100
-
7101
- /** @public */
7102
- declare interface PreviewValue {
7103
- _id?: string
7104
- _createdAt?: string
7105
- _updatedAt?: string
7106
- title?: string
7107
- subtitle?: string
7108
- description?: string
7109
- media?: ReactNode | ElementType
7110
- imageUrl?: string
7111
- }
7112
-
7113
- /** @public */
7114
- declare interface Reference {
7115
- _type: string
7116
- _ref: string
7117
- _key?: string
7118
- _weak?: boolean
7119
- _strengthenOnPublish?: {
7120
- type: string
7121
- weak?: boolean
7122
- template?: {
7123
- id: string
7124
- params: Record<string, string | number | boolean>
7125
- }
7126
- }
7127
- }
7128
-
7129
- /** @public */
7130
- declare interface ReferenceBaseOptions extends BaseSchemaTypeOptions {
7131
- disableNew?: boolean
7132
- }
7133
-
7134
- /** @public */
7135
- declare interface ReferenceDefinition extends BaseSchemaDefinition {
7136
- type: 'reference'
7137
- to: ReferenceTo
7138
- weak?: boolean
7139
- options?: ReferenceOptions
7140
- validation?: ValidationBuilder<ReferenceRule, ReferenceValue>
7141
- initialValue?: InitialValueProperty<any, Omit<ReferenceValue, '_type'>>
7142
- }
7143
-
7144
- /** @public */
7145
- declare type ReferenceFilterOptions =
7146
- | ReferenceFilterResolverOptions
7147
- | ReferenceFilterQueryOptions
7148
-
7149
- /** @public */
7150
- declare interface ReferenceFilterQueryOptions {
7151
- filter: string
7152
- filterParams?: Record<string, unknown>
7153
- }
7154
-
7155
- /** @public */
7156
- declare type ReferenceFilterResolver = (
7157
- context: ReferenceFilterResolverContext,
7158
- ) => ReferenceFilterSearchOptions | Promise<ReferenceFilterSearchOptions>
7159
-
7160
- /** @public */
7161
- declare interface ReferenceFilterResolverContext {
7162
- document: SanityDocument
7163
- parent?: Record<string, unknown> | Record<string, unknown>[]
7164
- parentPath: Path
7165
- getClient: (options: {apiVersion: string}) => SanityClient
7166
- }
7167
-
7168
- /** @public */
7169
- declare interface ReferenceFilterResolverOptions {
7170
- filter?: ReferenceFilterResolver
7171
- filterParams?: never
7172
- }
7173
-
7174
- /** @public */
7175
- declare type ReferenceFilterSearchOptions = {
7176
- filter?: string
7177
- params?: Record<string, unknown>
7178
- tag?: string
7179
- maxFieldDepth?: number
7180
- strategy?: SearchStrategy
7181
- perspective?: ClientPerspective
7182
- }
7183
-
7184
- /**
7185
- * Types are closed for extension. To add properties via declaration merging to this type,
7186
- * redeclare and add the properties to the interfaces that make up ReferenceOptions type.
7187
- *
7188
- * @see ReferenceFilterOptions
7189
- * @see ReferenceFilterResolverOptions
7190
- * @see ReferenceBaseOptions
7191
- *
7192
- * @public
7193
- */
7194
- declare type ReferenceOptions = ReferenceBaseOptions & ReferenceFilterOptions
7195
-
7196
- /** @public */
7197
- declare interface ReferenceRule
7198
- extends RuleDef<ReferenceRule, ReferenceValue> {}
7199
-
7200
- /** @public */
7201
- declare interface ReferenceSchemaType
7202
- extends Omit<ObjectSchemaType, 'options'> {
7203
- jsonType: 'object'
7204
- to: ObjectSchemaType[]
7205
- weak?: boolean
7206
- options?: ReferenceOptions
7207
- }
7208
-
7209
- /** @public */
7210
- declare type ReferenceTo =
7211
- | SchemaTypeDefinition
7212
- | TypeReference
7213
- | Array<SchemaTypeDefinition | TypeReference>
7214
-
7215
- /** @public */
7216
- declare type ReferenceValue = Reference
7217
-
7218
5851
  /**************************************
7219
5852
  * Resolve behavior event
7220
5853
  **************************************/
@@ -7240,437 +5873,6 @@ declare type ResolveBehaviorEvent<
7240
5873
  ? PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>
7241
5874
  : never
7242
5875
 
7243
- /** @public */
7244
- declare interface Role {
7245
- name: string
7246
- title: string
7247
- description?: string
7248
- }
7249
-
7250
- /** @public */
7251
- declare interface Rule {
7252
- /**
7253
- * @internal
7254
- * @deprecated internal use only
7255
- */
7256
- _type: RuleTypeConstraint | undefined
7257
- /**
7258
- * @internal
7259
- * @deprecated internal use only
7260
- */
7261
- _level: 'error' | 'warning' | 'info' | undefined
7262
- /**
7263
- * @internal
7264
- * @deprecated internal use only
7265
- */
7266
- _required: 'required' | 'optional' | undefined
7267
- /**
7268
- * @internal
7269
- * @deprecated internal use only
7270
- */
7271
- _typeDef: SchemaType | undefined
7272
- /**
7273
- * @internal
7274
- * @deprecated internal use only
7275
- */
7276
- _message: string | LocalizedValidationMessages | undefined
7277
- /**
7278
- * @internal
7279
- * @deprecated internal use only
7280
- */
7281
- _rules: RuleSpec[]
7282
- /**
7283
- * @internal
7284
- * @deprecated internal use only
7285
- */
7286
- _fieldRules: FieldRules | undefined
7287
- /**
7288
- * Takes in a path and returns an object with a symbol.
7289
- *
7290
- * When the validation lib sees this symbol, it will use the provided path to
7291
- * get a value from the current field's parent and use that value as the input
7292
- * to the Rule.
7293
- *
7294
- * The path that's given is forwarded to `lodash/get`
7295
- *
7296
- * ```js
7297
- * fields: [
7298
- * // ...
7299
- * {
7300
- * // ...
7301
- * name: 'highestTemperature',
7302
- * type: 'number',
7303
- * validation: (Rule) => Rule.positive().min(Rule.valueOfField('lowestTemperature')),
7304
- * // ...
7305
- * },
7306
- * ]
7307
- * ```
7308
- */
7309
- valueOfField: (path: string | string[]) => FieldReference
7310
- error(message?: string | LocalizedValidationMessages): Rule
7311
- warning(message?: string | LocalizedValidationMessages): Rule
7312
- info(message?: string | LocalizedValidationMessages): Rule
7313
- reset(): this
7314
- isRequired(): boolean
7315
- clone(): Rule
7316
- cloneWithRules(rules: RuleSpec[]): Rule
7317
- merge(rule: Rule): Rule
7318
- type(targetType: RuleTypeConstraint | Lowercase<RuleTypeConstraint>): Rule
7319
- all(children: Rule[]): Rule
7320
- either(children: Rule[]): Rule
7321
- optional(): Rule
7322
- required(): Rule
7323
- custom<T = unknown>(
7324
- fn: CustomValidator<T>,
7325
- options?: {
7326
- bypassConcurrencyLimit?: boolean
7327
- },
7328
- ): Rule
7329
- min(len: number | string | FieldReference): Rule
7330
- max(len: number | string | FieldReference): Rule
7331
- length(len: number | FieldReference): Rule
7332
- valid(value: unknown | unknown[]): Rule
7333
- integer(): Rule
7334
- precision(limit: number | FieldReference): Rule
7335
- positive(): Rule
7336
- negative(): Rule
7337
- greaterThan(num: number | FieldReference): Rule
7338
- lessThan(num: number | FieldReference): Rule
7339
- uppercase(): Rule
7340
- lowercase(): Rule
7341
- regex(
7342
- pattern: RegExp,
7343
- name: string,
7344
- options: {
7345
- name?: string
7346
- invert?: boolean
7347
- },
7348
- ): Rule
7349
- regex(
7350
- pattern: RegExp,
7351
- options: {
7352
- name?: string
7353
- invert?: boolean
7354
- },
7355
- ): Rule
7356
- regex(pattern: RegExp, name: string): Rule
7357
- regex(pattern: RegExp): Rule
7358
- email(): Rule
7359
- uri(options?: UriValidationOptions): Rule
7360
- unique(): Rule
7361
- reference(): Rule
7362
- fields(rules: FieldRules): Rule
7363
- assetRequired(): Rule
7364
- validate(
7365
- value: unknown,
7366
- options: ValidationContext & {
7367
- /**
7368
- * @deprecated Internal use only
7369
- * @internal
7370
- */
7371
- __internal?: {
7372
- customValidationConcurrencyLimiter?: {
7373
- ready: () => Promise<void>
7374
- release: () => void
7375
- }
7376
- }
7377
- },
7378
- ): Promise<ValidationMarker[]>
7379
- }
7380
-
7381
- /** @public */
7382
- declare type RuleBuilder<
7383
- T extends RuleDef<T, FieldValue>,
7384
- FieldValue = unknown,
7385
- > = T | T[]
7386
-
7387
- /** @public */
7388
- declare interface RuleDef<T, FieldValue = unknown> {
7389
- required: () => T
7390
- custom: <LenientFieldValue extends FieldValue>(
7391
- fn: CustomValidator<LenientFieldValue | undefined>,
7392
- ) => T
7393
- info: (message?: string | LocalizedValidationMessages) => T
7394
- error: (message?: string | LocalizedValidationMessages) => T
7395
- warning: (message?: string | LocalizedValidationMessages) => T
7396
- valueOfField: (path: string | string[]) => FieldReference
7397
- }
7398
-
7399
- /** @public */
7400
- declare type RuleSpec =
7401
- | {
7402
- flag: 'integer'
7403
- }
7404
- | {
7405
- flag: 'email'
7406
- }
7407
- | {
7408
- flag: 'unique'
7409
- }
7410
- | {
7411
- flag: 'reference'
7412
- }
7413
- | {
7414
- flag: 'type'
7415
- constraint: RuleTypeConstraint
7416
- }
7417
- | {
7418
- flag: 'all'
7419
- constraint: Rule[]
7420
- }
7421
- | {
7422
- flag: 'either'
7423
- constraint: Rule[]
7424
- }
7425
- | {
7426
- flag: 'presence'
7427
- constraint: 'optional' | 'required'
7428
- }
7429
- | {
7430
- flag: 'custom'
7431
- constraint: CustomValidator
7432
- }
7433
- | {
7434
- flag: 'min'
7435
- constraint: number | string
7436
- }
7437
- | {
7438
- flag: 'max'
7439
- constraint: number | string
7440
- }
7441
- | {
7442
- flag: 'length'
7443
- constraint: number
7444
- }
7445
- | {
7446
- flag: 'valid'
7447
- constraint: unknown[]
7448
- }
7449
- | {
7450
- flag: 'precision'
7451
- constraint: number
7452
- }
7453
- | {
7454
- flag: 'lessThan'
7455
- constraint: number
7456
- }
7457
- | {
7458
- flag: 'greaterThan'
7459
- constraint: number
7460
- }
7461
- | {
7462
- flag: 'stringCasing'
7463
- constraint: 'uppercase' | 'lowercase'
7464
- }
7465
- | {
7466
- flag: 'assetRequired'
7467
- constraint: {
7468
- assetType: 'asset' | 'image' | 'file'
7469
- }
7470
- }
7471
- | {
7472
- flag: 'regex'
7473
- constraint: {
7474
- pattern: RegExp
7475
- name?: string
7476
- invert: boolean
7477
- }
7478
- }
7479
- | {
7480
- flag: 'uri'
7481
- constraint: {
7482
- options: {
7483
- scheme: RegExp[]
7484
- allowRelative: boolean
7485
- relativeOnly: boolean
7486
- allowCredentials: boolean
7487
- }
7488
- }
7489
- }
7490
-
7491
- /** @public */
7492
- declare type RuleTypeConstraint =
7493
- | 'Array'
7494
- | 'Boolean'
7495
- | 'Date'
7496
- | 'Number'
7497
- | 'Object'
7498
- | 'String'
7499
-
7500
- /**
7501
- * Options for configuring how Sanity Create interfaces with the type or field.
7502
- *
7503
- * @public
7504
- */
7505
- declare interface SanityCreateOptions {
7506
- /** Set to true to exclude a type or field from appearing in Sanity Create */
7507
- exclude?: boolean
7508
- /**
7509
- * A short description of what the type or field is used for.
7510
- * Purpose can be used to improve how and when content mapping uses the field.
7511
- * */
7512
- purpose?: string
7513
- }
7514
-
7515
- /** @public */
7516
- declare interface SanityDocument {
7517
- _id: string
7518
- _type: string
7519
- _createdAt: string
7520
- _updatedAt: string
7521
- _rev: string
7522
- [key: string]: unknown
7523
- }
7524
-
7525
- /** @public */
7526
- declare interface Schema {
7527
- /** @internal */
7528
- _original?: {
7529
- name: string
7530
- types: SchemaTypeDefinition[]
7531
- }
7532
- /** @internal */
7533
- _registry: {
7534
- [typeName: string]: any
7535
- }
7536
- /** @internal */
7537
- _validation?: SchemaValidationProblemGroup[]
7538
- name: string
7539
- get: (name: string) => SchemaType | undefined
7540
- has: (name: string) => boolean
7541
- getTypeNames: () => string[]
7542
- }
7543
-
7544
- /**
7545
- * Note: you probably want `SchemaTypeDefinition` instead
7546
- * @see SchemaTypeDefinition
7547
- *
7548
- * @public
7549
- */
7550
- declare type SchemaType =
7551
- | ArraySchemaType
7552
- | BooleanSchemaType
7553
- | FileSchemaType
7554
- | NumberSchemaType
7555
- | ObjectSchemaType
7556
- | StringSchemaType
7557
- | ReferenceSchemaType
7558
-
7559
- /**
7560
- * Represents a Sanity schema type definition with an optional type parameter.
7561
- *
7562
- * It's recommend to use the `defineType` helper instead of this type by
7563
- * itself.
7564
- *
7565
- * @see defineType
7566
- *
7567
- * @public
7568
- */
7569
- declare type SchemaTypeDefinition<
7570
- TType extends IntrinsicTypeName = IntrinsicTypeName,
7571
- > = IntrinsicDefinitions[IntrinsicTypeName] | TypeAliasDefinition<string, TType>
7572
-
7573
- /** @public */
7574
- declare interface SchemaValidationError {
7575
- helpId?: string
7576
- message: string
7577
- severity: 'error'
7578
- }
7579
-
7580
- /** @internal */
7581
- declare type SchemaValidationProblem =
7582
- | SchemaValidationError
7583
- | SchemaValidationWarning
7584
-
7585
- /** @internal */
7586
- declare interface SchemaValidationProblemGroup {
7587
- path: SchemaValidationProblemPath
7588
- problems: SchemaValidationProblem[]
7589
- }
7590
-
7591
- /** @internal */
7592
- declare type SchemaValidationProblemPath = Array<
7593
- | {
7594
- kind: 'type'
7595
- type: string
7596
- name?: string
7597
- }
7598
- | {
7599
- kind: 'property'
7600
- name: string
7601
- }
7602
- >
7603
-
7604
- /**
7605
- * Represents the possible values of a schema type's `validation` field.
7606
- *
7607
- * If the schema has not been run through `inferFromSchema` from
7608
- * `sanity/validation` then value could be a function.
7609
- *
7610
- * `inferFromSchema` mutates the schema converts this value to an array of
7611
- * `Rule` instances.
7612
- *
7613
- * @privateRemarks
7614
- *
7615
- * Usage of the schema inside the studio will almost always be from the compiled
7616
- * `createSchema` function. In this case, you can cast the value or throw to
7617
- * narrow the type. E.g.:
7618
- *
7619
- * ```ts
7620
- * if (typeof type.validation === 'function') {
7621
- * throw new Error(
7622
- * `Schema type "${type.name}"'s \`validation\` was not run though \`inferFromSchema\``
7623
- * )
7624
- * }
7625
- * ```
7626
- *
7627
- * @public
7628
- */
7629
- declare type SchemaValidationValue =
7630
- | false
7631
- | undefined
7632
- | Rule
7633
- | SchemaValidationValue[]
7634
- | ((rule: Rule) => SchemaValidationValue)
7635
-
7636
- /** @internal */
7637
- declare interface SchemaValidationWarning {
7638
- helpId?: string
7639
- message: string
7640
- severity: 'warning'
7641
- }
7642
-
7643
- /** @public */
7644
- declare interface SearchConfiguration {
7645
- search?: {
7646
- /**
7647
- * Defines a search weight for this field to prioritize its importance
7648
- * during search operations in the Studio. This setting allows the specified
7649
- * field to be ranked higher in search results compared to other fields.
7650
- *
7651
- * By default, all fields are assigned a weight of 1. However, if a field is
7652
- * chosen as the `title` in the preview configuration's `select` option, it
7653
- * will automatically receive a default weight of 10. Similarly, if selected
7654
- * as the `subtitle`, the default weight is 5. Fields marked as
7655
- * `hidden: true` (no function) are assigned a weight of 0 by default.
7656
- *
7657
- * Note: Search weight configuration is currently supported only for fields
7658
- * of type string or portable text arrays.
7659
- */
7660
- weight?: number
7661
- }
7662
- }
7663
-
7664
- /**
7665
- * @public
7666
- */
7667
- declare const searchStrategies: readonly ['groqLegacy', 'groq2024']
7668
-
7669
- /**
7670
- * @public
7671
- */
7672
- declare type SearchStrategy = (typeof searchStrategies)[number]
7673
-
7674
5876
  declare type Serializer<TMIMEType extends MIMEType> = ({
7675
5877
  snapshot,
7676
5878
  event,
@@ -7683,159 +5885,8 @@ declare type Serializer<TMIMEType extends MIMEType> = ({
7683
5885
  'serialization.success' | 'serialization.failure'
7684
5886
  >
7685
5887
 
7686
- /** @public */
7687
- declare interface SingleFieldSet {
7688
- single: true
7689
- field: ObjectField
7690
- hidden?: ConditionalProperty
7691
- readOnly?: ConditionalProperty
7692
- group?: string | string[]
7693
- }
7694
-
7695
- /** @public */
7696
- declare interface SlugDefinition extends BaseSchemaDefinition {
7697
- type: 'slug'
7698
- options?: SlugOptions
7699
- validation?: ValidationBuilder<SlugRule, SlugValue>
7700
- initialValue?: InitialValueProperty<any, Omit<SlugValue, '_type'>>
7701
- }
7702
-
7703
- /** @public */
7704
- declare type SlugifierFn = (
7705
- source: string,
7706
- schemaType: SlugSchemaType,
7707
- context: SlugSourceContext,
7708
- ) => string | Promise<string>
7709
-
7710
- /** @public */
7711
- declare type SlugIsUniqueValidator = (
7712
- slug: string,
7713
- context: SlugValidationContext,
7714
- ) => boolean | Promise<boolean>
7715
-
7716
- /** @public */
7717
- declare interface SlugOptions
7718
- extends SearchConfiguration,
7719
- BaseSchemaTypeOptions {
7720
- source?: string | Path | SlugSourceFn
7721
- maxLength?: number
7722
- slugify?: SlugifierFn
7723
- isUnique?: SlugIsUniqueValidator
7724
- disableArrayWarning?: boolean
7725
- }
7726
-
7727
- /** @public */
7728
- declare type SlugParent = Record<string, unknown> | Record<string, unknown>[]
7729
-
7730
- /** @public */
7731
- declare interface SlugRule extends RuleDef<SlugRule, SlugValue> {}
7732
-
7733
- /** @public */
7734
- declare interface SlugSchemaType extends ObjectSchemaType {
7735
- jsonType: 'object'
7736
- options?: SlugOptions
7737
- }
7738
-
7739
- /** @public */
7740
- declare interface SlugSourceContext {
7741
- parentPath: Path
7742
- parent: SlugParent
7743
- projectId: string
7744
- dataset: string
7745
- schema: Schema
7746
- currentUser: CurrentUser | null
7747
- getClient: (options: {apiVersion: string}) => SanityClient
7748
- }
7749
-
7750
- /** @public */
7751
- declare type SlugSourceFn = (
7752
- document: SanityDocument,
7753
- context: SlugSourceContext,
7754
- ) => string | Promise<string>
7755
-
7756
- /** @public */
7757
- declare interface SlugValidationContext extends ValidationContext {
7758
- parent: SlugParent
7759
- type: SlugSchemaType
7760
- defaultIsUnique: SlugIsUniqueValidator
7761
- }
7762
-
7763
- /** @public */
7764
- declare interface SlugValue {
7765
- _type: 'slug'
7766
- current?: string
7767
- }
7768
-
7769
- /** @beta */
7770
- declare type SortOrdering = {
7771
- title: string
7772
- i18n?: I18nTextRecord<'title'>
7773
- name: string
7774
- by: SortOrderingItem[]
7775
- }
7776
-
7777
- /** @beta */
7778
- declare interface SortOrderingItem {
7779
- field: string
7780
- direction: 'asc' | 'desc'
7781
- }
7782
-
7783
5888
  declare type StrictExtract<T, U extends T> = U
7784
5889
 
7785
- /** @public */
7786
- declare interface StringDefinition extends BaseSchemaDefinition {
7787
- type: 'string'
7788
- options?: StringOptions
7789
- placeholder?: string
7790
- validation?: ValidationBuilder<StringRule, string>
7791
- initialValue?: InitialValueProperty<any, string>
7792
- }
7793
-
7794
- /** @public */
7795
- declare interface StringOptions
7796
- extends EnumListProps<string>,
7797
- SearchConfiguration,
7798
- BaseSchemaTypeOptions {}
7799
-
7800
- /** @public */
7801
- declare interface StringRule extends RuleDef<StringRule, string> {
7802
- min: (minNumber: number | FieldReference) => StringRule
7803
- max: (maxNumber: number | FieldReference) => StringRule
7804
- length: (exactLength: number | FieldReference) => StringRule
7805
- uppercase: () => StringRule
7806
- lowercase: () => StringRule
7807
- regex(
7808
- pattern: RegExp,
7809
- name: string,
7810
- options: {
7811
- name?: string
7812
- invert?: boolean
7813
- },
7814
- ): StringRule
7815
- regex(
7816
- pattern: RegExp,
7817
- options: {
7818
- name?: string
7819
- invert?: boolean
7820
- },
7821
- ): StringRule
7822
- regex(pattern: RegExp, name: string): StringRule
7823
- regex(pattern: RegExp): StringRule
7824
- email(): StringRule
7825
- }
7826
-
7827
- /**
7828
- * This is used for string, text, date and datetime.
7829
- * This interface represent the compiled version at runtime, when accessed through Schema.
7830
- *
7831
- * @public
7832
- */
7833
- declare interface StringSchemaType extends BaseSchemaType {
7834
- jsonType: 'string'
7835
- options?: StringOptions & TextOptions & DateOptions & DatetimeOptions
7836
- initialValue?: InitialValueProperty<any, string>
7837
- }
7838
-
7839
5890
  /**
7840
5891
  * @beta
7841
5892
  */
@@ -7985,199 +6036,9 @@ declare type TextBlockWithOptionalKey = Omit<PortableTextTextBlock, '_key'> & {
7985
6036
  _key?: PortableTextTextBlock['_key']
7986
6037
  }
7987
6038
 
7988
- /** @public */
7989
- declare interface TextDefinition extends BaseSchemaDefinition {
7990
- type: 'text'
7991
- rows?: number
7992
- options?: TextOptions
7993
- placeholder?: string
7994
- validation?: ValidationBuilder<TextRule, string>
7995
- initialValue?: InitialValueProperty<any, string>
7996
- }
7997
-
7998
- /** @public */
7999
- declare interface TextOptions extends StringOptions {}
8000
-
8001
- /** @public */
8002
- declare interface TextRule extends StringRule {}
8003
-
8004
- /** @public */
8005
- declare interface TitledListValue<V = unknown> {
8006
- _key?: string
8007
- title: string
8008
- value?: V
8009
- }
8010
-
8011
- /**
8012
- * Represents a type definition that is an alias/extension of an existing type
8013
- * in your schema. Creating a type alias will re-register that existing type
8014
- * under a different name. You can also override the default type options with
8015
- * a type alias definition.
8016
- *
8017
- * @public
8018
- */
8019
- declare interface TypeAliasDefinition<
8020
- TType extends string,
8021
- TAlias extends IntrinsicTypeName | undefined,
8022
- > extends BaseSchemaDefinition {
8023
- type: TType
8024
- options?: TAlias extends IntrinsicTypeName
8025
- ? IntrinsicDefinitions[TAlias]['options']
8026
- : unknown
8027
- validation?: SchemaValidationValue
8028
- initialValue?: InitialValueProperty<any, any>
8029
- preview?: PreviewConfig
8030
- components?: {
8031
- annotation?: ComponentType<any>
8032
- block?: ComponentType<any>
8033
- inlineBlock?: ComponentType<any>
8034
- diff?: ComponentType<any>
8035
- field?: ComponentType<any>
8036
- input?: ComponentType<any>
8037
- item?: ComponentType<any>
8038
- preview?: ComponentType<any>
8039
- }
8040
- }
8041
-
8042
- /**
8043
- * Represents a reference to another type registered top-level in your schema.
8044
- *
8045
- * @public
8046
- */
8047
- declare interface TypeReference {
8048
- type: string
8049
- name?: string
8050
- icon?: ComponentType | ReactNode
8051
- options?: {
8052
- [key: string]: unknown
8053
- }
8054
- }
8055
-
8056
6039
  declare type UnsetEvent = {
8057
6040
  type: 'unset'
8058
6041
  previousValue: Array<PortableTextBlock>
8059
6042
  }
8060
6043
 
8061
- /** @public */
8062
- declare interface UriValidationOptions {
8063
- scheme?: (string | RegExp) | Array<string | RegExp>
8064
- allowRelative?: boolean
8065
- relativeOnly?: boolean
8066
- allowCredentials?: boolean
8067
- }
8068
-
8069
- /** @public */
8070
- declare interface UrlDefinition extends BaseSchemaDefinition {
8071
- type: 'url'
8072
- options?: UrlOptions
8073
- placeholder?: string
8074
- validation?: ValidationBuilder<UrlRule, string>
8075
- initialValue?: InitialValueProperty<any, string>
8076
- }
8077
-
8078
- /** @public */
8079
- declare interface UrlOptions extends BaseSchemaTypeOptions {}
8080
-
8081
- /** @public */
8082
- declare interface UrlRule extends RuleDef<UrlRule, string> {
8083
- uri(options: UriValidationOptions): UrlRule
8084
- }
8085
-
8086
- /** @public */
8087
- declare type ValidationBuilder<
8088
- T extends RuleDef<T, FieldValue>,
8089
- FieldValue = unknown,
8090
- > = (rule: T) => RuleBuilder<T, FieldValue>
8091
-
8092
- /**
8093
- * A context object passed around during validation. This includes the
8094
- * `Rule.custom` context.
8095
- *
8096
- * e.g.
8097
- *
8098
- * ```js
8099
- * Rule.custom((_, validationContext) => {
8100
- * // ...
8101
- * })`
8102
- * ```
8103
- *
8104
- * @public
8105
- */
8106
- declare interface ValidationContext {
8107
- getClient: (options: {apiVersion: string}) => SanityClient
8108
- schema: Schema
8109
- parent?: unknown
8110
- type?: SchemaType
8111
- document?: SanityDocument
8112
- path?: Path
8113
- getDocumentExists?: (options: {id: string}) => Promise<boolean>
8114
- environment: 'cli' | 'studio'
8115
- }
8116
-
8117
- /**
8118
- * The shape that can be returned from a custom validator to be converted into
8119
- * a validation marker by the validation logic. Inside of a custom validator,
8120
- * you can return an array of these in order to specify multiple paths within
8121
- * an object or array.
8122
- *
8123
- * @public
8124
- */
8125
- declare interface ValidationError {
8126
- /**
8127
- * The message describing why the value is not valid. This message will be
8128
- * included in the validation markers after validation has finished running.
8129
- */
8130
- message: string
8131
- /**
8132
- * If writing a custom validator, you can return validation messages to
8133
- * specific path inside of the current value (object or array) by populating
8134
- * this `path` prop.
8135
- *
8136
- * NOTE: This path is relative to the current value and _not_ relative to
8137
- * the document.
8138
- */
8139
- path?: Path
8140
- /**
8141
- * Same as `path` but allows more than one value. If provided, the same
8142
- * message will create two markers from each path with the same message
8143
- * provided.
8144
- *
8145
- * @deprecated prefer `path`
8146
- */
8147
- paths?: Path[]
8148
- /**
8149
- * @deprecated Unused. Was used to store the results from `.either()` /`.all()`
8150
- */
8151
- children?: ValidationMarker[]
8152
- /**
8153
- * @deprecated Unused. Was used to signal if this error came from an `.either()`/`.all()`.
8154
- */
8155
- operation?: 'AND' | 'OR'
8156
- /**
8157
- * @deprecated Unused. Was relevant when validation error was used as a class.
8158
- */
8159
- cloneWithMessage?(message: string): ValidationError
8160
- }
8161
-
8162
- /** @public */
8163
- declare interface ValidationMarker {
8164
- level: 'error' | 'warning' | 'info'
8165
- /**
8166
- * The validation message for this marker. E.g. "Must be greater than 0"
8167
- */
8168
- message: string
8169
- /**
8170
- * @deprecated use `message` instead
8171
- */
8172
- item?: ValidationError
8173
- /**
8174
- * The sanity path _relative to the root of the current document_ to this
8175
- * marker.
8176
- *
8177
- * NOTE: Sanity paths may contain keyed segments (i.e. `{_key: string}`) that
8178
- * are not compatible with deep getters like lodash/get
8179
- */
8180
- path: Path
8181
- }
8182
-
8183
6044
  export {}