@portabletext/editor 1.48.6 → 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.
- package/lib/_chunks-cjs/behavior.core.cjs +20 -8
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/behavior.markdown.cjs +5 -5
- package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +137 -90
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs +2 -2
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-text-before.cjs +7 -4
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +63 -47
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +29 -23
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +3 -3
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +15 -15
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +258 -38
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +21 -10
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/behavior.markdown.js +5 -6
- package/lib/_chunks-es/behavior.markdown.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +91 -46
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.get-focus-inline-object.js +1 -2
- package/lib/_chunks-es/selector.get-focus-inline-object.js.map +1 -1
- package/lib/_chunks-es/selector.get-text-before.js +7 -4
- package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
- package/lib/_chunks-es/selector.is-overlapping-selection.js +61 -46
- package/lib/_chunks-es/selector.is-overlapping-selection.js.map +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +30 -26
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
- package/lib/_chunks-es/util.selection-point-to-block-offset.js +15 -16
- package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +258 -38
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/behaviors/index.d.cts +2552 -251
- package/lib/behaviors/index.d.ts +2552 -251
- package/lib/index.cjs +45 -21
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2350 -51
- package/lib/index.d.ts +2350 -51
- package/lib/index.js +44 -21
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +16 -7
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +2328 -23
- package/lib/plugins/index.d.ts +2328 -23
- package/lib/plugins/index.js +16 -7
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs +5 -5
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +2321 -28
- package/lib/selectors/index.d.ts +2321 -28
- package/lib/selectors/index.js +5 -6
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs +30 -24
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +2350 -44
- package/lib/utils/index.d.ts +2350 -44
- package/lib/utils/index.js +30 -24
- package/lib/utils/index.js.map +1 -1
- package/package.json +1 -2
- package/src/behavior-actions/behavior.action.block.unset.ts +1 -1
- package/src/behavior-actions/behavior.action.decorator.add.ts +20 -5
- package/src/behavior-actions/behavior.action.delete.ts +21 -1
- package/src/behaviors/behavior.abstract.decorator.ts +1 -1
- package/src/behaviors/behavior.abstract.delete.ts +1 -1
- package/src/behaviors/behavior.abstract.insert.ts +2 -2
- package/src/behaviors/behavior.abstract.select.ts +16 -4
- package/src/behaviors/behavior.abstract.split.ts +9 -6
- package/src/behaviors/behavior.core.block-objects.ts +5 -5
- package/src/behaviors/behavior.core.insert-break.ts +16 -4
- package/src/behaviors/behavior.core.lists.ts +4 -6
- package/src/behaviors/behavior.decorator-pair.ts +13 -4
- package/src/behaviors/behavior.default.ts +1 -1
- package/src/behaviors/behavior.markdown.ts +5 -5
- package/src/converters/converter.portable-text.ts +1 -1
- package/src/converters/converter.text-html.ts +1 -1
- package/src/converters/converter.text-plain.ts +4 -4
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +10 -2
- package/src/editor/plugins/createWithSchemaTypes.ts +12 -19
- package/src/internal-utils/__tests__/dmpToOperations.test.ts +13 -12
- package/src/internal-utils/drag-selection.ts +16 -4
- package/src/internal-utils/event-position.ts +20 -8
- package/src/internal-utils/parse-blocks.ts +17 -5
- package/src/internal-utils/validateValue.ts +6 -6
- package/src/plugins/plugin.decorator-shortcut.ts +3 -2
- package/src/plugins/plugin.markdown.tsx +2 -0
- package/src/plugins/plugin.one-line.tsx +2 -0
- package/src/selectors/selector.get-active-annotations.ts +5 -2
- package/src/selectors/selector.get-active-list-item.ts +4 -3
- package/src/selectors/selector.get-active-style.ts +4 -3
- package/src/selectors/selector.get-anchor-text-block.ts +3 -6
- package/src/selectors/selector.get-block-offsets.ts +2 -2
- package/src/selectors/selector.get-caret-word-selection.ts +11 -5
- package/src/selectors/selector.get-selected-slice.ts +1 -1
- package/src/selectors/selector.get-selected-spans.ts +11 -15
- package/src/selectors/selector.get-selected-text-blocks.ts +3 -3
- package/src/selectors/selector.get-selection-text.ts +3 -3
- package/src/selectors/selector.get-text-before.ts +5 -2
- package/src/selectors/selector.get-trimmed-selection.ts +20 -14
- package/src/selectors/selector.is-active-annotation.ts +4 -2
- package/src/selectors/selector.is-active-decorator.test.ts +3 -3
- package/src/selectors/selector.is-at-the-end-of-block.ts +4 -1
- package/src/selectors/selector.is-at-the-start-of-block.ts +4 -1
- package/src/selectors/selector.is-point-after-selection.ts +7 -6
- package/src/selectors/selector.is-point-before-selection.ts +7 -6
- package/src/selectors/selector.is-selecting-entire-blocks.ts +8 -2
- package/src/selectors/selectors.ts +25 -28
- package/src/utils/util.block-offset-to-block-selection-point.ts +4 -4
- package/src/utils/util.block-offset-to-selection-point.ts +5 -5
- package/src/utils/util.block-offset.test.ts +219 -156
- package/src/utils/util.block-offset.ts +14 -17
- package/src/utils/util.block-offsets-to-selection.ts +5 -5
- package/src/utils/util.child-selection-point-to-block-offset.ts +7 -10
- package/src/utils/util.get-block-end-point.ts +15 -15
- package/src/utils/util.get-block-start-point.ts +13 -12
- package/src/utils/util.is-empty-text-block.ts +9 -8
- package/src/utils/util.selection-point-to-block-offset.ts +4 -4
- package/src/utils/util.slice-blocks.test.ts +178 -121
- package/src/utils/util.slice-blocks.ts +25 -24
- package/src/utils/util.split-text-block.ts +18 -12
- package/lib/_chunks-cjs/parse-blocks.cjs +0 -205
- package/lib/_chunks-cjs/parse-blocks.cjs.map +0 -1
- package/lib/_chunks-es/parse-blocks.js +0 -206
- package/lib/_chunks-es/parse-blocks.js.map +0 -1
- package/src/behavior-actions/behavior.guards.ts +0 -24
package/lib/plugins/index.d.ts
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import type {Patch} from '@portabletext/patches'
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
PortableTextBlock,
|
|
11
|
-
PortableTextChild,
|
|
12
|
-
PortableTextListBlock,
|
|
13
|
-
PortableTextObject,
|
|
14
|
-
PortableTextSpan,
|
|
15
|
-
PortableTextTextBlock,
|
|
16
|
-
} from '@sanity/types'
|
|
2
|
+
import {ClientPerspective, SanityClient} from '@sanity/client'
|
|
3
|
+
import {
|
|
4
|
+
ComponentType,
|
|
5
|
+
ElementType,
|
|
6
|
+
JSX,
|
|
7
|
+
default as React_2,
|
|
8
|
+
ReactNode,
|
|
9
|
+
} from 'react'
|
|
17
10
|
import type {
|
|
18
11
|
FocusEvent as FocusEvent_2,
|
|
19
12
|
KeyboardEvent as KeyboardEvent_2,
|
|
20
13
|
} from 'react'
|
|
21
|
-
import {JSX, default as React_2} from 'react'
|
|
22
14
|
import type {Descendant, Operation, TextUnit} from 'slate'
|
|
23
15
|
import type {DOMNode} from 'slate-dom'
|
|
24
16
|
import type {ReactEditor} from 'slate-react'
|
|
@@ -216,6 +208,277 @@ declare const abstractBehaviorEventTypes: readonly [
|
|
|
216
208
|
'style.toggle',
|
|
217
209
|
]
|
|
218
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Types of array actions that can be performed
|
|
213
|
+
* @beta
|
|
214
|
+
*/
|
|
215
|
+
declare type ArrayActionName =
|
|
216
|
+
/**
|
|
217
|
+
* Add any item to the array at any position
|
|
218
|
+
*/
|
|
219
|
+
| 'add'
|
|
220
|
+
/**
|
|
221
|
+
* Add item after an existing item
|
|
222
|
+
*/
|
|
223
|
+
| 'addBefore'
|
|
224
|
+
/**
|
|
225
|
+
* Add item after an existing item
|
|
226
|
+
*/
|
|
227
|
+
| 'addAfter'
|
|
228
|
+
/**
|
|
229
|
+
* Remove any item
|
|
230
|
+
*/
|
|
231
|
+
| 'remove'
|
|
232
|
+
/**
|
|
233
|
+
* Duplicate item
|
|
234
|
+
*/
|
|
235
|
+
| 'duplicate'
|
|
236
|
+
/**
|
|
237
|
+
* Copy item
|
|
238
|
+
*/
|
|
239
|
+
| 'copy'
|
|
240
|
+
|
|
241
|
+
/** @public */
|
|
242
|
+
declare interface ArrayDefinition extends BaseSchemaDefinition {
|
|
243
|
+
type: 'array'
|
|
244
|
+
of: ArrayOfType[]
|
|
245
|
+
initialValue?: InitialValueProperty<any, unknown[]>
|
|
246
|
+
validation?: ValidationBuilder<ArrayRule<unknown[]>, unknown[]>
|
|
247
|
+
options?: ArrayOptions
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** @public */
|
|
251
|
+
declare type ArrayOfEntry<T> = Omit<T, 'name' | 'hidden'> & {
|
|
252
|
+
name?: string
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** @public */
|
|
256
|
+
declare type ArrayOfType<
|
|
257
|
+
TType extends IntrinsicTypeName = IntrinsicTypeName,
|
|
258
|
+
TAlias extends IntrinsicTypeName | undefined = undefined,
|
|
259
|
+
> =
|
|
260
|
+
| IntrinsicArrayOfDefinition[TType]
|
|
261
|
+
| ArrayOfEntry<TypeAliasDefinition<string, TAlias>>
|
|
262
|
+
|
|
263
|
+
/** @public */
|
|
264
|
+
declare interface ArrayOptions<V = unknown>
|
|
265
|
+
extends SearchConfiguration,
|
|
266
|
+
BaseSchemaTypeOptions {
|
|
267
|
+
list?: TitledListValue<V>[] | V[]
|
|
268
|
+
layout?: 'list' | 'tags' | 'grid'
|
|
269
|
+
/** @deprecated This option does not have any effect anymore */
|
|
270
|
+
direction?: 'horizontal' | 'vertical'
|
|
271
|
+
sortable?: boolean
|
|
272
|
+
modal?: {
|
|
273
|
+
type?: 'dialog' | 'popover'
|
|
274
|
+
width?: number | 'auto'
|
|
275
|
+
}
|
|
276
|
+
/** @alpha This API may change */
|
|
277
|
+
insertMenu?: InsertMenuOptions
|
|
278
|
+
/**
|
|
279
|
+
* A boolean flag to enable or disable tree editing for the array.
|
|
280
|
+
* If there are any nested arrays, they will inherit this value.
|
|
281
|
+
* @deprecated tree editing beta feature has been disabled
|
|
282
|
+
*/
|
|
283
|
+
treeEditing?: boolean
|
|
284
|
+
/**
|
|
285
|
+
* A list of array actions to disable
|
|
286
|
+
* Possible options are defined by {@link ArrayActionName}
|
|
287
|
+
* @beta
|
|
288
|
+
*/
|
|
289
|
+
disableActions?: ArrayActionName[]
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** @public */
|
|
293
|
+
declare interface ArrayRule<Value> extends RuleDef<ArrayRule<Value>, Value> {
|
|
294
|
+
min: (length: number | FieldReference) => ArrayRule<Value>
|
|
295
|
+
max: (length: number | FieldReference) => ArrayRule<Value>
|
|
296
|
+
length: (length: number | FieldReference) => ArrayRule<Value>
|
|
297
|
+
unique: () => ArrayRule<Value>
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** @public */
|
|
301
|
+
declare interface ArraySchemaType<V = unknown> extends BaseSchemaType {
|
|
302
|
+
jsonType: 'array'
|
|
303
|
+
of: (Exclude<SchemaType, ArraySchemaType> | ReferenceSchemaType)[]
|
|
304
|
+
options?: ArrayOptions<V> & {
|
|
305
|
+
layout?: V extends string ? 'tag' : 'grid'
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** @public */
|
|
310
|
+
declare interface Asset extends SanityDocument {
|
|
311
|
+
url: string
|
|
312
|
+
path: string
|
|
313
|
+
assetId: string
|
|
314
|
+
extension: string
|
|
315
|
+
mimeType: string
|
|
316
|
+
sha1hash: string
|
|
317
|
+
size: number
|
|
318
|
+
originalFilename?: string
|
|
319
|
+
label?: string
|
|
320
|
+
title?: string
|
|
321
|
+
description?: string
|
|
322
|
+
creditLine?: string
|
|
323
|
+
source?: AssetSourceSpec
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** @public */
|
|
327
|
+
declare type AssetFromSource = {
|
|
328
|
+
kind: 'assetDocumentId' | 'file' | 'base64' | 'url'
|
|
329
|
+
value: string | File_2
|
|
330
|
+
assetDocumentProps?: ImageAsset
|
|
331
|
+
mediaLibraryProps?: {
|
|
332
|
+
mediaLibraryId: string
|
|
333
|
+
assetId: string
|
|
334
|
+
assetInstanceId: string
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** @public */
|
|
339
|
+
declare interface AssetSource {
|
|
340
|
+
name: string
|
|
341
|
+
/** @deprecated provide `i18nKey` instead */
|
|
342
|
+
title?: string
|
|
343
|
+
i18nKey?: string
|
|
344
|
+
component: ComponentType<AssetSourceComponentProps>
|
|
345
|
+
icon?: ComponentType<EmptyProps>
|
|
346
|
+
/** @beta */
|
|
347
|
+
uploader?: AssetSourceUploader
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/** @public */
|
|
351
|
+
declare interface AssetSourceComponentProps {
|
|
352
|
+
action?: 'select' | 'upload'
|
|
353
|
+
assetSource: AssetSource
|
|
354
|
+
assetType?: 'file' | 'image'
|
|
355
|
+
accept: string
|
|
356
|
+
selectionType: 'single'
|
|
357
|
+
dialogHeaderTitle?: React.ReactNode
|
|
358
|
+
selectedAssets: Asset[]
|
|
359
|
+
onClose: () => void
|
|
360
|
+
onSelect: (assetFromSource: AssetFromSource[]) => void
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** @public */
|
|
364
|
+
declare interface AssetSourceSpec {
|
|
365
|
+
id: string
|
|
366
|
+
name: string
|
|
367
|
+
url?: string
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** @beta */
|
|
371
|
+
declare interface AssetSourceUploader {
|
|
372
|
+
upload(
|
|
373
|
+
files: globalThis.File[],
|
|
374
|
+
options?: {
|
|
375
|
+
/**
|
|
376
|
+
* The schema type of the field the asset is being uploaded to.
|
|
377
|
+
* May be of interest to the uploader to read file and image options.
|
|
378
|
+
*/
|
|
379
|
+
schemaType?: SchemaType
|
|
380
|
+
/**
|
|
381
|
+
* The uploader may send patches directly to the field
|
|
382
|
+
* Typed 'unknown' as we don't have patch definitions in sanity/types yet.
|
|
383
|
+
*/
|
|
384
|
+
onChange?: (patch: unknown) => void
|
|
385
|
+
},
|
|
386
|
+
): AssetSourceUploadFile[]
|
|
387
|
+
/**
|
|
388
|
+
* Abort the upload of a file
|
|
389
|
+
*/
|
|
390
|
+
abort(file?: AssetSourceUploadFile): void
|
|
391
|
+
/**
|
|
392
|
+
* Get the files that are currently being uploaded
|
|
393
|
+
*/
|
|
394
|
+
getFiles(): AssetSourceUploadFile[]
|
|
395
|
+
/**
|
|
396
|
+
* Subscribe to upload events from the uploader
|
|
397
|
+
*/
|
|
398
|
+
subscribe(subscriber: (event: AssetSourceUploadEvent) => void): () => void
|
|
399
|
+
/**
|
|
400
|
+
* Update the status of a file. Will be emitted to subscribers.
|
|
401
|
+
*/
|
|
402
|
+
updateFile(
|
|
403
|
+
fileId: string,
|
|
404
|
+
data: {
|
|
405
|
+
progress?: number
|
|
406
|
+
status?: string
|
|
407
|
+
error?: Error
|
|
408
|
+
},
|
|
409
|
+
): void
|
|
410
|
+
/**
|
|
411
|
+
* Reset the uploader (clear files). Should be called by the uploader when all files are done.
|
|
412
|
+
*/
|
|
413
|
+
reset(): void
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/** @beta */
|
|
417
|
+
declare type AssetSourceUploadEvent =
|
|
418
|
+
| AssetSourceUploadEventProgress
|
|
419
|
+
| AssetSourceUploadEventStatus
|
|
420
|
+
| AssetSourceUploadEventAllComplete
|
|
421
|
+
| AssetSourceUploadEventError
|
|
422
|
+
| AssetSourceUploadEventAbort
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Emitted when all files are done, either successfully, aborted or with errors
|
|
426
|
+
* @beta */
|
|
427
|
+
declare type AssetSourceUploadEventAbort = {
|
|
428
|
+
type: 'abort'
|
|
429
|
+
/**
|
|
430
|
+
* Files aborted
|
|
431
|
+
*/
|
|
432
|
+
files: AssetSourceUploadFile[]
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Emitted when all files are done, either successfully, aborted or with errors
|
|
437
|
+
* @beta */
|
|
438
|
+
declare type AssetSourceUploadEventAllComplete = {
|
|
439
|
+
type: 'all-complete'
|
|
440
|
+
files: AssetSourceUploadFile[]
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Emitted when all files are done, either successfully, aborted or with errors
|
|
445
|
+
* @beta */
|
|
446
|
+
declare type AssetSourceUploadEventError = {
|
|
447
|
+
type: 'error'
|
|
448
|
+
/**
|
|
449
|
+
* Files errored
|
|
450
|
+
*/
|
|
451
|
+
files: AssetSourceUploadFile[]
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Emitted when a file upload is progressing
|
|
456
|
+
* @beta */
|
|
457
|
+
declare type AssetSourceUploadEventProgress = {
|
|
458
|
+
type: 'progress'
|
|
459
|
+
file: AssetSourceUploadFile
|
|
460
|
+
progress: number
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Emitted when a file upload is changing status
|
|
465
|
+
* @beta */
|
|
466
|
+
declare type AssetSourceUploadEventStatus = {
|
|
467
|
+
type: 'status'
|
|
468
|
+
file: AssetSourceUploadFile
|
|
469
|
+
status: AssetSourceUploadFile['status']
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/** @beta */
|
|
473
|
+
declare interface AssetSourceUploadFile {
|
|
474
|
+
id: string
|
|
475
|
+
file: globalThis.File
|
|
476
|
+
progress: number
|
|
477
|
+
status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted'
|
|
478
|
+
error?: Error
|
|
479
|
+
result?: unknown
|
|
480
|
+
}
|
|
481
|
+
|
|
219
482
|
/**
|
|
220
483
|
* @public
|
|
221
484
|
*/
|
|
@@ -224,6 +487,60 @@ declare type BaseDefinition = {
|
|
|
224
487
|
title?: string
|
|
225
488
|
}
|
|
226
489
|
|
|
490
|
+
/** @public */
|
|
491
|
+
declare interface BaseSchemaDefinition {
|
|
492
|
+
name: string
|
|
493
|
+
title?: string
|
|
494
|
+
description?: string | React.JSX.Element
|
|
495
|
+
hidden?: ConditionalProperty
|
|
496
|
+
readOnly?: ConditionalProperty
|
|
497
|
+
icon?: ComponentType | ReactNode
|
|
498
|
+
validation?: unknown
|
|
499
|
+
initialValue?: unknown
|
|
500
|
+
deprecated?: DeprecatedProperty
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/** @public */
|
|
504
|
+
declare interface BaseSchemaType extends Partial<DeprecationConfiguration> {
|
|
505
|
+
name: string
|
|
506
|
+
title?: string
|
|
507
|
+
description?: string
|
|
508
|
+
type?: SchemaType
|
|
509
|
+
liveEdit?: boolean
|
|
510
|
+
readOnly?: ConditionalProperty
|
|
511
|
+
hidden?: ConditionalProperty
|
|
512
|
+
icon?: ComponentType
|
|
513
|
+
initialValue?: InitialValueProperty<any, any>
|
|
514
|
+
validation?: SchemaValidationValue
|
|
515
|
+
preview?: PreviewConfig
|
|
516
|
+
/** @beta */
|
|
517
|
+
components?: {
|
|
518
|
+
block?: ComponentType<any>
|
|
519
|
+
inlineBlock?: ComponentType<any>
|
|
520
|
+
annotation?: ComponentType<any>
|
|
521
|
+
diff?: ComponentType<any>
|
|
522
|
+
field?: ComponentType<any>
|
|
523
|
+
input?: ComponentType<any>
|
|
524
|
+
item?: ComponentType<any>
|
|
525
|
+
preview?: ComponentType<any>
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* @deprecated This will be removed.
|
|
529
|
+
*/
|
|
530
|
+
placeholder?: string
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* `BaseOptions` applies to all type options.
|
|
535
|
+
*
|
|
536
|
+
* It can be extended by interface declaration merging in plugins to provide generic options to all types and fields.
|
|
537
|
+
*
|
|
538
|
+
* @public
|
|
539
|
+
* */
|
|
540
|
+
declare interface BaseSchemaTypeOptions {
|
|
541
|
+
sanityCreate?: SanityCreateOptions
|
|
542
|
+
}
|
|
543
|
+
|
|
227
544
|
/**
|
|
228
545
|
* @beta
|
|
229
546
|
*/
|
|
@@ -316,6 +633,142 @@ export declare function BehaviorPlugin(props: {
|
|
|
316
633
|
behaviors: Array<Behavior>
|
|
317
634
|
}): null
|
|
318
635
|
|
|
636
|
+
/**
|
|
637
|
+
* Schema definition for text block decorators.
|
|
638
|
+
*
|
|
639
|
+
* @public
|
|
640
|
+
* @example The default set of decorators
|
|
641
|
+
* ```ts
|
|
642
|
+
* {
|
|
643
|
+
* name: 'blockContent',
|
|
644
|
+
* title: 'Content',
|
|
645
|
+
* type: 'array',
|
|
646
|
+
* of: [
|
|
647
|
+
* {
|
|
648
|
+
* type: 'block',
|
|
649
|
+
* marks: {
|
|
650
|
+
* decorators: [
|
|
651
|
+
* {title: 'Strong', value: 'strong'},
|
|
652
|
+
* {title: 'Emphasis', value: 'em'},
|
|
653
|
+
* {title: 'Underline', value: 'underline'},
|
|
654
|
+
* {title: 'Strike', value: 'strike'},
|
|
655
|
+
* {title: 'Code', value: 'code'},
|
|
656
|
+
* ]
|
|
657
|
+
* }
|
|
658
|
+
* }
|
|
659
|
+
* ]
|
|
660
|
+
* }
|
|
661
|
+
* ```
|
|
662
|
+
*/
|
|
663
|
+
declare interface BlockDecoratorDefinition {
|
|
664
|
+
title: string
|
|
665
|
+
i18nTitleKey?: string
|
|
666
|
+
value: string
|
|
667
|
+
icon?: ReactNode | ComponentType
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Schema definition for text blocks.
|
|
672
|
+
*
|
|
673
|
+
* @public
|
|
674
|
+
* @example the default block definition
|
|
675
|
+
* ```ts
|
|
676
|
+
* {
|
|
677
|
+
* name: 'blockContent',
|
|
678
|
+
* title: 'Content',
|
|
679
|
+
* type: 'array',
|
|
680
|
+
* of: [
|
|
681
|
+
* {
|
|
682
|
+
* type: 'block',
|
|
683
|
+
* marks: {
|
|
684
|
+
* decorators: [
|
|
685
|
+
* {title: 'Strong', value: 'strong'},
|
|
686
|
+
* {title: 'Emphasis', value: 'em'},
|
|
687
|
+
* {title: 'Underline', value: 'underline'},
|
|
688
|
+
* {title: 'Strike', value: 'strike'},
|
|
689
|
+
* {title: 'Code', value: 'code'},
|
|
690
|
+
* ],
|
|
691
|
+
* annotations: [
|
|
692
|
+
* {
|
|
693
|
+
* type: 'object',
|
|
694
|
+
* name: 'link',
|
|
695
|
+
* fields: [
|
|
696
|
+
* {
|
|
697
|
+
* type: 'string',
|
|
698
|
+
* name: 'href',
|
|
699
|
+
* },
|
|
700
|
+
* ],
|
|
701
|
+
* },
|
|
702
|
+
* ]
|
|
703
|
+
* },
|
|
704
|
+
* styles: [
|
|
705
|
+
* {title: 'Normal', value: 'normal'},
|
|
706
|
+
* {title: 'H1', value: 'h1'},
|
|
707
|
+
* {title: 'H2', value: 'h2'},
|
|
708
|
+
* {title: 'H3', value: 'h3'},
|
|
709
|
+
* {title: 'H4', value: 'h4'},
|
|
710
|
+
* {title: 'H5', value: 'h5'},
|
|
711
|
+
* {title: 'H6', value: 'h6'},
|
|
712
|
+
* {title: 'Quote', value: 'blockquote'}
|
|
713
|
+
* ],
|
|
714
|
+
* lists: [
|
|
715
|
+
* {title: 'Bullet', value: 'bullet'},
|
|
716
|
+
* {title: 'Number', value: 'number'},
|
|
717
|
+
* ],
|
|
718
|
+
* },
|
|
719
|
+
* ]
|
|
720
|
+
* }
|
|
721
|
+
* ```
|
|
722
|
+
*/
|
|
723
|
+
declare interface BlockDefinition extends BaseSchemaDefinition {
|
|
724
|
+
type: 'block'
|
|
725
|
+
styles?: BlockStyleDefinition[]
|
|
726
|
+
lists?: BlockListDefinition[]
|
|
727
|
+
marks?: BlockMarksDefinition
|
|
728
|
+
of?: ArrayOfType<'object' | 'reference'>[]
|
|
729
|
+
initialValue?: InitialValueProperty<any, any[]>
|
|
730
|
+
options?: BlockOptions
|
|
731
|
+
validation?: ValidationBuilder<BlockRule, any[]>
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Schema definition for a text block list style.
|
|
736
|
+
*
|
|
737
|
+
* @public
|
|
738
|
+
* @example The defaults lists
|
|
739
|
+
* ```ts
|
|
740
|
+
* {
|
|
741
|
+
* name: 'blockContent',
|
|
742
|
+
* title: 'Content',
|
|
743
|
+
* type: 'array',
|
|
744
|
+
* of: [
|
|
745
|
+
* {
|
|
746
|
+
* type: 'block',
|
|
747
|
+
* lists: [
|
|
748
|
+
* {title: 'Bullet', value: 'bullet'},
|
|
749
|
+
* {title: 'Number', value: 'number'},
|
|
750
|
+
* ]
|
|
751
|
+
* }
|
|
752
|
+
* ]
|
|
753
|
+
* }
|
|
754
|
+
* ```
|
|
755
|
+
*/
|
|
756
|
+
declare interface BlockListDefinition {
|
|
757
|
+
title: string
|
|
758
|
+
i18nTitleKey?: string
|
|
759
|
+
value: string
|
|
760
|
+
icon?: ReactNode | ComponentType
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Schema definition for text block marks (decorators and annotations).
|
|
765
|
+
*
|
|
766
|
+
* @public */
|
|
767
|
+
declare interface BlockMarksDefinition {
|
|
768
|
+
decorators?: BlockDecoratorDefinition[]
|
|
769
|
+
annotations?: ArrayOfType<'object' | 'reference'>[]
|
|
770
|
+
}
|
|
771
|
+
|
|
319
772
|
/**
|
|
320
773
|
* @beta
|
|
321
774
|
*/
|
|
@@ -324,10 +777,108 @@ declare type BlockOffset = {
|
|
|
324
777
|
offset: number
|
|
325
778
|
}
|
|
326
779
|
|
|
780
|
+
/**
|
|
781
|
+
* Schema options for a Block schema definition
|
|
782
|
+
* @public */
|
|
783
|
+
declare interface BlockOptions extends BaseSchemaTypeOptions {
|
|
784
|
+
/**
|
|
785
|
+
* Turn on or off the builtin browser spellchecking. Default is on.
|
|
786
|
+
*/
|
|
787
|
+
spellCheck?: boolean
|
|
788
|
+
unstable_whitespaceOnPasteMode?: 'preserve' | 'normalize' | 'remove'
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/** @public */
|
|
792
|
+
declare interface BlockRule extends RuleDef<BlockRule, any[]> {}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Schema definition for a text block style.
|
|
796
|
+
* A text block may have a block style like 'header', 'normal', 'lead'
|
|
797
|
+
* attached to it, which is stored on the `.style` property for that block.
|
|
798
|
+
*
|
|
799
|
+
* @public
|
|
800
|
+
* @remarks The first defined style will become the default style.´´
|
|
801
|
+
* @example The default set of styles
|
|
802
|
+
* ```ts
|
|
803
|
+
* {
|
|
804
|
+
* name: 'blockContent',
|
|
805
|
+
* title: 'Content',
|
|
806
|
+
* type: 'array',
|
|
807
|
+
* of: [
|
|
808
|
+
* {
|
|
809
|
+
* type: 'block',
|
|
810
|
+
* styles: [
|
|
811
|
+
* {title: 'Normal', value: 'normal'},
|
|
812
|
+
* {title: 'H1', value: 'h1'},
|
|
813
|
+
* {title: 'H2', value: 'h2'},
|
|
814
|
+
* {title: 'H3', value: 'h3'},
|
|
815
|
+
* {title: 'H4', value: 'h4'},
|
|
816
|
+
* {title: 'H5', value: 'h5'},
|
|
817
|
+
* {title: 'H6', value: 'h6'},
|
|
818
|
+
* {title: 'Quote', value: 'blockquote'}
|
|
819
|
+
* ]
|
|
820
|
+
* }
|
|
821
|
+
* ]
|
|
822
|
+
* }
|
|
823
|
+
* ```
|
|
824
|
+
* @example Example of defining a block type with custom styles and render components.
|
|
825
|
+
* ```ts
|
|
826
|
+
* defineArrayMember({
|
|
827
|
+
* type: 'block',
|
|
828
|
+
* styles: [
|
|
829
|
+
* {
|
|
830
|
+
* title: 'Paragraph',
|
|
831
|
+
* value: 'paragraph',
|
|
832
|
+
* component: ParagraphStyle,
|
|
833
|
+
* },
|
|
834
|
+
* {
|
|
835
|
+
* title: 'Lead',
|
|
836
|
+
* value: 'lead',
|
|
837
|
+
* component: LeadStyle,
|
|
838
|
+
* },
|
|
839
|
+
* {
|
|
840
|
+
* title: 'Heading',
|
|
841
|
+
* value: 'heading',
|
|
842
|
+
* component: HeadingStyle,
|
|
843
|
+
* },
|
|
844
|
+
* ],
|
|
845
|
+
* })
|
|
846
|
+
* ```
|
|
847
|
+
*/
|
|
848
|
+
declare interface BlockStyleDefinition {
|
|
849
|
+
title: string
|
|
850
|
+
value: string
|
|
851
|
+
i18nTitleKey?: string
|
|
852
|
+
icon?: ReactNode | ComponentType
|
|
853
|
+
}
|
|
854
|
+
|
|
327
855
|
declare type BlockWithOptionalKey =
|
|
328
856
|
| TextBlockWithOptionalKey
|
|
329
857
|
| ObjectBlockWithOptionalKey
|
|
330
858
|
|
|
859
|
+
/** @public */
|
|
860
|
+
declare interface BooleanDefinition extends BaseSchemaDefinition {
|
|
861
|
+
type: 'boolean'
|
|
862
|
+
options?: BooleanOptions
|
|
863
|
+
initialValue?: InitialValueProperty<any, boolean>
|
|
864
|
+
validation?: ValidationBuilder<BooleanRule, boolean>
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/** @public */
|
|
868
|
+
declare interface BooleanOptions extends BaseSchemaTypeOptions {
|
|
869
|
+
layout?: 'switch' | 'checkbox'
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/** @public */
|
|
873
|
+
declare interface BooleanRule extends RuleDef<BooleanRule, boolean> {}
|
|
874
|
+
|
|
875
|
+
/** @public */
|
|
876
|
+
declare interface BooleanSchemaType extends BaseSchemaType {
|
|
877
|
+
jsonType: 'boolean'
|
|
878
|
+
options?: BooleanOptions
|
|
879
|
+
initialValue?: InitialValueProperty<any, boolean>
|
|
880
|
+
}
|
|
881
|
+
|
|
331
882
|
declare type ClipboardBehaviorEvent =
|
|
332
883
|
| {
|
|
333
884
|
type: StrictExtract<NativeBehaviorEventType, 'clipboard.copy'>
|
|
@@ -351,6 +902,35 @@ declare type ClipboardBehaviorEvent =
|
|
|
351
902
|
position: Pick<EventPosition, 'selection'>
|
|
352
903
|
}
|
|
353
904
|
|
|
905
|
+
/** @public */
|
|
906
|
+
declare interface CollapseOptions {
|
|
907
|
+
collapsed?: boolean
|
|
908
|
+
collapsible?: boolean
|
|
909
|
+
/**
|
|
910
|
+
* @deprecated Use `collapsible` instead
|
|
911
|
+
*/
|
|
912
|
+
collapsable?: boolean
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/** @public */
|
|
916
|
+
declare type ConditionalProperty =
|
|
917
|
+
| boolean
|
|
918
|
+
| ConditionalPropertyCallback
|
|
919
|
+
| undefined
|
|
920
|
+
|
|
921
|
+
/** @public */
|
|
922
|
+
declare type ConditionalPropertyCallback = (
|
|
923
|
+
context: ConditionalPropertyCallbackContext,
|
|
924
|
+
) => boolean
|
|
925
|
+
|
|
926
|
+
/** @public */
|
|
927
|
+
declare interface ConditionalPropertyCallbackContext {
|
|
928
|
+
document: SanityDocument | undefined
|
|
929
|
+
parent: any
|
|
930
|
+
value: any
|
|
931
|
+
currentUser: Omit<CurrentUser, 'role'> | null
|
|
932
|
+
}
|
|
933
|
+
|
|
354
934
|
declare type Converter<TMIMEType extends MIMEType = MIMEType> = {
|
|
355
935
|
mimeType: TMIMEType
|
|
356
936
|
serialize: Serializer<TMIMEType>
|
|
@@ -394,6 +974,46 @@ declare type ConverterEvent<TMIMEType extends MIMEType = MIMEType> =
|
|
|
394
974
|
*/
|
|
395
975
|
export declare function CoreBehaviorsPlugin(): JSX.Element
|
|
396
976
|
|
|
977
|
+
/** @public */
|
|
978
|
+
declare interface CrossDatasetReferenceDefinition extends BaseSchemaDefinition {
|
|
979
|
+
type: 'crossDatasetReference'
|
|
980
|
+
weak?: boolean
|
|
981
|
+
to: {
|
|
982
|
+
type: string
|
|
983
|
+
title?: string
|
|
984
|
+
icon?: ComponentType
|
|
985
|
+
preview?: PreviewConfig
|
|
986
|
+
/**
|
|
987
|
+
* @deprecated Unused. Configuring search is no longer supported.
|
|
988
|
+
*/
|
|
989
|
+
__experimental_search?: {
|
|
990
|
+
path: string | string[]
|
|
991
|
+
weight?: number
|
|
992
|
+
mapWith?: string
|
|
993
|
+
}[]
|
|
994
|
+
}[]
|
|
995
|
+
dataset: string
|
|
996
|
+
studioUrl?: (document: {id: string; type?: string}) => string | null
|
|
997
|
+
tokenId?: string
|
|
998
|
+
options?: ReferenceOptions
|
|
999
|
+
/**
|
|
1000
|
+
* @deprecated Cross-project references are no longer supported, only cross-dataset
|
|
1001
|
+
*/
|
|
1002
|
+
projectId?: string
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/** @public */
|
|
1006
|
+
declare interface CurrentUser {
|
|
1007
|
+
id: string
|
|
1008
|
+
name: string
|
|
1009
|
+
email: string
|
|
1010
|
+
profileImage?: string
|
|
1011
|
+
provider?: string
|
|
1012
|
+
/** @deprecated use `roles` instead */
|
|
1013
|
+
role: string
|
|
1014
|
+
roles: Role[]
|
|
1015
|
+
}
|
|
1016
|
+
|
|
397
1017
|
/**
|
|
398
1018
|
* @beta
|
|
399
1019
|
*/
|
|
@@ -418,8 +1038,80 @@ declare type CustomBehaviorEventType<
|
|
|
418
1038
|
TType extends string = '',
|
|
419
1039
|
> = TType extends '' ? `${TNamespace}` : `${TNamespace}.${TType}`
|
|
420
1040
|
|
|
1041
|
+
/** @public */
|
|
1042
|
+
declare interface CustomValidator<T = unknown> {
|
|
1043
|
+
(
|
|
1044
|
+
value: T,
|
|
1045
|
+
context: ValidationContext,
|
|
1046
|
+
): CustomValidatorResult | Promise<CustomValidatorResult>
|
|
1047
|
+
bypassConcurrencyLimit?: boolean
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
/** @public */
|
|
1051
|
+
declare type CustomValidatorResult =
|
|
1052
|
+
| true
|
|
1053
|
+
| string
|
|
1054
|
+
| ValidationError
|
|
1055
|
+
| ValidationError[]
|
|
1056
|
+
| LocalizedValidationMessages
|
|
1057
|
+
|
|
1058
|
+
/** @public */
|
|
1059
|
+
declare interface DateDefinition extends BaseSchemaDefinition {
|
|
1060
|
+
type: 'date'
|
|
1061
|
+
options?: DateOptions
|
|
1062
|
+
placeholder?: string
|
|
1063
|
+
validation?: ValidationBuilder<DateRule, string>
|
|
1064
|
+
initialValue?: InitialValueProperty<any, string>
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
/** @public */
|
|
1068
|
+
declare interface DateOptions extends BaseSchemaTypeOptions {
|
|
1069
|
+
dateFormat?: string
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/** @public */
|
|
1073
|
+
declare interface DateRule extends RuleDef<DateRule, string> {
|
|
1074
|
+
/**
|
|
1075
|
+
* @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
|
|
1076
|
+
*/
|
|
1077
|
+
min: (minDate: string | FieldReference) => DateRule
|
|
1078
|
+
/**
|
|
1079
|
+
* @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
|
|
1080
|
+
*/
|
|
1081
|
+
max: (maxDate: string | FieldReference) => DateRule
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/** @public */
|
|
1085
|
+
declare interface DatetimeDefinition extends BaseSchemaDefinition {
|
|
1086
|
+
type: 'datetime'
|
|
1087
|
+
options?: DatetimeOptions
|
|
1088
|
+
placeholder?: string
|
|
1089
|
+
validation?: ValidationBuilder<DatetimeRule, string>
|
|
1090
|
+
initialValue?: InitialValueProperty<any, string>
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/** @public */
|
|
1094
|
+
declare interface DatetimeOptions extends BaseSchemaTypeOptions {
|
|
1095
|
+
dateFormat?: string
|
|
1096
|
+
timeFormat?: string
|
|
1097
|
+
timeStep?: number
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/** @public */
|
|
1101
|
+
declare interface DatetimeRule extends RuleDef<DatetimeRule, string> {
|
|
1102
|
+
/**
|
|
1103
|
+
* @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
|
|
1104
|
+
*/
|
|
1105
|
+
min: (minDate: string | FieldReference) => DatetimeRule
|
|
1106
|
+
/**
|
|
1107
|
+
* @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
|
|
1108
|
+
*/
|
|
1109
|
+
max: (maxDate: string | FieldReference) => DatetimeRule
|
|
1110
|
+
}
|
|
1111
|
+
|
|
421
1112
|
/**
|
|
422
1113
|
* @beta
|
|
1114
|
+
* @deprecated Install the plugin from `@portabletext/plugin-character-pair-decorator`
|
|
423
1115
|
*/
|
|
424
1116
|
export declare function DecoratorShortcutPlugin(config: {
|
|
425
1117
|
decorator: ({schema}: {schema: EditorSchema}) => string | undefined
|
|
@@ -429,6 +1121,18 @@ export declare function DecoratorShortcutPlugin(config: {
|
|
|
429
1121
|
}
|
|
430
1122
|
}): null
|
|
431
1123
|
|
|
1124
|
+
/** @public */
|
|
1125
|
+
declare interface DeprecatedProperty {
|
|
1126
|
+
reason: string
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* @public
|
|
1131
|
+
*/
|
|
1132
|
+
declare interface DeprecationConfiguration {
|
|
1133
|
+
deprecated: DeprecatedProperty
|
|
1134
|
+
}
|
|
1135
|
+
|
|
432
1136
|
declare type Deserializer<TMIMEType extends MIMEType> = ({
|
|
433
1137
|
snapshot,
|
|
434
1138
|
event,
|
|
@@ -441,13 +1145,47 @@ declare type Deserializer<TMIMEType extends MIMEType> = ({
|
|
|
441
1145
|
'deserialization.success' | 'deserialization.failure'
|
|
442
1146
|
>
|
|
443
1147
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
1148
|
+
/** @public */
|
|
1149
|
+
declare interface DocumentDefinition extends Omit<ObjectDefinition, 'type'> {
|
|
1150
|
+
type: 'document'
|
|
1151
|
+
liveEdit?: boolean
|
|
1152
|
+
/** @beta */
|
|
1153
|
+
orderings?: SortOrdering[]
|
|
1154
|
+
options?: DocumentOptions
|
|
1155
|
+
validation?: ValidationBuilder<DocumentRule, SanityDocument>
|
|
1156
|
+
initialValue?: InitialValueProperty<any, Record<string, unknown>>
|
|
1157
|
+
/** @deprecated Unused. Use the new field-level search config. */
|
|
1158
|
+
__experimental_search?: {
|
|
1159
|
+
path: string
|
|
1160
|
+
weight: number
|
|
1161
|
+
mapWith?: string
|
|
1162
|
+
}[]
|
|
1163
|
+
/** @alpha */
|
|
1164
|
+
__experimental_omnisearch_visibility?: boolean
|
|
1165
|
+
/**
|
|
1166
|
+
* Determines whether the large preview title is displayed in the document pane form
|
|
1167
|
+
* @alpha
|
|
1168
|
+
* */
|
|
1169
|
+
__experimental_formPreviewTitle?: boolean
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* This exists only to allow for extensions using declaration-merging.
|
|
1174
|
+
*
|
|
1175
|
+
* @public
|
|
1176
|
+
*/
|
|
1177
|
+
declare interface DocumentOptions extends BaseSchemaTypeOptions {}
|
|
1178
|
+
|
|
1179
|
+
/** @public */
|
|
1180
|
+
declare interface DocumentRule extends RuleDef<DocumentRule, SanityDocument> {}
|
|
1181
|
+
|
|
1182
|
+
declare type DragBehaviorEvent =
|
|
1183
|
+
| {
|
|
1184
|
+
type: StrictExtract<NativeBehaviorEventType, 'drag.dragstart'>
|
|
1185
|
+
originEvent: {
|
|
1186
|
+
dataTransfer: DataTransfer
|
|
1187
|
+
}
|
|
1188
|
+
position: Pick<EventPosition, 'selection'>
|
|
451
1189
|
}
|
|
452
1190
|
| {
|
|
453
1191
|
type: StrictExtract<NativeBehaviorEventType, 'drag.drag'>
|
|
@@ -5226,6 +5964,31 @@ declare type EditorSnapshot = {
|
|
|
5226
5964
|
}
|
|
5227
5965
|
}
|
|
5228
5966
|
|
|
5967
|
+
/** @public */
|
|
5968
|
+
declare interface EmailDefinition extends BaseSchemaDefinition {
|
|
5969
|
+
type: 'email'
|
|
5970
|
+
options?: EmailOptions
|
|
5971
|
+
placeholder?: string
|
|
5972
|
+
validation?: ValidationBuilder<EmailRule, string>
|
|
5973
|
+
initialValue?: InitialValueProperty<any, string>
|
|
5974
|
+
}
|
|
5975
|
+
|
|
5976
|
+
/** @public */
|
|
5977
|
+
declare interface EmailOptions extends BaseSchemaTypeOptions {}
|
|
5978
|
+
|
|
5979
|
+
/** @public */
|
|
5980
|
+
declare interface EmailRule extends RuleDef<EmailRule, string> {}
|
|
5981
|
+
|
|
5982
|
+
/** @public */
|
|
5983
|
+
declare interface EmptyProps {}
|
|
5984
|
+
|
|
5985
|
+
/** @public */
|
|
5986
|
+
declare interface EnumListProps<V = unknown> {
|
|
5987
|
+
list?: Array<TitledListValue<V> | V>
|
|
5988
|
+
layout?: 'radio' | 'dropdown'
|
|
5989
|
+
direction?: 'horizontal' | 'vertical'
|
|
5990
|
+
}
|
|
5991
|
+
|
|
5229
5992
|
/**
|
|
5230
5993
|
* @public
|
|
5231
5994
|
* Listen for events emitted by the editor. Must be used inside `EditorProvider`. Events available include:
|
|
@@ -5359,6 +6122,194 @@ declare type ExternalEditorEvent =
|
|
|
5359
6122
|
declare type ExtractNamespace<TType extends string> =
|
|
5360
6123
|
TType extends `${infer Namespace}.${string}` ? Namespace : TType
|
|
5361
6124
|
|
|
6125
|
+
/**
|
|
6126
|
+
* The shape of a field definition. Note, it's recommended to use the
|
|
6127
|
+
* `defineField` function instead of using this type directly.
|
|
6128
|
+
*
|
|
6129
|
+
* Where `defineField` infers the exact field type,
|
|
6130
|
+
* FieldDefinition is a compromise union of all types a field can have.
|
|
6131
|
+
*
|
|
6132
|
+
* A field definition can be a reference to another registered top-level type
|
|
6133
|
+
* or a inline type definition.
|
|
6134
|
+
*
|
|
6135
|
+
* @public
|
|
6136
|
+
*/
|
|
6137
|
+
declare type FieldDefinition<
|
|
6138
|
+
TType extends IntrinsicTypeName = IntrinsicTypeName,
|
|
6139
|
+
TAlias extends IntrinsicTypeName | undefined = undefined,
|
|
6140
|
+
> = (InlineFieldDefinition[TType] | TypeAliasDefinition<string, TAlias>) &
|
|
6141
|
+
FieldDefinitionBase
|
|
6142
|
+
|
|
6143
|
+
/** @public */
|
|
6144
|
+
declare interface FieldDefinitionBase {
|
|
6145
|
+
fieldset?: string
|
|
6146
|
+
group?: string | string[]
|
|
6147
|
+
}
|
|
6148
|
+
|
|
6149
|
+
/** @public */
|
|
6150
|
+
declare interface FieldGroup {
|
|
6151
|
+
name: string
|
|
6152
|
+
icon?: ComponentType
|
|
6153
|
+
title?: string
|
|
6154
|
+
description?: string
|
|
6155
|
+
i18n?: I18nTextRecord<'title'>
|
|
6156
|
+
hidden?: ConditionalProperty
|
|
6157
|
+
default?: boolean
|
|
6158
|
+
fields?: ObjectField[]
|
|
6159
|
+
}
|
|
6160
|
+
|
|
6161
|
+
/** @public */
|
|
6162
|
+
declare type FieldGroupDefinition = {
|
|
6163
|
+
name: string
|
|
6164
|
+
title?: string
|
|
6165
|
+
hidden?: ConditionalProperty
|
|
6166
|
+
icon?: ComponentType
|
|
6167
|
+
default?: boolean
|
|
6168
|
+
i18n?: I18nTextRecord<'title'>
|
|
6169
|
+
}
|
|
6170
|
+
|
|
6171
|
+
/**
|
|
6172
|
+
* Holds a reference to a different field
|
|
6173
|
+
* NOTE: Only use this through {@link Rule.valueOfField}
|
|
6174
|
+
*
|
|
6175
|
+
* @public
|
|
6176
|
+
*/
|
|
6177
|
+
declare interface FieldReference {
|
|
6178
|
+
type: symbol
|
|
6179
|
+
path: string | string[]
|
|
6180
|
+
}
|
|
6181
|
+
|
|
6182
|
+
/** @public */
|
|
6183
|
+
declare type FieldRules = {
|
|
6184
|
+
[fieldKey: string]: SchemaValidationValue
|
|
6185
|
+
}
|
|
6186
|
+
|
|
6187
|
+
/** @public */
|
|
6188
|
+
declare type Fieldset = SingleFieldSet | MultiFieldSet
|
|
6189
|
+
|
|
6190
|
+
/** @public */
|
|
6191
|
+
declare type FieldsetDefinition = {
|
|
6192
|
+
name: string
|
|
6193
|
+
title?: string
|
|
6194
|
+
description?: string
|
|
6195
|
+
group?: string
|
|
6196
|
+
hidden?: ConditionalProperty
|
|
6197
|
+
readOnly?: ConditionalProperty
|
|
6198
|
+
options?: ObjectOptions
|
|
6199
|
+
}
|
|
6200
|
+
|
|
6201
|
+
/** @public */
|
|
6202
|
+
declare interface File_2 {
|
|
6203
|
+
[key: string]: unknown
|
|
6204
|
+
asset?: Reference
|
|
6205
|
+
}
|
|
6206
|
+
|
|
6207
|
+
/** @public */
|
|
6208
|
+
declare interface FileDefinition
|
|
6209
|
+
extends Omit<
|
|
6210
|
+
ObjectDefinition,
|
|
6211
|
+
'type' | 'fields' | 'options' | 'groups' | 'validation'
|
|
6212
|
+
> {
|
|
6213
|
+
type: 'file'
|
|
6214
|
+
fields?: ObjectDefinition['fields']
|
|
6215
|
+
options?: FileOptions
|
|
6216
|
+
validation?: ValidationBuilder<FileRule, FileValue>
|
|
6217
|
+
initialValue?: InitialValueProperty<any, FileValue>
|
|
6218
|
+
}
|
|
6219
|
+
|
|
6220
|
+
/** @public */
|
|
6221
|
+
declare interface FileOptions extends ObjectOptions {
|
|
6222
|
+
storeOriginalFilename?: boolean
|
|
6223
|
+
accept?: string
|
|
6224
|
+
sources?: AssetSource[]
|
|
6225
|
+
}
|
|
6226
|
+
|
|
6227
|
+
/** @public */
|
|
6228
|
+
declare interface FileRule extends RuleDef<FileRule, FileValue> {
|
|
6229
|
+
/**
|
|
6230
|
+
* Require a file field has an asset.
|
|
6231
|
+
*
|
|
6232
|
+
* @example
|
|
6233
|
+
* ```ts
|
|
6234
|
+
* defineField({
|
|
6235
|
+
* name: 'file',
|
|
6236
|
+
* title: 'File',
|
|
6237
|
+
* type: 'file',
|
|
6238
|
+
* validation: (Rule) => Rule.required().assetRequired(),
|
|
6239
|
+
* })
|
|
6240
|
+
* ```
|
|
6241
|
+
*/
|
|
6242
|
+
assetRequired(): FileRule
|
|
6243
|
+
}
|
|
6244
|
+
|
|
6245
|
+
/** @public */
|
|
6246
|
+
declare interface FileSchemaType extends Omit<ObjectSchemaType, 'options'> {
|
|
6247
|
+
options?: FileOptions
|
|
6248
|
+
}
|
|
6249
|
+
|
|
6250
|
+
/** @public */
|
|
6251
|
+
declare interface FileValue {
|
|
6252
|
+
asset?: Reference
|
|
6253
|
+
[index: string]: unknown
|
|
6254
|
+
}
|
|
6255
|
+
|
|
6256
|
+
/** @public */
|
|
6257
|
+
declare interface GeopointDefinition extends BaseSchemaDefinition {
|
|
6258
|
+
type: 'geopoint'
|
|
6259
|
+
options?: GeopointOptions
|
|
6260
|
+
validation?: ValidationBuilder<GeopointRule, GeopointValue>
|
|
6261
|
+
initialValue?: InitialValueProperty<any, Omit<GeopointValue, '_type'>>
|
|
6262
|
+
}
|
|
6263
|
+
|
|
6264
|
+
/** @public */
|
|
6265
|
+
declare interface GeopointOptions extends BaseSchemaTypeOptions {}
|
|
6266
|
+
|
|
6267
|
+
/** @public */
|
|
6268
|
+
declare interface GeopointRule extends RuleDef<GeopointRule, GeopointValue> {}
|
|
6269
|
+
|
|
6270
|
+
/**
|
|
6271
|
+
* Geographical point representing a pair of latitude and longitude coordinates,
|
|
6272
|
+
* stored as degrees, in the World Geodetic System 1984 (WGS 84) format. Also
|
|
6273
|
+
* includes an optional `alt` property representing the altitude in meters.
|
|
6274
|
+
*
|
|
6275
|
+
* @public
|
|
6276
|
+
*/
|
|
6277
|
+
declare interface GeopointValue {
|
|
6278
|
+
/**
|
|
6279
|
+
* Type of the object. Must be `geopoint`.
|
|
6280
|
+
*/
|
|
6281
|
+
_type: 'geopoint'
|
|
6282
|
+
/**
|
|
6283
|
+
* Latitude in degrees
|
|
6284
|
+
*/
|
|
6285
|
+
lat: number
|
|
6286
|
+
/**
|
|
6287
|
+
* Longitude in degrees
|
|
6288
|
+
*/
|
|
6289
|
+
lng: number
|
|
6290
|
+
/**
|
|
6291
|
+
* Altitude in meters
|
|
6292
|
+
*/
|
|
6293
|
+
alt?: number
|
|
6294
|
+
}
|
|
6295
|
+
|
|
6296
|
+
/** @public */
|
|
6297
|
+
declare interface GlobalDocumentReferenceDefinition
|
|
6298
|
+
extends BaseSchemaDefinition {
|
|
6299
|
+
type: 'globalDocumentReference'
|
|
6300
|
+
weak?: boolean
|
|
6301
|
+
to: {
|
|
6302
|
+
type: string
|
|
6303
|
+
title?: string
|
|
6304
|
+
icon?: ComponentType
|
|
6305
|
+
preview?: PreviewConfig
|
|
6306
|
+
}[]
|
|
6307
|
+
resourceType: string
|
|
6308
|
+
resourceId: string
|
|
6309
|
+
options?: ReferenceOptions
|
|
6310
|
+
studioUrl?: (document: {id: string; type?: string}) => string | null
|
|
6311
|
+
}
|
|
6312
|
+
|
|
5362
6313
|
declare type HasTag = ReturnType<EditorActor['getSnapshot']>['hasTag']
|
|
5363
6314
|
|
|
5364
6315
|
declare interface History_2 {
|
|
@@ -5371,6 +6322,178 @@ declare type HistoryItem = {
|
|
|
5371
6322
|
timestamp: Date
|
|
5372
6323
|
}
|
|
5373
6324
|
|
|
6325
|
+
/** @public */
|
|
6326
|
+
declare interface HotspotOptions {
|
|
6327
|
+
previews?: HotspotPreview[]
|
|
6328
|
+
}
|
|
6329
|
+
|
|
6330
|
+
/** @public */
|
|
6331
|
+
declare interface HotspotPreview {
|
|
6332
|
+
title: string
|
|
6333
|
+
aspectRatio: number
|
|
6334
|
+
}
|
|
6335
|
+
|
|
6336
|
+
/** @public */
|
|
6337
|
+
declare type I18nTextRecord<K extends string> = {
|
|
6338
|
+
[P in K]?: {
|
|
6339
|
+
key: string
|
|
6340
|
+
ns: string
|
|
6341
|
+
}
|
|
6342
|
+
}
|
|
6343
|
+
|
|
6344
|
+
/** @public */
|
|
6345
|
+
declare interface ImageAsset extends Asset {
|
|
6346
|
+
_type: 'sanity.imageAsset'
|
|
6347
|
+
metadata: ImageMetadata
|
|
6348
|
+
}
|
|
6349
|
+
|
|
6350
|
+
/** @public */
|
|
6351
|
+
declare interface ImageCrop {
|
|
6352
|
+
_type?: 'sanity.imageCrop'
|
|
6353
|
+
left: number
|
|
6354
|
+
bottom: number
|
|
6355
|
+
right: number
|
|
6356
|
+
top: number
|
|
6357
|
+
}
|
|
6358
|
+
|
|
6359
|
+
/** @public */
|
|
6360
|
+
declare interface ImageDefinition
|
|
6361
|
+
extends Omit<
|
|
6362
|
+
ObjectDefinition,
|
|
6363
|
+
'type' | 'fields' | 'options' | 'groups' | 'validation'
|
|
6364
|
+
> {
|
|
6365
|
+
type: 'image'
|
|
6366
|
+
fields?: FieldDefinition[]
|
|
6367
|
+
options?: ImageOptions
|
|
6368
|
+
validation?: ValidationBuilder<ImageRule, ImageValue>
|
|
6369
|
+
initialValue?: InitialValueProperty<any, ImageValue>
|
|
6370
|
+
}
|
|
6371
|
+
|
|
6372
|
+
/** @public */
|
|
6373
|
+
declare interface ImageDimensions {
|
|
6374
|
+
_type: 'sanity.imageDimensions'
|
|
6375
|
+
height: number
|
|
6376
|
+
width: number
|
|
6377
|
+
aspectRatio: number
|
|
6378
|
+
}
|
|
6379
|
+
|
|
6380
|
+
/** @public */
|
|
6381
|
+
declare interface ImageHotspot {
|
|
6382
|
+
_type?: 'sanity.imageHotspot'
|
|
6383
|
+
width: number
|
|
6384
|
+
height: number
|
|
6385
|
+
x: number
|
|
6386
|
+
y: number
|
|
6387
|
+
}
|
|
6388
|
+
|
|
6389
|
+
/** @public */
|
|
6390
|
+
declare interface ImageMetadata {
|
|
6391
|
+
[key: string]: unknown
|
|
6392
|
+
_type: 'sanity.imageMetadata'
|
|
6393
|
+
dimensions: ImageDimensions
|
|
6394
|
+
palette?: ImagePalette
|
|
6395
|
+
lqip?: string
|
|
6396
|
+
blurHash?: string
|
|
6397
|
+
hasAlpha: boolean
|
|
6398
|
+
isOpaque: boolean
|
|
6399
|
+
}
|
|
6400
|
+
|
|
6401
|
+
/** @public */
|
|
6402
|
+
declare type ImageMetadataType =
|
|
6403
|
+
| 'blurhash'
|
|
6404
|
+
| 'lqip'
|
|
6405
|
+
| 'palette'
|
|
6406
|
+
| 'exif'
|
|
6407
|
+
| 'image'
|
|
6408
|
+
| 'location'
|
|
6409
|
+
|
|
6410
|
+
/** @public */
|
|
6411
|
+
declare interface ImageOptions extends FileOptions {
|
|
6412
|
+
metadata?: ImageMetadataType[]
|
|
6413
|
+
hotspot?: boolean | HotspotOptions
|
|
6414
|
+
}
|
|
6415
|
+
|
|
6416
|
+
/** @public */
|
|
6417
|
+
declare interface ImagePalette {
|
|
6418
|
+
_type: 'sanity.imagePalette'
|
|
6419
|
+
darkMuted?: ImageSwatch
|
|
6420
|
+
darkVibrant?: ImageSwatch
|
|
6421
|
+
dominant?: ImageSwatch
|
|
6422
|
+
lightMuted?: ImageSwatch
|
|
6423
|
+
lightVibrant?: ImageSwatch
|
|
6424
|
+
muted?: ImageSwatch
|
|
6425
|
+
vibrant?: ImageSwatch
|
|
6426
|
+
}
|
|
6427
|
+
|
|
6428
|
+
/** @public */
|
|
6429
|
+
declare interface ImageRule extends RuleDef<ImageRule, ImageValue> {
|
|
6430
|
+
/**
|
|
6431
|
+
* Require an image field has an asset.
|
|
6432
|
+
*
|
|
6433
|
+
* @example
|
|
6434
|
+
* ```ts
|
|
6435
|
+
* defineField({
|
|
6436
|
+
* name: 'image',
|
|
6437
|
+
* title: 'Image',
|
|
6438
|
+
* type: 'image',
|
|
6439
|
+
* validation: (Rule) => Rule.required().assetRequired(),
|
|
6440
|
+
* })
|
|
6441
|
+
* ```
|
|
6442
|
+
*/
|
|
6443
|
+
assetRequired(): ImageRule
|
|
6444
|
+
}
|
|
6445
|
+
|
|
6446
|
+
/** @public */
|
|
6447
|
+
declare interface ImageSwatch {
|
|
6448
|
+
_type: 'sanity.imagePaletteSwatch'
|
|
6449
|
+
background: string
|
|
6450
|
+
foreground: string
|
|
6451
|
+
population: number
|
|
6452
|
+
title?: string
|
|
6453
|
+
}
|
|
6454
|
+
|
|
6455
|
+
/** @public */
|
|
6456
|
+
declare interface ImageValue extends FileValue {
|
|
6457
|
+
crop?: ImageCrop
|
|
6458
|
+
hotspot?: ImageHotspot
|
|
6459
|
+
[index: string]: unknown
|
|
6460
|
+
}
|
|
6461
|
+
|
|
6462
|
+
/** @public */
|
|
6463
|
+
declare type IndexTuple = [number | '', number | '']
|
|
6464
|
+
|
|
6465
|
+
/** @public */
|
|
6466
|
+
declare type InitialValueProperty<Params, Value> =
|
|
6467
|
+
| Value
|
|
6468
|
+
| InitialValueResolver<Params, Value>
|
|
6469
|
+
| undefined
|
|
6470
|
+
|
|
6471
|
+
/** @public */
|
|
6472
|
+
declare type InitialValueResolver<Params, Value> = (
|
|
6473
|
+
params: Params | undefined,
|
|
6474
|
+
context: InitialValueResolverContext,
|
|
6475
|
+
) => Promise<Value> | Value
|
|
6476
|
+
|
|
6477
|
+
/** @public */
|
|
6478
|
+
declare interface InitialValueResolverContext {
|
|
6479
|
+
projectId: string
|
|
6480
|
+
dataset: string
|
|
6481
|
+
schema: Schema
|
|
6482
|
+
currentUser: CurrentUser | null
|
|
6483
|
+
getClient: (options: {apiVersion: string}) => SanityClient
|
|
6484
|
+
}
|
|
6485
|
+
|
|
6486
|
+
/** @public */
|
|
6487
|
+
declare type InlineFieldDefinition = {
|
|
6488
|
+
[K in keyof IntrinsicDefinitions]: Omit<
|
|
6489
|
+
IntrinsicDefinitions[K],
|
|
6490
|
+
'initialValue' | 'validation'
|
|
6491
|
+
> & {
|
|
6492
|
+
validation?: SchemaValidationValue
|
|
6493
|
+
initialValue?: InitialValueProperty<any, any>
|
|
6494
|
+
}
|
|
6495
|
+
}
|
|
6496
|
+
|
|
5374
6497
|
/**
|
|
5375
6498
|
* Used to represent native InputEvents that hold a DataTransfer object.
|
|
5376
6499
|
*
|
|
@@ -5389,6 +6512,33 @@ declare type InputBehaviorEvent = {
|
|
|
5389
6512
|
}
|
|
5390
6513
|
}
|
|
5391
6514
|
|
|
6515
|
+
/** @alpha This API may change */
|
|
6516
|
+
declare interface InsertMenuOptions {
|
|
6517
|
+
/**
|
|
6518
|
+
* @defaultValue `'auto'`
|
|
6519
|
+
* `filter: 'auto'` automatically turns on filtering if there are more than 5
|
|
6520
|
+
* schema types added to the menu.
|
|
6521
|
+
*/
|
|
6522
|
+
filter?: 'auto' | boolean
|
|
6523
|
+
groups?: Array<{
|
|
6524
|
+
name: string
|
|
6525
|
+
title?: string
|
|
6526
|
+
of?: Array<string>
|
|
6527
|
+
}>
|
|
6528
|
+
/** defaultValue `true` */
|
|
6529
|
+
showIcons?: boolean
|
|
6530
|
+
/** @defaultValue `[{name: 'list'}]` */
|
|
6531
|
+
views?: Array<
|
|
6532
|
+
| {
|
|
6533
|
+
name: 'list'
|
|
6534
|
+
}
|
|
6535
|
+
| {
|
|
6536
|
+
name: 'grid'
|
|
6537
|
+
previewImageUrl?: (schemaTypeName: string) => string | undefined
|
|
6538
|
+
}
|
|
6539
|
+
>
|
|
6540
|
+
}
|
|
6541
|
+
|
|
5392
6542
|
declare type InsertPlacement = 'auto' | 'after' | 'before'
|
|
5393
6543
|
|
|
5394
6544
|
declare type InternalPatchEvent = NamespaceEvent<PatchEvent, 'internal'> & {
|
|
@@ -5396,6 +6546,64 @@ declare type InternalPatchEvent = NamespaceEvent<PatchEvent, 'internal'> & {
|
|
|
5396
6546
|
value: Array<PortableTextBlock>
|
|
5397
6547
|
}
|
|
5398
6548
|
|
|
6549
|
+
/** @public */
|
|
6550
|
+
declare type IntrinsicArrayOfDefinition = {
|
|
6551
|
+
[K in keyof IntrinsicDefinitions]: Omit<
|
|
6552
|
+
ArrayOfEntry<IntrinsicDefinitions[K]>,
|
|
6553
|
+
'validation' | 'initialValue'
|
|
6554
|
+
> & {
|
|
6555
|
+
validation?: SchemaValidationValue
|
|
6556
|
+
initialValue?: InitialValueProperty<any, any>
|
|
6557
|
+
}
|
|
6558
|
+
}
|
|
6559
|
+
|
|
6560
|
+
/**
|
|
6561
|
+
* `IntrinsicDefinitions` is a lookup map for "predefined" schema definitions.
|
|
6562
|
+
* Schema types in `IntrinsicDefinitions` will have good type-completion and type-safety in {@link defineType},
|
|
6563
|
+
* {@link defineField} and {@link defineArrayMember} once the `type` property is provided.
|
|
6564
|
+
*
|
|
6565
|
+
* By default, `IntrinsicDefinitions` contains all standard Sanity schema types (`array`, `string`, `number` ect),
|
|
6566
|
+
* but it is an interface and as such, open for extension.
|
|
6567
|
+
*
|
|
6568
|
+
* This type can be extended using declaration merging; this way new entries can be added.
|
|
6569
|
+
* See {@link defineType} for examples on how this can be accomplished.
|
|
6570
|
+
*
|
|
6571
|
+
* @see defineType
|
|
6572
|
+
*
|
|
6573
|
+
* @public
|
|
6574
|
+
*/
|
|
6575
|
+
declare interface IntrinsicDefinitions {
|
|
6576
|
+
array: ArrayDefinition
|
|
6577
|
+
block: BlockDefinition
|
|
6578
|
+
boolean: BooleanDefinition
|
|
6579
|
+
date: DateDefinition
|
|
6580
|
+
datetime: DatetimeDefinition
|
|
6581
|
+
document: DocumentDefinition
|
|
6582
|
+
file: FileDefinition
|
|
6583
|
+
geopoint: GeopointDefinition
|
|
6584
|
+
image: ImageDefinition
|
|
6585
|
+
number: NumberDefinition
|
|
6586
|
+
object: ObjectDefinition
|
|
6587
|
+
reference: ReferenceDefinition
|
|
6588
|
+
crossDatasetReference: CrossDatasetReferenceDefinition
|
|
6589
|
+
globalDocumentReference: GlobalDocumentReferenceDefinition
|
|
6590
|
+
slug: SlugDefinition
|
|
6591
|
+
string: StringDefinition
|
|
6592
|
+
text: TextDefinition
|
|
6593
|
+
url: UrlDefinition
|
|
6594
|
+
email: EmailDefinition
|
|
6595
|
+
}
|
|
6596
|
+
|
|
6597
|
+
/**
|
|
6598
|
+
* A union of all intrinsic types allowed natively in the schema.
|
|
6599
|
+
*
|
|
6600
|
+
* @see IntrinsicDefinitions
|
|
6601
|
+
*
|
|
6602
|
+
* @public
|
|
6603
|
+
*/
|
|
6604
|
+
declare type IntrinsicTypeName =
|
|
6605
|
+
IntrinsicDefinitions[keyof IntrinsicDefinitions]['type']
|
|
6606
|
+
|
|
5399
6607
|
/**
|
|
5400
6608
|
* The editor has invalid data in the value that can be resolved by the user
|
|
5401
6609
|
* @beta */
|
|
@@ -5435,6 +6643,27 @@ declare type KeyboardBehaviorEvent =
|
|
|
5435
6643
|
>
|
|
5436
6644
|
}
|
|
5437
6645
|
|
|
6646
|
+
/** @public */
|
|
6647
|
+
declare type KeyedSegment = {
|
|
6648
|
+
_key: string
|
|
6649
|
+
}
|
|
6650
|
+
|
|
6651
|
+
/**
|
|
6652
|
+
* Holds localized validation messages for a given field.
|
|
6653
|
+
*
|
|
6654
|
+
* @example Custom message for English (US) and Norwegian (Bokmål):
|
|
6655
|
+
* ```
|
|
6656
|
+
* {
|
|
6657
|
+
* 'en-US': 'Needs to start with a capital letter',
|
|
6658
|
+
* 'no-NB': 'Må starte med stor bokstav',
|
|
6659
|
+
* }
|
|
6660
|
+
* ```
|
|
6661
|
+
* @public
|
|
6662
|
+
*/
|
|
6663
|
+
declare interface LocalizedValidationMessages {
|
|
6664
|
+
[locale: string]: string
|
|
6665
|
+
}
|
|
6666
|
+
|
|
5438
6667
|
/**
|
|
5439
6668
|
* @beta
|
|
5440
6669
|
*/
|
|
@@ -5504,6 +6733,8 @@ declare type MarkdownBehaviorsConfig = {
|
|
|
5504
6733
|
* )
|
|
5505
6734
|
* }
|
|
5506
6735
|
* ```
|
|
6736
|
+
*
|
|
6737
|
+
* @deprecated Install the plugin from `@portabletext/plugin-markdown-shortcuts`
|
|
5507
6738
|
*/
|
|
5508
6739
|
export declare function MarkdownPlugin(props: {
|
|
5509
6740
|
config: MarkdownPluginConfig
|
|
@@ -5530,6 +6761,21 @@ declare type MouseBehaviorEvent = {
|
|
|
5530
6761
|
position: EventPosition
|
|
5531
6762
|
}
|
|
5532
6763
|
|
|
6764
|
+
/** @public */
|
|
6765
|
+
declare interface MultiFieldSet {
|
|
6766
|
+
name: string
|
|
6767
|
+
title?: string
|
|
6768
|
+
description?: string
|
|
6769
|
+
single?: false
|
|
6770
|
+
group?: string | string[]
|
|
6771
|
+
options?: CollapseOptions & {
|
|
6772
|
+
columns?: number
|
|
6773
|
+
}
|
|
6774
|
+
fields: ObjectField[]
|
|
6775
|
+
hidden?: ConditionalProperty
|
|
6776
|
+
readOnly?: ConditionalProperty
|
|
6777
|
+
}
|
|
6778
|
+
|
|
5533
6779
|
/**
|
|
5534
6780
|
* @public
|
|
5535
6781
|
*/
|
|
@@ -5597,10 +6843,114 @@ declare const nativeBehaviorEventTypes: readonly [
|
|
|
5597
6843
|
'mouse.click',
|
|
5598
6844
|
]
|
|
5599
6845
|
|
|
6846
|
+
/** @public */
|
|
6847
|
+
declare interface NumberDefinition extends BaseSchemaDefinition {
|
|
6848
|
+
type: 'number'
|
|
6849
|
+
options?: NumberOptions
|
|
6850
|
+
placeholder?: string
|
|
6851
|
+
validation?: ValidationBuilder<NumberRule, number>
|
|
6852
|
+
initialValue?: InitialValueProperty<any, number>
|
|
6853
|
+
}
|
|
6854
|
+
|
|
6855
|
+
/** @public */
|
|
6856
|
+
declare interface NumberOptions
|
|
6857
|
+
extends EnumListProps<number>,
|
|
6858
|
+
BaseSchemaTypeOptions {}
|
|
6859
|
+
|
|
6860
|
+
/** @public */
|
|
6861
|
+
declare interface NumberRule extends RuleDef<NumberRule, number> {
|
|
6862
|
+
min: (minNumber: number | FieldReference) => NumberRule
|
|
6863
|
+
max: (maxNumber: number | FieldReference) => NumberRule
|
|
6864
|
+
lessThan: (limit: number | FieldReference) => NumberRule
|
|
6865
|
+
greaterThan: (limit: number | FieldReference) => NumberRule
|
|
6866
|
+
integer: () => NumberRule
|
|
6867
|
+
precision: (limit: number | FieldReference) => NumberRule
|
|
6868
|
+
positive: () => NumberRule
|
|
6869
|
+
negative: () => NumberRule
|
|
6870
|
+
}
|
|
6871
|
+
|
|
6872
|
+
/** @public */
|
|
6873
|
+
declare interface NumberSchemaType extends BaseSchemaType {
|
|
6874
|
+
jsonType: 'number'
|
|
6875
|
+
options?: NumberOptions
|
|
6876
|
+
initialValue?: InitialValueProperty<any, number>
|
|
6877
|
+
}
|
|
6878
|
+
|
|
5600
6879
|
declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
|
|
5601
6880
|
_key?: PortableTextObject['_key']
|
|
5602
6881
|
}
|
|
5603
6882
|
|
|
6883
|
+
/** @public */
|
|
6884
|
+
declare interface ObjectDefinition extends BaseSchemaDefinition {
|
|
6885
|
+
type: 'object'
|
|
6886
|
+
/**
|
|
6887
|
+
* Object must have at least one field. This is validated at Studio startup.
|
|
6888
|
+
*/
|
|
6889
|
+
fields: FieldDefinition[]
|
|
6890
|
+
groups?: FieldGroupDefinition[]
|
|
6891
|
+
fieldsets?: FieldsetDefinition[]
|
|
6892
|
+
preview?: PreviewConfig
|
|
6893
|
+
options?: ObjectOptions
|
|
6894
|
+
validation?: ValidationBuilder<ObjectRule, Record<string, unknown>>
|
|
6895
|
+
initialValue?: InitialValueProperty<any, Record<string, unknown>>
|
|
6896
|
+
}
|
|
6897
|
+
|
|
6898
|
+
/** @public */
|
|
6899
|
+
declare interface ObjectField<T extends SchemaType = SchemaType> {
|
|
6900
|
+
name: string
|
|
6901
|
+
fieldset?: string
|
|
6902
|
+
group?: string | string[]
|
|
6903
|
+
type: ObjectFieldType<T>
|
|
6904
|
+
}
|
|
6905
|
+
|
|
6906
|
+
/** @public */
|
|
6907
|
+
declare type ObjectFieldType<T extends SchemaType = SchemaType> = T & {
|
|
6908
|
+
hidden?: ConditionalProperty
|
|
6909
|
+
readOnly?: ConditionalProperty
|
|
6910
|
+
}
|
|
6911
|
+
|
|
6912
|
+
/** @public */
|
|
6913
|
+
declare interface ObjectOptions extends BaseSchemaTypeOptions {
|
|
6914
|
+
collapsible?: boolean
|
|
6915
|
+
collapsed?: boolean
|
|
6916
|
+
columns?: number
|
|
6917
|
+
modal?: {
|
|
6918
|
+
type?: 'dialog' | 'popover'
|
|
6919
|
+
width?: number | number[] | 'auto'
|
|
6920
|
+
}
|
|
6921
|
+
}
|
|
6922
|
+
|
|
6923
|
+
/** @public */
|
|
6924
|
+
declare interface ObjectRule
|
|
6925
|
+
extends RuleDef<ObjectRule, Record<string, unknown>> {}
|
|
6926
|
+
|
|
6927
|
+
/** @public */
|
|
6928
|
+
declare interface ObjectSchemaType extends BaseSchemaType {
|
|
6929
|
+
jsonType: 'object'
|
|
6930
|
+
fields: ObjectField[]
|
|
6931
|
+
groups?: FieldGroup[]
|
|
6932
|
+
fieldsets?: Fieldset[]
|
|
6933
|
+
initialValue?: InitialValueProperty<any, Record<string, unknown>>
|
|
6934
|
+
weak?: boolean
|
|
6935
|
+
/** @deprecated Unused. Use the new field-level search config. */
|
|
6936
|
+
__experimental_search?: {
|
|
6937
|
+
path: (string | number)[]
|
|
6938
|
+
weight: number
|
|
6939
|
+
mapWith?: string
|
|
6940
|
+
}[]
|
|
6941
|
+
/** @alpha */
|
|
6942
|
+
__experimental_omnisearch_visibility?: boolean
|
|
6943
|
+
/** @alpha */
|
|
6944
|
+
__experimental_actions?: string[]
|
|
6945
|
+
/** @alpha */
|
|
6946
|
+
__experimental_formPreviewTitle?: boolean
|
|
6947
|
+
/**
|
|
6948
|
+
* @beta
|
|
6949
|
+
*/
|
|
6950
|
+
orderings?: SortOrdering[]
|
|
6951
|
+
options?: any
|
|
6952
|
+
}
|
|
6953
|
+
|
|
5604
6954
|
/**
|
|
5605
6955
|
* @beta
|
|
5606
6956
|
* Restrict the editor to one line. The plugin takes care of blocking
|
|
@@ -5608,6 +6958,8 @@ declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
|
|
|
5608
6958
|
*
|
|
5609
6959
|
* Place it with as high priority as possible to make sure other plugins don't
|
|
5610
6960
|
* overwrite `insert.*` events before this plugin gets a chance to do so.
|
|
6961
|
+
*
|
|
6962
|
+
* @deprecated Install the plugin from `@portabletext/plugin-one-line`
|
|
5611
6963
|
*/
|
|
5612
6964
|
export declare function OneLinePlugin(): JSX.Element
|
|
5613
6965
|
|
|
@@ -5625,6 +6977,12 @@ declare type PatchEvent = {
|
|
|
5625
6977
|
patch: Patch
|
|
5626
6978
|
}
|
|
5627
6979
|
|
|
6980
|
+
/** @public */
|
|
6981
|
+
declare type Path = PathSegment[]
|
|
6982
|
+
|
|
6983
|
+
/** @public */
|
|
6984
|
+
declare type PathSegment = string | number | KeyedSegment | IndexTuple
|
|
6985
|
+
|
|
5628
6986
|
/**
|
|
5629
6987
|
* @internal
|
|
5630
6988
|
*/
|
|
@@ -5634,6 +6992,18 @@ declare type PickFromUnion<
|
|
|
5634
6992
|
TPickedTags extends TUnion[TTagKey],
|
|
5635
6993
|
> = TUnion extends Record<TTagKey, TPickedTags> ? TUnion : never
|
|
5636
6994
|
|
|
6995
|
+
/** @alpha */
|
|
6996
|
+
declare type PortableTextBlock = PortableTextTextBlock | PortableTextObject
|
|
6997
|
+
|
|
6998
|
+
/** @alpha */
|
|
6999
|
+
declare type PortableTextChild = PortableTextObject | PortableTextSpan
|
|
7000
|
+
|
|
7001
|
+
/** @alpha */
|
|
7002
|
+
declare interface PortableTextListBlock extends PortableTextTextBlock {
|
|
7003
|
+
listItem: string
|
|
7004
|
+
level: number
|
|
7005
|
+
}
|
|
7006
|
+
|
|
5637
7007
|
/** @beta */
|
|
5638
7008
|
declare type PortableTextMemberSchemaTypes = {
|
|
5639
7009
|
annotations: (ObjectSchemaType & {
|
|
@@ -5649,6 +7019,13 @@ declare type PortableTextMemberSchemaTypes = {
|
|
|
5649
7019
|
lists: BlockListDefinition[]
|
|
5650
7020
|
}
|
|
5651
7021
|
|
|
7022
|
+
/** @alpha */
|
|
7023
|
+
declare interface PortableTextObject {
|
|
7024
|
+
_type: string
|
|
7025
|
+
_key: string
|
|
7026
|
+
[other: string]: unknown
|
|
7027
|
+
}
|
|
7028
|
+
|
|
5652
7029
|
declare interface PortableTextSlateEditor extends ReactEditor {
|
|
5653
7030
|
_key: 'editor'
|
|
5654
7031
|
_type: 'editor'
|
|
@@ -5682,6 +7059,162 @@ declare interface PortableTextSlateEditor extends ReactEditor {
|
|
|
5682
7059
|
redo: () => void
|
|
5683
7060
|
}
|
|
5684
7061
|
|
|
7062
|
+
/** @alpha */
|
|
7063
|
+
declare interface PortableTextSpan {
|
|
7064
|
+
_key: string
|
|
7065
|
+
_type: 'span'
|
|
7066
|
+
text: string
|
|
7067
|
+
marks?: string[]
|
|
7068
|
+
}
|
|
7069
|
+
|
|
7070
|
+
/** @alpha */
|
|
7071
|
+
declare interface PortableTextTextBlock<
|
|
7072
|
+
TChild = PortableTextSpan | PortableTextObject,
|
|
7073
|
+
> {
|
|
7074
|
+
_type: string
|
|
7075
|
+
_key: string
|
|
7076
|
+
children: TChild[]
|
|
7077
|
+
markDefs?: PortableTextObject[]
|
|
7078
|
+
listItem?: string
|
|
7079
|
+
style?: string
|
|
7080
|
+
level?: number
|
|
7081
|
+
}
|
|
7082
|
+
|
|
7083
|
+
/** @public */
|
|
7084
|
+
declare interface PrepareViewOptions {
|
|
7085
|
+
/** @beta */
|
|
7086
|
+
ordering?: SortOrdering
|
|
7087
|
+
}
|
|
7088
|
+
|
|
7089
|
+
/** @public */
|
|
7090
|
+
declare interface PreviewConfig<
|
|
7091
|
+
Select extends Record<string, string> = Record<string, string>,
|
|
7092
|
+
PrepareValue extends Record<keyof Select, any> = Record<keyof Select, any>,
|
|
7093
|
+
> {
|
|
7094
|
+
select?: Select
|
|
7095
|
+
prepare?: (
|
|
7096
|
+
value: PrepareValue,
|
|
7097
|
+
viewOptions?: PrepareViewOptions,
|
|
7098
|
+
) => PreviewValue
|
|
7099
|
+
}
|
|
7100
|
+
|
|
7101
|
+
/** @public */
|
|
7102
|
+
declare interface PreviewValue {
|
|
7103
|
+
_id?: string
|
|
7104
|
+
_createdAt?: string
|
|
7105
|
+
_updatedAt?: string
|
|
7106
|
+
title?: string
|
|
7107
|
+
subtitle?: string
|
|
7108
|
+
description?: string
|
|
7109
|
+
media?: ReactNode | ElementType
|
|
7110
|
+
imageUrl?: string
|
|
7111
|
+
}
|
|
7112
|
+
|
|
7113
|
+
/** @public */
|
|
7114
|
+
declare interface Reference {
|
|
7115
|
+
_type: string
|
|
7116
|
+
_ref: string
|
|
7117
|
+
_key?: string
|
|
7118
|
+
_weak?: boolean
|
|
7119
|
+
_strengthenOnPublish?: {
|
|
7120
|
+
type: string
|
|
7121
|
+
weak?: boolean
|
|
7122
|
+
template?: {
|
|
7123
|
+
id: string
|
|
7124
|
+
params: Record<string, string | number | boolean>
|
|
7125
|
+
}
|
|
7126
|
+
}
|
|
7127
|
+
}
|
|
7128
|
+
|
|
7129
|
+
/** @public */
|
|
7130
|
+
declare interface ReferenceBaseOptions extends BaseSchemaTypeOptions {
|
|
7131
|
+
disableNew?: boolean
|
|
7132
|
+
}
|
|
7133
|
+
|
|
7134
|
+
/** @public */
|
|
7135
|
+
declare interface ReferenceDefinition extends BaseSchemaDefinition {
|
|
7136
|
+
type: 'reference'
|
|
7137
|
+
to: ReferenceTo
|
|
7138
|
+
weak?: boolean
|
|
7139
|
+
options?: ReferenceOptions
|
|
7140
|
+
validation?: ValidationBuilder<ReferenceRule, ReferenceValue>
|
|
7141
|
+
initialValue?: InitialValueProperty<any, Omit<ReferenceValue, '_type'>>
|
|
7142
|
+
}
|
|
7143
|
+
|
|
7144
|
+
/** @public */
|
|
7145
|
+
declare type ReferenceFilterOptions =
|
|
7146
|
+
| ReferenceFilterResolverOptions
|
|
7147
|
+
| ReferenceFilterQueryOptions
|
|
7148
|
+
|
|
7149
|
+
/** @public */
|
|
7150
|
+
declare interface ReferenceFilterQueryOptions {
|
|
7151
|
+
filter: string
|
|
7152
|
+
filterParams?: Record<string, unknown>
|
|
7153
|
+
}
|
|
7154
|
+
|
|
7155
|
+
/** @public */
|
|
7156
|
+
declare type ReferenceFilterResolver = (
|
|
7157
|
+
context: ReferenceFilterResolverContext,
|
|
7158
|
+
) => ReferenceFilterSearchOptions | Promise<ReferenceFilterSearchOptions>
|
|
7159
|
+
|
|
7160
|
+
/** @public */
|
|
7161
|
+
declare interface ReferenceFilterResolverContext {
|
|
7162
|
+
document: SanityDocument
|
|
7163
|
+
parent?: Record<string, unknown> | Record<string, unknown>[]
|
|
7164
|
+
parentPath: Path
|
|
7165
|
+
getClient: (options: {apiVersion: string}) => SanityClient
|
|
7166
|
+
}
|
|
7167
|
+
|
|
7168
|
+
/** @public */
|
|
7169
|
+
declare interface ReferenceFilterResolverOptions {
|
|
7170
|
+
filter?: ReferenceFilterResolver
|
|
7171
|
+
filterParams?: never
|
|
7172
|
+
}
|
|
7173
|
+
|
|
7174
|
+
/** @public */
|
|
7175
|
+
declare type ReferenceFilterSearchOptions = {
|
|
7176
|
+
filter?: string
|
|
7177
|
+
params?: Record<string, unknown>
|
|
7178
|
+
tag?: string
|
|
7179
|
+
maxFieldDepth?: number
|
|
7180
|
+
strategy?: SearchStrategy
|
|
7181
|
+
perspective?: ClientPerspective
|
|
7182
|
+
}
|
|
7183
|
+
|
|
7184
|
+
/**
|
|
7185
|
+
* Types are closed for extension. To add properties via declaration merging to this type,
|
|
7186
|
+
* redeclare and add the properties to the interfaces that make up ReferenceOptions type.
|
|
7187
|
+
*
|
|
7188
|
+
* @see ReferenceFilterOptions
|
|
7189
|
+
* @see ReferenceFilterResolverOptions
|
|
7190
|
+
* @see ReferenceBaseOptions
|
|
7191
|
+
*
|
|
7192
|
+
* @public
|
|
7193
|
+
*/
|
|
7194
|
+
declare type ReferenceOptions = ReferenceBaseOptions & ReferenceFilterOptions
|
|
7195
|
+
|
|
7196
|
+
/** @public */
|
|
7197
|
+
declare interface ReferenceRule
|
|
7198
|
+
extends RuleDef<ReferenceRule, ReferenceValue> {}
|
|
7199
|
+
|
|
7200
|
+
/** @public */
|
|
7201
|
+
declare interface ReferenceSchemaType
|
|
7202
|
+
extends Omit<ObjectSchemaType, 'options'> {
|
|
7203
|
+
jsonType: 'object'
|
|
7204
|
+
to: ObjectSchemaType[]
|
|
7205
|
+
weak?: boolean
|
|
7206
|
+
options?: ReferenceOptions
|
|
7207
|
+
}
|
|
7208
|
+
|
|
7209
|
+
/** @public */
|
|
7210
|
+
declare type ReferenceTo =
|
|
7211
|
+
| SchemaTypeDefinition
|
|
7212
|
+
| TypeReference
|
|
7213
|
+
| Array<SchemaTypeDefinition | TypeReference>
|
|
7214
|
+
|
|
7215
|
+
/** @public */
|
|
7216
|
+
declare type ReferenceValue = Reference
|
|
7217
|
+
|
|
5685
7218
|
/**************************************
|
|
5686
7219
|
* Resolve behavior event
|
|
5687
7220
|
**************************************/
|
|
@@ -5707,6 +7240,437 @@ declare type ResolveBehaviorEvent<
|
|
|
5707
7240
|
? PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>
|
|
5708
7241
|
: never
|
|
5709
7242
|
|
|
7243
|
+
/** @public */
|
|
7244
|
+
declare interface Role {
|
|
7245
|
+
name: string
|
|
7246
|
+
title: string
|
|
7247
|
+
description?: string
|
|
7248
|
+
}
|
|
7249
|
+
|
|
7250
|
+
/** @public */
|
|
7251
|
+
declare interface Rule {
|
|
7252
|
+
/**
|
|
7253
|
+
* @internal
|
|
7254
|
+
* @deprecated internal use only
|
|
7255
|
+
*/
|
|
7256
|
+
_type: RuleTypeConstraint | undefined
|
|
7257
|
+
/**
|
|
7258
|
+
* @internal
|
|
7259
|
+
* @deprecated internal use only
|
|
7260
|
+
*/
|
|
7261
|
+
_level: 'error' | 'warning' | 'info' | undefined
|
|
7262
|
+
/**
|
|
7263
|
+
* @internal
|
|
7264
|
+
* @deprecated internal use only
|
|
7265
|
+
*/
|
|
7266
|
+
_required: 'required' | 'optional' | undefined
|
|
7267
|
+
/**
|
|
7268
|
+
* @internal
|
|
7269
|
+
* @deprecated internal use only
|
|
7270
|
+
*/
|
|
7271
|
+
_typeDef: SchemaType | undefined
|
|
7272
|
+
/**
|
|
7273
|
+
* @internal
|
|
7274
|
+
* @deprecated internal use only
|
|
7275
|
+
*/
|
|
7276
|
+
_message: string | LocalizedValidationMessages | undefined
|
|
7277
|
+
/**
|
|
7278
|
+
* @internal
|
|
7279
|
+
* @deprecated internal use only
|
|
7280
|
+
*/
|
|
7281
|
+
_rules: RuleSpec[]
|
|
7282
|
+
/**
|
|
7283
|
+
* @internal
|
|
7284
|
+
* @deprecated internal use only
|
|
7285
|
+
*/
|
|
7286
|
+
_fieldRules: FieldRules | undefined
|
|
7287
|
+
/**
|
|
7288
|
+
* Takes in a path and returns an object with a symbol.
|
|
7289
|
+
*
|
|
7290
|
+
* When the validation lib sees this symbol, it will use the provided path to
|
|
7291
|
+
* get a value from the current field's parent and use that value as the input
|
|
7292
|
+
* to the Rule.
|
|
7293
|
+
*
|
|
7294
|
+
* The path that's given is forwarded to `lodash/get`
|
|
7295
|
+
*
|
|
7296
|
+
* ```js
|
|
7297
|
+
* fields: [
|
|
7298
|
+
* // ...
|
|
7299
|
+
* {
|
|
7300
|
+
* // ...
|
|
7301
|
+
* name: 'highestTemperature',
|
|
7302
|
+
* type: 'number',
|
|
7303
|
+
* validation: (Rule) => Rule.positive().min(Rule.valueOfField('lowestTemperature')),
|
|
7304
|
+
* // ...
|
|
7305
|
+
* },
|
|
7306
|
+
* ]
|
|
7307
|
+
* ```
|
|
7308
|
+
*/
|
|
7309
|
+
valueOfField: (path: string | string[]) => FieldReference
|
|
7310
|
+
error(message?: string | LocalizedValidationMessages): Rule
|
|
7311
|
+
warning(message?: string | LocalizedValidationMessages): Rule
|
|
7312
|
+
info(message?: string | LocalizedValidationMessages): Rule
|
|
7313
|
+
reset(): this
|
|
7314
|
+
isRequired(): boolean
|
|
7315
|
+
clone(): Rule
|
|
7316
|
+
cloneWithRules(rules: RuleSpec[]): Rule
|
|
7317
|
+
merge(rule: Rule): Rule
|
|
7318
|
+
type(targetType: RuleTypeConstraint | Lowercase<RuleTypeConstraint>): Rule
|
|
7319
|
+
all(children: Rule[]): Rule
|
|
7320
|
+
either(children: Rule[]): Rule
|
|
7321
|
+
optional(): Rule
|
|
7322
|
+
required(): Rule
|
|
7323
|
+
custom<T = unknown>(
|
|
7324
|
+
fn: CustomValidator<T>,
|
|
7325
|
+
options?: {
|
|
7326
|
+
bypassConcurrencyLimit?: boolean
|
|
7327
|
+
},
|
|
7328
|
+
): Rule
|
|
7329
|
+
min(len: number | string | FieldReference): Rule
|
|
7330
|
+
max(len: number | string | FieldReference): Rule
|
|
7331
|
+
length(len: number | FieldReference): Rule
|
|
7332
|
+
valid(value: unknown | unknown[]): Rule
|
|
7333
|
+
integer(): Rule
|
|
7334
|
+
precision(limit: number | FieldReference): Rule
|
|
7335
|
+
positive(): Rule
|
|
7336
|
+
negative(): Rule
|
|
7337
|
+
greaterThan(num: number | FieldReference): Rule
|
|
7338
|
+
lessThan(num: number | FieldReference): Rule
|
|
7339
|
+
uppercase(): Rule
|
|
7340
|
+
lowercase(): Rule
|
|
7341
|
+
regex(
|
|
7342
|
+
pattern: RegExp,
|
|
7343
|
+
name: string,
|
|
7344
|
+
options: {
|
|
7345
|
+
name?: string
|
|
7346
|
+
invert?: boolean
|
|
7347
|
+
},
|
|
7348
|
+
): Rule
|
|
7349
|
+
regex(
|
|
7350
|
+
pattern: RegExp,
|
|
7351
|
+
options: {
|
|
7352
|
+
name?: string
|
|
7353
|
+
invert?: boolean
|
|
7354
|
+
},
|
|
7355
|
+
): Rule
|
|
7356
|
+
regex(pattern: RegExp, name: string): Rule
|
|
7357
|
+
regex(pattern: RegExp): Rule
|
|
7358
|
+
email(): Rule
|
|
7359
|
+
uri(options?: UriValidationOptions): Rule
|
|
7360
|
+
unique(): Rule
|
|
7361
|
+
reference(): Rule
|
|
7362
|
+
fields(rules: FieldRules): Rule
|
|
7363
|
+
assetRequired(): Rule
|
|
7364
|
+
validate(
|
|
7365
|
+
value: unknown,
|
|
7366
|
+
options: ValidationContext & {
|
|
7367
|
+
/**
|
|
7368
|
+
* @deprecated Internal use only
|
|
7369
|
+
* @internal
|
|
7370
|
+
*/
|
|
7371
|
+
__internal?: {
|
|
7372
|
+
customValidationConcurrencyLimiter?: {
|
|
7373
|
+
ready: () => Promise<void>
|
|
7374
|
+
release: () => void
|
|
7375
|
+
}
|
|
7376
|
+
}
|
|
7377
|
+
},
|
|
7378
|
+
): Promise<ValidationMarker[]>
|
|
7379
|
+
}
|
|
7380
|
+
|
|
7381
|
+
/** @public */
|
|
7382
|
+
declare type RuleBuilder<
|
|
7383
|
+
T extends RuleDef<T, FieldValue>,
|
|
7384
|
+
FieldValue = unknown,
|
|
7385
|
+
> = T | T[]
|
|
7386
|
+
|
|
7387
|
+
/** @public */
|
|
7388
|
+
declare interface RuleDef<T, FieldValue = unknown> {
|
|
7389
|
+
required: () => T
|
|
7390
|
+
custom: <LenientFieldValue extends FieldValue>(
|
|
7391
|
+
fn: CustomValidator<LenientFieldValue | undefined>,
|
|
7392
|
+
) => T
|
|
7393
|
+
info: (message?: string | LocalizedValidationMessages) => T
|
|
7394
|
+
error: (message?: string | LocalizedValidationMessages) => T
|
|
7395
|
+
warning: (message?: string | LocalizedValidationMessages) => T
|
|
7396
|
+
valueOfField: (path: string | string[]) => FieldReference
|
|
7397
|
+
}
|
|
7398
|
+
|
|
7399
|
+
/** @public */
|
|
7400
|
+
declare type RuleSpec =
|
|
7401
|
+
| {
|
|
7402
|
+
flag: 'integer'
|
|
7403
|
+
}
|
|
7404
|
+
| {
|
|
7405
|
+
flag: 'email'
|
|
7406
|
+
}
|
|
7407
|
+
| {
|
|
7408
|
+
flag: 'unique'
|
|
7409
|
+
}
|
|
7410
|
+
| {
|
|
7411
|
+
flag: 'reference'
|
|
7412
|
+
}
|
|
7413
|
+
| {
|
|
7414
|
+
flag: 'type'
|
|
7415
|
+
constraint: RuleTypeConstraint
|
|
7416
|
+
}
|
|
7417
|
+
| {
|
|
7418
|
+
flag: 'all'
|
|
7419
|
+
constraint: Rule[]
|
|
7420
|
+
}
|
|
7421
|
+
| {
|
|
7422
|
+
flag: 'either'
|
|
7423
|
+
constraint: Rule[]
|
|
7424
|
+
}
|
|
7425
|
+
| {
|
|
7426
|
+
flag: 'presence'
|
|
7427
|
+
constraint: 'optional' | 'required'
|
|
7428
|
+
}
|
|
7429
|
+
| {
|
|
7430
|
+
flag: 'custom'
|
|
7431
|
+
constraint: CustomValidator
|
|
7432
|
+
}
|
|
7433
|
+
| {
|
|
7434
|
+
flag: 'min'
|
|
7435
|
+
constraint: number | string
|
|
7436
|
+
}
|
|
7437
|
+
| {
|
|
7438
|
+
flag: 'max'
|
|
7439
|
+
constraint: number | string
|
|
7440
|
+
}
|
|
7441
|
+
| {
|
|
7442
|
+
flag: 'length'
|
|
7443
|
+
constraint: number
|
|
7444
|
+
}
|
|
7445
|
+
| {
|
|
7446
|
+
flag: 'valid'
|
|
7447
|
+
constraint: unknown[]
|
|
7448
|
+
}
|
|
7449
|
+
| {
|
|
7450
|
+
flag: 'precision'
|
|
7451
|
+
constraint: number
|
|
7452
|
+
}
|
|
7453
|
+
| {
|
|
7454
|
+
flag: 'lessThan'
|
|
7455
|
+
constraint: number
|
|
7456
|
+
}
|
|
7457
|
+
| {
|
|
7458
|
+
flag: 'greaterThan'
|
|
7459
|
+
constraint: number
|
|
7460
|
+
}
|
|
7461
|
+
| {
|
|
7462
|
+
flag: 'stringCasing'
|
|
7463
|
+
constraint: 'uppercase' | 'lowercase'
|
|
7464
|
+
}
|
|
7465
|
+
| {
|
|
7466
|
+
flag: 'assetRequired'
|
|
7467
|
+
constraint: {
|
|
7468
|
+
assetType: 'asset' | 'image' | 'file'
|
|
7469
|
+
}
|
|
7470
|
+
}
|
|
7471
|
+
| {
|
|
7472
|
+
flag: 'regex'
|
|
7473
|
+
constraint: {
|
|
7474
|
+
pattern: RegExp
|
|
7475
|
+
name?: string
|
|
7476
|
+
invert: boolean
|
|
7477
|
+
}
|
|
7478
|
+
}
|
|
7479
|
+
| {
|
|
7480
|
+
flag: 'uri'
|
|
7481
|
+
constraint: {
|
|
7482
|
+
options: {
|
|
7483
|
+
scheme: RegExp[]
|
|
7484
|
+
allowRelative: boolean
|
|
7485
|
+
relativeOnly: boolean
|
|
7486
|
+
allowCredentials: boolean
|
|
7487
|
+
}
|
|
7488
|
+
}
|
|
7489
|
+
}
|
|
7490
|
+
|
|
7491
|
+
/** @public */
|
|
7492
|
+
declare type RuleTypeConstraint =
|
|
7493
|
+
| 'Array'
|
|
7494
|
+
| 'Boolean'
|
|
7495
|
+
| 'Date'
|
|
7496
|
+
| 'Number'
|
|
7497
|
+
| 'Object'
|
|
7498
|
+
| 'String'
|
|
7499
|
+
|
|
7500
|
+
/**
|
|
7501
|
+
* Options for configuring how Sanity Create interfaces with the type or field.
|
|
7502
|
+
*
|
|
7503
|
+
* @public
|
|
7504
|
+
*/
|
|
7505
|
+
declare interface SanityCreateOptions {
|
|
7506
|
+
/** Set to true to exclude a type or field from appearing in Sanity Create */
|
|
7507
|
+
exclude?: boolean
|
|
7508
|
+
/**
|
|
7509
|
+
* A short description of what the type or field is used for.
|
|
7510
|
+
* Purpose can be used to improve how and when content mapping uses the field.
|
|
7511
|
+
* */
|
|
7512
|
+
purpose?: string
|
|
7513
|
+
}
|
|
7514
|
+
|
|
7515
|
+
/** @public */
|
|
7516
|
+
declare interface SanityDocument {
|
|
7517
|
+
_id: string
|
|
7518
|
+
_type: string
|
|
7519
|
+
_createdAt: string
|
|
7520
|
+
_updatedAt: string
|
|
7521
|
+
_rev: string
|
|
7522
|
+
[key: string]: unknown
|
|
7523
|
+
}
|
|
7524
|
+
|
|
7525
|
+
/** @public */
|
|
7526
|
+
declare interface Schema {
|
|
7527
|
+
/** @internal */
|
|
7528
|
+
_original?: {
|
|
7529
|
+
name: string
|
|
7530
|
+
types: SchemaTypeDefinition[]
|
|
7531
|
+
}
|
|
7532
|
+
/** @internal */
|
|
7533
|
+
_registry: {
|
|
7534
|
+
[typeName: string]: any
|
|
7535
|
+
}
|
|
7536
|
+
/** @internal */
|
|
7537
|
+
_validation?: SchemaValidationProblemGroup[]
|
|
7538
|
+
name: string
|
|
7539
|
+
get: (name: string) => SchemaType | undefined
|
|
7540
|
+
has: (name: string) => boolean
|
|
7541
|
+
getTypeNames: () => string[]
|
|
7542
|
+
}
|
|
7543
|
+
|
|
7544
|
+
/**
|
|
7545
|
+
* Note: you probably want `SchemaTypeDefinition` instead
|
|
7546
|
+
* @see SchemaTypeDefinition
|
|
7547
|
+
*
|
|
7548
|
+
* @public
|
|
7549
|
+
*/
|
|
7550
|
+
declare type SchemaType =
|
|
7551
|
+
| ArraySchemaType
|
|
7552
|
+
| BooleanSchemaType
|
|
7553
|
+
| FileSchemaType
|
|
7554
|
+
| NumberSchemaType
|
|
7555
|
+
| ObjectSchemaType
|
|
7556
|
+
| StringSchemaType
|
|
7557
|
+
| ReferenceSchemaType
|
|
7558
|
+
|
|
7559
|
+
/**
|
|
7560
|
+
* Represents a Sanity schema type definition with an optional type parameter.
|
|
7561
|
+
*
|
|
7562
|
+
* It's recommend to use the `defineType` helper instead of this type by
|
|
7563
|
+
* itself.
|
|
7564
|
+
*
|
|
7565
|
+
* @see defineType
|
|
7566
|
+
*
|
|
7567
|
+
* @public
|
|
7568
|
+
*/
|
|
7569
|
+
declare type SchemaTypeDefinition<
|
|
7570
|
+
TType extends IntrinsicTypeName = IntrinsicTypeName,
|
|
7571
|
+
> = IntrinsicDefinitions[IntrinsicTypeName] | TypeAliasDefinition<string, TType>
|
|
7572
|
+
|
|
7573
|
+
/** @public */
|
|
7574
|
+
declare interface SchemaValidationError {
|
|
7575
|
+
helpId?: string
|
|
7576
|
+
message: string
|
|
7577
|
+
severity: 'error'
|
|
7578
|
+
}
|
|
7579
|
+
|
|
7580
|
+
/** @internal */
|
|
7581
|
+
declare type SchemaValidationProblem =
|
|
7582
|
+
| SchemaValidationError
|
|
7583
|
+
| SchemaValidationWarning
|
|
7584
|
+
|
|
7585
|
+
/** @internal */
|
|
7586
|
+
declare interface SchemaValidationProblemGroup {
|
|
7587
|
+
path: SchemaValidationProblemPath
|
|
7588
|
+
problems: SchemaValidationProblem[]
|
|
7589
|
+
}
|
|
7590
|
+
|
|
7591
|
+
/** @internal */
|
|
7592
|
+
declare type SchemaValidationProblemPath = Array<
|
|
7593
|
+
| {
|
|
7594
|
+
kind: 'type'
|
|
7595
|
+
type: string
|
|
7596
|
+
name?: string
|
|
7597
|
+
}
|
|
7598
|
+
| {
|
|
7599
|
+
kind: 'property'
|
|
7600
|
+
name: string
|
|
7601
|
+
}
|
|
7602
|
+
>
|
|
7603
|
+
|
|
7604
|
+
/**
|
|
7605
|
+
* Represents the possible values of a schema type's `validation` field.
|
|
7606
|
+
*
|
|
7607
|
+
* If the schema has not been run through `inferFromSchema` from
|
|
7608
|
+
* `sanity/validation` then value could be a function.
|
|
7609
|
+
*
|
|
7610
|
+
* `inferFromSchema` mutates the schema converts this value to an array of
|
|
7611
|
+
* `Rule` instances.
|
|
7612
|
+
*
|
|
7613
|
+
* @privateRemarks
|
|
7614
|
+
*
|
|
7615
|
+
* Usage of the schema inside the studio will almost always be from the compiled
|
|
7616
|
+
* `createSchema` function. In this case, you can cast the value or throw to
|
|
7617
|
+
* narrow the type. E.g.:
|
|
7618
|
+
*
|
|
7619
|
+
* ```ts
|
|
7620
|
+
* if (typeof type.validation === 'function') {
|
|
7621
|
+
* throw new Error(
|
|
7622
|
+
* `Schema type "${type.name}"'s \`validation\` was not run though \`inferFromSchema\``
|
|
7623
|
+
* )
|
|
7624
|
+
* }
|
|
7625
|
+
* ```
|
|
7626
|
+
*
|
|
7627
|
+
* @public
|
|
7628
|
+
*/
|
|
7629
|
+
declare type SchemaValidationValue =
|
|
7630
|
+
| false
|
|
7631
|
+
| undefined
|
|
7632
|
+
| Rule
|
|
7633
|
+
| SchemaValidationValue[]
|
|
7634
|
+
| ((rule: Rule) => SchemaValidationValue)
|
|
7635
|
+
|
|
7636
|
+
/** @internal */
|
|
7637
|
+
declare interface SchemaValidationWarning {
|
|
7638
|
+
helpId?: string
|
|
7639
|
+
message: string
|
|
7640
|
+
severity: 'warning'
|
|
7641
|
+
}
|
|
7642
|
+
|
|
7643
|
+
/** @public */
|
|
7644
|
+
declare interface SearchConfiguration {
|
|
7645
|
+
search?: {
|
|
7646
|
+
/**
|
|
7647
|
+
* Defines a search weight for this field to prioritize its importance
|
|
7648
|
+
* during search operations in the Studio. This setting allows the specified
|
|
7649
|
+
* field to be ranked higher in search results compared to other fields.
|
|
7650
|
+
*
|
|
7651
|
+
* By default, all fields are assigned a weight of 1. However, if a field is
|
|
7652
|
+
* chosen as the `title` in the preview configuration's `select` option, it
|
|
7653
|
+
* will automatically receive a default weight of 10. Similarly, if selected
|
|
7654
|
+
* as the `subtitle`, the default weight is 5. Fields marked as
|
|
7655
|
+
* `hidden: true` (no function) are assigned a weight of 0 by default.
|
|
7656
|
+
*
|
|
7657
|
+
* Note: Search weight configuration is currently supported only for fields
|
|
7658
|
+
* of type string or portable text arrays.
|
|
7659
|
+
*/
|
|
7660
|
+
weight?: number
|
|
7661
|
+
}
|
|
7662
|
+
}
|
|
7663
|
+
|
|
7664
|
+
/**
|
|
7665
|
+
* @public
|
|
7666
|
+
*/
|
|
7667
|
+
declare const searchStrategies: readonly ['groqLegacy', 'groq2024']
|
|
7668
|
+
|
|
7669
|
+
/**
|
|
7670
|
+
* @public
|
|
7671
|
+
*/
|
|
7672
|
+
declare type SearchStrategy = (typeof searchStrategies)[number]
|
|
7673
|
+
|
|
5710
7674
|
declare type Serializer<TMIMEType extends MIMEType> = ({
|
|
5711
7675
|
snapshot,
|
|
5712
7676
|
event,
|
|
@@ -5719,8 +7683,159 @@ declare type Serializer<TMIMEType extends MIMEType> = ({
|
|
|
5719
7683
|
'serialization.success' | 'serialization.failure'
|
|
5720
7684
|
>
|
|
5721
7685
|
|
|
7686
|
+
/** @public */
|
|
7687
|
+
declare interface SingleFieldSet {
|
|
7688
|
+
single: true
|
|
7689
|
+
field: ObjectField
|
|
7690
|
+
hidden?: ConditionalProperty
|
|
7691
|
+
readOnly?: ConditionalProperty
|
|
7692
|
+
group?: string | string[]
|
|
7693
|
+
}
|
|
7694
|
+
|
|
7695
|
+
/** @public */
|
|
7696
|
+
declare interface SlugDefinition extends BaseSchemaDefinition {
|
|
7697
|
+
type: 'slug'
|
|
7698
|
+
options?: SlugOptions
|
|
7699
|
+
validation?: ValidationBuilder<SlugRule, SlugValue>
|
|
7700
|
+
initialValue?: InitialValueProperty<any, Omit<SlugValue, '_type'>>
|
|
7701
|
+
}
|
|
7702
|
+
|
|
7703
|
+
/** @public */
|
|
7704
|
+
declare type SlugifierFn = (
|
|
7705
|
+
source: string,
|
|
7706
|
+
schemaType: SlugSchemaType,
|
|
7707
|
+
context: SlugSourceContext,
|
|
7708
|
+
) => string | Promise<string>
|
|
7709
|
+
|
|
7710
|
+
/** @public */
|
|
7711
|
+
declare type SlugIsUniqueValidator = (
|
|
7712
|
+
slug: string,
|
|
7713
|
+
context: SlugValidationContext,
|
|
7714
|
+
) => boolean | Promise<boolean>
|
|
7715
|
+
|
|
7716
|
+
/** @public */
|
|
7717
|
+
declare interface SlugOptions
|
|
7718
|
+
extends SearchConfiguration,
|
|
7719
|
+
BaseSchemaTypeOptions {
|
|
7720
|
+
source?: string | Path | SlugSourceFn
|
|
7721
|
+
maxLength?: number
|
|
7722
|
+
slugify?: SlugifierFn
|
|
7723
|
+
isUnique?: SlugIsUniqueValidator
|
|
7724
|
+
disableArrayWarning?: boolean
|
|
7725
|
+
}
|
|
7726
|
+
|
|
7727
|
+
/** @public */
|
|
7728
|
+
declare type SlugParent = Record<string, unknown> | Record<string, unknown>[]
|
|
7729
|
+
|
|
7730
|
+
/** @public */
|
|
7731
|
+
declare interface SlugRule extends RuleDef<SlugRule, SlugValue> {}
|
|
7732
|
+
|
|
7733
|
+
/** @public */
|
|
7734
|
+
declare interface SlugSchemaType extends ObjectSchemaType {
|
|
7735
|
+
jsonType: 'object'
|
|
7736
|
+
options?: SlugOptions
|
|
7737
|
+
}
|
|
7738
|
+
|
|
7739
|
+
/** @public */
|
|
7740
|
+
declare interface SlugSourceContext {
|
|
7741
|
+
parentPath: Path
|
|
7742
|
+
parent: SlugParent
|
|
7743
|
+
projectId: string
|
|
7744
|
+
dataset: string
|
|
7745
|
+
schema: Schema
|
|
7746
|
+
currentUser: CurrentUser | null
|
|
7747
|
+
getClient: (options: {apiVersion: string}) => SanityClient
|
|
7748
|
+
}
|
|
7749
|
+
|
|
7750
|
+
/** @public */
|
|
7751
|
+
declare type SlugSourceFn = (
|
|
7752
|
+
document: SanityDocument,
|
|
7753
|
+
context: SlugSourceContext,
|
|
7754
|
+
) => string | Promise<string>
|
|
7755
|
+
|
|
7756
|
+
/** @public */
|
|
7757
|
+
declare interface SlugValidationContext extends ValidationContext {
|
|
7758
|
+
parent: SlugParent
|
|
7759
|
+
type: SlugSchemaType
|
|
7760
|
+
defaultIsUnique: SlugIsUniqueValidator
|
|
7761
|
+
}
|
|
7762
|
+
|
|
7763
|
+
/** @public */
|
|
7764
|
+
declare interface SlugValue {
|
|
7765
|
+
_type: 'slug'
|
|
7766
|
+
current?: string
|
|
7767
|
+
}
|
|
7768
|
+
|
|
7769
|
+
/** @beta */
|
|
7770
|
+
declare type SortOrdering = {
|
|
7771
|
+
title: string
|
|
7772
|
+
i18n?: I18nTextRecord<'title'>
|
|
7773
|
+
name: string
|
|
7774
|
+
by: SortOrderingItem[]
|
|
7775
|
+
}
|
|
7776
|
+
|
|
7777
|
+
/** @beta */
|
|
7778
|
+
declare interface SortOrderingItem {
|
|
7779
|
+
field: string
|
|
7780
|
+
direction: 'asc' | 'desc'
|
|
7781
|
+
}
|
|
7782
|
+
|
|
5722
7783
|
declare type StrictExtract<T, U extends T> = U
|
|
5723
7784
|
|
|
7785
|
+
/** @public */
|
|
7786
|
+
declare interface StringDefinition extends BaseSchemaDefinition {
|
|
7787
|
+
type: 'string'
|
|
7788
|
+
options?: StringOptions
|
|
7789
|
+
placeholder?: string
|
|
7790
|
+
validation?: ValidationBuilder<StringRule, string>
|
|
7791
|
+
initialValue?: InitialValueProperty<any, string>
|
|
7792
|
+
}
|
|
7793
|
+
|
|
7794
|
+
/** @public */
|
|
7795
|
+
declare interface StringOptions
|
|
7796
|
+
extends EnumListProps<string>,
|
|
7797
|
+
SearchConfiguration,
|
|
7798
|
+
BaseSchemaTypeOptions {}
|
|
7799
|
+
|
|
7800
|
+
/** @public */
|
|
7801
|
+
declare interface StringRule extends RuleDef<StringRule, string> {
|
|
7802
|
+
min: (minNumber: number | FieldReference) => StringRule
|
|
7803
|
+
max: (maxNumber: number | FieldReference) => StringRule
|
|
7804
|
+
length: (exactLength: number | FieldReference) => StringRule
|
|
7805
|
+
uppercase: () => StringRule
|
|
7806
|
+
lowercase: () => StringRule
|
|
7807
|
+
regex(
|
|
7808
|
+
pattern: RegExp,
|
|
7809
|
+
name: string,
|
|
7810
|
+
options: {
|
|
7811
|
+
name?: string
|
|
7812
|
+
invert?: boolean
|
|
7813
|
+
},
|
|
7814
|
+
): StringRule
|
|
7815
|
+
regex(
|
|
7816
|
+
pattern: RegExp,
|
|
7817
|
+
options: {
|
|
7818
|
+
name?: string
|
|
7819
|
+
invert?: boolean
|
|
7820
|
+
},
|
|
7821
|
+
): StringRule
|
|
7822
|
+
regex(pattern: RegExp, name: string): StringRule
|
|
7823
|
+
regex(pattern: RegExp): StringRule
|
|
7824
|
+
email(): StringRule
|
|
7825
|
+
}
|
|
7826
|
+
|
|
7827
|
+
/**
|
|
7828
|
+
* This is used for string, text, date and datetime.
|
|
7829
|
+
* This interface represent the compiled version at runtime, when accessed through Schema.
|
|
7830
|
+
*
|
|
7831
|
+
* @public
|
|
7832
|
+
*/
|
|
7833
|
+
declare interface StringSchemaType extends BaseSchemaType {
|
|
7834
|
+
jsonType: 'string'
|
|
7835
|
+
options?: StringOptions & TextOptions & DateOptions & DatetimeOptions
|
|
7836
|
+
initialValue?: InitialValueProperty<any, string>
|
|
7837
|
+
}
|
|
7838
|
+
|
|
5724
7839
|
/**
|
|
5725
7840
|
* @beta
|
|
5726
7841
|
*/
|
|
@@ -5870,9 +7985,199 @@ declare type TextBlockWithOptionalKey = Omit<PortableTextTextBlock, '_key'> & {
|
|
|
5870
7985
|
_key?: PortableTextTextBlock['_key']
|
|
5871
7986
|
}
|
|
5872
7987
|
|
|
7988
|
+
/** @public */
|
|
7989
|
+
declare interface TextDefinition extends BaseSchemaDefinition {
|
|
7990
|
+
type: 'text'
|
|
7991
|
+
rows?: number
|
|
7992
|
+
options?: TextOptions
|
|
7993
|
+
placeholder?: string
|
|
7994
|
+
validation?: ValidationBuilder<TextRule, string>
|
|
7995
|
+
initialValue?: InitialValueProperty<any, string>
|
|
7996
|
+
}
|
|
7997
|
+
|
|
7998
|
+
/** @public */
|
|
7999
|
+
declare interface TextOptions extends StringOptions {}
|
|
8000
|
+
|
|
8001
|
+
/** @public */
|
|
8002
|
+
declare interface TextRule extends StringRule {}
|
|
8003
|
+
|
|
8004
|
+
/** @public */
|
|
8005
|
+
declare interface TitledListValue<V = unknown> {
|
|
8006
|
+
_key?: string
|
|
8007
|
+
title: string
|
|
8008
|
+
value?: V
|
|
8009
|
+
}
|
|
8010
|
+
|
|
8011
|
+
/**
|
|
8012
|
+
* Represents a type definition that is an alias/extension of an existing type
|
|
8013
|
+
* in your schema. Creating a type alias will re-register that existing type
|
|
8014
|
+
* under a different name. You can also override the default type options with
|
|
8015
|
+
* a type alias definition.
|
|
8016
|
+
*
|
|
8017
|
+
* @public
|
|
8018
|
+
*/
|
|
8019
|
+
declare interface TypeAliasDefinition<
|
|
8020
|
+
TType extends string,
|
|
8021
|
+
TAlias extends IntrinsicTypeName | undefined,
|
|
8022
|
+
> extends BaseSchemaDefinition {
|
|
8023
|
+
type: TType
|
|
8024
|
+
options?: TAlias extends IntrinsicTypeName
|
|
8025
|
+
? IntrinsicDefinitions[TAlias]['options']
|
|
8026
|
+
: unknown
|
|
8027
|
+
validation?: SchemaValidationValue
|
|
8028
|
+
initialValue?: InitialValueProperty<any, any>
|
|
8029
|
+
preview?: PreviewConfig
|
|
8030
|
+
components?: {
|
|
8031
|
+
annotation?: ComponentType<any>
|
|
8032
|
+
block?: ComponentType<any>
|
|
8033
|
+
inlineBlock?: ComponentType<any>
|
|
8034
|
+
diff?: ComponentType<any>
|
|
8035
|
+
field?: ComponentType<any>
|
|
8036
|
+
input?: ComponentType<any>
|
|
8037
|
+
item?: ComponentType<any>
|
|
8038
|
+
preview?: ComponentType<any>
|
|
8039
|
+
}
|
|
8040
|
+
}
|
|
8041
|
+
|
|
8042
|
+
/**
|
|
8043
|
+
* Represents a reference to another type registered top-level in your schema.
|
|
8044
|
+
*
|
|
8045
|
+
* @public
|
|
8046
|
+
*/
|
|
8047
|
+
declare interface TypeReference {
|
|
8048
|
+
type: string
|
|
8049
|
+
name?: string
|
|
8050
|
+
icon?: ComponentType | ReactNode
|
|
8051
|
+
options?: {
|
|
8052
|
+
[key: string]: unknown
|
|
8053
|
+
}
|
|
8054
|
+
}
|
|
8055
|
+
|
|
5873
8056
|
declare type UnsetEvent = {
|
|
5874
8057
|
type: 'unset'
|
|
5875
8058
|
previousValue: Array<PortableTextBlock>
|
|
5876
8059
|
}
|
|
5877
8060
|
|
|
8061
|
+
/** @public */
|
|
8062
|
+
declare interface UriValidationOptions {
|
|
8063
|
+
scheme?: (string | RegExp) | Array<string | RegExp>
|
|
8064
|
+
allowRelative?: boolean
|
|
8065
|
+
relativeOnly?: boolean
|
|
8066
|
+
allowCredentials?: boolean
|
|
8067
|
+
}
|
|
8068
|
+
|
|
8069
|
+
/** @public */
|
|
8070
|
+
declare interface UrlDefinition extends BaseSchemaDefinition {
|
|
8071
|
+
type: 'url'
|
|
8072
|
+
options?: UrlOptions
|
|
8073
|
+
placeholder?: string
|
|
8074
|
+
validation?: ValidationBuilder<UrlRule, string>
|
|
8075
|
+
initialValue?: InitialValueProperty<any, string>
|
|
8076
|
+
}
|
|
8077
|
+
|
|
8078
|
+
/** @public */
|
|
8079
|
+
declare interface UrlOptions extends BaseSchemaTypeOptions {}
|
|
8080
|
+
|
|
8081
|
+
/** @public */
|
|
8082
|
+
declare interface UrlRule extends RuleDef<UrlRule, string> {
|
|
8083
|
+
uri(options: UriValidationOptions): UrlRule
|
|
8084
|
+
}
|
|
8085
|
+
|
|
8086
|
+
/** @public */
|
|
8087
|
+
declare type ValidationBuilder<
|
|
8088
|
+
T extends RuleDef<T, FieldValue>,
|
|
8089
|
+
FieldValue = unknown,
|
|
8090
|
+
> = (rule: T) => RuleBuilder<T, FieldValue>
|
|
8091
|
+
|
|
8092
|
+
/**
|
|
8093
|
+
* A context object passed around during validation. This includes the
|
|
8094
|
+
* `Rule.custom` context.
|
|
8095
|
+
*
|
|
8096
|
+
* e.g.
|
|
8097
|
+
*
|
|
8098
|
+
* ```js
|
|
8099
|
+
* Rule.custom((_, validationContext) => {
|
|
8100
|
+
* // ...
|
|
8101
|
+
* })`
|
|
8102
|
+
* ```
|
|
8103
|
+
*
|
|
8104
|
+
* @public
|
|
8105
|
+
*/
|
|
8106
|
+
declare interface ValidationContext {
|
|
8107
|
+
getClient: (options: {apiVersion: string}) => SanityClient
|
|
8108
|
+
schema: Schema
|
|
8109
|
+
parent?: unknown
|
|
8110
|
+
type?: SchemaType
|
|
8111
|
+
document?: SanityDocument
|
|
8112
|
+
path?: Path
|
|
8113
|
+
getDocumentExists?: (options: {id: string}) => Promise<boolean>
|
|
8114
|
+
environment: 'cli' | 'studio'
|
|
8115
|
+
}
|
|
8116
|
+
|
|
8117
|
+
/**
|
|
8118
|
+
* The shape that can be returned from a custom validator to be converted into
|
|
8119
|
+
* a validation marker by the validation logic. Inside of a custom validator,
|
|
8120
|
+
* you can return an array of these in order to specify multiple paths within
|
|
8121
|
+
* an object or array.
|
|
8122
|
+
*
|
|
8123
|
+
* @public
|
|
8124
|
+
*/
|
|
8125
|
+
declare interface ValidationError {
|
|
8126
|
+
/**
|
|
8127
|
+
* The message describing why the value is not valid. This message will be
|
|
8128
|
+
* included in the validation markers after validation has finished running.
|
|
8129
|
+
*/
|
|
8130
|
+
message: string
|
|
8131
|
+
/**
|
|
8132
|
+
* If writing a custom validator, you can return validation messages to
|
|
8133
|
+
* specific path inside of the current value (object or array) by populating
|
|
8134
|
+
* this `path` prop.
|
|
8135
|
+
*
|
|
8136
|
+
* NOTE: This path is relative to the current value and _not_ relative to
|
|
8137
|
+
* the document.
|
|
8138
|
+
*/
|
|
8139
|
+
path?: Path
|
|
8140
|
+
/**
|
|
8141
|
+
* Same as `path` but allows more than one value. If provided, the same
|
|
8142
|
+
* message will create two markers from each path with the same message
|
|
8143
|
+
* provided.
|
|
8144
|
+
*
|
|
8145
|
+
* @deprecated prefer `path`
|
|
8146
|
+
*/
|
|
8147
|
+
paths?: Path[]
|
|
8148
|
+
/**
|
|
8149
|
+
* @deprecated Unused. Was used to store the results from `.either()` /`.all()`
|
|
8150
|
+
*/
|
|
8151
|
+
children?: ValidationMarker[]
|
|
8152
|
+
/**
|
|
8153
|
+
* @deprecated Unused. Was used to signal if this error came from an `.either()`/`.all()`.
|
|
8154
|
+
*/
|
|
8155
|
+
operation?: 'AND' | 'OR'
|
|
8156
|
+
/**
|
|
8157
|
+
* @deprecated Unused. Was relevant when validation error was used as a class.
|
|
8158
|
+
*/
|
|
8159
|
+
cloneWithMessage?(message: string): ValidationError
|
|
8160
|
+
}
|
|
8161
|
+
|
|
8162
|
+
/** @public */
|
|
8163
|
+
declare interface ValidationMarker {
|
|
8164
|
+
level: 'error' | 'warning' | 'info'
|
|
8165
|
+
/**
|
|
8166
|
+
* The validation message for this marker. E.g. "Must be greater than 0"
|
|
8167
|
+
*/
|
|
8168
|
+
message: string
|
|
8169
|
+
/**
|
|
8170
|
+
* @deprecated use `message` instead
|
|
8171
|
+
*/
|
|
8172
|
+
item?: ValidationError
|
|
8173
|
+
/**
|
|
8174
|
+
* The sanity path _relative to the root of the current document_ to this
|
|
8175
|
+
* marker.
|
|
8176
|
+
*
|
|
8177
|
+
* NOTE: Sanity paths may contain keyed segments (i.e. `{_key: string}`) that
|
|
8178
|
+
* are not compatible with deep getters like lodash/get
|
|
8179
|
+
*/
|
|
8180
|
+
path: Path
|
|
8181
|
+
}
|
|
8182
|
+
|
|
5878
8183
|
export {}
|