@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,6 +1,17 @@
1
1
  import type {KeyedSegment as KeyedSegment_2, Patch} from '@portabletext/patches'
2
- import {ClientPerspective, SanityClient} from '@sanity/client'
3
- import {ComponentType, ElementType, ReactNode} from 'react'
2
+ import type {
3
+ ArraySchemaType,
4
+ BlockDecoratorDefinition,
5
+ BlockListDefinition,
6
+ BlockStyleDefinition,
7
+ ObjectSchemaType,
8
+ Path,
9
+ PortableTextBlock,
10
+ PortableTextChild,
11
+ PortableTextListBlock,
12
+ PortableTextTextBlock,
13
+ } from '@sanity/types'
14
+ import {KeyedSegment, PortableTextObject, PortableTextSpan} from '@sanity/types'
4
15
  import type {
5
16
  FocusEvent as FocusEvent_2,
6
17
  KeyboardEvent as KeyboardEvent_2,
@@ -201,277 +212,6 @@ declare const abstractBehaviorEventTypes: readonly [
201
212
  'style.toggle',
202
213
  ]
203
214
 
204
- /**
205
- * Types of array actions that can be performed
206
- * @beta
207
- */
208
- declare type ArrayActionName =
209
- /**
210
- * Add any item to the array at any position
211
- */
212
- | 'add'
213
- /**
214
- * Add item after an existing item
215
- */
216
- | 'addBefore'
217
- /**
218
- * Add item after an existing item
219
- */
220
- | 'addAfter'
221
- /**
222
- * Remove any item
223
- */
224
- | 'remove'
225
- /**
226
- * Duplicate item
227
- */
228
- | 'duplicate'
229
- /**
230
- * Copy item
231
- */
232
- | 'copy'
233
-
234
- /** @public */
235
- declare interface ArrayDefinition extends BaseSchemaDefinition {
236
- type: 'array'
237
- of: ArrayOfType[]
238
- initialValue?: InitialValueProperty<any, unknown[]>
239
- validation?: ValidationBuilder<ArrayRule<unknown[]>, unknown[]>
240
- options?: ArrayOptions
241
- }
242
-
243
- /** @public */
244
- declare type ArrayOfEntry<T> = Omit<T, 'name' | 'hidden'> & {
245
- name?: string
246
- }
247
-
248
- /** @public */
249
- declare type ArrayOfType<
250
- TType extends IntrinsicTypeName = IntrinsicTypeName,
251
- TAlias extends IntrinsicTypeName | undefined = undefined,
252
- > =
253
- | IntrinsicArrayOfDefinition[TType]
254
- | ArrayOfEntry<TypeAliasDefinition<string, TAlias>>
255
-
256
- /** @public */
257
- declare interface ArrayOptions<V = unknown>
258
- extends SearchConfiguration,
259
- BaseSchemaTypeOptions {
260
- list?: TitledListValue<V>[] | V[]
261
- layout?: 'list' | 'tags' | 'grid'
262
- /** @deprecated This option does not have any effect anymore */
263
- direction?: 'horizontal' | 'vertical'
264
- sortable?: boolean
265
- modal?: {
266
- type?: 'dialog' | 'popover'
267
- width?: number | 'auto'
268
- }
269
- /** @alpha This API may change */
270
- insertMenu?: InsertMenuOptions
271
- /**
272
- * A boolean flag to enable or disable tree editing for the array.
273
- * If there are any nested arrays, they will inherit this value.
274
- * @deprecated tree editing beta feature has been disabled
275
- */
276
- treeEditing?: boolean
277
- /**
278
- * A list of array actions to disable
279
- * Possible options are defined by {@link ArrayActionName}
280
- * @beta
281
- */
282
- disableActions?: ArrayActionName[]
283
- }
284
-
285
- /** @public */
286
- declare interface ArrayRule<Value> extends RuleDef<ArrayRule<Value>, Value> {
287
- min: (length: number | FieldReference) => ArrayRule<Value>
288
- max: (length: number | FieldReference) => ArrayRule<Value>
289
- length: (length: number | FieldReference) => ArrayRule<Value>
290
- unique: () => ArrayRule<Value>
291
- }
292
-
293
- /** @public */
294
- declare interface ArraySchemaType<V = unknown> extends BaseSchemaType {
295
- jsonType: 'array'
296
- of: (Exclude<SchemaType, ArraySchemaType> | ReferenceSchemaType)[]
297
- options?: ArrayOptions<V> & {
298
- layout?: V extends string ? 'tag' : 'grid'
299
- }
300
- }
301
-
302
- /** @public */
303
- declare interface Asset extends SanityDocument {
304
- url: string
305
- path: string
306
- assetId: string
307
- extension: string
308
- mimeType: string
309
- sha1hash: string
310
- size: number
311
- originalFilename?: string
312
- label?: string
313
- title?: string
314
- description?: string
315
- creditLine?: string
316
- source?: AssetSourceSpec
317
- }
318
-
319
- /** @public */
320
- declare type AssetFromSource = {
321
- kind: 'assetDocumentId' | 'file' | 'base64' | 'url'
322
- value: string | File_2
323
- assetDocumentProps?: ImageAsset
324
- mediaLibraryProps?: {
325
- mediaLibraryId: string
326
- assetId: string
327
- assetInstanceId: string
328
- }
329
- }
330
-
331
- /** @public */
332
- declare interface AssetSource {
333
- name: string
334
- /** @deprecated provide `i18nKey` instead */
335
- title?: string
336
- i18nKey?: string
337
- component: ComponentType<AssetSourceComponentProps>
338
- icon?: ComponentType<EmptyProps>
339
- /** @beta */
340
- uploader?: AssetSourceUploader
341
- }
342
-
343
- /** @public */
344
- declare interface AssetSourceComponentProps {
345
- action?: 'select' | 'upload'
346
- assetSource: AssetSource
347
- assetType?: 'file' | 'image'
348
- accept: string
349
- selectionType: 'single'
350
- dialogHeaderTitle?: React.ReactNode
351
- selectedAssets: Asset[]
352
- onClose: () => void
353
- onSelect: (assetFromSource: AssetFromSource[]) => void
354
- }
355
-
356
- /** @public */
357
- declare interface AssetSourceSpec {
358
- id: string
359
- name: string
360
- url?: string
361
- }
362
-
363
- /** @beta */
364
- declare interface AssetSourceUploader {
365
- upload(
366
- files: globalThis.File[],
367
- options?: {
368
- /**
369
- * The schema type of the field the asset is being uploaded to.
370
- * May be of interest to the uploader to read file and image options.
371
- */
372
- schemaType?: SchemaType
373
- /**
374
- * The uploader may send patches directly to the field
375
- * Typed 'unknown' as we don't have patch definitions in sanity/types yet.
376
- */
377
- onChange?: (patch: unknown) => void
378
- },
379
- ): AssetSourceUploadFile[]
380
- /**
381
- * Abort the upload of a file
382
- */
383
- abort(file?: AssetSourceUploadFile): void
384
- /**
385
- * Get the files that are currently being uploaded
386
- */
387
- getFiles(): AssetSourceUploadFile[]
388
- /**
389
- * Subscribe to upload events from the uploader
390
- */
391
- subscribe(subscriber: (event: AssetSourceUploadEvent) => void): () => void
392
- /**
393
- * Update the status of a file. Will be emitted to subscribers.
394
- */
395
- updateFile(
396
- fileId: string,
397
- data: {
398
- progress?: number
399
- status?: string
400
- error?: Error
401
- },
402
- ): void
403
- /**
404
- * Reset the uploader (clear files). Should be called by the uploader when all files are done.
405
- */
406
- reset(): void
407
- }
408
-
409
- /** @beta */
410
- declare type AssetSourceUploadEvent =
411
- | AssetSourceUploadEventProgress
412
- | AssetSourceUploadEventStatus
413
- | AssetSourceUploadEventAllComplete
414
- | AssetSourceUploadEventError
415
- | AssetSourceUploadEventAbort
416
-
417
- /**
418
- * Emitted when all files are done, either successfully, aborted or with errors
419
- * @beta */
420
- declare type AssetSourceUploadEventAbort = {
421
- type: 'abort'
422
- /**
423
- * Files aborted
424
- */
425
- files: AssetSourceUploadFile[]
426
- }
427
-
428
- /**
429
- * Emitted when all files are done, either successfully, aborted or with errors
430
- * @beta */
431
- declare type AssetSourceUploadEventAllComplete = {
432
- type: 'all-complete'
433
- files: AssetSourceUploadFile[]
434
- }
435
-
436
- /**
437
- * Emitted when all files are done, either successfully, aborted or with errors
438
- * @beta */
439
- declare type AssetSourceUploadEventError = {
440
- type: 'error'
441
- /**
442
- * Files errored
443
- */
444
- files: AssetSourceUploadFile[]
445
- }
446
-
447
- /**
448
- * Emitted when a file upload is progressing
449
- * @beta */
450
- declare type AssetSourceUploadEventProgress = {
451
- type: 'progress'
452
- file: AssetSourceUploadFile
453
- progress: number
454
- }
455
-
456
- /**
457
- * Emitted when a file upload is changing status
458
- * @beta */
459
- declare type AssetSourceUploadEventStatus = {
460
- type: 'status'
461
- file: AssetSourceUploadFile
462
- status: AssetSourceUploadFile['status']
463
- }
464
-
465
- /** @beta */
466
- declare interface AssetSourceUploadFile {
467
- id: string
468
- file: globalThis.File
469
- progress: number
470
- status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted'
471
- error?: Error
472
- result?: unknown
473
- }
474
-
475
215
  /**
476
216
  * @public
477
217
  */
@@ -480,60 +220,6 @@ declare type BaseDefinition = {
480
220
  title?: string
481
221
  }
482
222
 
483
- /** @public */
484
- declare interface BaseSchemaDefinition {
485
- name: string
486
- title?: string
487
- description?: string | React.JSX.Element
488
- hidden?: ConditionalProperty
489
- readOnly?: ConditionalProperty
490
- icon?: ComponentType | ReactNode
491
- validation?: unknown
492
- initialValue?: unknown
493
- deprecated?: DeprecatedProperty
494
- }
495
-
496
- /** @public */
497
- declare interface BaseSchemaType extends Partial<DeprecationConfiguration> {
498
- name: string
499
- title?: string
500
- description?: string
501
- type?: SchemaType
502
- liveEdit?: boolean
503
- readOnly?: ConditionalProperty
504
- hidden?: ConditionalProperty
505
- icon?: ComponentType
506
- initialValue?: InitialValueProperty<any, any>
507
- validation?: SchemaValidationValue
508
- preview?: PreviewConfig
509
- /** @beta */
510
- components?: {
511
- block?: ComponentType<any>
512
- inlineBlock?: ComponentType<any>
513
- annotation?: ComponentType<any>
514
- diff?: ComponentType<any>
515
- field?: ComponentType<any>
516
- input?: ComponentType<any>
517
- item?: ComponentType<any>
518
- preview?: ComponentType<any>
519
- }
520
- /**
521
- * @deprecated This will be removed.
522
- */
523
- placeholder?: string
524
- }
525
-
526
- /**
527
- * `BaseOptions` applies to all type options.
528
- *
529
- * It can be extended by interface declaration merging in plugins to provide generic options to all types and fields.
530
- *
531
- * @public
532
- * */
533
- declare interface BaseSchemaTypeOptions {
534
- sanityCreate?: SanityCreateOptions
535
- }
536
-
537
223
  /**
538
224
  * @beta
539
225
  */
@@ -619,142 +305,6 @@ declare type BehaviorGuard<TBehaviorEvent, TGuardResponse> = (payload: {
619
305
  event: TBehaviorEvent
620
306
  }) => TGuardResponse | false
621
307
 
622
- /**
623
- * Schema definition for text block decorators.
624
- *
625
- * @public
626
- * @example The default set of decorators
627
- * ```ts
628
- * {
629
- * name: 'blockContent',
630
- * title: 'Content',
631
- * type: 'array',
632
- * of: [
633
- * {
634
- * type: 'block',
635
- * marks: {
636
- * decorators: [
637
- * {title: 'Strong', value: 'strong'},
638
- * {title: 'Emphasis', value: 'em'},
639
- * {title: 'Underline', value: 'underline'},
640
- * {title: 'Strike', value: 'strike'},
641
- * {title: 'Code', value: 'code'},
642
- * ]
643
- * }
644
- * }
645
- * ]
646
- * }
647
- * ```
648
- */
649
- declare interface BlockDecoratorDefinition {
650
- title: string
651
- i18nTitleKey?: string
652
- value: string
653
- icon?: ReactNode | ComponentType
654
- }
655
-
656
- /**
657
- * Schema definition for text blocks.
658
- *
659
- * @public
660
- * @example the default block definition
661
- * ```ts
662
- * {
663
- * name: 'blockContent',
664
- * title: 'Content',
665
- * type: 'array',
666
- * of: [
667
- * {
668
- * type: 'block',
669
- * marks: {
670
- * decorators: [
671
- * {title: 'Strong', value: 'strong'},
672
- * {title: 'Emphasis', value: 'em'},
673
- * {title: 'Underline', value: 'underline'},
674
- * {title: 'Strike', value: 'strike'},
675
- * {title: 'Code', value: 'code'},
676
- * ],
677
- * annotations: [
678
- * {
679
- * type: 'object',
680
- * name: 'link',
681
- * fields: [
682
- * {
683
- * type: 'string',
684
- * name: 'href',
685
- * },
686
- * ],
687
- * },
688
- * ]
689
- * },
690
- * styles: [
691
- * {title: 'Normal', value: 'normal'},
692
- * {title: 'H1', value: 'h1'},
693
- * {title: 'H2', value: 'h2'},
694
- * {title: 'H3', value: 'h3'},
695
- * {title: 'H4', value: 'h4'},
696
- * {title: 'H5', value: 'h5'},
697
- * {title: 'H6', value: 'h6'},
698
- * {title: 'Quote', value: 'blockquote'}
699
- * ],
700
- * lists: [
701
- * {title: 'Bullet', value: 'bullet'},
702
- * {title: 'Number', value: 'number'},
703
- * ],
704
- * },
705
- * ]
706
- * }
707
- * ```
708
- */
709
- declare interface BlockDefinition extends BaseSchemaDefinition {
710
- type: 'block'
711
- styles?: BlockStyleDefinition[]
712
- lists?: BlockListDefinition[]
713
- marks?: BlockMarksDefinition
714
- of?: ArrayOfType<'object' | 'reference'>[]
715
- initialValue?: InitialValueProperty<any, any[]>
716
- options?: BlockOptions
717
- validation?: ValidationBuilder<BlockRule, any[]>
718
- }
719
-
720
- /**
721
- * Schema definition for a text block list style.
722
- *
723
- * @public
724
- * @example The defaults lists
725
- * ```ts
726
- * {
727
- * name: 'blockContent',
728
- * title: 'Content',
729
- * type: 'array',
730
- * of: [
731
- * {
732
- * type: 'block',
733
- * lists: [
734
- * {title: 'Bullet', value: 'bullet'},
735
- * {title: 'Number', value: 'number'},
736
- * ]
737
- * }
738
- * ]
739
- * }
740
- * ```
741
- */
742
- declare interface BlockListDefinition {
743
- title: string
744
- i18nTitleKey?: string
745
- value: string
746
- icon?: ReactNode | ComponentType
747
- }
748
-
749
- /**
750
- * Schema definition for text block marks (decorators and annotations).
751
- *
752
- * @public */
753
- declare interface BlockMarksDefinition {
754
- decorators?: BlockDecoratorDefinition[]
755
- annotations?: ArrayOfType<'object' | 'reference'>[]
756
- }
757
-
758
308
  /**
759
309
  * @beta
760
310
  */
@@ -763,108 +313,10 @@ declare type BlockOffset = {
763
313
  offset: number
764
314
  }
765
315
 
766
- /**
767
- * Schema options for a Block schema definition
768
- * @public */
769
- declare interface BlockOptions extends BaseSchemaTypeOptions {
770
- /**
771
- * Turn on or off the builtin browser spellchecking. Default is on.
772
- */
773
- spellCheck?: boolean
774
- unstable_whitespaceOnPasteMode?: 'preserve' | 'normalize' | 'remove'
775
- }
776
-
777
- /** @public */
778
- declare interface BlockRule extends RuleDef<BlockRule, any[]> {}
779
-
780
- /**
781
- * Schema definition for a text block style.
782
- * A text block may have a block style like 'header', 'normal', 'lead'
783
- * attached to it, which is stored on the `.style` property for that block.
784
- *
785
- * @public
786
- * @remarks The first defined style will become the default style.´´
787
- * @example The default set of styles
788
- * ```ts
789
- * {
790
- * name: 'blockContent',
791
- * title: 'Content',
792
- * type: 'array',
793
- * of: [
794
- * {
795
- * type: 'block',
796
- * styles: [
797
- * {title: 'Normal', value: 'normal'},
798
- * {title: 'H1', value: 'h1'},
799
- * {title: 'H2', value: 'h2'},
800
- * {title: 'H3', value: 'h3'},
801
- * {title: 'H4', value: 'h4'},
802
- * {title: 'H5', value: 'h5'},
803
- * {title: 'H6', value: 'h6'},
804
- * {title: 'Quote', value: 'blockquote'}
805
- * ]
806
- * }
807
- * ]
808
- * }
809
- * ```
810
- * @example Example of defining a block type with custom styles and render components.
811
- * ```ts
812
- * defineArrayMember({
813
- * type: 'block',
814
- * styles: [
815
- * {
816
- * title: 'Paragraph',
817
- * value: 'paragraph',
818
- * component: ParagraphStyle,
819
- * },
820
- * {
821
- * title: 'Lead',
822
- * value: 'lead',
823
- * component: LeadStyle,
824
- * },
825
- * {
826
- * title: 'Heading',
827
- * value: 'heading',
828
- * component: HeadingStyle,
829
- * },
830
- * ],
831
- * })
832
- * ```
833
- */
834
- declare interface BlockStyleDefinition {
835
- title: string
836
- value: string
837
- i18nTitleKey?: string
838
- icon?: ReactNode | ComponentType
839
- }
840
-
841
316
  declare type BlockWithOptionalKey =
842
317
  | TextBlockWithOptionalKey
843
318
  | ObjectBlockWithOptionalKey
844
319
 
845
- /** @public */
846
- declare interface BooleanDefinition extends BaseSchemaDefinition {
847
- type: 'boolean'
848
- options?: BooleanOptions
849
- initialValue?: InitialValueProperty<any, boolean>
850
- validation?: ValidationBuilder<BooleanRule, boolean>
851
- }
852
-
853
- /** @public */
854
- declare interface BooleanOptions extends BaseSchemaTypeOptions {
855
- layout?: 'switch' | 'checkbox'
856
- }
857
-
858
- /** @public */
859
- declare interface BooleanRule extends RuleDef<BooleanRule, boolean> {}
860
-
861
- /** @public */
862
- declare interface BooleanSchemaType extends BaseSchemaType {
863
- jsonType: 'boolean'
864
- options?: BooleanOptions
865
- initialValue?: InitialValueProperty<any, boolean>
866
- }
867
-
868
320
  declare type ClipboardBehaviorEvent =
869
321
  | {
870
322
  type: StrictExtract<NativeBehaviorEventType, 'clipboard.copy'>
@@ -888,35 +340,6 @@ declare type ClipboardBehaviorEvent =
888
340
  position: Pick<EventPosition, 'selection'>
889
341
  }
890
342
 
891
- /** @public */
892
- declare interface CollapseOptions {
893
- collapsed?: boolean
894
- collapsible?: boolean
895
- /**
896
- * @deprecated Use `collapsible` instead
897
- */
898
- collapsable?: boolean
899
- }
900
-
901
- /** @public */
902
- declare type ConditionalProperty =
903
- | boolean
904
- | ConditionalPropertyCallback
905
- | undefined
906
-
907
- /** @public */
908
- declare type ConditionalPropertyCallback = (
909
- context: ConditionalPropertyCallbackContext,
910
- ) => boolean
911
-
912
- /** @public */
913
- declare interface ConditionalPropertyCallbackContext {
914
- document: SanityDocument | undefined
915
- parent: any
916
- value: any
917
- currentUser: Omit<CurrentUser, 'role'> | null
918
- }
919
-
920
343
  declare type Converter<TMIMEType extends MIMEType = MIMEType> = {
921
344
  mimeType: TMIMEType
922
345
  serialize: Serializer<TMIMEType>
@@ -955,46 +378,6 @@ declare type ConverterEvent<TMIMEType extends MIMEType = MIMEType> =
955
378
  mimeType: TMIMEType
956
379
  }
957
380
 
958
- /** @public */
959
- declare interface CrossDatasetReferenceDefinition extends BaseSchemaDefinition {
960
- type: 'crossDatasetReference'
961
- weak?: boolean
962
- to: {
963
- type: string
964
- title?: string
965
- icon?: ComponentType
966
- preview?: PreviewConfig
967
- /**
968
- * @deprecated Unused. Configuring search is no longer supported.
969
- */
970
- __experimental_search?: {
971
- path: string | string[]
972
- weight?: number
973
- mapWith?: string
974
- }[]
975
- }[]
976
- dataset: string
977
- studioUrl?: (document: {id: string; type?: string}) => string | null
978
- tokenId?: string
979
- options?: ReferenceOptions
980
- /**
981
- * @deprecated Cross-project references are no longer supported, only cross-dataset
982
- */
983
- projectId?: string
984
- }
985
-
986
- /** @public */
987
- declare interface CurrentUser {
988
- id: string
989
- name: string
990
- email: string
991
- profileImage?: string
992
- provider?: string
993
- /** @deprecated use `roles` instead */
994
- role: string
995
- roles: Role[]
996
- }
997
-
998
381
  /**
999
382
  * @beta
1000
383
  */
@@ -1019,89 +402,6 @@ declare type CustomBehaviorEventType<
1019
402
  TType extends string = '',
1020
403
  > = TType extends '' ? `${TNamespace}` : `${TNamespace}.${TType}`
1021
404
 
1022
- /** @public */
1023
- declare interface CustomValidator<T = unknown> {
1024
- (
1025
- value: T,
1026
- context: ValidationContext,
1027
- ): CustomValidatorResult | Promise<CustomValidatorResult>
1028
- bypassConcurrencyLimit?: boolean
1029
- }
1030
-
1031
- /** @public */
1032
- declare type CustomValidatorResult =
1033
- | true
1034
- | string
1035
- | ValidationError
1036
- | ValidationError[]
1037
- | LocalizedValidationMessages
1038
-
1039
- /** @public */
1040
- declare interface DateDefinition extends BaseSchemaDefinition {
1041
- type: 'date'
1042
- options?: DateOptions
1043
- placeholder?: string
1044
- validation?: ValidationBuilder<DateRule, string>
1045
- initialValue?: InitialValueProperty<any, string>
1046
- }
1047
-
1048
- /** @public */
1049
- declare interface DateOptions extends BaseSchemaTypeOptions {
1050
- dateFormat?: string
1051
- }
1052
-
1053
- /** @public */
1054
- declare interface DateRule extends RuleDef<DateRule, string> {
1055
- /**
1056
- * @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
1057
- */
1058
- min: (minDate: string | FieldReference) => DateRule
1059
- /**
1060
- * @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
1061
- */
1062
- max: (maxDate: string | FieldReference) => DateRule
1063
- }
1064
-
1065
- /** @public */
1066
- declare interface DatetimeDefinition extends BaseSchemaDefinition {
1067
- type: 'datetime'
1068
- options?: DatetimeOptions
1069
- placeholder?: string
1070
- validation?: ValidationBuilder<DatetimeRule, string>
1071
- initialValue?: InitialValueProperty<any, string>
1072
- }
1073
-
1074
- /** @public */
1075
- declare interface DatetimeOptions extends BaseSchemaTypeOptions {
1076
- dateFormat?: string
1077
- timeFormat?: string
1078
- timeStep?: number
1079
- }
1080
-
1081
- /** @public */
1082
- declare interface DatetimeRule extends RuleDef<DatetimeRule, string> {
1083
- /**
1084
- * @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
1085
- */
1086
- min: (minDate: string | FieldReference) => DatetimeRule
1087
- /**
1088
- * @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
1089
- */
1090
- max: (maxDate: string | FieldReference) => DatetimeRule
1091
- }
1092
-
1093
- /** @public */
1094
- declare interface DeprecatedProperty {
1095
- reason: string
1096
- }
1097
-
1098
- /**
1099
- * @public
1100
- */
1101
- declare interface DeprecationConfiguration {
1102
- deprecated: DeprecatedProperty
1103
- }
1104
-
1105
405
  declare type Deserializer<TMIMEType extends MIMEType> = ({
1106
406
  snapshot,
1107
407
  event,
@@ -1114,40 +414,6 @@ declare type Deserializer<TMIMEType extends MIMEType> = ({
1114
414
  'deserialization.success' | 'deserialization.failure'
1115
415
  >
1116
416
 
1117
- /** @public */
1118
- declare interface DocumentDefinition extends Omit<ObjectDefinition, 'type'> {
1119
- type: 'document'
1120
- liveEdit?: boolean
1121
- /** @beta */
1122
- orderings?: SortOrdering[]
1123
- options?: DocumentOptions
1124
- validation?: ValidationBuilder<DocumentRule, SanityDocument>
1125
- initialValue?: InitialValueProperty<any, Record<string, unknown>>
1126
- /** @deprecated Unused. Use the new field-level search config. */
1127
- __experimental_search?: {
1128
- path: string
1129
- weight: number
1130
- mapWith?: string
1131
- }[]
1132
- /** @alpha */
1133
- __experimental_omnisearch_visibility?: boolean
1134
- /**
1135
- * Determines whether the large preview title is displayed in the document pane form
1136
- * @alpha
1137
- * */
1138
- __experimental_formPreviewTitle?: boolean
1139
- }
1140
-
1141
- /**
1142
- * This exists only to allow for extensions using declaration-merging.
1143
- *
1144
- * @public
1145
- */
1146
- declare interface DocumentOptions extends BaseSchemaTypeOptions {}
1147
-
1148
- /** @public */
1149
- declare interface DocumentRule extends RuleDef<DocumentRule, SanityDocument> {}
1150
-
1151
417
  declare type DragBehaviorEvent =
1152
418
  | {
1153
419
  type: StrictExtract<NativeBehaviorEventType, 'drag.dragstart'>
@@ -1313,6 +579,7 @@ declare const editorMachine: StateMachine<
1313
579
  getLegacySchema: () => PortableTextMemberSchemaTypes
1314
580
  keyGenerator: () => string
1315
581
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
582
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
1316
583
  schema: EditorSchema
1317
584
  initialReadOnly: boolean
1318
585
  maxBlocks: number | undefined
@@ -1326,6 +593,7 @@ declare const editorMachine: StateMachine<
1326
593
  },
1327
594
  | InternalPatchEvent
1328
595
  | MutationEvent
596
+ | PatchesEvent
1329
597
  | {
1330
598
  type: 'add behavior'
1331
599
  behavior: Behavior
@@ -1358,7 +626,6 @@ declare const editorMachine: StateMachine<
1358
626
  type: 'update maxBlocks'
1359
627
  maxBlocks: number | undefined
1360
628
  }
1361
- | PatchesEvent
1362
629
  | {
1363
630
  type: 'blur'
1364
631
  editor: PortableTextSlateEditor
@@ -1374,7 +641,10 @@ declare const editorMachine: StateMachine<
1374
641
  type: 'done normalizing'
1375
642
  }
1376
643
  | {
1377
- type: 'done syncing initial value'
644
+ type: 'done syncing value'
645
+ }
646
+ | {
647
+ type: 'syncing value'
1378
648
  }
1379
649
  | {
1380
650
  type: 'behavior event'
@@ -1502,6 +772,18 @@ declare const editorMachine: StateMachine<
1502
772
  type: 'clear pending events'
1503
773
  params: NonReducibleUnknown
1504
774
  }
775
+ 'defer incoming patches': {
776
+ type: 'defer incoming patches'
777
+ params: NonReducibleUnknown
778
+ }
779
+ 'emit pending incoming patches': {
780
+ type: 'emit pending incoming patches'
781
+ params: NonReducibleUnknown
782
+ }
783
+ 'clear pending incoming patches': {
784
+ type: 'clear pending incoming patches'
785
+ params: NonReducibleUnknown
786
+ }
1505
787
  'handle blur': {
1506
788
  type: 'handle blur'
1507
789
  params: unknown
@@ -1535,10 +817,16 @@ declare const editorMachine: StateMachine<
1535
817
  }
1536
818
  'setup':
1537
819
  | 'setting up'
1538
- | 'dirty'
1539
820
  | {
1540
- pristine: 'normalizing' | 'idle'
1541
- }
821
+ 'set up': {
822
+ 'value sync': 'syncing value' | 'idle'
823
+ 'writing':
824
+ | 'dirty'
825
+ | {
826
+ pristine: 'normalizing' | 'idle'
827
+ }
828
+ }
829
+ }
1542
830
  },
1543
831
  'dragging internally',
1544
832
  {
@@ -1645,6 +933,7 @@ declare const editorMachine: StateMachine<
1645
933
  getLegacySchema: () => PortableTextMemberSchemaTypes
1646
934
  keyGenerator: () => string
1647
935
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
936
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
1648
937
  schema: EditorSchema
1649
938
  initialReadOnly: boolean
1650
939
  maxBlocks: number | undefined
@@ -1658,6 +947,7 @@ declare const editorMachine: StateMachine<
1658
947
  },
1659
948
  | InternalPatchEvent
1660
949
  | MutationEvent
950
+ | PatchesEvent
1661
951
  | {
1662
952
  type: 'add behavior'
1663
953
  behavior: Behavior
@@ -1690,7 +980,6 @@ declare const editorMachine: StateMachine<
1690
980
  type: 'update maxBlocks'
1691
981
  maxBlocks: number | undefined
1692
982
  }
1693
- | PatchesEvent
1694
983
  | {
1695
984
  type: 'blur'
1696
985
  editor: PortableTextSlateEditor
@@ -1706,7 +995,10 @@ declare const editorMachine: StateMachine<
1706
995
  type: 'done normalizing'
1707
996
  }
1708
997
  | {
1709
- type: 'done syncing initial value'
998
+ type: 'done syncing value'
999
+ }
1000
+ | {
1001
+ type: 'syncing value'
1710
1002
  }
1711
1003
  | {
1712
1004
  type: 'behavior event'
@@ -1792,6 +1084,7 @@ declare const editorMachine: StateMachine<
1792
1084
  >,
1793
1085
  | InternalPatchEvent
1794
1086
  | MutationEvent
1087
+ | PatchesEvent
1795
1088
  | {
1796
1089
  type: 'add behavior'
1797
1090
  behavior: Behavior
@@ -1824,7 +1117,6 @@ declare const editorMachine: StateMachine<
1824
1117
  type: 'update maxBlocks'
1825
1118
  maxBlocks: number | undefined
1826
1119
  }
1827
- | PatchesEvent
1828
1120
  | {
1829
1121
  type: 'blur'
1830
1122
  editor: PortableTextSlateEditor
@@ -1840,7 +1132,10 @@ declare const editorMachine: StateMachine<
1840
1132
  type: 'done normalizing'
1841
1133
  }
1842
1134
  | {
1843
- type: 'done syncing initial value'
1135
+ type: 'done syncing value'
1136
+ }
1137
+ | {
1138
+ type: 'syncing value'
1844
1139
  }
1845
1140
  | {
1846
1141
  type: 'behavior event'
@@ -1925,6 +1220,7 @@ declare const editorMachine: StateMachine<
1925
1220
  getLegacySchema: () => PortableTextMemberSchemaTypes
1926
1221
  keyGenerator: () => string
1927
1222
  pendingEvents: never[]
1223
+ pendingIncomingPatchesEvents: never[]
1928
1224
  schema: EditorSchema
1929
1225
  selection: null
1930
1226
  initialReadOnly: boolean
@@ -1940,6 +1236,7 @@ declare const editorMachine: StateMachine<
1940
1236
  getLegacySchema: () => PortableTextMemberSchemaTypes
1941
1237
  keyGenerator: () => string
1942
1238
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1239
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
1943
1240
  schema: EditorSchema
1944
1241
  initialReadOnly: boolean
1945
1242
  maxBlocks: number | undefined
@@ -1957,6 +1254,7 @@ declare const editorMachine: StateMachine<
1957
1254
  },
1958
1255
  | InternalPatchEvent
1959
1256
  | MutationEvent
1257
+ | PatchesEvent
1960
1258
  | {
1961
1259
  type: 'add behavior'
1962
1260
  behavior: Behavior
@@ -1989,7 +1287,6 @@ declare const editorMachine: StateMachine<
1989
1287
  type: 'update maxBlocks'
1990
1288
  maxBlocks: number | undefined
1991
1289
  }
1992
- | PatchesEvent
1993
1290
  | {
1994
1291
  type: 'blur'
1995
1292
  editor: PortableTextSlateEditor
@@ -2005,7 +1302,10 @@ declare const editorMachine: StateMachine<
2005
1302
  type: 'done normalizing'
2006
1303
  }
2007
1304
  | {
2008
- type: 'done syncing initial value'
1305
+ type: 'done syncing value'
1306
+ }
1307
+ | {
1308
+ type: 'syncing value'
2009
1309
  }
2010
1310
  | {
2011
1311
  type: 'behavior event'
@@ -2144,6 +1444,7 @@ declare const editorMachine: StateMachine<
2144
1444
  getLegacySchema: () => PortableTextMemberSchemaTypes
2145
1445
  keyGenerator: () => string
2146
1446
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1447
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
2147
1448
  schema: EditorSchema
2148
1449
  initialReadOnly: boolean
2149
1450
  maxBlocks: number | undefined
@@ -2160,6 +1461,7 @@ declare const editorMachine: StateMachine<
2160
1461
  },
2161
1462
  | InternalPatchEvent
2162
1463
  | MutationEvent
1464
+ | PatchesEvent
2163
1465
  | {
2164
1466
  type: 'add behavior'
2165
1467
  behavior: Behavior
@@ -2192,7 +1494,6 @@ declare const editorMachine: StateMachine<
2192
1494
  type: 'update maxBlocks'
2193
1495
  maxBlocks: number | undefined
2194
1496
  }
2195
- | PatchesEvent
2196
1497
  | {
2197
1498
  type: 'blur'
2198
1499
  editor: PortableTextSlateEditor
@@ -2208,7 +1509,10 @@ declare const editorMachine: StateMachine<
2208
1509
  type: 'done normalizing'
2209
1510
  }
2210
1511
  | {
2211
- type: 'done syncing initial value'
1512
+ type: 'done syncing value'
1513
+ }
1514
+ | {
1515
+ type: 'syncing value'
2212
1516
  }
2213
1517
  | {
2214
1518
  type: 'behavior event'
@@ -2347,6 +1651,7 @@ declare const editorMachine: StateMachine<
2347
1651
  getLegacySchema: () => PortableTextMemberSchemaTypes
2348
1652
  keyGenerator: () => string
2349
1653
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1654
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
2350
1655
  schema: EditorSchema
2351
1656
  initialReadOnly: boolean
2352
1657
  maxBlocks: number | undefined
@@ -2366,6 +1671,7 @@ declare const editorMachine: StateMachine<
2366
1671
  },
2367
1672
  | InternalPatchEvent
2368
1673
  | MutationEvent
1674
+ | PatchesEvent
2369
1675
  | {
2370
1676
  type: 'add behavior'
2371
1677
  behavior: Behavior
@@ -2398,7 +1704,6 @@ declare const editorMachine: StateMachine<
2398
1704
  type: 'update maxBlocks'
2399
1705
  maxBlocks: number | undefined
2400
1706
  }
2401
- | PatchesEvent
2402
1707
  | {
2403
1708
  type: 'blur'
2404
1709
  editor: PortableTextSlateEditor
@@ -2414,7 +1719,10 @@ declare const editorMachine: StateMachine<
2414
1719
  type: 'done normalizing'
2415
1720
  }
2416
1721
  | {
2417
- type: 'done syncing initial value'
1722
+ type: 'done syncing value'
1723
+ }
1724
+ | {
1725
+ type: 'syncing value'
2418
1726
  }
2419
1727
  | {
2420
1728
  type: 'behavior event'
@@ -2553,6 +1861,7 @@ declare const editorMachine: StateMachine<
2553
1861
  getLegacySchema: () => PortableTextMemberSchemaTypes
2554
1862
  keyGenerator: () => string
2555
1863
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
1864
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
2556
1865
  schema: EditorSchema
2557
1866
  initialReadOnly: boolean
2558
1867
  maxBlocks: number | undefined
@@ -2571,6 +1880,7 @@ declare const editorMachine: StateMachine<
2571
1880
  },
2572
1881
  | InternalPatchEvent
2573
1882
  | MutationEvent
1883
+ | PatchesEvent
2574
1884
  | {
2575
1885
  type: 'add behavior'
2576
1886
  behavior: Behavior
@@ -2603,7 +1913,6 @@ declare const editorMachine: StateMachine<
2603
1913
  type: 'update maxBlocks'
2604
1914
  maxBlocks: number | undefined
2605
1915
  }
2606
- | PatchesEvent
2607
1916
  | {
2608
1917
  type: 'blur'
2609
1918
  editor: PortableTextSlateEditor
@@ -2619,7 +1928,10 @@ declare const editorMachine: StateMachine<
2619
1928
  type: 'done normalizing'
2620
1929
  }
2621
1930
  | {
2622
- type: 'done syncing initial value'
1931
+ type: 'done syncing value'
1932
+ }
1933
+ | {
1934
+ type: 'syncing value'
2623
1935
  }
2624
1936
  | {
2625
1937
  type: 'behavior event'
@@ -2758,6 +2070,7 @@ declare const editorMachine: StateMachine<
2758
2070
  getLegacySchema: () => PortableTextMemberSchemaTypes
2759
2071
  keyGenerator: () => string
2760
2072
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2073
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
2761
2074
  schema: EditorSchema
2762
2075
  initialReadOnly: boolean
2763
2076
  maxBlocks: number | undefined
@@ -2775,6 +2088,7 @@ declare const editorMachine: StateMachine<
2775
2088
  },
2776
2089
  | InternalPatchEvent
2777
2090
  | MutationEvent
2091
+ | PatchesEvent
2778
2092
  | {
2779
2093
  type: 'add behavior'
2780
2094
  behavior: Behavior
@@ -2807,7 +2121,6 @@ declare const editorMachine: StateMachine<
2807
2121
  type: 'update maxBlocks'
2808
2122
  maxBlocks: number | undefined
2809
2123
  }
2810
- | PatchesEvent
2811
2124
  | {
2812
2125
  type: 'blur'
2813
2126
  editor: PortableTextSlateEditor
@@ -2823,7 +2136,10 @@ declare const editorMachine: StateMachine<
2823
2136
  type: 'done normalizing'
2824
2137
  }
2825
2138
  | {
2826
- type: 'done syncing initial value'
2139
+ type: 'done syncing value'
2140
+ }
2141
+ | {
2142
+ type: 'syncing value'
2827
2143
  }
2828
2144
  | {
2829
2145
  type: 'behavior event'
@@ -2963,6 +2279,7 @@ declare const editorMachine: StateMachine<
2963
2279
  getLegacySchema: () => PortableTextMemberSchemaTypes
2964
2280
  keyGenerator: () => string
2965
2281
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2282
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
2966
2283
  schema: EditorSchema
2967
2284
  initialReadOnly: boolean
2968
2285
  maxBlocks: number | undefined
@@ -2980,6 +2297,7 @@ declare const editorMachine: StateMachine<
2980
2297
  },
2981
2298
  | InternalPatchEvent
2982
2299
  | MutationEvent
2300
+ | PatchesEvent
2983
2301
  | {
2984
2302
  type: 'add behavior'
2985
2303
  behavior: Behavior
@@ -3012,7 +2330,6 @@ declare const editorMachine: StateMachine<
3012
2330
  type: 'update maxBlocks'
3013
2331
  maxBlocks: number | undefined
3014
2332
  }
3015
- | PatchesEvent
3016
2333
  | {
3017
2334
  type: 'blur'
3018
2335
  editor: PortableTextSlateEditor
@@ -3028,7 +2345,10 @@ declare const editorMachine: StateMachine<
3028
2345
  type: 'done normalizing'
3029
2346
  }
3030
2347
  | {
3031
- type: 'done syncing initial value'
2348
+ type: 'done syncing value'
2349
+ }
2350
+ | {
2351
+ type: 'syncing value'
3032
2352
  }
3033
2353
  | {
3034
2354
  type: 'behavior event'
@@ -3119,6 +2439,7 @@ declare const editorMachine: StateMachine<
3119
2439
  getLegacySchema: () => PortableTextMemberSchemaTypes
3120
2440
  keyGenerator: () => string
3121
2441
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2442
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
3122
2443
  schema: EditorSchema
3123
2444
  initialReadOnly: boolean
3124
2445
  maxBlocks: number | undefined
@@ -3136,6 +2457,7 @@ declare const editorMachine: StateMachine<
3136
2457
  },
3137
2458
  | InternalPatchEvent
3138
2459
  | MutationEvent
2460
+ | PatchesEvent
3139
2461
  | {
3140
2462
  type: 'add behavior'
3141
2463
  behavior: Behavior
@@ -3168,7 +2490,6 @@ declare const editorMachine: StateMachine<
3168
2490
  type: 'update maxBlocks'
3169
2491
  maxBlocks: number | undefined
3170
2492
  }
3171
- | PatchesEvent
3172
2493
  | {
3173
2494
  type: 'blur'
3174
2495
  editor: PortableTextSlateEditor
@@ -3184,7 +2505,10 @@ declare const editorMachine: StateMachine<
3184
2505
  type: 'done normalizing'
3185
2506
  }
3186
2507
  | {
3187
- type: 'done syncing initial value'
2508
+ type: 'done syncing value'
2509
+ }
2510
+ | {
2511
+ type: 'syncing value'
3188
2512
  }
3189
2513
  | {
3190
2514
  type: 'behavior event'
@@ -3324,6 +2648,7 @@ declare const editorMachine: StateMachine<
3324
2648
  getLegacySchema: () => PortableTextMemberSchemaTypes
3325
2649
  keyGenerator: () => string
3326
2650
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2651
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
3327
2652
  schema: EditorSchema
3328
2653
  initialReadOnly: boolean
3329
2654
  maxBlocks: number | undefined
@@ -3341,6 +2666,7 @@ declare const editorMachine: StateMachine<
3341
2666
  },
3342
2667
  | InternalPatchEvent
3343
2668
  | MutationEvent
2669
+ | PatchesEvent
3344
2670
  | {
3345
2671
  type: 'add behavior'
3346
2672
  behavior: Behavior
@@ -3373,7 +2699,6 @@ declare const editorMachine: StateMachine<
3373
2699
  type: 'update maxBlocks'
3374
2700
  maxBlocks: number | undefined
3375
2701
  }
3376
- | PatchesEvent
3377
2702
  | {
3378
2703
  type: 'blur'
3379
2704
  editor: PortableTextSlateEditor
@@ -3389,7 +2714,10 @@ declare const editorMachine: StateMachine<
3389
2714
  type: 'done normalizing'
3390
2715
  }
3391
2716
  | {
3392
- type: 'done syncing initial value'
2717
+ type: 'done syncing value'
2718
+ }
2719
+ | {
2720
+ type: 'syncing value'
3393
2721
  }
3394
2722
  | {
3395
2723
  type: 'behavior event'
@@ -3528,6 +2856,7 @@ declare const editorMachine: StateMachine<
3528
2856
  getLegacySchema: () => PortableTextMemberSchemaTypes
3529
2857
  keyGenerator: () => string
3530
2858
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
2859
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
3531
2860
  schema: EditorSchema
3532
2861
  initialReadOnly: boolean
3533
2862
  maxBlocks: number | undefined
@@ -3544,6 +2873,7 @@ declare const editorMachine: StateMachine<
3544
2873
  },
3545
2874
  | InternalPatchEvent
3546
2875
  | MutationEvent
2876
+ | PatchesEvent
3547
2877
  | {
3548
2878
  type: 'add behavior'
3549
2879
  behavior: Behavior
@@ -3576,7 +2906,6 @@ declare const editorMachine: StateMachine<
3576
2906
  type: 'update maxBlocks'
3577
2907
  maxBlocks: number | undefined
3578
2908
  }
3579
- | PatchesEvent
3580
2909
  | {
3581
2910
  type: 'blur'
3582
2911
  editor: PortableTextSlateEditor
@@ -3592,7 +2921,10 @@ declare const editorMachine: StateMachine<
3592
2921
  type: 'done normalizing'
3593
2922
  }
3594
2923
  | {
3595
- type: 'done syncing initial value'
2924
+ type: 'done syncing value'
2925
+ }
2926
+ | {
2927
+ type: 'syncing value'
3596
2928
  }
3597
2929
  | {
3598
2930
  type: 'behavior event'
@@ -3731,6 +3063,7 @@ declare const editorMachine: StateMachine<
3731
3063
  getLegacySchema: () => PortableTextMemberSchemaTypes
3732
3064
  keyGenerator: () => string
3733
3065
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3066
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
3734
3067
  schema: EditorSchema
3735
3068
  initialReadOnly: boolean
3736
3069
  maxBlocks: number | undefined
@@ -3748,6 +3081,7 @@ declare const editorMachine: StateMachine<
3748
3081
  },
3749
3082
  | InternalPatchEvent
3750
3083
  | MutationEvent
3084
+ | PatchesEvent
3751
3085
  | {
3752
3086
  type: 'add behavior'
3753
3087
  behavior: Behavior
@@ -3780,7 +3114,6 @@ declare const editorMachine: StateMachine<
3780
3114
  type: 'update maxBlocks'
3781
3115
  maxBlocks: number | undefined
3782
3116
  }
3783
- | PatchesEvent
3784
3117
  | {
3785
3118
  type: 'blur'
3786
3119
  editor: PortableTextSlateEditor
@@ -3796,7 +3129,10 @@ declare const editorMachine: StateMachine<
3796
3129
  type: 'done normalizing'
3797
3130
  }
3798
3131
  | {
3799
- type: 'done syncing initial value'
3132
+ type: 'done syncing value'
3133
+ }
3134
+ | {
3135
+ type: 'syncing value'
3800
3136
  }
3801
3137
  | {
3802
3138
  type: 'behavior event'
@@ -3933,7 +3269,10 @@ declare const editorMachine: StateMachine<
3933
3269
  readonly 'remove behavior': {
3934
3270
  readonly actions: 'remove behavior from context'
3935
3271
  }
3936
- readonly 'patches': {
3272
+ readonly 'update behaviors': {
3273
+ readonly actions: 'assign behaviors'
3274
+ }
3275
+ readonly 'update key generator': {
3937
3276
  readonly actions: ActionFunction<
3938
3277
  {
3939
3278
  behaviors: Set<Behavior>
@@ -3941,6 +3280,7 @@ declare const editorMachine: StateMachine<
3941
3280
  getLegacySchema: () => PortableTextMemberSchemaTypes
3942
3281
  keyGenerator: () => string
3943
3282
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3283
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
3944
3284
  schema: EditorSchema
3945
3285
  initialReadOnly: boolean
3946
3286
  maxBlocks: number | undefined
@@ -3952,9 +3292,13 @@ declare const editorMachine: StateMachine<
3952
3292
  }
3953
3293
  slateEditor?: PortableTextSlateEditor
3954
3294
  },
3955
- PatchesEvent,
3295
+ {
3296
+ type: 'update key generator'
3297
+ keyGenerator: () => string
3298
+ },
3956
3299
  | InternalPatchEvent
3957
3300
  | MutationEvent
3301
+ | PatchesEvent
3958
3302
  | {
3959
3303
  type: 'add behavior'
3960
3304
  behavior: Behavior
@@ -3987,7 +3331,6 @@ declare const editorMachine: StateMachine<
3987
3331
  type: 'update maxBlocks'
3988
3332
  maxBlocks: number | undefined
3989
3333
  }
3990
- | PatchesEvent
3991
3334
  | {
3992
3335
  type: 'blur'
3993
3336
  editor: PortableTextSlateEditor
@@ -4003,7 +3346,10 @@ declare const editorMachine: StateMachine<
4003
3346
  type: 'done normalizing'
4004
3347
  }
4005
3348
  | {
4006
- type: 'done syncing initial value'
3349
+ type: 'done syncing value'
3350
+ }
3351
+ | {
3352
+ type: 'syncing value'
4007
3353
  }
4008
3354
  | {
4009
3355
  type: 'behavior event'
@@ -4085,59 +3431,13 @@ declare const editorMachine: StateMachine<
4085
3431
  never,
4086
3432
  never,
4087
3433
  never,
4088
- | PatchEvent
4089
- | InternalPatchEvent
4090
- | MutationEvent
4091
- | PatchesEvent
4092
- | {
4093
- type: 'blurred'
4094
- event: FocusEvent_2<HTMLDivElement, Element>
4095
- }
4096
- | {
4097
- type: 'done loading'
4098
- }
4099
- | {
4100
- type: 'editable'
4101
- }
4102
- | {
4103
- type: 'error'
4104
- name: string
4105
- description: string
4106
- data: unknown
4107
- }
4108
- | {
4109
- type: 'focused'
4110
- event: FocusEvent_2<HTMLDivElement, Element>
4111
- }
4112
- | {
4113
- type: 'invalid value'
4114
- resolution: InvalidValueResolution | null
4115
- value: Array<PortableTextBlock> | undefined
4116
- }
4117
- | {
4118
- type: 'loading'
4119
- }
4120
- | {
4121
- type: 'read only'
4122
- }
4123
- | {
4124
- type: 'ready'
4125
- }
4126
- | {
4127
- type: 'selection'
4128
- selection: EditorSelection
4129
- }
4130
- | {
4131
- type: 'value changed'
4132
- value: Array<PortableTextBlock> | undefined
4133
- }
4134
- | UnsetEvent
3434
+ never
4135
3435
  >
4136
3436
  }
4137
- readonly 'update behaviors': {
4138
- readonly actions: 'assign behaviors'
3437
+ readonly 'update schema': {
3438
+ readonly actions: 'assign schema'
4139
3439
  }
4140
- readonly 'update key generator': {
3440
+ readonly 'update value': {
4141
3441
  readonly actions: ActionFunction<
4142
3442
  {
4143
3443
  behaviors: Set<Behavior>
@@ -4145,6 +3445,7 @@ declare const editorMachine: StateMachine<
4145
3445
  getLegacySchema: () => PortableTextMemberSchemaTypes
4146
3446
  keyGenerator: () => string
4147
3447
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3448
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4148
3449
  schema: EditorSchema
4149
3450
  initialReadOnly: boolean
4150
3451
  maxBlocks: number | undefined
@@ -4157,11 +3458,12 @@ declare const editorMachine: StateMachine<
4157
3458
  slateEditor?: PortableTextSlateEditor
4158
3459
  },
4159
3460
  {
4160
- type: 'update key generator'
4161
- keyGenerator: () => string
3461
+ type: 'update value'
3462
+ value: Array<PortableTextBlock> | undefined
4162
3463
  },
4163
3464
  | InternalPatchEvent
4164
3465
  | MutationEvent
3466
+ | PatchesEvent
4165
3467
  | {
4166
3468
  type: 'add behavior'
4167
3469
  behavior: Behavior
@@ -4194,7 +3496,6 @@ declare const editorMachine: StateMachine<
4194
3496
  type: 'update maxBlocks'
4195
3497
  maxBlocks: number | undefined
4196
3498
  }
4197
- | PatchesEvent
4198
3499
  | {
4199
3500
  type: 'blur'
4200
3501
  editor: PortableTextSlateEditor
@@ -4210,7 +3511,10 @@ declare const editorMachine: StateMachine<
4210
3511
  type: 'done normalizing'
4211
3512
  }
4212
3513
  | {
4213
- type: 'done syncing initial value'
3514
+ type: 'done syncing value'
3515
+ }
3516
+ | {
3517
+ type: 'syncing value'
4214
3518
  }
4215
3519
  | {
4216
3520
  type: 'behavior event'
@@ -4295,10 +3599,7 @@ declare const editorMachine: StateMachine<
4295
3599
  never
4296
3600
  >
4297
3601
  }
4298
- readonly 'update schema': {
4299
- readonly actions: 'assign schema'
4300
- }
4301
- readonly 'update value': {
3602
+ readonly 'update maxBlocks': {
4302
3603
  readonly actions: ActionFunction<
4303
3604
  {
4304
3605
  behaviors: Set<Behavior>
@@ -4306,6 +3607,7 @@ declare const editorMachine: StateMachine<
4306
3607
  getLegacySchema: () => PortableTextMemberSchemaTypes
4307
3608
  keyGenerator: () => string
4308
3609
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3610
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4309
3611
  schema: EditorSchema
4310
3612
  initialReadOnly: boolean
4311
3613
  maxBlocks: number | undefined
@@ -4318,11 +3620,12 @@ declare const editorMachine: StateMachine<
4318
3620
  slateEditor?: PortableTextSlateEditor
4319
3621
  },
4320
3622
  {
4321
- type: 'update value'
4322
- value: Array<PortableTextBlock> | undefined
3623
+ type: 'update maxBlocks'
3624
+ maxBlocks: number | undefined
4323
3625
  },
4324
3626
  | InternalPatchEvent
4325
3627
  | MutationEvent
3628
+ | PatchesEvent
4326
3629
  | {
4327
3630
  type: 'add behavior'
4328
3631
  behavior: Behavior
@@ -4355,7 +3658,6 @@ declare const editorMachine: StateMachine<
4355
3658
  type: 'update maxBlocks'
4356
3659
  maxBlocks: number | undefined
4357
3660
  }
4358
- | PatchesEvent
4359
3661
  | {
4360
3662
  type: 'blur'
4361
3663
  editor: PortableTextSlateEditor
@@ -4371,7 +3673,10 @@ declare const editorMachine: StateMachine<
4371
3673
  type: 'done normalizing'
4372
3674
  }
4373
3675
  | {
4374
- type: 'done syncing initial value'
3676
+ type: 'done syncing value'
3677
+ }
3678
+ | {
3679
+ type: 'syncing value'
4375
3680
  }
4376
3681
  | {
4377
3682
  type: 'behavior event'
@@ -4456,210 +3761,53 @@ declare const editorMachine: StateMachine<
4456
3761
  never
4457
3762
  >
4458
3763
  }
4459
- readonly 'update maxBlocks': {
4460
- readonly actions: ActionFunction<
4461
- {
4462
- behaviors: Set<Behavior>
4463
- converters: Set<Converter>
4464
- getLegacySchema: () => PortableTextMemberSchemaTypes
4465
- keyGenerator: () => string
4466
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
4467
- schema: EditorSchema
4468
- initialReadOnly: boolean
4469
- maxBlocks: number | undefined
4470
- selection: EditorSelection
4471
- incomingValue: Array<PortableTextBlock> | undefined
4472
- internalDrag?: {
4473
- ghost?: HTMLElement
4474
- origin: Pick<EventPosition, 'selection'>
4475
- }
4476
- slateEditor?: PortableTextSlateEditor
4477
- },
4478
- {
4479
- type: 'update maxBlocks'
4480
- maxBlocks: number | undefined
4481
- },
4482
- | InternalPatchEvent
4483
- | MutationEvent
4484
- | {
4485
- type: 'add behavior'
4486
- behavior: Behavior
4487
- }
4488
- | {
4489
- type: 'remove behavior'
4490
- behavior: Behavior
4491
- }
4492
- | {
4493
- type: 'update readOnly'
4494
- readOnly: boolean
4495
- }
4496
- | {
4497
- type: 'update schema'
4498
- schema: EditorSchema
4499
- }
4500
- | {
4501
- type: 'update behaviors'
4502
- behaviors: Array<Behavior>
4503
- }
4504
- | {
4505
- type: 'update key generator'
4506
- keyGenerator: () => string
4507
- }
4508
- | {
4509
- type: 'update value'
4510
- value: Array<PortableTextBlock> | undefined
4511
- }
4512
- | {
4513
- type: 'update maxBlocks'
4514
- maxBlocks: number | undefined
4515
- }
4516
- | PatchesEvent
4517
- | {
4518
- type: 'blur'
4519
- editor: PortableTextSlateEditor
4520
- }
4521
- | {
4522
- type: 'focus'
4523
- editor: PortableTextSlateEditor
4524
- }
4525
- | {
4526
- type: 'normalizing'
4527
- }
4528
- | {
4529
- type: 'done normalizing'
4530
- }
4531
- | {
4532
- type: 'done syncing initial value'
4533
- }
4534
- | {
4535
- type: 'behavior event'
4536
- behaviorEvent: BehaviorEvent
4537
- editor: PortableTextSlateEditor
4538
- nativeEvent?: {
4539
- preventDefault: () => void
4540
- }
4541
- }
4542
- | {
4543
- type: 'notify.patch'
4544
- patch: Patch
4545
- }
4546
- | {
4547
- type: 'notify.mutation'
4548
- patches: Array<Patch>
4549
- snapshot: Array<PortableTextBlock> | undefined
4550
- value: Array<PortableTextBlock> | undefined
4551
- }
4552
- | {
4553
- type: 'notify.blurred'
4554
- event: FocusEvent_2<HTMLDivElement, Element>
4555
- }
4556
- | {
4557
- type: 'notify.done loading'
4558
- }
4559
- | {
4560
- type: 'notify.editable'
4561
- }
4562
- | {
4563
- type: 'notify.error'
4564
- name: string
4565
- description: string
4566
- data: unknown
4567
- }
4568
- | {
4569
- type: 'notify.focused'
4570
- event: FocusEvent_2<HTMLDivElement, Element>
4571
- }
4572
- | {
4573
- type: 'notify.invalid value'
4574
- resolution: InvalidValueResolution | null
4575
- value: Array<PortableTextBlock> | undefined
4576
- }
4577
- | {
4578
- type: 'notify.loading'
4579
- }
4580
- | {
4581
- type: 'notify.read only'
4582
- }
4583
- | {
4584
- type: 'notify.ready'
4585
- }
4586
- | {
4587
- type: 'notify.selection'
4588
- selection: EditorSelection
4589
- }
4590
- | {
4591
- type: 'notify.value changed'
4592
- value: Array<PortableTextBlock> | undefined
4593
- }
4594
- | {
4595
- type: 'notify.unset'
4596
- previousValue: Array<PortableTextBlock>
4597
- }
4598
- | {
4599
- type: 'dragstart'
4600
- origin: Pick<EventPosition, 'selection'>
4601
- ghost?: HTMLElement
4602
- }
4603
- | {
4604
- type: 'dragend'
4605
- }
4606
- | {
4607
- type: 'drop'
4608
- },
4609
- undefined,
4610
- never,
4611
- never,
4612
- never,
4613
- never,
4614
- never
4615
- >
4616
- }
4617
- }
4618
- readonly type: 'parallel'
4619
- readonly states: {
4620
- readonly 'edit mode': {
4621
- readonly initial: 'read only'
4622
- readonly states: {
4623
- readonly 'read only': {
4624
- readonly initial: 'determine initial edit mode'
4625
- readonly on: {
4626
- readonly 'behavior event': {
4627
- readonly actions: 'handle behavior event'
4628
- readonly guard: ({
4629
- event,
4630
- }: GuardArgs<
4631
- {
4632
- behaviors: Set<Behavior>
4633
- converters: Set<Converter>
4634
- getLegacySchema: () => PortableTextMemberSchemaTypes
4635
- keyGenerator: () => string
4636
- pendingEvents: Array<InternalPatchEvent | MutationEvent>
4637
- schema: EditorSchema
4638
- initialReadOnly: boolean
4639
- maxBlocks: number | undefined
4640
- selection: EditorSelection
4641
- incomingValue: Array<PortableTextBlock> | undefined
4642
- internalDrag?: {
4643
- ghost?: HTMLElement
4644
- origin: Pick<EventPosition, 'selection'>
4645
- }
4646
- slateEditor?: PortableTextSlateEditor
4647
- },
4648
- {
4649
- type: 'behavior event'
4650
- behaviorEvent: BehaviorEvent
4651
- editor: PortableTextSlateEditor
4652
- nativeEvent?: {
4653
- preventDefault: () => void
4654
- }
4655
- }
4656
- >) => boolean
4657
- }
3764
+ }
3765
+ readonly type: 'parallel'
3766
+ readonly states: {
3767
+ readonly 'edit mode': {
3768
+ readonly initial: 'read only'
3769
+ readonly states: {
3770
+ readonly 'read only': {
3771
+ readonly initial: 'determine initial edit mode'
3772
+ readonly on: {
3773
+ readonly 'behavior event': {
3774
+ readonly actions: 'handle behavior event'
3775
+ readonly guard: ({
3776
+ event,
3777
+ }: GuardArgs<
3778
+ {
3779
+ behaviors: Set<Behavior>
3780
+ converters: Set<Converter>
3781
+ getLegacySchema: () => PortableTextMemberSchemaTypes
3782
+ keyGenerator: () => string
3783
+ pendingEvents: Array<InternalPatchEvent | MutationEvent>
3784
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
3785
+ schema: EditorSchema
3786
+ initialReadOnly: boolean
3787
+ maxBlocks: number | undefined
3788
+ selection: EditorSelection
3789
+ incomingValue: Array<PortableTextBlock> | undefined
3790
+ internalDrag?: {
3791
+ ghost?: HTMLElement
3792
+ origin: Pick<EventPosition, 'selection'>
3793
+ }
3794
+ slateEditor?: PortableTextSlateEditor
3795
+ },
3796
+ {
3797
+ type: 'behavior event'
3798
+ behaviorEvent: BehaviorEvent
3799
+ editor: PortableTextSlateEditor
3800
+ nativeEvent?: {
3801
+ preventDefault: () => void
3802
+ }
3803
+ }
3804
+ >) => boolean
3805
+ }
4658
3806
  }
4659
3807
  readonly states: {
4660
3808
  readonly 'determine initial edit mode': {
4661
3809
  readonly on: {
4662
- readonly 'done syncing initial value': readonly [
3810
+ readonly 'done syncing value': readonly [
4663
3811
  {
4664
3812
  readonly target: '#editor.edit mode.read only.read only'
4665
3813
  readonly guard: ({
@@ -4673,6 +3821,7 @@ declare const editorMachine: StateMachine<
4673
3821
  pendingEvents: Array<
4674
3822
  InternalPatchEvent | MutationEvent
4675
3823
  >
3824
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4676
3825
  schema: EditorSchema
4677
3826
  initialReadOnly: boolean
4678
3827
  maxBlocks: number | undefined
@@ -4685,7 +3834,7 @@ declare const editorMachine: StateMachine<
4685
3834
  slateEditor?: PortableTextSlateEditor
4686
3835
  },
4687
3836
  {
4688
- type: 'done syncing initial value'
3837
+ type: 'done syncing value'
4689
3838
  }
4690
3839
  >) => boolean
4691
3840
  },
@@ -4707,6 +3856,7 @@ declare const editorMachine: StateMachine<
4707
3856
  getLegacySchema: () => PortableTextMemberSchemaTypes
4708
3857
  keyGenerator: () => string
4709
3858
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3859
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4710
3860
  schema: EditorSchema
4711
3861
  initialReadOnly: boolean
4712
3862
  maxBlocks: number | undefined
@@ -4742,6 +3892,7 @@ declare const editorMachine: StateMachine<
4742
3892
  getLegacySchema: () => PortableTextMemberSchemaTypes
4743
3893
  keyGenerator: () => string
4744
3894
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3895
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4745
3896
  schema: EditorSchema
4746
3897
  initialReadOnly: boolean
4747
3898
  maxBlocks: number | undefined
@@ -4777,6 +3928,7 @@ declare const editorMachine: StateMachine<
4777
3928
  getLegacySchema: () => PortableTextMemberSchemaTypes
4778
3929
  keyGenerator: () => string
4779
3930
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
3931
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4780
3932
  schema: EditorSchema
4781
3933
  initialReadOnly: boolean
4782
3934
  maxBlocks: number | undefined
@@ -4794,6 +3946,7 @@ declare const editorMachine: StateMachine<
4794
3946
  },
4795
3947
  | InternalPatchEvent
4796
3948
  | MutationEvent
3949
+ | PatchesEvent
4797
3950
  | {
4798
3951
  type: 'add behavior'
4799
3952
  behavior: Behavior
@@ -4826,7 +3979,6 @@ declare const editorMachine: StateMachine<
4826
3979
  type: 'update maxBlocks'
4827
3980
  maxBlocks: number | undefined
4828
3981
  }
4829
- | PatchesEvent
4830
3982
  | {
4831
3983
  type: 'blur'
4832
3984
  editor: PortableTextSlateEditor
@@ -4842,7 +3994,10 @@ declare const editorMachine: StateMachine<
4842
3994
  type: 'done normalizing'
4843
3995
  }
4844
3996
  | {
4845
- type: 'done syncing initial value'
3997
+ type: 'done syncing value'
3998
+ }
3999
+ | {
4000
+ type: 'syncing value'
4846
4001
  }
4847
4002
  | {
4848
4003
  type: 'behavior event'
@@ -4944,6 +4099,7 @@ declare const editorMachine: StateMachine<
4944
4099
  pendingEvents: Array<
4945
4100
  InternalPatchEvent | MutationEvent
4946
4101
  >
4102
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4947
4103
  schema: EditorSchema
4948
4104
  initialReadOnly: boolean
4949
4105
  maxBlocks: number | undefined
@@ -4962,6 +4118,7 @@ declare const editorMachine: StateMachine<
4962
4118
  },
4963
4119
  | InternalPatchEvent
4964
4120
  | MutationEvent
4121
+ | PatchesEvent
4965
4122
  | {
4966
4123
  type: 'add behavior'
4967
4124
  behavior: Behavior
@@ -4994,7 +4151,6 @@ declare const editorMachine: StateMachine<
4994
4151
  type: 'update maxBlocks'
4995
4152
  maxBlocks: number | undefined
4996
4153
  }
4997
- | PatchesEvent
4998
4154
  | {
4999
4155
  type: 'blur'
5000
4156
  editor: PortableTextSlateEditor
@@ -5010,7 +4166,10 @@ declare const editorMachine: StateMachine<
5010
4166
  type: 'done normalizing'
5011
4167
  }
5012
4168
  | {
5013
- type: 'done syncing initial value'
4169
+ type: 'done syncing value'
4170
+ }
4171
+ | {
4172
+ type: 'syncing value'
5014
4173
  }
5015
4174
  | {
5016
4175
  type: 'behavior event'
@@ -5134,6 +4293,7 @@ declare const editorMachine: StateMachine<
5134
4293
  getLegacySchema: () => PortableTextMemberSchemaTypes
5135
4294
  keyGenerator: () => string
5136
4295
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4296
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
5137
4297
  schema: EditorSchema
5138
4298
  initialReadOnly: boolean
5139
4299
  maxBlocks: number | undefined
@@ -5147,6 +4307,7 @@ declare const editorMachine: StateMachine<
5147
4307
  },
5148
4308
  | InternalPatchEvent
5149
4309
  | MutationEvent
4310
+ | PatchesEvent
5150
4311
  | {
5151
4312
  type: 'add behavior'
5152
4313
  behavior: Behavior
@@ -5179,7 +4340,6 @@ declare const editorMachine: StateMachine<
5179
4340
  type: 'update maxBlocks'
5180
4341
  maxBlocks: number | undefined
5181
4342
  }
5182
- | PatchesEvent
5183
4343
  | {
5184
4344
  type: 'blur'
5185
4345
  editor: PortableTextSlateEditor
@@ -5195,7 +4355,10 @@ declare const editorMachine: StateMachine<
5195
4355
  type: 'done normalizing'
5196
4356
  }
5197
4357
  | {
5198
- type: 'done syncing initial value'
4358
+ type: 'done syncing value'
4359
+ }
4360
+ | {
4361
+ type: 'syncing value'
5199
4362
  }
5200
4363
  | {
5201
4364
  type: 'behavior event'
@@ -5274,6 +4437,7 @@ declare const editorMachine: StateMachine<
5274
4437
  },
5275
4438
  | InternalPatchEvent
5276
4439
  | MutationEvent
4440
+ | PatchesEvent
5277
4441
  | {
5278
4442
  type: 'add behavior'
5279
4443
  behavior: Behavior
@@ -5306,7 +4470,6 @@ declare const editorMachine: StateMachine<
5306
4470
  type: 'update maxBlocks'
5307
4471
  maxBlocks: number | undefined
5308
4472
  }
5309
- | PatchesEvent
5310
4473
  | {
5311
4474
  type: 'blur'
5312
4475
  editor: PortableTextSlateEditor
@@ -5322,7 +4485,10 @@ declare const editorMachine: StateMachine<
5322
4485
  type: 'done normalizing'
5323
4486
  }
5324
4487
  | {
5325
- type: 'done syncing initial value'
4488
+ type: 'done syncing value'
4489
+ }
4490
+ | {
4491
+ type: 'syncing value'
5326
4492
  }
5327
4493
  | {
5328
4494
  type: 'behavior event'
@@ -5407,6 +4573,7 @@ declare const editorMachine: StateMachine<
5407
4573
  getLegacySchema: () => PortableTextMemberSchemaTypes
5408
4574
  keyGenerator: () => string
5409
4575
  pendingEvents: Array<InternalPatchEvent | MutationEvent>
4576
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
5410
4577
  schema: EditorSchema
5411
4578
  initialReadOnly: boolean
5412
4579
  maxBlocks: number | undefined
@@ -5420,6 +4587,7 @@ declare const editorMachine: StateMachine<
5420
4587
  },
5421
4588
  | InternalPatchEvent
5422
4589
  | MutationEvent
4590
+ | PatchesEvent
5423
4591
  | {
5424
4592
  type: 'add behavior'
5425
4593
  behavior: Behavior
@@ -5452,7 +4620,6 @@ declare const editorMachine: StateMachine<
5452
4620
  type: 'update maxBlocks'
5453
4621
  maxBlocks: number | undefined
5454
4622
  }
5455
- | PatchesEvent
5456
4623
  | {
5457
4624
  type: 'blur'
5458
4625
  editor: PortableTextSlateEditor
@@ -5468,7 +4635,10 @@ declare const editorMachine: StateMachine<
5468
4635
  type: 'done normalizing'
5469
4636
  }
5470
4637
  | {
5471
- type: 'done syncing initial value'
4638
+ type: 'done syncing value'
4639
+ }
4640
+ | {
4641
+ type: 'syncing value'
5472
4642
  }
5473
4643
  | {
5474
4644
  type: 'behavior event'
@@ -5547,6 +4717,7 @@ declare const editorMachine: StateMachine<
5547
4717
  },
5548
4718
  | InternalPatchEvent
5549
4719
  | MutationEvent
4720
+ | PatchesEvent
5550
4721
  | {
5551
4722
  type: 'add behavior'
5552
4723
  behavior: Behavior
@@ -5579,7 +4750,6 @@ declare const editorMachine: StateMachine<
5579
4750
  type: 'update maxBlocks'
5580
4751
  maxBlocks: number | undefined
5581
4752
  }
5582
- | PatchesEvent
5583
4753
  | {
5584
4754
  type: 'blur'
5585
4755
  editor: PortableTextSlateEditor
@@ -5595,7 +4765,10 @@ declare const editorMachine: StateMachine<
5595
4765
  type: 'done normalizing'
5596
4766
  }
5597
4767
  | {
5598
- type: 'done syncing initial value'
4768
+ type: 'done syncing value'
4769
+ }
4770
+ | {
4771
+ type: 'syncing value'
5599
4772
  }
5600
4773
  | {
5601
4774
  type: 'behavior event'
@@ -5698,7 +4871,11 @@ declare const editorMachine: StateMachine<
5698
4871
  readonly initial: 'setting up'
5699
4872
  readonly states: {
5700
4873
  readonly 'setting up': {
5701
- readonly exit: readonly ['emit ready']
4874
+ readonly exit: readonly [
4875
+ 'emit ready',
4876
+ 'emit pending incoming patches',
4877
+ 'clear pending incoming patches',
4878
+ ]
5702
4879
  readonly on: {
5703
4880
  readonly 'internal.patch': {
5704
4881
  readonly actions: 'defer event'
@@ -5706,58 +4883,308 @@ declare const editorMachine: StateMachine<
5706
4883
  readonly 'mutation': {
5707
4884
  readonly actions: 'defer event'
5708
4885
  }
5709
- readonly 'done syncing initial value': {
5710
- readonly target: 'pristine'
4886
+ readonly 'done syncing value': {
4887
+ readonly target: 'set up'
4888
+ }
4889
+ readonly 'patches': {
4890
+ readonly actions: readonly ['defer incoming patches']
5711
4891
  }
5712
4892
  }
5713
4893
  }
5714
- readonly 'pristine': {
5715
- readonly initial: 'idle'
4894
+ readonly 'set up': {
4895
+ readonly type: 'parallel'
5716
4896
  readonly states: {
5717
- readonly idle: {
5718
- readonly on: {
5719
- readonly 'normalizing': {
5720
- readonly target: 'normalizing'
5721
- }
5722
- readonly 'internal.patch': {
5723
- readonly actions: 'defer event'
5724
- readonly target: '#editor.setup.dirty'
4897
+ readonly 'value sync': {
4898
+ readonly initial: 'idle'
4899
+ readonly states: {
4900
+ readonly 'idle': {
4901
+ readonly on: {
4902
+ readonly 'patches': {
4903
+ readonly actions: readonly [
4904
+ ActionFunction<
4905
+ {
4906
+ behaviors: Set<Behavior>
4907
+ converters: Set<Converter>
4908
+ getLegacySchema: () => PortableTextMemberSchemaTypes
4909
+ keyGenerator: () => string
4910
+ pendingEvents: Array<
4911
+ InternalPatchEvent | MutationEvent
4912
+ >
4913
+ pendingIncomingPatchesEvents: Array<PatchesEvent>
4914
+ schema: EditorSchema
4915
+ initialReadOnly: boolean
4916
+ maxBlocks: number | undefined
4917
+ selection: EditorSelection
4918
+ incomingValue:
4919
+ | Array<PortableTextBlock>
4920
+ | undefined
4921
+ internalDrag?: {
4922
+ ghost?: HTMLElement
4923
+ origin: Pick<EventPosition, 'selection'>
4924
+ }
4925
+ slateEditor?: PortableTextSlateEditor
4926
+ },
4927
+ PatchesEvent,
4928
+ | InternalPatchEvent
4929
+ | MutationEvent
4930
+ | PatchesEvent
4931
+ | {
4932
+ type: 'add behavior'
4933
+ behavior: Behavior
4934
+ }
4935
+ | {
4936
+ type: 'remove behavior'
4937
+ behavior: Behavior
4938
+ }
4939
+ | {
4940
+ type: 'update readOnly'
4941
+ readOnly: boolean
4942
+ }
4943
+ | {
4944
+ type: 'update schema'
4945
+ schema: EditorSchema
4946
+ }
4947
+ | {
4948
+ type: 'update behaviors'
4949
+ behaviors: Array<Behavior>
4950
+ }
4951
+ | {
4952
+ type: 'update key generator'
4953
+ keyGenerator: () => string
4954
+ }
4955
+ | {
4956
+ type: 'update value'
4957
+ value: Array<PortableTextBlock> | undefined
4958
+ }
4959
+ | {
4960
+ type: 'update maxBlocks'
4961
+ maxBlocks: number | undefined
4962
+ }
4963
+ | {
4964
+ type: 'blur'
4965
+ editor: PortableTextSlateEditor
4966
+ }
4967
+ | {
4968
+ type: 'focus'
4969
+ editor: PortableTextSlateEditor
4970
+ }
4971
+ | {
4972
+ type: 'normalizing'
4973
+ }
4974
+ | {
4975
+ type: 'done normalizing'
4976
+ }
4977
+ | {
4978
+ type: 'done syncing value'
4979
+ }
4980
+ | {
4981
+ type: 'syncing value'
4982
+ }
4983
+ | {
4984
+ type: 'behavior event'
4985
+ behaviorEvent: BehaviorEvent
4986
+ editor: PortableTextSlateEditor
4987
+ nativeEvent?: {
4988
+ preventDefault: () => void
4989
+ }
4990
+ }
4991
+ | {
4992
+ type: 'notify.patch'
4993
+ patch: Patch
4994
+ }
4995
+ | {
4996
+ type: 'notify.mutation'
4997
+ patches: Array<Patch>
4998
+ snapshot: Array<PortableTextBlock> | undefined
4999
+ value: Array<PortableTextBlock> | undefined
5000
+ }
5001
+ | {
5002
+ type: 'notify.blurred'
5003
+ event: FocusEvent_2<HTMLDivElement, Element>
5004
+ }
5005
+ | {
5006
+ type: 'notify.done loading'
5007
+ }
5008
+ | {
5009
+ type: 'notify.editable'
5010
+ }
5011
+ | {
5012
+ type: 'notify.error'
5013
+ name: string
5014
+ description: string
5015
+ data: unknown
5016
+ }
5017
+ | {
5018
+ type: 'notify.focused'
5019
+ event: FocusEvent_2<HTMLDivElement, Element>
5020
+ }
5021
+ | {
5022
+ type: 'notify.invalid value'
5023
+ resolution: InvalidValueResolution | null
5024
+ value: Array<PortableTextBlock> | undefined
5025
+ }
5026
+ | {
5027
+ type: 'notify.loading'
5028
+ }
5029
+ | {
5030
+ type: 'notify.read only'
5031
+ }
5032
+ | {
5033
+ type: 'notify.ready'
5034
+ }
5035
+ | {
5036
+ type: 'notify.selection'
5037
+ selection: EditorSelection
5038
+ }
5039
+ | {
5040
+ type: 'notify.value changed'
5041
+ value: Array<PortableTextBlock> | undefined
5042
+ }
5043
+ | {
5044
+ type: 'notify.unset'
5045
+ previousValue: Array<PortableTextBlock>
5046
+ }
5047
+ | {
5048
+ type: 'dragstart'
5049
+ origin: Pick<EventPosition, 'selection'>
5050
+ ghost?: HTMLElement
5051
+ }
5052
+ | {
5053
+ type: 'dragend'
5054
+ }
5055
+ | {
5056
+ type: 'drop'
5057
+ },
5058
+ undefined,
5059
+ never,
5060
+ never,
5061
+ never,
5062
+ never,
5063
+ | PatchEvent
5064
+ | InternalPatchEvent
5065
+ | MutationEvent
5066
+ | PatchesEvent
5067
+ | {
5068
+ type: 'blurred'
5069
+ event: FocusEvent_2<HTMLDivElement, Element>
5070
+ }
5071
+ | {
5072
+ type: 'done loading'
5073
+ }
5074
+ | {
5075
+ type: 'editable'
5076
+ }
5077
+ | {
5078
+ type: 'error'
5079
+ name: string
5080
+ description: string
5081
+ data: unknown
5082
+ }
5083
+ | {
5084
+ type: 'focused'
5085
+ event: FocusEvent_2<HTMLDivElement, Element>
5086
+ }
5087
+ | {
5088
+ type: 'invalid value'
5089
+ resolution: InvalidValueResolution | null
5090
+ value: Array<PortableTextBlock> | undefined
5091
+ }
5092
+ | {
5093
+ type: 'loading'
5094
+ }
5095
+ | {
5096
+ type: 'read only'
5097
+ }
5098
+ | {
5099
+ type: 'ready'
5100
+ }
5101
+ | {
5102
+ type: 'selection'
5103
+ selection: EditorSelection
5104
+ }
5105
+ | {
5106
+ type: 'value changed'
5107
+ value: Array<PortableTextBlock> | undefined
5108
+ }
5109
+ | UnsetEvent
5110
+ >,
5111
+ ]
5112
+ }
5113
+ readonly 'syncing value': {
5114
+ readonly target: 'syncing value'
5115
+ }
5116
+ }
5725
5117
  }
5726
- readonly 'mutation': {
5727
- readonly actions: 'defer event'
5728
- readonly target: '#editor.setup.dirty'
5118
+ readonly 'syncing value': {
5119
+ readonly exit: readonly [
5120
+ 'emit pending incoming patches',
5121
+ 'clear pending incoming patches',
5122
+ ]
5123
+ readonly on: {
5124
+ readonly 'patches': {
5125
+ readonly actions: readonly ['defer incoming patches']
5126
+ }
5127
+ readonly 'done syncing value': {
5128
+ readonly target: 'idle'
5129
+ }
5130
+ }
5729
5131
  }
5730
5132
  }
5731
5133
  }
5732
- readonly normalizing: {
5733
- readonly on: {
5734
- readonly 'done normalizing': {
5735
- readonly target: 'idle'
5736
- }
5737
- readonly 'internal.patch': {
5738
- readonly actions: 'defer event'
5134
+ readonly 'writing': {
5135
+ readonly initial: 'pristine'
5136
+ readonly states: {
5137
+ readonly pristine: {
5138
+ readonly initial: 'idle'
5139
+ readonly states: {
5140
+ readonly idle: {
5141
+ readonly on: {
5142
+ readonly 'normalizing': {
5143
+ readonly target: 'normalizing'
5144
+ }
5145
+ readonly 'internal.patch': {
5146
+ readonly actions: 'defer event'
5147
+ readonly target: '#editor.setup.set up.writing.dirty'
5148
+ }
5149
+ readonly 'mutation': {
5150
+ readonly actions: 'defer event'
5151
+ readonly target: '#editor.setup.set up.writing.dirty'
5152
+ }
5153
+ }
5154
+ }
5155
+ readonly normalizing: {
5156
+ readonly on: {
5157
+ readonly 'done normalizing': {
5158
+ readonly target: 'idle'
5159
+ }
5160
+ readonly 'internal.patch': {
5161
+ readonly actions: 'defer event'
5162
+ }
5163
+ readonly 'mutation': {
5164
+ readonly actions: 'defer event'
5165
+ }
5166
+ }
5167
+ }
5168
+ }
5739
5169
  }
5740
- readonly 'mutation': {
5741
- readonly actions: 'defer event'
5170
+ readonly dirty: {
5171
+ readonly entry: readonly [
5172
+ 'emit pending events',
5173
+ 'clear pending events',
5174
+ ]
5175
+ readonly on: {
5176
+ readonly 'internal.patch': {
5177
+ readonly actions: 'emit patch event'
5178
+ }
5179
+ readonly 'mutation': {
5180
+ readonly actions: 'emit mutation event'
5181
+ }
5182
+ }
5742
5183
  }
5743
5184
  }
5744
5185
  }
5745
5186
  }
5746
5187
  }
5747
- readonly 'dirty': {
5748
- readonly entry: readonly [
5749
- 'emit pending events',
5750
- 'clear pending events',
5751
- ]
5752
- readonly on: {
5753
- readonly 'internal.patch': {
5754
- readonly actions: 'emit patch event'
5755
- }
5756
- readonly 'mutation': {
5757
- readonly actions: 'emit mutation event'
5758
- }
5759
- }
5760
- }
5761
5188
  }
5762
5189
  }
5763
5190
  }
@@ -5864,31 +5291,6 @@ declare type EditorSnapshot = {
5864
5291
  }
5865
5292
  }
5866
5293
 
5867
- /** @public */
5868
- declare interface EmailDefinition extends BaseSchemaDefinition {
5869
- type: 'email'
5870
- options?: EmailOptions
5871
- placeholder?: string
5872
- validation?: ValidationBuilder<EmailRule, string>
5873
- initialValue?: InitialValueProperty<any, string>
5874
- }
5875
-
5876
- /** @public */
5877
- declare interface EmailOptions extends BaseSchemaTypeOptions {}
5878
-
5879
- /** @public */
5880
- declare interface EmailRule extends RuleDef<EmailRule, string> {}
5881
-
5882
- /** @public */
5883
- declare interface EmptyProps {}
5884
-
5885
- /** @public */
5886
- declare interface EnumListProps<V = unknown> {
5887
- list?: Array<TitledListValue<V> | V>
5888
- layout?: 'radio' | 'dropdown'
5889
- direction?: 'horizontal' | 'vertical'
5890
- }
5891
-
5892
5294
  declare type EventPosition = {
5893
5295
  block: 'start' | 'end'
5894
5296
  /**
@@ -5902,229 +5304,58 @@ declare type ExtractNamespace<TType extends string> =
5902
5304
  TType extends `${infer Namespace}.${string}` ? Namespace : TType
5903
5305
 
5904
5306
  /**
5905
- * The shape of a field definition. Note, it's recommended to use the
5906
- * `defineField` function instead of using this type directly.
5907
- *
5908
- * Where `defineField` infers the exact field type,
5909
- * FieldDefinition is a compromise union of all types a field can have.
5910
- *
5911
- * A field definition can be a reference to another registered top-level type
5912
- * or a inline type definition.
5913
- *
5914
5307
  * @public
5915
5308
  */
5916
- declare type FieldDefinition<
5917
- TType extends IntrinsicTypeName = IntrinsicTypeName,
5918
- TAlias extends IntrinsicTypeName | undefined = undefined,
5919
- > = (InlineFieldDefinition[TType] | TypeAliasDefinition<string, TAlias>) &
5920
- FieldDefinitionBase
5309
+ export declare const getActiveAnnotations: EditorSelector<
5310
+ Array<PortableTextObject>
5311
+ >
5921
5312
 
5922
- /** @public */
5923
- declare interface FieldDefinitionBase {
5924
- fieldset?: string
5925
- group?: string | string[]
5926
- }
5313
+ /**
5314
+ * @public
5315
+ */
5316
+ export declare const getActiveListItem: EditorSelector<
5317
+ PortableTextListBlock['listItem'] | undefined
5318
+ >
5927
5319
 
5928
- /** @public */
5929
- declare interface FieldGroup {
5930
- name: string
5931
- icon?: ComponentType
5932
- title?: string
5933
- description?: string
5934
- i18n?: I18nTextRecord<'title'>
5935
- hidden?: ConditionalProperty
5936
- default?: boolean
5937
- fields?: ObjectField[]
5938
- }
5320
+ /**
5321
+ * @public
5322
+ */
5323
+ export declare const getActiveStyle: EditorSelector<
5324
+ PortableTextTextBlock['style']
5325
+ >
5939
5326
 
5940
- /** @public */
5941
- declare type FieldGroupDefinition = {
5942
- name: string
5943
- title?: string
5944
- hidden?: ConditionalProperty
5945
- icon?: ComponentType
5946
- default?: boolean
5947
- i18n?: I18nTextRecord<'title'>
5948
- }
5327
+ /**
5328
+ * @public
5329
+ */
5330
+ export declare const getAnchorBlock: EditorSelector<
5331
+ | {
5332
+ node: PortableTextBlock
5333
+ path: [KeyedSegment]
5334
+ }
5335
+ | undefined
5336
+ >
5949
5337
 
5950
5338
  /**
5951
- * Holds a reference to a different field
5952
- * NOTE: Only use this through {@link Rule.valueOfField}
5953
- *
5954
5339
  * @public
5955
5340
  */
5956
- declare interface FieldReference {
5957
- type: symbol
5958
- path: string | string[]
5959
- }
5341
+ export declare const getAnchorChild: EditorSelector<
5342
+ | {
5343
+ node: PortableTextObject | PortableTextSpan
5344
+ path: [KeyedSegment_2, 'children', KeyedSegment_2]
5345
+ }
5346
+ | undefined
5347
+ >
5960
5348
 
5961
- /** @public */
5962
- declare type FieldRules = {
5963
- [fieldKey: string]: SchemaValidationValue
5964
- }
5965
-
5966
- /** @public */
5967
- declare type Fieldset = SingleFieldSet | MultiFieldSet
5968
-
5969
- /** @public */
5970
- declare type FieldsetDefinition = {
5971
- name: string
5972
- title?: string
5973
- description?: string
5974
- group?: string
5975
- hidden?: ConditionalProperty
5976
- readOnly?: ConditionalProperty
5977
- options?: ObjectOptions
5978
- }
5979
-
5980
- /** @public */
5981
- declare interface File_2 {
5982
- [key: string]: unknown
5983
- asset?: Reference
5984
- }
5985
-
5986
- /** @public */
5987
- declare interface FileDefinition
5988
- extends Omit<
5989
- ObjectDefinition,
5990
- 'type' | 'fields' | 'options' | 'groups' | 'validation'
5991
- > {
5992
- type: 'file'
5993
- fields?: ObjectDefinition['fields']
5994
- options?: FileOptions
5995
- validation?: ValidationBuilder<FileRule, FileValue>
5996
- initialValue?: InitialValueProperty<any, FileValue>
5997
- }
5998
-
5999
- /** @public */
6000
- declare interface FileOptions extends ObjectOptions {
6001
- storeOriginalFilename?: boolean
6002
- accept?: string
6003
- sources?: AssetSource[]
6004
- }
6005
-
6006
- /** @public */
6007
- declare interface FileRule extends RuleDef<FileRule, FileValue> {
6008
- /**
6009
- * Require a file field has an asset.
6010
- *
6011
- * @example
6012
- * ```ts
6013
- * defineField({
6014
- * name: 'file',
6015
- * title: 'File',
6016
- * type: 'file',
6017
- * validation: (Rule) => Rule.required().assetRequired(),
6018
- * })
6019
- * ```
6020
- */
6021
- assetRequired(): FileRule
6022
- }
6023
-
6024
- /** @public */
6025
- declare interface FileSchemaType extends Omit<ObjectSchemaType, 'options'> {
6026
- options?: FileOptions
6027
- }
6028
-
6029
- /** @public */
6030
- declare interface FileValue {
6031
- asset?: Reference
6032
- [index: string]: unknown
6033
- }
6034
-
6035
- /** @public */
6036
- declare interface GeopointDefinition extends BaseSchemaDefinition {
6037
- type: 'geopoint'
6038
- options?: GeopointOptions
6039
- validation?: ValidationBuilder<GeopointRule, GeopointValue>
6040
- initialValue?: InitialValueProperty<any, Omit<GeopointValue, '_type'>>
6041
- }
6042
-
6043
- /** @public */
6044
- declare interface GeopointOptions extends BaseSchemaTypeOptions {}
6045
-
6046
- /** @public */
6047
- declare interface GeopointRule extends RuleDef<GeopointRule, GeopointValue> {}
6048
-
6049
- /**
6050
- * Geographical point representing a pair of latitude and longitude coordinates,
6051
- * stored as degrees, in the World Geodetic System 1984 (WGS 84) format. Also
6052
- * includes an optional `alt` property representing the altitude in meters.
6053
- *
6054
- * @public
6055
- */
6056
- declare interface GeopointValue {
6057
- /**
6058
- * Type of the object. Must be `geopoint`.
6059
- */
6060
- _type: 'geopoint'
6061
- /**
6062
- * Latitude in degrees
6063
- */
6064
- lat: number
6065
- /**
6066
- * Longitude in degrees
6067
- */
6068
- lng: number
6069
- /**
6070
- * Altitude in meters
6071
- */
6072
- alt?: number
6073
- }
6074
-
6075
- /**
6076
- * @public
6077
- */
6078
- export declare const getActiveAnnotations: EditorSelector<
6079
- Array<PortableTextObject>
6080
- >
6081
-
6082
- /**
6083
- * @public
6084
- */
6085
- export declare const getActiveListItem: EditorSelector<
6086
- PortableTextListBlock['listItem'] | undefined
6087
- >
6088
-
6089
- /**
6090
- * @public
6091
- */
6092
- export declare const getActiveStyle: EditorSelector<
6093
- PortableTextTextBlock['style']
6094
- >
6095
-
6096
- /**
6097
- * @public
6098
- */
6099
- export declare const getAnchorBlock: EditorSelector<
6100
- | {
6101
- node: PortableTextBlock
6102
- path: [KeyedSegment]
6103
- }
6104
- | undefined
6105
- >
6106
-
6107
- /**
6108
- * @public
6109
- */
6110
- export declare const getAnchorChild: EditorSelector<
6111
- | {
6112
- node: PortableTextObject | PortableTextSpan
6113
- path: [KeyedSegment_2, 'children', KeyedSegment_2]
6114
- }
6115
- | undefined
6116
- >
6117
-
6118
- /**
6119
- * @public
6120
- */
6121
- export declare const getAnchorSpan: EditorSelector<
6122
- | {
6123
- node: PortableTextSpan
6124
- path: [KeyedSegment_2, 'children', KeyedSegment_2]
6125
- }
6126
- | undefined
6127
- >
5349
+ /**
5350
+ * @public
5351
+ */
5352
+ export declare const getAnchorSpan: EditorSelector<
5353
+ | {
5354
+ node: PortableTextSpan
5355
+ path: [KeyedSegment_2, 'children', KeyedSegment_2]
5356
+ }
5357
+ | undefined
5358
+ >
6128
5359
 
6129
5360
  /**
6130
5361
  * @public
@@ -6395,23 +5626,6 @@ export declare const getTrimmedSelection: EditorSelector<EditorSelection>
6395
5626
  */
6396
5627
  export declare const getValue: EditorSelector<Array<PortableTextBlock>>
6397
5628
 
6398
- /** @public */
6399
- declare interface GlobalDocumentReferenceDefinition
6400
- extends BaseSchemaDefinition {
6401
- type: 'globalDocumentReference'
6402
- weak?: boolean
6403
- to: {
6404
- type: string
6405
- title?: string
6406
- icon?: ComponentType
6407
- preview?: PreviewConfig
6408
- }[]
6409
- resourceType: string
6410
- resourceId: string
6411
- options?: ReferenceOptions
6412
- studioUrl?: (document: {id: string; type?: string}) => string | null
6413
- }
6414
-
6415
5629
  declare type HasTag = ReturnType<EditorActor['getSnapshot']>['hasTag']
6416
5630
 
6417
5631
  declare interface History_2 {
@@ -6424,178 +5638,6 @@ declare type HistoryItem = {
6424
5638
  timestamp: Date
6425
5639
  }
6426
5640
 
6427
- /** @public */
6428
- declare interface HotspotOptions {
6429
- previews?: HotspotPreview[]
6430
- }
6431
-
6432
- /** @public */
6433
- declare interface HotspotPreview {
6434
- title: string
6435
- aspectRatio: number
6436
- }
6437
-
6438
- /** @public */
6439
- declare type I18nTextRecord<K extends string> = {
6440
- [P in K]?: {
6441
- key: string
6442
- ns: string
6443
- }
6444
- }
6445
-
6446
- /** @public */
6447
- declare interface ImageAsset extends Asset {
6448
- _type: 'sanity.imageAsset'
6449
- metadata: ImageMetadata
6450
- }
6451
-
6452
- /** @public */
6453
- declare interface ImageCrop {
6454
- _type?: 'sanity.imageCrop'
6455
- left: number
6456
- bottom: number
6457
- right: number
6458
- top: number
6459
- }
6460
-
6461
- /** @public */
6462
- declare interface ImageDefinition
6463
- extends Omit<
6464
- ObjectDefinition,
6465
- 'type' | 'fields' | 'options' | 'groups' | 'validation'
6466
- > {
6467
- type: 'image'
6468
- fields?: FieldDefinition[]
6469
- options?: ImageOptions
6470
- validation?: ValidationBuilder<ImageRule, ImageValue>
6471
- initialValue?: InitialValueProperty<any, ImageValue>
6472
- }
6473
-
6474
- /** @public */
6475
- declare interface ImageDimensions {
6476
- _type: 'sanity.imageDimensions'
6477
- height: number
6478
- width: number
6479
- aspectRatio: number
6480
- }
6481
-
6482
- /** @public */
6483
- declare interface ImageHotspot {
6484
- _type?: 'sanity.imageHotspot'
6485
- width: number
6486
- height: number
6487
- x: number
6488
- y: number
6489
- }
6490
-
6491
- /** @public */
6492
- declare interface ImageMetadata {
6493
- [key: string]: unknown
6494
- _type: 'sanity.imageMetadata'
6495
- dimensions: ImageDimensions
6496
- palette?: ImagePalette
6497
- lqip?: string
6498
- blurHash?: string
6499
- hasAlpha: boolean
6500
- isOpaque: boolean
6501
- }
6502
-
6503
- /** @public */
6504
- declare type ImageMetadataType =
6505
- | 'blurhash'
6506
- | 'lqip'
6507
- | 'palette'
6508
- | 'exif'
6509
- | 'image'
6510
- | 'location'
6511
-
6512
- /** @public */
6513
- declare interface ImageOptions extends FileOptions {
6514
- metadata?: ImageMetadataType[]
6515
- hotspot?: boolean | HotspotOptions
6516
- }
6517
-
6518
- /** @public */
6519
- declare interface ImagePalette {
6520
- _type: 'sanity.imagePalette'
6521
- darkMuted?: ImageSwatch
6522
- darkVibrant?: ImageSwatch
6523
- dominant?: ImageSwatch
6524
- lightMuted?: ImageSwatch
6525
- lightVibrant?: ImageSwatch
6526
- muted?: ImageSwatch
6527
- vibrant?: ImageSwatch
6528
- }
6529
-
6530
- /** @public */
6531
- declare interface ImageRule extends RuleDef<ImageRule, ImageValue> {
6532
- /**
6533
- * Require an image field has an asset.
6534
- *
6535
- * @example
6536
- * ```ts
6537
- * defineField({
6538
- * name: 'image',
6539
- * title: 'Image',
6540
- * type: 'image',
6541
- * validation: (Rule) => Rule.required().assetRequired(),
6542
- * })
6543
- * ```
6544
- */
6545
- assetRequired(): ImageRule
6546
- }
6547
-
6548
- /** @public */
6549
- declare interface ImageSwatch {
6550
- _type: 'sanity.imagePaletteSwatch'
6551
- background: string
6552
- foreground: string
6553
- population: number
6554
- title?: string
6555
- }
6556
-
6557
- /** @public */
6558
- declare interface ImageValue extends FileValue {
6559
- crop?: ImageCrop
6560
- hotspot?: ImageHotspot
6561
- [index: string]: unknown
6562
- }
6563
-
6564
- /** @public */
6565
- declare type IndexTuple = [number | '', number | '']
6566
-
6567
- /** @public */
6568
- declare type InitialValueProperty<Params, Value> =
6569
- | Value
6570
- | InitialValueResolver<Params, Value>
6571
- | undefined
6572
-
6573
- /** @public */
6574
- declare type InitialValueResolver<Params, Value> = (
6575
- params: Params | undefined,
6576
- context: InitialValueResolverContext,
6577
- ) => Promise<Value> | Value
6578
-
6579
- /** @public */
6580
- declare interface InitialValueResolverContext {
6581
- projectId: string
6582
- dataset: string
6583
- schema: Schema
6584
- currentUser: CurrentUser | null
6585
- getClient: (options: {apiVersion: string}) => SanityClient
6586
- }
6587
-
6588
- /** @public */
6589
- declare type InlineFieldDefinition = {
6590
- [K in keyof IntrinsicDefinitions]: Omit<
6591
- IntrinsicDefinitions[K],
6592
- 'initialValue' | 'validation'
6593
- > & {
6594
- validation?: SchemaValidationValue
6595
- initialValue?: InitialValueProperty<any, any>
6596
- }
6597
- }
6598
-
6599
5641
  /**
6600
5642
  * Used to represent native InputEvents that hold a DataTransfer object.
6601
5643
  *
@@ -6614,33 +5656,6 @@ declare type InputBehaviorEvent = {
6614
5656
  }
6615
5657
  }
6616
5658
 
6617
- /** @alpha This API may change */
6618
- declare interface InsertMenuOptions {
6619
- /**
6620
- * @defaultValue `'auto'`
6621
- * `filter: 'auto'` automatically turns on filtering if there are more than 5
6622
- * schema types added to the menu.
6623
- */
6624
- filter?: 'auto' | boolean
6625
- groups?: Array<{
6626
- name: string
6627
- title?: string
6628
- of?: Array<string>
6629
- }>
6630
- /** defaultValue `true` */
6631
- showIcons?: boolean
6632
- /** @defaultValue `[{name: 'list'}]` */
6633
- views?: Array<
6634
- | {
6635
- name: 'list'
6636
- }
6637
- | {
6638
- name: 'grid'
6639
- previewImageUrl?: (schemaTypeName: string) => string | undefined
6640
- }
6641
- >
6642
- }
6643
-
6644
5659
  declare type InsertPlacement = 'auto' | 'after' | 'before'
6645
5660
 
6646
5661
  declare type InternalPatchEvent = NamespaceEvent<PatchEvent, 'internal'> & {
@@ -6648,64 +5663,6 @@ declare type InternalPatchEvent = NamespaceEvent<PatchEvent, 'internal'> & {
6648
5663
  value: Array<PortableTextBlock>
6649
5664
  }
6650
5665
 
6651
- /** @public */
6652
- declare type IntrinsicArrayOfDefinition = {
6653
- [K in keyof IntrinsicDefinitions]: Omit<
6654
- ArrayOfEntry<IntrinsicDefinitions[K]>,
6655
- 'validation' | 'initialValue'
6656
- > & {
6657
- validation?: SchemaValidationValue
6658
- initialValue?: InitialValueProperty<any, any>
6659
- }
6660
- }
6661
-
6662
- /**
6663
- * `IntrinsicDefinitions` is a lookup map for "predefined" schema definitions.
6664
- * Schema types in `IntrinsicDefinitions` will have good type-completion and type-safety in {@link defineType},
6665
- * {@link defineField} and {@link defineArrayMember} once the `type` property is provided.
6666
- *
6667
- * By default, `IntrinsicDefinitions` contains all standard Sanity schema types (`array`, `string`, `number` ect),
6668
- * but it is an interface and as such, open for extension.
6669
- *
6670
- * This type can be extended using declaration merging; this way new entries can be added.
6671
- * See {@link defineType} for examples on how this can be accomplished.
6672
- *
6673
- * @see defineType
6674
- *
6675
- * @public
6676
- */
6677
- declare interface IntrinsicDefinitions {
6678
- array: ArrayDefinition
6679
- block: BlockDefinition
6680
- boolean: BooleanDefinition
6681
- date: DateDefinition
6682
- datetime: DatetimeDefinition
6683
- document: DocumentDefinition
6684
- file: FileDefinition
6685
- geopoint: GeopointDefinition
6686
- image: ImageDefinition
6687
- number: NumberDefinition
6688
- object: ObjectDefinition
6689
- reference: ReferenceDefinition
6690
- crossDatasetReference: CrossDatasetReferenceDefinition
6691
- globalDocumentReference: GlobalDocumentReferenceDefinition
6692
- slug: SlugDefinition
6693
- string: StringDefinition
6694
- text: TextDefinition
6695
- url: UrlDefinition
6696
- email: EmailDefinition
6697
- }
6698
-
6699
- /**
6700
- * A union of all intrinsic types allowed natively in the schema.
6701
- *
6702
- * @see IntrinsicDefinitions
6703
- *
6704
- * @public
6705
- */
6706
- declare type IntrinsicTypeName =
6707
- IntrinsicDefinitions[keyof IntrinsicDefinitions]['type']
6708
-
6709
5666
  /**
6710
5667
  * The editor has invalid data in the value that can be resolved by the user
6711
5668
  * @beta */
@@ -6823,27 +5780,6 @@ declare type KeyboardBehaviorEvent =
6823
5780
  >
6824
5781
  }
6825
5782
 
6826
- /** @public */
6827
- declare type KeyedSegment = {
6828
- _key: string
6829
- }
6830
-
6831
- /**
6832
- * Holds localized validation messages for a given field.
6833
- *
6834
- * @example Custom message for English (US) and Norwegian (Bokmål):
6835
- * ```
6836
- * {
6837
- * 'en-US': 'Needs to start with a capital letter',
6838
- * 'no-NB': 'Må starte med stor bokstav',
6839
- * }
6840
- * ```
6841
- * @public
6842
- */
6843
- declare interface LocalizedValidationMessages {
6844
- [locale: string]: string
6845
- }
6846
-
6847
5783
  declare type MIMEType = `${string}/${string}`
6848
5784
 
6849
5785
  declare type MouseBehaviorEvent = {
@@ -6851,21 +5787,6 @@ declare type MouseBehaviorEvent = {
6851
5787
  position: EventPosition
6852
5788
  }
6853
5789
 
6854
- /** @public */
6855
- declare interface MultiFieldSet {
6856
- name: string
6857
- title?: string
6858
- description?: string
6859
- single?: false
6860
- group?: string | string[]
6861
- options?: CollapseOptions & {
6862
- columns?: number
6863
- }
6864
- fields: ObjectField[]
6865
- hidden?: ConditionalProperty
6866
- readOnly?: ConditionalProperty
6867
- }
6868
-
6869
5790
  /**
6870
5791
  * @public
6871
5792
  */
@@ -6933,114 +5854,10 @@ declare const nativeBehaviorEventTypes: readonly [
6933
5854
  'mouse.click',
6934
5855
  ]
6935
5856
 
6936
- /** @public */
6937
- declare interface NumberDefinition extends BaseSchemaDefinition {
6938
- type: 'number'
6939
- options?: NumberOptions
6940
- placeholder?: string
6941
- validation?: ValidationBuilder<NumberRule, number>
6942
- initialValue?: InitialValueProperty<any, number>
6943
- }
6944
-
6945
- /** @public */
6946
- declare interface NumberOptions
6947
- extends EnumListProps<number>,
6948
- BaseSchemaTypeOptions {}
6949
-
6950
- /** @public */
6951
- declare interface NumberRule extends RuleDef<NumberRule, number> {
6952
- min: (minNumber: number | FieldReference) => NumberRule
6953
- max: (maxNumber: number | FieldReference) => NumberRule
6954
- lessThan: (limit: number | FieldReference) => NumberRule
6955
- greaterThan: (limit: number | FieldReference) => NumberRule
6956
- integer: () => NumberRule
6957
- precision: (limit: number | FieldReference) => NumberRule
6958
- positive: () => NumberRule
6959
- negative: () => NumberRule
6960
- }
6961
-
6962
- /** @public */
6963
- declare interface NumberSchemaType extends BaseSchemaType {
6964
- jsonType: 'number'
6965
- options?: NumberOptions
6966
- initialValue?: InitialValueProperty<any, number>
6967
- }
6968
-
6969
5857
  declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
6970
5858
  _key?: PortableTextObject['_key']
6971
5859
  }
6972
5860
 
6973
- /** @public */
6974
- declare interface ObjectDefinition extends BaseSchemaDefinition {
6975
- type: 'object'
6976
- /**
6977
- * Object must have at least one field. This is validated at Studio startup.
6978
- */
6979
- fields: FieldDefinition[]
6980
- groups?: FieldGroupDefinition[]
6981
- fieldsets?: FieldsetDefinition[]
6982
- preview?: PreviewConfig
6983
- options?: ObjectOptions
6984
- validation?: ValidationBuilder<ObjectRule, Record<string, unknown>>
6985
- initialValue?: InitialValueProperty<any, Record<string, unknown>>
6986
- }
6987
-
6988
- /** @public */
6989
- declare interface ObjectField<T extends SchemaType = SchemaType> {
6990
- name: string
6991
- fieldset?: string
6992
- group?: string | string[]
6993
- type: ObjectFieldType<T>
6994
- }
6995
-
6996
- /** @public */
6997
- declare type ObjectFieldType<T extends SchemaType = SchemaType> = T & {
6998
- hidden?: ConditionalProperty
6999
- readOnly?: ConditionalProperty
7000
- }
7001
-
7002
- /** @public */
7003
- declare interface ObjectOptions extends BaseSchemaTypeOptions {
7004
- collapsible?: boolean
7005
- collapsed?: boolean
7006
- columns?: number
7007
- modal?: {
7008
- type?: 'dialog' | 'popover'
7009
- width?: number | number[] | 'auto'
7010
- }
7011
- }
7012
-
7013
- /** @public */
7014
- declare interface ObjectRule
7015
- extends RuleDef<ObjectRule, Record<string, unknown>> {}
7016
-
7017
- /** @public */
7018
- declare interface ObjectSchemaType extends BaseSchemaType {
7019
- jsonType: 'object'
7020
- fields: ObjectField[]
7021
- groups?: FieldGroup[]
7022
- fieldsets?: Fieldset[]
7023
- initialValue?: InitialValueProperty<any, Record<string, unknown>>
7024
- weak?: boolean
7025
- /** @deprecated Unused. Use the new field-level search config. */
7026
- __experimental_search?: {
7027
- path: (string | number)[]
7028
- weight: number
7029
- mapWith?: string
7030
- }[]
7031
- /** @alpha */
7032
- __experimental_omnisearch_visibility?: boolean
7033
- /** @alpha */
7034
- __experimental_actions?: string[]
7035
- /** @alpha */
7036
- __experimental_formPreviewTitle?: boolean
7037
- /**
7038
- * @beta
7039
- */
7040
- orderings?: SortOrdering[]
7041
- options?: any
7042
- }
7043
-
7044
5861
  /**
7045
5862
  * @public
7046
5863
  */
@@ -7055,12 +5872,6 @@ declare type PatchEvent = {
7055
5872
  patch: Patch
7056
5873
  }
7057
5874
 
7058
- /** @public */
7059
- declare type Path = PathSegment[]
7060
-
7061
- /** @public */
7062
- declare type PathSegment = string | number | KeyedSegment | IndexTuple
7063
-
7064
5875
  /**
7065
5876
  * @internal
7066
5877
  */
@@ -7070,18 +5881,6 @@ declare type PickFromUnion<
7070
5881
  TPickedTags extends TUnion[TTagKey],
7071
5882
  > = TUnion extends Record<TTagKey, TPickedTags> ? TUnion : never
7072
5883
 
7073
- /** @alpha */
7074
- declare type PortableTextBlock = PortableTextTextBlock | PortableTextObject
7075
-
7076
- /** @alpha */
7077
- declare type PortableTextChild = PortableTextObject | PortableTextSpan
7078
-
7079
- /** @alpha */
7080
- declare interface PortableTextListBlock extends PortableTextTextBlock {
7081
- listItem: string
7082
- level: number
7083
- }
7084
-
7085
5884
  /** @beta */
7086
5885
  declare type PortableTextMemberSchemaTypes = {
7087
5886
  annotations: (ObjectSchemaType & {
@@ -7097,13 +5896,6 @@ declare type PortableTextMemberSchemaTypes = {
7097
5896
  lists: BlockListDefinition[]
7098
5897
  }
7099
5898
 
7100
- /** @alpha */
7101
- declare interface PortableTextObject {
7102
- _type: string
7103
- _key: string
7104
- [other: string]: unknown
7105
- }
7106
-
7107
5899
  declare interface PortableTextSlateEditor extends ReactEditor {
7108
5900
  _key: 'editor'
7109
5901
  _type: 'editor'
@@ -7137,162 +5929,6 @@ declare interface PortableTextSlateEditor extends ReactEditor {
7137
5929
  redo: () => void
7138
5930
  }
7139
5931
 
7140
- /** @alpha */
7141
- declare interface PortableTextSpan {
7142
- _key: string
7143
- _type: 'span'
7144
- text: string
7145
- marks?: string[]
7146
- }
7147
-
7148
- /** @alpha */
7149
- declare interface PortableTextTextBlock<
7150
- TChild = PortableTextSpan | PortableTextObject,
7151
- > {
7152
- _type: string
7153
- _key: string
7154
- children: TChild[]
7155
- markDefs?: PortableTextObject[]
7156
- listItem?: string
7157
- style?: string
7158
- level?: number
7159
- }
7160
-
7161
- /** @public */
7162
- declare interface PrepareViewOptions {
7163
- /** @beta */
7164
- ordering?: SortOrdering
7165
- }
7166
-
7167
- /** @public */
7168
- declare interface PreviewConfig<
7169
- Select extends Record<string, string> = Record<string, string>,
7170
- PrepareValue extends Record<keyof Select, any> = Record<keyof Select, any>,
7171
- > {
7172
- select?: Select
7173
- prepare?: (
7174
- value: PrepareValue,
7175
- viewOptions?: PrepareViewOptions,
7176
- ) => PreviewValue
7177
- }
7178
-
7179
- /** @public */
7180
- declare interface PreviewValue {
7181
- _id?: string
7182
- _createdAt?: string
7183
- _updatedAt?: string
7184
- title?: string
7185
- subtitle?: string
7186
- description?: string
7187
- media?: ReactNode | ElementType
7188
- imageUrl?: string
7189
- }
7190
-
7191
- /** @public */
7192
- declare interface Reference {
7193
- _type: string
7194
- _ref: string
7195
- _key?: string
7196
- _weak?: boolean
7197
- _strengthenOnPublish?: {
7198
- type: string
7199
- weak?: boolean
7200
- template?: {
7201
- id: string
7202
- params: Record<string, string | number | boolean>
7203
- }
7204
- }
7205
- }
7206
-
7207
- /** @public */
7208
- declare interface ReferenceBaseOptions extends BaseSchemaTypeOptions {
7209
- disableNew?: boolean
7210
- }
7211
-
7212
- /** @public */
7213
- declare interface ReferenceDefinition extends BaseSchemaDefinition {
7214
- type: 'reference'
7215
- to: ReferenceTo
7216
- weak?: boolean
7217
- options?: ReferenceOptions
7218
- validation?: ValidationBuilder<ReferenceRule, ReferenceValue>
7219
- initialValue?: InitialValueProperty<any, Omit<ReferenceValue, '_type'>>
7220
- }
7221
-
7222
- /** @public */
7223
- declare type ReferenceFilterOptions =
7224
- | ReferenceFilterResolverOptions
7225
- | ReferenceFilterQueryOptions
7226
-
7227
- /** @public */
7228
- declare interface ReferenceFilterQueryOptions {
7229
- filter: string
7230
- filterParams?: Record<string, unknown>
7231
- }
7232
-
7233
- /** @public */
7234
- declare type ReferenceFilterResolver = (
7235
- context: ReferenceFilterResolverContext,
7236
- ) => ReferenceFilterSearchOptions | Promise<ReferenceFilterSearchOptions>
7237
-
7238
- /** @public */
7239
- declare interface ReferenceFilterResolverContext {
7240
- document: SanityDocument
7241
- parent?: Record<string, unknown> | Record<string, unknown>[]
7242
- parentPath: Path
7243
- getClient: (options: {apiVersion: string}) => SanityClient
7244
- }
7245
-
7246
- /** @public */
7247
- declare interface ReferenceFilterResolverOptions {
7248
- filter?: ReferenceFilterResolver
7249
- filterParams?: never
7250
- }
7251
-
7252
- /** @public */
7253
- declare type ReferenceFilterSearchOptions = {
7254
- filter?: string
7255
- params?: Record<string, unknown>
7256
- tag?: string
7257
- maxFieldDepth?: number
7258
- strategy?: SearchStrategy
7259
- perspective?: ClientPerspective
7260
- }
7261
-
7262
- /**
7263
- * Types are closed for extension. To add properties via declaration merging to this type,
7264
- * redeclare and add the properties to the interfaces that make up ReferenceOptions type.
7265
- *
7266
- * @see ReferenceFilterOptions
7267
- * @see ReferenceFilterResolverOptions
7268
- * @see ReferenceBaseOptions
7269
- *
7270
- * @public
7271
- */
7272
- declare type ReferenceOptions = ReferenceBaseOptions & ReferenceFilterOptions
7273
-
7274
- /** @public */
7275
- declare interface ReferenceRule
7276
- extends RuleDef<ReferenceRule, ReferenceValue> {}
7277
-
7278
- /** @public */
7279
- declare interface ReferenceSchemaType
7280
- extends Omit<ObjectSchemaType, 'options'> {
7281
- jsonType: 'object'
7282
- to: ObjectSchemaType[]
7283
- weak?: boolean
7284
- options?: ReferenceOptions
7285
- }
7286
-
7287
- /** @public */
7288
- declare type ReferenceTo =
7289
- | SchemaTypeDefinition
7290
- | TypeReference
7291
- | Array<SchemaTypeDefinition | TypeReference>
7292
-
7293
- /** @public */
7294
- declare type ReferenceValue = Reference
7295
-
7296
5932
  /**************************************
7297
5933
  * Resolve behavior event
7298
5934
  **************************************/
@@ -7318,437 +5954,6 @@ declare type ResolveBehaviorEvent<
7318
5954
  ? PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>
7319
5955
  : never
7320
5956
 
7321
- /** @public */
7322
- declare interface Role {
7323
- name: string
7324
- title: string
7325
- description?: string
7326
- }
7327
-
7328
- /** @public */
7329
- declare interface Rule {
7330
- /**
7331
- * @internal
7332
- * @deprecated internal use only
7333
- */
7334
- _type: RuleTypeConstraint | undefined
7335
- /**
7336
- * @internal
7337
- * @deprecated internal use only
7338
- */
7339
- _level: 'error' | 'warning' | 'info' | undefined
7340
- /**
7341
- * @internal
7342
- * @deprecated internal use only
7343
- */
7344
- _required: 'required' | 'optional' | undefined
7345
- /**
7346
- * @internal
7347
- * @deprecated internal use only
7348
- */
7349
- _typeDef: SchemaType | undefined
7350
- /**
7351
- * @internal
7352
- * @deprecated internal use only
7353
- */
7354
- _message: string | LocalizedValidationMessages | undefined
7355
- /**
7356
- * @internal
7357
- * @deprecated internal use only
7358
- */
7359
- _rules: RuleSpec[]
7360
- /**
7361
- * @internal
7362
- * @deprecated internal use only
7363
- */
7364
- _fieldRules: FieldRules | undefined
7365
- /**
7366
- * Takes in a path and returns an object with a symbol.
7367
- *
7368
- * When the validation lib sees this symbol, it will use the provided path to
7369
- * get a value from the current field's parent and use that value as the input
7370
- * to the Rule.
7371
- *
7372
- * The path that's given is forwarded to `lodash/get`
7373
- *
7374
- * ```js
7375
- * fields: [
7376
- * // ...
7377
- * {
7378
- * // ...
7379
- * name: 'highestTemperature',
7380
- * type: 'number',
7381
- * validation: (Rule) => Rule.positive().min(Rule.valueOfField('lowestTemperature')),
7382
- * // ...
7383
- * },
7384
- * ]
7385
- * ```
7386
- */
7387
- valueOfField: (path: string | string[]) => FieldReference
7388
- error(message?: string | LocalizedValidationMessages): Rule
7389
- warning(message?: string | LocalizedValidationMessages): Rule
7390
- info(message?: string | LocalizedValidationMessages): Rule
7391
- reset(): this
7392
- isRequired(): boolean
7393
- clone(): Rule
7394
- cloneWithRules(rules: RuleSpec[]): Rule
7395
- merge(rule: Rule): Rule
7396
- type(targetType: RuleTypeConstraint | Lowercase<RuleTypeConstraint>): Rule
7397
- all(children: Rule[]): Rule
7398
- either(children: Rule[]): Rule
7399
- optional(): Rule
7400
- required(): Rule
7401
- custom<T = unknown>(
7402
- fn: CustomValidator<T>,
7403
- options?: {
7404
- bypassConcurrencyLimit?: boolean
7405
- },
7406
- ): Rule
7407
- min(len: number | string | FieldReference): Rule
7408
- max(len: number | string | FieldReference): Rule
7409
- length(len: number | FieldReference): Rule
7410
- valid(value: unknown | unknown[]): Rule
7411
- integer(): Rule
7412
- precision(limit: number | FieldReference): Rule
7413
- positive(): Rule
7414
- negative(): Rule
7415
- greaterThan(num: number | FieldReference): Rule
7416
- lessThan(num: number | FieldReference): Rule
7417
- uppercase(): Rule
7418
- lowercase(): Rule
7419
- regex(
7420
- pattern: RegExp,
7421
- name: string,
7422
- options: {
7423
- name?: string
7424
- invert?: boolean
7425
- },
7426
- ): Rule
7427
- regex(
7428
- pattern: RegExp,
7429
- options: {
7430
- name?: string
7431
- invert?: boolean
7432
- },
7433
- ): Rule
7434
- regex(pattern: RegExp, name: string): Rule
7435
- regex(pattern: RegExp): Rule
7436
- email(): Rule
7437
- uri(options?: UriValidationOptions): Rule
7438
- unique(): Rule
7439
- reference(): Rule
7440
- fields(rules: FieldRules): Rule
7441
- assetRequired(): Rule
7442
- validate(
7443
- value: unknown,
7444
- options: ValidationContext & {
7445
- /**
7446
- * @deprecated Internal use only
7447
- * @internal
7448
- */
7449
- __internal?: {
7450
- customValidationConcurrencyLimiter?: {
7451
- ready: () => Promise<void>
7452
- release: () => void
7453
- }
7454
- }
7455
- },
7456
- ): Promise<ValidationMarker[]>
7457
- }
7458
-
7459
- /** @public */
7460
- declare type RuleBuilder<
7461
- T extends RuleDef<T, FieldValue>,
7462
- FieldValue = unknown,
7463
- > = T | T[]
7464
-
7465
- /** @public */
7466
- declare interface RuleDef<T, FieldValue = unknown> {
7467
- required: () => T
7468
- custom: <LenientFieldValue extends FieldValue>(
7469
- fn: CustomValidator<LenientFieldValue | undefined>,
7470
- ) => T
7471
- info: (message?: string | LocalizedValidationMessages) => T
7472
- error: (message?: string | LocalizedValidationMessages) => T
7473
- warning: (message?: string | LocalizedValidationMessages) => T
7474
- valueOfField: (path: string | string[]) => FieldReference
7475
- }
7476
-
7477
- /** @public */
7478
- declare type RuleSpec =
7479
- | {
7480
- flag: 'integer'
7481
- }
7482
- | {
7483
- flag: 'email'
7484
- }
7485
- | {
7486
- flag: 'unique'
7487
- }
7488
- | {
7489
- flag: 'reference'
7490
- }
7491
- | {
7492
- flag: 'type'
7493
- constraint: RuleTypeConstraint
7494
- }
7495
- | {
7496
- flag: 'all'
7497
- constraint: Rule[]
7498
- }
7499
- | {
7500
- flag: 'either'
7501
- constraint: Rule[]
7502
- }
7503
- | {
7504
- flag: 'presence'
7505
- constraint: 'optional' | 'required'
7506
- }
7507
- | {
7508
- flag: 'custom'
7509
- constraint: CustomValidator
7510
- }
7511
- | {
7512
- flag: 'min'
7513
- constraint: number | string
7514
- }
7515
- | {
7516
- flag: 'max'
7517
- constraint: number | string
7518
- }
7519
- | {
7520
- flag: 'length'
7521
- constraint: number
7522
- }
7523
- | {
7524
- flag: 'valid'
7525
- constraint: unknown[]
7526
- }
7527
- | {
7528
- flag: 'precision'
7529
- constraint: number
7530
- }
7531
- | {
7532
- flag: 'lessThan'
7533
- constraint: number
7534
- }
7535
- | {
7536
- flag: 'greaterThan'
7537
- constraint: number
7538
- }
7539
- | {
7540
- flag: 'stringCasing'
7541
- constraint: 'uppercase' | 'lowercase'
7542
- }
7543
- | {
7544
- flag: 'assetRequired'
7545
- constraint: {
7546
- assetType: 'asset' | 'image' | 'file'
7547
- }
7548
- }
7549
- | {
7550
- flag: 'regex'
7551
- constraint: {
7552
- pattern: RegExp
7553
- name?: string
7554
- invert: boolean
7555
- }
7556
- }
7557
- | {
7558
- flag: 'uri'
7559
- constraint: {
7560
- options: {
7561
- scheme: RegExp[]
7562
- allowRelative: boolean
7563
- relativeOnly: boolean
7564
- allowCredentials: boolean
7565
- }
7566
- }
7567
- }
7568
-
7569
- /** @public */
7570
- declare type RuleTypeConstraint =
7571
- | 'Array'
7572
- | 'Boolean'
7573
- | 'Date'
7574
- | 'Number'
7575
- | 'Object'
7576
- | 'String'
7577
-
7578
- /**
7579
- * Options for configuring how Sanity Create interfaces with the type or field.
7580
- *
7581
- * @public
7582
- */
7583
- declare interface SanityCreateOptions {
7584
- /** Set to true to exclude a type or field from appearing in Sanity Create */
7585
- exclude?: boolean
7586
- /**
7587
- * A short description of what the type or field is used for.
7588
- * Purpose can be used to improve how and when content mapping uses the field.
7589
- * */
7590
- purpose?: string
7591
- }
7592
-
7593
- /** @public */
7594
- declare interface SanityDocument {
7595
- _id: string
7596
- _type: string
7597
- _createdAt: string
7598
- _updatedAt: string
7599
- _rev: string
7600
- [key: string]: unknown
7601
- }
7602
-
7603
- /** @public */
7604
- declare interface Schema {
7605
- /** @internal */
7606
- _original?: {
7607
- name: string
7608
- types: SchemaTypeDefinition[]
7609
- }
7610
- /** @internal */
7611
- _registry: {
7612
- [typeName: string]: any
7613
- }
7614
- /** @internal */
7615
- _validation?: SchemaValidationProblemGroup[]
7616
- name: string
7617
- get: (name: string) => SchemaType | undefined
7618
- has: (name: string) => boolean
7619
- getTypeNames: () => string[]
7620
- }
7621
-
7622
- /**
7623
- * Note: you probably want `SchemaTypeDefinition` instead
7624
- * @see SchemaTypeDefinition
7625
- *
7626
- * @public
7627
- */
7628
- declare type SchemaType =
7629
- | ArraySchemaType
7630
- | BooleanSchemaType
7631
- | FileSchemaType
7632
- | NumberSchemaType
7633
- | ObjectSchemaType
7634
- | StringSchemaType
7635
- | ReferenceSchemaType
7636
-
7637
- /**
7638
- * Represents a Sanity schema type definition with an optional type parameter.
7639
- *
7640
- * It's recommend to use the `defineType` helper instead of this type by
7641
- * itself.
7642
- *
7643
- * @see defineType
7644
- *
7645
- * @public
7646
- */
7647
- declare type SchemaTypeDefinition<
7648
- TType extends IntrinsicTypeName = IntrinsicTypeName,
7649
- > = IntrinsicDefinitions[IntrinsicTypeName] | TypeAliasDefinition<string, TType>
7650
-
7651
- /** @public */
7652
- declare interface SchemaValidationError {
7653
- helpId?: string
7654
- message: string
7655
- severity: 'error'
7656
- }
7657
-
7658
- /** @internal */
7659
- declare type SchemaValidationProblem =
7660
- | SchemaValidationError
7661
- | SchemaValidationWarning
7662
-
7663
- /** @internal */
7664
- declare interface SchemaValidationProblemGroup {
7665
- path: SchemaValidationProblemPath
7666
- problems: SchemaValidationProblem[]
7667
- }
7668
-
7669
- /** @internal */
7670
- declare type SchemaValidationProblemPath = Array<
7671
- | {
7672
- kind: 'type'
7673
- type: string
7674
- name?: string
7675
- }
7676
- | {
7677
- kind: 'property'
7678
- name: string
7679
- }
7680
- >
7681
-
7682
- /**
7683
- * Represents the possible values of a schema type's `validation` field.
7684
- *
7685
- * If the schema has not been run through `inferFromSchema` from
7686
- * `sanity/validation` then value could be a function.
7687
- *
7688
- * `inferFromSchema` mutates the schema converts this value to an array of
7689
- * `Rule` instances.
7690
- *
7691
- * @privateRemarks
7692
- *
7693
- * Usage of the schema inside the studio will almost always be from the compiled
7694
- * `createSchema` function. In this case, you can cast the value or throw to
7695
- * narrow the type. E.g.:
7696
- *
7697
- * ```ts
7698
- * if (typeof type.validation === 'function') {
7699
- * throw new Error(
7700
- * `Schema type "${type.name}"'s \`validation\` was not run though \`inferFromSchema\``
7701
- * )
7702
- * }
7703
- * ```
7704
- *
7705
- * @public
7706
- */
7707
- declare type SchemaValidationValue =
7708
- | false
7709
- | undefined
7710
- | Rule
7711
- | SchemaValidationValue[]
7712
- | ((rule: Rule) => SchemaValidationValue)
7713
-
7714
- /** @internal */
7715
- declare interface SchemaValidationWarning {
7716
- helpId?: string
7717
- message: string
7718
- severity: 'warning'
7719
- }
7720
-
7721
- /** @public */
7722
- declare interface SearchConfiguration {
7723
- search?: {
7724
- /**
7725
- * Defines a search weight for this field to prioritize its importance
7726
- * during search operations in the Studio. This setting allows the specified
7727
- * field to be ranked higher in search results compared to other fields.
7728
- *
7729
- * By default, all fields are assigned a weight of 1. However, if a field is
7730
- * chosen as the `title` in the preview configuration's `select` option, it
7731
- * will automatically receive a default weight of 10. Similarly, if selected
7732
- * as the `subtitle`, the default weight is 5. Fields marked as
7733
- * `hidden: true` (no function) are assigned a weight of 0 by default.
7734
- *
7735
- * Note: Search weight configuration is currently supported only for fields
7736
- * of type string or portable text arrays.
7737
- */
7738
- weight?: number
7739
- }
7740
- }
7741
-
7742
- /**
7743
- * @public
7744
- */
7745
- declare const searchStrategies: readonly ['groqLegacy', 'groq2024']
7746
-
7747
- /**
7748
- * @public
7749
- */
7750
- declare type SearchStrategy = (typeof searchStrategies)[number]
7751
-
7752
5957
  declare type Serializer<TMIMEType extends MIMEType> = ({
7753
5958
  snapshot,
7754
5959
  event,
@@ -7761,159 +5966,8 @@ declare type Serializer<TMIMEType extends MIMEType> = ({
7761
5966
  'serialization.success' | 'serialization.failure'
7762
5967
  >
7763
5968
 
7764
- /** @public */
7765
- declare interface SingleFieldSet {
7766
- single: true
7767
- field: ObjectField
7768
- hidden?: ConditionalProperty
7769
- readOnly?: ConditionalProperty
7770
- group?: string | string[]
7771
- }
7772
-
7773
- /** @public */
7774
- declare interface SlugDefinition extends BaseSchemaDefinition {
7775
- type: 'slug'
7776
- options?: SlugOptions
7777
- validation?: ValidationBuilder<SlugRule, SlugValue>
7778
- initialValue?: InitialValueProperty<any, Omit<SlugValue, '_type'>>
7779
- }
7780
-
7781
- /** @public */
7782
- declare type SlugifierFn = (
7783
- source: string,
7784
- schemaType: SlugSchemaType,
7785
- context: SlugSourceContext,
7786
- ) => string | Promise<string>
7787
-
7788
- /** @public */
7789
- declare type SlugIsUniqueValidator = (
7790
- slug: string,
7791
- context: SlugValidationContext,
7792
- ) => boolean | Promise<boolean>
7793
-
7794
- /** @public */
7795
- declare interface SlugOptions
7796
- extends SearchConfiguration,
7797
- BaseSchemaTypeOptions {
7798
- source?: string | Path | SlugSourceFn
7799
- maxLength?: number
7800
- slugify?: SlugifierFn
7801
- isUnique?: SlugIsUniqueValidator
7802
- disableArrayWarning?: boolean
7803
- }
7804
-
7805
- /** @public */
7806
- declare type SlugParent = Record<string, unknown> | Record<string, unknown>[]
7807
-
7808
- /** @public */
7809
- declare interface SlugRule extends RuleDef<SlugRule, SlugValue> {}
7810
-
7811
- /** @public */
7812
- declare interface SlugSchemaType extends ObjectSchemaType {
7813
- jsonType: 'object'
7814
- options?: SlugOptions
7815
- }
7816
-
7817
- /** @public */
7818
- declare interface SlugSourceContext {
7819
- parentPath: Path
7820
- parent: SlugParent
7821
- projectId: string
7822
- dataset: string
7823
- schema: Schema
7824
- currentUser: CurrentUser | null
7825
- getClient: (options: {apiVersion: string}) => SanityClient
7826
- }
7827
-
7828
- /** @public */
7829
- declare type SlugSourceFn = (
7830
- document: SanityDocument,
7831
- context: SlugSourceContext,
7832
- ) => string | Promise<string>
7833
-
7834
- /** @public */
7835
- declare interface SlugValidationContext extends ValidationContext {
7836
- parent: SlugParent
7837
- type: SlugSchemaType
7838
- defaultIsUnique: SlugIsUniqueValidator
7839
- }
7840
-
7841
- /** @public */
7842
- declare interface SlugValue {
7843
- _type: 'slug'
7844
- current?: string
7845
- }
7846
-
7847
- /** @beta */
7848
- declare type SortOrdering = {
7849
- title: string
7850
- i18n?: I18nTextRecord<'title'>
7851
- name: string
7852
- by: SortOrderingItem[]
7853
- }
7854
-
7855
- /** @beta */
7856
- declare interface SortOrderingItem {
7857
- field: string
7858
- direction: 'asc' | 'desc'
7859
- }
7860
-
7861
5969
  declare type StrictExtract<T, U extends T> = U
7862
5970
 
7863
- /** @public */
7864
- declare interface StringDefinition extends BaseSchemaDefinition {
7865
- type: 'string'
7866
- options?: StringOptions
7867
- placeholder?: string
7868
- validation?: ValidationBuilder<StringRule, string>
7869
- initialValue?: InitialValueProperty<any, string>
7870
- }
7871
-
7872
- /** @public */
7873
- declare interface StringOptions
7874
- extends EnumListProps<string>,
7875
- SearchConfiguration,
7876
- BaseSchemaTypeOptions {}
7877
-
7878
- /** @public */
7879
- declare interface StringRule extends RuleDef<StringRule, string> {
7880
- min: (minNumber: number | FieldReference) => StringRule
7881
- max: (maxNumber: number | FieldReference) => StringRule
7882
- length: (exactLength: number | FieldReference) => StringRule
7883
- uppercase: () => StringRule
7884
- lowercase: () => StringRule
7885
- regex(
7886
- pattern: RegExp,
7887
- name: string,
7888
- options: {
7889
- name?: string
7890
- invert?: boolean
7891
- },
7892
- ): StringRule
7893
- regex(
7894
- pattern: RegExp,
7895
- options: {
7896
- name?: string
7897
- invert?: boolean
7898
- },
7899
- ): StringRule
7900
- regex(pattern: RegExp, name: string): StringRule
7901
- regex(pattern: RegExp): StringRule
7902
- email(): StringRule
7903
- }
7904
-
7905
- /**
7906
- * This is used for string, text, date and datetime.
7907
- * This interface represent the compiled version at runtime, when accessed through Schema.
7908
- *
7909
- * @public
7910
- */
7911
- declare interface StringSchemaType extends BaseSchemaType {
7912
- jsonType: 'string'
7913
- options?: StringOptions & TextOptions & DateOptions & DatetimeOptions
7914
- initialValue?: InitialValueProperty<any, string>
7915
- }
7916
-
7917
5971
  /**
7918
5972
  * @beta
7919
5973
  */
@@ -8063,199 +6117,9 @@ declare type TextBlockWithOptionalKey = Omit<PortableTextTextBlock, '_key'> & {
8063
6117
  _key?: PortableTextTextBlock['_key']
8064
6118
  }
8065
6119
 
8066
- /** @public */
8067
- declare interface TextDefinition extends BaseSchemaDefinition {
8068
- type: 'text'
8069
- rows?: number
8070
- options?: TextOptions
8071
- placeholder?: string
8072
- validation?: ValidationBuilder<TextRule, string>
8073
- initialValue?: InitialValueProperty<any, string>
8074
- }
8075
-
8076
- /** @public */
8077
- declare interface TextOptions extends StringOptions {}
8078
-
8079
- /** @public */
8080
- declare interface TextRule extends StringRule {}
8081
-
8082
- /** @public */
8083
- declare interface TitledListValue<V = unknown> {
8084
- _key?: string
8085
- title: string
8086
- value?: V
8087
- }
8088
-
8089
- /**
8090
- * Represents a type definition that is an alias/extension of an existing type
8091
- * in your schema. Creating a type alias will re-register that existing type
8092
- * under a different name. You can also override the default type options with
8093
- * a type alias definition.
8094
- *
8095
- * @public
8096
- */
8097
- declare interface TypeAliasDefinition<
8098
- TType extends string,
8099
- TAlias extends IntrinsicTypeName | undefined,
8100
- > extends BaseSchemaDefinition {
8101
- type: TType
8102
- options?: TAlias extends IntrinsicTypeName
8103
- ? IntrinsicDefinitions[TAlias]['options']
8104
- : unknown
8105
- validation?: SchemaValidationValue
8106
- initialValue?: InitialValueProperty<any, any>
8107
- preview?: PreviewConfig
8108
- components?: {
8109
- annotation?: ComponentType<any>
8110
- block?: ComponentType<any>
8111
- inlineBlock?: ComponentType<any>
8112
- diff?: ComponentType<any>
8113
- field?: ComponentType<any>
8114
- input?: ComponentType<any>
8115
- item?: ComponentType<any>
8116
- preview?: ComponentType<any>
8117
- }
8118
- }
8119
-
8120
- /**
8121
- * Represents a reference to another type registered top-level in your schema.
8122
- *
8123
- * @public
8124
- */
8125
- declare interface TypeReference {
8126
- type: string
8127
- name?: string
8128
- icon?: ComponentType | ReactNode
8129
- options?: {
8130
- [key: string]: unknown
8131
- }
8132
- }
8133
-
8134
6120
  declare type UnsetEvent = {
8135
6121
  type: 'unset'
8136
6122
  previousValue: Array<PortableTextBlock>
8137
6123
  }
8138
6124
 
8139
- /** @public */
8140
- declare interface UriValidationOptions {
8141
- scheme?: (string | RegExp) | Array<string | RegExp>
8142
- allowRelative?: boolean
8143
- relativeOnly?: boolean
8144
- allowCredentials?: boolean
8145
- }
8146
-
8147
- /** @public */
8148
- declare interface UrlDefinition extends BaseSchemaDefinition {
8149
- type: 'url'
8150
- options?: UrlOptions
8151
- placeholder?: string
8152
- validation?: ValidationBuilder<UrlRule, string>
8153
- initialValue?: InitialValueProperty<any, string>
8154
- }
8155
-
8156
- /** @public */
8157
- declare interface UrlOptions extends BaseSchemaTypeOptions {}
8158
-
8159
- /** @public */
8160
- declare interface UrlRule extends RuleDef<UrlRule, string> {
8161
- uri(options: UriValidationOptions): UrlRule
8162
- }
8163
-
8164
- /** @public */
8165
- declare type ValidationBuilder<
8166
- T extends RuleDef<T, FieldValue>,
8167
- FieldValue = unknown,
8168
- > = (rule: T) => RuleBuilder<T, FieldValue>
8169
-
8170
- /**
8171
- * A context object passed around during validation. This includes the
8172
- * `Rule.custom` context.
8173
- *
8174
- * e.g.
8175
- *
8176
- * ```js
8177
- * Rule.custom((_, validationContext) => {
8178
- * // ...
8179
- * })`
8180
- * ```
8181
- *
8182
- * @public
8183
- */
8184
- declare interface ValidationContext {
8185
- getClient: (options: {apiVersion: string}) => SanityClient
8186
- schema: Schema
8187
- parent?: unknown
8188
- type?: SchemaType
8189
- document?: SanityDocument
8190
- path?: Path
8191
- getDocumentExists?: (options: {id: string}) => Promise<boolean>
8192
- environment: 'cli' | 'studio'
8193
- }
8194
-
8195
- /**
8196
- * The shape that can be returned from a custom validator to be converted into
8197
- * a validation marker by the validation logic. Inside of a custom validator,
8198
- * you can return an array of these in order to specify multiple paths within
8199
- * an object or array.
8200
- *
8201
- * @public
8202
- */
8203
- declare interface ValidationError {
8204
- /**
8205
- * The message describing why the value is not valid. This message will be
8206
- * included in the validation markers after validation has finished running.
8207
- */
8208
- message: string
8209
- /**
8210
- * If writing a custom validator, you can return validation messages to
8211
- * specific path inside of the current value (object or array) by populating
8212
- * this `path` prop.
8213
- *
8214
- * NOTE: This path is relative to the current value and _not_ relative to
8215
- * the document.
8216
- */
8217
- path?: Path
8218
- /**
8219
- * Same as `path` but allows more than one value. If provided, the same
8220
- * message will create two markers from each path with the same message
8221
- * provided.
8222
- *
8223
- * @deprecated prefer `path`
8224
- */
8225
- paths?: Path[]
8226
- /**
8227
- * @deprecated Unused. Was used to store the results from `.either()` /`.all()`
8228
- */
8229
- children?: ValidationMarker[]
8230
- /**
8231
- * @deprecated Unused. Was used to signal if this error came from an `.either()`/`.all()`.
8232
- */
8233
- operation?: 'AND' | 'OR'
8234
- /**
8235
- * @deprecated Unused. Was relevant when validation error was used as a class.
8236
- */
8237
- cloneWithMessage?(message: string): ValidationError
8238
- }
8239
-
8240
- /** @public */
8241
- declare interface ValidationMarker {
8242
- level: 'error' | 'warning' | 'info'
8243
- /**
8244
- * The validation message for this marker. E.g. "Must be greater than 0"
8245
- */
8246
- message: string
8247
- /**
8248
- * @deprecated use `message` instead
8249
- */
8250
- item?: ValidationError
8251
- /**
8252
- * The sanity path _relative to the root of the current document_ to this
8253
- * marker.
8254
- *
8255
- * NOTE: Sanity paths may contain keyed segments (i.e. `{_key: string}`) that
8256
- * are not compatible with deep getters like lodash/get
8257
- */
8258
- path: Path
8259
- }
8260
-
8261
6125
  export {}