@electrolux-oss/sanity-plugin-media 1.0.3 → 3.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,11 +1,17 @@
1
- # Sanity Media Plugin - Electrolux Version (for Sanity Studio v3)
1
+ # Sanity Media Plugin - Electrolux Version (for Sanity Studio v4)
2
2
 
3
- > This plugin is for **Sanity Studio v3**.
3
+ > This plugin is for **Sanity Studio v4**.
4
4
  > This is a forked version of Sanitys own [Media Plugin (v4.0.0)](https://github.com/sanity-io/sanity-plugin-media)
5
5
 
6
+ ## :warning: Breaking changes - (v2.0.0 → v3.0.0)
7
+ ### **v2 → v3**
8
+
9
+ This release upgrades the plugin’s peer dependency from **React 18** to **React 19**.
10
+ Projects using this plugin must update to React 19 before upgrading to v3.
11
+
6
12
  ## What is it?
7
13
 
8
- A Sanity Studio v3 plugin that extends media handling capabilities with custom enhancements, based on a fork of an original plugin by Sanity.io.
14
+ A Sanity Studio v4 plugin that extends media handling capabilities with custom enhancements, based on a fork of an original plugin by Sanity.io.
9
15
 
10
16
  A convenient way to browse, manage and refine your [Sanity](https://www.sanity.io/) assets.
11
17
 
@@ -52,7 +58,7 @@ _Asset details tab_ | _Asset alt texts tab_
52
58
  - Define a list of available languages to enable multi-language alt texts for assets.
53
59
  - See example of how to enable this feature [here](###plugin-config).
54
60
 
55
- ## Install (Sanity Studio v3)
61
+ ## Install (Sanity Studio v4)
56
62
 
57
63
  In your Sanity project folder:
58
64
 
@@ -146,27 +152,39 @@ export default defineConfig({
146
152
 
147
153
  ### Test your plugin locally
148
154
 
149
- In the plugin directory run this command:
155
+ **Step 1: Set up the plugin for local development**
156
+
157
+ In the plugin directory, run:
150
158
  ```zsh
151
159
  npm run link-watch
152
160
  ```
153
161
 
154
- This will set up your plugin to build whenever the code changes, and publish the package to a local yalc repository.
162
+ This will:
163
+ - Build your plugin automatically whenever code changes
164
+ - Publish the package to a local yalc repository
155
165
 
156
- Run the command in the studio project directory:
166
+ **Step 2: Link the plugin to your studio**
157
167
 
168
+ In your studio project directory, run:
158
169
  ```zsh
159
- npx yalc add @electrolux-oss/sanity-plugin-media && npx yalc link @electrolux-oss/sanity-plugin-media && npm install
170
+ npx yalc add @electrolux-oss/sanity-plugin-media && npm install
160
171
  ```
161
172
 
162
- You should see something like this in the `package.json` file:
173
+ **Step 3: Verify the setup**
163
174
 
175
+ Check your studio's `package.json` - you should see:
176
+ ```json
177
+ "@electrolux-oss/sanity-plugin-media": "file:.yalc/@electrolux-oss/sanity-plugin-media"
164
178
  ```
165
- "@electrolux-oss/sanity-plugin-media": "file:.yalc/@electrolux-oss/sanity-plugin-media",
179
+
180
+ Now you can use the local version of the plugin:
181
+ ```typescript
182
+ import { workflow } from '@electrolux-oss/sanity-plugin-media'
166
183
  ```
167
184
 
168
- Which means you can safely use the local version of the plugin with this import:
185
+ ### Making changes
169
186
 
170
- ```
171
- import { media } from '@electrolux-oss/sanity-plugin-media'
172
- ```
187
+ When you modify the plugin code:
188
+ 1. The `link-watch` command will automatically rebuild
189
+ 2. In your studio, run `npx yalc update` to pull the latest changes
190
+ 3. Restart your dev server: `npm run dev`
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AssetSourceComponentProps } from 'sanity'
2
2
  import { ForwardRefExoticComponent } from 'react'
3
- import { JSX as JSX_2 } from 'react'
3
+ import { JSX } from 'react'
4
4
  import { Plugin as Plugin_2 } from 'sanity'
5
5
  import { RefAttributes } from 'react'
6
6
  import { SVGProps } from 'react'
@@ -8,7 +8,7 @@ import { SVGProps } from 'react'
8
8
  export declare const media: Plugin_2<void | MediaToolOptions>
9
9
 
10
10
  export declare const mediaAssetSource: {
11
- component: (props: AssetSourceComponentProps) => JSX_2.Element
11
+ component: (props: AssetSourceComponentProps) => JSX.Element
12
12
  icon: ForwardRefExoticComponent<
13
13
  Omit<SVGProps<SVGSVGElement>, 'ref'> & RefAttributes<SVGSVGElement>
14
14
  >
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AssetSourceComponentProps } from 'sanity'
2
2
  import { ForwardRefExoticComponent } from 'react'
3
- import { JSX as JSX_2 } from 'react'
3
+ import { JSX } from 'react'
4
4
  import { Plugin as Plugin_2 } from 'sanity'
5
5
  import { RefAttributes } from 'react'
6
6
  import { SVGProps } from 'react'
@@ -8,7 +8,7 @@ import { SVGProps } from 'react'
8
8
  export declare const media: Plugin_2<void | MediaToolOptions>
9
9
 
10
10
  export declare const mediaAssetSource: {
11
- component: (props: AssetSourceComponentProps) => JSX_2.Element
11
+ component: (props: AssetSourceComponentProps) => JSX.Element
12
12
  icon: ForwardRefExoticComponent<
13
13
  Omit<SVGProps<SVGSVGElement>, 'ref'> & RefAttributes<SVGSVGElement>
14
14
  >
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), icons = require("@sanity/icons"), react = require("react"), ui = require("@sanity/ui"), groq = require("groq"), reactRedux = require("react-redux"), nanoid = require("nanoid"), reduxObservable = require("redux-observable"), rxjs = require("rxjs"), operators$1 = require("rxjs/operators"), toolkit = require("@reduxjs/toolkit"), uuid = require("@sanity/uuid"), styledComponents = require("styled-components"), pluralize = require("pluralize"), reactNprogress = require("@tanem/react-nprogress"), color = require("@sanity/color"), Select = require("react-select"), reactVirtuoso = require("react-virtuoso"), reactHookForm = require("react-hook-form"), zod = require("@hookform/resolvers/zod"), z = require("zod"), format = require("date-fns/format"), filesize = require("filesize"), copy = require("copy-to-clipboard"), router = require("sanity/router"), reactFileIcon = require("react-file-icon"), CreatableSelect = require("react-select/creatable"), formatRelative = require("date-fns/formatRelative"), reactDropzone = require("react-dropzone");
3
+ var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), icons = require("@sanity/icons"), react = require("react"), ui = require("@sanity/ui"), groq = require("groq"), reactRedux = require("react-redux"), nanoid = require("nanoid"), reduxObservable = require("redux-observable"), rxjs = require("rxjs"), operators$1 = require("rxjs/operators"), toolkit = require("@reduxjs/toolkit"), uuid = require("@sanity/uuid"), styledComponents = require("styled-components"), pluralize = require("pluralize"), reactNprogress = require("@tanem/react-nprogress"), color = require("@sanity/color"), Select = require("react-select"), reactVirtuoso = require("react-virtuoso"), reactHookForm = require("react-hook-form"), zod = require("@hookform/resolvers/zod"), z = require("zod"), dateFns = require("date-fns"), filesize = require("filesize"), copy = require("copy-to-clipboard"), router = require("sanity/router"), reactFileIcon = require("react-file-icon"), CreatableSelect = require("react-select/creatable"), reactDropzone = require("react-dropzone");
4
4
  function _interopDefaultCompat(e) {
5
5
  return e && typeof e == "object" && "default" in e ? e : { default: e };
6
6
  }
@@ -19,7 +19,7 @@ function _interopNamespaceCompat(e) {
19
19
  }
20
20
  }), n.default = e, Object.freeze(n);
21
21
  }
