@electrolux-oss/sanity-plugin-media 4.1.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,28 +1,14 @@
1
- # Sanity Media Plugin - Electrolux Version (for Sanity Studio v5 and v6)
1
+ # Sanity Media Plugin - Electrolux Version (for Sanity Studio v6)
2
2
 
3
- > This plugin supports **Sanity Studio v5 and v6**.
4
- > This is a forked version of Sanitys own [Media Plugin (v4.0.0)](https://github.com/sanity-io/sanity-plugin-media)
3
+ > This plugin supports **Sanity Studio v6.20 and newer**.
4
+ > Originally based on Sanity's [sanity-io/sanity-plugin-media](https://github.com/sanity-io/sanity-plugin-media) (v4.0.0, MIT).
5
5
 
6
- ## :warning: Breaking changes - (v3.0.0 → v4.0.0)
7
-
8
- ### **v3 → v4**
9
-
10
- This release targets **Sanity Studio v5 and v6**. Support for Studio v4 has been dropped, and the
11
- package is now **ESM-only** (the CommonJS build has been removed).
12
- Projects must be on Studio v5 or v6 (and React 19.2.2 or newer) before upgrading to v4.
13
-
14
- ### **v2 → v3**
15
-
16
- This release upgrades the plugin’s peer dependency from **React 18** to **React 19**.
17
- Projects using this plugin must update to React 19 before upgrading to v3.
18
-
19
- ## What is it?
20
-
21
- A Sanity Studio v5 / v6 plugin that extends media handling capabilities with custom enhancements, based on a fork of an original plugin by Sanity.io.
6
+ > [!WARNING]
7
+ > Breaking changes introduced in version 5.0.0 of this plugin. See [Breaking changes](#breaking-changes).
22
8
 
23
9
  A convenient way to browse, manage and refine your [Sanity](https://www.sanity.io/) assets.
24
10
 
25
- 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.
11
+ Use it standalone as a browser, or hook it up as a [custom asset source](https://www.sanity.io/docs/custom-asset-sources) to power both image and file selection too.
26
12
 
27
13
  ![Grid view](https://user-images.githubusercontent.com/209129/108927411-21aa7f00-7638-11eb-9cf7-334598ac4103.png)
28
14
  _Default grid view_
@@ -58,14 +44,24 @@ _Default grid view_
58
44
  - Built with the same [UI components Sanity uses](https://www.sanity.io/ui) under the hood
59
45
  - Fully responsive and mobile friendly
60
46
 
61
- #### Added support for multi-language alt texts
47
+ #### Electrolux additions
62
48
 
63
- - Define a list of available languages to enable multi-language alt texts for assets.
64
- - See example of how to enable this feature [here](###plugin-config).
49
+ - Multi-language alt texts, with validation of the default language (see [Plugin config](#plugin-config))
50
+ - Automatic tagging of assets selected or uploaded through a field (see [Auto-tagging assets from a field](#auto-tagging-assets-from-a-field))
51
+ - An **Edit Media** option on image and file fields (see [Edit Media](#edit-media))
52
+ - A maximum upload size for every upload in the Studio, and tags that hide assets from the browser
53
+ - A record of who uploaded each asset (see [Uploaded by](#uploaded-by))
65
54
 
66
- ## Install (Sanity Studio v5 and v6)
55
+ ## Install (Sanity Studio v6.20+)
67
56
 
68
- In your Sanity project folder:
57
+ | Package / Runtime | Requirement |
58
+ | --------------------- | ----------- |
59
+ | `sanity` | `^6.20.0` |
60
+ | `react` / `react-dom` | `^19.2.2` |
61
+ | `styled-components` | `^6.1.15` |
62
+ | Node.js | `>=22.12` |
63
+
64
+ Run
69
65
 
70
66
  ```zsh
71
67
  npm install --save @electrolux-oss/sanity-plugin-media
@@ -124,7 +120,7 @@ export default defineConfig({
124
120
  })
125
121
  ```
126
122
 
127
- ### Plugin Config
123
+ ### Plugin config
128
124
 
129
125
  ```ts
130
126
  // sanity.config.ts
@@ -225,7 +221,7 @@ The plugin adds an **Edit Media** option to the asset menu of image and file fie
225
221
 
226
222
  ## Develop locally
227
223
 
228
- ### Test your plugin locally
224
+ ### Link the plugin to a local studio
229
225
 
230
226
  **Step 1: Set up the plugin for local development**
231
227
 
@@ -264,8 +260,57 @@ import { media } from '@electrolux-oss/sanity-plugin-media'
264
260
 
265
261
  ### Making changes
266
262
 
267
- When you modify the plugin code:
263
+ When you modify the plugin code, `link-watch` rebuilds it and pushes the build to every studio
264
+ linked with yalc. Reload the studio to pick up the changes, and restart its dev server if it still
265
+ serves the old build.
266
+
267
+ ### Running the checks
268
+
269
+ ```zsh
270
+ npm run typecheck # tsc --noEmit
271
+ npm run lint # ESLint
272
+ npm run build # also fails on type errors
273
+ ```
274
+
275
+ This plugin has no automated tests yet.
268
276
 
269
- 1. The `link-watch` command will automatically rebuild
270
- 2. In your studio, run `npx yalc update` to pull the latest changes
271
- 3. Restart your dev server: `npm run dev`
277
+ ## Breaking changes
278
+
279
+ ### **v4 → v5**
280
+
281
+ This release requires **Sanity Studio v6.20 or newer**, the first Studio release on `@sanity/ui`
282
+ ^4.4.9. Support for Studio v5 and Studio v6 before 6.20 has been dropped; stay on v4 of this
283
+ plugin for older Studios.
284
+
285
+ - The plugin now uses the same `@sanity/ui` (v4) and `@sanity/client` (v8) versions as the Studio,
286
+ so npm installs one shared copy of each instead of a second one inside the plugin.
287
+ - `react-is` is no longer a peer dependency.
288
+ - The tag inputs take their colors and fonts from the Studio's theme, so they follow custom themes.
289
+
290
+ Requirements:
291
+
292
+ | Package / Runtime | Requirement |
293
+ | --------------------- | ----------- |
294
+ | `sanity` | `^6.20.0` |
295
+ | `react` / `react-dom` | `^19.2.2` |
296
+ | `styled-components` | `^6.1.15` |
297
+ | Node.js | `>=22.12` |
298
+
299
+ ### **v3 → v4**
300
+
301
+ This release targets **Sanity Studio v5 and v6**. Support for Studio v4 has been dropped, and the
302
+ package is now **ESM-only** (the CommonJS build has been removed).
303
+
304
+ Requirements:
305
+
306
+ | Package / Runtime | Requirement |
307
+ | ---------------------------------- | -------------------- |
308
+ | `sanity` | `^5.0.0 \|\| ^6.0.0` |
309
+ | `react` / `react-dom` / `react-is` | `^19.2.2` |
310
+ | `styled-components` | `^6.1.15` |
311
+ | Node.js | `>=22.12` |
312
+
313
+ ### **v2 → v3**
314
+
315
+ This release upgrades the plugin’s peer dependency from **React 18** to **React 19**.
316
+ Projects using this plugin must update to React 19 before upgrading to v3.
package/dist/index.d.ts CHANGED
@@ -43,13 +43,7 @@ declare const createAssetFormSchema: (
43
43
  ) => z.ZodObject<
44
44
  {
45
45
  altText: z.ZodOptional<z.ZodString>
46
- altTexts:
47
- | z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>
48
- | z.ZodEffects<
49
- z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>,
50
- Record<string, string | null>,
51
- Record<string, string | null>
52
- >
46
+ altTexts: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>
53
47
  creditLine: z.ZodOptional<z.ZodString>
54
48
  description: z.ZodOptional<z.ZodString>
55
49
  opt: z.ZodObject<
@@ -63,105 +57,20 @@ declare const createAssetFormSchema: (
63
57
  label: z.ZodString
64
58
  value: z.ZodString
65
59
  },
66
- 'strip',
67
- z.ZodTypeAny,
68
- {
69
- label: string
70
- value: string
71
- },
72
- {
73
- label: string
74
- value: string
75
- }
76
- >,
77
- 'many'
60
+ z.core.$strip
61
+ >
78
62
  >
79
63
  >
80
64
  },
81
- 'strip',
82
- z.ZodTypeAny,
83
- {
84
- tags:
85
- | {
86
- label: string
87
- value: string
88
- }[]
89
- | null
90
- },
91
- {
92
- tags:
93
- | {
94
- label: string
95
- value: string
96
- }[]
97
- | null
98
- }
65
+ z.core.$strip
99
66
  >
100
67
  },
101
- 'strip',
102
- z.ZodTypeAny,
103
- {
104
- media: {
105
- tags:
106
- | {
107
- label: string
108
- value: string
109
- }[]
110
- | null
111
- }
112
- },
113
- {
114
- media: {
115
- tags:
116
- | {
117
- label: string
118
- value: string
119
- }[]
120
- | null
121
- }
122
- }
68
+ z.core.$strip
123
69
  >
124
70
  originalFilename: z.ZodString
125
71
  title: z.ZodOptional<z.ZodString>
126
72
  },
127
- 'strip',
128
- z.ZodTypeAny,
129
- {
130
- altTexts: Record<string, string | null>
131
- opt: {
132
- media: {
133
- tags:
134
- | {
135
- label: string
136
- value: string
137
- }[]
138
- | null
139
- }
140
- }
141
- originalFilename: string
142
- altText?: string | undefined
143
- creditLine?: string | undefined
144
- description?: string | undefined
145
- title?: string | undefined
146
- },
147
- {
148
- altTexts: Record<string, string | null>
149
- opt: {
150
- media: {
151
- tags:
152
- | {
153
- label: string
154
- value: string
155
- }[]
156
- | null
157
- }
158
- }
159
- originalFilename: string
160
- altText?: string | undefined
161
- creditLine?: string | undefined
162
- description?: string | undefined
163
- title?: string | undefined
164
- }
73
+ z.core.$strip
165
74
  >
166
75
 
167
76
  declare type CustomFields = {
@@ -291,16 +200,7 @@ declare const tagOptionSchema: z.ZodObject<
291
200
  label: z.ZodString
292
201
  value: z.ZodString
293
202
  },
294
- 'strip',
295
- z.ZodTypeAny,
296
- {
297
- label: string
298
- value: string
299
- },
300
- {
301
- label: string
302
- value: string
303
- }
203
+ z.core.$strip
304
204
  >
305
205
 
306
206
  declare type TagSelectOption = z.infer<typeof tagOptionSchema>