sanity-plugin-cloudinary 1.4.1 → 2.0.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/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/components/VideoPlayer.tsx","../src/utils.ts","../src/components/AssetPreview.tsx","../src/components/WidgetInput.tsx","../src/components/SecretsConfigView.tsx","../src/components/CloudinaryInput.tsx","../src/components/AssetDiff.tsx","../src/schema/cloudinaryAsset.ts","../src/schema/cloudinaryAssetDerived.ts","../src/components/asset-source/Icon.tsx","../src/components/asset-source/CloudinaryAssetSource.tsx","../src/schema/cloudinaryAssetContext.ts","../src/schema/cloudinaryAssetContextCustom.ts","../src/components/AssetListFunctions.tsx","../src/index.ts"],"sourcesContent":["import React, {CSSProperties} from 'react'\n\ntype PlayerKind = 'player' | 'diff'\n\nexport type VideoPlayerProps = {\n src: string\n // eslint-disable-next-line react/no-unused-prop-types\n kind: PlayerKind\n}\n\nexport default function VideoPlayer(props: VideoPlayerProps) {\n const {src} = props\n\n const style: CSSProperties = {\n width: '100%',\n height: 'auto',\n }\n\n return (\n <video controls style={style}>\n <source src={src} type=\"video/mp4\" />\n </video>\n )\n}\n","/* eslint-disable camelcase,@typescript-eslint/explicit-module-boundary-types */\nimport {\n CloudinaryAsset,\n CloudinaryAssetResponse,\n CloudinaryMediaLibrary,\n InsertHandlerParams,\n} from './types'\n\nconst widgetSrc = 'https://media-library.cloudinary.com/global/all.js'\n\nexport function assetUrl(asset: Partial<Pick<CloudinaryAsset, 'url' | 'secure_url' | 'derived'>>) {\n if (asset.derived && asset.derived.length > 0) {\n const [derived] = asset.derived\n if (derived.secure_url) {\n return derived.secure_url\n }\n return derived.url\n }\n if (asset.secure_url) {\n return asset.secure_url\n }\n return asset.url\n}\n\nexport const openMediaSelector = (\n cloudName: string,\n apiKey: string,\n multiple: boolean,\n insertHandler: (params: InsertHandlerParams) => void,\n selectedAsset?: CloudinaryAsset\n) => {\n loadJS(widgetSrc, () => {\n const options: Record<string, any> = {\n cloud_name: cloudName,\n api_key: apiKey,\n insert_caption: 'Select',\n multiple,\n }\n\n if (selectedAsset) {\n options.asset = {\n public_id: selectedAsset.public_id,\n type: selectedAsset.type,\n resource_type: selectedAsset.resource_type,\n }\n }\n\n window.cloudinary.openMediaLibrary(options, {insertHandler})\n })\n}\n\nexport const createMediaLibrary = ({\n cloudName,\n apiKey,\n inlineContainer,\n libraryCreated,\n insertHandler,\n}: {\n cloudName: string\n apiKey: string\n inlineContainer: string\n libraryCreated: (library: CloudinaryMediaLibrary) => void\n insertHandler: (params: InsertHandlerParams) => void\n}) => {\n loadJS(widgetSrc, () => {\n const options: Record<string, any> = {\n cloud_name: cloudName,\n api_key: apiKey,\n insert_caption: 'Select',\n inline_container: inlineContainer,\n remove_header: true,\n }\n\n libraryCreated(window.cloudinary.createMediaLibrary(options, {insertHandler}))\n })\n}\n\nexport function loadJS(url: string, callback: () => void) {\n const existingScript = document.getElementById('damWidget')\n if (!existingScript) {\n const script = document.createElement('script')\n script.src = url\n script.id = 'damWidget'\n document.body.appendChild(script)\n script.onload = () => {\n if (callback) {\n return callback()\n }\n return true\n }\n }\n if (existingScript && callback) {\n return callback()\n }\n return true\n}\n\nexport function encodeSourceId(asset: CloudinaryAssetResponse): string {\n const {resource_type, public_id, type} = asset\n return btoa(JSON.stringify({public_id, resource_type, type})) // Sort keys alphabetically!\n}\n\nexport function encodeFilename(asset: CloudinaryAssetResponse) {\n return `${asset.public_id.split('/').slice(-1)[0]}.${asset.format}`\n}\n\nexport function decodeSourceId(sourceId: string): CloudinaryAssetResponse | undefined {\n let sourceIdDecoded: any\n try {\n sourceIdDecoded = JSON.parse(atob(sourceId))\n } catch (err) {\n // Do nothing\n }\n return sourceIdDecoded\n}\n","import React from 'react'\nimport VideoPlayer from './VideoPlayer'\nimport {assetUrl} from '../utils'\nimport {Flex, Text} from '@sanity/ui'\nimport {CloudinaryAsset} from '../types'\nimport {DocumentIcon} from '@sanity/icons'\n\ninterface ComponentProps {\n layout?: 'default' | 'block'\n value: CloudinaryAsset | undefined\n}\n\nconst AssetPreview = ({value, layout}: ComponentProps) => {\n const url = value && assetUrl(value)\n if (!value || !url) {\n return null\n }\n\n switch (value.resource_type) {\n case 'video':\n return (\n <Flex\n align=\"center\"\n style={{\n maxWidth: layout === 'default' ? '80px' : '100%',\n }}\n >\n <VideoPlayer src={url} kind=\"player\" />\n </Flex>\n )\n case 'raw':\n return (\n <Flex align=\"center\">\n <DocumentIcon />\n <Text size={1} style={{marginLeft: '0.5em'}}>\n {value.display_name ?? 'Raw file'}\n </Text>\n </Flex>\n )\n default:\n return (\n <Flex align=\"center\">\n <img\n alt=\"preview\"\n src={\n // Cloudinary returns resource_type as \"image\" even for PDFs,\n // so we check the format to handle PDFs specifically.\n // If it's a PDF, convert the first page to JPG and overlay a \"PDF\" label for thumbnail clarity.\n value.format === 'pdf'\n ? url?.replace(\n 'image/upload',\n 'image/upload/f_jpg,pg_1,l_text:Verdana_75_letter_spacing_14:PDF'\n )\n : url\n }\n style={{\n maxWidth: layout === 'default' ? '80px' : '100%',\n height: 'auto',\n }}\n />\n </Flex>\n )\n }\n}\n\nexport default AssetPreview\n","import React, {useCallback} from 'react'\nimport {ObjectInputProps, PatchEvent, unset} from 'sanity'\nimport {Button, Flex, Grid, Stack} from '@sanity/ui'\nimport {PlugIcon} from '@sanity/icons'\nimport {styled} from 'styled-components'\nimport AssetPreview from './AssetPreview'\nimport {CloudinaryAsset} from '../types'\n\nconst SetupButtonContainer = styled.div`\n position: relative;\n display: block;\n font-size: 0.8em;\n transform: translate(0%, -10%);\n`\n\ntype WidgetInputProps = ObjectInputProps & {openMediaSelector: () => void; onSetup: () => void}\n\nconst WidgetInput = (props: WidgetInputProps) => {\n const {onChange, readOnly, value, openMediaSelector} = props\n\n const removeValue = useCallback(() => {\n onChange(PatchEvent.from([unset()]))\n }, [onChange])\n\n return (\n <Stack>\n <SetupButtonContainer>\n <Flex flex={1} justify=\"flex-end\">\n <Button\n color=\"primary\"\n icon={PlugIcon}\n mode=\"bleed\"\n title=\"Configure\"\n onClick={props.onSetup}\n tabIndex={1}\n />\n </Flex>\n </SetupButtonContainer>\n\n <Flex style={{textAlign: 'center', width: '100%'}} marginBottom={2}>\n <AssetPreview value={value as CloudinaryAsset} />\n </Flex>\n\n <Grid gap={1} style={{gridTemplateColumns: 'repeat(auto-fit, minmax(100px, 1fr))'}}>\n <Button\n disabled={readOnly}\n mode=\"ghost\"\n title=\"Select an asset\"\n tone=\"default\"\n onClick={openMediaSelector}\n text=\"Select…\"\n />\n <Button\n disabled={readOnly || !value}\n tone=\"critical\"\n mode=\"ghost\"\n title=\"Remove asset\"\n text=\"Remove\"\n onClick={removeValue}\n />\n </Grid>\n </Stack>\n )\n}\n\nexport default WidgetInput\n","import React from 'react'\nimport {SettingsView} from '@sanity/studio-secrets'\n\nexport type Secrets = {\n cloudName: string\n apiKey: string\n}\n\nconst pluginConfigKeys = [\n {\n key: 'cloudName',\n title: 'Cloud name',\n description: '',\n },\n {\n key: 'apiKey',\n title: 'API key',\n description: '',\n },\n]\n\nexport const namespace = 'cloudinary'\n\ntype Props = {\n onClose: () => void\n}\n\nconst SecretsConfigView = (props: Props) => {\n return (\n <SettingsView\n title=\"Cloudinary config\"\n namespace={namespace}\n keys={pluginConfigKeys}\n onClose={props.onClose}\n />\n )\n}\n\nexport default SecretsConfigView\n","import React, {useCallback, useState} from 'react'\nimport WidgetInput from './WidgetInput'\nimport {nanoid} from 'nanoid'\nimport {ObjectInputProps, PatchEvent, set} from 'sanity'\nimport {CloudinaryAsset, CloudinaryAssetResponse} from '../types'\nimport {useSecrets} from '@sanity/studio-secrets'\nimport {InsertHandlerParams} from '../types'\nimport {openMediaSelector} from '../utils'\nimport SecretsConfigView, {namespace, Secrets} from './SecretsConfigView'\n\nconst CloudinaryInput = (props: ObjectInputProps) => {\n const [showSettings, setShowSettings] = useState(false)\n const {secrets} = useSecrets<Secrets>(namespace)\n const {onChange, schemaType: type} = props\n const value = (props.value as CloudinaryAsset) || undefined\n\n /* eslint-disable camelcase */\n const handleSelect = useCallback(\n (payload: InsertHandlerParams) => {\n const [asset] = payload.assets\n\n if (!asset) {\n return\n }\n\n let updatedAsset = asset\n\n // Update the asset with the new custom values\n const assetWithoutNulls = Object.fromEntries(\n Object.entries(asset).filter(([_, assetValue]) => assetValue !== null)\n ) as CloudinaryAssetResponse\n\n // Ensure we preserve the required fields from the original asset\n const requiredFields = {\n public_id: asset.public_id,\n resource_type: asset.resource_type,\n type: asset.type,\n url: asset.url,\n secure_url: asset.secure_url,\n format: asset.format,\n width: asset.width,\n height: asset.height,\n bytes: asset.bytes,\n tags: asset.tags,\n }\n updatedAsset = {\n ...assetWithoutNulls,\n ...requiredFields,\n }\n\n //The metadata in Sanity Studio cannot contain special characters,\n //hence the cloudinary metadata (context) needs to be transformed to valid object keys\n if (asset.context) {\n const objectWithRenamedKeys = Object.fromEntries(\n Object.entries(asset.context.custom).map(([contextKey, contextValue]) => {\n return [contextKey.replace(/[^a-zA-Z0-9_]|-/g, '_'), contextValue]\n })\n )\n\n // Update the asset with the new custom values\n updatedAsset = {\n ...updatedAsset,\n context: {\n ...asset.context,\n custom: objectWithRenamedKeys,\n },\n }\n }\n\n // Handle derived field - only include if not null\n if (asset.derived) {\n const derivedWithType = asset.derived.map((derivedItem) => ({\n ...derivedItem,\n _type: 'derived',\n }))\n\n updatedAsset = {\n ...updatedAsset,\n derived: derivedWithType,\n }\n }\n\n onChange(\n PatchEvent.from([\n set(\n Object.assign(\n {\n _type: type.name,\n _version: 1,\n ...(value?._key ? {_key: value._key} : {_key: nanoid()}),\n },\n updatedAsset\n )\n ),\n ])\n )\n },\n [onChange, type, value?._key]\n )\n\n const action = secrets\n ? () =>\n openMediaSelector(\n secrets.cloudName,\n secrets.apiKey,\n false, // single selection\n handleSelect,\n value\n )\n : () => setShowSettings(true)\n\n return (\n <>\n {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n <WidgetInput onSetup={() => setShowSettings(true)} openMediaSelector={action} {...props} />\n </>\n )\n /* eslint-enable camelcase */\n}\n\nexport default CloudinaryInput\n","import React from 'react'\nimport {DiffFromTo} from 'sanity'\nimport VideoPlayer from './VideoPlayer'\nimport {assetUrl} from '../utils'\nimport {CloudinaryAsset} from '../types'\n\ntype Props = {\n value: CloudinaryAsset | undefined\n}\n\nconst CloudinaryDiffPreview = ({value}: Props) => {\n if (!value) {\n return null\n }\n\n const url = assetUrl(value)\n\n if (value.resource_type === 'video' && url) {\n return (\n <section\n style={{\n display: 'flex',\n flexWrap: 'wrap',\n justifyContent: 'space-between',\n }}\n >\n <VideoPlayer src={url} kind=\"diff\" />\n </section>\n )\n }\n\n return <img alt=\"preview\" src={url} style={{maxWidth: '100%', height: 'auto'}} />\n}\n\ntype DiffProps = {\n diff: any\n schemaType: any\n}\n\nconst AssetDiff = ({diff, schemaType}: DiffProps) => {\n return <DiffFromTo diff={diff} schemaType={schemaType} previewComponent={CloudinaryDiffPreview} />\n}\n\nexport default AssetDiff\n","/* eslint-disable */\nimport CloudinaryInput from '../components/CloudinaryInput'\nimport AssetDiff from '../components/AssetDiff'\nimport AssetPreview from '../components/AssetPreview'\nimport {defineType} from 'sanity'\n\nexport const cloudinaryAssetSchema = defineType({\n type: 'object',\n name: 'cloudinary.asset',\n fields: [\n {\n type: 'string',\n name: 'public_id',\n },\n {\n type: 'string',\n name: 'resource_type',\n // \"image\", \"?\"\n },\n {\n type: 'string',\n name: 'type',\n // \"upload\", \"?\"\n },\n {\n type: 'string',\n name: 'format',\n // \"jpg\"\n },\n {\n type: 'number',\n name: 'version',\n },\n {\n type: 'url',\n name: 'url',\n },\n {\n type: 'url',\n name: 'secure_url',\n },\n {\n type: 'number',\n name: 'width',\n },\n {\n type: 'number',\n name: 'height',\n },\n {\n type: 'number',\n name: 'bytes',\n },\n {\n type: 'number',\n name: 'duration',\n // can be null\n },\n {\n type: 'array',\n name: 'tags',\n of: [{type: 'string'}],\n },\n {\n type: 'datetime',\n name: 'created_at',\n },\n {\n type: 'array',\n name: 'derived',\n of: [{type: 'cloudinary.assetDerived', name: 'derived'}],\n },\n {\n type: 'string',\n name: 'access_mode',\n },\n {\n type: 'cloudinary.assetContext',\n name: 'context',\n },\n // metadata array of unknown content\n ],\n ...({\n components: {\n input: CloudinaryInput,\n diff: AssetDiff,\n preview: AssetPreview,\n },\n } as {}), //TODO revert this change when rc.1 is released\n preview: {\n select: {\n url: 'url',\n resource_type: 'resource_type',\n derived: 'derived.0.url',\n },\n prepare({url, derived, resource_type}) {\n return {\n title: url,\n value: {\n title: url,\n resource_type,\n url: derived || url,\n },\n }\n },\n },\n})\n","import {defineType} from 'sanity'\n\nexport type CloudinaryAssetDerived = {\n raw_transformation: string\n url: string\n secure_url: string\n}\n\nexport const cloudinaryAssetDerivedSchema = defineType({\n type: 'object',\n name: 'cloudinary.assetDerived',\n fields: [\n {\n type: 'string',\n name: 'raw_transformation',\n },\n {\n type: 'url',\n name: 'url',\n },\n {\n type: 'url',\n name: 'secure_url',\n },\n ],\n})\n","import React from 'react'\n\nexport function CloudinaryIcon() {\n return (\n <svg\n version=\"1.1\"\n id=\"Layer_1\"\n x=\"0px\"\n y=\"0px\"\n width=\"1em\"\n height=\"1em\"\n viewBox=\"0 0 141.732 141.747\"\n enableBackground=\"new 0 0 141.732 141.747\"\n >\n <g>\n <path\n fill=\"#0071CE\"\n d=\"M115.585,109.242c-1.609,0-3.107-1.024-3.635-2.637c-0.657-2.008,0.438-4.169,2.447-4.826\n c7.278-2.382,11.98-8.761,11.98-16.252c0-9.487-7.718-17.206-17.205-17.206c-0.659,0-1.368,0.052-2.231,0.164l-3.741,0.485\n l-0.537-3.735c-2.299-16.016-16.251-28.094-32.454-28.094c-13.395,0-25.32,8.019-30.377,20.43l-0.952,2.335l-2.52,0.046\n c-11.581,0.213-21.003,9.804-21.003,21.379c0,8.45,4.906,16.156,12.498,19.631c1.921,0.88,2.766,3.15,1.886,5.071\n c-0.88,1.921-3.149,2.764-5.07,1.887C14.363,103.202,7.703,92.766,7.703,81.331c0-14.88,11.465-27.345,26.028-28.876\n c6.71-14.03,20.773-22.965,36.477-22.965c18.796,0,35.135,13.178,39.372,31.184c13.519,0.219,24.45,11.284,24.45,24.854\n c0,10.693-6.934,20.146-17.253,23.523C116.382,109.18,115.98,109.242,115.585,109.242z\"\n />\n <path\n fill=\"#DC8327\"\n d=\"M57.12,111.02c-0.001-0.001-0.001-0.001-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001\n c0,0-0.001-0.001-0.001-0.001l-0.001-0.001c0,0-0.001,0-0.001-0.001h-0.001l-0.001-0.001c0.001-0.001-0.001-0.001-0.001-0.001\n l-0.001-0.001c0,0-0.001,0-0.001,0l-0.001-0.001c0.001,0.001-0.001-0.001-0.001-0.001s-0.002-0.001-0.003-0.001l-0.001-0.001H57.1\n c-0.001-0.001-0.001-0.001-0.001-0.001l-0.001-0.001c-0.003-0.001-0.002-0.001-0.003-0.001c-0.001,0.001-0.001-0.001-0.002-0.001\n l-0.001-0.001c0,0-0.001-0.001-0.002-0.001l-0.001-0.001c-0.001-0.001-0.003-0.001-0.004-0.001s-0.003-0.001-0.004-0.001\n c-0.001-0.001-0.001-0.001-0.002-0.001h-0.001c-0.001-0.001-0.002-0.001-0.003-0.001c-0.001-0.001-0.003-0.001-0.003-0.001\n c-0.001,0-0.001,0-0.001,0l-0.002-0.001c-0.001,0-0.001-0.001-0.001-0.001h-0.001c-0.059-0.021-0.122-0.034-0.188-0.037h-0.002\n h-0.002c-0.001,0-0.001,0-0.002,0c0,0,0,0-0.001,0c0,0-0.001,0-0.001,0h-0.001c-0.001-0.001-0.001-0.001-0.001-0.001\n c-0.001,0-0.002,0-0.002,0c-0.001,0-0.002,0-0.002,0h-0.001h-0.001h-0.001c-0.001,0-0.002,0-0.002,0h-0.001H56.86h-0.001h-0.001\n c-0.001,0-0.001,0-0.001,0h-0.001h-0.001h-0.001h-0.001c-0.001,0-0.001,0-0.001,0c-1.656,0-3.011-1.348-3.021-3V74.29h2.567\n c0.004,0,0.009,0,0.013,0c0.393,0.017,0.661-0.285,0.661-0.648c0-0.271-0.166-0.503-0.402-0.6l-12.379-8.544\n c-0.222-0.153-0.515-0.153-0.737,0l-12.476,8.611c-0.234,0.161-0.335,0.456-0.251,0.727c0.085,0.271,0.335,0.455,0.619,0.455h2.58\n l0.002,33.674c0.013,2.328,1.883,4.228,4.262,4.288c0.027,0.003,0.053,0.005,0.08,0.005h18.481c0.004,0,0.007,0,0.011,0\n c0.17-0.003,0.324-0.071,0.438-0.18c0,0,0,0,0.001-0.001c0.002-0.002,0.004-0.004,0.005-0.005c0.001-0.001,0.002-0.001,0.003-0.003\n c0,0,0.001-0.001,0.001-0.001l0.001-0.001l0.001-0.001l0.001-0.001l0.001-0.001c0.001-0.001,0.001-0.001,0.001-0.001\n c0.002-0.001,0.001-0.001,0.002-0.002c0,0,0,0,0.001-0.001l0.001-0.001c0,0,0,0,0.001-0.001c0.112-0.116,0.182-0.273,0.183-0.447\n v-0.002v-0.001v-0.001v-0.001v-0.001v-0.001v-0.001v-0.002C57.498,111.345,57.343,111.121,57.12,111.02z\"\n />\n <path\n fill=\"#F4B21B\"\n d=\"M83.889,111.02c0,0-0.001-0.001-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001\n c-0.001-0.001-0.001-0.001-0.001-0.001l-0.001-0.001h-0.001c0,0-0.001-0.001-0.001-0.001c0,0-0.001-0.001-0.001-0.001\n c0.001-0.001-0.001-0.001-0.002-0.001l-0.001-0.001h-0.001c-0.001,0-0.001-0.001-0.001-0.001c-0.002,0.001-0.002-0.001-0.002-0.001\n l-0.002-0.001l-0.001-0.001h-0.001c0,0-0.001-0.001-0.001-0.001l-0.001-0.001c-0.001-0.001-0.002-0.001-0.002-0.001\n c-0.001,0.001-0.001-0.001-0.003-0.001l-0.001-0.001l-0.001-0.001c0,0-0.001,0-0.002-0.001c-0.001-0.001-0.003-0.001-0.004-0.001\n s-0.003-0.001-0.004-0.001c-0.001-0.001-0.001-0.001-0.002-0.001c-0.001,0-0.001,0-0.002-0.001c0,0-0.001,0-0.002-0.001\n c-0.003-0.001-0.001-0.001-0.002-0.001c-0.003,0-0.001,0-0.002-0.001c0,0-0.001-0.001-0.002-0.001l-0.001-0.001h-0.001\n c-0.059-0.021-0.122-0.034-0.188-0.037h-0.002c-0.001,0-0.001,0-0.001,0c-0.001,0-0.002,0-0.002,0s-0.001,0-0.001,0h-0.001h-0.001\n l-0.001-0.001c-0.001,0-0.002,0-0.002,0c-0.001,0-0.002,0-0.002,0h-0.001c-0.001,0-0.001,0-0.001,0h-0.001\n c-0.001,0-0.002,0-0.002,0s-0.001,0-0.002,0h-0.001c0,0-0.001,0-0.001,0h-0.001c-0.001,0-0.001,0-0.001,0h-0.001h-0.001h-0.001\n h-0.001c-0.001,0-0.001,0-0.001,0c-1.655,0-3.01-1.348-3.02-3V81.829h2.579c0.009-0.001,0.016-0.001,0.026,0\n c0.358,0,0.648-0.29,0.648-0.648c0-0.271-0.166-0.503-0.402-0.6l-12.38-8.544c-0.222-0.153-0.515-0.153-0.737,0L57.86,80.647\n c-0.234,0.161-0.335,0.456-0.251,0.727c0.085,0.271,0.335,0.455,0.619,0.455h2.568l0.002,26.135\n c0.011,2.329,1.884,4.23,4.264,4.289c0.026,0.003,0.052,0.004,0.078,0.004h18.481c0.004,0,0.007,0,0.011,0\n c0.17-0.003,0.324-0.071,0.438-0.18c0,0,0,0,0.001-0.001c0.002-0.002,0.006-0.004,0.005-0.005c0.001-0.001,0.002-0.001,0.003-0.003\n c0.001-0.001,0.001-0.001,0.001-0.001l0.001-0.001l0.001-0.001c0,0,0.001,0,0.001-0.001l0.001-0.001\n c0.001,0,0.001-0.001,0.001-0.001c0.003-0.001,0.002-0.001,0.002-0.002c0,0,0,0,0.001-0.001c0,0,0,0,0.001-0.001\n c0,0,0,0,0.001-0.001c0.112-0.116,0.182-0.273,0.183-0.447v-0.002v-0.001v-0.001v-0.001v-0.001v-0.001v-0.001v-0.002\n C84.267,111.345,84.112,111.121,83.889,111.02z\"\n />\n <path\n fill=\"#F2D864\"\n d=\"M110.667,111.02l-0.002-0.001c-0.001,0-0.002-0.001-0.003-0.001h-0.001\n c-0.001-0.001-0.001-0.001-0.001-0.001l-0.001-0.001c-0.001,0-0.001,0-0.001-0.001h-0.001l-0.001-0.001\n c-0.001-0.001-0.001-0.001-0.001-0.001s-0.001,0-0.001-0.001h-0.001c0,0-0.001-0.001-0.001-0.001\n c-0.001,0.001-0.001-0.001-0.002-0.001c0.001-0.001-0.001-0.001-0.002-0.001l-0.001-0.001c-0.001,0-0.001,0-0.001,0\n c-0.001-0.001-0.001-0.001-0.001-0.001l-0.001-0.001c-0.003-0.001-0.002-0.001-0.002-0.001c-0.001,0.001-0.001-0.001-0.003-0.001\n l-0.001-0.001c0.001-0.001-0.001-0.001-0.002-0.001c0,0-0.001,0-0.001-0.001c-0.001-0.001-0.003-0.001-0.004-0.001\n s-0.003-0.001-0.004-0.001l-0.002-0.001c0,0-0.001,0-0.002-0.001l-0.002-0.001c-0.003-0.001-0.003-0.001-0.002-0.001\n c-0.003,0-0.003,0-0.002-0.001c-0.001,0-0.001-0.001-0.001-0.001c-0.001,0-0.002-0.001-0.002-0.001h-0.001\n c-0.059-0.021-0.122-0.034-0.188-0.037h-0.001c-0.001,0-0.002,0-0.002,0c-0.001,0-0.002,0-0.003,0h-0.001h-0.001h-0.001\n c-0.001-0.001-0.001-0.001-0.002-0.001c0,0-0.001,0-0.002,0c0,0-0.001,0-0.002,0h-0.001c0,0-0.001,0-0.001,0h-0.001\n c-0.001,0-0.002,0-0.002,0h-0.002c0,0,0,0-0.001,0c0,0-0.001,0-0.001,0h-0.001c0,0-0.001,0-0.001,0h-0.001h-0.001h-0.001H110.4\n c0,0-0.001,0-0.001,0c-1.655,0-3.01-1.348-3.02-3V89.365h2.573c0.004,0,0.009,0,0.013,0c0.365-0.009,0.661-0.285,0.661-0.648\n c0-0.271-0.166-0.503-0.402-0.6l-12.38-8.544c-0.221-0.153-0.515-0.153-0.737,0l-12.476,8.61c-0.234,0.161-0.335,0.456-0.251,0.727\n c0.085,0.271,0.335,0.455,0.619,0.455h2.573l0.002,18.599c0.013,2.329,1.885,4.231,4.264,4.289\n c0.026,0.003,0.052,0.004,0.078,0.004h18.481c0.004,0,0.007,0,0.011,0c0.17-0.003,0.324-0.071,0.438-0.18l0.001-0.001\n c0.002-0.002,0.005-0.004,0.005-0.005c0.001-0.001,0.002-0.001,0.003-0.003c0,0,0.001-0.001,0.001-0.001l0.001-0.001l0.001-0.001\n l0.001-0.001l0.001-0.001l0.001-0.001c0.003-0.001,0.001-0.001,0.002-0.002c0,0,0,0,0.001-0.001l0.001-0.001c0,0,0,0,0.001-0.001\n c0.112-0.116,0.182-0.273,0.183-0.447v-0.002v-0.001v-0.001v-0.001v-0.001v-0.001v-0.001v-0.002\n C111.045,111.345,110.889,111.121,110.667,111.02z\"\n />\n </g>\n </svg>\n )\n}\n","/* eslint-disable camelcase */\nimport React, {useCallback, useEffect, useRef, useState} from 'react'\nimport {Box, Button, Dialog, Flex, Spinner, Stack, Text} from '@sanity/ui'\nimport {CloudinaryMediaLibrary, InsertHandlerParams} from '../../types'\nimport {createMediaLibrary, decodeSourceId, encodeFilename, encodeSourceId} from '../../utils'\nimport {styled} from 'styled-components'\nimport {useSecrets} from '@sanity/studio-secrets'\nimport SecretsConfigView, {namespace, Secrets} from '../SecretsConfigView'\nimport {AssetSourceComponentProps, ImageAsset} from 'sanity'\nimport {PlugIcon} from '@sanity/icons'\n\nexport const Widget = styled.div`\n height: 70vh;\n`\n\nexport function CloudinaryAssetSource(props: AssetSourceComponentProps) {\n const {onClose, dialogHeaderTitle} = props\n\n const [loadingMessage, setLoadingMessage] = useState<string | undefined>(\n 'Loading Cloudinary Media Libary'\n )\n const library = useRef<CloudinaryMediaLibrary | undefined>(undefined)\n const contentRef = useRef<HTMLDivElement | null>(null)\n const {secrets} = useSecrets<Secrets>(namespace)\n const cloudName = secrets?.cloudName\n const apiKey = secrets?.apiKey\n const [widgetId] = useState(() => `cloundinaryWidget-${Date.now()}`)\n const [showSettings, setShowSettings] = useState(false)\n\n const propsRef = useRef(props)\n\n useEffect(() => {\n // because we have to access props after loading js in a callback,\n // we cannot pass props as dependecnies as that will cause infinite updates\n // this takes a snapshot of props, so we can access them later\n propsRef.current = props\n }, [props])\n\n const handleClose = useCallback(() => {\n if (library.current) {\n library.current.hide()\n }\n onClose()\n }, [onClose, library])\n\n useEffect(() => {\n if (!cloudName || !apiKey) {\n return\n }\n\n createMediaLibrary({\n cloudName,\n apiKey,\n inlineContainer: `#${widgetId}`,\n libraryCreated: (lib: CloudinaryMediaLibrary) => {\n library.current = lib\n const selectedAssets = propsRef.current.selectedAssets\n const firstSelectedAsset = selectedAssets ? selectedAssets[0] : null\n\n // eslint-disable-next-line no-undef\n const iframe: ChildNode | null | undefined =\n contentRef.current && contentRef.current.firstChild\n if (iframe && iframe instanceof HTMLIFrameElement) {\n setLoadingMessage(undefined)\n let asset\n if (\n propsRef.current.selectionType === 'single' &&\n firstSelectedAsset &&\n firstSelectedAsset.source &&\n firstSelectedAsset.source.id\n ) {\n asset = decodeSourceId(firstSelectedAsset.source.id)\n }\n const folder = asset\n ? {\n path: asset.public_id.split('/').slice(0, -1).join('/'),\n resource_type: 'image',\n }\n : {path: '', resource_type: 'image'}\n if (lib && contentRef.current) {\n lib.show({folder, asset})\n contentRef.current.style.visibility = 'visible'\n }\n }\n },\n insertHandler: ({assets}: InsertHandlerParams) => {\n if (!library.current) {\n return\n }\n const imageAssets = assets.filter((asset) => asset.resource_type === 'image')\n if (imageAssets.length === 0) {\n throw new Error('The selection did not contain any images.')\n }\n library.current.hide()\n propsRef.current.onSelect(\n imageAssets.map((asset) => {\n const url =\n asset.derived && asset.derived[0] ? asset.derived[0].secure_url : asset.secure_url\n return {\n kind: 'url',\n value: url,\n assetDocumentProps: {\n _type: 'sanity.imageAsset',\n originalFilename: encodeFilename(asset),\n source: {\n id: encodeSourceId(asset),\n name: `cloudinary:${cloudName}`,\n },\n } as ImageAsset,\n }\n })\n )\n },\n })\n }, [cloudName, apiKey, widgetId])\n\n const hasConfig = apiKey && cloudName\n return (\n <Dialog\n id=\"cloudinary-asset-source\"\n header={dialogHeaderTitle ?? 'Select image from Cloudinary'}\n onClose={handleClose}\n open\n width={4}\n >\n <Box padding={4}>\n {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}\n <Flex flex={1} justify=\"flex-end\">\n <Button\n color=\"primary\"\n icon={PlugIcon}\n mode=\"bleed\"\n title=\"Configure\"\n onClick={() => setShowSettings(true)}\n tabIndex={1}\n text={hasConfig ? undefined : 'Configure Cloudinary plugin'}\n />\n </Flex>\n\n {hasConfig && loadingMessage && (\n <Stack space={3}>\n <Flex align=\"center\" justify=\"center\">\n <Spinner muted />\n </Flex>\n <Text size={1} muted align=\"center\">\n {loadingMessage}\n </Text>\n </Stack>\n )}\n\n <Widget style={{visibility: 'hidden'}} ref={contentRef} id={widgetId} />\n </Box>\n </Dialog>\n )\n}\n","import {defineType} from 'sanity'\n\nexport interface CloudinaryAssetContext {\n custom: object\n}\n\nexport const cloudinaryAssetContext = defineType({\n type: 'object',\n name: 'cloudinary.assetContext',\n fields: [\n {\n type: 'cloudinary.assetContextCustom',\n name: 'custom',\n },\n ],\n})\n","import {defineType} from 'sanity'\n\nexport type CloudinaryAssetContextCustom = {\n alt: string\n caption: string\n}\n\nexport const cloudinaryAssetContextCustom = defineType({\n type: 'object',\n name: 'cloudinary.assetContextCustom',\n fields: [\n {\n type: 'string',\n name: 'alt',\n },\n {\n type: 'string',\n name: 'caption',\n },\n ],\n})\n","import React, {useCallback} from 'react'\nimport {Box, Button, Flex} from '@sanity/ui'\nimport {\n ArrayInputFunctionsProps,\n ArrayOfObjectsFunctions,\n ArraySchemaType,\n insert,\n ObjectSchemaType,\n PatchEvent,\n setIfMissing,\n} from 'sanity'\n\nimport {useSecrets} from '@sanity/studio-secrets'\nimport SecretsConfigView, {namespace} from './SecretsConfigView'\nimport {cloudinaryAssetSchema} from '../schema/cloudinaryAsset'\nimport {openMediaSelector} from '../utils'\nimport {InsertHandlerParams} from '../types'\nimport {PlugIcon} from '@sanity/icons'\n\ninterface ApiConfig {\n cloudName: string\n apiKey: string\n}\n\nexport const AssetListFunctions = (\n props: ArrayInputFunctionsProps<{_key: string}, ArraySchemaType>\n) => {\n const {onValueCreate, onChange} = props\n\n const {secrets, loading} = useSecrets<ApiConfig>(namespace)\n const [showSettings, setShowSettings] = React.useState(false)\n\n const show = useCallback(() => setShowSettings(true), [setShowSettings])\n const hide = useCallback(() => setShowSettings(false), [setShowSettings])\n\n const cloudinaryType = props.schemaType.of.find(\n (t: {name: string}) => t.name === cloudinaryAssetSchema.name\n ) as ObjectSchemaType | undefined\n\n if (!cloudinaryType) {\n throw new Error(`AssetListFunctions can only be used in array.of ${\n cloudinaryAssetSchema.name\n }, but it was array.of\n ${props.schemaType.of.map((t) => t.name)}`)\n }\n\n const handleSelect = useCallback(\n (selected: InsertHandlerParams) => {\n const items = selected.assets.map((asset) =>\n Object.assign(\n {},\n asset,\n {\n // Schema version. In case we ever change our schema.\n _version: 1,\n },\n onValueCreate(cloudinaryType as any) // onValueCreate is mistyped\n )\n )\n onChange(PatchEvent.from([setIfMissing([]), insert(items, 'after', [-1])]))\n },\n [onValueCreate, onChange, cloudinaryType]\n )\n\n const handleOpenSelector = useCallback(\n () =>\n secrets &&\n openMediaSelector(\n secrets.cloudName,\n secrets.apiKey,\n true, // multi-selection\n handleSelect\n ),\n [secrets, handleSelect]\n )\n return (\n <Flex gap={2} flex={1}>\n {showSettings && <SecretsConfigView onClose={hide} />}\n <Box flex={1}>\n <ArrayOfObjectsFunctions {...props} />\n </Box>\n {cloudinaryType && (\n <>\n <Box flex={1}>\n <Button\n style={{width: '100%'}}\n disabled={props.readOnly || loading}\n mode=\"bleed\"\n text=\"Add multiple\"\n onClick={handleOpenSelector}\n />\n </Box>\n <Box>\n <Button onClick={show} icon={PlugIcon} mode=\"bleed\" title={'Configure'} />\n </Box>\n </>\n )}\n </Flex>\n )\n}\n","import {cloudinaryAssetSchema} from './schema/cloudinaryAsset'\nimport {cloudinaryAssetDerivedSchema} from './schema/cloudinaryAssetDerived'\nimport {\n definePlugin,\n AssetSource,\n ArrayOfObjectsInputProps,\n isArrayOfObjectsSchemaType,\n} from 'sanity'\nimport {CloudinaryIcon} from './components/asset-source/Icon'\nimport {CloudinaryAssetSource} from './components/asset-source/CloudinaryAssetSource'\nimport {cloudinaryAssetContext} from './schema/cloudinaryAssetContext'\nimport {cloudinaryAssetContextCustom} from './schema/cloudinaryAssetContextCustom'\nimport {AssetListFunctions} from './components/AssetListFunctions'\n\nexport {type CloudinaryAssetContext} from './schema/cloudinaryAssetContext'\nexport {type CloudinaryAssetDerived} from './schema/cloudinaryAssetDerived'\nexport {type CloudinaryAssetContextCustom} from './schema/cloudinaryAssetContextCustom'\n\nexport type {AssetDocument, CloudinaryAsset} from './types'\n\nexport {\n cloudinaryAssetSchema,\n cloudinaryAssetDerivedSchema,\n cloudinaryAssetContext,\n cloudinaryAssetContextCustom,\n}\n\nexport const cloudinarySchemaPlugin = definePlugin({\n name: 'cloudinary-schema',\n form: {\n components: {\n input: (props) => {\n const {schemaType} = props\n if (isArrayOfObjectsSchemaType(schemaType)) {\n const arrayProps = props as ArrayOfObjectsInputProps\n const cloudinaryType = arrayProps.schemaType.of.find(\n (t: {name: string}) => t.name === cloudinaryAssetSchema.name\n )\n if (cloudinaryType) {\n return arrayProps.renderDefault({...arrayProps, arrayFunctions: AssetListFunctions})\n }\n }\n return props.renderDefault(props)\n },\n },\n },\n schema: {\n types: [\n cloudinaryAssetSchema,\n cloudinaryAssetDerivedSchema,\n cloudinaryAssetContext,\n cloudinaryAssetContextCustom,\n ],\n },\n})\n\nexport const cloudinaryImageSource: AssetSource = {\n name: 'cloudinary-image',\n title: 'Cloudinary',\n icon: CloudinaryIcon,\n component: CloudinaryAssetSource,\n}\n\nexport const cloudinaryAssetSourcePlugin = definePlugin({\n name: 'cloudinart-asset-source',\n form: {\n image: {\n assetSources: [cloudinaryImageSource],\n },\n },\n})\n"],"names":["VideoPlayer","props","src","style","width","height","jsx","controls","children","type","widgetSrc","assetUrl","asset","derived","length","secure_url","url","openMediaSelector","cloudName","apiKey","multiple","insertHandler","selectedAsset","loadJS","options","cloud_name","api_key","insert_caption","public_id","resource_type","window","cloudinary","openMediaLibrary","createMediaLibrary","_ref","inlineContainer","libraryCreated","inline_container","remove_header","callback","existingScript","document","getElementById","script","createElement","id","body","appendChild","onload","encodeSourceId","btoa","JSON","stringify","encodeFilename","split","slice","format","decodeSourceId","sourceId","sourceIdDecoded","parse","atob","err","AssetPreview","_ref2","value","layout","Flex","align","maxWidth","kind","jsxs","DocumentIcon","Text","size","marginLeft","display_name","alt","replace","SetupButtonContainer","styled","div","WidgetInput","onChange","readOnly","removeValue","useCallback","PatchEvent","from","unset","Stack","flex","justify","Button","color","icon","PlugIcon","mode","title","onClick","onSetup","tabIndex","textAlign","marginBottom","Grid","gap","gridTemplateColumns","disabled","tone","text","pluginConfigKeys","key","description","namespace","SecretsConfigView","SettingsView","keys","onClose","CloudinaryInput","showSettings","setShowSettings","useState","secrets","useSecrets","schemaType","handleSelect","payload","assets","updatedAsset","assetWithoutNulls","Object","fromEntries","entries","filter","_ref3","_","assetValue","requiredFields","bytes","tags","context","objectWithRenamedKeys","custom","map","_ref4","contextKey","contextValue","derivedWithType","derivedItem","_type","set","assign","name","_version","_key","nanoid","action","Fragment","CloudinaryDiffPreview","_ref5","display","flexWrap","justifyContent","AssetDiff","_ref6","diff","DiffFromTo","previewComponent","cloudinaryAssetSchema","defineType","fields","of","components","input","preview","select","prepare","_ref7","cloudinaryAssetDerivedSchema","CloudinaryIcon","version","x","y","viewBox","enableBackground","fill","d","Widget","CloudinaryAssetSource","dialogHeaderTitle","loadingMessage","setLoadingMessage","library","useRef","contentRef","widgetId","Date","now","propsRef","useEffect","current","handleClose","hide","lib","selectedAssets","firstSelectedAsset","iframe","firstChild","HTMLIFrameElement","selectionType","source","folder","path","join","show","visibility","_ref8","imageAssets","Error","onSelect","assetDocumentProps","originalFilename","hasConfig","Dialog","header","open","Box","padding","space","Spinner","muted","ref","cloudinaryAssetContext","cloudinaryAssetContextCustom","AssetListFunctions","onValueCreate","loading","React","cloudinaryType","find","t","selected","items","setIfMissing","insert","handleOpenSelector","ArrayOfObjectsFunctions","cloudinarySchemaPlugin","definePlugin","form","isArrayOfObjectsSchemaType","arrayProps","renderDefault","arrayFunctions","schema","types","cloudinaryImageSource","component","cloudinaryAssetSourcePlugin","image","assetSources"],"mappings":";;;;;;;;;;;;;;;;;;;AAUA,SAAwBA,YAAYC,KAAyB,EAAA;EACrD,MAAA;IAACC;EAAO,CAAA,GAAAD,KAAA;EAEd,MAAME,KAAuB,GAAA;IAC3BC,KAAO,EAAA,MAAA;IACPC,MAAQ,EAAA;EAAA,CACV;EAGE,OAAAC,eAAAA,UAAAA,CAAAA,GAAA,CAAC,OAAM,EAAA;IAAAC,QAAA,EAAQ,IAAC;IAAAJ,KAAA;IACdK,wCAAC,QAAO,EAAA;MAAAN,GAAA;MAAUO,IAAK,EAAA;IAAY,CAAA;EACrC,CAAA,CAAA;AAEJ;ACfA,MAAMC,SAAY,GAAA,oDAAA;AAEX,SAASC,SAASC,KAAyE,EAAA;EAChG,IAAIA,KAAM,CAAAC,OAAA,IAAWD,KAAM,CAAAC,OAAA,CAAQC,SAAS,CAAG,EAAA;IACvC,MAAA,CAACD,OAAO,CAAA,GAAID,KAAM,CAAAC,OAAA;IACxB,IAAIA,QAAQE,UAAY,EAAA;MACtB,OAAOF,OAAQ,CAAAE,UAAA;IACjB;IACA,OAAOF,OAAQ,CAAAG,GAAA;EACjB;EACA,IAAIJ,MAAMG,UAAY,EAAA;IACpB,OAAOH,KAAM,CAAAG,UAAA;EACf;EACA,OAAOH,KAAM,CAAAI,GAAA;AACf;AAEO,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ArE;AACb,CAAA;AAEO,MAAMsE,8BAA8BV,MAAAA,CAAAA,YAAa,CAAA;EACtDhG,IAAM,EAAA,yBAAA;EACNiG,IAAM,EAAA;IACJU,KAAO,EAAA;MACLC,YAAA,EAAc,CAACJ,qBAAqB;IACtC;EACF;AACF,CAAC,CAAA;;;;;;;"}
package/sanity.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "parts": [
3
- {
4
- "implements": "part:@sanity/base/sanity-root",
5
- "path": "./v2-incompatible.js"
6
- }
7
- ]
8
- }
@@ -1,44 +0,0 @@
1
- import React from 'react'
2
- import {DiffFromTo} from 'sanity'
3
- import VideoPlayer from './VideoPlayer'
4
- import {assetUrl} from '../utils'
5
- import {CloudinaryAsset} from '../types'
6
-
7
- type Props = {
8
- value: CloudinaryAsset | undefined
9
- }
10
-
11
- const CloudinaryDiffPreview = ({value}: Props) => {
12
- if (!value) {
13
- return null
14
- }
15
-
16
- const url = assetUrl(value)
17
-
18
- if (value.resource_type === 'video' && url) {
19
- return (
20
- <section
21
- style={{
22
- display: 'flex',
23
- flexWrap: 'wrap',
24
- justifyContent: 'space-between',
25
- }}
26
- >
27
- <VideoPlayer src={url} kind="diff" />
28
- </section>
29
- )
30
- }
31
-
32
- return <img alt="preview" src={url} style={{maxWidth: '100%', height: 'auto'}} />
33
- }
34
-
35
- type DiffProps = {
36
- diff: any
37
- schemaType: any
38
- }
39
-
40
- const AssetDiff = ({diff, schemaType}: DiffProps) => {
41
- return <DiffFromTo diff={diff} schemaType={schemaType} previewComponent={CloudinaryDiffPreview} />
42
- }
43
-
44
- export default AssetDiff
@@ -1,100 +0,0 @@
1
- import React, {useCallback} from 'react'
2
- import {Box, Button, Flex} from '@sanity/ui'
3
- import {
4
- ArrayInputFunctionsProps,
5
- ArrayOfObjectsFunctions,
6
- ArraySchemaType,
7
- insert,
8
- ObjectSchemaType,
9
- PatchEvent,
10
- setIfMissing,
11
- } from 'sanity'
12
-
13
- import {useSecrets} from '@sanity/studio-secrets'
14
- import SecretsConfigView, {namespace} from './SecretsConfigView'
15
- import {cloudinaryAssetSchema} from '../schema/cloudinaryAsset'
16
- import {openMediaSelector} from '../utils'
17
- import {InsertHandlerParams} from '../types'
18
- import {PlugIcon} from '@sanity/icons'
19
-
20
- interface ApiConfig {
21
- cloudName: string
22
- apiKey: string
23
- }
24
-
25
- export const AssetListFunctions = (
26
- props: ArrayInputFunctionsProps<{_key: string}, ArraySchemaType>
27
- ) => {
28
- const {onValueCreate, onChange} = props
29
-
30
- const {secrets, loading} = useSecrets<ApiConfig>(namespace)
31
- const [showSettings, setShowSettings] = React.useState(false)
32
-
33
- const show = useCallback(() => setShowSettings(true), [setShowSettings])
34
- const hide = useCallback(() => setShowSettings(false), [setShowSettings])
35
-
36
- const cloudinaryType = props.schemaType.of.find(
37
- (t: {name: string}) => t.name === cloudinaryAssetSchema.name
38
- ) as ObjectSchemaType | undefined
39
-
40
- if (!cloudinaryType) {
41
- throw new Error(`AssetListFunctions can only be used in array.of ${
42
- cloudinaryAssetSchema.name
43
- }, but it was array.of
44
- ${props.schemaType.of.map((t) => t.name)}`)
45
- }
46
-
47
- const handleSelect = useCallback(
48
- (selected: InsertHandlerParams) => {
49
- const items = selected.assets.map((asset) =>
50
- Object.assign(
51
- {},
52
- asset,
53
- {
54
- // Schema version. In case we ever change our schema.
55
- _version: 1,
56
- },
57
- onValueCreate(cloudinaryType as any) // onValueCreate is mistyped
58
- )
59
- )
60
- onChange(PatchEvent.from([setIfMissing([]), insert(items, 'after', [-1])]))
61
- },
62
- [onValueCreate, onChange, cloudinaryType]
63
- )
64
-
65
- const handleOpenSelector = useCallback(
66
- () =>
67
- secrets &&
68
- openMediaSelector(
69
- secrets.cloudName,
70
- secrets.apiKey,
71
- true, // multi-selection
72
- handleSelect
73
- ),
74
- [secrets, handleSelect]
75
- )
76
- return (
77
- <Flex gap={2} flex={1}>
78
- {showSettings && <SecretsConfigView onClose={hide} />}
79
- <Box flex={1}>
80
- <ArrayOfObjectsFunctions {...props} />
81
- </Box>
82
- {cloudinaryType && (
83
- <>
84
- <Box flex={1}>
85
- <Button
86
- style={{width: '100%'}}
87
- disabled={props.readOnly || loading}
88
- mode="bleed"
89
- text="Add multiple"
90
- onClick={handleOpenSelector}
91
- />
92
- </Box>
93
- <Box>
94
- <Button onClick={show} icon={PlugIcon} mode="bleed" title={'Configure'} />
95
- </Box>
96
- </>
97
- )}
98
- </Flex>
99
- )
100
- }
@@ -1,66 +0,0 @@
1
- import React from 'react'
2
- import VideoPlayer from './VideoPlayer'
3
- import {assetUrl} from '../utils'
4
- import {Flex, Text} from '@sanity/ui'
5
- import {CloudinaryAsset} from '../types'
6
- import {DocumentIcon} from '@sanity/icons'
7
-
8
- interface ComponentProps {
9
- layout?: 'default' | 'block'
10
- value: CloudinaryAsset | undefined
11
- }
12
-
13
- const AssetPreview = ({value, layout}: ComponentProps) => {
14
- const url = value && assetUrl(value)
15
- if (!value || !url) {
16
- return null
17
- }
18
-
19
- switch (value.resource_type) {
20
- case 'video':
21
- return (
22
- <Flex
23
- align="center"
24
- style={{
25
- maxWidth: layout === 'default' ? '80px' : '100%',
26
- }}
27
- >
28
- <VideoPlayer src={url} kind="player" />
29
- </Flex>
30
- )
31
- case 'raw':
32
- return (
33
- <Flex align="center">
34
- <DocumentIcon />
35
- <Text size={1} style={{marginLeft: '0.5em'}}>
36
- {value.display_name ?? 'Raw file'}
37
- </Text>
38
- </Flex>
39
- )
40
- default:
41
- return (
42
- <Flex align="center">
43
- <img
44
- alt="preview"
45
- src={
46
- // Cloudinary returns resource_type as "image" even for PDFs,
47
- // so we check the format to handle PDFs specifically.
48
- // If it's a PDF, convert the first page to JPG and overlay a "PDF" label for thumbnail clarity.
49
- value.format === 'pdf'
50
- ? url?.replace(
51
- 'image/upload',
52
- 'image/upload/f_jpg,pg_1,l_text:Verdana_75_letter_spacing_14:PDF'
53
- )
54
- : url
55
- }
56
- style={{
57
- maxWidth: layout === 'default' ? '80px' : '100%',
58
- height: 'auto',
59
- }}
60
- />
61
- </Flex>
62
- )
63
- }
64
- }
65
-
66
- export default AssetPreview
@@ -1,121 +0,0 @@
1
- import React, {useCallback, useState} from 'react'
2
- import WidgetInput from './WidgetInput'
3
- import {nanoid} from 'nanoid'
4
- import {ObjectInputProps, PatchEvent, set} from 'sanity'
5
- import {CloudinaryAsset, CloudinaryAssetResponse} from '../types'
6
- import {useSecrets} from '@sanity/studio-secrets'
7
- import {InsertHandlerParams} from '../types'
8
- import {openMediaSelector} from '../utils'
9
- import SecretsConfigView, {namespace, Secrets} from './SecretsConfigView'
10
-
11
- const CloudinaryInput = (props: ObjectInputProps) => {
12
- const [showSettings, setShowSettings] = useState(false)
13
- const {secrets} = useSecrets<Secrets>(namespace)
14
- const {onChange, schemaType: type} = props
15
- const value = (props.value as CloudinaryAsset) || undefined
16
-
17
- /* eslint-disable camelcase */
18
- const handleSelect = useCallback(
19
- (payload: InsertHandlerParams) => {
20
- const [asset] = payload.assets
21
-
22
- if (!asset) {
23
- return
24
- }
25
-
26
- let updatedAsset = asset
27
-
28
- // Update the asset with the new custom values
29
- const assetWithoutNulls = Object.fromEntries(
30
- Object.entries(asset).filter(([_, assetValue]) => assetValue !== null)
31
- ) as CloudinaryAssetResponse
32
-
33
- // Ensure we preserve the required fields from the original asset
34
- const requiredFields = {
35
- public_id: asset.public_id,
36
- resource_type: asset.resource_type,
37
- type: asset.type,
38
- url: asset.url,
39
- secure_url: asset.secure_url,
40
- format: asset.format,
41
- width: asset.width,
42
- height: asset.height,
43
- bytes: asset.bytes,
44
- tags: asset.tags,
45
- }
46
- updatedAsset = {
47
- ...assetWithoutNulls,
48
- ...requiredFields,
49
- }
50
-
51
- //The metadata in Sanity Studio cannot contain special characters,
52
- //hence the cloudinary metadata (context) needs to be transformed to valid object keys
53
- if (asset.context) {
54
- const objectWithRenamedKeys = Object.fromEntries(
55
- Object.entries(asset.context.custom).map(([contextKey, contextValue]) => {
56
- return [contextKey.replace(/[^a-zA-Z0-9_]|-/g, '_'), contextValue]
57
- })
58
- )
59
-
60
- // Update the asset with the new custom values
61
- updatedAsset = {
62
- ...updatedAsset,
63
- context: {
64
- ...asset.context,
65
- custom: objectWithRenamedKeys,
66
- },
67
- }
68
- }
69
-
70
- // Handle derived field - only include if not null
71
- if (asset.derived) {
72
- const derivedWithType = asset.derived.map((derivedItem) => ({
73
- ...derivedItem,
74
- _type: 'derived',
75
- }))
76
-
77
- updatedAsset = {
78
- ...updatedAsset,
79
- derived: derivedWithType,
80
- }
81
- }
82
-
83
- onChange(
84
- PatchEvent.from([
85
- set(
86
- Object.assign(
87
- {
88
- _type: type.name,
89
- _version: 1,
90
- ...(value?._key ? {_key: value._key} : {_key: nanoid()}),
91
- },
92
- updatedAsset
93
- )
94
- ),
95
- ])
96
- )
97
- },
98
- [onChange, type, value?._key]
99
- )
100
-
101
- const action = secrets
102
- ? () =>
103
- openMediaSelector(
104
- secrets.cloudName,
105
- secrets.apiKey,
106
- false, // single selection
107
- handleSelect,
108
- value
109
- )
110
- : () => setShowSettings(true)
111
-
112
- return (
113
- <>
114
- {showSettings && <SecretsConfigView onClose={() => setShowSettings(false)} />}
115
- <WidgetInput onSetup={() => setShowSettings(true)} openMediaSelector={action} {...props} />
116
- </>
117
- )
118
- /* eslint-enable camelcase */
119
- }
120
-
121
- export default CloudinaryInput
@@ -1,39 +0,0 @@
1
- import React from 'react'
2
- import {SettingsView} from '@sanity/studio-secrets'
3
-
4
- export type Secrets = {
5
- cloudName: string
6
- apiKey: string
7
- }
8
-
9
- const pluginConfigKeys = [
10
- {
11
- key: 'cloudName',
12
- title: 'Cloud name',
13
- description: '',
14
- },
15
- {
16
- key: 'apiKey',
17
- title: 'API key',
18
- description: '',
19
- },
20
- ]
21
-
22
- export const namespace = 'cloudinary'
23
-
24
- type Props = {
25
- onClose: () => void
26
- }
27
-
28
- const SecretsConfigView = (props: Props) => {
29
- return (
30
- <SettingsView
31
- title="Cloudinary config"
32
- namespace={namespace}
33
- keys={pluginConfigKeys}
34
- onClose={props.onClose}
35
- />
36
- )
37
- }
38
-
39
- export default SecretsConfigView
@@ -1,24 +0,0 @@
1
- import React, {CSSProperties} from 'react'
2
-
3
- type PlayerKind = 'player' | 'diff'
4
-
5
- export type VideoPlayerProps = {
6
- src: string
7
- // eslint-disable-next-line react/no-unused-prop-types
8
- kind: PlayerKind
9
- }
10
-
11
- export default function VideoPlayer(props: VideoPlayerProps) {
12
- const {src} = props
13
-
14
- const style: CSSProperties = {
15
- width: '100%',
16
- height: 'auto',
17
- }
18
-
19
- return (
20
- <video controls style={style}>
21
- <source src={src} type="video/mp4" />
22
- </video>
23
- )
24
- }
@@ -1,66 +0,0 @@
1
- import React, {useCallback} from 'react'
2
- import {ObjectInputProps, PatchEvent, unset} from 'sanity'
3
- import {Button, Flex, Grid, Stack} from '@sanity/ui'
4
- import {PlugIcon} from '@sanity/icons'
5
- import {styled} from 'styled-components'
6
- import AssetPreview from './AssetPreview'
7
- import {CloudinaryAsset} from '../types'
8
-
9
- const SetupButtonContainer = styled.div`
10
- position: relative;
11
- display: block;
12
- font-size: 0.8em;
13
- transform: translate(0%, -10%);
14
- `
15
-
16
- type WidgetInputProps = ObjectInputProps & {openMediaSelector: () => void; onSetup: () => void}
17
-
18
- const WidgetInput = (props: WidgetInputProps) => {
19
- const {onChange, readOnly, value, openMediaSelector} = props
20
-
21
- const removeValue = useCallback(() => {
22
- onChange(PatchEvent.from([unset()]))
23
- }, [onChange])
24
-
25
- return (
26
- <Stack>
27
- <SetupButtonContainer>
28
- <Flex flex={1} justify="flex-end">
29
- <Button
30
- color="primary"
31
- icon={PlugIcon}
32
- mode="bleed"
33
- title="Configure"
34
- onClick={props.onSetup}
35
- tabIndex={1}
36
- />
37
- </Flex>
38
- </SetupButtonContainer>
39
-
40
- <Flex style={{textAlign: 'center', width: '100%'}} marginBottom={2}>
41
- <AssetPreview value={value as CloudinaryAsset} />
42
- </Flex>
43
-
44
- <Grid gap={1} style={{gridTemplateColumns: 'repeat(auto-fit, minmax(100px, 1fr))'}}>
45
- <Button
46
- disabled={readOnly}
47
- mode="ghost"
48
- title="Select an asset"
49
- tone="default"
50
- onClick={openMediaSelector}
51
- text="Select…"
52
- />
53
- <Button
54
- disabled={readOnly || !value}
55
- tone="critical"
56
- mode="ghost"
57
- title="Remove asset"
58
- text="Remove"
59
- onClick={removeValue}
60
- />
61
- </Grid>
62
- </Stack>
63
- )
64
- }
65
-
66
- export default WidgetInput