diff --git a/apps/web/components/Objects/Editor/Extensions/Image/ImageBlockComponent.tsx b/apps/web/components/Objects/Editor/Extensions/Image/ImageBlockComponent.tsx index 5227b95c..a622f6c5 100644 --- a/apps/web/components/Objects/Editor/Extensions/Image/ImageBlockComponent.tsx +++ b/apps/web/components/Objects/Editor/Extensions/Image/ImageBlockComponent.tsx @@ -1,7 +1,7 @@ import { NodeViewWrapper } from '@tiptap/react' import React, { useEffect } from 'react' import { Resizable } from 're-resizable' -import { AlertTriangle, Image, Download, AlignLeft, AlignCenter, AlignRight } from 'lucide-react' +import { AlertTriangle, Image, Download, AlignLeft, AlignCenter, AlignRight, Expand } from 'lucide-react' import { uploadNewImageFile } from '../../../../../services/blocks/Image/images' import { getActivityBlockMediaDirectory } from '@services/media/media' import { useOrg } from '@components/Contexts/OrgContext' @@ -10,6 +10,7 @@ import { useEditorProvider } from '@components/Contexts/Editor/EditorContext' import { useLHSession } from '@components/Contexts/LHSessionContext' import { FileUploadBlock, FileUploadBlockButton, FileUploadBlockInput } from '../../FileUploadBlock' import { constructAcceptValue } from '@/lib/constants'; +import Modal from '@components/Objects/StyledElements/Modal/Modal' const SUPPORTED_FILES = constructAcceptValue(['image']) @@ -30,6 +31,7 @@ function ImageBlockComponent(props: any) { width: props.node.attrs.size ? props.node.attrs.size.width : 300, }) const [alignment, setAlignment] = React.useState(props.node.attrs.alignment || 'center') + const [isModalOpen, setIsModalOpen] = React.useState(false) const fileId = blockObject ? `${blockObject.content.file_id}.${blockObject.content.file_format}` @@ -78,6 +80,10 @@ function ImageBlockComponent(props: any) { document.body.removeChild(link); }; + const handleExpand = () => { + setIsModalOpen(true); + }; + const handleAlignmentChange = (newAlignment: string) => { setAlignment(newAlignment); props.updateAttributes({ @@ -85,6 +91,15 @@ function ImageBlockComponent(props: any) { }); }; + const imageUrl = blockObject ? getActivityBlockMediaDirectory( + org?.org_uuid, + course?.courseStructure.course_uuid, + props.extension.options.activity.activity_uuid, + blockObject.block_uuid, + fileId || '', + 'imageBlock' + ) : null; + useEffect(() => {}, [course, org]) const getAlignmentClass = () => { @@ -99,126 +114,150 @@ function ImageBlockComponent(props: any) { }; return ( - - - - - - - {blockObject && isEditable && ( -
- { - const newWidth = Math.min(imageSize.width + d.width, ref.parentElement?.clientWidth || 1000); - props.updateAttributes({ - size: { - width: newWidth, + <> + + + + + + + {blockObject && isEditable && ( +
+ + }} + style={{ + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + height: '100%', + maxWidth: '100%', + }} + maxWidth="100%" + minWidth={200} + enable={{ right: true }} + onResizeStop={(e, direction, ref, d) => { + const newWidth = Math.min(imageSize.width + d.width, ref.parentElement?.clientWidth || 1000); + props.updateAttributes({ + size: { + width: newWidth, + }, + }) + setImageSize({ + width: newWidth, + }) + }} + > +
+ +
+ + + +
+ +
+
+
+
+ )} + + {blockObject && !isEditable && ( +
-
+
-
- -
- )} - - {blockObject && !isEditable && ( -
-
- -
-
- )} + )} - {isLoading && ( -
- -
+ {isLoading && ( +
+ +
+ )} + + + {blockObject && imageUrl && ( + + +
+ } + /> )} -
+ ) } diff --git a/apps/web/components/Objects/Editor/Extensions/PDF/PDFBlockComponent.tsx b/apps/web/components/Objects/Editor/Extensions/PDF/PDFBlockComponent.tsx index 3988699b..47da2d7e 100644 --- a/apps/web/components/Objects/Editor/Extensions/PDF/PDFBlockComponent.tsx +++ b/apps/web/components/Objects/Editor/Extensions/PDF/PDFBlockComponent.tsx @@ -1,7 +1,7 @@ import { NodeViewWrapper } from '@tiptap/react' import React, { useEffect } from 'react' import styled from 'styled-components' -import { AlertTriangle, FileText, Download } from 'lucide-react' +import { AlertTriangle, FileText, Download, Expand } from 'lucide-react' import { uploadNewPDFFile } from '../../../../../services/blocks/Pdf/pdf' import { getActivityBlockMediaDirectory } from '@services/media/media' import { useOrg } from '@components/Contexts/OrgContext' @@ -10,6 +10,7 @@ import { useEditorProvider } from '@components/Contexts/Editor/EditorContext' import { useLHSession } from '@components/Contexts/LHSessionContext' import { FileUploadBlock, FileUploadBlockButton, FileUploadBlockInput } from '../../FileUploadBlock' import { constructAcceptValue } from '@/lib/constants'; +import Modal from '@components/Objects/StyledElements/Modal/Modal' const SUPPORTED_FILES = constructAcceptValue(['pdf']) @@ -23,6 +24,7 @@ function PDFBlockComponent(props: any) { const [blockObject, setblockObject] = React.useState( props.node.attrs.blockObject ) + const [isModalOpen, setIsModalOpen] = React.useState(false) const fileId = blockObject ? `${blockObject.content.file_id}.${blockObject.content.file_format}` : null @@ -70,47 +72,83 @@ function PDFBlockComponent(props: any) { document.body.removeChild(link); }; + const handleExpand = () => { + setIsModalOpen(true); + }; + + const pdfUrl = blockObject ? getActivityBlockMediaDirectory( + org?.org_uuid, + course?.courseStructure.course_uuid, + props.extension.options.activity.activity_uuid, + blockObject.block_uuid, + fileId || '', + 'pdfBlock' + ) : null; + useEffect(() => { }, [course, org]) return ( - - - - - - - {blockObject && ( - -
-