sanity-plugin-media 4.1.0 → 4.1.1
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/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/components/ReduxProvider/index.tsx +2 -1
- package/src/constants.ts +6 -0
- package/src/types/index.ts +3 -0
- package/src/utils/isSupportedAssetType.ts +15 -0
package/dist/index.js
CHANGED
|
@@ -467,7 +467,10 @@ const useKeyPress = (hotkey, onPress) => {
|
|
|
467
467
|
fn: (value, _field) => value ? `references('${value}')` : void 0,
|
|
468
468
|
label: "includes"
|
|
469
469
|
}
|
|
470
|
-
},
|
|
470
|
+
}, SUPPORTED_ASSET_TYPES = [
|
|
471
|
+
"file",
|
|
472
|
+
"image"
|
|
473
|
+
], ORDER_OPTIONS = [
|
|
471
474
|
{
|
|
472
475
|
direction: "desc",
|
|
473
476
|
field: "_createdAt"
|
|
@@ -4009,7 +4012,7 @@ const DialogAssetEdit = (props) => {
|
|
|
4009
4012
|
`
|
|
4010
4013
|
), StyledWarningOutlineIcon = styledComponents.styled(icons.WarningFilledIcon)(({ theme }) => ({
|
|
4011
4014
|
color: theme.sanity.color.spot.red
|
|
4012
|
-
})), CardAsset = (props) => {
|
|
4015
|
+
})), CardAsset$1 = (props) => {
|
|
4013
4016
|
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();
|
|
4014
4017
|
if (!asset)
|
|
4015
4018
|
return null;
|
|
@@ -4139,7 +4142,7 @@ const DialogAssetEdit = (props) => {
|
|
|
4139
4142
|
)
|
|
4140
4143
|
] }) });
|
|
4141
4144
|
};
|
|
4142
|
-
var CardAsset
|
|
4145
|
+
var CardAsset = react.memo(CardAsset$1);
|
|
4143
4146
|
const PREVIEW_WIDTH = 180, createBlob = (img) => new Promise((resolve) => {
|
|
4144
4147
|
const imageAspect = img.width / img.height, canvas = document.createElement("canvas");
|
|
4145
4148
|
canvas.width = PREVIEW_WIDTH, canvas.height = Math.max(PREVIEW_WIDTH / imageAspect, 1);
|
|
@@ -4496,7 +4499,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
|
|
|
4496
4499
|
}
|
|
4497
4500
|
) });
|
|
4498
4501
|
}, CARD_HEIGHT = 220, CARD_WIDTH = 240, VirtualCell = react.memo(
|
|
4499
|
-
({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsxRuntime.jsx(CardAsset
|
|
4502
|
+
({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsxRuntime.jsx(CardAsset, { id: item.id, selected }) : item?.type === "upload" ? /* @__PURE__ */ jsxRuntime.jsx(CardUpload, { id: item.id }) : null
|
|
4500
4503
|
), StyledItemContainer = styledComponents.styled.div`
|
|
4501
4504
|
height: ${CARD_HEIGHT}px;
|
|
4502
4505
|
width: ${CARD_WIDTH}px;
|
|
@@ -4661,7 +4664,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
|
|
|
4661
4664
|
`
|
|
4662
4665
|
), StyledWarningIcon = styledComponents.styled(icons.WarningFilledIcon)(({ theme }) => ({
|
|
4663
4666
|
color: theme.sanity.color.spot.red
|
|
4664
|
-
})), TableRowAsset = (props) => {
|
|
4667
|
+
})), TableRowAsset$1 = (props) => {
|
|
4665
4668
|
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(
|
|
4666
4669
|
(e) => {
|
|
4667
4670
|
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 })));
|
|
@@ -4887,7 +4890,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
|
|
|
4887
4890
|
}
|
|
4888
4891
|
) : null;
|
|
4889
4892
|
};
|
|
4890
|
-
var TableRowAsset
|
|
4893
|
+
var TableRowAsset = react.memo(TableRowAsset$1);
|
|
4891
4894
|
const TableRowUpload = (props) => {
|
|
4892
4895
|
const { id } = props, scheme = sanity.useColorSchemeValue(), dispatch = reactRedux.useDispatch(), item = useTypedSelector((state) => selectUploadById(state, id)), mediaIndex = ui.useMediaIndex();
|
|
4893
4896
|
if (!item)
|
|
@@ -5001,7 +5004,7 @@ const TableRowUpload = (props) => {
|
|
|
5001
5004
|
}
|
|
5002
5005
|
);
|
|
5003
5006
|
}, VirtualRow = react.memo(
|
|
5004
|
-
({ item, selected }) => item?.type === "asset" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: "100px" }, children: /* @__PURE__ */ jsxRuntime.jsx(TableRowAsset
|
|
5007
|
+
({ 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
|
|
5005
5008
|
), AssetTableVirtualized = (props) => {
|
|
5006
5009
|
const { items, onLoadMore } = props, selectedAssets = useTypedSelector((state) => state.selected.assets), selectedIds = selectedAssets && selectedAssets.map((asset) => asset._id) || [], totalCount = items?.length;
|
|
5007
5010
|
return totalCount === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5264,6 +5267,9 @@ const rootEpic = reduxObservable.combineEpics(
|
|
|
5264
5267
|
const assetIds = getAssetIds(document2);
|
|
5265
5268
|
return [...new Set(assetIds.sort())];
|
|
5266
5269
|
};
|
|
5270
|
+
function isSupportedAssetType(assetType) {
|
|
5271
|
+
return assetType ? SUPPORTED_ASSET_TYPES.includes(assetType) : !1;
|
|
5272
|
+
}
|
|
5267
5273
|
class ReduxProvider extends react.Component {
|
|
5268
5274
|
store;
|
|
5269
5275
|
constructor(props) {
|
|
@@ -5294,7 +5300,7 @@ class ReduxProvider extends react.Component {
|
|
|
5294
5300
|
preloadedState: {
|
|
5295
5301
|
assets: {
|
|
5296
5302
|
...initialState$5,
|
|
5297
|
-
assetTypes: props?.assetType ? [props.assetType] : ["file", "image"]
|
|
5303
|
+
assetTypes: isSupportedAssetType(props?.assetType) ? [props.assetType] : ["file", "image"]
|
|
5298
5304
|
},
|
|
5299
5305
|
debug: {
|
|
5300
5306
|
badConnection: !1,
|