22
- var groq__default = /* @__PURE__ */ _interopDefaultCompat(groq), pluralize__default = /* @__PURE__ */ _interopDefaultCompat(pluralize), Select__default = /* @__PURE__ */ _interopDefaultCompat(Select), z__namespace = /* @__PURE__ */ _interopNamespaceCompat(z), format__default = /* @__PURE__ */ _interopDefaultCompat(format), filesize__default = /* @__PURE__ */ _interopDefaultCompat(filesize), copy__default = /* @__PURE__ */ _interopDefaultCompat(copy), CreatableSelect__default = /* @__PURE__ */ _interopDefaultCompat(CreatableSelect), formatRelative__default = /* @__PURE__ */ _interopDefaultCompat(formatRelative);
22
+ var groq__default = /* @__PURE__ */ _interopDefaultCompat(groq), pluralize__default = /* @__PURE__ */ _interopDefaultCompat(pluralize), Select__default = /* @__PURE__ */ _interopDefaultCompat(Select), z__namespace = /* @__PURE__ */ _interopNamespaceCompat(z), filesize__default = /* @__PURE__ */ _interopDefaultCompat(filesize), copy__default = /* @__PURE__ */ _interopDefaultCompat(copy), CreatableSelect__default = /* @__PURE__ */ _interopDefaultCompat(CreatableSelect);
23
23
  function getDefaultExportFromCjs(x) {
24
24
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
25
25
  }
