From e1054363f2361b226f705ccc60597e02b7043af3 Mon Sep 17 00:00:00 2001 From: jimmylee Date: Wed, 16 Sep 2020 02:16:46 -0700 Subject: [PATCH] validations: expanded --- common/validations.js | 8 +++++--- components/core/SlateMediaObject.js | 27 +++++++++++++-------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/common/validations.js b/common/validations.js index caf6a59f..91759284 100644 --- a/common/validations.js +++ b/common/validations.js @@ -100,19 +100,21 @@ export const password = (text) => { }; export const isFileTypeAllowed = (type = "") => { + console.log({ type }); + if (type.startsWith("text/")) { return true; } - if (type.startsWith("application/font-woff")) { + if (type.startsWith("model/")) { return true; } - if (type.startsWith("application/pdf")) { + if (type.startsWith("font/")) { return true; } - if (type.startsWith("application/epub")) { + if (type.startsWith("application/")) { return true; } diff --git a/components/core/SlateMediaObject.js b/components/core/SlateMediaObject.js index 9bca790a..4ee634b5 100644 --- a/components/core/SlateMediaObject.js +++ b/components/core/SlateMediaObject.js @@ -48,6 +48,10 @@ const STYLES_IMAGE = css` max-height: 100%; `; +const typeMap = { + "video/quicktime": "video/mp4", +}; + export default class SlateMediaObject extends React.Component { render() { const name = `${this.props.data.name}`; @@ -55,45 +59,40 @@ export default class SlateMediaObject extends React.Component { // This is a hack to catch this undefined case I don't want to track down yet. const url = this.props.data.url.replace("https://undefined", "https://"); const type = this.props.data.type ? this.props.data.type : "LEGACY_NO_TYPE"; + const playType = typeMap[type] ? typeMap[type] : type; let element =
No Preview
; if (type.startsWith("application/pdf")) { - element = ; + return ; } if (type.startsWith("video/")) { - let videoType = type; - if (videoType === "video/quicktime") { - videoType = "video/mp4"; - } - - element = ( + return ( ); } if (type.startsWith("audio/")) { - element = ( + return (
); } if (type.startsWith("image/")) { - element = ( + return (