sanity-plugin-mux-input
4.1.74.1.8
dist/index.js~
dist/index.jsModified+35−24
Index: package/dist/index.js
===================================================================
--- package/dist/index.js
+++ package/dist/index.js
@@ -341,9 +341,9 @@
}
function useDialogState() {
return useState(!1);
}
-const PLUGIN_VERSION_QUERY = { sanityVersion: "4.1.7" };
+const PLUGIN_VERSION_QUERY = { sanityVersion: "4.1.8" };
function saveSecrets(client, token, secretKey, enableSignedUrls, signingKeyId, signingKeyPrivate, drmConfigId) {
let doc = {
_id: "secrets.mux",
_type: "mux.apiKey",
@@ -883,9 +883,9 @@
* @param assetId - The Mux asset ID to check against
* @returns true if the filename is empty or matches the placeholder format
*/
function isEmptyOrPlaceholderTitle(filename, assetId) {
- return !filename || filename.trim() === "" ? !0 : filename === generateAssetPlaceholder(assetId);
+ return !filename || filename.trim() === "" || filename === generateAssetPlaceholder(assetId);
}
function parseMuxDate(date) {
return /* @__PURE__ */ new Date(Number(date) * 1e3);
}
@@ -1111,9 +1111,9 @@
};
}
const useAssetsInSanity = createHookFromObservableFactory((documentStore) => documentStore.listenQuery("*[_type == \"mux.videoAsset\"] {\n \"uploadId\": coalesce(uploadId, data.upload_id),\n \"assetId\": coalesce(assetId, data.id),\n }", {}, { apiVersion: SANITY_API_VERSION }));
function assetExistsInSanity(asset, existingAssets) {
- return asset.status === "ready" ? existingAssets.some((existing) => existing.assetId === asset.id || existing.uploadId === asset.upload_id) : !1;
+ return asset.status === "ready" && existingAssets.some((existing) => existing.assetId === asset.id || existing.uploadId === asset.upload_id);
}
function useInView(ref, options = {}) {
let [inView, setInView] = useState(!1);
return useEffect(() => {
@@ -3715,9 +3715,13 @@
value: timeFormatted,
placeholder: "hh:mm:ss",
onChange: (event) => {
let value = event.currentTarget.value;
- setTimeFormatted(value), isValidTimeFormat(value) ? (setInputError(""), setNextTime(getSecondsFromTimeFormat(value))) : setInputError("Invalid time format");
+ if (setTimeFormatted(value), isValidTimeFormat(value)) {
+ setInputError("");
+ let totalSeconds = getSecondsFromTimeFormat(value);
+ setNextTime(totalSeconds);
+ } else setInputError("Invalid time format");
},
customValidity: inputError
})]
})
@@ -3860,9 +3864,9 @@
preload: "metadata",
crossOrigin: "anonymous",
metadata: {
player_name: "Sanity Admin Dashboard",
- player_version: "4.1.7",
+ player_version: "4.1.8",
page_type: "Preview Player"
},
audio: isAudio,
_hlsConfig: hlsConfig,
@@ -4035,9 +4039,20 @@
displayName: "Container",
componentId: "sc-tqydu5-0"
})`*{color:${(props) => props.theme.sanity.color.base.fg};}a{text-decoration:none;}h2{font-size:${(props) => props.theme.sanity.fonts.text.sizes[1]};}`, VideoReferences = (props) => {
let schema = useSchema();
- return props.isLoaded ? props.references?.length ? /* @__PURE__ */ jsx(Container, { children: collate(props.references || [])?.map((documentPair) => /* @__PURE__ */ jsx(Card, {
+ if (!props.isLoaded) return /* @__PURE__ */ jsx(SpinnerBox, {});
+ if (!props.references?.length) return /* @__PURE__ */ jsx(Card, {
+ border: !0,
+ radius: 3,
+ padding: 3,
+ children: /* @__PURE__ */ jsx(Text, {
+ size: 2,
+ children: "No documents are using this video"
+ })
+ });
+ let documentPairs = collate(props.references || []);
+ return /* @__PURE__ */ jsx(Container, { children: documentPairs?.map((documentPair) => /* @__PURE__ */ jsx(Card, {
marginBottom: 2,
padding: 2,
radius: 2,
shadow: 1,
@@ -4045,17 +4060,9 @@
children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(DocumentPreview, {
documentPair,
schemaType: schema.get(documentPair.type)
}) })
- }, documentPair.id)) }) : /* @__PURE__ */ jsx(Card, {
- border: !0,
- radius: 3,
- padding: 3,
- children: /* @__PURE__ */ jsx(Text, {
- size: 2,
- children: "No documents are using this video"
- })
- }) : /* @__PURE__ */ jsx(SpinnerBox, {});
+ }, documentPair.id)) });
};
function DeleteDialog({ asset, references, referencesLoading, cancelDelete, succeededDeleting }) {
let client = useClient$1(), [state, setState] = useState("checkingReferences"), [deleteOnMux, setDeleteOnMux] = useState(!0), toast = useToast();
useEffect(() => {
@@ -5348,13 +5355,14 @@
displayName: "StyledDialog",
componentId: "sc-z1aqru-0"
})`> div[data-ui='DialogCard'] > div[data-ui='Card']{height:100%;}`;
function InputBrowser({ setDialogState, asset, onChange, config }) {
+ let id = `InputBrowser${useId()}`, handleClose = useCallback(() => setDialogState(!1), [setDialogState]);
return /* @__PURE__ */ jsx(StyledDialog, {
__unstable_autoFocus: !0,
header: "Select video",
- id: `InputBrowser${useId()}`,
- onClose: useCallback(() => setDialogState(!1), [setDialogState]),
+ id,
+ onClose: handleClose,
width: 2,
children: /* @__PURE__ */ jsx(SelectAssets, {
config,
asset,
@@ -5996,9 +6004,10 @@
return;
}
setIsValidating(!0), setIsValid(null), setUrlError(null), validationTimeoutRef.current = setTimeout(() => {
try {
- if (isValidExtension(new URL(url).pathname.toLowerCase())) {
+ let pathname = new URL(url).pathname.toLowerCase();
+ if (isValidExtension(pathname)) {
setIsValid(!0), setUrlError(null), onValidationChange?.(null);
let img = new Image();
img.onload = () => {
let imageAspectRatio = img.naturalWidth && img.naturalHeight ? img.naturalWidth / img.naturalHeight : 1;
@@ -6263,12 +6272,14 @@
}), /* @__PURE__ */ jsx(Button, {
text: "Manual",
mode: mode === "manual" ? "default" : "ghost",
onClick: () => {
- setMode("manual"), updateOverlaySettings(convertWatermarkToMuxOverlay({
+ setMode("manual");
+ let overlay = convertWatermarkToMuxOverlay({
...watermark,
enabled: !0
- }) ?? {});
+ });
+ updateOverlaySettings(overlay ?? {});
}
})]
})]
})
@@ -7440,19 +7451,19 @@
});
}
const UploadCardWithFocusRing = withFocusRing(Card);
function UploadCard({ children, tone, onPaste, onDrop, onDragEnter, onDragLeave, onDragOver, ref }) {
- let inputRef = useRef(null);
+ let inputRef = useRef(null), handleKeyDown = useCallback((event) => {
+ event.target.closest("#vtt-url") || (event.ctrlKey || event.metaKey) && event.key === "v" && inputRef.current.focus();
+ }, []);
return /* @__PURE__ */ jsxs(UploadCardWithFocusRing, {
tone,
ref,
padding: 0,
radius: 2,
shadow: 0,
tabIndex: 0,
- onKeyDown: useCallback((event) => {
- event.target.closest("#vtt-url") || (event.ctrlKey || event.metaKey) && event.key === "v" && inputRef.current.focus();
- }, []),
+ onKeyDown: handleKeyDown,
onPaste,
onDrop,
onDragEnter,
onDragLeave,