'use client'; import { cn, createPrimitiveComponent } from '@udecode/cn'; import { PreviewImage, useImagePreview, useImagePreviewState, useScaleInput, useScaleInputState, } from '@udecode/plate-media/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 ScaleInput = createPrimitiveComponent('input')({ propsHook: useScaleInput, stateHook: useScaleInputState, }); const SCROLL_SPEED = 4; export const ImagePreview = () => { const state = useImagePreviewState({ scrollSpeed: SCROLL_SPEED }); const { closeProps, currentUrlIndex, maskLayerProps, nextDisabled, nextProps, prevDisabled, prevProps, scaleTextProps, zommOutProps, zoomInDisabled, zoomInProps, zoomOutDisabled, } = useImagePreview(state); const { isOpen, scale } = state; return (
e.stopPropagation()} >
{(currentUrlIndex ?? 0) + 1}
{state.isEditingScale ? ( <> {' '} % ) : ( {scale * 100 + '%'} )}
{/* TODO: downLoad the image */}
); };