import { NodeViewWrapper } from "@tiptap/react"; import { AlertTriangle, Image, Loader, Video } from "lucide-react"; import React, { useEffect } from "react"; import styled from "styled-components"; import { getBackendUrl } from "../../../../../services/config/config"; import { uploadNewVideoFile } from "../../../../../services/blocks/Video/video"; import { getActivityBlockMediaDirectory } from "@services/media/media"; import { UploadIcon } from "@radix-ui/react-icons"; import { useOrg } from "@components/Contexts/OrgContext"; import { useCourse } from "@components/Contexts/CourseContext"; function VideoBlockComponents(props: any) { const org = useOrg() as any; const course = useCourse() as any; const [video, setVideo] = React.useState(null); const [isLoading, setIsLoading] = React.useState(false); const [blockObject, setblockObject] = React.useState(props.node.attrs.blockObject); const fileId = blockObject ? `${blockObject.content.file_id}.${blockObject.content.file_format}` : null; const handleVideoChange = (event: React.ChangeEvent) => { setVideo(event.target.files[0]); }; const handleSubmit = async (e: any) => { e.preventDefault(); setIsLoading(true); let object = await uploadNewVideoFile(video, props.extension.options.activity.activity_uuid); setIsLoading(false); setblockObject(object); props.updateAttributes({ blockObject: object, }); }; useEffect(() => { } , [course, org]); return ( {!blockObject && ( {isLoading ? ( ) : ( <>
)}
)} {blockObject && ( )}
); } const BlockVideoWrapper = styled.div` //border: ${(props) => (props.contentEditable ? "2px dashed #713f1117" : "none")}; // center align-items: center; justify-content: center; text-align: center; font-size: 14px; `; const BlockVideo = styled.div` display: flex; flex-direction: column; `; export default VideoBlockComponents;