2020-08-09 01:19:35 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as Constants from "~/common/constants";
|
|
|
|
|
|
|
|
import { css } from "@emotion/react";
|
|
|
|
|
|
|
|
const STYLES_IMAGE = css`
|
|
|
|
display: block;
|
|
|
|
max-width: 100%;
|
|
|
|
max-height: 100%;
|
2020-08-22 20:30:03 +03:00
|
|
|
pointer-events: none;
|
2020-08-09 01:19:35 +03:00
|
|
|
`;
|
|
|
|
|
2020-08-22 12:32:40 +03:00
|
|
|
const STYLES_ENTITY = css`
|
2020-08-09 01:19:35 +03:00
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
border: 1px solid ${Constants.system.border};
|
2020-08-22 12:32:40 +03:00
|
|
|
background-color: ${Constants.system.foreground};
|
2020-08-09 01:19:35 +03:00
|
|
|
font-size: 24px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
cursor: pointer;
|
2020-08-22 20:30:03 +03:00
|
|
|
pointer-events: none;
|
2020-08-09 01:19:35 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
export default class SlateMediaObjectPreview extends React.Component {
|
|
|
|
render() {
|
2020-08-22 20:30:03 +03:00
|
|
|
let element = <div css={STYLES_ENTITY}>No Preview</div>;
|
2020-08-22 12:32:40 +03:00
|
|
|
|
2020-08-09 01:19:35 +03:00
|
|
|
if (this.props.type && this.props.type.startsWith("video/")) {
|
2020-08-22 20:30:03 +03:00
|
|
|
element = <div css={STYLES_ENTITY}>Video</div>;
|
2020-08-09 01:19:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.props.type && this.props.type.startsWith("audio/")) {
|
2020-08-22 20:30:03 +03:00
|
|
|
element = <div css={STYLES_ENTITY}>Audio</div>;
|
2020-08-09 01:19:35 +03:00
|
|
|
}
|
|
|
|
|
2020-08-10 13:10:44 +03:00
|
|
|
if (this.props.type && this.props.type.startsWith("application/epub")) {
|
2020-08-22 20:30:03 +03:00
|
|
|
element = <div css={STYLES_ENTITY}>EPub</div>;
|
2020-08-10 13:10:44 +03:00
|
|
|
}
|
|
|
|
|
2020-08-09 01:19:35 +03:00
|
|
|
if (this.props.type && this.props.type.startsWith("application/pdf")) {
|
2020-08-22 20:30:03 +03:00
|
|
|
element = <div css={STYLES_ENTITY}>PDF</div>;
|
2020-08-22 12:32:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.props.type && this.props.type.startsWith("image/")) {
|
2020-08-22 20:30:03 +03:00
|
|
|
element = <img css={STYLES_IMAGE} src={this.props.url} />;
|
2020-08-09 01:19:35 +03:00
|
|
|
}
|
|
|
|
|
2020-08-22 20:30:03 +03:00
|
|
|
return element;
|
2020-08-09 01:19:35 +03:00
|
|
|
}
|
|
|
|
}
|