sanity-plugin-media 2.0.3 → 2.0.5
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/LICENSE +1 -1
- package/README.md +9 -20
- package/lib/index.esm.js +1 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +6 -6
- package/src/components/DialogAssetEdit/index.tsx +5 -14
- package/src/components/FormFieldInputFilename/index.tsx +0 -50
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-media",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "This version of `sanity-plugin-media` is for Sanity Studio V3.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "git@github.com:sanity-io/sanity-plugin-media.git"
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
|
-
"author": "
|
|
24
|
+
"author": "Sanity.io <hello@sanity.io>",
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
27
|
"types": "./lib/src/index.d.ts",
|
|
@@ -73,14 +73,14 @@
|
|
|
73
73
|
"react-select": "^5.3.2",
|
|
74
74
|
"react-virtuoso": "^2.11.0",
|
|
75
75
|
"redux": "^4.2.0",
|
|
76
|
-
"redux-observable": "^
|
|
77
|
-
"rxjs": "^
|
|
76
|
+
"redux-observable": "^2.0.0",
|
|
77
|
+
"rxjs": "^7.0.0",
|
|
78
78
|
"yup": "^0.32.11"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@commitlint/cli": "^17.2.0",
|
|
82
82
|
"@commitlint/config-conventional": "^17.2.0",
|
|
83
|
-
"@sanity/client": "^
|
|
83
|
+
"@sanity/client": "^4.0.1",
|
|
84
84
|
"@sanity/color": "^2.1.20",
|
|
85
85
|
"@sanity/icons": "^2.0.0",
|
|
86
86
|
"@sanity/pkg-utils": "^1.17.2",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"react": "^18",
|
|
111
111
|
"react-dom": "^18",
|
|
112
112
|
"rimraf": "^3.0.2",
|
|
113
|
-
"sanity": "^3.
|
|
113
|
+
"sanity": "^3.2.0",
|
|
114
114
|
"standard-version": "^9.5.0",
|
|
115
115
|
"styled-components": "^5.3.3",
|
|
116
116
|
"typescript": "^4.8.4"
|
|
@@ -20,7 +20,6 @@ import AssetMetadata from '../AssetMetadata'
|
|
|
20
20
|
import Dialog from '../Dialog'
|
|
21
21
|
import DocumentList from '../DocumentList'
|
|
22
22
|
import FileAssetPreview from '../FileAssetPreview'
|
|
23
|
-
import FormFieldInputFilename from '../FormFieldInputFilename'
|
|
24
23
|
import FormFieldInputTags from '../FormFieldInputTags'
|
|
25
24
|
import FormFieldInputText from '../FormFieldInputText'
|
|
26
25
|
import FormFieldInputTextarea from '../FormFieldInputTextarea'
|
|
@@ -35,14 +34,9 @@ type Props = {
|
|
|
35
34
|
type FormData = yup.InferType<typeof formSchema>
|
|
36
35
|
|
|
37
36
|
const formSchema = yup.object().shape({
|
|
38
|
-
originalFilename: yup.string().required('Filename cannot be empty')
|
|
37
|
+
originalFilename: yup.string().trim().required('Filename cannot be empty')
|
|
39
38
|
})
|
|
40
39
|
|
|
41
|
-
const getFilenameWithoutExtension = (asset?: Asset): string | undefined => {
|
|
42
|
-
const extensionIndex = asset?.originalFilename?.toLowerCase().lastIndexOf(`.${asset.extension}`)
|
|
43
|
-
return asset?.originalFilename?.slice(0, extensionIndex)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
40
|
const DialogAssetEdit = (props: Props) => {
|
|
47
41
|
const {
|
|
48
42
|
children,
|
|
@@ -73,7 +67,7 @@ const DialogAssetEdit = (props: Props) => {
|
|
|
73
67
|
const generateDefaultValues = (asset?: Asset) => ({
|
|
74
68
|
altText: asset?.altText || '',
|
|
75
69
|
description: asset?.description || '',
|
|
76
|
-
originalFilename: asset
|
|
70
|
+
originalFilename: asset?.originalFilename || '',
|
|
77
71
|
opt: {media: {tags: assetTagOptions}},
|
|
78
72
|
title: asset?.title || ''
|
|
79
73
|
})
|
|
@@ -165,9 +159,7 @@ const DialogAssetEdit = (props: Props) => {
|
|
|
165
159
|
_weak: true
|
|
166
160
|
})) || null
|
|
167
161
|
}
|
|
168
|
-
}
|
|
169
|
-
// Append extension to filename
|
|
170
|
-
originalFilename: `${sanitizedFormData.originalFilename}.${assetItem?.asset.extension}`
|
|
162
|
+
}
|
|
171
163
|
}
|
|
172
164
|
})
|
|
173
165
|
)
|
|
@@ -323,14 +315,13 @@ const DialogAssetEdit = (props: Props) => {
|
|
|
323
315
|
value={assetTagOptions}
|
|
324
316
|
/>
|
|
325
317
|
{/* Filename */}
|
|
326
|
-
<
|
|
318
|
+
<FormFieldInputText
|
|
327
319
|
disabled={formUpdating}
|
|
328
320
|
error={errors?.originalFilename}
|
|
329
|
-
extension={currentAsset?.extension || ''}
|
|
330
321
|
label="Filename"
|
|
331
322
|
name="originalFilename"
|
|
332
323
|
ref={register}
|
|
333
|
-
value={
|
|
324
|
+
value={currentAsset?.originalFilename}
|
|
334
325
|
/>
|
|
335
326
|
{/* Title */}
|
|
336
327
|
<FormFieldInputText
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {Box, Flex, TextInput} from '@sanity/ui'
|
|
2
|
-
import React, {forwardRef} from 'react'
|
|
3
|
-
import {FieldError} from 'react-hook-form'
|
|
4
|
-
|
|
5
|
-
import FormFieldInputLabel from '../FormFieldInputLabel'
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
description?: string
|
|
9
|
-
extension: string
|
|
10
|
-
disabled?: boolean
|
|
11
|
-
error?: FieldError
|
|
12
|
-
label: string
|
|
13
|
-
name: string
|
|
14
|
-
placeholder?: string
|
|
15
|
-
value?: string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type Ref = HTMLInputElement
|
|
19
|
-
|
|
20
|
-
const FormFieldInputText = forwardRef<Ref, Props>((props: Props, ref) => {
|
|
21
|
-
const {description, disabled, error, extension, label, name, placeholder, value} = props
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<Box>
|
|
25
|
-
{/* Label */}
|
|
26
|
-
<FormFieldInputLabel description={description} error={error} label={label} name={name} />
|
|
27
|
-
|
|
28
|
-
{/* Input */}
|
|
29
|
-
<Flex>
|
|
30
|
-
<Box style={{flexGrow: 1}}>
|
|
31
|
-
<TextInput
|
|
32
|
-
autoComplete="off"
|
|
33
|
-
autoFocus
|
|
34
|
-
defaultValue={value}
|
|
35
|
-
disabled={disabled}
|
|
36
|
-
id={name}
|
|
37
|
-
name={name}
|
|
38
|
-
placeholder={placeholder}
|
|
39
|
-
ref={ref}
|
|
40
|
-
/>
|
|
41
|
-
</Box>
|
|
42
|
-
<Box style={{width: '70px'}}>
|
|
43
|
-
<TextInput defaultValue={`.${extension}`} disabled />
|
|
44
|
-
</Box>
|
|
45
|
-
</Flex>
|
|
46
|
-
</Box>
|
|
47
|
-
)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
export default FormFieldInputText
|