sanity-plugin-media 2.0.0-alpha.1 → 2.0.0-v3-studio.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/README.md +81 -33
  2. package/lib/cjs/index.js +7833 -0
  3. package/lib/cjs/index.js.map +1 -0
  4. package/lib/esm/index.js +7825 -0
  5. package/lib/esm/index.js.map +1 -0
  6. package/lib/types/index.d.ts +5 -0
  7. package/lib/types/index.d.ts.map +1 -0
  8. package/package.json +85 -76
  9. package/src/components/AssetGridVirtualized/index.tsx +79 -0
  10. package/src/components/AssetMetadata/index.tsx +113 -0
  11. package/src/components/AssetTableVirtualized/index.tsx +71 -0
  12. package/src/components/Browser/index.tsx +156 -0
  13. package/src/components/ButtonAssetCopy/index.tsx +67 -0
  14. package/src/components/ButtonViewGroup/index.tsx +39 -0
  15. package/src/components/CardAsset/index.tsx +266 -0
  16. package/src/components/CardUpload/index.tsx +157 -0
  17. package/src/components/Controls/index.tsx +135 -0
  18. package/src/components/DebugControls/index.tsx +77 -0
  19. package/src/components/Dialog/index.tsx +11 -0
  20. package/src/components/DialogAssetEdit/index.tsx +425 -0
  21. package/src/components/DialogConfirm/index.tsx +89 -0
  22. package/src/components/DialogSearchFacets/index.tsx +43 -0
  23. package/src/components/DialogTagCreate/index.tsx +122 -0
  24. package/src/components/DialogTagEdit/index.tsx +213 -0
  25. package/src/components/DialogTags/index.tsx +48 -0
  26. package/src/components/Dialogs/index.tsx +77 -0
  27. package/src/components/DocumentList/index.tsx +107 -0
  28. package/src/components/FileAssetPreview/index.tsx +37 -0
  29. package/src/components/FileIcon/index.tsx +41 -0
  30. package/src/components/FormBuilderTool/index.tsx +51 -0
  31. package/src/components/FormFieldInputFilename/index.tsx +50 -0
  32. package/src/components/FormFieldInputLabel/index.tsx +67 -0
  33. package/src/components/FormFieldInputTags/index.tsx +97 -0
  34. package/src/components/FormFieldInputText/index.tsx +41 -0
  35. package/src/components/FormFieldInputTextarea/index.tsx +43 -0
  36. package/src/components/FormSubmitButton/index.tsx +57 -0
  37. package/src/components/Header/index.tsx +76 -0
  38. package/src/components/Image/index.tsx +32 -0
  39. package/src/components/Items/index.tsx +67 -0
  40. package/src/components/Notifications/index.tsx +23 -0
  41. package/src/components/OrderSelect/index.tsx +59 -0
  42. package/src/components/PickedBar/index.tsx +75 -0
  43. package/src/components/Portal/index.tsx +24 -0
  44. package/src/components/Progress/index.tsx +39 -0
  45. package/src/components/ReduxProvider/index.tsx +74 -0
  46. package/src/components/SearchFacet/index.tsx +59 -0
  47. package/src/components/SearchFacetNumber/index.tsx +126 -0
  48. package/src/components/SearchFacetSelect/index.tsx +109 -0
  49. package/src/components/SearchFacetString/index.tsx +85 -0
  50. package/src/components/SearchFacetTags/index.tsx +108 -0
  51. package/src/components/SearchFacets/index.tsx +70 -0
  52. package/src/components/SearchFacetsControl/index.tsx +127 -0
  53. package/src/components/TableHeader/index.tsx +102 -0
  54. package/src/components/TableHeaderItem/index.tsx +61 -0
  55. package/src/components/TableRowAsset/index.tsx +334 -0
  56. package/src/components/TableRowUpload/index.tsx +165 -0
  57. package/src/components/Tag/index.tsx +199 -0
  58. package/src/components/TagIcon/index.tsx +24 -0
  59. package/src/components/TagView/index.tsx +48 -0
  60. package/src/components/TagViewHeader/index.tsx +71 -0
  61. package/src/components/TagsPanel/index.tsx +40 -0
  62. package/src/components/TagsVirtualized/index.tsx +159 -0
  63. package/src/components/TextInputNumber/index.tsx +32 -0
  64. package/src/components/TextInputSearch/index.tsx +59 -0
  65. package/src/components/Tool/index.tsx +13 -0
  66. package/src/components/UploadDropzone/index.tsx +150 -0
  67. package/src/config/orders.ts +28 -0
  68. package/src/config/searchFacets.ts +301 -0
  69. package/src/constants.ts +75 -0
  70. package/src/contexts/AssetSourceDispatchContext.tsx +37 -0
  71. package/src/contexts/DropzoneDispatchContext.tsx +34 -0
  72. package/src/hooks/useBreakpointIndex.ts +49 -0
  73. package/src/hooks/useKeyPress.ts +37 -0
  74. package/src/hooks/useOnScreen.ts +34 -0
  75. package/src/hooks/useTypedSelector.ts +7 -0
  76. package/src/index.ts +44 -0
  77. package/src/modules/assets/actions.ts +41 -0
  78. package/src/modules/assets/index.ts +806 -0
  79. package/src/modules/debug/index.ts +28 -0
  80. package/src/modules/dialog/actions.ts +10 -0
  81. package/src/modules/dialog/index.ts +233 -0
  82. package/src/modules/index.ts +109 -0
  83. package/src/modules/notifications/index.ts +178 -0
  84. package/src/modules/search/index.ts +134 -0
  85. package/src/modules/selected/index.ts +22 -0
  86. package/src/modules/selectors.ts +17 -0
  87. package/src/modules/tags/index.ts +544 -0
  88. package/src/modules/types.ts +9 -0
  89. package/src/modules/uploads/actions.ts +13 -0
  90. package/src/modules/uploads/index.ts +283 -0
  91. package/src/operators/checkTagName.ts +32 -0
  92. package/src/operators/debugThrottle.ts +25 -0
  93. package/src/schemas/tag.ts +28 -0
  94. package/src/styled/GlobalStyles/index.tsx +41 -0
  95. package/src/styled/react-select/creatable.tsx +187 -0
  96. package/src/styled/react-select/single.tsx +190 -0
  97. package/src/styled/theme.ts +12 -0
  98. package/src/types/index.ts +332 -0
  99. package/src/utils/blocksToText.ts +27 -0
  100. package/src/utils/constructFilter.ts +98 -0
  101. package/src/utils/generatePreviewBlobUrl.ts +47 -0
  102. package/src/utils/getAssetResolution.ts +7 -0
  103. package/src/utils/getDocumentAssetIds.ts +35 -0
  104. package/src/utils/getTagSelectOptions.ts +16 -0
  105. package/src/utils/imageDprUrl.ts +27 -0
  106. package/src/utils/sanitizeFormData.ts +26 -0
  107. package/src/utils/typeGuards.ts +9 -0
  108. package/src/utils/uploadSanityAsset.ts +93 -0
  109. package/src/utils/withMaxConcurrency.ts +55 -0
  110. package/CHANGELOG.md +0 -192
  111. package/dist/app.js +0 -78
  112. package/dist/app.js.map +0 -1
  113. package/dist/client.js +0 -12
  114. package/dist/client.js.map +0 -1
  115. package/dist/components/AssetMetadata/index.js +0 -61
  116. package/dist/components/AssetMetadata/index.js.map +0 -1
  117. package/dist/components/Browser/index.js +0 -118
  118. package/dist/components/Browser/index.js.map +0 -1
  119. package/dist/components/ButtonAssetClipboardCopy/index.js +0 -71
  120. package/dist/components/ButtonAssetCopy/index.js +0 -74
  121. package/dist/components/ButtonAssetCopy/index.js.map +0 -1
  122. package/dist/components/ButtonC/index.js +0 -71
  123. package/dist/components/ButtonClipboardCopy/index.js +0 -71
  124. package/dist/components/ButtonViewGroup/index.js +0 -27
  125. package/dist/components/ButtonViewGroup/index.js.map +0 -1
  126. package/dist/components/Card/index.js +0 -185
  127. package/dist/components/Card/index.js.map +0 -1
  128. package/dist/components/CardAsset/index.js +0 -174
  129. package/dist/components/CardAsset/index.js.map +0 -1
  130. package/dist/components/CardUpload/index.js +0 -96
  131. package/dist/components/CardUpload/index.js.map +0 -1
  132. package/dist/components/CardUpload copy/index.js +0 -60
  133. package/dist/components/Cards/index.js +0 -95
  134. package/dist/components/Cards/index.js.map +0 -1
  135. package/dist/components/Controls/index.js +0 -74
  136. package/dist/components/Controls/index.js.map +0 -1
  137. package/dist/components/DebugControls/index.js +0 -51
  138. package/dist/components/DebugControls/index.js.map +0 -1
  139. package/dist/components/DialogAssetEdit/index.js +0 -303
  140. package/dist/components/DialogAssetEdit/index.js.map +0 -1
  141. package/dist/components/DialogConfirm/index.js +0 -48
  142. package/dist/components/DialogConfirm/index.js.map +0 -1
  143. package/dist/components/DialogDeleteConfirm/index.js +0 -62
  144. package/dist/components/DialogDeleteConfirm/index.js.map +0 -1
  145. package/dist/components/DialogDetails/index.js +0 -322
  146. package/dist/components/DialogDetails/index.js.map +0 -1
  147. package/dist/components/DialogSearchFacets/index.js +0 -47
  148. package/dist/components/DialogSearchFacets/index.js.map +0 -1
  149. package/dist/components/DialogSearchFacets copy/index.js +0 -45
  150. package/dist/components/DialogTagCreate/index.js +0 -126
  151. package/dist/components/DialogTagCreate/index.js.map +0 -1
  152. package/dist/components/DialogTagCreate copy/index.js +0 -38
  153. package/dist/components/DialogTagEdit/index.js +0 -213
  154. package/dist/components/DialogTagEdit/index.js.map +0 -1
  155. package/dist/components/DialogTags/index.js +0 -49
  156. package/dist/components/DialogTags/index.js.map +0 -1
  157. package/dist/components/Dialogs/index.js +0 -46
  158. package/dist/components/Dialogs/index.js.map +0 -1
  159. package/dist/components/DocumentList/index.js +0 -50
  160. package/dist/components/DocumentList/index.js.map +0 -1
  161. package/dist/components/Dropzone/index.js +0 -66
  162. package/dist/components/Dropzone/index.js.map +0 -1
  163. package/dist/components/DropzoneTest/index.js +0 -37
  164. package/dist/components/FileAssetPreview/index.js +0 -24
  165. package/dist/components/FileAssetPreview/index.js.map +0 -1
  166. package/dist/components/FileIcon/index.js +0 -34
  167. package/dist/components/FileIcon/index.js.map +0 -1
  168. package/dist/components/FormDetails/index.js +0 -241
  169. package/dist/components/FormFieldInputFilename/index.js +0 -39
  170. package/dist/components/FormFieldInputFilename/index.js.map +0 -1
  171. package/dist/components/FormFieldInputLabel/index.js +0 -32
  172. package/dist/components/FormFieldInputLabel/index.js.map +0 -1
  173. package/dist/components/FormFieldInputTags/index.js +0 -40
  174. package/dist/components/FormFieldInputTags/index.js.map +0 -1
  175. package/dist/components/FormFieldInputText/index.js +0 -35
  176. package/dist/components/FormFieldInputText/index.js.map +0 -1
  177. package/dist/components/FormFieldInputTextarea/index.js +0 -35
  178. package/dist/components/FormFieldInputTextarea/index.js.map +0 -1
  179. package/dist/components/FormSubmitButton/index.js +0 -21
  180. package/dist/components/FormSubmitButton/index.js.map +0 -1
  181. package/dist/components/GlobalStyles/index.js +0 -10
  182. package/dist/components/Header/index.js +0 -36
  183. package/dist/components/Header/index.js.map +0 -1
  184. package/dist/components/Image/index.js +0 -34
  185. package/dist/components/Image/index.js.map +0 -1
  186. package/dist/components/Items/index.js +0 -127
  187. package/dist/components/Items/index.js.map +0 -1
  188. package/dist/components/NoResults/index.js +0 -12
  189. package/dist/components/Notifications/index.js +0 -25
  190. package/dist/components/Notifications/index.js.map +0 -1
  191. package/dist/components/OrderSelect/index.js +0 -30
  192. package/dist/components/OrderSelect/index.js.map +0 -1
  193. package/dist/components/PanelHeader/index.js +0 -49
  194. package/dist/components/PanelHeader/index.js.map +0 -1
  195. package/dist/components/PickedBar/index.js +0 -52
  196. package/dist/components/PickedBar/index.js.map +0 -1
  197. package/dist/components/Portal/Portal.js +0 -50
  198. package/dist/components/Portal/index.js +0 -49
  199. package/dist/components/Portal/index.js.map +0 -1
  200. package/dist/components/Progress/index.js +0 -30
  201. package/dist/components/Progress/index.js.map +0 -1
  202. package/dist/components/ReduxProvider/index.js +0 -106
  203. package/dist/components/ReduxProvider/index.js.map +0 -1
  204. package/dist/components/SearchFacet/index.js +0 -38
  205. package/dist/components/SearchFacet/index.js.map +0 -1
  206. package/dist/components/SearchFacetNumber/index.js +0 -43
  207. package/dist/components/SearchFacetNumber/index.js.map +0 -1
  208. package/dist/components/SearchFacetSearchable/index.js +0 -61
  209. package/dist/components/SearchFacetSearchable/index.js.map +0 -1
  210. package/dist/components/SearchFacetSelect/index.js +0 -39
  211. package/dist/components/SearchFacetSelect/index.js.map +0 -1
  212. package/dist/components/SearchFacetString/index.js +0 -35
  213. package/dist/components/SearchFacetString/index.js.map +0 -1
  214. package/dist/components/SearchFacetTags/index.js +0 -48
  215. package/dist/components/SearchFacetTags/index.js.map +0 -1
  216. package/dist/components/SearchFacets/index.js +0 -52
  217. package/dist/components/SearchFacets/index.js.map +0 -1
  218. package/dist/components/SearchFacetsControl/index.js +0 -57
  219. package/dist/components/SearchFacetsControl/index.js.map +0 -1
  220. package/dist/components/Table/index.js +0 -87
  221. package/dist/components/Table/index.js.map +0 -1
  222. package/dist/components/TableHeader/index.js +0 -76
  223. package/dist/components/TableHeader/index.js.map +0 -1
  224. package/dist/components/TableHeaderItem/index.js +0 -44
  225. package/dist/components/TableHeaderItem/index.js.map +0 -1
  226. package/dist/components/TableRow/index.js +0 -221
  227. package/dist/components/TableRow/index.js.map +0 -1
  228. package/dist/components/TableRowAsset/index.js +0 -220
  229. package/dist/components/TableRowAsset/index.js.map +0 -1
  230. package/dist/components/TableRowUpload/index.js +0 -103
  231. package/dist/components/TableRowUpload/index.js.map +0 -1
  232. package/dist/components/Tag/index.js +0 -97
  233. package/dist/components/Tag/index.js.map +0 -1
  234. package/dist/components/TagIcon/index.js +0 -12
  235. package/dist/components/TagIcon/index.js.map +0 -1
  236. package/dist/components/TagPanel/index.js +0 -20
  237. package/dist/components/TagPanel/index.js.map +0 -1
  238. package/dist/components/Tags/index.js +0 -22
  239. package/dist/components/Tags/index.js.map +0 -1
  240. package/dist/components/TagsAll/index.js +0 -24
  241. package/dist/components/TagsAll/index.js.map +0 -1
  242. package/dist/components/TagsPanel/index.js +0 -34
  243. package/dist/components/TagsPanel/index.js.map +0 -1
  244. package/dist/components/TagsPicked/index.js +0 -82
  245. package/dist/components/TagsPicked/index.js.map +0 -1
  246. package/dist/components/TextEllipsis/index.js +0 -14
  247. package/dist/components/TextEllipsis/index.js.map +0 -1
  248. package/dist/components/TextInputNumber/index.js +0 -43
  249. package/dist/components/TextInputNumber/index.js.map +0 -1
  250. package/dist/components/TextInputSearch/index.js +0 -39
  251. package/dist/components/TextInputSearch/index.js.map +0 -1
  252. package/dist/components/UploadCard/index.js +0 -14
  253. package/dist/components/UploadDropzone/index.js +0 -198
  254. package/dist/components/UploadDropzone/index.js.map +0 -1
  255. package/dist/config/orders.js +0 -30
  256. package/dist/config/orders.js.map +0 -1
  257. package/dist/config/searchFacets.js +0 -294
  258. package/dist/config/searchFacets.js.map +0 -1
  259. package/dist/constants/searchFacets.js +0 -272
  260. package/dist/constants.js +0 -75
  261. package/dist/constants.js.map +0 -1
  262. package/dist/contexts/AssetSourceDispatchContext copy.js +0 -41
  263. package/dist/contexts/AssetSourceDispatchContext.js +0 -42
  264. package/dist/contexts/AssetSourceDispatchContext.js.map +0 -1
  265. package/dist/contexts/DropzoneDispatchContext.js +0 -40
  266. package/dist/contexts/DropzoneDispatchContext.js.map +0 -1
  267. package/dist/helpers/withRedux.js +0 -84
  268. package/dist/helpers/withRedux.js.map +0 -1
  269. package/dist/hooks/useBreakpointIndex.js +0 -66
  270. package/dist/hooks/useBreakpointIndex.js.map +0 -1
  271. package/dist/hooks/useKeyPress.js +0 -36
  272. package/dist/hooks/useKeyPress.js.map +0 -1
  273. package/dist/hooks/useOnScreen.js +0 -48
  274. package/dist/hooks/useOnScreen.js.map +0 -1
  275. package/dist/hooks/useTypedSelector.js +0 -6
  276. package/dist/hooks/useTypedSelector.js.map +0 -1
  277. package/dist/index.js +0 -14
  278. package/dist/index.js.map +0 -1
  279. package/dist/modules/assets/assetsSlice.js +0 -552
  280. package/dist/modules/assets/index.js +0 -621
  281. package/dist/modules/assets/index.js.map +0 -1
  282. package/dist/modules/assets/types.js +0 -2
  283. package/dist/modules/assets/types.js.map +0 -1
  284. package/dist/modules/debug/debugSlice.js +0 -23
  285. package/dist/modules/debug/index.js +0 -23
  286. package/dist/modules/debug/index.js.map +0 -1
  287. package/dist/modules/debug/types.js +0 -2
  288. package/dist/modules/debug/types.js.map +0 -1
  289. package/dist/modules/dialog/dialogSlice.js +0 -192
  290. package/dist/modules/dialog/index.js +0 -186
  291. package/dist/modules/dialog/index.js.map +0 -1
  292. package/dist/modules/dialog/types.js +0 -2
  293. package/dist/modules/dialog/types.js.map +0 -1
  294. package/dist/modules/document/documentSlice.js +0 -9
  295. package/dist/modules/document/index.js +0 -10
  296. package/dist/modules/document/index.js.map +0 -1
  297. package/dist/modules/document/types.js +0 -3
  298. package/dist/modules/document/types.js.map +0 -1
  299. package/dist/modules/document copy/index.js +0 -9
  300. package/dist/modules/documentAssets/index.js +0 -9
  301. package/dist/modules/index.js +0 -47
  302. package/dist/modules/index.js.map +0 -1
  303. package/dist/modules/notifications/index.js +0 -122
  304. package/dist/modules/notifications/index.js.map +0 -1
  305. package/dist/modules/notifications/notificationsSlice.js +0 -123
  306. package/dist/modules/notifications/types.js +0 -2
  307. package/dist/modules/notifications/types.js.map +0 -1
  308. package/dist/modules/search/index.js +0 -111
  309. package/dist/modules/search/index.js.map +0 -1
  310. package/dist/modules/search/searchSlice.js +0 -122
  311. package/dist/modules/search/types.js +0 -2
  312. package/dist/modules/search/types.js.map +0 -1
  313. package/dist/modules/selected/index.js +0 -15
  314. package/dist/modules/selected/index.js.map +0 -1
  315. package/dist/modules/selectedAssets/index.js +0 -10
  316. package/dist/modules/selectedAssets/index.js.map +0 -1
  317. package/dist/modules/selectedAssets/selectedAssetsSlice.js +0 -9
  318. package/dist/modules/selectedAssets/types.js +0 -2
  319. package/dist/modules/selectedAssets/types.js.map +0 -1
  320. package/dist/modules/selectedAssets copy/index.js +0 -9
  321. package/dist/modules/selectors.js +0 -34
  322. package/dist/modules/selectors.js.map +0 -1
  323. package/dist/modules/tags/index.js +0 -436
  324. package/dist/modules/tags/index.js.map +0 -1
  325. package/dist/modules/tags/selectedAssetsSlice.js +0 -9
  326. package/dist/modules/tags/tagsSlice.js +0 -442
  327. package/dist/modules/tags/tagsSlice.js.map +0 -1
  328. package/dist/modules/tags/types.js +0 -2
  329. package/dist/modules/tags/types.js.map +0 -1
  330. package/dist/modules/types.js +0 -3
  331. package/dist/modules/types.js.map +0 -1
  332. package/dist/modules/uploads/index.js +0 -216
  333. package/dist/modules/uploads/index.js.map +0 -1
  334. package/dist/operators/checkTagName.js +0 -34
  335. package/dist/operators/checkTagName.js.map +0 -1
  336. package/dist/operators/debugThrottle copy.js +0 -15
  337. package/dist/operators/debugThrottle.js +0 -19
  338. package/dist/operators/debugThrottle.js.map +0 -1
  339. package/dist/operators/fetchExistingTag.js +0 -27
  340. package/dist/schemas/tag.js +0 -33
  341. package/dist/schemas/tag.js.map +0 -1
  342. package/dist/styled/GlobalStyles/index.js +0 -14
  343. package/dist/styled/GlobalStyles/index.js.map +0 -1
  344. package/dist/styled/react-select/creatable.js +0 -103
  345. package/dist/styled/react-select/creatable.js.map +0 -1
  346. package/dist/styled/react-select/single.js +0 -96
  347. package/dist/styled/react-select/single.js.map +0 -1
  348. package/dist/styled/theme.js +0 -13
  349. package/dist/styled/theme.js.map +0 -1
  350. package/dist/types/index.js +0 -3
  351. package/dist/types/index.js.map +0 -1
  352. package/dist/utils/blocksToText.js +0 -26
  353. package/dist/utils/blocksToText.js.map +0 -1
  354. package/dist/utils/constructFilter.js +0 -91
  355. package/dist/utils/constructFilter.js.map +0 -1
  356. package/dist/utils/generatePreviewBlobUrl.js +0 -83
  357. package/dist/utils/generatePreviewBlobUrl.js.map +0 -1
  358. package/dist/utils/getAssetResolution.js +0 -7
  359. package/dist/utils/getAssetResolution.js.map +0 -1
  360. package/dist/utils/getDocumentAssetIds.js +0 -52
  361. package/dist/utils/getDocumentAssetIds.js.map +0 -1
  362. package/dist/utils/getDocumentAssetRefs.js +0 -50
  363. package/dist/utils/getTagSelectOptions.js +0 -17
  364. package/dist/utils/getTagSelectOptions.js.map +0 -1
  365. package/dist/utils/imageDprUrl.js +0 -18
  366. package/dist/utils/imageDprUrl.js.map +0 -1
  367. package/dist/utils/sanitizeFormData.js +0 -26
  368. package/dist/utils/sanitizeFormData.js.map +0 -1
  369. package/dist/utils/typeGuards.js +0 -12
  370. package/dist/utils/typeGuards.js.map +0 -1
  371. package/dist/utils/uploadSanityAsset.js +0 -77
  372. package/dist/utils/uploadSanityAsset.js.map +0 -1
  373. package/dist/utils/withMaxConcurrency.js +0 -79
  374. package/dist/utils/withMaxConcurrency.js.map +0 -1
  375. package/sanity.json +0 -21
