mirror of
https://github.com/docmost/docmost.git
synced 2026-06-11 10:46:54 +08:00
29 lines
793 B
TypeScript
29 lines
793 B
TypeScript
import { NodeViewProps, NodeViewWrapper } from "@tiptap/react";
|
|
import { useMemo } from "react";
|
|
import { getFileUrl } from "@/lib/config.ts";
|
|
import clsx from "clsx";
|
|
|
|
export default function VideoView(props: NodeViewProps) {
|
|
const { node, selected } = props;
|
|
const { src, width, align } = node.attrs;
|
|
|
|
const alignClass = useMemo(() => {
|
|
if (align === "left") return "alignLeft";
|
|
if (align === "right") return "alignRight";
|
|
if (align === "center") return "alignCenter";
|
|
return "alignCenter";
|
|
}, [align]);
|
|
|
|
return (
|
|
<NodeViewWrapper>
|
|
<video
|
|
preload="metadata"
|
|
width={width}
|
|
controls
|
|
src={getFileUrl(src)}
|
|
className={clsx(selected ? "ProseMirror-selectednode" : "", alignClass)}
|
|
/>
|
|
</NodeViewWrapper>
|
|
);
|
|
}
|