From 759156035b0e773bdacfe72bad0885e097362d44 Mon Sep 17 00:00:00 2001 From: largis21 Date: Mon, 27 Jan 2025 20:03:51 +0100 Subject: [PATCH] feat: added preview and icon fields (#23) --- src/linkField.tsx | 10 +++++++--- src/types.ts | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/linkField.tsx b/src/linkField.tsx index af36219..e15315d 100644 --- a/src/linkField.tsx +++ b/src/linkField.tsx @@ -58,12 +58,16 @@ export const linkField = definePlugin((opts) => { enableLinkParameters = true, enableAnchorLinks = true, customLinkTypes = [], + icon, + preview, } = opts || {} - const linkType = { + const linkType = defineType({ name: 'link', title: 'Link', type: 'object', + icon, + preview, fieldsets: [ { name: 'advanced', @@ -256,12 +260,12 @@ export const linkField = definePlugin((opts) => { input: (props: ObjectInputProps) => LinkInput({customLinkTypes, ...props, value: props.value as LinkValue}), }, - } + }) return { name: 'link-field', schema: { - types: [defineType(linkType)], + types: [linkType], }, } }) diff --git a/src/types.ts b/src/types.ts index 96176b1..ca36e29 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,9 +1,11 @@ import {ComponentType} from 'react' import type { + BaseSchemaDefinition, CurrentUser, ObjectInputProps, ObjectSchemaType, Path, + PreviewConfig, ReferenceFilterOptions, SanityDocument, } from 'sanity' @@ -158,6 +160,10 @@ export interface LinkFieldPluginOptions { * ``` */ customLinkTypes?: CustomLinkType[] + + icon?: BaseSchemaDefinition['icon'] + + preview?: PreviewConfig } /**