AcadeDoc/apps/client/src/features/editor/components/video/video-view.tsx
Philipinho 1f4bd129a8 editor improvements
* add callout, youtube embed, image, video, table, detail, math
* fix attachments module
* other fixes
2024-06-20 14:57:00 +01:00

32 lines
837 B
TypeScript

import { NodeViewProps, NodeViewWrapper } from "@tiptap/react";
import { useMemo } from "react";
import { getBackendUrl } from "@/lib/config.ts";
export default function VideoView(props: NodeViewProps) {
const { node, selected } = props;
const { src, width, align } = node.attrs;
const flexJustifyContent = useMemo(() => {
if (align === "center") return "center";
if (align === "right") return "flex-end";
return "flex-start";
}, [align]);
return (
<NodeViewWrapper
style={{
position: "relative",
display: "flex",
justifyContent: flexJustifyContent,
}}
>
<video
preload="metadata"
width={width}
controls
src={getBackendUrl() + src}
className={selected && "ProseMirror-selectednode"}
/>
</NodeViewWrapper>
);
}