返回 presentation-ai
media-video-node-static.tsx
根目录 / src / components / plate / ui / media-video-node-static.tsx
1 import {
2 NodeApi,
3 type TCaptionElement,
4 type TResizableProps,
5 type TVideoElement,
6 } from "platejs";
7 import { SlateElement, type SlateElementProps } from "platejs/static";
8
9 export function VideoElementStatic(
10 props: SlateElementProps<TVideoElement & TCaptionElement & TResizableProps>,
11 ) {
12 const { align = "center", caption, url, width } = props.element;
13
14 return (
15 <SlateElement className="py-2.5" {...props}>
16 <div style={{ textAlign: align }}>
17 <figure
18 className="group relative m-0 inline-block cursor-default"
19 style={{ width }}
20 >
21 <video
22 aria-label="media video node static control"
23 className="w-full max-w-full rounded-sm object-cover px-0"
24 src={url}
25 controls
26 >
27 <track kind="captions" src="data:text/vtt,WEBVTT%0A" />
28 </video>
29 {caption && <figcaption>{NodeApi.string(caption[0]!)}</figcaption>}
30 </figure>
31 </div>
32 {props.children}
33 </SlateElement>
34 );
35 }
36
36 lines Plain Text