package/README.md CHANGED
@@ -1,14 +1,23 @@
1
1
  # Sanity Media
2
2
 
3
+ > ⚠️ This version of `sanity-plugin-media` is for [Sanity Studio V3](https://www.sanity.io/blog/sanity-studio-v3-developer-preview), which is currently in developer preview.
4
+ >
5
+ > The Studio V2 compatible version can be found on the [V2 branch](https://github.com/robinpyon/sanity-plugin-media).
6
+
7
+ ## What is it?
8
+
3
9
  ![npm-v](https://img.shields.io/npm/v/sanity-plugin-media?style=flat-square)
4
10
  ![npm-dw](https://img.shields.io/npm/dw/sanity-plugin-media?style=flat-square)
5
11
 
6
12
  A convenient way to browse, manage and refine your [Sanity](https://www.sanity.io/) assets.
7
13
 
8
- Use it standalone as a browser, or optionally hook it up as a [custom asset source](https://www.sanity.io/docs/custom-asset-sources) and use it to power asset selection too.
14
+ Use it standalone as a browser, or optionally hook it up as a [custom asset source](https://www.sanity.io/docs/custom-asset-sources) and use it to power both image and file selection too.
9
15
 
10
16
  ![Grid view](https://user-images.githubusercontent.com/209129/108927411-21aa7f00-7638-11eb-9cf7-334598ac4103.png)
11
- ![Asset view](https://user-images.githubusercontent.com/209129/105532355-9fe6cf00-5ce2-11eb-9982-b2bfd22f3409.png)
17
+ _Default grid view_
18
+
19
+ ![Asset view](https://user-images.githubusercontent.com/209129/132573482-fa866da9-7ee0-42db-b39f-25a0e48bba9f.png)
20
+ _Individual asset view_
12
21
 
13
22
  ## Features
14
23
 
@@ -29,51 +38,75 @@ Use it standalone as a browser, or optionally hook it up as a [custom asset sour
29
38
 
30
39
  #### Built for large datasets and collaborative editing in mind
31
40
 
32
- - Virtualized grid + tabular views for super speedy browsing, even with thousands of assets
41
+ - Virtualized grid + tabular views for super speedy browsing, even with thousands of assets and tags
33
42
  - Utilises Sanity's [real time updates](https://www.sanity.io/docs/realtime-updates) for live changes from other studio members
34
43
 
35
- #### Fits right in with your Sanity studio!
44
+ #### Fits right in with your Sanity studio
36
45
 
37
46
  - Built with the same [UI components Sanity uses](https://www.sanity.io/ui) under the hood
38
47
  - Fully responsive and mobile friendly
39
48
 
40
- ## Install
49
+ ## Install (V3 Studio only)
41
50
 
42
- In your Sanity project folder:
51
+ In your Sanity project folder, install the plugin and its peer dependency:
43
52
 
44
53
  ```sh
45
- sanity install media
54
+ npm install --save sanity-plugin-media@v3-studio @mdx-js/react
46
55
  ```
47
56
 
48
- This will add the Media button to your studio menu. If this is all you're after – that's all you need to do!
57
+ or
49
58
 
50
- ### Enabling it as a global [custom asset source](https://www.sanity.io/docs/custom-asset-sources)
59
+ ```sh
60
+ yarn add sanity-plugin-media@v3-studio @mdx-js/react
61
+ ```
51
62
 
52
- You'll need to do this if you want to use the plugin when selecting images.
63
+ `@mdx-js/react` will be removed as a dependency in a future version.
53
64
 
54
- This plugin exposes `part:sanity-plugin-media/asset-source` which you import when defining custom asset sources.
65
+ ## Usage
55
66
 
56
- In `sanity.json`, add the following snippet to the `parts` array:
67
+ Add it as a plugin in your `sanity.config.ts` (or .js) file:
57
68
 
58
- ```json
59
- {
60
- "implements": "part:@sanity/form-builder/input/image/asset-sources",
61
- "path": "./parts/assetSources.js"
62
- }
69
+ ```js
70
+ import {media} from 'sanity-plugin-media'
71
+
72
+ export default createConfig({
73
+ // ...
74
+ plugins: [media()]
75
+ })
63
76
  ```
64
77
 
65
- In `./parts/assetSources.js`:
78
+ This will enable the Media plugin as both a standalone tool (accessible in your studio menu) and as an additional asset source for your image and file fields.
66
79
 
67
- ```js
68
- import MediaAssetSource from 'part:sanity-plugin-media/asset-source'
80
+ ### Customizing the asset source
69
81
 
70
- export default [MediaAssetSource]
71
- ```
82
+ You can configure your studio to use this asset source either exclusively, or conditionally enable it based on the type of asset (image or file).
72
83
 
73
- That's it! The browser will now pop up every time you try select an image.
84
+ ```js
85
+ import {media, mediaAssetSource} from 'sanity-plugin-media'
86
+
87
+ export default createConfig({
88
+ // ...
89
+ plugins: [media()],
90
+ form: {
91
+ // Don't use this plugin when selecting files only (but allow all other enabled asset sources)
92
+ file: {
93
+ assetSources: previousAssetSources => {
94
+ return previousAssetSources.filter(assetSource => assetSource !== mediaAssetSource)
95
+ }
96
+ }
97
+ }
98
+ })
99
+ ```
74
100
 
75
101
  ## Known issues
76
102
 
103
+ <details>
104
+ <summary>(V3) Where has the references tab gone?</summary>
105
+
106
+ - This will be enabled in a future version!
107
+
108
+ </details>
109
+
77
110
  <details>
78
111
  <summary>There isn't a way to edit asset fields directly from the desk (without opening the plugin)</summary>
79
112
 
@@ -101,13 +134,6 @@ That's it! The browser will now pop up every time you try select an image.
101
134
 
102
135
  </details>
103
136
 
104
- <details>
105
- <summary>There isn't a way to use the plugin to select file (non-image) assets</summary>
106
-
107
- - This will be possible if and when Sanity enables custom asset sources on `file` fields.
108
-
109
- </details>
110
-
111
137
  <details>
112
138
  <summary>Limitations when using Sanity's GraphQL endpoints</summary>
113
139
 
@@ -195,7 +221,7 @@ Note that tags are namespaced within `opt.media` and tag names are accessed via
195
221
  #### Deleting assets
196
222
 
197
223
  <details>
198
- <summary>How come deleting multiple assets fails, even if only one asset is in use?</summary>
224
+ <summary>Why am I unable to delete multiple assets, even if only one asset is in use?</summary>
199
225
 
200
226
  - Batch mutations are carried out via Sanity [transactions](https://www.sanity.io/docs/transactions). These transactions are _atomic_, meaning that if one deletion fails (often because it's referenced elsewhere), then all mutations in the transaction will fail and no changes will occur
201
227
  - To get around this, simply make sure that all assets you've marked for deletion are not referenced – this can be easily accomplished by using a search facet to only show assets which are not in use
@@ -207,8 +233,8 @@ Note that tags are namespaced within `opt.media` and tag names are accessed via
207
233
  <details>
208
234
  <summary>How does the plugin determine what should uploaded as a <code>sanity.imageAsset</code> or <code>sanity.fileAsset</code>?</summary>
209
235
 
210
- - The plugin will look at incoming files' MIME type. All files of type `image/*` will be uploaded as `sanity.imageAsset`, everything else will be treated as `sanity.fileAsset`
211
- - This means that it's not possible to upload images as `sanity.fileAsset` via the plugin. In the rare case that you do need images to be treated as files, consider uploading them outside of the plugin
236
+ - As a rule of thumb, when uploading when accessing the plugin as a _tool_ (e.g. if you've acceessed it via the studio menu), it will look at any incoming files' MIME type. All files of type `image/*` will be uploaded as `sanity.imageAsset` whilst everything else will be treated as `sanity.fileAsset`
237
+ - If you upload when using the plugin in a _file_ selection context, these be uploaded as `sanity.fileAsset` regardless of their MIME type. This is probably not what you want, since images uploaded as files won't have associated metadata nor will they work in Sanity's image pipeline.
212
238
 
213
239
  </details>
214
240
 
@@ -229,3 +255,25 @@ Contributions, issues and feature requests are welcome!
229
255
  ## License
230
256
 
231
257
  MIT. See [license](LICENSE)
258
+
259
+ ## Develop & test
260
+
261
+ Make sure to run `npm run build` once, then run
262
+
263
+ ```bash
264
+ npm run link-watch
265
+ ```
266
+
267
+ In another shell, `cd` to your test studio and run:
268
+
269
+ ```bash
270
+ npx yalc add sanity-plugin-media && yarn install
271
+ ```
272
+
273
+ Now, changes in this repo will be automatically built and pushed to the studio,
274
+ triggering hotreload. Yalc avoids issues with react-hooks that are typical when using yarn/npm link.
275
+
276
+ ### About build & watch
277
+
278
+ This plugin uses [@sanity/plugin-sdk](https://github.com/sanity-io/plugin-sdk)
279
+ with default configuration for build & watch scripts.