sanity-plugin-cloudinary 1.0.0-v3-studio.2 → 1.0.0-v3-studio.3
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 +6 -6
- package/lib/index.esm.js +2 -0
- package/lib/index.esm.js.map +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib/src/index.d.ts +35 -0
- package/package.json +21 -20
- package/src/index.ts +3 -3
- package/src/schema/cloudinaryAsset.ts +7 -5
- package/lib/cjs/index.js +0 -708
- package/lib/cjs/index.js.map +0 -1
- package/lib/esm/index.js +0 -697
- package/lib/esm/index.js.map +0 -1
- package/lib/types/index.d.ts +0 -22
- package/lib/types/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -33,10 +33,10 @@ Also see notes below on how Cloudinary config should be provided.
|
|
|
33
33
|
### Add Cloudinary as an asset source to all images
|
|
34
34
|
|
|
35
35
|
```js
|
|
36
|
-
import {
|
|
36
|
+
import {defineConfg} from 'sanity'
|
|
37
37
|
import {cloudinaryAssetSourcePlugin} from 'sanity-plugin-cloudinary'
|
|
38
38
|
|
|
39
|
-
export default
|
|
39
|
+
export default defineConfg({
|
|
40
40
|
/*...*/
|
|
41
41
|
plugins: [cloudinaryAssetSourcePlugin()],
|
|
42
42
|
})
|
|
@@ -45,10 +45,10 @@ export default createConfig({
|
|
|
45
45
|
### Fine tune image sources
|
|
46
46
|
|
|
47
47
|
```js
|
|
48
|
-
import {
|
|
48
|
+
import {defineConfg} from 'sanity'
|
|
49
49
|
import {cloudinaryImageSource} from 'sanity-plugin-cloudinary'
|
|
50
50
|
|
|
51
|
-
export default
|
|
51
|
+
export default defineConfg({
|
|
52
52
|
/*...*/
|
|
53
53
|
form: {
|
|
54
54
|
image: {
|
|
@@ -72,10 +72,10 @@ export default createConfig({
|
|
|
72
72
|
## Cloudinary assets
|
|
73
73
|
|
|
74
74
|
```js
|
|
75
|
-
import {
|
|
75
|
+
import {defineConfg} from 'sanity'
|
|
76
76
|
import {cloudinarySchemaPlugin} from 'sanity-plugin-cloudinary'
|
|
77
77
|
|
|
78
|
-
export default
|
|
78
|
+
export default defineConfg({
|
|
79
79
|
/*...*/
|
|
80
80
|
plugins: [cloudinarySchemaPlugin()],
|
|
81
81
|
})
|
package/lib/index.esm.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e,n;function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);n&&(c=c.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,c)}return t}function c(e){for(var n=1;n<arguments.length;n++){var c=null!=arguments[n]?arguments[n]:{};n%2?t(Object(c),!0).forEach((function(n){r(e,n,c[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(c)):t(Object(c)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(c,n))}))}return e}function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}import{jsxs as l,jsx as o,Fragment as s}from"react/jsx-runtime";import a,{useCallback as d,useState as u,useRef as p,useEffect as y}from"react";import{PatchEvent as h,unset as m,set as f,DiffFromTo as v,defineType as g,definePlugin as b}from"sanity";import{Box as _,Stack as C,Flex as j,Button as w,Grid as O,Dialog as k,Spinner as x,Text as S}from"@sanity/ui";import{PlugIcon as P}from"@sanity/icons";import D from"styled-components";import M from"video.js";import{nanoid as N}from"nanoid";import{SettingsView as z,useSecrets as H}from"@sanity/studio-secrets";class E extends a.Component{componentDidMount(){const{src:e}=this.props;this.player=M(this.videoNode,{sources:[{src:e}],controls:!0})}componentWillUnmount(){this.player&&this.player.dispose()}render(){const{kind:e}=this.props;return l("div",{children:[o("link",{href:"https://vjs.zencdn.net/7.8.4/video-js.css",rel:"stylesheet"}),o("div",{"data-vjs-player":!0,children:o("video",{onClick:e=>e.stopPropagation(),style:"diff"===e?{position:"relative"}:{},className:{player:"video-js vjs-16-9 vjs-big-play-centered",diff:"video-js vjs-layout-tiny vjs-fluid"}[e],ref:e=>{e&&(this.videoNode=e)}})})]})}}const L="https://media-library.cloudinary.com/global/all.js";function T(e){if(e.derived&&e.derived.length>0){const[n]=e.derived;return n.secure_url?n.secure_url:n.url}return e.secure_url?e.secure_url:e.url}function W(e,n){const t=document.getElementById("damWidget");if(!t){const t=document.createElement("script");t.src=e,t.id="damWidget",document.body.appendChild(t),t.onload=()=>!n||n()}return!t||!n||n()}function B(e){const{resource_type:n,public_id:t,type:c}=e;return btoa(JSON.stringify({public_id:t,resource_type:n,type:c}))}function I(e){return"".concat(e.public_id.split("/").slice(-1)[0],".").concat(e.format)}const K=e=>{let{value:n,layout:t}=e;const c=n&&T(n);return n&&c?"video"===n.resource_type?o(_,{children:o(E,{src:c,kind:"player"})}):o(_,{children:o("img",{alt:"preview",src:c,style:{maxWidth:"default"===t?"80px":"100%",height:"auto"}})}):null},A=D.div(e||(e=i(["\n position: relative;\n display: block;\n font-size: 0.8em;\n transform: translate(0%, -10%);\n"]))),F=e=>{const{onChange:n,readOnly:t,value:c,openMediaSelector:r}=e,i=d((()=>{n(h.from([m()]))}),[n]);return l(C,{children:[o(A,{children:o(j,{flex:1,justify:"flex-end",children:o(w,{color:"primary",icon:P,mode:"bleed",title:"Configure",onClick:e.onSetup,tabIndex:1})})}),o(j,{style:{textAlign:"center"},marginBottom:2,children:o(K,{value:c})}),l(O,{gap:1,style:{gridTemplateColumns:"repeat(auto-fit, minmax(100px, 1fr))"},children:[o(w,{disabled:t,mode:"ghost",title:"Select an asset",tone:"default",onClick:r,text:"Select…"}),o(w,{disabled:t||!c,tone:"critical",mode:"ghost",title:"Remove asset",text:"Remove",onClick:i})]})]})},V=[{key:"cloudName",title:"Cloud name",description:""},{key:"apiKey",title:"API key",description:""}],J=e=>o(z,{title:"Cloudinary config",namespace:"cloudinary",keys:V,onClose:e.onClose}),R=e=>{let{value:n}=e;if(!n)return null;const t=T(n);return"video"===n.resource_type?o("section",{style:{display:"flex",flexWrap:"wrap",justifyContent:"space-between"},children:o(E,{src:t,kind:"diff"})}):o("img",{alt:"preview",src:t,style:{maxWidth:"100%",height:"auto"}})},U=g(c(c({type:"object",name:"cloudinary.asset",fields:[{type:"string",name:"public_id"},{type:"string",name:"resource_type"},{type:"string",name:"type"},{type:"string",name:"format"},{type:"number",name:"version"},{type:"url",name:"url"},{type:"url",name:"secure_url"},{type:"number",name:"width"},{type:"number",name:"height"},{type:"number",name:"bytes"},{type:"number",name:"duration"},{type:"array",name:"tags",of:[{type:"string"}]},{type:"datetime",name:"created_at"},{type:"array",name:"derived",of:[{type:"cloudinary.assetDerived"}]},{type:"string",name:"access_mode"}]},{components:{input:e=>{const[n,t]=u(!1),{secrets:r}=H("cloudinary"),{onChange:i,schemaType:a}=e,p=e.value||void 0,y=d((e=>{const[n]=e.assets;n&&i(h.from([f(Object.assign(c({_type:a.name,_version:1},(null==p?void 0:p._key)?{_key:p._key}:{_key:N()}),n))]))}),[i,a,null==p?void 0:p._key]),m=r?()=>{return e=r.cloudName,n=r.apiKey,t=!1,c=y,i=p,void W(L,(()=>{const r={cloud_name:e,api_key:n,insert_caption:"Select",multiple:t};i&&(r.asset={public_id:i.public_id,type:i.type,resource_type:i.resource_type}),window.cloudinary.openMediaLibrary(r,{insertHandler:c})}));var e,n,t,c,i}:()=>t(!0);return l(s,{children:[n&&o(J,{onClose:()=>t(!1)}),o(F,c({onSetup:()=>t(!0),openMediaSelector:m},e))]})},diff:e=>{let{diff:n,schemaType:t}=e;return o(v,{diff:n,schemaType:t,previewComponent:R})},preview:K}}),{},{preview:{select:{url:"url",resource_type:"resource_type",derived:"derived.0.url"},prepare(e){let{url:n,derived:t,resource_type:c}=e;return{title:n,resource_type:c,url:t||n}}}})),q=g({type:"object",name:"cloudinary.assetDerived",fields:[{type:"string",name:"raw_transformation"},{type:"url",name:"url"},{type:"url",name:"secure_url"}]});const G=D.div(n||(n=i(["\n height: 70vh;\n"])));const Q=b({name:"cloudinary-schema",schema:{types:[U,q]}}),X={name:"cloudinary-image",title:"Cloudinary",icon:function(){return o("svg",{version:"1.1",id:"Layer_1",x:"0px",y:"0px",width:"1em",height:"1em",viewBox:"0 0 141.732 141.747",enableBackground:"new 0 0 141.732 141.747",children:l("g",{children:[o("path",{fill:"#0071CE",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"}),o("path",{fill:"#DC8327",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"}),o("path",{fill:"#F4B21B",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"}),o("path",{fill:"#F2D864",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"})]})})},component:function(e){const{onClose:n}=e,[t,c]=u("Loading Cloudinary Media Libary"),r=p(),i=p(null),{secrets:s}=H("cloudinary"),a=null==s?void 0:s.cloudName,h=null==s?void 0:s.apiKey,[m]=u((()=>"cloundinaryWidget-".concat(Date.now()))),[f,v]=u(!1),g=p(e);y((()=>{g.current=e}),[e]);const b=d((()=>{r.current&&r.current.hide(),n()}),[n,r]);y((()=>{a&&h&&(e=>{let{cloudName:n,apiKey:t,inlineContainer:c,libraryCreated:r,insertHandler:i}=e;W(L,(()=>{const e={cloud_name:n,api_key:t,insert_caption:"Select",inline_container:c,remove_header:!0};r(window.cloudinary.createMediaLibrary(e,{insertHandler:i}))}))})({cloudName:a,apiKey:h,inlineContainer:"#".concat(m),libraryCreated:e=>{r.current=e;const n=g.current.selectedAssets,t=n?n[0]:null,l=i.current&&i.current.firstChild;if(l&&l instanceof HTMLIFrameElement){let n;c(void 0),"single"===g.current.selectionType&&t&&t.source&&t.source.id&&(n=function(e){let n;try{n=JSON.parse(atob(e))}catch(e){}return n}(t.source.id));const r=n?{path:n.public_id.split("/").slice(0,-1).join("/"),resource_type:"image"}:{path:"",resource_type:"image"};e&&i.current&&(e.show({folder:r,asset:n}),i.current.style.visibility="visible")}},insertHandler:e=>{let{assets:n}=e;if(!r.current)return;const t=n.filter((e=>"image"===e.resource_type));if(0===t.length)throw new Error("The selection did not contain any images.");r.current.hide(),g.current.onSelect(t.map((e=>({kind:"url",value:e.derived&&e.derived[0]?e.derived[0].secure_url:e.secure_url,assetDocumentProps:{_type:"sanity.imageAsset",originalFilename:I(e),source:{id:B(e),name:"cloudinary:".concat(a)}}}))))}})}),[a,h,m]);const O=h&&a;return o(k,{id:"cloudinary-asset-source",header:"Select image from Cloudinary",onClose:b,open:!0,width:4,children:l(_,{padding:4,children:[f&&o(J,{onClose:()=>v(!1)}),o(j,{flex:1,justify:"flex-end",children:o(w,{color:"primary",icon:P,mode:"bleed",title:"Configure",onClick:()=>v(!0),tabIndex:1,text:O?void 0:"Configure Cloudinary plugin"})}),O&&t&&l(C,{space:3,children:[o(j,{align:"center",justify:"center",children:o(x,{muted:!0})}),o(S,{size:1,muted:!0,align:"center",children:t})]}),o(G,{style:{visibility:"hidden"},ref:i,id:m})]})})}},Y=b({name:"cloudinart-asset-source",form:{image:{assetSources:[X]}}});export{q as cloudinaryAssetDerivedSchema,U as cloudinaryAssetSchema,Y as cloudinaryAssetSourcePlugin,X as cloudinaryImageSource,Q as cloudinarySchemaPlugin};
|
|
2
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/components/VideoPlayer.tsx","../src/utils.ts","../src/components/AssetPreview.tsx","../src/components/WidgetInput.tsx","../src/components/SecretsConfigView.tsx","../src/components/AssetDiff.tsx","../src/schema/cloudinaryAsset.ts","../src/components/CloudinaryInput.tsx","../src/schema/cloudinaryAssetDerived.ts","../src/components/asset-source/CloudinaryAssetSource.tsx","../src/index.ts","../src/components/asset-source/Icon.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport videojs, { VideoJsPlayer } from 'video.js';\n\ntype PlayerKind = 'player' | 'diff';\n\nexport type VideoPlayerProps = {\n src: string;\n kind: PlayerKind;\n};\n\nexport default class VideoPlayer extends React.Component<\n VideoPlayerProps,\n any\n> {\n videoNode?: HTMLVideoElement;\n player?: VideoJsPlayer;\n\n componentDidMount() {\n const { src } = this.props;\n this.player = videojs(this.videoNode, {\n sources: [{ src }],\n controls: true,\n });\n }\n\n componentWillUnmount() {\n if (this.player) {\n this.player.dispose();\n }\n }\n\n render() {\n const { kind } = this.props;\n const className: Record<PlayerKind, string> = {\n player: 'video-js vjs-16-9 vjs-big-play-centered',\n diff: 'video-js vjs-layout-tiny vjs-fluid',\n };\n\n const style: CSSProperties = { position: 'relative' };\n\n return (\n <div>\n <link\n href=\"https://vjs.zencdn.net/7.8.4/video-js.css\"\n rel=\"stylesheet\"\n />\n <div data-vjs-player>\n <video\n onClick={event => event.stopPropagation()}\n style={kind === 'diff' ? style : {}}\n className={className[kind]}\n ref={node => {\n if (node) {\n this.videoNode = node;\n }\n }}\n ></video>\n </div>\n </div>\n );\n }\n}\n","/* eslint-disable camelcase */\nimport {\n CloudinaryAsset,\n CloudinaryAssetResponse,\n CloudinaryMediaLibrary,\n InsertHandlerParams,\n} from './typings'\n\nconst widgetSrc = 'https://media-library.cloudinary.com/global/all.js'\n\nexport function assetUrl(asset: CloudinaryAsset) {\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 {Box} from '@sanity/ui'\nimport {CloudinaryAsset} from '../typings'\n\ntype 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 <Box>\n <VideoPlayer src={url} kind=\"player\" />\n </Box>\n )\n default:\n return (\n <Box>\n <img\n alt=\"preview\"\n src={url}\n style={{\n maxWidth: layout === 'default' ? '80px' : '100%',\n height: 'auto',\n }}\n />\n </Box>\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 '../typings'\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'}} 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 from 'react'\nimport {DiffFromTo} from 'sanity'\nimport VideoPlayer from './VideoPlayer'\nimport {assetUrl} from '../utils'\nimport {CloudinaryAsset} from '../typings'\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') {\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'}],\n },\n {\n type: 'string',\n name: 'access_mode',\n },\n // context array of unknown content\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 resource_type,\n url: derived || url,\n }\n },\n },\n})\n","import React, {useCallback, useState} from 'react'\nimport WidgetInput from './WidgetInput'\nimport {nanoid} from 'nanoid'\nimport {ObjectInputProps, PatchEvent, set} from 'sanity'\nimport {CloudinaryAsset} from '../typings'\nimport {useSecrets} from '@sanity/studio-secrets'\nimport {InsertHandlerParams} from '../typings'\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 const handleSelect = useCallback(\n (payload: InsertHandlerParams) => {\n const [asset] = payload.assets\n if (!asset) {\n return\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 asset\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}\n\nexport default CloudinaryInput\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","/* 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 '../../typings'\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} = props\n\n const [loadingMessage, setLoadingMessage] = useState<string | undefined>(\n 'Loading Cloudinary Media Libary'\n )\n const library = useRef<CloudinaryMediaLibrary | 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=\"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 {cloudinaryAssetSchema} from './schema/cloudinaryAsset'\nimport {cloudinaryAssetDerivedSchema} from './schema/cloudinaryAssetDerived'\nimport {definePlugin, AssetSource} from 'sanity'\nimport {CloudinaryIcon} from './components/asset-source/Icon'\nimport {CloudinaryAssetSource} from './components/asset-source/CloudinaryAssetSource'\n\nexport {cloudinaryAssetSchema, cloudinaryAssetDerivedSchema}\n\nexport const cloudinarySchemaPlugin = definePlugin({\n name: 'cloudinary-schema',\n schema: {\n types: [cloudinaryAssetSchema, cloudinaryAssetDerivedSchema],\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","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"],"names":["VideoPlayer","React","Component","componentDidMount","src","this","props","player","videojs","videoNode","sources","controls","componentWillUnmount","dispose","render","kind","jsxs","children","jsx","href","rel","onClick","event","stopPropagation","style","position","className","diff","ref","node","widgetSrc","assetUrl","asset","derived","length","secure_url","url","loadJS","callback","existingScript","document","getElementById","script","createElement","id","body","appendChild","onload","encodeSourceId","resource_type","public_id","type","btoa","JSON","stringify","encodeFilename","split","slice","format","AssetPreview","_ref2","value","layout","Box","alt","maxWidth","height","SetupButtonContainer","styled","div","_templateObject","_taggedTemplateLiteral","WidgetInput","onChange","readOnly","openMediaSelector","removeValue","useCallback","PatchEvent","from","unset","Stack","Flex","flex","justify","Button","color","icon","PlugIcon","mode","title","onSetup","tabIndex","textAlign","marginBottom","Grid","gap","gridTemplateColumns","disabled","tone","text","pluginConfigKeys","key","description","SecretsConfigView","SettingsView","namespace","keys","onClose","CloudinaryDiffPreview","_ref3","display","flexWrap","justifyContent","cloudinaryAssetSchema","defineType","_objectSpread","name","fields","of","components","input","showSettings","setShowSettings","useState","secrets","useSecrets","schemaType","handleSelect","payload","assets","set","Object","assign","_type","_version","_key","nanoid","action","cloudName","apiKey","multiple","insertHandler","selectedAsset","options","cloud_name","api_key","insert_caption","window","cloudinary","openMediaLibrary","Fragment","_ref4","DiffFromTo","previewComponent","preview","select","prepare","_ref5","cloudinaryAssetDerivedSchema","Widget","_templateObject2","cloudinarySchemaPlugin","definePlugin","schema","types","cloudinaryImageSource","version","x","y","width","viewBox","enableBackground","fill","d","component","loadingMessage","setLoadingMessage","library","useRef","contentRef","widgetId","Date","now","propsRef","useEffect","current","handleClose","hide","_ref","inlineContainer","libraryCreated","inline_container","remove_header","createMediaLibrary","lib","selectedAssets","firstSelectedAsset","iframe","firstChild","HTMLIFrameElement","selectionType","source","sourceId","sourceIdDecoded","parse","atob","err","decodeSourceId","folder","path","join","show","visibility","_ref6","imageAssets","filter","Error","onSelect","map","assetDocumentProps","originalFilename","hasConfig","Dialog","header","open","padding","space","align","Spinner","muted","Text","size","cloudinaryAssetSourcePlugin","form","image","assetSources"],"mappings":"k2CAUqB,MAAAA,UAAoBC,EAAMC,UAO7CC,oBACQ,MAAAC,IAAEA,GAAQC,KAAKC,MAChBD,KAAAE,OAASC,EAAQH,KAAKI,UAAW,CACpCC,QAAS,CAAC,CAAEN,QACZO,UAAU,GAEd,CAEAC,uBACMP,KAAKE,QACPF,KAAKE,OAAOM,SAEhB,CAEAC,SACQ,MAAAC,KAAEA,GAASV,KAAKC,MAQtB,OACGU,EAAA,MAAA,CACCC,SAAA,CAACC,EAAA,OAAA,CACCC,KAAK,4CACLC,IAAI,eAELF,EAAA,MAAA,CAAI,mBAAe,EAClBD,SAACC,EAAA,QAAA,CACCG,QAAkBC,GAAAA,EAAMC,kBACxBC,MAAgB,SAATT,EAXc,CAAEU,SAAU,YAWA,CAAC,EAClCC,UAjBsC,CAC5CnB,OAAQ,0CACRoB,KAAM,sCAeqBZ,GACrBa,IAAaC,IACPA,IACFxB,KAAKI,UAAYoB,EACnB,QAMZ,ECpDF,MAAMC,EAAY,qDAEX,SAASC,EAASC,GACvB,GAAIA,EAAMC,SAAWD,EAAMC,QAAQC,OAAS,EAAG,CACvC,MAACD,GAAWD,EAAMC,QACxB,OAAIA,EAAQE,WACHF,EAAQE,WAEVF,EAAQG,GACjB,CACA,OAAIJ,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EAAA6M,EAAA,CACCnL,GAAG,0BACHoL,OAAO,+BACPpH,QAAS+E,EACTsC,MAAI,EACJvD,MAAO,EAEPzJ,SAACD,EAAA+C,EAAA,CAAImK,QAAS,EACXjN,SAAA,CAAAyG,GAAiBxG,EAAAsF,EAAA,CAAkBI,QAAS,IAAMe,GAAgB,KAClEzG,EAAAgE,EAAA,CAAKC,KAAM,EAAGC,QAAQ,WACrBnE,SAACC,EAAAmE,EAAA,CACCC,MAAM,UACNC,KAAMC,EACNC,KAAK,QACLC,MAAM,YACNrE,QAAS,IAAMsG,GAAgB,GAC/B/B,SAAU,EACVQ,KAAM0H,OAAY,EAAY,kCAIjCA,GAAa9C,GACXhK,EAAAiE,EAAA,CAAMkJ,MAAO,EACZlN,SAAA,CAACC,EAAAgE,EAAA,CAAKkJ,MAAM,SAAShJ,QAAQ,SAC3BnE,SAACC,EAAAmN,EAAA,CAAQC,OAAK,MAEfpN,EAAAqN,EAAA,CAAKC,KAAM,EAAGF,OAAK,EAACF,MAAM,SACxBnN,SAAA+J,OAKN9J,EAAA8I,EAAA,CAAOxI,MAAO,CAAC6L,WAAY,UAAWzL,IAAKwJ,EAAYxI,GAAIyI,QAIpE,GCpIaoD,EAA8BtE,EAAa,CACtD9C,KAAM,0BACNqH,KAAM,CACJC,MAAO,CACLC,aAAc,CAACtE"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e,n;function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);n&&(c=c.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,c)}return t}function c(e){for(var n=1;n<arguments.length;n++){var c=null!=arguments[n]?arguments[n]:{};n%2?t(Object(c),!0).forEach((function(n){r(e,n,c[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(c)):t(Object(c)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(c,n))}))}return e}function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}Object.defineProperty(exports,"__esModule",{value:!0});var l=require("react/jsx-runtime"),s=require("react"),o=require("sanity"),a=require("@sanity/ui"),u=require("@sanity/icons"),d=require("styled-components"),p=require("video.js"),y=require("nanoid"),h=require("@sanity/studio-secrets");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=m(s),v=m(d),j=m(p);class x extends f.default.Component{componentDidMount(){const{src:e}=this.props;this.player=j.default(this.videoNode,{sources:[{src:e}],controls:!0})}componentWillUnmount(){this.player&&this.player.dispose()}render(){const{kind:e}=this.props;return l.jsxs("div",{children:[l.jsx("link",{href:"https://vjs.zencdn.net/7.8.4/video-js.css",rel:"stylesheet"}),l.jsx("div",{"data-vjs-player":!0,children:l.jsx("video",{onClick:e=>e.stopPropagation(),style:"diff"===e?{position:"relative"}:{},className:{player:"video-js vjs-16-9 vjs-big-play-centered",diff:"video-js vjs-layout-tiny vjs-fluid"}[e],ref:e=>{e&&(this.videoNode=e)}})})]})}}const g="https://media-library.cloudinary.com/global/all.js";function b(e){if(e.derived&&e.derived.length>0){const[n]=e.derived;return n.secure_url?n.secure_url:n.url}return e.secure_url?e.secure_url:e.url}function _(e,n){const t=document.getElementById("damWidget");if(!t){const t=document.createElement("script");t.src=e,t.id="damWidget",document.body.appendChild(t),t.onload=()=>!n||n()}return!t||!n||n()}function C(e){const{resource_type:n,public_id:t,type:c}=e;return btoa(JSON.stringify({public_id:t,resource_type:n,type:c}))}function w(e){return"".concat(e.public_id.split("/").slice(-1)[0],".").concat(e.format)}const S=e=>{let{value:n,layout:t}=e;const c=n&&b(n);return n&&c?"video"===n.resource_type?l.jsx(a.Box,{children:l.jsx(x,{src:c,kind:"player"})}):l.jsx(a.Box,{children:l.jsx("img",{alt:"preview",src:c,style:{maxWidth:"default"===t?"80px":"100%",height:"auto"}})}):null},k=v.default.div(e||(e=i(["\n position: relative;\n display: block;\n font-size: 0.8em;\n transform: translate(0%, -10%);\n"]))),O=e=>{const{onChange:n,readOnly:t,value:c,openMediaSelector:r}=e,i=s.useCallback((()=>{n(o.PatchEvent.from([o.unset()]))}),[n]);return l.jsxs(a.Stack,{children:[l.jsx(k,{children:l.jsx(a.Flex,{flex:1,justify:"flex-end",children:l.jsx(a.Button,{color:"primary",icon:u.PlugIcon,mode:"bleed",title:"Configure",onClick:e.onSetup,tabIndex:1})})}),l.jsx(a.Flex,{style:{textAlign:"center"},marginBottom:2,children:l.jsx(S,{value:c})}),l.jsxs(a.Grid,{gap:1,style:{gridTemplateColumns:"repeat(auto-fit, minmax(100px, 1fr))"},children:[l.jsx(a.Button,{disabled:t,mode:"ghost",title:"Select an asset",tone:"default",onClick:r,text:"Select…"}),l.jsx(a.Button,{disabled:t||!c,tone:"critical",mode:"ghost",title:"Remove asset",text:"Remove",onClick:i})]})]})},P=[{key:"cloudName",title:"Cloud name",description:""},{key:"apiKey",title:"API key",description:""}],D=e=>l.jsx(h.SettingsView,{title:"Cloudinary config",namespace:"cloudinary",keys:P,onClose:e.onClose}),B=e=>{let{value:n}=e;if(!n)return null;const t=b(n);return"video"===n.resource_type?l.jsx("section",{style:{display:"flex",flexWrap:"wrap",justifyContent:"space-between"},children:l.jsx(x,{src:t,kind:"diff"})}):l.jsx("img",{alt:"preview",src:t,style:{maxWidth:"100%",height:"auto"}})},M=o.defineType(c(c({type:"object",name:"cloudinary.asset",fields:[{type:"string",name:"public_id"},{type:"string",name:"resource_type"},{type:"string",name:"type"},{type:"string",name:"format"},{type:"number",name:"version"},{type:"url",name:"url"},{type:"url",name:"secure_url"},{type:"number",name:"width"},{type:"number",name:"height"},{type:"number",name:"bytes"},{type:"number",name:"duration"},{type:"array",name:"tags",of:[{type:"string"}]},{type:"datetime",name:"created_at"},{type:"array",name:"derived",of:[{type:"cloudinary.assetDerived"}]},{type:"string",name:"access_mode"}]},{components:{input:e=>{const[n,t]=s.useState(!1),{secrets:r}=h.useSecrets("cloudinary"),{onChange:i,schemaType:a}=e,u=e.value||void 0,d=s.useCallback((e=>{const[n]=e.assets;n&&i(o.PatchEvent.from([o.set(Object.assign(c({_type:a.name,_version:1},(null==u?void 0:u._key)?{_key:u._key}:{_key:y.nanoid()}),n))]))}),[i,a,null==u?void 0:u._key]),p=r?()=>{return e=r.cloudName,n=r.apiKey,t=!1,c=d,i=u,void _(g,(()=>{const r={cloud_name:e,api_key:n,insert_caption:"Select",multiple:t};i&&(r.asset={public_id:i.public_id,type:i.type,resource_type:i.resource_type}),window.cloudinary.openMediaLibrary(r,{insertHandler:c})}));var e,n,t,c,i}:()=>t(!0);return l.jsxs(l.Fragment,{children:[n&&l.jsx(D,{onClose:()=>t(!1)}),l.jsx(O,c({onSetup:()=>t(!0),openMediaSelector:p},e))]})},diff:e=>{let{diff:n,schemaType:t}=e;return l.jsx(o.DiffFromTo,{diff:n,schemaType:t,previewComponent:B})},preview:S}}),{},{preview:{select:{url:"url",resource_type:"resource_type",derived:"derived.0.url"},prepare(e){let{url:n,derived:t,resource_type:c}=e;return{title:n,resource_type:c,url:t||n}}}})),E=o.defineType({type:"object",name:"cloudinary.assetDerived",fields:[{type:"string",name:"raw_transformation"},{type:"url",name:"url"},{type:"url",name:"secure_url"}]});const T=v.default.div(n||(n=i(["\n height: 70vh;\n"])));const F=o.definePlugin({name:"cloudinary-schema",schema:{types:[M,E]}}),N={name:"cloudinary-image",title:"Cloudinary",icon:function(){return l.jsx("svg",{version:"1.1",id:"Layer_1",x:"0px",y:"0px",width:"1em",height:"1em",viewBox:"0 0 141.732 141.747",enableBackground:"new 0 0 141.732 141.747",children:l.jsxs("g",{children:[l.jsx("path",{fill:"#0071CE",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"}),l.jsx("path",{fill:"#DC8327",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"}),l.jsx("path",{fill:"#F4B21B",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"}),l.jsx("path",{fill:"#F2D864",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"})]})})},component:function(e){const{onClose:n}=e,[t,c]=s.useState("Loading Cloudinary Media Libary"),r=s.useRef(),i=s.useRef(null),{secrets:o}=h.useSecrets("cloudinary"),d=null==o?void 0:o.cloudName,p=null==o?void 0:o.apiKey,[y]=s.useState((()=>"cloundinaryWidget-".concat(Date.now()))),[m,f]=s.useState(!1),v=s.useRef(e);s.useEffect((()=>{v.current=e}),[e]);const j=s.useCallback((()=>{r.current&&r.current.hide(),n()}),[n,r]);s.useEffect((()=>{d&&p&&(e=>{let{cloudName:n,apiKey:t,inlineContainer:c,libraryCreated:r,insertHandler:i}=e;_(g,(()=>{const e={cloud_name:n,api_key:t,insert_caption:"Select",inline_container:c,remove_header:!0};r(window.cloudinary.createMediaLibrary(e,{insertHandler:i}))}))})({cloudName:d,apiKey:p,inlineContainer:"#".concat(y),libraryCreated:e=>{r.current=e;const n=v.current.selectedAssets,t=n?n[0]:null,l=i.current&&i.current.firstChild;if(l&&l instanceof HTMLIFrameElement){let n;c(void 0),"single"===v.current.selectionType&&t&&t.source&&t.source.id&&(n=function(e){let n;try{n=JSON.parse(atob(e))}catch(e){}return n}(t.source.id));const r=n?{path:n.public_id.split("/").slice(0,-1).join("/"),resource_type:"image"}:{path:"",resource_type:"image"};e&&i.current&&(e.show({folder:r,asset:n}),i.current.style.visibility="visible")}},insertHandler:e=>{let{assets:n}=e;if(!r.current)return;const t=n.filter((e=>"image"===e.resource_type));if(0===t.length)throw new Error("The selection did not contain any images.");r.current.hide(),v.current.onSelect(t.map((e=>({kind:"url",value:e.derived&&e.derived[0]?e.derived[0].secure_url:e.secure_url,assetDocumentProps:{_type:"sanity.imageAsset",originalFilename:w(e),source:{id:C(e),name:"cloudinary:".concat(d)}}}))))}})}),[d,p,y]);const x=p&&d;return l.jsx(a.Dialog,{id:"cloudinary-asset-source",header:"Select image from Cloudinary",onClose:j,open:!0,width:4,children:l.jsxs(a.Box,{padding:4,children:[m&&l.jsx(D,{onClose:()=>f(!1)}),l.jsx(a.Flex,{flex:1,justify:"flex-end",children:l.jsx(a.Button,{color:"primary",icon:u.PlugIcon,mode:"bleed",title:"Configure",onClick:()=>f(!0),tabIndex:1,text:x?void 0:"Configure Cloudinary plugin"})}),x&&t&&l.jsxs(a.Stack,{space:3,children:[l.jsx(a.Flex,{align:"center",justify:"center",children:l.jsx(a.Spinner,{muted:!0})}),l.jsx(a.Text,{size:1,muted:!0,align:"center",children:t})]}),l.jsx(T,{style:{visibility:"hidden"},ref:i,id:y})]})})}},q=o.definePlugin({name:"cloudinart-asset-source",form:{image:{assetSources:[N]}}});exports.cloudinaryAssetDerivedSchema=E,exports.cloudinaryAssetSchema=M,exports.cloudinaryAssetSourcePlugin=q,exports.cloudinaryImageSource=N,exports.cloudinarySchemaPlugin=F;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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/AssetDiff.tsx","../src/schema/cloudinaryAsset.ts","../src/components/CloudinaryInput.tsx","../src/schema/cloudinaryAssetDerived.ts","../src/components/asset-source/CloudinaryAssetSource.tsx","../src/index.ts","../src/components/asset-source/Icon.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport videojs, { VideoJsPlayer } from 'video.js';\n\ntype PlayerKind = 'player' | 'diff';\n\nexport type VideoPlayerProps = {\n src: string;\n kind: PlayerKind;\n};\n\nexport default class VideoPlayer extends React.Component<\n VideoPlayerProps,\n any\n> {\n videoNode?: HTMLVideoElement;\n player?: VideoJsPlayer;\n\n componentDidMount() {\n const { src } = this.props;\n this.player = videojs(this.videoNode, {\n sources: [{ src }],\n controls: true,\n });\n }\n\n componentWillUnmount() {\n if (this.player) {\n this.player.dispose();\n }\n }\n\n render() {\n const { kind } = this.props;\n const className: Record<PlayerKind, string> = {\n player: 'video-js vjs-16-9 vjs-big-play-centered',\n diff: 'video-js vjs-layout-tiny vjs-fluid',\n };\n\n const style: CSSProperties = { position: 'relative' };\n\n return (\n <div>\n <link\n href=\"https://vjs.zencdn.net/7.8.4/video-js.css\"\n rel=\"stylesheet\"\n />\n <div data-vjs-player>\n <video\n onClick={event => event.stopPropagation()}\n style={kind === 'diff' ? style : {}}\n className={className[kind]}\n ref={node => {\n if (node) {\n this.videoNode = node;\n }\n }}\n ></video>\n </div>\n </div>\n );\n }\n}\n","/* eslint-disable camelcase */\nimport {\n CloudinaryAsset,\n CloudinaryAssetResponse,\n CloudinaryMediaLibrary,\n InsertHandlerParams,\n} from './typings'\n\nconst widgetSrc = 'https://media-library.cloudinary.com/global/all.js'\n\nexport function assetUrl(asset: CloudinaryAsset) {\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 {Box} from '@sanity/ui'\nimport {CloudinaryAsset} from '../typings'\n\ntype 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 <Box>\n <VideoPlayer src={url} kind=\"player\" />\n </Box>\n )\n default:\n return (\n <Box>\n <img\n alt=\"preview\"\n src={url}\n style={{\n maxWidth: layout === 'default' ? '80px' : '100%',\n height: 'auto',\n }}\n />\n </Box>\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 '../typings'\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'}} 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 from 'react'\nimport {DiffFromTo} from 'sanity'\nimport VideoPlayer from './VideoPlayer'\nimport {assetUrl} from '../utils'\nimport {CloudinaryAsset} from '../typings'\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') {\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'}],\n },\n {\n type: 'string',\n name: 'access_mode',\n },\n // context array of unknown content\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 resource_type,\n url: derived || url,\n }\n },\n },\n})\n","import React, {useCallback, useState} from 'react'\nimport WidgetInput from './WidgetInput'\nimport {nanoid} from 'nanoid'\nimport {ObjectInputProps, PatchEvent, set} from 'sanity'\nimport {CloudinaryAsset} from '../typings'\nimport {useSecrets} from '@sanity/studio-secrets'\nimport {InsertHandlerParams} from '../typings'\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 const handleSelect = useCallback(\n (payload: InsertHandlerParams) => {\n const [asset] = payload.assets\n if (!asset) {\n return\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 asset\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}\n\nexport default CloudinaryInput\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","/* 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 '../../typings'\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} = props\n\n const [loadingMessage, setLoadingMessage] = useState<string | undefined>(\n 'Loading Cloudinary Media Libary'\n )\n const library = useRef<CloudinaryMediaLibrary | 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=\"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 {cloudinaryAssetSchema} from './schema/cloudinaryAsset'\nimport {cloudinaryAssetDerivedSchema} from './schema/cloudinaryAssetDerived'\nimport {definePlugin, AssetSource} from 'sanity'\nimport {CloudinaryIcon} from './components/asset-source/Icon'\nimport {CloudinaryAssetSource} from './components/asset-source/CloudinaryAssetSource'\n\nexport {cloudinaryAssetSchema, cloudinaryAssetDerivedSchema}\n\nexport const cloudinarySchemaPlugin = definePlugin({\n name: 'cloudinary-schema',\n schema: {\n types: [cloudinaryAssetSchema, cloudinaryAssetDerivedSchema],\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","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"],"names":["VideoPlayer","React","Component","componentDidMount","src","this","props","player","videojs","videoNode","sources","controls","componentWillUnmount","dispose","render","kind","jsxs","children","jsx","href","rel","onClick","event","stopPropagation","style","position","className","diff","ref","node","widgetSrc","assetUrl","asset","derived","length","secure_url","url","loadJS","callback","existingScript","document","getElementById","script","createElement","id","body","appendChild","onload","encodeSourceId","resource_type","public_id","type","btoa","JSON","stringify","encodeFilename","split","slice","format","AssetPreview","_ref2","value","layout","Box","alt","maxWidth","height","SetupButtonContainer","styled","div","_templateObject","_taggedTemplateLiteral","WidgetInput","onChange","readOnly","openMediaSelector","removeValue","useCallback","PatchEvent","from","unset","Stack","Flex","flex","justify","Button","color","icon","PlugIcon","mode","title","onSetup","tabIndex","textAlign","marginBottom","Grid","gap","gridTemplateColumns","disabled","tone","text","pluginConfigKeys","key","description","SecretsConfigView","SettingsView","namespace","keys","onClose","CloudinaryDiffPreview","_ref3","display","flexWrap","justifyContent","cloudinaryAssetSchema","defineType","_objectSpread","name","fields","of","components","input","showSettings","setShowSettings","useState","secrets","useSecrets","schemaType","handleSelect","payload","assets","set","Object","assign","_type","_version","_key","nanoid","action","cloudName","apiKey","multiple","insertHandler","selectedAsset","options","cloud_name","api_key","insert_caption","window","cloudinary","openMediaLibrary","Fragment","_ref4","DiffFromTo","previewComponent","preview","select","prepare","_ref5","cloudinaryAssetDerivedSchema","Widget","_templateObject2","cloudinarySchemaPlugin","definePlugin","schema","types","cloudinaryImageSource","version","x","y","width","viewBox","enableBackground","fill","d","component","loadingMessage","setLoadingMessage","library","useRef","contentRef","widgetId","concat","Date","now","propsRef","useEffect","current","handleClose","hide","_ref","inlineContainer","libraryCreated","inline_container","remove_header","createMediaLibrary","lib","selectedAssets","firstSelectedAsset","iframe","firstChild","HTMLIFrameElement","selectionType","source","sourceId","sourceIdDecoded","parse","atob","err","decodeSourceId","folder","path","join","show","visibility","_ref6","imageAssets","filter","Error","onSelect","map","assetDocumentProps","originalFilename","hasConfig","Dialog","header","open","padding","space","align","Spinner","muted","Text","size","cloudinaryAssetSourcePlugin","form","image","assetSources"],"mappings":"gsCAUqB,MAAAA,UAAoBC,UAAMC,UAO7CC,oBACQ,MAAAC,IAAEA,GAAQC,KAAKC,MAChBD,KAAAE,OAASC,UAAQH,KAAKI,UAAW,CACpCC,QAAS,CAAC,CAAEN,QACZO,UAAU,GAEd,CAEAC,uBACMP,KAAKE,QACPF,KAAKE,OAAOM,SAEhB,CAEAC,SACQ,MAAAC,KAAEA,GAASV,KAAKC,MAQtB,OACGU,EAAAA,KAAA,MAAA,CACCC,SAAA,CAACC,EAAAA,IAAA,OAAA,CACCC,KAAK,4CACLC,IAAI,eAELF,EAAAA,IAAA,MAAA,CAAI,mBAAe,EAClBD,SAACC,EAAAA,IAAA,QAAA,CACCG,QAAkBC,GAAAA,EAAMC,kBACxBC,MAAgB,SAATT,EAXc,CAAEU,SAAU,YAWA,CAAC,EAClCC,UAjBsC,CAC5CnB,OAAQ,0CACRoB,KAAM,sCAeqBZ,GACrBa,IAAaC,IACPA,IACFxB,KAAKI,UAAYoB,EACnB,QAMZ,ECpDF,MAAMC,EAAY,qDAEX,SAASC,EAASC,GACvB,GAAIA,EAAMC,SAAWD,EAAMC,QAAQC,OAAS,EAAG,CACvC,MAACD,GAAWD,EAAMC,QACxB,OAAIA,EAAQE,WACHF,EAAQE,WAEVF,EAAQG,GACjB,CACA,OAAIJ,EAAMG,WACDH,EAAMG,WAERH,EAAMI,GACf,CAuDgB,SAAAC,EAAOD,EAAaE,GAC5B,MAAAC,EAAiBC,SAASC,eAAe,aAC/C,IAAKF,EAAgB,CACb,MAAAG,EAASF,SAASG,cAAc,UACtCD,EAAOtC,IAAM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
2
|
+
import {ObjectDefinition} from 'sanity'
|
|
3
|
+
import {Plugin as Plugin_2} from 'sanity'
|
|
4
|
+
import {PreviewConfig} from 'sanity'
|
|
5
|
+
|
|
6
|
+
export declare const cloudinaryAssetDerivedSchema: {
|
|
7
|
+
type: 'object'
|
|
8
|
+
name: 'cloudinary.assetDerived'
|
|
9
|
+
} & Omit<ObjectDefinition, 'preview'> & {
|
|
10
|
+
preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare const cloudinaryAssetSchema: {
|
|
14
|
+
type: 'object'
|
|
15
|
+
name: 'cloudinary.asset'
|
|
16
|
+
} & Omit<ObjectDefinition, 'preview'> & {
|
|
17
|
+
preview?:
|
|
18
|
+
| PreviewConfig<
|
|
19
|
+
{
|
|
20
|
+
url: string
|
|
21
|
+
resource_type: string
|
|
22
|
+
derived: string
|
|
23
|
+
},
|
|
24
|
+
Record<'url' | 'derived' | 'resource_type', any>
|
|
25
|
+
>
|
|
26
|
+
| undefined
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare const cloudinaryAssetSourcePlugin: Plugin_2<void>
|
|
30
|
+
|
|
31
|
+
export declare const cloudinaryImageSource: AssetSource
|
|
32
|
+
|
|
33
|
+
export declare const cloudinarySchemaPlugin: Plugin_2<void>
|
|
34
|
+
|
|
35
|
+
export {}
|
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-cloudinary",
|
|
3
|
-
"version": "1.0.0-v3-studio.
|
|
3
|
+
"version": "1.0.0-v3-studio.3",
|
|
4
4
|
"description": "> **NOTE**",
|
|
5
5
|
"author": "Sanity.io <hello@sanity.io>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"source": "./src/index.ts",
|
|
8
|
-
"main": "./lib/
|
|
9
|
-
"module": "./lib/
|
|
10
|
-
"types": "./lib/
|
|
8
|
+
"main": "./lib/index.js",
|
|
9
|
+
"module": "./lib/index.esm.js",
|
|
10
|
+
"types": "./lib/src/index.d.ts",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
13
|
+
"types": "./lib/src/index.d.ts",
|
|
14
|
+
"source": "./src/index.ts",
|
|
15
|
+
"import": "./lib/index.esm.js",
|
|
16
|
+
"require": "./lib/index.js",
|
|
17
|
+
"default": "./lib/index.esm.js"
|
|
15
18
|
}
|
|
16
19
|
},
|
|
17
20
|
"files": [
|
|
@@ -24,32 +27,31 @@
|
|
|
24
27
|
"node": ">=14.0.0"
|
|
25
28
|
},
|
|
26
29
|
"scripts": {
|
|
27
|
-
"build": "
|
|
28
|
-
"watch": "
|
|
30
|
+
"build": "pkg-utils build",
|
|
31
|
+
"watch": "pkg-utils watch",
|
|
29
32
|
"prepublishOnly": "npm run build",
|
|
30
33
|
"clean": "rimraf lib",
|
|
31
34
|
"lint": "eslint .",
|
|
32
|
-
"prebuild": "npm run clean && plugin-kit verify-package --silent",
|
|
35
|
+
"prebuild": "npm run clean && plugin-kit verify-package --silent && pkg-utils",
|
|
33
36
|
"link-watch": "plugin-kit link-watch",
|
|
34
37
|
"prepare": "husky install"
|
|
35
38
|
},
|
|
36
39
|
"peerDependencies": {
|
|
37
40
|
"react": "^18.0.0",
|
|
38
41
|
"react-dom": "^18.0.0",
|
|
39
|
-
"sanity": "dev-preview || 3.0.0-
|
|
42
|
+
"sanity": "dev-preview || 3.0.0-rc.0"
|
|
40
43
|
},
|
|
41
44
|
"devDependencies": {
|
|
42
|
-
"@commitlint/cli": "^17.
|
|
43
|
-
"@commitlint/config-conventional": "^17.
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@sanity/plugin-kit": "^1.0.2",
|
|
45
|
+
"@commitlint/cli": "^17.2.0",
|
|
46
|
+
"@commitlint/config-conventional": "^17.2.0",
|
|
47
|
+
"@sanity/pkg-utils": "^1.16.2",
|
|
48
|
+
"@sanity/plugin-kit": "^2.0.7",
|
|
47
49
|
"@sanity/semantic-release-preset": "^2.0.2",
|
|
48
50
|
"@types/react": "^18.0.0",
|
|
49
51
|
"@types/styled-components": "^5.1.26",
|
|
50
52
|
"@types/video.js": "^7.3.15",
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
52
|
-
"@typescript-eslint/parser": "^5.
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^5.42.0",
|
|
54
|
+
"@typescript-eslint/parser": "^5.42.0",
|
|
53
55
|
"eslint": "^8.26.0",
|
|
54
56
|
"eslint-config-prettier": "^8.5.0",
|
|
55
57
|
"eslint-config-sanity": "^6.0.0",
|
|
@@ -58,13 +60,12 @@
|
|
|
58
60
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
59
61
|
"husky": "^8.0.1",
|
|
60
62
|
"lint-staged": "^13.0.3",
|
|
61
|
-
"parcel": "~2.6.0",
|
|
62
63
|
"postcss": "^8.0.0",
|
|
63
64
|
"prettier": "^2.7.1",
|
|
64
65
|
"react": "^18.0.0",
|
|
65
66
|
"rimraf": "^3.0.2",
|
|
66
|
-
"sanity": "dev-preview || 3.0.0-
|
|
67
|
-
"typescript": "
|
|
67
|
+
"sanity": "dev-preview || 3.0.0-rc.0",
|
|
68
|
+
"typescript": "^4.8.4"
|
|
68
69
|
},
|
|
69
70
|
"dependencies": {
|
|
70
71
|
"@sanity/icons": "^1.3.6",
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {cloudinaryAssetSchema} from './schema/cloudinaryAsset'
|
|
2
2
|
import {cloudinaryAssetDerivedSchema} from './schema/cloudinaryAssetDerived'
|
|
3
|
-
import {
|
|
3
|
+
import {definePlugin, AssetSource} from 'sanity'
|
|
4
4
|
import {CloudinaryIcon} from './components/asset-source/Icon'
|
|
5
5
|
import {CloudinaryAssetSource} from './components/asset-source/CloudinaryAssetSource'
|
|
6
6
|
|
|
7
7
|
export {cloudinaryAssetSchema, cloudinaryAssetDerivedSchema}
|
|
8
8
|
|
|
9
|
-
export const cloudinarySchemaPlugin =
|
|
9
|
+
export const cloudinarySchemaPlugin = definePlugin({
|
|
10
10
|
name: 'cloudinary-schema',
|
|
11
11
|
schema: {
|
|
12
12
|
types: [cloudinaryAssetSchema, cloudinaryAssetDerivedSchema],
|
|
@@ -20,7 +20,7 @@ export const cloudinaryImageSource: AssetSource = {
|
|
|
20
20
|
component: CloudinaryAssetSource,
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export const cloudinaryAssetSourcePlugin =
|
|
23
|
+
export const cloudinaryAssetSourcePlugin = definePlugin({
|
|
24
24
|
name: 'cloudinart-asset-source',
|
|
25
25
|
form: {
|
|
26
26
|
image: {
|
|
@@ -77,11 +77,13 @@ export const cloudinaryAssetSchema = defineType({
|
|
|
77
77
|
// context array of unknown content
|
|
78
78
|
// metadata array of unknown content
|
|
79
79
|
],
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
...({
|
|
81
|
+
components: {
|
|
82
|
+
input: CloudinaryInput,
|
|
83
|
+
diff: AssetDiff,
|
|
84
|
+
preview: AssetPreview,
|
|
85
|
+
},
|
|
86
|
+
} as {}), //TODO revert this change when rc.1 is released
|
|
85
87
|
preview: {
|
|
86
88
|
select: {
|
|
87
89
|
url: 'url',
|