sanity-plugin-cloudinary 0.2.1 → 1.0.0-v3-studio.2
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 +160 -66
- package/lib/cjs/index.js +708 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/esm/index.js +697 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/types/index.d.ts +22 -0
- package/lib/types/index.d.ts.map +1 -0
- package/package.json +66 -40
- package/sanity.json +3 -15
- package/src/arrayFunctions.tsx +71 -0
- package/src/components/AssetDiff.tsx +44 -0
- package/src/components/AssetPreview.tsx +41 -0
- package/src/components/CloudinaryInput.tsx +61 -0
- package/src/components/SecretsConfigView.tsx +39 -0
- package/src/components/VideoPlayer.tsx +62 -0
- package/src/components/WidgetInput.tsx +66 -0
- package/src/components/asset-source/CloudinaryAssetSource.tsx +155 -0
- package/src/components/asset-source/Icon.tsx +93 -0
- package/src/index.ts +30 -0
- package/src/schema/cloudinaryAsset.ts +99 -0
- package/src/schema/cloudinaryAssetDerived.ts +26 -0
- package/src/typings.d.ts +74 -0
- package/src/utils.ts +115 -0
- package/v2-incompatible.js +11 -0
- package/dist/arrayFunctions.js +0 -82
- package/dist/arrayFunctions.js.map +0 -1
- package/dist/components/AssetDiff.js +0 -62
- package/dist/components/AssetDiff.js.map +0 -1
- package/dist/components/AssetPreview.js +0 -46
- package/dist/components/AssetPreview.js.map +0 -1
- package/dist/components/CloudinaryInput.js +0 -90
- package/dist/components/CloudinaryInput.js.map +0 -1
- package/dist/components/SecretsConfigView.js +0 -37
- package/dist/components/SecretsConfigView.js.map +0 -1
- package/dist/components/VideoPlayer.js +0 -70
- package/dist/components/VideoPlayer.js.map +0 -1
- package/dist/components/WidgetInput.js +0 -87
- package/dist/components/WidgetInput.js.map +0 -1
- package/dist/index.js +0 -24
- package/dist/index.js.map +0 -1
- package/dist/schema/cloudinary.js +0 -19
- package/dist/schema/cloudinary.js.map +0 -1
- package/dist/schema/cloudinaryAsset.js +0 -100
- package/dist/schema/cloudinaryAsset.js.map +0 -1
- package/dist/schema/cloudinaryAssetDerived.js +0 -22
- package/dist/schema/cloudinaryAssetDerived.js.map +0 -1
- package/dist/typings.d.js +0 -8
- package/dist/typings.d.js.map +0 -1
- package/dist/utils.js +0 -92
- package/dist/utils.js.map +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,12 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# sanity-plugin-cloudinary
|
|
2
|
+
|
|
3
|
+
> **NOTE**
|
|
4
|
+
>
|
|
5
|
+
> This is the **Sanity Studio v3 version** of sanity-plugin-cloudinary AND sanity-plugin-asset-source-cloudinary.
|
|
6
|
+
>
|
|
7
|
+
> For the v2 versions of these, please refer to the [v2-branch for sanity-plugin-cloudinary](https://github.com/sanity-io/sanity-plugin-cloudinary) and
|
|
8
|
+
> [sanity-plugin-asset-source-cloudinary](https://github.com/sanity-io/sanity-plugin-asset-source-cloudinary).
|
|
2
9
|
|
|
3
10
|
## Installation
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
```
|
|
13
|
+
npm install --save sanity-plugin-cloudinary@studio-v3
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
or
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
yarn add sanity-plugin-cloudinary@studio-v3
|
|
20
|
+
```
|
|
6
21
|
|
|
7
22
|
## Usage
|
|
8
23
|
|
|
9
|
-
|
|
24
|
+
There are two plugins in this package:
|
|
25
|
+
|
|
26
|
+
- `cloudinaryAssetSourcePlugin` - use this if you intend to serve Cloudinary images from the Sanity CDN
|
|
27
|
+
- `cloudinarySchemaPlugin` - use this if you intend to serve Cloudinary images from the Cloudinary CDN
|
|
28
|
+
|
|
29
|
+
Also see notes below on how Cloudinary config should be provided.
|
|
30
|
+
|
|
31
|
+
## Cloudinary as a Sanity asset
|
|
32
|
+
|
|
33
|
+
### Add Cloudinary as an asset source to all images
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
import {createConfg} from 'sanity'
|
|
37
|
+
import {cloudinaryAssetSourcePlugin} from 'sanity-plugin-cloudinary'
|
|
38
|
+
|
|
39
|
+
export default createConfig({
|
|
40
|
+
/*...*/
|
|
41
|
+
plugins: [cloudinaryAssetSourcePlugin()],
|
|
42
|
+
})
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Fine tune image sources
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
import {createConfg} from 'sanity'
|
|
49
|
+
import {cloudinaryImageSource} from 'sanity-plugin-cloudinary'
|
|
50
|
+
|
|
51
|
+
export default createConfig({
|
|
52
|
+
/*...*/
|
|
53
|
+
form: {
|
|
54
|
+
image: {
|
|
55
|
+
assetSources: (previousAssetSources, context) => {
|
|
56
|
+
if (context.currentUser?.roles.includes('cloudinaryAccess')) {
|
|
57
|
+
// appends cloudinary as an asset source
|
|
58
|
+
return [...previousAssetSources, cloudinaryImageSource]
|
|
59
|
+
}
|
|
60
|
+
if (context.currentUser?.roles.includes('onlyCloudinaryAccess')) {
|
|
61
|
+
// only use clooudinary as an asset source
|
|
62
|
+
return [cloudinaryImageSource]
|
|
63
|
+
}
|
|
64
|
+
// dont add cloudnary as an asset sources
|
|
65
|
+
return previousAssetSources
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Cloudinary assets
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
import {createConfg} from 'sanity'
|
|
76
|
+
import {cloudinarySchemaPlugin} from 'sanity-plugin-cloudinary'
|
|
77
|
+
|
|
78
|
+
export default createConfig({
|
|
79
|
+
/*...*/
|
|
80
|
+
plugins: [cloudinarySchemaPlugin()],
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Now you can declare a field to be `cloudinary.asset` in your schema
|
|
10
85
|
|
|
11
86
|
```javascript
|
|
12
87
|
{
|
|
@@ -25,7 +100,6 @@ Uses Cloudinary media library for selecting assets and transformations
|
|
|
25
100
|
|
|
26
101
|
<img width="1416" alt="Screen Shot 2021-03-22 at 10 33 58 PM" src="https://user-images.githubusercontent.com/38528/112098236-b41e3f80-8b5e-11eb-9ee2-aa243420cf03.png">
|
|
27
102
|
|
|
28
|
-
|
|
29
103
|
<img width="996" alt="Screen Shot 2021-03-22 at 10 07 52 PM" src="https://user-images.githubusercontent.com/38528/112096210-0f4e3300-8b5b-11eb-9f26-45481df878ba.png">
|
|
30
104
|
|
|
31
105
|
## In arrays
|
|
@@ -43,30 +117,30 @@ If you use this type in an array, you will have additional array functions for a
|
|
|
43
117
|
|
|
44
118
|
<img width="658" alt="Screen Shot 2021-03-30 at 5 59 09 PM" src="https://user-images.githubusercontent.com/38528/113075424-bfd2bd00-9181-11eb-94e4-f69da4688963.png">
|
|
45
119
|
|
|
46
|
-
|
|
47
120
|
## Content
|
|
121
|
+
|
|
48
122
|
Here is an example of which data is stored on your document after selecting an asset.
|
|
49
123
|
|
|
50
124
|
```json
|
|
51
125
|
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
126
|
+
"public_id": "29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x",
|
|
127
|
+
"resource_type": "image",
|
|
128
|
+
"type": "upload",
|
|
129
|
+
"format": "jpg",
|
|
130
|
+
"version": 1616474653,
|
|
131
|
+
"url": "http://res.cloudinary.com/dzwiku20l/image/upload/v1616474653/29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x.jpg",
|
|
132
|
+
"secure_url": "https://res.cloudinary.com/dzwiku20l/image/upload/v1616474653/29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x.jpg",
|
|
133
|
+
"width": 2400,
|
|
134
|
+
"height": 1344,
|
|
135
|
+
"bytes": 547710,
|
|
136
|
+
"duration": null,
|
|
137
|
+
"tags": [],
|
|
138
|
+
"metadata": {},
|
|
139
|
+
"created_at": "2021-03-23T04:44:13Z",
|
|
140
|
+
"access_mode": "public",
|
|
141
|
+
"_version": 1,
|
|
142
|
+
"_type": "cloudinary.asset"
|
|
143
|
+
}
|
|
70
144
|
```
|
|
71
145
|
|
|
72
146
|
Note: The `_version` in the data here refers to the schema version of this plugin, should the way it stores the data from Cloudinary change in the future.
|
|
@@ -79,31 +153,31 @@ You can create a transformation when selecting the asset, and this information i
|
|
|
79
153
|
|
|
80
154
|
```json
|
|
81
155
|
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
156
|
+
"public_id": "29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x",
|
|
157
|
+
"resource_type": "image",
|
|
158
|
+
"type": "upload",
|
|
159
|
+
"format": "jpg",
|
|
160
|
+
"version": 1616474653,
|
|
161
|
+
"url": "http://res.cloudinary.com/dzwiku20l/image/upload/v1616474653/29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x.jpg",
|
|
162
|
+
"secure_url": "https://res.cloudinary.com/dzwiku20l/image/upload/v1616474653/29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x.jpg",
|
|
163
|
+
"width": 2400,
|
|
164
|
+
"height": 1344,
|
|
165
|
+
"bytes": 547710,
|
|
166
|
+
"duration": null,
|
|
167
|
+
"tags": null,
|
|
168
|
+
"metadata": [],
|
|
169
|
+
"created_at": "2021-03-23T04:44:13Z",
|
|
170
|
+
"derived": [
|
|
171
|
+
{
|
|
172
|
+
"url": "http://res.cloudinary.com/dzwiku20l/image/upload/a_45/v1616474653/29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x.jpg",
|
|
173
|
+
"secure_url": "https://res.cloudinary.com/dzwiku20l/image/upload/a_45/v1616474653/29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x.jpg",
|
|
174
|
+
"raw_transformation": "a_45"
|
|
175
|
+
}
|
|
176
|
+
],
|
|
177
|
+
"access_mode": "public",
|
|
178
|
+
"_version": 1,
|
|
179
|
+
"_type": "cloudinary.asset"
|
|
180
|
+
}
|
|
107
181
|
```
|
|
108
182
|
|
|
109
183
|
## Video
|
|
@@ -114,22 +188,42 @@ Video assets gets a video player preview in the Studio
|
|
|
114
188
|
|
|
115
189
|
```json
|
|
116
190
|
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
191
|
+
"public_id": "Make_it_happen_together.-WWa8qtgD0f0_nucpr9",
|
|
192
|
+
"resource_type": "video",
|
|
193
|
+
"type": "upload",
|
|
194
|
+
"format": "mp4",
|
|
195
|
+
"version": 1616474928,
|
|
196
|
+
"url": "http://res.cloudinary.com/dzwiku20l/video/upload/v1616474928/Make_it_happen_together.-WWa8qtgD0f0_nucpr9.mp4",
|
|
197
|
+
"secure_url": "https://res.cloudinary.com/dzwiku20l/video/upload/v1616474928/Make_it_happen_together.-WWa8qtgD0f0_nucpr9.mp4",
|
|
198
|
+
"width": 1920,
|
|
199
|
+
"height": 1080,
|
|
200
|
+
"bytes": 3937717,
|
|
201
|
+
"duration": 24.1,
|
|
202
|
+
"tags": [],
|
|
203
|
+
"metadata": [],
|
|
204
|
+
"created_at": "2021-03-23T04:48:48Z",
|
|
205
|
+
"access_mode": "public",
|
|
206
|
+
"_version": 1,
|
|
207
|
+
"_type": "cloudinary.asset"
|
|
208
|
+
}
|
|
135
209
|
```
|
|
210
|
+
|
|
211
|
+
## License
|
|
212
|
+
|
|
213
|
+
MIT-licensed. See LICENSE.
|
|
214
|
+
|
|
215
|
+
## Develop & test
|
|
216
|
+
|
|
217
|
+
This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
|
|
218
|
+
with default configuration for build & watch scripts.
|
|
219
|
+
|
|
220
|
+
See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
|
|
221
|
+
on how to run this plugin with hotreload in the studio.
|
|
222
|
+
|
|
223
|
+
### Release new version
|
|
224
|
+
|
|
225
|
+
Run ["CI & Release" workflow](https://github.com/sanity-io/sanity-plugin-cloudinary/actions/workflows/main.yml).
|
|
226
|
+
Make sure to select the main branch and check "Release new version".
|
|
227
|
+
|
|
228
|
+
Semantic release will only release on configured branches, so it is safe to run release on any branch.
|
|
229
|
+
|