sanity-plugin-media 2.0.0-alpha.1 → 2.0.0-v3-studio.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 +81 -33
- package/lib/cjs/index.js +7833 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/esm/index.js +7825 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/index.d.ts.map +1 -0
- package/package.json +85 -76
- package/src/components/AssetGridVirtualized/index.tsx +79 -0
- package/src/components/AssetMetadata/index.tsx +113 -0
- package/src/components/AssetTableVirtualized/index.tsx +71 -0
- package/src/components/Browser/index.tsx +156 -0
- package/src/components/ButtonAssetCopy/index.tsx +67 -0
- package/src/components/ButtonViewGroup/index.tsx +39 -0
- package/src/components/CardAsset/index.tsx +266 -0
- package/src/components/CardUpload/index.tsx +157 -0
- package/src/components/Controls/index.tsx +135 -0
- package/src/components/DebugControls/index.tsx +77 -0
- package/src/components/Dialog/index.tsx +11 -0
- package/src/components/DialogAssetEdit/index.tsx +425 -0
- package/src/components/DialogConfirm/index.tsx +89 -0
- package/src/components/DialogSearchFacets/index.tsx +43 -0
- package/src/components/DialogTagCreate/index.tsx +122 -0
- package/src/components/DialogTagEdit/index.tsx +213 -0
- package/src/components/DialogTags/index.tsx +48 -0
- package/src/components/Dialogs/index.tsx +77 -0
- package/src/components/DocumentList/index.tsx +107 -0
- package/src/components/FileAssetPreview/index.tsx +37 -0
- package/src/components/FileIcon/index.tsx +41 -0
- package/src/components/FormBuilderTool/index.tsx +51 -0
- package/src/components/FormFieldInputFilename/index.tsx +50 -0
- package/src/components/FormFieldInputLabel/index.tsx +67 -0
- package/src/components/FormFieldInputTags/index.tsx +97 -0
- package/src/components/FormFieldInputText/index.tsx +41 -0
- package/src/components/FormFieldInputTextarea/index.tsx +43 -0
- package/src/components/FormSubmitButton/index.tsx +57 -0
- package/src/components/Header/index.tsx +76 -0
- package/src/components/Image/index.tsx +32 -0
- package/src/components/Items/index.tsx +67 -0
- package/src/components/Notifications/index.tsx +23 -0
- package/src/components/OrderSelect/index.tsx +59 -0
- package/src/components/PickedBar/index.tsx +75 -0
- package/src/components/Portal/index.tsx +24 -0
- package/src/components/Progress/index.tsx +39 -0
- package/src/components/ReduxProvider/index.tsx +74 -0
- package/src/components/SearchFacet/index.tsx +59 -0
- package/src/components/SearchFacetNumber/index.tsx +126 -0
- package/src/components/SearchFacetSelect/index.tsx +109 -0
- package/src/components/SearchFacetString/index.tsx +85 -0
- package/src/components/SearchFacetTags/index.tsx +108 -0
- package/src/components/SearchFacets/index.tsx +70 -0
- package/src/components/SearchFacetsControl/index.tsx +127 -0
- package/src/components/TableHeader/index.tsx +102 -0
- package/src/components/TableHeaderItem/index.tsx +61 -0
- package/src/components/TableRowAsset/index.tsx +334 -0
- package/src/components/TableRowUpload/index.tsx +165 -0
- package/src/components/Tag/index.tsx +199 -0
- package/src/components/TagIcon/index.tsx +24 -0
- package/src/components/TagView/index.tsx +48 -0
- package/src/components/TagViewHeader/index.tsx +71 -0
- package/src/components/TagsPanel/index.tsx +40 -0
- package/src/components/TagsVirtualized/index.tsx +159 -0
- package/src/components/TextInputNumber/index.tsx +32 -0
- package/src/components/TextInputSearch/index.tsx +59 -0
- package/src/components/Tool/index.tsx +13 -0
- package/src/components/UploadDropzone/index.tsx +150 -0
- package/src/config/orders.ts +28 -0
- package/src/config/searchFacets.ts +301 -0
- package/src/constants.ts +75 -0
- package/src/contexts/AssetSourceDispatchContext.tsx +37 -0
- package/src/contexts/DropzoneDispatchContext.tsx +34 -0
- package/src/hooks/useBreakpointIndex.ts +49 -0
- package/src/hooks/useKeyPress.ts +37 -0
- package/src/hooks/useOnScreen.ts +34 -0
- package/src/hooks/useTypedSelector.ts +7 -0
- package/src/index.ts +44 -0
- package/src/modules/assets/actions.ts +41 -0
- package/src/modules/assets/index.ts +806 -0
- package/src/modules/debug/index.ts +28 -0
- package/src/modules/dialog/actions.ts +10 -0
- package/src/modules/dialog/index.ts +233 -0
- package/src/modules/index.ts +109 -0
- package/src/modules/notifications/index.ts +178 -0
- package/src/modules/search/index.ts +134 -0
- package/src/modules/selected/index.ts +22 -0
- package/src/modules/selectors.ts +17 -0
- package/src/modules/tags/index.ts +544 -0
- package/src/modules/types.ts +9 -0
- package/src/modules/uploads/actions.ts +13 -0
- package/src/modules/uploads/index.ts +283 -0
- package/src/operators/checkTagName.ts +32 -0
- package/src/operators/debugThrottle.ts +25 -0
- package/src/schemas/tag.ts +28 -0
- package/src/styled/GlobalStyles/index.tsx +41 -0
- package/src/styled/react-select/creatable.tsx +187 -0
- package/src/styled/react-select/single.tsx +190 -0
- package/src/styled/theme.ts +12 -0
- package/src/types/index.ts +332 -0
- package/src/utils/blocksToText.ts +27 -0
- package/src/utils/constructFilter.ts +98 -0
- package/src/utils/generatePreviewBlobUrl.ts +47 -0
- package/src/utils/getAssetResolution.ts +7 -0
- package/src/utils/getDocumentAssetIds.ts +35 -0
- package/src/utils/getTagSelectOptions.ts +16 -0
- package/src/utils/imageDprUrl.ts +27 -0
- package/src/utils/sanitizeFormData.ts +26 -0
- package/src/utils/typeGuards.ts +9 -0
- package/src/utils/uploadSanityAsset.ts +93 -0
- package/src/utils/withMaxConcurrency.ts +55 -0
- package/CHANGELOG.md +0 -192
- package/dist/app.js +0 -78
- package/dist/app.js.map +0 -1
- package/dist/client.js +0 -12
- package/dist/client.js.map +0 -1
- package/dist/components/AssetMetadata/index.js +0 -61
- package/dist/components/AssetMetadata/index.js.map +0 -1
- package/dist/components/Browser/index.js +0 -118
- package/dist/components/Browser/index.js.map +0 -1
- package/dist/components/ButtonAssetClipboardCopy/index.js +0 -71
- package/dist/components/ButtonAssetCopy/index.js +0 -74
- package/dist/components/ButtonAssetCopy/index.js.map +0 -1
- package/dist/components/ButtonC/index.js +0 -71
- package/dist/components/ButtonClipboardCopy/index.js +0 -71
- package/dist/components/ButtonViewGroup/index.js +0 -27
- package/dist/components/ButtonViewGroup/index.js.map +0 -1
- package/dist/components/Card/index.js +0 -185
- package/dist/components/Card/index.js.map +0 -1
- package/dist/components/CardAsset/index.js +0 -174
- package/dist/components/CardAsset/index.js.map +0 -1
- package/dist/components/CardUpload/index.js +0 -96
- package/dist/components/CardUpload/index.js.map +0 -1
- package/dist/components/CardUpload copy/index.js +0 -60
- package/dist/components/Cards/index.js +0 -95
- package/dist/components/Cards/index.js.map +0 -1
- package/dist/components/Controls/index.js +0 -74
- package/dist/components/Controls/index.js.map +0 -1
- package/dist/components/DebugControls/index.js +0 -51
- package/dist/components/DebugControls/index.js.map +0 -1
- package/dist/components/DialogAssetEdit/index.js +0 -303
- package/dist/components/DialogAssetEdit/index.js.map +0 -1
- package/dist/components/DialogConfirm/index.js +0 -48
- package/dist/components/DialogConfirm/index.js.map +0 -1
- package/dist/components/DialogDeleteConfirm/index.js +0 -62
- package/dist/components/DialogDeleteConfirm/index.js.map +0 -1
- package/dist/components/DialogDetails/index.js +0 -322
- package/dist/components/DialogDetails/index.js.map +0 -1
- package/dist/components/DialogSearchFacets/index.js +0 -47
- package/dist/components/DialogSearchFacets/index.js.map +0 -1
- package/dist/components/DialogSearchFacets copy/index.js +0 -45
- package/dist/components/DialogTagCreate/index.js +0 -126
- package/dist/components/DialogTagCreate/index.js.map +0 -1
- package/dist/components/DialogTagCreate copy/index.js +0 -38
- package/dist/components/DialogTagEdit/index.js +0 -213
- package/dist/components/DialogTagEdit/index.js.map +0 -1
- package/dist/components/DialogTags/index.js +0 -49
- package/dist/components/DialogTags/index.js.map +0 -1
- package/dist/components/Dialogs/index.js +0 -46
- package/dist/components/Dialogs/index.js.map +0 -1
- package/dist/components/DocumentList/index.js +0 -50
- package/dist/components/DocumentList/index.js.map +0 -1
- package/dist/components/Dropzone/index.js +0 -66
- package/dist/components/Dropzone/index.js.map +0 -1
- package/dist/components/DropzoneTest/index.js +0 -37
- package/dist/components/FileAssetPreview/index.js +0 -24
- package/dist/components/FileAssetPreview/index.js.map +0 -1
- package/dist/components/FileIcon/index.js +0 -34
- package/dist/components/FileIcon/index.js.map +0 -1
- package/dist/components/FormDetails/index.js +0 -241
- package/dist/components/FormFieldInputFilename/index.js +0 -39
- package/dist/components/FormFieldInputFilename/index.js.map +0 -1
- package/dist/components/FormFieldInputLabel/index.js +0 -32
- package/dist/components/FormFieldInputLabel/index.js.map +0 -1
- package/dist/components/FormFieldInputTags/index.js +0 -40
- package/dist/components/FormFieldInputTags/index.js.map +0 -1
- package/dist/components/FormFieldInputText/index.js +0 -35
- package/dist/components/FormFieldInputText/index.js.map +0 -1
- package/dist/components/FormFieldInputTextarea/index.js +0 -35
- package/dist/components/FormFieldInputTextarea/index.js.map +0 -1
- package/dist/components/FormSubmitButton/index.js +0 -21
- package/dist/components/FormSubmitButton/index.js.map +0 -1
- package/dist/components/GlobalStyles/index.js +0 -10
- package/dist/components/Header/index.js +0 -36
- package/dist/components/Header/index.js.map +0 -1
- package/dist/components/Image/index.js +0 -34
- package/dist/components/Image/index.js.map +0 -1
- package/dist/components/Items/index.js +0 -127
- package/dist/components/Items/index.js.map +0 -1
- package/dist/components/NoResults/index.js +0 -12
- package/dist/components/Notifications/index.js +0 -25
- package/dist/components/Notifications/index.js.map +0 -1
- package/dist/components/OrderSelect/index.js +0 -30
- package/dist/components/OrderSelect/index.js.map +0 -1
- package/dist/components/PanelHeader/index.js +0 -49
- package/dist/components/PanelHeader/index.js.map +0 -1
- package/dist/components/PickedBar/index.js +0 -52
- package/dist/components/PickedBar/index.js.map +0 -1
- package/dist/components/Portal/Portal.js +0 -50
- package/dist/components/Portal/index.js +0 -49
- package/dist/components/Portal/index.js.map +0 -1
- package/dist/components/Progress/index.js +0 -30
- package/dist/components/Progress/index.js.map +0 -1
- package/dist/components/ReduxProvider/index.js +0 -106
- package/dist/components/ReduxProvider/index.js.map +0 -1
- package/dist/components/SearchFacet/index.js +0 -38
- package/dist/components/SearchFacet/index.js.map +0 -1
- package/dist/components/SearchFacetNumber/index.js +0 -43
- package/dist/components/SearchFacetNumber/index.js.map +0 -1
- package/dist/components/SearchFacetSearchable/index.js +0 -61
- package/dist/components/SearchFacetSearchable/index.js.map +0 -1
- package/dist/components/SearchFacetSelect/index.js +0 -39
- package/dist/components/SearchFacetSelect/index.js.map +0 -1
- package/dist/components/SearchFacetString/index.js +0 -35
- package/dist/components/SearchFacetString/index.js.map +0 -1
- package/dist/components/SearchFacetTags/index.js +0 -48
- package/dist/components/SearchFacetTags/index.js.map +0 -1
- package/dist/components/SearchFacets/index.js +0 -52
- package/dist/components/SearchFacets/index.js.map +0 -1
- package/dist/components/SearchFacetsControl/index.js +0 -57
- package/dist/components/SearchFacetsControl/index.js.map +0 -1
- package/dist/components/Table/index.js +0 -87
- package/dist/components/Table/index.js.map +0 -1
- package/dist/components/TableHeader/index.js +0 -76
- package/dist/components/TableHeader/index.js.map +0 -1
- package/dist/components/TableHeaderItem/index.js +0 -44
- package/dist/components/TableHeaderItem/index.js.map +0 -1
- package/dist/components/TableRow/index.js +0 -221
- package/dist/components/TableRow/index.js.map +0 -1
- package/dist/components/TableRowAsset/index.js +0 -220
- package/dist/components/TableRowAsset/index.js.map +0 -1
- package/dist/components/TableRowUpload/index.js +0 -103
- package/dist/components/TableRowUpload/index.js.map +0 -1
- package/dist/components/Tag/index.js +0 -97
- package/dist/components/Tag/index.js.map +0 -1
- package/dist/components/TagIcon/index.js +0 -12
- package/dist/components/TagIcon/index.js.map +0 -1
- package/dist/components/TagPanel/index.js +0 -20
- package/dist/components/TagPanel/index.js.map +0 -1
- package/dist/components/Tags/index.js +0 -22
- package/dist/components/Tags/index.js.map +0 -1
- package/dist/components/TagsAll/index.js +0 -24
- package/dist/components/TagsAll/index.js.map +0 -1
- package/dist/components/TagsPanel/index.js +0 -34
- package/dist/components/TagsPanel/index.js.map +0 -1
- package/dist/components/TagsPicked/index.js +0 -82
- package/dist/components/TagsPicked/index.js.map +0 -1
- package/dist/components/TextEllipsis/index.js +0 -14
- package/dist/components/TextEllipsis/index.js.map +0 -1
- package/dist/components/TextInputNumber/index.js +0 -43
- package/dist/components/TextInputNumber/index.js.map +0 -1
- package/dist/components/TextInputSearch/index.js +0 -39
- package/dist/components/TextInputSearch/index.js.map +0 -1
- package/dist/components/UploadCard/index.js +0 -14
- package/dist/components/UploadDropzone/index.js +0 -198
- package/dist/components/UploadDropzone/index.js.map +0 -1
- package/dist/config/orders.js +0 -30
- package/dist/config/orders.js.map +0 -1
- package/dist/config/searchFacets.js +0 -294
- package/dist/config/searchFacets.js.map +0 -1
- package/dist/constants/searchFacets.js +0 -272
- package/dist/constants.js +0 -75
- package/dist/constants.js.map +0 -1
- package/dist/contexts/AssetSourceDispatchContext copy.js +0 -41
- package/dist/contexts/AssetSourceDispatchContext.js +0 -42
- package/dist/contexts/AssetSourceDispatchContext.js.map +0 -1
- package/dist/contexts/DropzoneDispatchContext.js +0 -40
- package/dist/contexts/DropzoneDispatchContext.js.map +0 -1
- package/dist/helpers/withRedux.js +0 -84
- package/dist/helpers/withRedux.js.map +0 -1
- package/dist/hooks/useBreakpointIndex.js +0 -66
- package/dist/hooks/useBreakpointIndex.js.map +0 -1
- package/dist/hooks/useKeyPress.js +0 -36
- package/dist/hooks/useKeyPress.js.map +0 -1
- package/dist/hooks/useOnScreen.js +0 -48
- package/dist/hooks/useOnScreen.js.map +0 -1
- package/dist/hooks/useTypedSelector.js +0 -6
- package/dist/hooks/useTypedSelector.js.map +0 -1
- package/dist/index.js +0 -14
- package/dist/index.js.map +0 -1
- package/dist/modules/assets/assetsSlice.js +0 -552
- package/dist/modules/assets/index.js +0 -621
- package/dist/modules/assets/index.js.map +0 -1
- package/dist/modules/assets/types.js +0 -2
- package/dist/modules/assets/types.js.map +0 -1
- package/dist/modules/debug/debugSlice.js +0 -23
- package/dist/modules/debug/index.js +0 -23
- package/dist/modules/debug/index.js.map +0 -1
- package/dist/modules/debug/types.js +0 -2
- package/dist/modules/debug/types.js.map +0 -1
- package/dist/modules/dialog/dialogSlice.js +0 -192
- package/dist/modules/dialog/index.js +0 -186
- package/dist/modules/dialog/index.js.map +0 -1
- package/dist/modules/dialog/types.js +0 -2
- package/dist/modules/dialog/types.js.map +0 -1
- package/dist/modules/document/documentSlice.js +0 -9
- package/dist/modules/document/index.js +0 -10
- package/dist/modules/document/index.js.map +0 -1
- package/dist/modules/document/types.js +0 -3
- package/dist/modules/document/types.js.map +0 -1
- package/dist/modules/document copy/index.js +0 -9
- package/dist/modules/documentAssets/index.js +0 -9
- package/dist/modules/index.js +0 -47
- package/dist/modules/index.js.map +0 -1
- package/dist/modules/notifications/index.js +0 -122
- package/dist/modules/notifications/index.js.map +0 -1
- package/dist/modules/notifications/notificationsSlice.js +0 -123
- package/dist/modules/notifications/types.js +0 -2
- package/dist/modules/notifications/types.js.map +0 -1
- package/dist/modules/search/index.js +0 -111
- package/dist/modules/search/index.js.map +0 -1
- package/dist/modules/search/searchSlice.js +0 -122
- package/dist/modules/search/types.js +0 -2
- package/dist/modules/search/types.js.map +0 -1
- package/dist/modules/selected/index.js +0 -15
- package/dist/modules/selected/index.js.map +0 -1
- package/dist/modules/selectedAssets/index.js +0 -10
- package/dist/modules/selectedAssets/index.js.map +0 -1
- package/dist/modules/selectedAssets/selectedAssetsSlice.js +0 -9
- package/dist/modules/selectedAssets/types.js +0 -2
- package/dist/modules/selectedAssets/types.js.map +0 -1
- package/dist/modules/selectedAssets copy/index.js +0 -9
- package/dist/modules/selectors.js +0 -34
- package/dist/modules/selectors.js.map +0 -1
- package/dist/modules/tags/index.js +0 -436
- package/dist/modules/tags/index.js.map +0 -1
- package/dist/modules/tags/selectedAssetsSlice.js +0 -9
- package/dist/modules/tags/tagsSlice.js +0 -442
- package/dist/modules/tags/tagsSlice.js.map +0 -1
- package/dist/modules/tags/types.js +0 -2
- package/dist/modules/tags/types.js.map +0 -1
- package/dist/modules/types.js +0 -3
- package/dist/modules/types.js.map +0 -1
- package/dist/modules/uploads/index.js +0 -216
- package/dist/modules/uploads/index.js.map +0 -1
- package/dist/operators/checkTagName.js +0 -34
- package/dist/operators/checkTagName.js.map +0 -1
- package/dist/operators/debugThrottle copy.js +0 -15
- package/dist/operators/debugThrottle.js +0 -19
- package/dist/operators/debugThrottle.js.map +0 -1
- package/dist/operators/fetchExistingTag.js +0 -27
- package/dist/schemas/tag.js +0 -33
- package/dist/schemas/tag.js.map +0 -1
- package/dist/styled/GlobalStyles/index.js +0 -14
- package/dist/styled/GlobalStyles/index.js.map +0 -1
- package/dist/styled/react-select/creatable.js +0 -103
- package/dist/styled/react-select/creatable.js.map +0 -1
- package/dist/styled/react-select/single.js +0 -96
- package/dist/styled/react-select/single.js.map +0 -1
- package/dist/styled/theme.js +0 -13
- package/dist/styled/theme.js.map +0 -1
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/utils/blocksToText.js +0 -26
- package/dist/utils/blocksToText.js.map +0 -1
- package/dist/utils/constructFilter.js +0 -91
- package/dist/utils/constructFilter.js.map +0 -1
- package/dist/utils/generatePreviewBlobUrl.js +0 -83
- package/dist/utils/generatePreviewBlobUrl.js.map +0 -1
- package/dist/utils/getAssetResolution.js +0 -7
- package/dist/utils/getAssetResolution.js.map +0 -1
- package/dist/utils/getDocumentAssetIds.js +0 -52
- package/dist/utils/getDocumentAssetIds.js.map +0 -1
- package/dist/utils/getDocumentAssetRefs.js +0 -50
- package/dist/utils/getTagSelectOptions.js +0 -17
- package/dist/utils/getTagSelectOptions.js.map +0 -1
- package/dist/utils/imageDprUrl.js +0 -18
- package/dist/utils/imageDprUrl.js.map +0 -1
- package/dist/utils/sanitizeFormData.js +0 -26
- package/dist/utils/sanitizeFormData.js.map +0 -1
- package/dist/utils/typeGuards.js +0 -12
- package/dist/utils/typeGuards.js.map +0 -1
- package/dist/utils/uploadSanityAsset.js +0 -77
- package/dist/utils/uploadSanityAsset.js.map +0 -1
- package/dist/utils/withMaxConcurrency.js +0 -79
- package/dist/utils/withMaxConcurrency.js.map +0 -1
- package/sanity.json +0 -21
package/README.md
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
# Sanity Media
|
|
2
2
|
|
|
3
|
+
> ⚠️ This version of `sanity-plugin-media` is for [Sanity Studio V3](https://www.sanity.io/blog/sanity-studio-v3-developer-preview), which is currently in developer preview.
|
|
4
|
+
>
|
|
5
|
+
> The Studio V2 compatible version can be found on the [V2 branch](https://github.com/robinpyon/sanity-plugin-media).
|
|
6
|
+
|
|
7
|
+
## What is it?
|
|
8
|
+
|
|
3
9
|

|
|
4
10
|

|
|
5
11
|
|
|
6
12
|
A convenient way to browse, manage and refine your [Sanity](https://www.sanity.io/) assets.
|
|
7
13
|
|
|
8
|
-
Use it standalone as a browser, or optionally hook it up as a [custom asset source](https://www.sanity.io/docs/custom-asset-sources) and use it to power
|
|
14
|
+
Use it standalone as a browser, or optionally hook it up as a [custom asset source](https://www.sanity.io/docs/custom-asset-sources) and use it to power both image and file selection too.
|
|
9
15
|
|
|
10
16
|

|
|
11
|
-
|
|
17
|
+
_Default grid view_
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
_Individual asset view_
|
|
12
21
|
|
|
13
22
|
## Features
|
|
14
23
|
|
|
@@ -29,51 +38,75 @@ Use it standalone as a browser, or optionally hook it up as a [custom asset sour
|
|
|
29
38
|
|
|
30
39
|
#### Built for large datasets and collaborative editing in mind
|
|
31
40
|
|
|
32
|
-
- Virtualized grid + tabular views for super speedy browsing, even with thousands of assets
|
|
41
|
+
- Virtualized grid + tabular views for super speedy browsing, even with thousands of assets and tags
|
|
33
42
|
- Utilises Sanity's [real time updates](https://www.sanity.io/docs/realtime-updates) for live changes from other studio members
|
|
34
43
|
|
|
35
|
-
#### Fits right in with your Sanity studio
|
|
44
|
+
#### Fits right in with your Sanity studio
|
|
36
45
|
|
|
37
46
|
- Built with the same [UI components Sanity uses](https://www.sanity.io/ui) under the hood
|
|
38
47
|
- Fully responsive and mobile friendly
|
|
39
48
|
|
|
40
|
-
## Install
|
|
49
|
+
## Install (V3 Studio only)
|
|
41
50
|
|
|
42
|
-
In your Sanity project folder:
|
|
51
|
+
In your Sanity project folder, install the plugin and its peer dependency:
|
|
43
52
|
|
|
44
53
|
```sh
|
|
45
|
-
|
|
54
|
+
npm install --save sanity-plugin-media@v3-studio @mdx-js/react
|
|
46
55
|
```
|
|
47
56
|
|
|
48
|
-
|
|
57
|
+
or
|
|
49
58
|
|
|
50
|
-
|
|
59
|
+
```sh
|
|
60
|
+
yarn add sanity-plugin-media@v3-studio @mdx-js/react
|
|
61
|
+
```
|
|
51
62
|
|
|
52
|
-
|
|
63
|
+
`@mdx-js/react` will be removed as a dependency in a future version.
|
|
53
64
|
|
|
54
|
-
|
|
65
|
+
## Usage
|
|
55
66
|
|
|
56
|
-
|
|
67
|
+
Add it as a plugin in your `sanity.config.ts` (or .js) file:
|
|
57
68
|
|
|
58
|
-
```
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
```js
|
|
70
|
+
import {media} from 'sanity-plugin-media'
|
|
71
|
+
|
|
72
|
+
export default createConfig({
|
|
73
|
+
// ...
|
|
74
|
+
plugins: [media()]
|
|
75
|
+
})
|
|
63
76
|
```
|
|
64
77
|
|
|
65
|
-
|
|
78
|
+
This will enable the Media plugin as both a standalone tool (accessible in your studio menu) and as an additional asset source for your image and file fields.
|
|
66
79
|
|
|
67
|
-
|
|
68
|
-
import MediaAssetSource from 'part:sanity-plugin-media/asset-source'
|
|
80
|
+
### Customizing the asset source
|
|
69
81
|
|
|
70
|
-
|
|
71
|
-
```
|
|
82
|
+
You can configure your studio to use this asset source either exclusively, or conditionally enable it based on the type of asset (image or file).
|
|
72
83
|
|
|
73
|
-
|
|
84
|
+
```js
|
|
85
|
+
import {media, mediaAssetSource} from 'sanity-plugin-media'
|
|
86
|
+
|
|
87
|
+
export default createConfig({
|
|
88
|
+
// ...
|
|
89
|
+
plugins: [media()],
|
|
90
|
+
form: {
|
|
91
|
+
// Don't use this plugin when selecting files only (but allow all other enabled asset sources)
|
|
92
|
+
file: {
|
|
93
|
+
assetSources: previousAssetSources => {
|
|
94
|
+
return previousAssetSources.filter(assetSource => assetSource !== mediaAssetSource)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
```
|
|
74
100
|
|
|
75
101
|
## Known issues
|
|
76
102
|
|
|
103
|
+
<details>
|
|
104
|
+
<summary>(V3) Where has the references tab gone?</summary>
|
|
105
|
+
|
|
106
|
+
- This will be enabled in a future version!
|
|
107
|
+
|
|
108
|
+
</details>
|
|
109
|
+
|
|
77
110
|
<details>
|
|
78
111
|
<summary>There isn't a way to edit asset fields directly from the desk (without opening the plugin)</summary>
|
|
79
112
|
|
|
@@ -101,13 +134,6 @@ That's it! The browser will now pop up every time you try select an image.
|
|
|
101
134
|
|
|
102
135
|
</details>
|
|
103
136
|
|
|
104
|
-
<details>
|
|
105
|
-
<summary>There isn't a way to use the plugin to select file (non-image) assets</summary>
|
|
106
|
-
|
|
107
|
-
- This will be possible if and when Sanity enables custom asset sources on `file` fields.
|
|
108
|
-
|
|
109
|
-
</details>
|
|
110
|
-
|
|
111
137
|
<details>
|
|
112
138
|
<summary>Limitations when using Sanity's GraphQL endpoints</summary>
|
|
113
139
|
|
|
@@ -195,7 +221,7 @@ Note that tags are namespaced within `opt.media` and tag names are accessed via
|
|
|
195
221
|
#### Deleting assets
|
|
196
222
|
|
|
197
223
|
<details>
|
|
198
|
-
<summary>
|
|
224
|
+
<summary>Why am I unable to delete multiple assets, even if only one asset is in use?</summary>
|
|
199
225
|
|
|
200
226
|
- Batch mutations are carried out via Sanity [transactions](https://www.sanity.io/docs/transactions). These transactions are _atomic_, meaning that if one deletion fails (often because it's referenced elsewhere), then all mutations in the transaction will fail and no changes will occur
|
|
201
227
|
- To get around this, simply make sure that all assets you've marked for deletion are not referenced – this can be easily accomplished by using a search facet to only show assets which are not in use
|
|
@@ -207,8 +233,8 @@ Note that tags are namespaced within `opt.media` and tag names are accessed via
|
|
|
207
233
|
<details>
|
|
208
234
|
<summary>How does the plugin determine what should uploaded as a <code>sanity.imageAsset</code> or <code>sanity.fileAsset</code>?</summary>
|
|
209
235
|
|
|
210
|
-
-
|
|
211
|
-
-
|
|
236
|
+
- As a rule of thumb, when uploading when accessing the plugin as a _tool_ (e.g. if you've acceessed it via the studio menu), it will look at any incoming files' MIME type. All files of type `image/*` will be uploaded as `sanity.imageAsset` whilst everything else will be treated as `sanity.fileAsset`
|
|
237
|
+
- If you upload when using the plugin in a _file_ selection context, these be uploaded as `sanity.fileAsset` regardless of their MIME type. This is probably not what you want, since images uploaded as files won't have associated metadata nor will they work in Sanity's image pipeline.
|
|
212
238
|
|
|
213
239
|
</details>
|
|
214
240
|
|
|
@@ -229,3 +255,25 @@ Contributions, issues and feature requests are welcome!
|
|
|
229
255
|
## License
|
|
230
256
|
|
|
231
257
|
MIT. See [license](LICENSE)
|
|
258
|
+
|
|
259
|
+
## Develop & test
|
|
260
|
+
|
|
261
|
+
Make sure to run `npm run build` once, then run
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
npm run link-watch
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
In another shell, `cd` to your test studio and run:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
npx yalc add sanity-plugin-media && yarn install
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Now, changes in this repo will be automatically built and pushed to the studio,
|
|
274
|
+
triggering hotreload. Yalc avoids issues with react-hooks that are typical when using yarn/npm link.
|
|
275
|
+
|
|
276
|
+
### About build & watch
|
|
277
|
+
|
|
278
|
+
This plugin uses [@sanity/plugin-sdk](https://github.com/sanity-io/plugin-sdk)
|
|
279
|
+
with default configuration for build & watch scripts.
|