import type Uppy from '@uppy/core' import type { Body, State, UIPlugin } from '@uppy/core' import type { I18n, Meta, Translator, UppyFile, UppyFileId, } from '@uppy/core/utils' import classNames from 'classnames' import type { ComponentChildren, MouseEventHandler } from 'preact' import type { TargetWithRender } from '../Dashboard.js' declare module '@uppy/core' { export interface UppyEventMap { 'file-editor:cancel': (file: UppyFile) => void } } type EditorPanelProps = { className?: string | undefined closeFileEditor: () => void editors: TargetWithRender[] fileCardFor: UppyFileId | null files: State['files'] i18n: I18n i18nArray: Translator['translateArray'] saveFileEditor: MouseEventHandler state: State uppy: Uppy } function EditorPanel( props: EditorPanelProps, ): ComponentChildren { const file = props.fileCardFor ? props.files[props.fileCardFor] : undefined if (!file) { return null } const handleCancel = () => { props.uppy.emit('file-editor:cancel', file) props.closeFileEditor() } return (
{props.i18nArray('editing', { file: ( {file.meta ? file.meta.name : file.name} ), })}
{props.editors.map((target) => { return ( props.uppy.getPlugin(target.id) as UIPlugin< // biome-ignore lint/complexity/noBannedTypes: {} means anything except null or undefined. {}, M, B > ).render(props.state) })}
) } export default EditorPanel