Added videos in Markdawn

This commit is contained in:
DrMint 2023-05-22 20:07:45 +02:00
parent ff89031123
commit 6093ef131a
3 changed files with 44 additions and 3 deletions

View File

@ -17,6 +17,8 @@ import { atoms } from "contexts/atoms";
import { useAtomGetter } from "helpers/atoms"; import { useAtomGetter } from "helpers/atoms";
import { Link } from "components/Inputs/Link"; import { Link } from "components/Inputs/Link";
import { useFormat } from "hooks/useFormat"; import { useFormat } from "hooks/useFormat";
import { VideoPlayer } from "components/Player";
import { getVideoFile } from "helpers/videos";
/* /*
* *
@ -144,6 +146,16 @@ export const Markdawn = ({ className, text: rawText }: MarkdawnProps): JSX.Eleme
}, },
}, },
Video: {
component: (comProps) => (
<VideoPlayer
src={getVideoFile(comProps.id)}
title={comProps.title}
className="my-8"
/>
),
},
InsetBox: { InsetBox: {
component: (compProps) => <InsetBox className="my-12">{compProps.children}</InsetBox>, component: (compProps) => <InsetBox className="my-12">{compProps.children}</InsetBox>,
}, },

View File

@ -251,14 +251,18 @@ const PlayerControls = ({
/> />
<div className="grid w-full place-items-start"> <div className="grid w-full place-items-start">
{isDefinedAndNotEmpty(title) && ( {isDefinedAndNotEmpty(title) && (
<p className="line-clamp-1 text-left text-xs text-dark">{title}</p> <p className="!my-0 line-clamp-1 text-left text-xs text-dark">{title}</p>
)} )}
<div <div
className={cJoin( className={cJoin(
"flex w-full place-content-between place-items-center", "flex w-full place-content-between place-items-center",
cIf(isContentPanelAtLeastMd, "gap-5", "gap-3") cIf(isContentPanelAtLeastMd, "gap-5", "gap-3")
)}> )}>
<p className={cJoin("font-mono", cIf(isContentPanelAtLeastMd, "h-5", "h-3 text-xs"))}> <p
className={cJoin(
"!my-0 font-mono",
cIf(isContentPanelAtLeastMd, "h-5", "h-3 text-xs")
)}>
{prettyDuration(currentTime)} {prettyDuration(currentTime)}
</p> </p>
<Slider <Slider
@ -276,7 +280,11 @@ const PlayerControls = ({
max={duration * STEP_MULTIPLIER} max={duration * STEP_MULTIPLIER}
/> />
{!isContentPanelAtLeastXl && type === "video" && <p>/</p>} {!isContentPanelAtLeastXl && type === "video" && <p>/</p>}
<p className={cJoin("font-mono", cIf(isContentPanelAtLeastMd, "h-5", "h-3 text-xs"))}> <p
className={cJoin(
"!my-0 font-mono",
cIf(isContentPanelAtLeastMd, "h-5", "h-3 text-xs")
)}>
{prettyDuration(duration)} {prettyDuration(duration)}
</p> </p>
</div> </div>

View File

@ -444,6 +444,27 @@ const Editor = (props: Props): JSX.Element => {
<Button icon="dashboard" /> <Button icon="dashboard" />
</ToolTip> </ToolTip>
<ToolTip
placement="bottom"
content={
<>
<h3 className="text-lg">Videos</h3>
<div className="grid gap-2">
<Button
onClick={() => insert(`<Video id="XXXXXXXXX" />`)}
icon="movie"
text="Video"
/>
<Button
onClick={() => insert(`<Video id="XXXXXXXXX" title="My Title" />`)}
icon="movie"
text="Video + title"
/>
</div>
</>
}>
<Button icon="movie" />
</ToolTip>
<ToolTip placement="bottom" content={<h3 className="text-lg">Scene break</h3>}> <ToolTip placement="bottom" content={<h3 className="text-lg">Scene break</h3>}>
<Button onClick={() => insert("\n* * *\n")} icon="more_horiz" /> <Button onClick={() => insert("\n* * *\n")} icon="more_horiz" />
</ToolTip> </ToolTip>