mirror of
https://github.com/docmost/docmost.git
synced 2026-05-18 07:24:04 +08:00
30 lines
847 B
TypeScript
30 lines
847 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 data-drag-handle>
|
|
<video
|
|
preload="metadata"
|
|
width={width}
|
|
controls
|
|
src={getFileUrl(src)}
|
|
className={clsx(selected ? "ProseMirror-selectednode" : "", alignClass)}
|
|
style={{ display: "block" }}
|
|
/>
|
|
</NodeViewWrapper>
|
|
);
|
|
}
|