feat: resize images in super editor (#2052)

This commit is contained in:
Aman Harwara
2022-11-24 21:06:09 +05:30
committed by GitHub
parent 2e517c985d
commit 2485bed350
7 changed files with 185 additions and 41 deletions

View File

@@ -7,6 +7,7 @@ import { AppPaneId } from '../ResponsivePane/AppPaneMetadata'
import { useResponsiveAppPane } from '../ResponsivePane/ResponsivePaneProvider'
import { createObjectURLWithRef } from './CreateObjectURLWithRef'
import ImagePreview from './ImagePreview'
import { ImageZoomLevelProps } from './ImageZoomLevelProps'
import { PreviewableTextFileTypes, RequiresNativeFilePreview } from './isFilePreviewable'
import TextPreview from './TextPreview'
@@ -14,9 +15,17 @@ type Props = {
application: WebApplication
file: FileItem
bytes: Uint8Array
}
isEmbeddedInSuper: boolean
} & ImageZoomLevelProps
const PreviewComponent: FunctionComponent<Props> = ({ application, file, bytes }) => {
const PreviewComponent: FunctionComponent<Props> = ({
application,
file,
bytes,
isEmbeddedInSuper,
imageZoomLevel,
setImageZoomLevel,
}) => {
const { selectedPane } = useResponsiveAppPane()
const objectUrlRef = useRef<string>()
@@ -73,7 +82,14 @@ const PreviewComponent: FunctionComponent<Props> = ({ application, file, bytes }
}
if (file.mimeType.startsWith('image/')) {
return <ImagePreview objectUrl={objectUrl} />
return (
<ImagePreview
objectUrl={objectUrl}
isEmbeddedInSuper={isEmbeddedInSuper}
imageZoomLevel={imageZoomLevel}
setImageZoomLevel={setImageZoomLevel}
/>
)
}
if (file.mimeType.startsWith('video/')) {