gcg-website/static/admin/shortcodes/youtube.js

64 lines
1.2 KiB
JavaScript
Raw Normal View History

import { Card, TextField } from "./components/index.js";
const YoutubeShortcode = {
2023-05-29 16:22:34 +02:00
label: "YouTube-Video",
openTag: "{{< ",
closeTag: " >}}",
separator: " ",
toProps: (args) => {
if (args.length > 0) {
return { src: args[0] };
}
2023-05-29 16:22:34 +02:00
return { src: "" };
},
toArgs: ({ src }) => {
return [src];
},
control: ({ src, onChange }) => {
return Card(
[
TextField({
label: "YouTube-Video-ID",
value: src,
onChange: (event) => {
onChange({ src: event.target.value });
},
}),
h(
"iframe",
{
width: "100%",
height: "360",
src: `https://piped.kavin.rocks/embed/${src}`,
2023-09-30 21:15:23 +02:00
style: {
paddingLeft: "0.75rem",
paddingRight: "0.75rem",
paddingTop: "0.75rem",
},
2023-05-29 16:22:34 +02:00
},
""
),
],
{ vertical: true }
);
},
preview: ({ src }) => {
return h(
"span",
{},
h(
"iframe",
{
width: "420",
height: "315",
src: `https://piped.kavin.rocks/embed/${src}`,
},
""
)
);
},
};
export default YoutubeShortcode;