@@ -2788,7 +2788,7 @@ const imageDprUrl = (asset, options) => {
2788
2788
  Row,
2789
2789
  {
2790
2790
  label: "Original date",
2791
- value: format__default.default(new Date(exif.DateTimeOriginal), "PPp")
2791
+ value: dateFns.format(new Date(exif.DateTimeOriginal), "PPp")
2792
2792
  }
2793
2793
  )
2794
2794
  ] }) })
@@ -3079,7 +3079,7 @@ const imageDprUrl = (asset, options) => {
3079
3079
  "Last updated",
3080
3080
  /* @__PURE__ */ jsxRuntime.jsx("br", {}),
3081
3081
  " ",
3082
- format__default.default(new Date(lastUpdated), "PPp")
3082
+ dateFns.format(new Date(lastUpdated), "PPp")
3083
3083
  ] }) : content = "No unpublished changes" : content = "There are validation errors that need to be fixed before this document can be published", /* @__PURE__ */ jsxRuntime.jsx(
3084
3084
  ui.Tooltip,
3085
3085
  {
@@ -4045,7 +4045,7 @@ const imageDprUrl = (asset, options) => {
4045
4045
  `
4046
4046
  ), StyledWarningOutlineIcon = styledComponents.styled(icons.WarningFilledIcon)(({ theme }) => ({
4047
4047
  color: theme.sanity.color.spot.red
4048
- })), CardAsset = (props) => {
4048
+ })), CardAsset$1 = (props) => {
4049
4049
  const { id, selected } = props, scheme = sanity.useColorSchemeValue(), shiftPressed = useKeyPress("shift"), dispatch = reactRedux.useDispatch(), lastPicked = useTypedSelector((state) => state.assets.lastPicked), item = useTypedSelector((state) => selectAssetById(state, id)), asset = item?.asset, error = item?.error, isOpaque = item?.asset?.metadata?.isOpaque, picked = item?.picked, updating = item?.updating, { onSelect } = useAssetSourceActions();
4050
4050
  if (!asset)
4051
4051
  return null;
@@ -4175,7 +4175,7 @@ const imageDprUrl = (asset, options) => {
4175
4175
  )
4176
4176
  ] }) });
4177
4177
  };
4178
- var CardAsset$1 = react.memo(CardAsset);
4178
+ var CardAsset = react.memo(CardAsset$1);
4179
4179
  const PREVIEW_WIDTH = 180, createBlob = (img) => new Promise((resolve) => {
4180
4180
  const imageAspect = img.width / img.height, canvas = document.createElement("canvas");
4181
4181
  canvas.width = PREVIEW_WIDTH, canvas.height = Math.max(PREVIEW_WIDTH / imageAspect, 1);
@@ -4532,7 +4532,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
4532
4532
  }
4533
4533
  ) });
4534
4534
  }, CARD_HEIGHT = 220, CARD_WIDTH = 240, VirtualCell = react.memo(
4535
- ({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsxRuntime.jsx(CardAsset$1, { id: item.id, selected }) : item?.type === "upload" ? /* @__PURE__ */ jsxRuntime.jsx(CardUpload, { id: item.id }) : null
4535
+ ({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsxRuntime.jsx(CardAsset, { id: item.id, selected }) : item?.type === "upload" ? /* @__PURE__ */ jsxRuntime.jsx(CardUpload, { id: item.id }) : null
4536
4536
  ), StyledItemContainer = styledComponents.styled.div`
4537
4537
  height: ${CARD_HEIGHT}px;
4538
4538
  width: ${CARD_WIDTH}px;
@@ -4697,7 +4697,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
4697
4697
  `
4698
4698
  ), StyledWarningIcon = styledComponents.styled(icons.WarningFilledIcon)(({ theme }) => ({
4699
4699
  color: theme.sanity.color.spot.red
4700
- })), TableRowAsset = (props) => {
4700
+ })), TableRowAsset$1 = (props) => {
4701
4701
  const { id, selected } = props, scheme = sanity.useColorSchemeValue(), shiftPressed = useKeyPress("shift"), [referenceCountVisible, setReferenceCountVisible] = react.useState(!1), refCountVisibleTimeout = react.useRef(null), dispatch = reactRedux.useDispatch(), lastPicked = useTypedSelector((state) => state.assets.lastPicked), item = useTypedSelector((state) => selectAssetById(state, id)), mediaIndex = ui.useMediaIndex(), asset = item?.asset, error = item?.error, isOpaque = item?.asset?.metadata?.isOpaque, picked = item?.picked, updating = item?.updating, { onSelect } = useAssetSourceActions(), handleContextActionClick = react.useCallback(
4702
4702
  (e) => {
4703
4703
  e.stopPropagation(), asset && (onSelect ? dispatch(dialogActions.showAssetEdit({ assetId: asset._id })) : shiftPressed.current && !picked ? dispatch(assetsActions.pickRange({ startId: lastPicked || asset._id, endId: asset._id })) : dispatch(assetsActions.pick({ assetId: asset._id, picked: !picked })));
@@ -4878,7 +4878,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
4878
4878
  gridRow: mediaIndex < 3 ? 4 : "auto",
4879
4879
  opacity: opacityCell
4880
4880
  },
4881
- children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, style: { lineHeight: "2em" }, textOverflow: "ellipsis", children: formatRelative__default.default(new Date(asset._updatedAt), /* @__PURE__ */ new Date()) })
4881
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, style: { lineHeight: "2em" }, textOverflow: "ellipsis", children: dateFns.formatRelative(new Date(asset._updatedAt), /* @__PURE__ */ new Date()) })
4882
4882
  }
4883
4883
  ),
4884
4884
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -4923,7 +4923,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
4923
4923
  }
4924
4924
  ) : null;
4925
4925
  };
4926
- var TableRowAsset$1 = react.memo(TableRowAsset);
4926
+ var TableRowAsset = react.memo(TableRowAsset$1);
4927
4927
  const TableRowUpload = (props) => {
4928
4928
  const { id } = props, scheme = sanity.useColorSchemeValue(), dispatch = reactRedux.useDispatch(), item = useTypedSelector((state) => selectUploadById(state, id)), mediaIndex = ui.useMediaIndex();
4929
4929
  if (!item)
@@ -5037,7 +5037,7 @@ const TableRowUpload = (props) => {
5037
5037
  }
5038
5038
  );
5039
5039
  }, VirtualRow = react.memo(
5040
- ({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsxRuntime.jsx(TableRowAsset$1, { id: item.id, selected }) }) : item?.type === "upload" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsxRuntime.jsx(TableRowUpload, { id: item.id }) }) : null
5040
+ ({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsxRuntime.jsx(TableRowAsset, { id: item.id, selected }) }) : item?.type === "upload" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsxRuntime.jsx(TableRowUpload, { id: item.id }) }) : null
5041
5041
  ), AssetTableVirtualized = (props) => {
5042
5042
  const { items, onLoadMore } = props, selectedAssets = useTypedSelector((state) => state.selected.assets), selectedIds = selectedAssets && selectedAssets.map((asset) => asset._id) || [], totalCount = items?.length;
5043
5043
  return totalCount === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(