import { ElementIds } from '@/Constants/ElementIDs' import { observer } from 'mobx-react-lite' import { ChangeEventHandler, FormEventHandler, useCallback, useEffect, useState } from 'react' import AttachedFilesButton from '@/Components/AttachedFilesPopover/AttachedFilesButton' import FileOptionsPanel from '@/Components/FileContextMenu/FileOptionsPanel' import FilePreview from '@/Components/FilePreview/FilePreview' import { FileViewProps } from './FileViewProps' const FileViewWithoutProtection = ({ application, viewControllerManager, file }: FileViewProps) => { const [name, setName] = useState(file.name) useEffect(() => { setName(file.name) }, [file.name]) const onTitleChange: ChangeEventHandler = useCallback(async (event) => { setName(event.target.value) }, []) const onFormSubmit: FormEventHandler = useCallback( async (event) => { event.preventDefault() await application.items.renameFile(file, name) void application.sync.sync() }, [application.items, application.sync, file, name], ) return (
{ event.target.select() }} spellCheck={false} value={name} autoComplete="off" />
) } export default observer(FileViewWithoutProtection)