import { cn } from '@udecode/cn'; import { PreviewImage, useImagePreview, useImagePreviewValue, useScaleInput, } from '@udecode/plate-media/react'; import { useEditorRef } from '@udecode/plate/react'; import { cva } from 'class-variance-authority'; import { ArrowLeft, ArrowRight, Download, Minus, Plus, X } from 'lucide-react'; const toolButtonVariants = cva('rounded bg-[rgba(0,0,0,0.5)] px-1', { defaultVariants: { variant: 'default', }, variants: { variant: { default: 'text-white', disabled: 'cursor-not-allowed text-gray-400', }, }, }); const SCROLL_SPEED = 4; export const ImagePreview = () => { const editor = useEditorRef(); const isOpen = useImagePreviewValue('isOpen', editor.id); const scale = useImagePreviewValue('scale'); const isEditingScale = useImagePreviewValue('isEditingScale'); const { closeProps, currentUrlIndex, maskLayerProps, nextDisabled, nextProps, prevDisabled, prevProps, scaleTextProps, zommOutProps, zoomInDisabled, zoomInProps, zoomOutDisabled, } = useImagePreview({ scrollSpeed: SCROLL_SPEED }); return (
e.stopPropagation()} {...maskLayerProps} >
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
e.stopPropagation()} >
{(currentUrlIndex ?? 0) + 1}
{isEditingScale ? ( <> {' '} % ) : ( {scale * 100 + '%'} )}
{/* TODO: downLoad the image */}
); }; export function ScaleInput(props: React.ComponentProps<'input'>) { const { props: scaleInputProps, ref } = useScaleInput(); return ; }