@portabletext/editor 1.48.7 → 1.48.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs +20 -8
  2. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  3. package/lib/_chunks-cjs/behavior.markdown.cjs +5 -5
  4. package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
  5. package/lib/_chunks-cjs/editor-provider.cjs +121 -90
  6. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  7. package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs +2 -2
  8. package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs.map +1 -1
  9. package/lib/_chunks-cjs/selector.get-text-before.cjs +7 -4
  10. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  11. package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +63 -47
  12. package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +1 -1
  13. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +29 -23
  14. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
  15. package/lib/_chunks-cjs/util.merge-text-blocks.cjs +3 -3
  16. package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
  17. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +15 -15
  18. package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
  19. package/lib/_chunks-cjs/util.slice-blocks.cjs +258 -38
  20. package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
  21. package/lib/_chunks-es/behavior.core.js +21 -10
  22. package/lib/_chunks-es/behavior.core.js.map +1 -1
  23. package/lib/_chunks-es/behavior.markdown.js +5 -6
  24. package/lib/_chunks-es/behavior.markdown.js.map +1 -1
  25. package/lib/_chunks-es/editor-provider.js +75 -46
  26. package/lib/_chunks-es/editor-provider.js.map +1 -1
  27. package/lib/_chunks-es/selector.get-focus-inline-object.js +1 -2
  28. package/lib/_chunks-es/selector.get-focus-inline-object.js.map +1 -1
  29. package/lib/_chunks-es/selector.get-text-before.js +7 -4
  30. package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
  31. package/lib/_chunks-es/selector.is-overlapping-selection.js +61 -46
  32. package/lib/_chunks-es/selector.is-overlapping-selection.js.map +1 -1
  33. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +30 -26
  34. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
  35. package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
  36. package/lib/_chunks-es/util.selection-point-to-block-offset.js +15 -16
  37. package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
  38. package/lib/_chunks-es/util.slice-blocks.js +258 -38
  39. package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
  40. package/lib/behaviors/index.d.cts +2552 -251
  41. package/lib/behaviors/index.d.ts +2552 -251
  42. package/lib/index.cjs +45 -21
  43. package/lib/index.cjs.map +1 -1
  44. package/lib/index.d.cts +2350 -51
  45. package/lib/index.d.ts +2350 -51
  46. package/lib/index.js +44 -21
  47. package/lib/index.js.map +1 -1
  48. package/lib/plugins/index.cjs +16 -7
  49. package/lib/plugins/index.cjs.map +1 -1
  50. package/lib/plugins/index.d.cts +2324 -24
  51. package/lib/plugins/index.d.ts +2324 -24
  52. package/lib/plugins/index.js +16 -7
  53. package/lib/plugins/index.js.map +1 -1
  54. package/lib/selectors/index.cjs +5 -5
  55. package/lib/selectors/index.cjs.map +1 -1
  56. package/lib/selectors/index.d.cts +2321 -28
  57. package/lib/selectors/index.d.ts +2321 -28
  58. package/lib/selectors/index.js +5 -6
  59. package/lib/selectors/index.js.map +1 -1
  60. package/lib/utils/index.cjs +30 -24
  61. package/lib/utils/index.cjs.map +1 -1
  62. package/lib/utils/index.d.cts +2350 -44
  63. package/lib/utils/index.d.ts +2350 -44
  64. package/lib/utils/index.js +30 -24
  65. package/lib/utils/index.js.map +1 -1
  66. package/package.json +1 -2
  67. package/src/behavior-actions/behavior.action.block.unset.ts +1 -1
  68. package/src/behavior-actions/behavior.action.decorator.add.ts +20 -5
  69. package/src/behaviors/behavior.abstract.decorator.ts +1 -1
  70. package/src/behaviors/behavior.abstract.delete.ts +1 -1
  71. package/src/behaviors/behavior.abstract.insert.ts +2 -2
  72. package/src/behaviors/behavior.abstract.select.ts +16 -4
  73. package/src/behaviors/behavior.abstract.split.ts +9 -6
  74. package/src/behaviors/behavior.core.block-objects.ts +5 -5
  75. package/src/behaviors/behavior.core.insert-break.ts +16 -4
  76. package/src/behaviors/behavior.core.lists.ts +4 -6
  77. package/src/behaviors/behavior.decorator-pair.ts +13 -4
  78. package/src/behaviors/behavior.default.ts +1 -1
  79. package/src/behaviors/behavior.markdown.ts +5 -5
  80. package/src/converters/converter.portable-text.ts +1 -1
  81. package/src/converters/converter.text-html.ts +1 -1
  82. package/src/converters/converter.text-plain.ts +4 -4
  83. package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +10 -2
  84. package/src/editor/plugins/createWithSchemaTypes.ts +12 -19
  85. package/src/internal-utils/__tests__/dmpToOperations.test.ts +13 -12
  86. package/src/internal-utils/drag-selection.ts +16 -4
  87. package/src/internal-utils/event-position.ts +20 -8
  88. package/src/internal-utils/parse-blocks.ts +17 -5
  89. package/src/internal-utils/validateValue.ts +6 -6
  90. package/src/plugins/plugin.decorator-shortcut.ts +2 -2
  91. package/src/selectors/selector.get-active-annotations.ts +5 -2
  92. package/src/selectors/selector.get-active-list-item.ts +4 -3
  93. package/src/selectors/selector.get-active-style.ts +4 -3
  94. package/src/selectors/selector.get-anchor-text-block.ts +3 -6
  95. package/src/selectors/selector.get-block-offsets.ts +2 -2
  96. package/src/selectors/selector.get-caret-word-selection.ts +11 -5
  97. package/src/selectors/selector.get-selected-slice.ts +1 -1
  98. package/src/selectors/selector.get-selected-spans.ts +11 -15
  99. package/src/selectors/selector.get-selected-text-blocks.ts +3 -3
  100. package/src/selectors/selector.get-selection-text.ts +3 -3
  101. package/src/selectors/selector.get-text-before.ts +5 -2
  102. package/src/selectors/selector.get-trimmed-selection.ts +20 -14
  103. package/src/selectors/selector.is-active-annotation.ts +4 -2
  104. package/src/selectors/selector.is-active-decorator.test.ts +3 -3
  105. package/src/selectors/selector.is-at-the-end-of-block.ts +4 -1
  106. package/src/selectors/selector.is-at-the-start-of-block.ts +4 -1
  107. package/src/selectors/selector.is-point-after-selection.ts +7 -6
  108. package/src/selectors/selector.is-point-before-selection.ts +7 -6
  109. package/src/selectors/selector.is-selecting-entire-blocks.ts +8 -2
  110. package/src/selectors/selectors.ts +25 -28
  111. package/src/utils/util.block-offset-to-block-selection-point.ts +4 -4
  112. package/src/utils/util.block-offset-to-selection-point.ts +5 -5
  113. package/src/utils/util.block-offset.test.ts +219 -156
  114. package/src/utils/util.block-offset.ts +14 -17
  115. package/src/utils/util.block-offsets-to-selection.ts +5 -5
  116. package/src/utils/util.child-selection-point-to-block-offset.ts +7 -10
  117. package/src/utils/util.get-block-end-point.ts +15 -15
  118. package/src/utils/util.get-block-start-point.ts +13 -12
  119. package/src/utils/util.is-empty-text-block.ts +9 -8
  120. package/src/utils/util.selection-point-to-block-offset.ts +4 -4
  121. package/src/utils/util.slice-blocks.test.ts +178 -121
  122. package/src/utils/util.slice-blocks.ts +25 -24
  123. package/src/utils/util.split-text-block.ts +18 -12
  124. package/lib/_chunks-cjs/parse-blocks.cjs +0 -205
  125. package/lib/_chunks-cjs/parse-blocks.cjs.map +0 -1
  126. package/lib/_chunks-es/parse-blocks.js +0 -206
  127. package/lib/_chunks-es/parse-blocks.js.map +0 -1
  128. package/src/behavior-actions/behavior.guards.ts +0 -24
package/lib/index.d.cts CHANGED
@@ -1,22 +1,8 @@
1
1
  import {Patch} from '@portabletext/patches'
2
- import type {
3
- ArrayDefinition,
4
- ArraySchemaType,
5
- BlockDecoratorDefinition,
6
- BlockListDefinition,
7
- BlockStyleDefinition,
8
- KeyedSegment,
9
- ObjectSchemaType,
10
- Path,
11
- PortableTextListBlock,
12
- PortableTextObject,
13
- TypedObject,
14
- } from '@sanity/types'
2
+ import {ClientPerspective, SanityClient} from '@sanity/client'
15
3
  import {
16
- PortableTextBlock,
17
- PortableTextChild,
18
- PortableTextSpan,
19
- PortableTextTextBlock,
4
+ PortableTextSpan as PortableTextSpan_2,
5
+ PortableTextTextBlock as PortableTextTextBlock_2,
20
6
  } from '@sanity/types'
