File size: 1,562 Bytes
abcf568 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | import { ImageLightbox } from '../../../components/image-preview/lightbox'
import { useI18n } from '../../../i18n'
import { uploadReferenceImage } from '../../../lib/api'
interface PlotPreviewLightboxProps {
isOpen: boolean
activeImage?: string
activeIndex: number
total: number
editableFilename?: string
canNavigate: boolean
onPrev: () => void
onNext: () => void
onClose: () => void
onSendPreviewToComposer?: (attachment: { url: string; name: string; mimeType?: string }) => void
}
export function PlotPreviewLightbox({
isOpen,
activeImage,
activeIndex,
total,
editableFilename,
canNavigate,
onPrev,
onNext,
onClose,
onSendPreviewToComposer,
}: PlotPreviewLightboxProps) {
const { t } = useI18n()
return (
<ImageLightbox
isOpen={isOpen}
activeImage={activeImage}
activeIndex={activeIndex}
total={total}
initialZoom={0.5}
baseScaleMode="cover"
baseScaleBias={1}
minZoom={0.25}
maxZoom={4}
zoomDisplayScale={2}
editableFilename={editableFilename ?? t('studio.plot.inlinePreview')}
appearance="studio"
onPrev={canNavigate ? onPrev : undefined}
onNext={canNavigate ? onNext : undefined}
onCommitAnnotatedImage={onSendPreviewToComposer ? async ({ file, filename }) => {
const uploaded = await uploadReferenceImage(file)
onSendPreviewToComposer({
url: uploaded.url,
name: filename,
mimeType: uploaded.mimeType,
})
} : undefined}
onClose={onClose}
/>
)
}
|