import FolderIcon from '@mui/icons-material/Folder'; import { Typography } from '@mui/material'; import { useTranslation } from 'react-i18next'; import { useValidateHtmlWiki } from './useImportHtmlWiki'; import { CreateContainer, LocationPickerButton, LocationPickerContainer, LocationPickerInput } from './FormComponents'; import type { IWikiWorkspaceFormProps } from './useForm'; export function ImportHtmlWikiForm({ form, isCreateMainWorkspace, isCreateSyncedWorkspace, errorInWhichComponent, errorInWhichComponentSetter, }: IWikiWorkspaceFormProps & { isCreateSyncedWorkspace: boolean }): React.JSX.Element { const { t } = useTranslation(); const { wikiHtmlPathSetter, wikiFolderLocation, wikiFolderName, wikiHtmlPath, parentFolderLocation, wikiFolderNameSetter } = form; useValidateHtmlWiki(isCreateMainWorkspace, isCreateSyncedWorkspace, form, errorInWhichComponentSetter); return ( ) => { // https://zh-hans.reactjs.org/docs/events.html#clipboard-events wikiHtmlPathSetter(event.target.value); }} label={t('AddWorkspace.LocalWikiHtml')} value={wikiHtmlPath} /> { // first clear the text, so button will refresh wikiHtmlPathSetter(''); const filePaths = await window.service.native.pickFile([{ name: 'html文件', extensions: ['html', 'htm'] }]); if (filePaths.length > 0) { wikiHtmlPathSetter(filePaths[0]); const fileName = await window.service.native.path('basename', filePaths[0]); if (fileName !== undefined) { // use html file name as default wiki name wikiFolderNameSetter(fileName.split('.')[0]); } } }} endIcon={} > {t('AddWorkspace.Choose')} ) => { form.parentFolderLocationSetter(event.target.value); }} label={t('AddWorkspace.WorkspaceParentFolder')} value={parentFolderLocation} /> { // first clear the text, so button will refresh form.parentFolderLocationSetter(''); const filePaths = await window.service.native.pickDirectory(parentFolderLocation); if (filePaths.length > 0) { form.parentFolderLocationSetter(filePaths[0]); } }} endIcon={} > {t('AddWorkspace.Choose')} ) => { wikiFolderNameSetter(event.target.value); }} label={t('AddWorkspace.ExtractedWikiFolderName')} helperText={`${t('AddWorkspace.CreateWiki')}${wikiFolderLocation ?? ''}`} value={wikiFolderName} /> ); }