返回 presentation-ai
media-audio-node.tsx
根目录 / src / components / plate / ui / media-audio-node.tsx
1 "use client";
2
3 import { useMediaState } from "@platejs/media/react";
4 import { ResizableProvider } from "@platejs/resizable";
5 import { type TAudioElement } from "platejs";
6 import { PlateElement, withHOC, type PlateElementProps } from "platejs/react";
7
8 import { Caption, CaptionTextarea } from "./caption";
9
10 export const AudioElement = withHOC(
11 ResizableProvider,
12 function AudioElement(props: PlateElementProps<TAudioElement>) {
13 const { align = "center", readOnly, unsafeUrl } = useMediaState();
14
15 return (
16 <PlateElement {...props} className="mb-1">
17 <figure
18 className="group relative cursor-default"
19 contentEditable={false}
20 >
21 <div className="h-16">
22 <audio
23 aria-label="media audio node control"
24 className="size-full"
25 src={unsafeUrl}
26 controls
27 >
28 <track kind="captions" src="data:text/vtt,WEBVTT%0A" />
29 </audio>
30 </div>
31
32 <Caption style={{ width: "100%" }} align={align}>
33 <CaptionTextarea
34 className="h-20"
35 readOnly={readOnly}
36 placeholder="Write a caption..."
37 />
38 </Caption>
39 </figure>
40 {props.children}
41 </PlateElement>
42 );
43 },
44 );
45
45 lines Plain Text