import { h, Fragment, type Ref, defineComponent } from 'vue' import type { ImageBlockConfig } from '../../config' import { ImageInput } from '../../../__internal__/components/image-input' import { keepAlive } from '../../../__internal__/keep-alive' import { ImageViewer } from './image-viewer' keepAlive(h, Fragment) type Attrs = { src: string caption: string ratio: number } export type MilkdownImageBlockProps = { selected: Ref readonly: Ref setAttr: (attr: T, value: Attrs[T]) => void config: ImageBlockConfig } & { [P in keyof Attrs]: Ref } export const MilkdownImageBlock = defineComponent({ props: { src: { type: Object, required: true, }, caption: { type: Object, required: true, }, ratio: { type: Object, required: true, }, selected: { type: Object, required: true, }, readonly: { type: Object, required: true, }, setAttr: { type: Function, required: true, }, config: { type: Object, required: true, }, }, setup(props) { const { src } = props return () => { if (!src.value?.length) { return ( props.setAttr('src', link)} imageIcon={props.config.imageIcon} uploadButton={props.config.uploadButton} confirmButton={props.config.confirmButton} uploadPlaceholderText={props.config.uploadPlaceholderText} onUpload={props.config.onUpload} onImageLoadError={props.config.onImageLoadError} /> ) } return } }, })