@driftime/sanity-plugin-link 0.1.0
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/README.md +593 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1010 -0
- package/dist/index.js.map +1 -0
- package/dist/render.d.ts +164 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +413 -0
- package/dist/render.js.map +1 -0
- package/dist/types-BR08fVY8.js +188 -0
- package/dist/types-BR08fVY8.js.map +1 -0
- package/dist/types-BXseTKgu.d.ts +176 -0
- package/dist/types-BXseTKgu.d.ts.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["isDefined","useState","ArrayOfObjectsFormNode","ArrayOfObjectsMember","BaseFormNode","DocumentFieldActionNode","ObjectFieldProps","ObjectFormNode","ObjectMember","ChangeIndicator","FieldActionsProvider","FieldActionsResolver","FormField","getPublishedId","useFormValue","hasMembers","node","collectNodeValidation","validation","collectMemberValidation","members","flatMap","member","kind","field","fieldSet","item","FieldProps","Field","t0","$","_c","actions","schemaType","title","description","presence","level","inputId","path","changed","children","inputProps","t1","Symbol","for","headerActions","setHeaderActions","t2","documentId","fieldValidation","focused","t3","publishedId","undefined","t4","name","t5","readOnly","deprecated","t6","t7","ComponentProps","ComponentType","createElement","defaultIconProps","width","height","strokeWidth","createSanityIcon","icon","props","Icon","SanityIcon","ComponentProps","HashIconProps","HashIcon","props","$","_c","t0","t1","t2","t3","Symbol","for","t4","defaultIconProps","isDefined","TextInput","ChangeEvent","StringInputProps","set","unset","HashIcon","AnchorProps","Anchor","t0","$","_c","elementProps","value","onChange","readOnly","t1","handleChange","event","next","currentTarget","t2","Symbol","for","t3","t4","Hidden","isDefined","stegaClean","composeAnchorHref","SanityLink","getDomain","url","address","undefined","URL","hostname","replace","getLocalDetail","value","Partial","type","anchor","email","phone","getReferencedId","reference","_ref","asset","file","composeSummary","label","detail","written","isDefined","readPath","useEffect","useState","useDocumentPreviewStore","getLocalDetail","getReferencedId","SanityLink","ReadDetail","id","detail","useDestinationDetail","value","titleField","$","_c","previewStore","t0","local","t1","isFile","type","read","setRead","t2","t3","destinationId","path","split","subscription","observePaths","_ref","subscribe","document","undefined","unsubscribe","t4","observed","ComponentProps","LinkIconProps","LinkIcon","props","$","_c","t0","t1","Symbol","for","t2","ComponentProps","ExternalLinkIconProps","ExternalLinkIcon","props","$","_c","t0","t1","t2","Symbol","for","t3","ComponentProps","FileDownIconProps","FileDownIcon","props","$","_c","t0","t1","t2","t3","Symbol","for","t4","ComponentProps","FileSymlinkIconProps","FileSymlinkIcon","props","$","_c","t0","t1","t2","Symbol","for","t3","ComponentProps","MailIconProps","MailIcon","props","$","_c","t0","t1","Symbol","for","t2","ComponentProps","PhoneIconProps","PhoneIcon","props","$","_c","t0","Symbol","for","t1","ComponentProps","ComponentType","ExternalLinkIcon","FileDownIcon","FileSymlinkIcon","HashIcon","MailIcon","PhoneIcon","SanityLinkDestination","LinkTypeDefinition","name","icon","label","fields","linkTypes","const","defaultDestinations","map","linkType","linkTypes","SanityLinkDestination","linkMarkTypeName","getLinkType","name","find","linkType","getStaleFields","type","kept","Set","fields","filter","flatMap","field","has","showsField","parent","some","owned","isLinkType","isLinkMark","_type","isDefined","defaultDestinations","linkTypes","getLinkType","SanityLinkConfig","SanityLinkOptions","SanityLinkDestination","LinkType","resolveLinkOptions","options","config","destinations","getOfferedLinkTypes","offered","rest","Set","flatMap","name","linkType","everything","others","defaultIconProps","isDefined","CloseIcon","Box","Button","Dialog","Flex","Stack","Tab","TabList","TabPanel","ReactNode","useEffect","useState","ObjectInputProps","ObjectSchemaType","set","setIfMissing","unset","useDestinationDetail","LinkIcon","getLinkType","getStaleFields","LinkType","getOfferedLinkTypes","resolveLinkOptions","composeSummary","SanityLinkConfig","SanityLinkOptions","SanityLink","SanityLinkDestination","DestinationsProps","id","offered","selected","showTabs","readOnly","onSelect","type","children","Destinations","t0","$","_c","t1","map","linkType","name","label","t2","t3","t4","LinkSchemaType","options","InputProps","Partial","createDestinationPatches","typeName","_type","field","createInput","titleField","config","Input","props","path","schemaType","value","onChange","renderDefault","open","setOpen","destinations","defaultLinkType","stored","detail","summary","Icon","icon","at","isArrayItem","length","handleSelectType","isDefined","AddIcon","CloseIcon","Box","Button","Flex","Stack","TextInput","randomKey","ChangeEvent","ArrayOfObjectsInputProps","insert","set","setIfMissing","unset","SanityLinkSearchParam","searchParamTypeName","readParam","param","_key","key","undefined","value","SearchParamsProps","SearchParams","t0","$","_c","id","onChange","readOnly","t1","params","t2","handleEdit","field","next","t3","t4","index","key_0","parameterValue","position","String","event","currentTarget","event_0","map","Symbol","for","t5","_type","t6","t7","Field","createSanityIcon","convertCase","isDefined","defineArrayMember","defineField","defineType","Anchor","Hidden","createInput","SearchParams","defaultTitleField","linkTypes","LinkIcon","getLinkType","isLinkMark","isLinkType","showsField","SanityLinkConfig","SanityEmailLink","SanityFileLink","SanityLink","SanityLinkDestination","SanityLinkSearchParam","SanityPageLink","SanityPhoneLink","SanityUrlLink","linkTypeName","searchParamTypeName","createLinkType","config","documentTypes","title","field","titleField","name","type","icon","description","components","input","validation","rule","custom","value","Partial","preview","select","label","prepare","selection","linkType","media","fields","to","map","hidden","parent","context","uri","scheme","email","regex","every","key","carried","of","subtitle","some","ObjectOptions","TypeAliasDefinition","definePlugin","pluginName","createLinkType","SanityLinkDestination","linkTypeName","IntrinsicDefinitions","link","SanityLinkDefinition","SanityLinkOptions","destinations","Omit","options","SanityLinkConfig","documentTypes","title","SanityLinkTitleField","field","linkPlugin","config","name","schema","types","createSanityIcon","defineArrayMember","LinkIcon","SanityLink","linkMarkTypeName","linkTypeName","linkAnnotation","name","type","title","icon","EditorSchema","isDefined","SanityUrlLink","linkMarkTypeName","createUrlLink","schema","url","annotation","annotations","find","name","undefined","_type","type","useEditor","defineBehavior","raise","isSelectionExpanded","htmlToPortableText","isDefined","useEffect","PortableTextPluginsProps","createUrlLink","pasteUrlBehavior","on","guard","snapshot","event","html","originEvent","dataTransfer","getData","test","blocks","schema","context","keyGenerator","rules","deserialize","element","next","Element","nodeName","toLowerCase","undefined","url","getAttribute","link","childNodes","_type","markDef","_key","children","actions","type","placement","PortableTextLinkPlugins","props","$","_c","editor","t0","t1","unregister","registerBehavior","behavior","t2","renderDefault","plugins","pasteLink","_temp","value","href"],"sources":["../../@repo/components/field.tsx","../../@repo/lib/icons.ts","../src/icons/hash.tsx","../src/components/anchor.tsx","../src/components/hidden.tsx","../src/lib/summary.ts","../src/hooks/use-destination-detail.ts","../src/icons/link.tsx","../src/icons/external-link.tsx","../src/icons/file-down.tsx","../src/icons/file-symlink.tsx","../src/icons/mail.tsx","../src/icons/phone.tsx","../src/config/destinations.ts","../src/lib/link-types.ts","../src/lib/options.ts","../src/components/input.tsx","../src/components/search-params.tsx","../src/schemas/types/link.ts","../src/plugin.ts","../src/schemas/annotations/link-mark.ts","../src/lib/annotations.ts","../src/components/portable-text-plugins.tsx"],"sourcesContent":["import { isDefined } from \"@repo/lib/utils\";\nimport { useState } from \"react\";\nimport type {\n ArrayOfObjectsFormNode,\n ArrayOfObjectsMember,\n BaseFormNode,\n DocumentFieldActionNode,\n ObjectFieldProps,\n ObjectFormNode,\n ObjectMember,\n} from \"sanity\";\nimport {\n ChangeIndicator,\n FieldActionsProvider,\n FieldActionsResolver,\n FormField,\n getPublishedId,\n useFormValue,\n} from \"sanity\";\n\n/**\n * Checks whether a form node holds members of its own, as an object or an array of objects does.\n *\n * @param node - The form node to check.\n * @returns True if the node holds members.\n */\nfunction hasMembers(node: BaseFormNode): node is ObjectFormNode | ArrayOfObjectsFormNode {\n return \"members\" in node;\n}\n\n/**\n * Gathers the validation reported on a form node and on anything inside it.\n *\n * @param node - The form node to gather validation from.\n * @returns Every validation reported on the node or within it.\n */\nfunction collectNodeValidation(node: BaseFormNode): BaseFormNode[\"validation\"] {\n return [...node.validation, ...(hasMembers(node) ? collectMemberValidation(node.members) : [])];\n}\n\n/**\n * Gathers the validation reported anywhere inside a field's members. The form hands a field only what\n * is reported at its own path, which suits a frame drawing its members inline but leaves one that\n * hides them showing nothing they report.\n *\n * @param members - The members to gather validation from.\n * @returns Every validation reported on a member or within one.\n */\nfunction collectMemberValidation(members: (ObjectMember | ArrayOfObjectsMember)[]): BaseFormNode[\"validation\"] {\n return members.flatMap((member) => {\n if (member.kind === \"field\") return collectNodeValidation(member.field);\n if (member.kind === \"fieldSet\") return collectMemberValidation(member.fieldSet.members);\n if (member.kind === \"item\") return collectNodeValidation(member.item);\n\n return [];\n });\n}\n\nexport type FieldProps = ObjectFieldProps;\n\nexport function Field({\n actions,\n schemaType,\n title,\n description,\n presence,\n validation,\n level,\n inputId,\n path,\n changed,\n children,\n inputProps,\n}: FieldProps) {\n const [headerActions, setHeaderActions] = useState<DocumentFieldActionNode[]>([]);\n\n const documentId = useFormValue([\"_id\"]);\n const publishedId = typeof documentId === \"string\" ? getPublishedId(documentId) : undefined;\n const focused = inputProps.focused === true;\n const fieldValidation = [...validation, ...collectMemberValidation(inputProps.members)];\n\n return (\n <>\n {isDefined(publishedId) && isDefined(actions) && (\n <FieldActionsResolver\n actions={actions}\n documentId={publishedId}\n documentType={schemaType.name}\n onActions={setHeaderActions}\n path={path}\n schemaType={schemaType}\n />\n )}\n <FieldActionsProvider actions={headerActions} focused={focused} path={path}>\n <FormField\n __unstable_headerActions={headerActions}\n __unstable_presence={presence}\n description={description}\n inputId={inputId}\n level={level}\n title={title}\n validation={fieldValidation}\n deprecated={schemaType.deprecated}\n path={path}\n readOnly={inputProps.readOnly}\n >\n <ChangeIndicator path={path} hasFocus={focused} isChanged={changed}>\n {children}\n </ChangeIndicator>\n </FormField>\n </FieldActionsProvider>\n </>\n );\n}\n","import type { ComponentProps, ComponentType } from \"react\";\nimport { createElement } from \"react\";\n\n/**\n * Properties the plugin's own icons are drawn with. Icons taken from `@sanity/icons` are left alone,\n * since they already carry the sizing and stroke the rest of the Studio uses.\n */\nexport const defaultIconProps: ComponentProps<\"svg\"> = { width: \"1em\", height: \"1em\", strokeWidth: 1.5 };\n\n/**\n * Creates a Sanity Studio icon component from an SVG icon.\n *\n * @param icon - The icon component to wrap.\n * @param props - Additional props merged over the default properties a Studio icon is drawn with.\n * @returns A Studio icon component.\n */\nexport function createSanityIcon(icon: ComponentType<ComponentProps<\"svg\">>, props?: ComponentProps<\"svg\">) {\n const Icon = icon;\n\n function SanityIcon() {\n return createElement(Icon, { ...defaultIconProps, ...props });\n }\n\n return SanityIcon;\n}\n","import type { ComponentProps } from \"react\";\n\nexport type HashIconProps = ComponentProps<\"svg\">;\n\nexport function HashIcon(props: HashIconProps) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={24}\n height={24}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...props}\n >\n <line x1=\"4\" x2=\"20\" y1=\"9\" y2=\"9\" />\n <line x1=\"4\" x2=\"20\" y1=\"15\" y2=\"15\" />\n <line x1=\"10\" x2=\"8\" y1=\"3\" y2=\"21\" />\n <line x1=\"16\" x2=\"14\" y1=\"3\" y2=\"21\" />\n </svg>\n );\n}\n","import { defaultIconProps } from \"@repo/lib/icons\";\nimport { isDefined } from \"@repo/lib/utils\";\nimport { TextInput } from \"@sanity/ui\";\nimport type { ChangeEvent } from \"react\";\nimport type { StringInputProps } from \"sanity\";\nimport { set, unset } from \"sanity\";\n\nimport { HashIcon } from \"@/icons/hash\";\n\nexport type AnchorProps = StringInputProps;\n\nexport function Anchor({ elementProps, value, onChange, readOnly }: AnchorProps) {\n function handleChange(event: ChangeEvent<HTMLInputElement>) {\n const next = event.currentTarget.value;\n\n onChange(isDefined(next) ? set(next) : unset());\n }\n\n // The prefix slot sizes to its content, so the hash goes in the icon slot to match the field height.\n return (\n <TextInput\n {...elementProps}\n icon={<HashIcon {...defaultIconProps} width=\"0.8em\" height=\"0.8em\" />}\n value={value ?? \"\"}\n readOnly={readOnly}\n onChange={handleChange}\n placeholder=\"our-values\"\n />\n );\n}\n","export function Hidden() {\n return null;\n}\n","import { isDefined } from \"@repo/lib/utils\";\nimport { stegaClean } from \"@sanity/client/stega\";\n\nimport { composeAnchorHref } from \"@/lib/destinations\";\nimport type { SanityLink } from \"@/types\";\n\n/**\n * Reads the host a web address points at, so a link to a file buried three folders deep still reads\n * as the site it came from. The subdomain everyone ignores goes with it.\n *\n * @param url - The address to read.\n * @returns The host, or undefined when the address cannot be read as one.\n */\nfunction getDomain(url: string | undefined) {\n const address = stegaClean(url);\n if (!isDefined(address)) return undefined;\n\n try {\n return new URL(address).hostname.replace(/^www\\./u, \"\");\n } catch {\n return undefined;\n }\n}\n\n/**\n * Describes where a link leads using only what the document already holds, which covers every\n * destination an author typed out in full.\n *\n * @param value - The link being authored.\n * @returns The description, or undefined when the destination is stored as a pointer.\n */\nexport function getLocalDetail(value: Partial<SanityLink> | undefined) {\n if (!isDefined(value)) return undefined;\n\n if (value.type === \"anchor\") return composeAnchorHref(value.anchor);\n if (value.type === \"url\") return getDomain(value.url);\n if (value.type === \"email\") return stegaClean(value.email);\n if (value.type === \"phone\") return stegaClean(value.phone);\n\n return undefined;\n}\n\n/**\n * Names the document a link leads to, for the two destinations stored as a pointer rather than as\n * something an author wrote.\n *\n * @param value - The link being authored.\n * @returns The document's identifier, or undefined when the destination holds none.\n */\nexport function getReferencedId(value: Partial<SanityLink> | undefined) {\n if (!isDefined(value)) return undefined;\n\n if (value.type === \"page\") {\n const { reference } = value;\n\n return isDefined(reference) && \"_ref\" in reference ? reference._ref : undefined;\n }\n\n if (value.type === \"file\") {\n const asset = value.file?.asset;\n\n return isDefined(asset) && \"_ref\" in asset ? asset._ref : undefined;\n }\n\n return undefined;\n}\n\n/**\n * Builds the one line the closed control reads, putting what an author wrote first and where it\n * leads in brackets behind it. Either alone stands on its own.\n *\n * @param label - Text the author wrote.\n * @param detail - Where the link leads.\n * @returns The line, or undefined when neither is known.\n */\nexport function composeSummary(label: string | undefined, detail: string | undefined) {\n const written = stegaClean(label);\n if (isDefined(written) && isDefined(detail)) return `${written} (${detail})`;\n\n return written ?? detail;\n}\n","import { isDefined, readPath } from \"@repo/lib/utils\";\nimport { useEffect, useState } from \"react\";\nimport { useDocumentPreviewStore } from \"sanity\";\n\nimport { getLocalDetail, getReferencedId } from \"@/lib/summary\";\nimport type { SanityLink } from \"@/types\";\n\n/** What was read, kept with the destination it was read for so a stale answer is never shown. */\ninterface ReadDetail {\n /** Identifier of the destination the description was read for. */\n id: string;\n /** Description of where the link leads, absent when the destination holds nothing to read. */\n detail?: string;\n}\n\n/**\n * Describes where a link leads, reading the title or filename held by the document it points at.\n * Read through the Studio's preview store, so links share one subscription and a rename updates them.\n *\n * @param value - The link being authored.\n * @param titleField - Field an internal link's destination holds its title in.\n * @returns Where the link leads, or undefined while it is being read or when there is nothing to read.\n */\nexport function useDestinationDetail(value: Partial<SanityLink> | undefined, titleField: string) {\n const previewStore = useDocumentPreviewStore();\n\n const local = getLocalDetail(value);\n const id = getReferencedId(value);\n const isFile = value?.type === \"file\";\n\n const [read, setRead] = useState<ReadDetail>();\n\n useEffect(() => {\n if (!isDefined(id)) return undefined;\n\n // Held under its own name so the closure below keeps the narrowing the guard above established.\n const destinationId = id;\n const path = (isFile ? \"originalFilename\" : titleField).split(\".\");\n\n const subscription = previewStore.observePaths({ _ref: destinationId }, [path]).subscribe((document) => {\n const detail = readPath(document, path);\n\n setRead({ id: destinationId, detail: typeof detail === \"string\" ? detail : undefined });\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [previewStore, id, isFile, titleField]);\n\n const observed = isDefined(read) && read.id === id ? read.detail : undefined;\n\n return local ?? observed;\n}\n","import type { ComponentProps } from \"react\";\n\nexport type LinkIconProps = ComponentProps<\"svg\">;\n\nexport function LinkIcon(props: LinkIconProps) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={24}\n height={24}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...props}\n >\n <path d=\"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\" />\n <path d=\"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\" />\n </svg>\n );\n}\n","import type { ComponentProps } from \"react\";\n\nexport type ExternalLinkIconProps = ComponentProps<\"svg\">;\n\nexport function ExternalLinkIcon(props: ExternalLinkIconProps) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={24}\n height={24}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...props}\n >\n <path d=\"M15 3h6v6\" />\n <path d=\"M10 14 21 3\" />\n <path d=\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\" />\n </svg>\n );\n}\n","import type { ComponentProps } from \"react\";\n\nexport type FileDownIconProps = ComponentProps<\"svg\">;\n\nexport function FileDownIcon(props: FileDownIconProps) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={24}\n height={24}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...props}\n >\n <path d=\"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z\" />\n <path d=\"M14 2v5a1 1 0 0 0 1 1h5\" />\n <path d=\"M12 18v-6\" />\n <path d=\"m9 15 3 3 3-3\" />\n </svg>\n );\n}\n","import type { ComponentProps } from \"react\";\n\nexport type FileSymlinkIconProps = ComponentProps<\"svg\">;\n\nexport function FileSymlinkIcon(props: FileSymlinkIconProps) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={24}\n height={24}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...props}\n >\n <path d=\"M4 11V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7\" />\n <path d=\"M14 2v5a1 1 0 0 0 1 1h5\" />\n <path d=\"m10 18 3-3-3-3\" />\n </svg>\n );\n}\n","import type { ComponentProps } from \"react\";\n\nexport type MailIconProps = ComponentProps<\"svg\">;\n\nexport function MailIcon(props: MailIconProps) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={24}\n height={24}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...props}\n >\n <path d=\"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7\" />\n <rect x=\"2\" y=\"4\" width=\"20\" height=\"16\" rx=\"2\" />\n </svg>\n );\n}\n","import type { ComponentProps } from \"react\";\n\nexport type PhoneIconProps = ComponentProps<\"svg\">;\n\nexport function PhoneIcon(props: PhoneIconProps) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={24}\n height={24}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...props}\n >\n <path d=\"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384\" />\n </svg>\n );\n}\n","import type { ComponentProps, ComponentType } from \"react\";\n\nimport { ExternalLinkIcon } from \"@/icons/external-link\";\nimport { FileDownIcon } from \"@/icons/file-down\";\nimport { FileSymlinkIcon } from \"@/icons/file-symlink\";\nimport { HashIcon } from \"@/icons/hash\";\nimport { MailIcon } from \"@/icons/mail\";\nimport { PhoneIcon } from \"@/icons/phone\";\nimport type { SanityLinkDestination } from \"@/types\";\n\n/** One kind of destination a link may point at, as the Studio offers it. */\ninterface LinkTypeDefinition {\n /** Value stored to discriminate the link. */\n name: SanityLinkDestination;\n /** Icon shown beside the destination wherever it is named. */\n icon: ComponentType<ComponentProps<\"svg\">>;\n /** The one name this destination goes by, on its tab and anywhere else it is named. */\n label: string;\n /** Fields this destination shows. A field may be shared, as the anchor is by a page and a section. */\n fields: string[];\n}\n\n/**\n * The kinds of destination a link may point at, offered in this order. The stored union, the schema's\n * fields, the tabs, and the resolver all follow it.\n */\nexport const linkTypes = [\n { name: \"page\", icon: FileSymlinkIcon, label: \"Page\", fields: [\"reference\", \"anchor\", \"searchParams\"] },\n { name: \"anchor\", icon: HashIcon, label: \"Anchor\", fields: [\"anchor\"] },\n { name: \"url\", icon: ExternalLinkIcon, label: \"URL\", fields: [\"url\"] },\n { name: \"email\", icon: MailIcon, label: \"Email\", fields: [\"email\", \"subject\"] },\n { name: \"phone\", icon: PhoneIcon, label: \"Phone\", fields: [\"phone\"] },\n { name: \"file\", icon: FileDownIcon, label: \"File\", fields: [\"file\"] },\n] as const satisfies LinkTypeDefinition[];\n\n/** Destinations offered where nothing narrows them. */\nexport const defaultDestinations: SanityLinkDestination[] = linkTypes.map((linkType) => linkType.name);\n","import { linkTypes } from \"@/config/destinations\";\nimport type { SanityLinkDestination } from \"@/types\";\nimport { linkMarkTypeName } from \"@/types\";\n\n/**\n * Reads which kind of destination a stored value names, so the tabs and the preview describe the same\n * choice. A value the plugin no longer offers reads as no choice at all.\n *\n * @param name - The stored type value.\n * @returns The matching link type, or undefined when nothing recognisable was stored.\n */\nexport function getLinkType(name: string | undefined) {\n return linkTypes.find((linkType) => linkType.name === name);\n}\n\n/**\n * Names the fields every other destination owns, so moving to one clears what the last one wrote. A\n * field the destination being moved to also owns is kept, since a page and a section share the anchor.\n *\n * @param type - The destination being moved to.\n * @returns Fields belonging to the destinations being left.\n */\nexport function getStaleFields(type: SanityLinkDestination) {\n const kept = new Set<string>(getLinkType(type)?.fields);\n\n return linkTypes\n .filter((linkType) => linkType.name !== type)\n .flatMap((linkType) => [...linkType.fields])\n .filter((field) => !kept.has(field));\n}\n\n/**\n * Checks whether the destination a link points at shows a given field, so a field's visibility is\n * read from the one table that says which destination owns what.\n *\n * @param parent - The link the field belongs to.\n * @param field - Name of the field to check for.\n * @returns Whether the link's destination shows that field.\n */\nexport function showsField(parent: unknown, field: string) {\n return linkTypes.some(\n (linkType) => linkType.fields.some((owned) => owned === field) && isLinkType(parent, linkType.name),\n );\n}\n\n/**\n * Checks the kind of destination the link a field belongs to points at, so a field is shown and\n * required only for the link type that uses it.\n *\n * @param parent - The link the field belongs to.\n * @param type - The link type to check for.\n * @returns Whether the link points at that kind of destination.\n */\nexport function isLinkType(parent: unknown, type: SanityLinkDestination) {\n return typeof parent === \"object\" && parent !== null && \"type\" in parent && parent.type === type;\n}\n\n/**\n * Checks whether the link a field belongs to was authored as an annotation, where the text it wraps\n * supplies what the field would otherwise hold.\n *\n * @param parent - The link the field belongs to.\n * @returns Whether the link is a text annotation.\n */\nexport function isLinkMark(parent: unknown) {\n return typeof parent === \"object\" && parent !== null && \"_type\" in parent && parent._type === linkMarkTypeName;\n}\n","import { isDefined } from \"@repo/lib/utils\";\n\nimport { defaultDestinations, linkTypes } from \"@/config/destinations\";\nimport { getLinkType } from \"@/lib/link-types\";\nimport type { SanityLinkConfig, SanityLinkOptions } from \"@/plugin\";\nimport type { SanityLinkDestination } from \"@/types\";\n\n/** One destination as the Studio offers it, for passing an already-narrowed set around. */\nexport type LinkType = (typeof linkTypes)[number];\n\n/**\n * Settles what a link field offers. The list says what is on and replaces whatever the plugin was\n * given, so one line tells you the whole answer.\n *\n * @param options - Options the field itself was given.\n * @param config - Configuration the plugin was given.\n * @returns The settings the field runs on.\n */\nexport function resolveLinkOptions(options: SanityLinkOptions | undefined, config: SanityLinkConfig) {\n return {\n destinations: options?.destinations ?? config.destinations ?? defaultDestinations,\n };\n}\n\n/**\n * Narrows the destinations to those on offer, in the order they were named. A name this version does\n * not recognise is skipped, and a set that leaves nothing offers them all rather than a field with\n * nowhere to point.\n *\n * @param destinations - Destinations to offer.\n * @returns The destinations on offer, of which there is always at least one.\n */\nexport function getOfferedLinkTypes(destinations: SanityLinkDestination[]): [LinkType, ...LinkType[]] {\n const [offered, ...rest] = [...new Set(destinations)].flatMap((name) => {\n const linkType = getLinkType(name);\n\n return isDefined(linkType) ? [linkType] : [];\n });\n\n const [everything, ...others] = linkTypes;\n\n return isDefined(offered) ? [offered, ...rest] : [everything, ...others];\n}\n","import { defaultIconProps } from \"@repo/lib/icons\";\nimport { isDefined } from \"@repo/lib/utils\";\nimport { CloseIcon } from \"@sanity/icons/Close\";\nimport { Box, Button, Dialog, Flex, Stack, Tab, TabList, TabPanel } from \"@sanity/ui\";\nimport type { ReactNode } from \"react\";\nimport { useEffect, useState } from \"react\";\nimport type { ObjectInputProps, ObjectSchemaType } from \"sanity\";\nimport { set, setIfMissing, unset } from \"sanity\";\n\nimport { useDestinationDetail } from \"@/hooks/use-destination-detail\";\nimport { LinkIcon } from \"@/icons/link\";\nimport { getLinkType, getStaleFields } from \"@/lib/link-types\";\nimport type { LinkType } from \"@/lib/options\";\nimport { getOfferedLinkTypes, resolveLinkOptions } from \"@/lib/options\";\nimport { composeSummary } from \"@/lib/summary\";\nimport type { SanityLinkConfig, SanityLinkOptions } from \"@/plugin\";\nimport type { SanityLink, SanityLinkDestination } from \"@/types\";\n\ninterface DestinationsProps {\n id: string;\n offered: LinkType[];\n selected: LinkType;\n showTabs: boolean;\n readOnly: boolean | undefined;\n onSelect: (type: SanityLinkDestination) => void;\n children: ReactNode;\n}\n\nfunction Destinations({ id, offered, selected, showTabs, readOnly, onSelect, children }: DestinationsProps) {\n return (\n <Stack gap={4}>\n {showTabs && (\n <TabList gap={1}>\n {offered.map((linkType) => (\n <Tab\n key={linkType.name}\n id={`${id}-tab-${linkType.name}`}\n aria-controls={`${id}-panel`}\n icon={<linkType.icon {...defaultIconProps} />}\n label={linkType.label}\n selected={linkType.name === selected.name}\n disabled={readOnly}\n onClick={() => {\n onSelect(linkType.name);\n }}\n />\n ))}\n </TabList>\n )}\n {showTabs && (\n <TabPanel id={`${id}-panel`} aria-labelledby={`${id}-tab-${selected.name}`} paddingTop={3}>\n {children}\n </TabPanel>\n )}\n {!showTabs && children}\n </Stack>\n );\n}\n\n/** Compiled shape of a link field, carrying the options the field itself was given. */\ninterface LinkSchemaType extends ObjectSchemaType {\n options?: SanityLinkOptions;\n}\n\nexport type InputProps = ObjectInputProps<Partial<SanityLink>, LinkSchemaType>;\n\n/**\n * Builds the patches that move a link to a destination, clearing whatever the last one wrote. A\n * destination moved away from would otherwise stay in the document unseen, and reappear the moment\n * an author moved the tab back.\n *\n * @param typeName - Name the link type is registered under.\n * @param type - The destination being moved to.\n * @returns The patches to apply.\n */\nfunction createDestinationPatches(typeName: string, type: SanityLinkDestination) {\n return [\n setIfMissing({ _type: typeName }),\n set(type, [\"type\" satisfies keyof SanityLink]),\n ...getStaleFields(type).map((field) => unset([field])),\n ];\n}\n\n/**\n * Creates the input a link field is drawn with, holding what the plugin was configured with so a\n * field naming its own destinations replaces them rather than adding to them.\n *\n * @param titleField - Field an internal link's destination holds its title in.\n * @param config - Configuration the plugin was given.\n * @returns The input component.\n */\nexport function createInput(titleField: string, config: SanityLinkConfig) {\n function Input(props: InputProps) {\n const { id, path, schemaType, value, onChange, readOnly, renderDefault } = props;\n\n const [open, setOpen] = useState(false);\n\n const { destinations } = resolveLinkOptions(schemaType.options, config);\n const offered = getOfferedLinkTypes(destinations);\n const [defaultLinkType] = offered;\n\n const stored = getLinkType(value?.type);\n const selected = stored ?? defaultLinkType;\n const detail = useDestinationDetail(value, titleField);\n const summary = composeSummary(value?.label, detail) ?? stored?.label;\n const Icon = stored?.icon ?? LinkIcon;\n\n // An object inside an array ends its path with a keyed segment, where a plain field ends with a name.\n const isArrayItem = typeof path.at(-1) === \"object\";\n\n const showTabs = offered.length > 1;\n\n function handleSelectType(type: SanityLinkDestination) {\n onChange(createDestinationPatches(schemaType.name, type));\n }\n\n // An array item has no button of ours to write the standing destination, so mounting writes it.\n useEffect(() => {\n if (!isArrayItem || isDefined(stored)) return;\n\n onChange(createDestinationPatches(schemaType.name, selected.name));\n }, [isArrayItem, stored, selected, onChange, schemaType.name]);\n\n if (isArrayItem) {\n return (\n <Destinations\n id={id}\n offered={offered}\n selected={selected}\n showTabs={showTabs}\n readOnly={readOnly}\n onSelect={handleSelectType}\n >\n {renderDefault(props)}\n </Destinations>\n );\n }\n\n return (\n <Flex gap={2}>\n <Button\n id={id}\n type=\"button\"\n mode=\"ghost\"\n icon={<Icon {...defaultIconProps} />}\n text={summary ?? \"Add link\"}\n disabled={readOnly}\n onClick={() => {\n if (!isDefined(stored)) handleSelectType(selected.name);\n\n setOpen(true);\n }}\n aria-label={isDefined(summary) ? `Edit link: ${summary}` : \"Add link\"}\n />\n {isDefined(value) && (\n <Button\n type=\"button\"\n mode=\"ghost\"\n tone=\"critical\"\n icon={<CloseIcon />}\n text=\"Clear\"\n disabled={readOnly}\n onClick={() => {\n onChange(unset());\n }}\n aria-label=\"Clear this link\"\n />\n )}\n {open && (\n <Dialog\n id={`${id}-dialog`}\n header=\"Link\"\n width={1}\n onClose={() => {\n setOpen(false);\n }}\n onClickOutside={() => {\n setOpen(false);\n }}\n >\n <Box padding={4}>\n <Destinations\n id={id}\n offered={offered}\n selected={selected}\n showTabs={showTabs}\n readOnly={readOnly}\n onSelect={handleSelectType}\n >\n {renderDefault(props)}\n </Destinations>\n </Box>\n </Dialog>\n )}\n </Flex>\n );\n }\n\n return Input;\n}\n","import { isDefined } from \"@repo/lib/utils\";\nimport { AddIcon } from \"@sanity/icons/Add\";\nimport { CloseIcon } from \"@sanity/icons/Close\";\nimport { Box, Button, Flex, Stack, TextInput } from \"@sanity/ui\";\nimport { randomKey } from \"@sanity/util/content\";\nimport type { ChangeEvent } from \"react\";\nimport type { ArrayOfObjectsInputProps } from \"sanity\";\nimport { insert, set, setIfMissing, unset } from \"sanity\";\n\nimport type { SanityLinkSearchParam } from \"@/types\";\nimport { searchParamTypeName } from \"@/types\";\n\n/**\n * Reads a row's pair, which arrives as the bare keyed item the array input is typed with rather than\n * as the parameter it holds.\n *\n * @param param - The stored row.\n * @returns The name and value the row carries, either of which may be unwritten.\n */\nfunction readParam(param: { _key: string }) {\n return {\n key: \"key\" in param && typeof param.key === \"string\" ? param.key : undefined,\n value: \"value\" in param && typeof param.value === \"string\" ? param.value : undefined,\n };\n}\n\nexport type SearchParamsProps = ArrayOfObjectsInputProps;\n\nexport function SearchParams({ id, value, onChange, readOnly }: SearchParamsProps) {\n const params = value ?? [];\n\n function handleEdit(key: string, field: keyof SanityLinkSearchParam, next: string) {\n onChange(isDefined(next) ? set(next, [{ _key: key }, field]) : unset([{ _key: key }, field]));\n }\n\n return (\n <Stack gap={2}>\n {params.map((param, index) => {\n const { key, value: parameterValue } = readParam(param);\n const position = String(index + 1);\n\n return (\n <Flex key={param._key} gap={2} align=\"center\">\n <Box flex={1}>\n <TextInput\n id={index === 0 ? id : undefined}\n value={key ?? \"\"}\n placeholder=\"Name\"\n readOnly={readOnly}\n onChange={(event: ChangeEvent<HTMLInputElement>) => {\n handleEdit(param._key, \"key\", event.currentTarget.value);\n }}\n aria-label={`Name of parameter ${position}`}\n />\n </Box>\n <Box flex={1}>\n <TextInput\n value={parameterValue ?? \"\"}\n placeholder=\"Value\"\n readOnly={readOnly}\n onChange={(event: ChangeEvent<HTMLInputElement>) => {\n handleEdit(param._key, \"value\", event.currentTarget.value);\n }}\n aria-label={`Value of parameter ${position}`}\n />\n </Box>\n <Button\n type=\"button\"\n mode=\"bleed\"\n tone=\"critical\"\n icon={<CloseIcon />}\n disabled={readOnly}\n onClick={() => {\n onChange(unset([{ _key: param._key }]));\n }}\n aria-label={`Remove parameter ${position}`}\n />\n </Flex>\n );\n })}\n <Flex>\n <Button\n type=\"button\"\n mode=\"ghost\"\n icon={<AddIcon />}\n text=\"Add parameter\"\n disabled={readOnly}\n onClick={() => {\n onChange([setIfMissing([]), insert([{ _type: searchParamTypeName, _key: randomKey(12) }], \"after\", [-1])]);\n }}\n />\n </Flex>\n </Stack>\n );\n}\n","import { Field } from \"@repo/components/field\";\nimport { createSanityIcon } from \"@repo/lib/icons\";\nimport { convertCase, isDefined } from \"@repo/lib/utils\";\nimport { defineArrayMember, defineField, defineType } from \"sanity\";\n\nimport { Anchor } from \"@/components/anchor\";\nimport { Hidden } from \"@/components/hidden\";\nimport { createInput } from \"@/components/input\";\nimport { SearchParams } from \"@/components/search-params\";\nimport { defaultTitleField } from \"@/config/defaults\";\nimport { linkTypes } from \"@/config/destinations\";\nimport { LinkIcon } from \"@/icons/link\";\nimport { getLinkType, isLinkMark, isLinkType, showsField } from \"@/lib/link-types\";\nimport type { SanityLinkConfig } from \"@/plugin\";\nimport type {\n SanityEmailLink,\n SanityFileLink,\n SanityLink,\n SanityLinkDestination,\n SanityLinkSearchParam,\n SanityPageLink,\n SanityPhoneLink,\n SanityUrlLink,\n} from \"@/types\";\nimport { linkTypeName, searchParamTypeName } from \"@/types\";\n\n/**\n * Creates the object type a link is stored as, offering internal pages among the document types it\n * is given and borrowing a label from whichever field those documents hold their title in.\n *\n * @param config - Configuration the plugin was given.\n * @returns An object type definition for a stored link.\n */\nexport function createLinkType(config: SanityLinkConfig) {\n const { documentTypes, title: { field: titleField = defaultTitleField } = {} } = config;\n\n return defineType({\n name: linkTypeName satisfies SanityLink[\"_type\"],\n type: \"object\",\n icon: createSanityIcon(LinkIcon),\n description: \"Link to a page, a URL, an email address, a phone number, or a file.\",\n // Deliberately the flat frame a primitive field gets, not the collapsible fieldset Sanity wraps an object in.\n components: { field: Field, input: createInput(titleField, config) },\n // The field naming the destination sits behind a tab, so requiring it would report where nobody looks.\n validation: (rule) =>\n rule.custom((value: Partial<SanityLink> | undefined) =>\n !isDefined(value) || isDefined(value.type) ? true : \"Choose a destination.\",\n ),\n preview: {\n select: {\n type: \"type\",\n title: `reference.${titleField}`,\n label: \"label\",\n },\n prepare(selection: { type?: SanityLinkDestination; title?: string; label?: string }) {\n const { type, title, label } = selection;\n const linkType = getLinkType(type);\n\n return {\n title: label ?? title ?? linkType?.label ?? \"Link\",\n media: createSanityIcon(linkType?.icon ?? LinkIcon),\n };\n },\n },\n fields: [\n defineField({\n name: \"type\" satisfies keyof SanityLink,\n type: \"string\",\n description: \"Which kind of destination this link points at, chosen from the tabs above.\",\n // Sanity drops an object whose every member is hidden, so this field is kept in the form and draws nothing.\n components: { field: Hidden },\n }),\n defineField({\n name: \"reference\" satisfies keyof SanityPageLink,\n type: \"reference\",\n description: \"Page on this site to link to, which keeps working if its address changes.\",\n to: documentTypes.map((type) => ({ type })),\n hidden: ({ parent }) => !showsField(parent, \"reference\"),\n validation: (rule) =>\n rule.custom((value, context) =>\n isLinkType(context.parent, \"page\") && !isDefined(value) ? \"Choose the page this link opens.\" : true,\n ),\n }),\n defineField({\n name: \"url\" satisfies keyof SanityUrlLink,\n type: \"url\",\n title: \"URL\",\n description: \"Full web address to link to, including the https:// in front of it.\",\n hidden: ({ parent }) => !showsField(parent, \"url\"),\n validation: (rule) =>\n rule\n .uri({ scheme: [\"http\", \"https\"] })\n .custom((value, context) =>\n isLinkType(context.parent, \"url\") && !isDefined(value) ? \"Enter the web address this link opens.\" : true,\n ),\n }),\n defineField({\n name: \"email\" satisfies keyof SanityEmailLink,\n type: \"string\",\n description: \"Address a message opens to when a visitor follows this link.\",\n hidden: ({ parent }) => !showsField(parent, \"email\"),\n validation: (rule) =>\n rule\n .email()\n .custom((value, context) =>\n isLinkType(context.parent, \"email\") && !isDefined(value)\n ? \"Enter the address this link opens a message to.\"\n : true,\n ),\n }),\n defineField({\n name: \"subject\" satisfies keyof SanityEmailLink,\n type: \"string\",\n description: \"Optional subject line, filled in for the visitor before they start writing.\",\n hidden: ({ parent }) => !showsField(parent, \"subject\"),\n }),\n defineField({\n name: \"phone\" satisfies keyof SanityPhoneLink,\n type: \"string\",\n description: \"Number to call, written however it reads best. Spacing is ignored.\",\n hidden: ({ parent }) => !showsField(parent, \"phone\"),\n validation: (rule) =>\n rule\n .regex(/^\\+?[\\d\\s()-]{6,}$/u, { name: \"phone number\" })\n .custom((value, context) =>\n isLinkType(context.parent, \"phone\") && !isDefined(value) ? \"Enter the number this link calls.\" : true,\n ),\n }),\n defineField({\n name: \"file\" satisfies keyof SanityFileLink,\n type: \"file\",\n description: \"File a visitor downloads, uploaded here so it stays with the link.\",\n hidden: ({ parent }) => !showsField(parent, \"file\"),\n validation: (rule) =>\n rule.custom((value, context) =>\n isLinkType(context.parent, \"file\") && !isDefined(value) ? \"Upload the file this link serves.\" : true,\n ),\n }),\n defineField({\n name: \"anchor\" satisfies keyof SanityPageLink,\n type: \"string\",\n description: \"Section of the page to send the visitor to, named without its leading hash.\",\n hidden: ({ parent }) => !showsField(parent, \"anchor\"),\n components: { input: Anchor },\n validation: (rule) =>\n rule.custom((value, context) => {\n if (!isDefined(value)) {\n return isLinkType(context.parent, \"anchor\") ? \"Name the section this link scrolls to.\" : true;\n }\n\n return value === convertCase(value, \"kebab\")\n ? true\n : \"Write the section name in lowercase, with hyphens instead of spaces.\";\n }),\n }),\n defineField({\n name: \"searchParams\" satisfies keyof SanityPageLink,\n type: \"array\",\n title: \"Search Parameters\",\n description: \"Extra values carried in the address, often recording where a visitor came from.\",\n hidden: ({ parent }) => !showsField(parent, \"searchParams\"),\n components: { input: SearchParams },\n validation: (rule) =>\n rule.custom((value: SanityLinkSearchParam[] | undefined) =>\n !isDefined(value) || value.every(({ key, value: carried }) => !isDefined(carried) || isDefined(key))\n ? true\n : \"Name every parameter that carries a value.\",\n ),\n of: [\n defineArrayMember({\n name: searchParamTypeName satisfies SanityLinkSearchParam[\"_type\"],\n type: \"object\",\n preview: {\n select: {\n key: \"key\" satisfies keyof SanityLinkSearchParam,\n value: \"value\" satisfies keyof SanityLinkSearchParam,\n },\n prepare(selection: { key?: string; value?: string }) {\n const { key, value } = selection;\n\n return { title: key ?? \"Parameter\", subtitle: value };\n },\n },\n fields: [\n defineField({\n name: \"key\" satisfies keyof SanityLinkSearchParam,\n type: \"string\",\n description: \"Name this value is read under.\",\n }),\n defineField({\n name: \"value\" satisfies keyof SanityLinkSearchParam,\n type: \"string\",\n description: \"Value carried under that name.\",\n }),\n ],\n }),\n ],\n }),\n defineField({\n name: \"label\" satisfies keyof SanityLink,\n type: \"string\",\n description: \"Text a visitor clicks, which should still make sense out of context.\",\n hidden: ({ parent }) => isLinkMark(parent) || !linkTypes.some(({ name }) => isLinkType(parent, name)),\n validation: (rule) =>\n rule.custom((value, context) => {\n const { parent } = context;\n if (isLinkMark(parent) || isLinkType(parent, \"page\")) return true;\n\n return linkTypes.some(({ name }) => isLinkType(parent, name)) && !isDefined(value)\n ? \"Write the text a visitor clicks.\"\n : true;\n }),\n }),\n ],\n });\n}\n","import type { ObjectOptions, TypeAliasDefinition } from \"sanity\";\nimport { definePlugin } from \"sanity\";\n\nimport { pluginName } from \"@/config/defaults\";\nimport { createLinkType } from \"@/schemas/types/link\";\nimport type { SanityLinkDestination, linkTypeName } from \"@/types\";\n\ndeclare module \"@sanity/types\" {\n interface IntrinsicDefinitions {\n link: SanityLinkDefinition;\n }\n}\n\n/**\n * Options a link field takes. The list says what is on and replaces whatever the plugin was given,\n * so one line tells you the whole answer.\n *\n * @public\n */\nexport interface SanityLinkOptions extends ObjectOptions {\n /** Destinations an author may choose from, offered in the order they are named. All when omitted. */\n destinations?: SanityLinkDestination[];\n}\n\n/**\n * Shape of a field or array member holding a link, so its options are completed and checked the way\n * a built-in type's are.\n *\n * @public\n */\nexport interface SanityLinkDefinition extends Omit<TypeAliasDefinition<typeof linkTypeName, undefined>, \"options\"> {\n options?: SanityLinkOptions;\n}\n\n/**\n * Everything the plugin accepts, of which only the document types are required.\n *\n * @public\n */\nexport interface SanityLinkConfig {\n /** Document types an internal link may point at, offered in the order they are named. */\n documentTypes: string[];\n /** Destinations an author may choose from, offered in the order they are named. All when omitted. */\n destinations?: SanityLinkDestination[];\n /** Where a page's title is read from, for previews and for the label an internal link borrows. */\n title?: SanityLinkTitleField;\n}\n\n/**\n * Where the Studio reads a page's title from.\n *\n * @public\n */\nexport interface SanityLinkTitleField {\n /** Field a page holds its title in. Reads `title` when omitted. */\n field?: string;\n}\n\n/**\n * Creates the link field type for Sanity Studio, offering a page, a section of it, an address, an\n * email, a phone number, or a file behind one control, and resolving nothing about routing itself.\n *\n * @param config - Plugin configuration.\n * @returns Sanity plugin definition.\n * @public\n */\nexport const linkPlugin = definePlugin<SanityLinkConfig>((config) => ({\n name: pluginName,\n schema: {\n types: [createLinkType(config)],\n },\n}));\n","import { createSanityIcon } from \"@repo/lib/icons\";\nimport { defineArrayMember } from \"sanity\";\n\nimport { LinkIcon } from \"@/icons/link\";\nimport type { SanityLink } from \"@/types\";\nimport { linkMarkTypeName, linkTypeName } from \"@/types\";\n\n/**\n * The link as a Portable Text annotation, for a consumer's own text types to offer alongside their\n * other annotations. An annotated link takes the text it wraps as its label, so it never asks for\n * one of its own.\n *\n * @public\n */\nexport const linkAnnotation = defineArrayMember({\n // The name differs from the type deliberately: it is the name that gets stored as `_type`.\n name: linkMarkTypeName satisfies SanityLink[\"_type\"],\n type: linkTypeName,\n title: \"Link\",\n icon: createSanityIcon(LinkIcon),\n});\n","import type { EditorSchema } from \"@portabletext/editor\";\nimport { isDefined } from \"@repo/lib/utils\";\n\nimport type { SanityUrlLink } from \"@/types\";\nimport { linkMarkTypeName } from \"@/types\";\n\n/**\n * Builds the annotation a pasted address becomes, so an address arriving as markup lands on the link\n * type this plugin registers.\n *\n * @param schema - Schema of the editor the paste landed in.\n * @param url - Address the pasted link points at.\n * @returns The annotation to apply, or undefined when the editor offers no link annotation.\n */\nexport function createUrlLink(schema: EditorSchema, url: string) {\n const annotation = schema.annotations.find(({ name }) => name === linkMarkTypeName);\n if (!isDefined(annotation)) return undefined;\n\n return { _type: linkMarkTypeName, type: \"url\", url } satisfies SanityUrlLink;\n}\n","import { useEditor } from \"@portabletext/editor\";\nimport { defineBehavior, raise } from \"@portabletext/editor/behaviors\";\nimport { isSelectionExpanded } from \"@portabletext/editor/selectors\";\nimport { htmlToPortableText } from \"@portabletext/html\";\nimport { isDefined } from \"@repo/lib/utils\";\nimport { useEffect } from \"react\";\nimport type { PortableTextPluginsProps } from \"sanity\";\n\nimport { createUrlLink } from \"@/lib/annotations\";\n\n/**\n * Keeps hyperlinks when formatted text is pasted. Sanity's own handling recognises only its default\n * annotation shape, so a pasted link would otherwise arrive as plain text.\n */\nconst pasteUrlBehavior = defineBehavior({\n on: \"clipboard.paste\",\n guard: ({ snapshot, event }) => {\n const html = event.originEvent.dataTransfer.getData(\"text/html\");\n\n if (!/<a\\s[^>]*href/iu.test(html)) return false;\n\n const blocks = htmlToPortableText(html, {\n schema: snapshot.context.schema,\n keyGenerator: snapshot.context.keyGenerator,\n rules: [\n {\n deserialize(element, next) {\n if (!(element instanceof Element) || element.nodeName.toLowerCase() !== \"a\") return undefined;\n\n const url = element.getAttribute(\"href\");\n const link = isDefined(url) ? createUrlLink(snapshot.context.schema, url) : undefined;\n\n if (!isDefined(link)) return next(element.childNodes);\n\n return {\n _type: \"__annotation\",\n markDef: { ...link, _key: snapshot.context.keyGenerator() },\n children: next(element.childNodes),\n };\n },\n },\n ],\n });\n\n return { blocks };\n },\n actions: [\n ({ snapshot }, { blocks }) => [\n ...(isSelectionExpanded(snapshot) ? [raise({ type: \"delete\" })] : []),\n raise({ type: \"insert.blocks\", blocks, placement: \"auto\" }),\n ],\n ],\n});\n\n/**\n * Writes this plugin's link when an author pastes one, from formatted markup or a bare address. Pass\n * it to a text type's `components.portableText.plugins`.\n *\n * @param props - Portable Text plugin props the Studio supplies.\n * @returns The editor's own plugins, with link pasting replaced.\n * @public\n */\nexport function PortableTextLinkPlugins(props: PortableTextPluginsProps) {\n const editor = useEditor();\n\n useEffect(() => {\n const unregister = editor.registerBehavior({ behavior: pasteUrlBehavior });\n\n return () => {\n unregister();\n };\n }, [editor]);\n\n return props.renderDefault({\n ...props,\n plugins: {\n ...props.plugins,\n pasteLink: {\n ...props.plugins.pasteLink,\n link: ({ context, value }) => createUrlLink(context.schema, value.href),\n },\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,SAASe,WAAWC,MAAqE;CACvF,OAAO,aAAaA;AACtB;;;;;;;AAQA,SAASC,sBAAsBD,MAAgD;CAC7E,OAAO,CAAC,GAAGA,KAAKE,YAAY,GAAIH,WAAWC,IAAI,IAAIG,wBAAwBH,KAAKI,OAAO,IAAI,CAAA,CAAG;AAChG;;;;;;;;;AAUA,SAASD,wBAAwBC,SAA8E;CAC7G,OAAOA,QAAQC,SAASC,WAClBA,OAAOC,SAAS,UAAgBN,sBAAsBK,OAAOE,KAAK,IAClEF,OAAOC,SAAS,aAAmBJ,wBAAwBG,OAAOG,SAASL,OAAO,IAClFE,OAAOC,SAAS,SAAeN,sBAAsBK,OAAOI,IAAI,IAE7D,CAAA,CACR;AACH;AAIA,SAAOE,MAAAC,IAAA;CAAA,IAAAC,IAAAC,EAAA,EAAA,GAAe,EAAAC,SAAAC,YAAAC,OAAAC,aAAAC,UAAAlB,YAAAmB,OAAAC,SAAAC,MAAAC,SAAAC,UAAAC,eAAAb,IAaTc;CAAA,AAAAb,EAAA,OAAAc,OAAAC,IAAA,2BAAA,KACmEF,KAAA,CAAA,GAAEb,EAAA,KAAAa,MAAAA,KAAAb,EAAA;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C;EAAE,aAEpE;GACLwC,WAAW;EAAC;CACb,GACAD,KAAA,CAACF,MAAM,GAACF,EAAA,KAAAE,QAAAF,EAAA,KAAAG,IAAAH,EAAA,KAAAI,KANX1C,UAAUyC,IAMPC,EAAQ;CAAC,IAAAI;CAWV,OAXUR,EAAA,OAAAD,QAWVS,KAAAR,EAAA,MATKQ,KAAAT,MAAKU,cAAe;EAAA,GACtBV;EAAKW,SACC;GAAA,GACJX,MAAKW;GAAQC,WACL;IAAA,GACNZ,MAAKW,QAAQC;IAAUtB,MACpBuB;GACR;EACF;CACF,CAAC,GAACZ,EAAA,KAAAD,OAAAC,EAAA,KAAAQ,KATKA;AASL;AApBG,SAAAI,MAAAT,IAAA;CAiBQ,IAAA,EAAA1B,SAAAoC,UAAAV;CAAkB,OAAKvC,cAAca,QAAOD,QAASqC,MAAKC,IAAK;AAAC"}
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { a as SanityLinkDestination, c as SanityLinkFileAsset, d as SanityLinkSearchParam, f as SanityPageLink, i as SanityLink, l as SanityLinkReference, m as SanityUrlLink, n as SanityEmailLink, o as SanityLinkDocument, p as SanityPhoneLink, r as SanityFileLink, s as SanityLinkFile, t as SanityAnchorLink, u as SanityLinkRouteParams } from "./types-BXseTKgu.js";
|
|
2
|
+
/**
|
|
3
|
+
* One entry in a site's route table, pairing the path a document is served at with the GROQ that
|
|
4
|
+
* fills the parameters in it. Keys beyond these two are kept as written and mean nothing here.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
interface SanityLinkRouteDefinition {
|
|
9
|
+
/** URL path pattern, in which every `[name]` segment is a parameter. */
|
|
10
|
+
path: string;
|
|
11
|
+
/** GROQ expression resolving each path parameter against the documents the route renders. */
|
|
12
|
+
params?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Route definitions keyed by the document type each one renders.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
type SanityLinkRoutes = Record<string, SanityLinkRouteDefinition>;
|
|
20
|
+
/**
|
|
21
|
+
* Parameter names a path pattern declares, so `"/[category]/[slug]"` reads as `"category" | "slug"`.
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
type SanityLinkRouteParamNames<TPath extends string> = TPath extends `${string}[${infer TParam}]${infer TRest}` ? TParam | SanityLinkRouteParamNames<TRest> : never;
|
|
25
|
+
/**
|
|
26
|
+
* A route table checked against the patterns it declares, so every parameter a path names has a GROQ
|
|
27
|
+
* expression and nothing else does.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
type SanityCheckedLinkRoutes<TRoutes extends SanityLinkRoutes> = { [K in keyof TRoutes]: [SanityLinkRouteParamNames<TRoutes[K]["path"]>] extends [never] ? {
|
|
31
|
+
params?: undefined;
|
|
32
|
+
} : {
|
|
33
|
+
params: Record<SanityLinkRouteParamNames<TRoutes[K]["path"]>, string> & { [P in keyof TRoutes[K]["params"]]: P extends SanityLinkRouteParamNames<TRoutes[K]["path"]> ? string : never; };
|
|
34
|
+
}; };
|
|
35
|
+
/**
|
|
36
|
+
* Every route addressable without a document, each carrying the parameters its own path declares.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
type SanityLinkRouteInput<TRoutes extends SanityLinkRoutes> = { [K in keyof TRoutes & string]: {
|
|
41
|
+
_type: K;
|
|
42
|
+
} & Record<SanityLinkRouteParamNames<TRoutes[K]["path"]>, string>; }[keyof TRoutes & string];
|
|
43
|
+
/**
|
|
44
|
+
* A hook run after a link has been resolved, one per kind of destination, receiving the address the
|
|
45
|
+
* plugin built and the stored link it was built from. Returning nothing leaves the link pointing
|
|
46
|
+
* nowhere, as an unresolvable route does.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
type SanityLinkResolvers<TDocument extends SanityLinkDocument = SanityLinkDocument> = { [K in SanityLinkDestination]?: (href: string, link: Extract<SanityLink<TDocument>, {
|
|
51
|
+
type: K;
|
|
52
|
+
}>) => string | undefined | Promise<string | undefined>; };
|
|
53
|
+
/**
|
|
54
|
+
* Resolvers checked against the destinations a link may point at, so a key naming anything else is
|
|
55
|
+
* rejected rather than quietly never run.
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
type SanityCheckedLinkResolvers<TResolvers, TDocument extends SanityLinkDocument = SanityLinkDocument> = { [K in keyof TResolvers]: K extends SanityLinkDestination ? (href: string, link: Extract<SanityLink<TDocument>, {
|
|
59
|
+
type: K;
|
|
60
|
+
}>) => string | undefined | Promise<string | undefined> : never; };
|
|
61
|
+
/**
|
|
62
|
+
* Everything the resolver needs to know about a site before it can resolve a link against it. A site
|
|
63
|
+
* whose documents carry more than the plugin reads narrows the document type as well.
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
interface SanityLinkResolverConfig<TRoutes extends SanityLinkRoutes = SanityLinkRoutes, TDocument extends SanityLinkDocument = SanityLinkDocument, TResolvers extends SanityLinkResolvers<TDocument> = SanityLinkResolvers<TDocument>> {
|
|
68
|
+
/** Absolute address the site is served from, which decides what counts as leaving it. */
|
|
69
|
+
baseUrl: string;
|
|
70
|
+
/** Path patterns keyed by the document type each one renders. Page links lead nowhere when omitted. */
|
|
71
|
+
routes?: TRoutes & SanityCheckedLinkRoutes<TRoutes>;
|
|
72
|
+
/** Hooks having the last word on an address, one per kind of destination. */
|
|
73
|
+
resolvers?: TResolvers & SanityCheckedLinkResolvers<TResolvers, TDocument>;
|
|
74
|
+
/** Whether links leaving the site open in a new browser tab. Enabled when omitted. */
|
|
75
|
+
openExternalInNewTab?: boolean;
|
|
76
|
+
/** Where a page's title comes from, for the label an internal link borrows when none was written. */
|
|
77
|
+
title?: SanityLinkTitleConfig<TDocument>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Where a page's title is read from, both by the fragment that fetches it and by the resolver that
|
|
81
|
+
* labels a link with it.
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
interface SanityLinkTitleConfig<TDocument extends SanityLinkDocument = SanityLinkDocument> {
|
|
86
|
+
/** Field the link fragment fetches from a page. Reads `title` when omitted. */
|
|
87
|
+
field?: string;
|
|
88
|
+
/** Reads the title from a fetched page. Reads `field` when omitted. */
|
|
89
|
+
resolver?: (document: TDocument) => string | undefined;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A link resolved into the parts an anchor is drawn from.
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
interface SanityResolvedLink {
|
|
97
|
+
/** Address the link points at. */
|
|
98
|
+
href?: string;
|
|
99
|
+
/** Text a visitor reads, written by the author or borrowed from the destination. */
|
|
100
|
+
label?: string;
|
|
101
|
+
/** Whether the link serves a file rather than opening a page. */
|
|
102
|
+
download?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A resolved link alongside the navigation state around it, all of which a site needs to draw the
|
|
106
|
+
* link correctly rather than merely point it somewhere.
|
|
107
|
+
*
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
110
|
+
interface SanityLinkState {
|
|
111
|
+
/** The link resolved into the parts an anchor is drawn from, absent when it leads nowhere usable. */
|
|
112
|
+
resolvedLink: SanityResolvedLink | undefined;
|
|
113
|
+
/** Whether the destination is a web address on another site. */
|
|
114
|
+
isExternal: boolean;
|
|
115
|
+
/** Whether the link should open in a new browser tab. */
|
|
116
|
+
opensNewTab: boolean;
|
|
117
|
+
/** Whether the destination names a location within a page rather than the page itself. */
|
|
118
|
+
hasAnchor: boolean;
|
|
119
|
+
/** Whether the destination is the page being read or one of the paths above it. */
|
|
120
|
+
containsActivePath: boolean;
|
|
121
|
+
/** Whether the destination is the page being read and nothing else. */
|
|
122
|
+
isActivePath: boolean;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* What a resolution hands back, which is a promise when a declared resolver can only answer with one
|
|
126
|
+
* and the navigation state itself otherwise. A resolver that might answer either way reads as the
|
|
127
|
+
* synchronous form, since its declaration decides nothing.
|
|
128
|
+
*
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
type SanityLinkResolution<TResolvers> = [{ [K in keyof TResolvers]-?: NonNullable<TResolvers[K]> extends ((...args: never[]) => infer TAnswer) ? [Exclude<TAnswer, PromiseLike<unknown>>] extends [never] ? true : never : never; }[keyof TResolvers]] extends [never] ? SanityLinkState : Promise<SanityLinkState>;
|
|
132
|
+
/**
|
|
133
|
+
* A link to resolve, taken from the first source declared, and the page it is being drawn on.
|
|
134
|
+
*
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
interface SanityResolveLinkProps<TRoutes extends SanityLinkRoutes = SanityLinkRoutes, TDocument extends SanityLinkDocument = SanityLinkDocument> {
|
|
138
|
+
/** Stored link an author authored. */
|
|
139
|
+
link?: SanityLink<TDocument> | null | undefined;
|
|
140
|
+
/** Route named in code, for a destination no author authored. */
|
|
141
|
+
route?: SanityLinkRouteInput<TRoutes> | null | undefined;
|
|
142
|
+
/** Address to point at as it is. */
|
|
143
|
+
href?: string | null | undefined;
|
|
144
|
+
/** Path of the page being drawn, compared against the link to read its navigation state. Reading a navigation state without it throws in development. */
|
|
145
|
+
pathname?: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Binds a site's routing and conventions to the resolver, so a link is resolved the same way
|
|
149
|
+
* everywhere it is drawn.
|
|
150
|
+
*
|
|
151
|
+
* @param linkConfig - What the resolver needs to know about the site.
|
|
152
|
+
* @returns An object holding the resolver, the route table, and the GROQ the two of them rely on.
|
|
153
|
+
* @public
|
|
154
|
+
* @throws If the base address is not an absolute one.
|
|
155
|
+
*/
|
|
156
|
+
export declare function defineLinkConfig<const TRoutes extends SanityLinkRoutes = SanityLinkRoutes, TDocument extends SanityLinkDocument = SanityLinkDocument, TResolvers extends SanityLinkResolvers<TDocument> = SanityLinkResolvers<TDocument>>(linkConfig: SanityLinkResolverConfig<TRoutes, TDocument, TResolvers>): {
|
|
157
|
+
resolveLink: (props: SanityResolveLinkProps<TRoutes, TDocument>) => SanityLinkResolution<TResolvers>;
|
|
158
|
+
resolveRoute: (destination: SanityLinkDocument | SanityLinkRouteInput<TRoutes & SanityCheckedLinkRoutes<TRoutes>>) => string | undefined;
|
|
159
|
+
routes: TRoutes & SanityCheckedLinkRoutes<TRoutes>;
|
|
160
|
+
routeParamsFragment: string;
|
|
161
|
+
linkFragment: string;
|
|
162
|
+
};
|
|
163
|
+
export type { SanityAnchorLink, SanityEmailLink, SanityFileLink, SanityLink, SanityLinkDestination, SanityLinkDocument, SanityLinkFile, SanityLinkFileAsset, SanityLinkReference, SanityLinkResolution, SanityLinkResolverConfig, SanityLinkResolvers, SanityLinkRouteDefinition, SanityLinkRouteInput, SanityLinkRouteParams, SanityLinkRoutes, SanityLinkSearchParam, SanityLinkState, SanityLinkTitleConfig, SanityPageLink, SanityPhoneLink, SanityResolveLinkProps, SanityResolvedLink, SanityUrlLink };
|
|
164
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","names":[],"sources":["../src/lib/routes.ts","../src/lib/links.ts"],"mappings":";;;;;;;UAYiB;;EAEf;;EAEA,SAAS;;;;;;;KAQC,mBAAmB,eAAe;;;;;KAMlC,0BAA0B,wBAAwB,iCAAiC,gBAAgB,UAC3G,SAAS,0BAA0B;;;;;;KAQ3B,wBAAwB,gBAAgB,uBACjD,WAAW,WAAW,0BAA0B,QAAQ;EACnD;;EAEA,QAAQ,OAAO,0BAA0B,QAAQ,0BAC9C,WAAW,QAAQ,eAAe,UAAU,0BAA0B,QAAQ;;;;;;;KAU7E,qBAAqB,gBAAgB,uBAC9C,WAAW;EAAqB,OAAO;IAAM,OAAO,0BAA0B,QAAQ,8BACjF;;;;;;;;KCnCI,oBAAoB,kBAA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