21
7
  import type {
22
8
  BaseSyntheticEvent,
@@ -28,11 +14,14 @@ import type {
28
14
  } from 'react'
29
15
  import {
30
16
  Component,
17
+ ComponentType,
18
+ ElementType,
31
19
  ForwardRefExoticComponent,
32
20
  JSX,
33
21
  MutableRefObject,
34
22
  PropsWithChildren,
35
23
  default as React_2,
24
+ ReactNode,
36
25
  RefAttributes,
37
26
  TextareaHTMLAttributes,
38
27
  } from 'react'
@@ -254,6 +243,277 @@ export declare type AddedAnnotationPaths = {
254
243
  spanPath: Path
255
244
  }
256
245
 
246
+ /**
247
+ * Types of array actions that can be performed
248
+ * @beta
249
+ */
250
+ declare type ArrayActionName =
251
+ /**
252
+ * Add any item to the array at any position
253
+ */
254
+ | 'add'
255
+ /**
256
+ * Add item after an existing item
257
+ */
258
+ | 'addBefore'
259
+ /**
260
+ * Add item after an existing item
261
+ */
262
+ | 'addAfter'
263
+ /**
264
+ * Remove any item
265
+ */
266
+ | 'remove'
267
+ /**
268
+ * Duplicate item
269
+ */
270
+ | 'duplicate'
271
+ /**
272
+ * Copy item
273
+ */
274
+ | 'copy'
275
+
276
+ /** @public */
277
+ declare interface ArrayDefinition extends BaseSchemaDefinition {
278
+ type: 'array'
279
+ of: ArrayOfType[]
280
+ initialValue?: InitialValueProperty<any, unknown[]>
281
+ validation?: ValidationBuilder<ArrayRule<unknown[]>, unknown[]>
282
+ options?: ArrayOptions
283
+ }
284
+
285
+ /** @public */
286
+ declare type ArrayOfEntry<T> = Omit<T, 'name' | 'hidden'> & {
287
+ name?: string
288
+ }
289
+
290
+ /** @public */
291
+ declare type ArrayOfType<
292
+ TType extends IntrinsicTypeName = IntrinsicTypeName,
293
+ TAlias extends IntrinsicTypeName | undefined = undefined,
294
+ > =
295
+ | IntrinsicArrayOfDefinition[TType]
296
+ | ArrayOfEntry<TypeAliasDefinition<string, TAlias>>
297
+
298
+ /** @public */
299
+ declare interface ArrayOptions<V = unknown>
300
+ extends SearchConfiguration,
301
+ BaseSchemaTypeOptions {
302
+ list?: TitledListValue<V>[] | V[]
303
+ layout?: 'list' | 'tags' | 'grid'
304
+ /** @deprecated This option does not have any effect anymore */
305
+ direction?: 'horizontal' | 'vertical'
306
+ sortable?: boolean
307
+ modal?: {
308
+ type?: 'dialog' | 'popover'
309
+ width?: number | 'auto'
310
+ }
311
+ /** @alpha This API may change */
312
+ insertMenu?: InsertMenuOptions
313
+ /**
314
+ * A boolean flag to enable or disable tree editing for the array.
315
+ * If there are any nested arrays, they will inherit this value.
316
+ * @deprecated tree editing beta feature has been disabled
317
+ */
318
+ treeEditing?: boolean
319
+ /**
320
+ * A list of array actions to disable
321
+ * Possible options are defined by {@link ArrayActionName}
322
+ * @beta
323
+ */
324
+ disableActions?: ArrayActionName[]
325
+ }
326
+
327
+ /** @public */
328
+ declare interface ArrayRule<Value> extends RuleDef<ArrayRule<Value>, Value> {
329
+ min: (length: number | FieldReference) => ArrayRule<Value>
330
+ max: (length: number | FieldReference) => ArrayRule<Value>
331
+ length: (length: number | FieldReference) => ArrayRule<Value>
332
+ unique: () => ArrayRule<Value>
333
+ }
334
+
335
+ /** @public */
336
+ declare interface ArraySchemaType<V = unknown> extends BaseSchemaType {
337
+ jsonType: 'array'
338
+ of: (Exclude<SchemaType, ArraySchemaType> | ReferenceSchemaType)[]
339
+ options?: ArrayOptions<V> & {
340
+ layout?: V extends string ? 'tag' : 'grid'
341
+ }
342
+ }
343
+
344
+ /** @public */
345
+ declare interface Asset extends SanityDocument {
346
+ url: string
347
+ path: string
348
+ assetId: string
349
+ extension: string
350
+ mimeType: string
351
+ sha1hash: string
352
+ size: number
353
+ originalFilename?: string
354
+ label?: string
355
+ title?: string
356
+ description?: string
357
+ creditLine?: string
358
+ source?: AssetSourceSpec
359
+ }
360
+
361
+ /** @public */
362
+ declare type AssetFromSource = {
363
+ kind: 'assetDocumentId' | 'file' | 'base64' | 'url'
364
+ value: string | File_2
365
+ assetDocumentProps?: ImageAsset
366
+ mediaLibraryProps?: {
367
+ mediaLibraryId: string
368
+ assetId: string
369
+ assetInstanceId: string
370
+ }
371
+ }
372
+
373
+ /** @public */
374
+ declare interface AssetSource {
375
+ name: string
376
+ /** @deprecated provide `i18nKey` instead */
377
+ title?: string
378
+ i18nKey?: string
379
+ component: ComponentType<AssetSourceComponentProps>
380
+ icon?: ComponentType<EmptyProps>
381
+ /** @beta */
382
+ uploader?: AssetSourceUploader
383
+ }
384
+
385
+ /** @public */
386
+ declare interface AssetSourceComponentProps {
387
+ action?: 'select' | 'upload'
388
+ assetSource: AssetSource
389
+ assetType?: 'file' | 'image'
390
+ accept: string
391
+ selectionType: 'single'
392
+ dialogHeaderTitle?: React.ReactNode
393
+ selectedAssets: Asset[]
394
+ onClose: () => void
395
+ onSelect: (assetFromSource: AssetFromSource[]) => void
396
+ }
397
+
398
+ /** @public */
399
+ declare interface AssetSourceSpec {
400
+ id: string
401
+ name: string
402
+ url?: string
403
+ }
404
+
405
+ /** @beta */
406
+ declare interface AssetSourceUploader {
407
+ upload(
408
+ files: globalThis.File[],
409
+ options?: {
410
+ /**
411
+ * The schema type of the field the asset is being uploaded to.
412
+ * May be of interest to the uploader to read file and image options.
413
+ */
414
+ schemaType?: SchemaType
415
+ /**
416
+ * The uploader may send patches directly to the field
417
+ * Typed 'unknown' as we don't have patch definitions in sanity/types yet.
418
+ */
419
+ onChange?: (patch: unknown) => void
420
+ },
421
+ ): AssetSourceUploadFile[]
422
+ /**
423
+ * Abort the upload of a file
424
+ */
425
+ abort(file?: AssetSourceUploadFile): void
426
+ /**
427
+ * Get the files that are currently being uploaded
428
+ */
429
+ getFiles(): AssetSourceUploadFile[]
430
+ /**
431
+ * Subscribe to upload events from the uploader
432
+ */
433
+ subscribe(subscriber: (event: AssetSourceUploadEvent) => void): () => void
434
+ /**
435
+ * Update the status of a file. Will be emitted to subscribers.
436
+ */
437
+ updateFile(
438
+ fileId: string,
439
+ data: {
440
+ progress?: number
441
+ status?: string
442
+ error?: Error
443
+ },
444
+ ): void
445
+ /**
446
+ * Reset the uploader (clear files). Should be called by the uploader when all files are done.
447
+ */
448
+ reset(): void
449
+ }
450
+
451
+ /** @beta */
452
+ declare type AssetSourceUploadEvent =
453
+ | AssetSourceUploadEventProgress
454
+ | AssetSourceUploadEventStatus
455
+ | AssetSourceUploadEventAllComplete
456
+ | AssetSourceUploadEventError
457
+ | AssetSourceUploadEventAbort
458
+
459
+ /**
460
+ * Emitted when all files are done, either successfully, aborted or with errors
461
+ * @beta */
462
+ declare type AssetSourceUploadEventAbort = {
463
+ type: 'abort'
464
+ /**
465
+ * Files aborted
466
+ */
467
+ files: AssetSourceUploadFile[]
468
+ }
469
+
470
+ /**
471
+ * Emitted when all files are done, either successfully, aborted or with errors
472
+ * @beta */
473
+ declare type AssetSourceUploadEventAllComplete = {
474
+ type: 'all-complete'
475
+ files: AssetSourceUploadFile[]
476
+ }
477
+
478
+ /**
479
+ * Emitted when all files are done, either successfully, aborted or with errors
480
+ * @beta */
481
+ declare type AssetSourceUploadEventError = {
482
+ type: 'error'
483
+ /**
484
+ * Files errored
485
+ */
486
+ files: AssetSourceUploadFile[]
487
+ }
488
+
489
+ /**
490
+ * Emitted when a file upload is progressing
491
+ * @beta */
492
+ declare type AssetSourceUploadEventProgress = {
493
+ type: 'progress'
494
+ file: AssetSourceUploadFile
495
+ progress: number
496
+ }
497
+
498
+ /**
499
+ * Emitted when a file upload is changing status
500
+ * @beta */
501
+ declare type AssetSourceUploadEventStatus = {
502
+ type: 'status'
503
+ file: AssetSourceUploadFile
504
+ status: AssetSourceUploadFile['status']
505
+ }
506
+
507
+ /** @beta */
508
+ declare interface AssetSourceUploadFile {
509
+ id: string
510
+ file: globalThis.File
511
+ progress: number
512
+ status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted'
513
+ error?: Error
514
+ result?: unknown
515
+ }
516
+
257
517
  /**
258
518
  * @public
259
519
  */
@@ -262,6 +522,60 @@ export declare type BaseDefinition = {
262
522
  title?: string
263
523
  }
264
524
 
525
+ /** @public */
526
+ declare interface BaseSchemaDefinition {
527
+ name: string
528
+ title?: string
529
+ description?: string | React.JSX.Element
530
+ hidden?: ConditionalProperty
531
+ readOnly?: ConditionalProperty
532
+ icon?: ComponentType | ReactNode
533
+ validation?: unknown
534
+ initialValue?: unknown
535
+ deprecated?: DeprecatedProperty
536
+ }
537
+
538
+ /** @public */
539
+ declare interface BaseSchemaType extends Partial<DeprecationConfiguration> {
540
+ name: string
541
+ title?: string
542
+ description?: string
543
+ type?: SchemaType
544
+ liveEdit?: boolean
545
+ readOnly?: ConditionalProperty
546
+ hidden?: ConditionalProperty
547
+ icon?: ComponentType
548
+ initialValue?: InitialValueProperty<any, any>
549
+ validation?: SchemaValidationValue
550
+ preview?: PreviewConfig
551
+ /** @beta */
552
+ components?: {
553
+ block?: ComponentType<any>
554
+ inlineBlock?: ComponentType<any>
555
+ annotation?: ComponentType<any>
556
+ diff?: ComponentType<any>
557
+ field?: ComponentType<any>
558
+ input?: ComponentType<any>
559
+ item?: ComponentType<any>
560
+ preview?: ComponentType<any>
561
+ }
562
+ /**
563
+ * @deprecated This will be removed.
564
+ */
565
+ placeholder?: string
566
+ }
567
+
568
+ /**
569
+ * `BaseOptions` applies to all type options.
570
+ *
571
+ * It can be extended by interface declaration merging in plugins to provide generic options to all types and fields.
572
+ *
573
+ * @public
574
+ * */
575
+ declare interface BaseSchemaTypeOptions {
576
+ sanityCreate?: SanityCreateOptions
577
+ }
578
+
265
579
  /**
266
580
  * @beta
267
581
  */
@@ -375,6 +689,40 @@ export declare interface BlockChildRenderProps {
375
689
  value: PortableTextChild
376
690
  }
377
691
 
692
+ /**
693
+ * Schema definition for text block decorators.
694
+ *
695
+ * @public
696
+ * @example The default set of decorators
697
+ * ```ts
698
+ * {
699
+ * name: 'blockContent',
700
+ * title: 'Content',
701
+ * type: 'array',
702
+ * of: [
703
+ * {
704
+ * type: 'block',
705
+ * marks: {
706
+ * decorators: [
707
+ * {title: 'Strong', value: 'strong'},
708
+ * {title: 'Emphasis', value: 'em'},
709
+ * {title: 'Underline', value: 'underline'},
710
+ * {title: 'Strike', value: 'strike'},
711
+ * {title: 'Code', value: 'code'},
712
+ * ]
713
+ * }
714
+ * }
715
+ * ]
716
+ * }
717
+ * ```
718
+ */
719
+ declare interface BlockDecoratorDefinition {
720
+ title: string
721
+ i18nTitleKey?: string
722
+ value: string
723
+ icon?: ReactNode | ComponentType
724
+ }
725
+
378
726
  /** @beta */
379
727
  export declare interface BlockDecoratorRenderProps {
380
728
  children: ReactElement<any>
@@ -388,6 +736,99 @@ export declare interface BlockDecoratorRenderProps {
388
736
  value: string
389
737
  }
390
738
 
739
+ /**
740
+ * Schema definition for text blocks.
741
+ *
742
+ * @public
743
+ * @example the default block definition
744
+ * ```ts
745
+ * {
746
+ * name: 'blockContent',
747
+ * title: 'Content',
748
+ * type: 'array',
749
+ * of: [
750
+ * {
751
+ * type: 'block',
752
+ * marks: {
753
+ * decorators: [
754
+ * {title: 'Strong', value: 'strong'},
755
+ * {title: 'Emphasis', value: 'em'},
756
+ * {title: 'Underline', value: 'underline'},
757
+ * {title: 'Strike', value: 'strike'},
758
+ * {title: 'Code', value: 'code'},
759
+ * ],
760
+ * annotations: [
761
+ * {
762
+ * type: 'object',
763
+ * name: 'link',
764
+ * fields: [
765
+ * {
766
+ * type: 'string',
767
+ * name: 'href',
768
+ * },
769
+ * ],
770
+ * },
771
+ * ]
772
+ * },
773
+ * styles: [
774
+ * {title: 'Normal', value: 'normal'},
775
+ * {title: 'H1', value: 'h1'},
776
+ * {title: 'H2', value: 'h2'},
777
+ * {title: 'H3', value: 'h3'},
778
+ * {title: 'H4', value: 'h4'},
779
+ * {title: 'H5', value: 'h5'},
780
+ * {title: 'H6', value: 'h6'},
781
+ * {title: 'Quote', value: 'blockquote'}
782
+ * ],
783
+ * lists: [
784
+ * {title: 'Bullet', value: 'bullet'},
785
+ * {title: 'Number', value: 'number'},
786
+ * ],
787
+ * },
788
+ * ]
789
+ * }
790
+ * ```
791
+ */
792
+ declare interface BlockDefinition extends BaseSchemaDefinition {
793
+ type: 'block'
794
+ styles?: BlockStyleDefinition[]
795
+ lists?: BlockListDefinition[]
796
+ marks?: BlockMarksDefinition
797
+ of?: ArrayOfType<'object' | 'reference'>[]
798
+ initialValue?: InitialValueProperty<any, any[]>
799
+ options?: BlockOptions
800
+ validation?: ValidationBuilder<BlockRule, any[]>
801
+ }
802
+
803
+ /**
804
+ * Schema definition for a text block list style.
805
+ *
806
+ * @public
807
+ * @example The defaults lists
808
+ * ```ts
809
+ * {
810
+ * name: 'blockContent',
811
+ * title: 'Content',
812
+ * type: 'array',
813
+ * of: [
814
+ * {
815
+ * type: 'block',
816
+ * lists: [
817
+ * {title: 'Bullet', value: 'bullet'},
818
+ * {title: 'Number', value: 'number'},
819
+ * ]
820
+ * }
821
+ * ]
822
+ * }
823
+ * ```
824
+ */
825
+ declare interface BlockListDefinition {
826
+ title: string
827
+ i18nTitleKey?: string
828
+ value: string
829
+ icon?: ReactNode | ComponentType
830
+ }
831
+
391
832
  /** @beta */
392
833
  export declare interface BlockListItemRenderProps {
393
834
  block: PortableTextTextBlock
@@ -401,6 +842,15 @@ export declare interface BlockListItemRenderProps {
401
842
  value: string
402
843
  }
403
844
 
845
+ /**
846
+ * Schema definition for text block marks (decorators and annotations).
847
+ *
848
+ * @public */
849
+ declare interface BlockMarksDefinition {
850
+ decorators?: BlockDecoratorDefinition[]
851
+ annotations?: ArrayOfType<'object' | 'reference'>[]
852
+ }
853
+
404
854
  /**
405
855
  * @beta
406
856
  */
@@ -409,6 +859,17 @@ export declare type BlockOffset = {
409
859
  offset: number
410
860
  }
411
861
 
862
+ /**
863
+ * Schema options for a Block schema definition
864
+ * @public */
865
+ declare interface BlockOptions extends BaseSchemaTypeOptions {
866
+ /**
867
+ * Turn on or off the builtin browser spellchecking. Default is on.
868
+ */
869
+ spellCheck?: boolean
870
+ unstable_whitespaceOnPasteMode?: 'preserve' | 'normalize' | 'remove'
871
+ }
872
+
412
873
  /** @beta */
413
874
  export declare interface BlockRenderProps {
414
875
  children: ReactElement<any>
@@ -425,6 +886,70 @@ export declare interface BlockRenderProps {
425
886
  value: PortableTextBlock
426
887
  }
427
888
 
889
+ /** @public */
890
+ declare interface BlockRule extends RuleDef<BlockRule, any[]> {}
891
+
892
+ /**
893
+ * Schema definition for a text block style.
894
+ * A text block may have a block style like 'header', 'normal', 'lead'
895
+ * attached to it, which is stored on the `.style` property for that block.
896
+ *
897
+ * @public
898
+ * @remarks The first defined style will become the default style.´´
899
+ * @example The default set of styles
900
+ * ```ts
901
+ * {
902
+ * name: 'blockContent',
903
+ * title: 'Content',
904
+ * type: 'array',
905
+ * of: [
906
+ * {
907
+ * type: 'block',
908
+ * styles: [
909
+ * {title: 'Normal', value: 'normal'},
910
+ * {title: 'H1', value: 'h1'},
911
+ * {title: 'H2', value: 'h2'},
912
+ * {title: 'H3', value: 'h3'},
913
+ * {title: 'H4', value: 'h4'},
914
+ * {title: 'H5', value: 'h5'},
915
+ * {title: 'H6', value: 'h6'},
916
+ * {title: 'Quote', value: 'blockquote'}
917
+ * ]
918
+ * }
919
+ * ]
920
+ * }
921
+ * ```
922
+ * @example Example of defining a block type with custom styles and render components.
923
+ * ```ts
924
+ * defineArrayMember({
925
+ * type: 'block',
926
+ * styles: [
927
+ * {
928
+ * title: 'Paragraph',
929
+ * value: 'paragraph',
930
+ * component: ParagraphStyle,
931
+ * },
932
+ * {
933
+ * title: 'Lead',
934
+ * value: 'lead',
935
+ * component: LeadStyle,
936
+ * },
937
+ * {
938
+ * title: 'Heading',
939
+ * value: 'heading',
940
+ * component: HeadingStyle,
941
+ * },
942
+ * ],
943
+ * })
944
+ * ```
945
+ */
946
+ declare interface BlockStyleDefinition {
947
+ title: string
948
+ value: string
949
+ i18nTitleKey?: string
950
+ icon?: ReactNode | ComponentType
951
+ }
952
+
428
953
  /** @beta */
429
954
  export declare interface BlockStyleRenderProps {
430
955
  block: PortableTextTextBlock
@@ -449,6 +974,29 @@ export declare type BlurChange = {
449
974
  event: FocusEvent_2<HTMLDivElement, Element>
450
975
  }
451
976
 
977
+ /** @public */
978
+ declare interface BooleanDefinition extends BaseSchemaDefinition {
979
+ type: 'boolean'
980
+ options?: BooleanOptions
981
+ initialValue?: InitialValueProperty<any, boolean>
982
+ validation?: ValidationBuilder<BooleanRule, boolean>
983
+ }
984
+
985
+ /** @public */
986
+ declare interface BooleanOptions extends BaseSchemaTypeOptions {
987
+ layout?: 'switch' | 'checkbox'
988
+ }
989
+
990
+ /** @public */
991
+ declare interface BooleanRule extends RuleDef<BooleanRule, boolean> {}
992
+
993
+ /** @public */
994
+ declare interface BooleanSchemaType extends BaseSchemaType {
995
+ jsonType: 'boolean'
996
+ options?: BooleanOptions
997
+ initialValue?: InitialValueProperty<any, boolean>
998
+ }
999
+
452
1000
  declare type ClipboardBehaviorEvent =
453
1001
  | {
454
1002
  type: StrictExtract<NativeBehaviorEventType, 'clipboard.copy'>
@@ -472,6 +1020,35 @@ declare type ClipboardBehaviorEvent =
472
1020
  position: Pick<EventPosition, 'selection'>
473
1021
  }
474
1022
 
1023
+ /** @public */
1024
+ declare interface CollapseOptions {
1025
+ collapsed?: boolean
1026
+ collapsible?: boolean
1027
+ /**
1028
+ * @deprecated Use `collapsible` instead
1029
+ */
1030
+ collapsable?: boolean
1031
+ }
1032
+
1033
+ /** @public */
1034
+ declare type ConditionalProperty =
1035
+ | boolean
1036
+ | ConditionalPropertyCallback
1037
+ | undefined
1038
+
1039
+ /** @public */
1040
+ declare type ConditionalPropertyCallback = (
1041
+ context: ConditionalPropertyCallbackContext,
1042
+ ) => boolean
1043
+
1044
+ /** @public */
1045
+ declare interface ConditionalPropertyCallbackContext {
1046
+ document: SanityDocument | undefined
1047
+ parent: any
1048
+ value: any
1049
+ currentUser: Omit<CurrentUser, 'role'> | null
1050
+ }
1051
+
475
1052
  /**
476
1053
  * The editor was either connected or disconnected to the network
477
1054
  * To show out of sync warnings etc when in collaborative mode.
@@ -519,6 +1096,46 @@ declare type ConverterEvent<TMIMEType extends MIMEType = MIMEType> =
519
1096
  mimeType: TMIMEType
520
1097
  }
521
1098
 
1099
+ /** @public */
1100
+ declare interface CrossDatasetReferenceDefinition extends BaseSchemaDefinition {
1101
+ type: 'crossDatasetReference'
1102
+ weak?: boolean
1103
+ to: {
1104
+ type: string
1105
+ title?: string
1106
+ icon?: ComponentType
1107
+ preview?: PreviewConfig
1108
+ /**
1109
+ * @deprecated Unused. Configuring search is no longer supported.
1110
+ */
1111
+ __experimental_search?: {
1112
+ path: string | string[]
1113
+ weight?: number
1114
+ mapWith?: string
1115
+ }[]
1116
+ }[]
1117
+ dataset: string
1118
+ studioUrl?: (document: {id: string; type?: string}) => string | null
1119
+ tokenId?: string
1120
+ options?: ReferenceOptions
1121
+ /**
1122
+ * @deprecated Cross-project references are no longer supported, only cross-dataset
1123
+ */
1124
+ projectId?: string
1125
+ }
1126
+
1127
+ /** @public */
1128
+ declare interface CurrentUser {
1129
+ id: string
1130
+ name: string
1131
+ email: string
1132
+ profileImage?: string
1133
+ provider?: string
1134
+ /** @deprecated use `roles` instead */
1135
+ role: string
1136
+ roles: Role[]
1137
+ }
1138
+
522
1139
  /**
523
1140
  * @beta
524
1141
  */
@@ -543,6 +1160,77 @@ declare type CustomBehaviorEventType<
543
1160
  TType extends string = '',
544
1161
  > = TType extends '' ? `${TNamespace}` : `${TNamespace}.${TType}`
545
1162
 
1163
+ /** @public */
1164
+ declare interface CustomValidator<T = unknown> {
1165
+ (
1166
+ value: T,
1167
+ context: ValidationContext,
1168
+ ): CustomValidatorResult | Promise<CustomValidatorResult>
1169
+ bypassConcurrencyLimit?: boolean
1170
+ }
1171
+
1172
+ /** @public */
1173
+ declare type CustomValidatorResult =
1174
+ | true
1175
+ | string
1176
+ | ValidationError
1177
+ | ValidationError[]
1178
+ | LocalizedValidationMessages
1179
+
1180
+ /** @public */
1181
+ declare interface DateDefinition extends BaseSchemaDefinition {
1182
+ type: 'date'
1183
+ options?: DateOptions
1184
+ placeholder?: string
1185
+ validation?: ValidationBuilder<DateRule, string>
1186
+ initialValue?: InitialValueProperty<any, string>
1187
+ }
1188
+
1189
+ /** @public */
1190
+ declare interface DateOptions extends BaseSchemaTypeOptions {
1191
+ dateFormat?: string
1192
+ }
1193
+
1194
+ /** @public */
1195
+ declare interface DateRule extends RuleDef<DateRule, string> {
1196
+ /**
1197
+ * @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
1198
+ */
1199
+ min: (minDate: string | FieldReference) => DateRule
1200
+ /**
1201
+ * @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
1202
+ */
1203
+ max: (maxDate: string | FieldReference) => DateRule
1204
+ }
1205
+
1206
+ /** @public */
1207
+ declare interface DatetimeDefinition extends BaseSchemaDefinition {
1208
+ type: 'datetime'
1209
+ options?: DatetimeOptions
1210
+ placeholder?: string
1211
+ validation?: ValidationBuilder<DatetimeRule, string>
1212
+ initialValue?: InitialValueProperty<any, string>
1213
+ }
1214
+
1215
+ /** @public */
1216
+ declare interface DatetimeOptions extends BaseSchemaTypeOptions {
1217
+ dateFormat?: string
1218
+ timeFormat?: string
1219
+ timeStep?: number
1220
+ }
1221
+
1222
+ /** @public */
1223
+ declare interface DatetimeRule extends RuleDef<DatetimeRule, string> {
1224
+ /**
1225
+ * @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
1226
+ */
1227
+ min: (minDate: string | FieldReference) => DatetimeRule
1228
+ /**
1229
+ * @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
1230
+ */
1231
+ max: (maxDate: string | FieldReference) => DatetimeRule
1232
+ }
1233
+
546
1234
  /**
547
1235
  * @public
548
1236
  * A helper wrapper that adds editor support, such as autocomplete and type checking, for a schema definition.
@@ -570,6 +1258,18 @@ export declare function defineSchema<
570
1258
  const TSchemaDefinition extends SchemaDefinition,
571
1259
  >(definition: TSchemaDefinition): TSchemaDefinition
572
1260
 
1261
+ /** @public */
1262
+ declare interface DeprecatedProperty {
1263
+ reason: string
1264
+ }
1265
+
1266
+ /**
1267
+ * @public
1268
+ */
1269
+ declare interface DeprecationConfiguration {
1270
+ deprecated: DeprecatedProperty
1271
+ }
1272
+
573
1273
  declare type Deserializer<TMIMEType extends MIMEType> = ({
574
1274
  snapshot,
575
1275
  event,
@@ -582,8 +1282,42 @@ declare type Deserializer<TMIMEType extends MIMEType> = ({
582
1282
  'deserialization.success' | 'deserialization.failure'
583
1283
  >
584
1284
 
585
- declare type DragBehaviorEvent =
586
- | {
1285
+ /** @public */
1286
+ declare interface DocumentDefinition extends Omit<ObjectDefinition, 'type'> {
1287
+ type: 'document'
1288
+ liveEdit?: boolean
1289
+ /** @beta */
1290
+ orderings?: SortOrdering[]
1291
+ options?: DocumentOptions
1292
+ validation?: ValidationBuilder<DocumentRule, SanityDocument>
1293
+ initialValue?: InitialValueProperty<any, Record<string, unknown>>
1294
+ /** @deprecated Unused. Use the new field-level search config. */
1295
+ __experimental_search?: {
1296
+ path: string
1297
+ weight: number
1298
+ mapWith?: string
1299
+ }[]
1300
+ /** @alpha */
1301
+ __experimental_omnisearch_visibility?: boolean
1302
+ /**
1303
+ * Determines whether the large preview title is displayed in the document pane form
1304
+ * @alpha
1305
+ * */
1306
+ __experimental_formPreviewTitle?: boolean
1307
+ }
1308
+
1309
+ /**
1310
+ * This exists only to allow for extensions using declaration-merging.
1311
+ *
1312
+ * @public
1313
+ */
1314
+ declare interface DocumentOptions extends BaseSchemaTypeOptions {}
1315
+
1316
+ /** @public */
1317
+ declare interface DocumentRule extends RuleDef<DocumentRule, SanityDocument> {}
1318
+
1319
+ declare type DragBehaviorEvent =
1320
+ | {
587
1321
  type: StrictExtract<NativeBehaviorEventType, 'drag.dragstart'>
588
1322
  originEvent: {
589
1323
  dataTransfer: DataTransfer
@@ -5460,6 +6194,31 @@ export declare type EditorSnapshot = {
5460
6194
  }
5461
6195
  }
5462
6196
 
6197
+ /** @public */
6198
+ declare interface EmailDefinition extends BaseSchemaDefinition {
6199
+ type: 'email'
6200
+ options?: EmailOptions
6201
+ placeholder?: string
6202
+ validation?: ValidationBuilder<EmailRule, string>
6203
+ initialValue?: InitialValueProperty<any, string>
6204
+ }
6205
+
6206
+ /** @public */
6207
+ declare interface EmailOptions extends BaseSchemaTypeOptions {}
6208
+
6209
+ /** @public */
6210
+ declare interface EmailRule extends RuleDef<EmailRule, string> {}
6211
+
6212
+ /** @public */
6213
+ declare interface EmptyProps {}
6214
+
6215
+ /** @public */
6216
+ declare interface EnumListProps<V = unknown> {
6217
+ list?: Array<TitledListValue<V> | V>
6218
+ layout?: 'radio' | 'dropdown'
6219
+ direction?: 'horizontal' | 'vertical'
6220
+ }
6221
+
5463
6222
  /**
5464
6223
  * The editor produced an error
5465
6224
  * @beta */
@@ -5551,11 +6310,142 @@ declare type ExternalEditorEvent =
5551
6310
  declare type ExtractNamespace<TType extends string> =
5552
6311
  TType extends `${infer Namespace}.${string}` ? Namespace : TType
5553
6312
 
5554
- declare type FieldDefinition = {
6313
+ /**
6314
+ * The shape of a field definition. Note, it's recommended to use the
6315
+ * `defineField` function instead of using this type directly.
6316
+ *
6317
+ * Where `defineField` infers the exact field type,
6318
+ * FieldDefinition is a compromise union of all types a field can have.
6319
+ *
6320
+ * A field definition can be a reference to another registered top-level type
6321
+ * or a inline type definition.
6322
+ *
6323
+ * @public
6324
+ */
6325
+ declare type FieldDefinition<
6326
+ TType extends IntrinsicTypeName = IntrinsicTypeName,
6327
+ TAlias extends IntrinsicTypeName | undefined = undefined,
6328
+ > = (InlineFieldDefinition[TType] | TypeAliasDefinition<string, TAlias>) &
6329
+ FieldDefinitionBase
6330
+
6331
+ declare type FieldDefinition_2 = {
5555
6332
  name: string
5556
6333
  type: 'string' | 'number' | 'boolean' | 'array' | 'object'
5557
6334
  }
5558
6335
 
6336
+ /** @public */
6337
+ declare interface FieldDefinitionBase {
6338
+ fieldset?: string
6339
+ group?: string | string[]
6340
+ }
6341
+
6342
+ /** @public */
6343
+ declare interface FieldGroup {
6344
+ name: string
6345
+ icon?: ComponentType
6346
+ title?: string
6347
+ description?: string
6348
+ i18n?: I18nTextRecord<'title'>
6349
+ hidden?: ConditionalProperty
6350
+ default?: boolean
6351
+ fields?: ObjectField[]
6352
+ }
6353
+
6354
+ /** @public */
6355
+ declare type FieldGroupDefinition = {
6356
+ name: string
6357
+ title?: string
6358
+ hidden?: ConditionalProperty
6359
+ icon?: ComponentType
6360
+ default?: boolean
6361
+ i18n?: I18nTextRecord<'title'>
6362
+ }
6363
+
6364
+ /**
6365
+ * Holds a reference to a different field
6366
+ * NOTE: Only use this through {@link Rule.valueOfField}
6367
+ *
6368
+ * @public
6369
+ */
6370
+ declare interface FieldReference {
6371
+ type: symbol
6372
+ path: string | string[]
6373
+ }
6374
+
6375
+ /** @public */
6376
+ declare type FieldRules = {
6377
+ [fieldKey: string]: SchemaValidationValue
6378
+ }
6379
+
6380
+ /** @public */
6381
+ declare type Fieldset = SingleFieldSet | MultiFieldSet
6382
+
6383
+ /** @public */
6384
+ declare type FieldsetDefinition = {
6385
+ name: string
6386
+ title?: string
6387
+ description?: string
6388
+ group?: string
6389
+ hidden?: ConditionalProperty
6390
+ readOnly?: ConditionalProperty
6391
+ options?: ObjectOptions
6392
+ }
6393
+
6394
+ /** @public */
6395
+ declare interface File_2 {
6396
+ [key: string]: unknown
6397
+ asset?: Reference
6398
+ }
6399
+
6400
+ /** @public */
6401
+ declare interface FileDefinition
6402
+ extends Omit<
6403
+ ObjectDefinition,
6404
+ 'type' | 'fields' | 'options' | 'groups' | 'validation'
6405
+ > {
6406
+ type: 'file'
6407
+ fields?: ObjectDefinition['fields']
6408
+ options?: FileOptions
6409
+ validation?: ValidationBuilder<FileRule, FileValue>
6410
+ initialValue?: InitialValueProperty<any, FileValue>
6411
+ }
6412
+
6413
+ /** @public */
6414
+ declare interface FileOptions extends ObjectOptions {
6415
+ storeOriginalFilename?: boolean
6416
+ accept?: string
6417
+ sources?: AssetSource[]
6418
+ }
6419
+
6420
+ /** @public */
6421
+ declare interface FileRule extends RuleDef<FileRule, FileValue> {
6422
+ /**
6423
+ * Require a file field has an asset.
6424
+ *
6425
+ * @example
6426
+ * ```ts
6427
+ * defineField({
6428
+ * name: 'file',
6429
+ * title: 'File',
6430
+ * type: 'file',
6431
+ * validation: (Rule) => Rule.required().assetRequired(),
6432
+ * })
6433
+ * ```
6434
+ */
6435
+ assetRequired(): FileRule
6436
+ }
6437
+
6438
+ /** @public */
6439
+ declare interface FileSchemaType extends Omit<ObjectSchemaType, 'options'> {
6440
+ options?: FileOptions
6441
+ }
6442
+
6443
+ /** @public */
6444
+ declare interface FileValue {
6445
+ asset?: Reference
6446
+ [index: string]: unknown
6447
+ }
6448
+
5559
6449
  /**
5560
6450
  * The editor received focus
5561
6451
  * @beta */
@@ -5564,6 +6454,63 @@ export declare type FocusChange = {
5564
6454
  event: FocusEvent_2<HTMLDivElement, Element>
5565
6455
  }
5566
6456
 
6457
+ /** @public */
6458
+ declare interface GeopointDefinition extends BaseSchemaDefinition {
6459
+ type: 'geopoint'
6460
+ options?: GeopointOptions
6461
+ validation?: ValidationBuilder<GeopointRule, GeopointValue>
6462
+ initialValue?: InitialValueProperty<any, Omit<GeopointValue, '_type'>>
6463
+ }
6464
+
6465
+ /** @public */
6466
+ declare interface GeopointOptions extends BaseSchemaTypeOptions {}
6467
+
6468
+ /** @public */
6469
+ declare interface GeopointRule extends RuleDef<GeopointRule, GeopointValue> {}
6470
+
6471
+ /**
6472
+ * Geographical point representing a pair of latitude and longitude coordinates,
6473
+ * stored as degrees, in the World Geodetic System 1984 (WGS 84) format. Also
6474
+ * includes an optional `alt` property representing the altitude in meters.
6475
+ *
6476
+ * @public
6477
+ */
6478
+ declare interface GeopointValue {
6479
+ /**
6480
+ * Type of the object. Must be `geopoint`.
6481
+ */
6482
+ _type: 'geopoint'
6483
+ /**
6484
+ * Latitude in degrees
6485
+ */
6486
+ lat: number
6487
+ /**
6488
+ * Longitude in degrees
6489
+ */
6490
+ lng: number
6491
+ /**
6492
+ * Altitude in meters
6493
+ */
6494
+ alt?: number
6495
+ }
6496
+
6497
+ /** @public */
6498
+ declare interface GlobalDocumentReferenceDefinition
6499
+ extends BaseSchemaDefinition {
6500
+ type: 'globalDocumentReference'
6501
+ weak?: boolean
6502
+ to: {
6503
+ type: string
6504
+ title?: string
6505
+ icon?: ComponentType
6506
+ preview?: PreviewConfig
6507
+ }[]
6508
+ resourceType: string
6509
+ resourceId: string
6510
+ options?: ReferenceOptions
6511
+ studioUrl?: (document: {id: string; type?: string}) => string | null
6512
+ }
6513
+
5567
6514
  declare type HasTag = ReturnType<EditorActor['getSnapshot']>['hasTag']
5568
6515
 
5569
6516
  declare interface History_2 {
@@ -5587,6 +6534,178 @@ export declare type HotkeyOptions = {
5587
6534
  >
5588
6535
  }
5589
6536
 
6537
+ /** @public */
6538
+ declare interface HotspotOptions {
6539
+ previews?: HotspotPreview[]
6540
+ }
6541
+
6542
+ /** @public */
6543
+ declare interface HotspotPreview {
6544
+ title: string
6545
+ aspectRatio: number
6546
+ }
6547
+
6548
+ /** @public */
6549
+ declare type I18nTextRecord<K extends string> = {
6550
+ [P in K]?: {
6551
+ key: string
6552
+ ns: string
6553
+ }
6554
+ }
6555
+
6556
+ /** @public */
6557
+ declare interface ImageAsset extends Asset {
6558
+ _type: 'sanity.imageAsset'
6559
+ metadata: ImageMetadata
6560
+ }
6561
+
6562
+ /** @public */
6563
+ declare interface ImageCrop {
6564
+ _type?: 'sanity.imageCrop'
6565
+ left: number
6566
+ bottom: number
6567
+ right: number
6568
+ top: number
6569
+ }
6570
+
6571
+ /** @public */
6572
+ declare interface ImageDefinition
6573
+ extends Omit<
6574
+ ObjectDefinition,
6575
+ 'type' | 'fields' | 'options' | 'groups' | 'validation'
6576
+ > {
6577
+ type: 'image'
6578
+ fields?: FieldDefinition[]
6579
+ options?: ImageOptions
6580
+ validation?: ValidationBuilder<ImageRule, ImageValue>
6581
+ initialValue?: InitialValueProperty<any, ImageValue>
6582
+ }
6583
+
6584
+ /** @public */
6585
+ declare interface ImageDimensions {
6586
+ _type: 'sanity.imageDimensions'
6587
+ height: number
6588
+ width: number
6589
+ aspectRatio: number
6590
+ }
6591
+
6592
+ /** @public */
6593
+ declare interface ImageHotspot {
6594
+ _type?: 'sanity.imageHotspot'
6595
+ width: number
6596
+ height: number
6597
+ x: number
6598
+ y: number
6599
+ }
6600
+
6601
+ /** @public */
6602
+ declare interface ImageMetadata {
6603
+ [key: string]: unknown
6604
+ _type: 'sanity.imageMetadata'
6605
+ dimensions: ImageDimensions
6606
+ palette?: ImagePalette
6607
+ lqip?: string
6608
+ blurHash?: string
6609
+ hasAlpha: boolean
6610
+ isOpaque: boolean
6611
+ }
6612
+
6613
+ /** @public */
6614
+ declare type ImageMetadataType =
6615
+ | 'blurhash'
6616
+ | 'lqip'
6617
+ | 'palette'
6618
+ | 'exif'
6619
+ | 'image'
6620
+ | 'location'
6621
+
6622
+ /** @public */
6623
+ declare interface ImageOptions extends FileOptions {
6624
+ metadata?: ImageMetadataType[]
6625
+ hotspot?: boolean | HotspotOptions
6626
+ }
6627
+
6628
+ /** @public */
6629
+ declare interface ImagePalette {
6630
+ _type: 'sanity.imagePalette'
6631
+ darkMuted?: ImageSwatch
6632
+ darkVibrant?: ImageSwatch
6633
+ dominant?: ImageSwatch
6634
+ lightMuted?: ImageSwatch
6635
+ lightVibrant?: ImageSwatch
6636
+ muted?: ImageSwatch
6637
+ vibrant?: ImageSwatch
6638
+ }
6639
+
6640
+ /** @public */
6641
+ declare interface ImageRule extends RuleDef<ImageRule, ImageValue> {
6642
+ /**
6643
+ * Require an image field has an asset.
6644
+ *
6645
+ * @example
6646
+ * ```ts
6647
+ * defineField({
6648
+ * name: 'image',
6649
+ * title: 'Image',
6650
+ * type: 'image',
6651
+ * validation: (Rule) => Rule.required().assetRequired(),
6652
+ * })
6653
+ * ```
6654
+ */
6655
+ assetRequired(): ImageRule
6656
+ }
6657
+
6658
+ /** @public */
6659
+ declare interface ImageSwatch {
6660
+ _type: 'sanity.imagePaletteSwatch'
6661
+ background: string
6662
+ foreground: string
6663
+ population: number
6664
+ title?: string
6665
+ }
6666
+
6667
+ /** @public */
6668
+ declare interface ImageValue extends FileValue {
6669
+ crop?: ImageCrop
6670
+ hotspot?: ImageHotspot
6671
+ [index: string]: unknown
6672
+ }
6673
+
6674
+ /** @public */
6675
+ declare type IndexTuple = [number | '', number | '']
6676
+
6677
+ /** @public */
6678
+ declare type InitialValueProperty<Params, Value> =
6679
+ | Value
6680
+ | InitialValueResolver<Params, Value>
6681
+ | undefined
6682
+
6683
+ /** @public */
6684
+ declare type InitialValueResolver<Params, Value> = (
6685
+ params: Params | undefined,
6686
+ context: InitialValueResolverContext,
6687
+ ) => Promise<Value> | Value
6688
+
6689
+ /** @public */
6690
+ declare interface InitialValueResolverContext {
6691
+ projectId: string
6692
+ dataset: string
6693
+ schema: Schema
6694
+ currentUser: CurrentUser | null
6695
+ getClient: (options: {apiVersion: string}) => SanityClient
6696
+ }
6697
+
6698
+ /** @public */
6699
+ declare type InlineFieldDefinition = {
6700
+ [K in keyof IntrinsicDefinitions]: Omit<
6701
+ IntrinsicDefinitions[K],
6702
+ 'initialValue' | 'validation'
6703
+ > & {
6704
+ validation?: SchemaValidationValue
6705
+ initialValue?: InitialValueProperty<any, any>
6706
+ }
6707
+ }
6708
+
5590
6709
  /**
5591
6710
  * Used to represent native InputEvents that hold a DataTransfer object.
5592
6711
  *
@@ -5605,6 +6724,33 @@ declare type InputBehaviorEvent = {
5605
6724
  }
5606
6725
  }
5607
6726
 
6727
+ /** @alpha This API may change */
6728
+ declare interface InsertMenuOptions {
6729
+ /**
6730
+ * @defaultValue `'auto'`
6731
+ * `filter: 'auto'` automatically turns on filtering if there are more than 5
6732
+ * schema types added to the menu.
6733
+ */
6734
+ filter?: 'auto' | boolean
6735
+ groups?: Array<{
6736
+ name: string
6737
+ title?: string
6738
+ of?: Array<string>
6739
+ }>
6740
+ /** defaultValue `true` */
6741
+ showIcons?: boolean
6742
+ /** @defaultValue `[{name: 'list'}]` */
6743
+ views?: Array<
6744
+ | {
6745
+ name: 'list'
6746
+ }
6747
+ | {
6748
+ name: 'grid'
6749
+ previewImageUrl?: (schemaTypeName: string) => string | undefined
6750
+ }
6751
+ >
6752
+ }
6753
+
5608
6754
  declare type InsertPlacement = 'auto' | 'after' | 'before'
5609
6755
 
5610
6756
  declare type InternalEditor = Editor & {
@@ -5620,6 +6766,64 @@ declare type InternalPatchEvent = NamespaceEvent<PatchEvent, 'internal'> & {
5620
6766
  value: Array<PortableTextBlock>
5621
6767
  }
5622
6768
 
6769
+ /** @public */
6770
+ declare type IntrinsicArrayOfDefinition = {
6771
+ [K in keyof IntrinsicDefinitions]: Omit<
6772
+ ArrayOfEntry<IntrinsicDefinitions[K]>,
6773
+ 'validation' | 'initialValue'
6774
+ > & {
6775
+ validation?: SchemaValidationValue
6776
+ initialValue?: InitialValueProperty<any, any>
6777
+ }
6778
+ }
6779
+
6780
+ /**
6781
+ * `IntrinsicDefinitions` is a lookup map for "predefined" schema definitions.
6782
+ * Schema types in `IntrinsicDefinitions` will have good type-completion and type-safety in {@link defineType},
6783
+ * {@link defineField} and {@link defineArrayMember} once the `type` property is provided.
6784
+ *
6785
+ * By default, `IntrinsicDefinitions` contains all standard Sanity schema types (`array`, `string`, `number` ect),
6786
+ * but it is an interface and as such, open for extension.
6787
+ *
6788
+ * This type can be extended using declaration merging; this way new entries can be added.
6789
+ * See {@link defineType} for examples on how this can be accomplished.
6790
+ *
6791
+ * @see defineType
6792
+ *
6793
+ * @public
6794
+ */
6795
+ declare interface IntrinsicDefinitions {
6796
+ array: ArrayDefinition
6797
+ block: BlockDefinition
6798
+ boolean: BooleanDefinition
6799
+ date: DateDefinition
6800
+ datetime: DatetimeDefinition
6801
+ document: DocumentDefinition
6802
+ file: FileDefinition
6803
+ geopoint: GeopointDefinition
6804
+ image: ImageDefinition
6805
+ number: NumberDefinition
6806
+ object: ObjectDefinition
6807
+ reference: ReferenceDefinition
6808
+ crossDatasetReference: CrossDatasetReferenceDefinition
6809
+ globalDocumentReference: GlobalDocumentReferenceDefinition
6810
+ slug: SlugDefinition
6811
+ string: StringDefinition
6812
+ text: TextDefinition
6813
+ url: UrlDefinition
6814
+ email: EmailDefinition
6815
+ }
6816
+
6817
+ /**
6818
+ * A union of all intrinsic types allowed natively in the schema.
6819
+ *
6820
+ * @see IntrinsicDefinitions
6821
+ *
6822
+ * @public
6823
+ */
6824
+ declare type IntrinsicTypeName =
6825
+ IntrinsicDefinitions[keyof IntrinsicDefinitions]['type']
6826
+
5623
6827
  /**
5624
6828
  * The editor has an invalid value
5625
6829
  * @beta */
@@ -5668,6 +6872,11 @@ declare type KeyboardBehaviorEvent =
5668
6872
  >
5669
6873
  }
5670
6874
 
6875
+ /** @public */
6876
+ declare type KeyedSegment = {
6877
+ _key: string
6878
+ }
6879
+
5671
6880
  /**
5672
6881
  * @public
5673
6882
  */
@@ -5682,6 +6891,22 @@ export declare type LoadingChange = {
5682
6891
  isLoading: boolean
5683
6892
  }
5684
6893
 
6894
+ /**
6895
+ * Holds localized validation messages for a given field.
6896
+ *
6897
+ * @example Custom message for English (US) and Norwegian (Bokmål):
6898
+ * ```
6899
+ * {
6900
+ * 'en-US': 'Needs to start with a capital letter',
6901
+ * 'no-NB': 'Må starte med stor bokstav',
6902
+ * }
6903
+ * ```
6904
+ * @public
6905
+ */
6906
+ declare interface LocalizedValidationMessages {
6907
+ [locale: string]: string
6908
+ }
6909
+
5685
6910
  declare type MIMEType = `${string}/${string}`
5686
6911
 
5687
6912
  declare type MouseBehaviorEvent = {
@@ -5689,6 +6914,21 @@ declare type MouseBehaviorEvent = {
5689
6914
  position: EventPosition
5690
6915
  }
5691
6916
 
6917
+ /** @public */
6918
+ declare interface MultiFieldSet {
6919
+ name: string
6920
+ title?: string
6921
+ description?: string
6922
+ single?: false
6923
+ group?: string | string[]
6924
+ options?: CollapseOptions & {
6925
+ columns?: number
6926
+ }
6927
+ fields: ObjectField[]
6928
+ hidden?: ConditionalProperty
6929
+ readOnly?: ConditionalProperty
6930
+ }
6931
+
5692
6932
  /**
5693
6933
  * The editor has mutated it's content.
5694
6934
  * @beta */
@@ -5765,35 +7005,139 @@ declare const nativeBehaviorEventTypes: readonly [
5765
7005
  'mouse.click',
5766
7006
  ]
5767
7007
 
5768
- declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
5769
- _key?: PortableTextObject['_key']
7008
+ /** @public */
7009
+ declare interface NumberDefinition extends BaseSchemaDefinition {
7010
+ type: 'number'
7011
+ options?: NumberOptions
7012
+ placeholder?: string
7013
+ validation?: ValidationBuilder<NumberRule, number>
7014
+ initialValue?: InitialValueProperty<any, number>
5770
7015
  }
5771
7016
 
5772
- /** @beta */
5773
- export declare type OnBeforeInputFn = (event: InputEvent) => void
7017
+ /** @public */
7018
+ declare interface NumberOptions
7019
+ extends EnumListProps<number>,
7020
+ BaseSchemaTypeOptions {}
5774
7021
 
5775
- /** @beta */
5776
- export declare type OnCopyFn = (
5777
- event: ClipboardEvent_2<HTMLDivElement | HTMLSpanElement>,
5778
- ) => undefined | unknown
7022
+ /** @public */
7023
+ declare interface NumberRule extends RuleDef<NumberRule, number> {
7024
+ min: (minNumber: number | FieldReference) => NumberRule
7025
+ max: (maxNumber: number | FieldReference) => NumberRule
7026
+ lessThan: (limit: number | FieldReference) => NumberRule
7027
+ greaterThan: (limit: number | FieldReference) => NumberRule
7028
+ integer: () => NumberRule
7029
+ precision: (limit: number | FieldReference) => NumberRule
7030
+ positive: () => NumberRule
7031
+ negative: () => NumberRule
7032
+ }
5779
7033
 
5780
- /**
5781
- * @beta
5782
- * It is encouraged not to return `Promise<undefined>` from the `OnPasteFn` as
5783
- * a mechanism to fall back to the native paste behaviour. This doesn't work in
5784
- * all cases. Always return plain `undefined` if possible.
5785
- **/
5786
- export declare type OnPasteFn = (data: PasteData) => OnPasteResultOrPromise
7034
+ /** @public */
7035
+ declare interface NumberSchemaType extends BaseSchemaType {
7036
+ jsonType: 'number'
7037
+ options?: NumberOptions
7038
+ initialValue?: InitialValueProperty<any, number>
7039
+ }
5787
7040
 
5788
- /** @beta */
5789
- export declare type OnPasteResult =
5790
- | {
5791
- insert?: TypedObject[]
5792
- path?: Path
5793
- }
5794
- | undefined
7041
+ declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
7042
+ _key?: PortableTextObject['_key']
7043
+ }
5795
7044
 
5796
- /**
7045
+ /** @public */
7046
+ declare interface ObjectDefinition extends BaseSchemaDefinition {
7047
+ type: 'object'
7048
+ /**
7049
+ * Object must have at least one field. This is validated at Studio startup.
7050
+ */
7051
+ fields: FieldDefinition[]
7052
+ groups?: FieldGroupDefinition[]
7053
+ fieldsets?: FieldsetDefinition[]
7054
+ preview?: PreviewConfig
7055
+ options?: ObjectOptions
7056
+ validation?: ValidationBuilder<ObjectRule, Record<string, unknown>>
7057
+ initialValue?: InitialValueProperty<any, Record<string, unknown>>
7058
+ }
7059
+
7060
+ /** @public */
7061
+ declare interface ObjectField<T extends SchemaType = SchemaType> {
7062
+ name: string
7063
+ fieldset?: string
7064
+ group?: string | string[]
7065
+ type: ObjectFieldType<T>
7066
+ }
7067
+
7068
+ /** @public */
7069
+ declare type ObjectFieldType<T extends SchemaType = SchemaType> = T & {
7070
+ hidden?: ConditionalProperty
7071
+ readOnly?: ConditionalProperty
7072
+ }
7073
+
7074
+ /** @public */
7075
+ declare interface ObjectOptions extends BaseSchemaTypeOptions {
7076
+ collapsible?: boolean
7077
+ collapsed?: boolean
7078
+ columns?: number
7079
+ modal?: {
7080
+ type?: 'dialog' | 'popover'
7081
+ width?: number | number[] | 'auto'
7082
+ }
7083
+ }
7084
+
7085
+ /** @public */
7086
+ declare interface ObjectRule
7087
+ extends RuleDef<ObjectRule, Record<string, unknown>> {}
7088
+
7089
+ /** @public */
7090
+ declare interface ObjectSchemaType extends BaseSchemaType {
7091
+ jsonType: 'object'
7092
+ fields: ObjectField[]
7093
+ groups?: FieldGroup[]
7094
+ fieldsets?: Fieldset[]
7095
+ initialValue?: InitialValueProperty<any, Record<string, unknown>>
7096
+ weak?: boolean
7097
+ /** @deprecated Unused. Use the new field-level search config. */
7098
+ __experimental_search?: {
7099
+ path: (string | number)[]
7100
+ weight: number
7101
+ mapWith?: string
7102
+ }[]
7103
+ /** @alpha */
7104
+ __experimental_omnisearch_visibility?: boolean
7105
+ /** @alpha */
7106
+ __experimental_actions?: string[]
7107
+ /** @alpha */
7108
+ __experimental_formPreviewTitle?: boolean
7109
+ /**
7110
+ * @beta
7111
+ */
7112
+ orderings?: SortOrdering[]
7113
+ options?: any
7114
+ }
7115
+
7116
+ /** @beta */
7117
+ export declare type OnBeforeInputFn = (event: InputEvent) => void
7118
+
7119
+ /** @beta */
7120
+ export declare type OnCopyFn = (
7121
+ event: ClipboardEvent_2<HTMLDivElement | HTMLSpanElement>,
7122
+ ) => undefined | unknown
7123
+
7124
+ /**
7125
+ * @beta
7126
+ * It is encouraged not to return `Promise<undefined>` from the `OnPasteFn` as
7127
+ * a mechanism to fall back to the native paste behaviour. This doesn't work in
7128
+ * all cases. Always return plain `undefined` if possible.
7129
+ **/
7130
+ export declare type OnPasteFn = (data: PasteData) => OnPasteResultOrPromise
7131
+
7132
+ /** @beta */
7133
+ export declare type OnPasteResult =
7134
+ | {
7135
+ insert?: TypedObject[]
7136
+ path?: Path
7137
+ }
7138
+ | undefined
7139
+
7140
+ /**
5797
7141
  * @beta
5798
7142
  */
5799
7143
  export declare type OnPasteResultOrPromise =
@@ -5838,6 +7182,12 @@ export declare type PatchObservable = Observable<{
5838
7182
  snapshot: PortableTextBlock[] | undefined
5839
7183
  }>
5840
7184
 
7185
+ /** @public */
7186
+ declare type Path = PathSegment[]
7187
+
7188
+ /** @public */
7189
+ declare type PathSegment = string | number | KeyedSegment | IndexTuple
7190
+
5841
7191
  /**
5842
7192
  * @internal
5843
7193
  */
@@ -5847,9 +7197,13 @@ declare type PickFromUnion<
5847
7197
  TPickedTags extends TUnion[TTagKey],
5848
7198
  > = TUnion extends Record<TTagKey, TPickedTags> ? TUnion : never
5849
7199
 
5850
- export {PortableTextBlock}
7200
+ /** @alpha */
7201
+ export declare type PortableTextBlock =
7202
+ | PortableTextTextBlock
7203
+ | PortableTextObject
5851
7204
 
5852
- export {PortableTextChild}
7205
+ /** @alpha */
7206
+ export declare type PortableTextChild = PortableTextObject | PortableTextSpan
5853
7207
 
5854
7208
  /**
5855
7209
  * @public
@@ -6004,9 +7358,9 @@ export declare class PortableTextEditor extends Component<
6004
7358
  path: Path,
6005
7359
  ) => [
6006
7360
  (
6007
- | PortableTextTextBlock<PortableTextObject | PortableTextSpan>
7361
+ | PortableTextTextBlock_2<PortableTextObject | PortableTextSpan_2>
6008
7362
  | PortableTextObject
6009
- | PortableTextSpan
7363
+ | PortableTextSpan_2
6010
7364
  | undefined
6011
7365
  ),
6012
7366
  Path | undefined,
@@ -6402,6 +7756,12 @@ export declare type PortableTextEditorProps<
6402
7756
  }
6403
7757
  >
6404
7758
 
7759
+ /** @alpha */
7760
+ declare interface PortableTextListBlock extends PortableTextTextBlock {
7761
+ listItem: string
7762
+ level: number
7763
+ }
7764
+
6405
7765
  /** @beta */
6406
7766
  export declare type PortableTextMemberSchemaTypes = {
6407
7767
  annotations: (ObjectSchemaType & {
@@ -6417,6 +7777,13 @@ export declare type PortableTextMemberSchemaTypes = {
6417
7777
  lists: BlockListDefinition[]
6418
7778
  }
6419
7779
 
7780
+ /** @alpha */
7781
+ declare interface PortableTextObject {
7782
+ _type: string
7783
+ _key: string
7784
+ [other: string]: unknown
7785
+ }
7786
+
6420
7787
  declare interface PortableTextSlateEditor extends ReactEditor {
6421
7788
  _key: 'editor'
6422
7789
  _type: 'editor'
@@ -6450,7 +7817,56 @@ declare interface PortableTextSlateEditor extends ReactEditor {
6450
7817
  redo: () => void
6451
7818
  }
6452
7819
 
6453
- export {PortableTextSpan}
7820
+ /** @alpha */
7821
+ export declare interface PortableTextSpan {
7822
+ _key: string
7823
+ _type: 'span'
7824
+ text: string
7825
+ marks?: string[]
7826
+ }
7827
+
7828
+ /** @alpha */
7829
+ declare interface PortableTextTextBlock<
7830
+ TChild = PortableTextSpan | PortableTextObject,
7831
+ > {
7832
+ _type: string
7833
+ _key: string
7834
+ children: TChild[]
7835
+ markDefs?: PortableTextObject[]
7836
+ listItem?: string
7837
+ style?: string
7838
+ level?: number
7839
+ }
7840
+
7841
+ /** @public */
7842
+ declare interface PrepareViewOptions {
7843
+ /** @beta */
7844
+ ordering?: SortOrdering
7845
+ }
7846
+
7847
+ /** @public */
7848
+ declare interface PreviewConfig<
7849
+ Select extends Record<string, string> = Record<string, string>,
7850
+ PrepareValue extends Record<keyof Select, any> = Record<keyof Select, any>,
7851
+ > {
7852
+ select?: Select
7853
+ prepare?: (
7854
+ value: PrepareValue,
7855
+ viewOptions?: PrepareViewOptions,
7856
+ ) => PreviewValue
7857
+ }
7858
+
7859
+ /** @public */
7860
+ declare interface PreviewValue {
7861
+ _id?: string
7862
+ _createdAt?: string
7863
+ _updatedAt?: string
7864
+ title?: string
7865
+ subtitle?: string
7866
+ description?: string
7867
+ media?: ReactNode | ElementType
7868
+ imageUrl?: string
7869
+ }
6454
7870
 
6455
7871
  /**
6456
7872
  * A range decoration is a UI affordance that wraps a given selection range in the editor
@@ -6511,6 +7927,111 @@ export declare type RedoChange = {
6511
7927
  timestamp: Date
6512
7928
  }
6513
7929
 
7930
+ /** @public */
7931
+ declare interface Reference {
7932
+ _type: string
7933
+ _ref: string
7934
+ _key?: string
7935
+ _weak?: boolean
7936
+ _strengthenOnPublish?: {
7937
+ type: string
7938
+ weak?: boolean
7939
+ template?: {
7940
+ id: string
7941
+ params: Record<string, string | number | boolean>
7942
+ }
7943
+ }
7944
+ }
7945
+
7946
+ /** @public */
7947
+ declare interface ReferenceBaseOptions extends BaseSchemaTypeOptions {
7948
+ disableNew?: boolean
7949
+ }
7950
+
7951
+ /** @public */
7952
+ declare interface ReferenceDefinition extends BaseSchemaDefinition {
7953
+ type: 'reference'
7954
+ to: ReferenceTo
7955
+ weak?: boolean
7956
+ options?: ReferenceOptions
7957
+ validation?: ValidationBuilder<ReferenceRule, ReferenceValue>
7958
+ initialValue?: InitialValueProperty<any, Omit<ReferenceValue, '_type'>>
7959
+ }
7960
+
7961
+ /** @public */
7962
+ declare type ReferenceFilterOptions =
7963
+ | ReferenceFilterResolverOptions
7964
+ | ReferenceFilterQueryOptions
7965
+
7966
+ /** @public */
7967
+ declare interface ReferenceFilterQueryOptions {
7968
+ filter: string
7969
+ filterParams?: Record<string, unknown>
7970
+ }
7971
+
7972
+ /** @public */
7973
+ declare type ReferenceFilterResolver = (
7974
+ context: ReferenceFilterResolverContext,
7975
+ ) => ReferenceFilterSearchOptions | Promise<ReferenceFilterSearchOptions>
7976
+
7977
+ /** @public */
7978
+ declare interface ReferenceFilterResolverContext {
7979
+ document: SanityDocument
7980
+ parent?: Record<string, unknown> | Record<string, unknown>[]
7981
+ parentPath: Path
7982
+ getClient: (options: {apiVersion: string}) => SanityClient
7983
+ }
7984
+
7985
+ /** @public */
7986
+ declare interface ReferenceFilterResolverOptions {
7987
+ filter?: ReferenceFilterResolver
7988
+ filterParams?: never
7989
+ }
7990
+
7991
+ /** @public */
7992
+ declare type ReferenceFilterSearchOptions = {
7993
+ filter?: string
7994
+ params?: Record<string, unknown>
7995
+ tag?: string
7996
+ maxFieldDepth?: number
7997
+ strategy?: SearchStrategy
7998
+ perspective?: ClientPerspective
7999
+ }
8000
+
8001
+ /**
8002
+ * Types are closed for extension. To add properties via declaration merging to this type,
8003
+ * redeclare and add the properties to the interfaces that make up ReferenceOptions type.
8004
+ *
8005
+ * @see ReferenceFilterOptions
8006
+ * @see ReferenceFilterResolverOptions
8007
+ * @see ReferenceBaseOptions
8008
+ *
8009
+ * @public
8010
+ */
8011
+ declare type ReferenceOptions = ReferenceBaseOptions & ReferenceFilterOptions
8012
+
8013
+ /** @public */
8014
+ declare interface ReferenceRule
8015
+ extends RuleDef<ReferenceRule, ReferenceValue> {}
8016
+
8017
+ /** @public */
8018
+ declare interface ReferenceSchemaType
8019
+ extends Omit<ObjectSchemaType, 'options'> {
8020
+ jsonType: 'object'
8021
+ to: ObjectSchemaType[]
8022
+ weak?: boolean
8023
+ options?: ReferenceOptions
8024
+ }
8025
+
8026
+ /** @public */
8027
+ declare type ReferenceTo =
8028
+ | SchemaTypeDefinition
8029
+ | TypeReference
8030
+ | Array<SchemaTypeDefinition | TypeReference>
8031
+
8032
+ /** @public */
8033
+ declare type ReferenceValue = Reference
8034
+
6514
8035
  /** @beta */
6515
8036
  export declare type RenderAnnotationFunction = (
6516
8037
  props: BlockAnnotationRenderProps,
@@ -6574,6 +8095,307 @@ declare type ResolveBehaviorEvent<
6574
8095
  ? PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>
6575
8096
  : never
6576
8097
 
8098
+ /** @public */
8099
+ declare interface Role {
8100
+ name: string
8101
+ title: string
8102
+ description?: string
8103
+ }
8104
+
8105
+ /** @public */
8106
+ declare interface Rule {
8107
+ /**
8108
+ * @internal
8109
+ * @deprecated internal use only
8110
+ */
8111
+ _type: RuleTypeConstraint | undefined
8112
+ /**
8113
+ * @internal
8114
+ * @deprecated internal use only
8115
+ */
8116
+ _level: 'error' | 'warning' | 'info' | undefined
8117
+ /**
8118
+ * @internal
8119
+ * @deprecated internal use only
8120
+ */
8121
+ _required: 'required' | 'optional' | undefined
8122
+ /**
8123
+ * @internal
8124
+ * @deprecated internal use only
8125
+ */
8126
+ _typeDef: SchemaType | undefined
8127
+ /**
8128
+ * @internal
8129
+ * @deprecated internal use only
8130
+ */
8131
+ _message: string | LocalizedValidationMessages | undefined
8132
+ /**
8133
+ * @internal
8134
+ * @deprecated internal use only
8135
+ */
8136
+ _rules: RuleSpec[]
8137
+ /**
8138
+ * @internal
8139
+ * @deprecated internal use only
8140
+ */
8141
+ _fieldRules: FieldRules | undefined
8142
+ /**
8143
+ * Takes in a path and returns an object with a symbol.
8144
+ *
8145
+ * When the validation lib sees this symbol, it will use the provided path to
8146
+ * get a value from the current field's parent and use that value as the input
8147
+ * to the Rule.
8148
+ *
8149
+ * The path that's given is forwarded to `lodash/get`
8150
+ *
8151
+ * ```js
8152
+ * fields: [
8153
+ * // ...
8154
+ * {
8155
+ * // ...
8156
+ * name: 'highestTemperature',
8157
+ * type: 'number',
8158
+ * validation: (Rule) => Rule.positive().min(Rule.valueOfField('lowestTemperature')),
8159
+ * // ...
8160
+ * },
8161
+ * ]
8162
+ * ```
8163
+ */
8164
+ valueOfField: (path: string | string[]) => FieldReference
8165
+ error(message?: string | LocalizedValidationMessages): Rule
8166
+ warning(message?: string | LocalizedValidationMessages): Rule
8167
+ info(message?: string | LocalizedValidationMessages): Rule
8168
+ reset(): this
8169
+ isRequired(): boolean
8170
+ clone(): Rule
8171
+ cloneWithRules(rules: RuleSpec[]): Rule
8172
+ merge(rule: Rule): Rule
8173
+ type(targetType: RuleTypeConstraint | Lowercase<RuleTypeConstraint>): Rule
8174
+ all(children: Rule[]): Rule
8175
+ either(children: Rule[]): Rule
8176
+ optional(): Rule
8177
+ required(): Rule
8178
+ custom<T = unknown>(
8179
+ fn: CustomValidator<T>,
8180
+ options?: {
8181
+ bypassConcurrencyLimit?: boolean
8182
+ },
8183
+ ): Rule
8184
+ min(len: number | string | FieldReference): Rule
8185
+ max(len: number | string | FieldReference): Rule
8186
+ length(len: number | FieldReference): Rule
8187
+ valid(value: unknown | unknown[]): Rule
8188
+ integer(): Rule
8189
+ precision(limit: number | FieldReference): Rule
8190
+ positive(): Rule
8191
+ negative(): Rule
8192
+ greaterThan(num: number | FieldReference): Rule
8193
+ lessThan(num: number | FieldReference): Rule
8194
+ uppercase(): Rule
8195
+ lowercase(): Rule
8196
+ regex(
8197
+ pattern: RegExp,
8198
+ name: string,
8199
+ options: {
8200
+ name?: string
8201
+ invert?: boolean
8202
+ },
8203
+ ): Rule
8204
+ regex(
8205
+ pattern: RegExp,
8206
+ options: {
8207
+ name?: string
8208
+ invert?: boolean
8209
+ },
8210
+ ): Rule
8211
+ regex(pattern: RegExp, name: string): Rule
8212
+ regex(pattern: RegExp): Rule
8213
+ email(): Rule
8214
+ uri(options?: UriValidationOptions): Rule
8215
+ unique(): Rule
8216
+ reference(): Rule
8217
+ fields(rules: FieldRules): Rule
8218
+ assetRequired(): Rule
8219
+ validate(
8220
+ value: unknown,
8221
+ options: ValidationContext & {
8222
+ /**
8223
+ * @deprecated Internal use only
8224
+ * @internal
8225
+ */
8226
+ __internal?: {
8227
+ customValidationConcurrencyLimiter?: {
8228
+ ready: () => Promise<void>
8229
+ release: () => void
8230
+ }
8231
+ }
8232
+ },
8233
+ ): Promise<ValidationMarker[]>
8234
+ }
8235
+
8236
+ /** @public */
8237
+ declare type RuleBuilder<
8238
+ T extends RuleDef<T, FieldValue>,
8239
+ FieldValue = unknown,
8240
+ > = T | T[]
8241
+
8242
+ /** @public */
8243
+ declare interface RuleDef<T, FieldValue = unknown> {
8244
+ required: () => T
8245
+ custom: <LenientFieldValue extends FieldValue>(
8246
+ fn: CustomValidator<LenientFieldValue | undefined>,
8247
+ ) => T
8248
+ info: (message?: string | LocalizedValidationMessages) => T
8249
+ error: (message?: string | LocalizedValidationMessages) => T
8250
+ warning: (message?: string | LocalizedValidationMessages) => T
8251
+ valueOfField: (path: string | string[]) => FieldReference
8252
+ }
8253
+
8254
+ /** @public */
8255
+ declare type RuleSpec =
8256
+ | {
8257
+ flag: 'integer'
8258
+ }
8259
+ | {
8260
+ flag: 'email'
8261
+ }
8262
+ | {
8263
+ flag: 'unique'
8264
+ }
8265
+ | {
8266
+ flag: 'reference'
8267
+ }
8268
+ | {
8269
+ flag: 'type'
8270
+ constraint: RuleTypeConstraint
8271
+ }
8272
+ | {
8273
+ flag: 'all'
8274
+ constraint: Rule[]
8275
+ }
8276
+ | {
8277
+ flag: 'either'
8278
+ constraint: Rule[]
8279
+ }
8280
+ | {
8281
+ flag: 'presence'
8282
+ constraint: 'optional' | 'required'
8283
+ }
8284
+ | {
8285
+ flag: 'custom'
8286
+ constraint: CustomValidator
8287
+ }
8288
+ | {
8289
+ flag: 'min'
8290
+ constraint: number | string
8291
+ }
8292
+ | {
8293
+ flag: 'max'
8294
+ constraint: number | string
8295
+ }
8296
+ | {
8297
+ flag: 'length'
8298
+ constraint: number
8299
+ }
8300
+ | {
8301
+ flag: 'valid'
8302
+ constraint: unknown[]
8303
+ }
8304
+ | {
8305
+ flag: 'precision'
8306
+ constraint: number
8307
+ }
8308
+ | {
8309
+ flag: 'lessThan'
8310
+ constraint: number
8311
+ }
8312
+ | {
8313
+ flag: 'greaterThan'
8314
+ constraint: number
8315
+ }
8316
+ | {
8317
+ flag: 'stringCasing'
8318
+ constraint: 'uppercase' | 'lowercase'
8319
+ }
8320
+ | {
8321
+ flag: 'assetRequired'
8322
+ constraint: {
8323
+ assetType: 'asset' | 'image' | 'file'
8324
+ }
8325
+ }
8326
+ | {
8327
+ flag: 'regex'
8328
+ constraint: {
8329
+ pattern: RegExp
8330
+ name?: string
8331
+ invert: boolean
8332
+ }
8333
+ }
8334
+ | {
8335
+ flag: 'uri'
8336
+ constraint: {
8337
+ options: {
8338
+ scheme: RegExp[]
8339
+ allowRelative: boolean
8340
+ relativeOnly: boolean
8341
+ allowCredentials: boolean
8342
+ }
8343
+ }
8344
+ }
8345
+
8346
+ /** @public */
8347
+ declare type RuleTypeConstraint =
8348
+ | 'Array'
8349
+ | 'Boolean'
8350
+ | 'Date'
8351
+ | 'Number'
8352
+ | 'Object'
8353
+ | 'String'
8354
+
8355
+ /**
8356
+ * Options for configuring how Sanity Create interfaces with the type or field.
8357
+ *
8358
+ * @public
8359
+ */
8360
+ declare interface SanityCreateOptions {
8361
+ /** Set to true to exclude a type or field from appearing in Sanity Create */
8362
+ exclude?: boolean
8363
+ /**
8364
+ * A short description of what the type or field is used for.
8365
+ * Purpose can be used to improve how and when content mapping uses the field.
8366
+ * */
8367
+ purpose?: string
8368
+ }
8369
+
8370
+ /** @public */
8371
+ declare interface SanityDocument {
8372
+ _id: string
8373
+ _type: string
8374
+ _createdAt: string
8375
+ _updatedAt: string
8376
+ _rev: string
8377
+ [key: string]: unknown
8378
+ }
8379
+
8380
+ /** @public */
8381
+ declare interface Schema {
8382
+ /** @internal */
8383
+ _original?: {
8384
+ name: string
8385
+ types: SchemaTypeDefinition[]
8386
+ }
8387
+ /** @internal */
8388
+ _registry: {
8389
+ [typeName: string]: any
8390
+ }
8391
+ /** @internal */
8392
+ _validation?: SchemaValidationProblemGroup[]
8393
+ name: string
8394
+ get: (name: string) => SchemaType | undefined
8395
+ has: (name: string) => boolean
8396
+ getTypeNames: () => string[]
8397
+ }
8398
+
6577
8399
  /**
6578
8400
  * @public
6579
8401
  */
@@ -6583,29 +8405,159 @@ export declare type SchemaDefinition<
6583
8405
  decorators?: ReadonlyArray<TBaseDefinition>
6584
8406
  blockObjects?: ReadonlyArray<
6585
8407
  TBaseDefinition & {
6586
- fields?: ReadonlyArray<FieldDefinition>
8408
+ fields?: ReadonlyArray<FieldDefinition_2>
6587
8409
  }
6588
8410
  >
6589
8411
  inlineObjects?: ReadonlyArray<
6590
8412
  TBaseDefinition & {
6591
- fields?: ReadonlyArray<FieldDefinition>
8413
+ fields?: ReadonlyArray<FieldDefinition_2>
6592
8414
  }
6593
8415
  >
6594
8416
  annotations?: ReadonlyArray<
6595
8417
  TBaseDefinition & {
6596
- fields?: ReadonlyArray<FieldDefinition>
8418
+ fields?: ReadonlyArray<FieldDefinition_2>
6597
8419
  }
6598
8420
  >
6599
8421
  lists?: ReadonlyArray<TBaseDefinition>
6600
8422
  styles?: ReadonlyArray<TBaseDefinition>
6601
8423
  }
6602
8424
 
8425
+ /**
8426
+ * Note: you probably want `SchemaTypeDefinition` instead
8427
+ * @see SchemaTypeDefinition
8428
+ *
8429
+ * @public
8430
+ */
8431
+ declare type SchemaType =
8432
+ | ArraySchemaType
8433
+ | BooleanSchemaType
8434
+ | FileSchemaType
8435
+ | NumberSchemaType
8436
+ | ObjectSchemaType
8437
+ | StringSchemaType
8438
+ | ReferenceSchemaType
8439
+
8440
+ /**
8441
+ * Represents a Sanity schema type definition with an optional type parameter.
8442
+ *
8443
+ * It's recommend to use the `defineType` helper instead of this type by
8444
+ * itself.
8445
+ *
8446
+ * @see defineType
8447
+ *
8448
+ * @public
8449
+ */
8450
+ declare type SchemaTypeDefinition<
8451
+ TType extends IntrinsicTypeName = IntrinsicTypeName,
8452
+ > = IntrinsicDefinitions[IntrinsicTypeName] | TypeAliasDefinition<string, TType>
8453
+
8454
+ /** @public */
8455
+ declare interface SchemaValidationError {
8456
+ helpId?: string
8457
+ message: string
8458
+ severity: 'error'
8459
+ }
8460
+
8461
+ /** @internal */
8462
+ declare type SchemaValidationProblem =
8463
+ | SchemaValidationError
8464
+ | SchemaValidationWarning
8465
+
8466
+ /** @internal */
8467
+ declare interface SchemaValidationProblemGroup {
8468
+ path: SchemaValidationProblemPath
8469
+ problems: SchemaValidationProblem[]
8470
+ }
8471
+
8472
+ /** @internal */
8473
+ declare type SchemaValidationProblemPath = Array<
8474
+ | {
8475
+ kind: 'type'
8476
+ type: string
8477
+ name?: string
8478
+ }
8479
+ | {
8480
+ kind: 'property'
8481
+ name: string
8482
+ }
8483
+ >
8484
+
8485
+ /**
8486
+ * Represents the possible values of a schema type's `validation` field.
8487
+ *
8488
+ * If the schema has not been run through `inferFromSchema` from
8489
+ * `sanity/validation` then value could be a function.
8490
+ *
8491
+ * `inferFromSchema` mutates the schema converts this value to an array of
8492
+ * `Rule` instances.
8493
+ *
8494
+ * @privateRemarks
8495
+ *
8496
+ * Usage of the schema inside the studio will almost always be from the compiled
8497
+ * `createSchema` function. In this case, you can cast the value or throw to
8498
+ * narrow the type. E.g.:
8499
+ *
8500
+ * ```ts
8501
+ * if (typeof type.validation === 'function') {
8502
+ * throw new Error(
8503
+ * `Schema type "${type.name}"'s \`validation\` was not run though \`inferFromSchema\``
8504
+ * )
8505
+ * }
8506
+ * ```
8507
+ *
8508
+ * @public
8509
+ */
8510
+ declare type SchemaValidationValue =
8511
+ | false
8512
+ | undefined
8513
+ | Rule
8514
+ | SchemaValidationValue[]
8515
+ | ((rule: Rule) => SchemaValidationValue)
8516
+
8517
+ /** @internal */
8518
+ declare interface SchemaValidationWarning {
8519
+ helpId?: string
8520
+ message: string
8521
+ severity: 'warning'
8522
+ }
8523
+
6603
8524
  /** @beta */
6604
8525
  export declare type ScrollSelectionIntoViewFunction = (
6605
8526
  editor: PortableTextEditor,
6606
8527
  domRange: globalThis.Range,
6607
8528
  ) => void
6608
8529
 
8530
+ /** @public */
8531
+ declare interface SearchConfiguration {
8532
+ search?: {
8533
+ /**
8534
+ * Defines a search weight for this field to prioritize its importance
8535
+ * during search operations in the Studio. This setting allows the specified
8536
+ * field to be ranked higher in search results compared to other fields.
8537
+ *
8538
+ * By default, all fields are assigned a weight of 1. However, if a field is
8539
+ * chosen as the `title` in the preview configuration's `select` option, it
8540
+ * will automatically receive a default weight of 10. Similarly, if selected
8541
+ * as the `subtitle`, the default weight is 5. Fields marked as
8542
+ * `hidden: true` (no function) are assigned a weight of 0 by default.
8543
+ *
8544
+ * Note: Search weight configuration is currently supported only for fields
8545
+ * of type string or portable text arrays.
8546
+ */
8547
+ weight?: number
8548
+ }
8549
+ }
8550
+
8551
+ /**
8552
+ * @public
8553
+ */
8554
+ declare const searchStrategies: readonly ['groqLegacy', 'groq2024']
8555
+
8556
+ /**
8557
+ * @public
8558
+ */
8559
+ declare type SearchStrategy = (typeof searchStrategies)[number]
8560
+
6609
8561
  /**
6610
8562
  * The editor has a new selection
6611
8563
  * @beta */
@@ -6626,13 +8578,164 @@ declare type Serializer<TMIMEType extends MIMEType> = ({
6626
8578
  'serialization.success' | 'serialization.failure'
6627
8579
  >
6628
8580
 
8581
+ /** @public */
8582
+ declare interface SingleFieldSet {
8583
+ single: true
8584
+ field: ObjectField
8585
+ hidden?: ConditionalProperty
8586
+ readOnly?: ConditionalProperty
8587
+ group?: string | string[]
8588
+ }
8589
+
6629
8590
  declare type SlateEditor = {
6630
8591
  instance: PortableTextSlateEditor
6631
8592
  initialValue: Array<Descendant>
6632
8593
  }
6633
8594
 
8595
+ /** @public */
8596
+ declare interface SlugDefinition extends BaseSchemaDefinition {
8597
+ type: 'slug'
8598
+ options?: SlugOptions
8599
+ validation?: ValidationBuilder<SlugRule, SlugValue>
8600
+ initialValue?: InitialValueProperty<any, Omit<SlugValue, '_type'>>
8601
+ }
8602
+
8603
+ /** @public */
8604
+ declare type SlugifierFn = (
8605
+ source: string,
8606
+ schemaType: SlugSchemaType,
8607
+ context: SlugSourceContext,
8608
+ ) => string | Promise<string>
8609
+
8610
+ /** @public */
8611
+ declare type SlugIsUniqueValidator = (
8612
+ slug: string,
8613
+ context: SlugValidationContext,
8614
+ ) => boolean | Promise<boolean>
8615
+
8616
+ /** @public */
8617
+ declare interface SlugOptions
8618
+ extends SearchConfiguration,
8619
+ BaseSchemaTypeOptions {
8620
+ source?: string | Path | SlugSourceFn
8621
+ maxLength?: number
8622
+ slugify?: SlugifierFn
8623
+ isUnique?: SlugIsUniqueValidator
8624
+ disableArrayWarning?: boolean
8625
+ }
8626
+
8627
+ /** @public */
8628
+ declare type SlugParent = Record<string, unknown> | Record<string, unknown>[]
8629
+
8630
+ /** @public */
8631
+ declare interface SlugRule extends RuleDef<SlugRule, SlugValue> {}
8632
+
8633
+ /** @public */
8634
+ declare interface SlugSchemaType extends ObjectSchemaType {
8635
+ jsonType: 'object'
8636
+ options?: SlugOptions
8637
+ }
8638
+
8639
+ /** @public */
8640
+ declare interface SlugSourceContext {
8641
+ parentPath: Path
8642
+ parent: SlugParent
8643
+ projectId: string
8644
+ dataset: string
8645
+ schema: Schema
8646
+ currentUser: CurrentUser | null
8647
+ getClient: (options: {apiVersion: string}) => SanityClient
8648
+ }
8649
+
8650
+ /** @public */
8651
+ declare type SlugSourceFn = (
8652
+ document: SanityDocument,
8653
+ context: SlugSourceContext,
8654
+ ) => string | Promise<string>
8655
+
8656
+ /** @public */
8657
+ declare interface SlugValidationContext extends ValidationContext {
8658
+ parent: SlugParent
8659
+ type: SlugSchemaType
8660
+ defaultIsUnique: SlugIsUniqueValidator
8661
+ }
8662
+
8663
+ /** @public */
8664
+ declare interface SlugValue {
8665
+ _type: 'slug'
8666
+ current?: string
8667
+ }
8668
+
8669
+ /** @beta */
8670
+ declare type SortOrdering = {
8671
+ title: string
8672
+ i18n?: I18nTextRecord<'title'>
8673
+ name: string
8674
+ by: SortOrderingItem[]
8675
+ }
8676
+
8677
+ /** @beta */
8678
+ declare interface SortOrderingItem {
8679
+ field: string
8680
+ direction: 'asc' | 'desc'
8681
+ }
8682
+
6634
8683
  declare type StrictExtract<T, U extends T> = U
6635
8684
 
8685
+ /** @public */
8686
+ declare interface StringDefinition extends BaseSchemaDefinition {
8687
+ type: 'string'
8688
+ options?: StringOptions
8689
+ placeholder?: string
8690
+ validation?: ValidationBuilder<StringRule, string>
8691
+ initialValue?: InitialValueProperty<any, string>
8692
+ }
8693
+
8694
+ /** @public */
8695
+ declare interface StringOptions
8696
+ extends EnumListProps<string>,
8697
+ SearchConfiguration,
8698
+ BaseSchemaTypeOptions {}
8699
+
8700
+ /** @public */
8701
+ declare interface StringRule extends RuleDef<StringRule, string> {
8702
+ min: (minNumber: number | FieldReference) => StringRule
8703
+ max: (maxNumber: number | FieldReference) => StringRule
8704
+ length: (exactLength: number | FieldReference) => StringRule
8705
+ uppercase: () => StringRule
8706
+ lowercase: () => StringRule
8707
+ regex(
8708
+ pattern: RegExp,
8709
+ name: string,
8710
+ options: {
8711
+ name?: string
8712
+ invert?: boolean
8713
+ },
8714
+ ): StringRule
8715
+ regex(
8716
+ pattern: RegExp,
8717
+ options: {
8718
+ name?: string
8719
+ invert?: boolean
8720
+ },
8721
+ ): StringRule
8722
+ regex(pattern: RegExp, name: string): StringRule
8723
+ regex(pattern: RegExp): StringRule
8724
+ email(): StringRule
8725
+ }
8726
+
8727
+ /**
8728
+ * This is used for string, text, date and datetime.
8729
+ * This interface represent the compiled version at runtime, when accessed through Schema.
8730
+ *
8731
+ * @public
8732
+ */
8733
+ declare interface StringSchemaType extends BaseSchemaType {
8734
+ jsonType: 'string'
8735
+ options?: StringOptions & TextOptions & DateOptions & DatetimeOptions
8736
+ initialValue?: InitialValueProperty<any, string>
8737
+ }
8738
+
6636
8739
  /**
6637
8740
  * @beta
6638
8741
  */
@@ -6782,6 +8885,80 @@ declare type TextBlockWithOptionalKey = Omit<PortableTextTextBlock, '_key'> & {
6782
8885
  _key?: PortableTextTextBlock['_key']
6783
8886
  }
6784
8887
 
8888
+ /** @public */
8889
+ declare interface TextDefinition extends BaseSchemaDefinition {
8890
+ type: 'text'
8891
+ rows?: number
8892
+ options?: TextOptions
8893
+ placeholder?: string
8894
+ validation?: ValidationBuilder<TextRule, string>
8895
+ initialValue?: InitialValueProperty<any, string>
8896
+ }
8897
+
8898
+ /** @public */
8899
+ declare interface TextOptions extends StringOptions {}
8900
+
8901
+ /** @public */
8902
+ declare interface TextRule extends StringRule {}
8903
+
8904
+ /** @public */
8905
+ declare interface TitledListValue<V = unknown> {
8906
+ _key?: string
8907
+ title: string
8908
+ value?: V
8909
+ }
8910
+
8911
+ /**
8912
+ * Represents a type definition that is an alias/extension of an existing type
8913
+ * in your schema. Creating a type alias will re-register that existing type
8914
+ * under a different name. You can also override the default type options with
8915
+ * a type alias definition.
8916
+ *
8917
+ * @public
8918
+ */
8919
+ declare interface TypeAliasDefinition<
8920
+ TType extends string,
8921
+ TAlias extends IntrinsicTypeName | undefined,
8922
+ > extends BaseSchemaDefinition {
8923
+ type: TType
8924
+ options?: TAlias extends IntrinsicTypeName
8925
+ ? IntrinsicDefinitions[TAlias]['options']
8926
+ : unknown
8927
+ validation?: SchemaValidationValue
8928
+ initialValue?: InitialValueProperty<any, any>
8929
+ preview?: PreviewConfig
8930
+ components?: {
8931
+ annotation?: ComponentType<any>
8932
+ block?: ComponentType<any>
8933
+ inlineBlock?: ComponentType<any>
8934
+ diff?: ComponentType<any>
8935
+ field?: ComponentType<any>
8936
+ input?: ComponentType<any>
8937
+ item?: ComponentType<any>
8938
+ preview?: ComponentType<any>
8939
+ }
8940
+ }
8941
+
8942
+ /** @public */
8943
+ declare interface TypedObject {
8944
+ [key: string]: unknown
8945
+ _type: string
8946
+ }
8947
+
8948
+ /**
8949
+ * Represents a reference to another type registered top-level in your schema.
8950
+ *
8951
+ * @public
8952
+ */
8953
+ declare interface TypeReference {
8954
+ type: string
8955
+ name?: string
8956
+ icon?: ComponentType | ReactNode
8957
+ options?: {
8958
+ [key: string]: unknown
8959
+ }
8960
+ }
8961
+
6785
8962
  /**
6786
8963
  * The editor performed a undo history step
6787
8964
  * @beta */
@@ -6802,6 +8979,31 @@ declare type UnsetEvent = {
6802
8979
  previousValue: Array<PortableTextBlock>
6803
8980
  }
6804
8981
 
8982
+ /** @public */
8983
+ declare interface UriValidationOptions {
8984
+ scheme?: (string | RegExp) | Array<string | RegExp>
8985
+ allowRelative?: boolean
8986
+ relativeOnly?: boolean
8987
+ allowCredentials?: boolean
8988
+ }
8989
+
8990
+ /** @public */
8991
+ declare interface UrlDefinition extends BaseSchemaDefinition {
8992
+ type: 'url'
8993
+ options?: UrlOptions
8994
+ placeholder?: string
8995
+ validation?: ValidationBuilder<UrlRule, string>
8996
+ initialValue?: InitialValueProperty<any, string>
8997
+ }
8998
+
8999
+ /** @public */
9000
+ declare interface UrlOptions extends BaseSchemaTypeOptions {}
9001
+
9002
+ /** @public */
9003
+ declare interface UrlRule extends RuleDef<UrlRule, string> {
9004
+ uri(options: UriValidationOptions): UrlRule
9005
+ }
9006
+
6805
9007
  /**
6806
9008
  * @public
6807
9009
  * Get the current editor context from the `EditorProvider`.
@@ -6863,6 +9065,103 @@ export declare const usePortableTextEditor: () => PortableTextEditor
6863
9065
  */
6864
9066
  export declare const usePortableTextEditorSelection: () => EditorSelection
6865
9067
 
9068
+ /** @public */
9069
+ declare type ValidationBuilder<
9070
+ T extends RuleDef<T, FieldValue>,
9071
+ FieldValue = unknown,
9072
+ > = (rule: T) => RuleBuilder<T, FieldValue>
9073
+
9074
+ /**
9075
+ * A context object passed around during validation. This includes the
9076
+ * `Rule.custom` context.
9077
+ *
9078
+ * e.g.
9079
+ *
9080
+ * ```js
9081
+ * Rule.custom((_, validationContext) => {
9082
+ * // ...
9083
+ * })`
9084
+ * ```
9085
+ *
9086
+ * @public
9087
+ */
9088
+ declare interface ValidationContext {
9089
+ getClient: (options: {apiVersion: string}) => SanityClient
9090
+ schema: Schema
9091
+ parent?: unknown
9092
+ type?: SchemaType
9093
+ document?: SanityDocument
9094
+ path?: Path
9095
+ getDocumentExists?: (options: {id: string}) => Promise<boolean>
9096
+ environment: 'cli' | 'studio'
9097
+ }
9098
+
9099
+ /**
9100
+ * The shape that can be returned from a custom validator to be converted into
9101
+ * a validation marker by the validation logic. Inside of a custom validator,
9102
+ * you can return an array of these in order to specify multiple paths within
9103
+ * an object or array.
9104
+ *
9105
+ * @public
9106
+ */
9107
+ declare interface ValidationError {
9108
+ /**
9109
+ * The message describing why the value is not valid. This message will be
9110
+ * included in the validation markers after validation has finished running.
9111
+ */
9112
+ message: string
9113
+ /**
9114
+ * If writing a custom validator, you can return validation messages to
9115
+ * specific path inside of the current value (object or array) by populating
9116
+ * this `path` prop.
9117
+ *
9118
+ * NOTE: This path is relative to the current value and _not_ relative to
9119
+ * the document.
9120
+ */
9121
+ path?: Path
9122
+ /**
9123
+ * Same as `path` but allows more than one value. If provided, the same
9124
+ * message will create two markers from each path with the same message
9125
+ * provided.
9126
+ *
9127
+ * @deprecated prefer `path`
9128
+ */
9129
+ paths?: Path[]
9130
+ /**
9131
+ * @deprecated Unused. Was used to store the results from `.either()` /`.all()`
9132
+ */
9133
+ children?: ValidationMarker[]
9134
+ /**
9135
+ * @deprecated Unused. Was used to signal if this error came from an `.either()`/`.all()`.
9136
+ */
9137
+ operation?: 'AND' | 'OR'
9138
+ /**
9139
+ * @deprecated Unused. Was relevant when validation error was used as a class.
9140
+ */
9141
+ cloneWithMessage?(message: string): ValidationError
9142
+ }
9143
+
9144
+ /** @public */
9145
+ declare interface ValidationMarker {
9146
+ level: 'error' | 'warning' | 'info'
9147
+ /**
9148
+ * The validation message for this marker. E.g. "Must be greater than 0"
9149
+ */
9150
+ message: string
9151
+ /**
9152
+ * @deprecated use `message` instead
9153
+ */
9154
+ item?: ValidationError
9155
+ /**
9156
+ * The sanity path _relative to the root of the current document_ to this
9157
+ * marker.
9158
+ *
9159
+ * NOTE: Sanity paths may contain keyed segments (i.e. `{_key: string}`) that
9160
+ * are not compatible with deep getters like lodash/get
9161
+ */
9162
+ path: Path
9163
+ }
9164
+
6866
9165
  /**
6867
9166
  * The editor has received a new (props) value
6868
9167
  * @beta */