This commit is contained in:
robin 2022-09-30 17:29:45 +08:00 committed by mingcheng
parent d8354224d4
commit 9868cf498d
1 changed files with 12 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import { Form, Button } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import { marked } from 'marked';
import classNames from 'classnames';
import { Editor, Modal } from '@answer/components';
import { postAnswer } from '@answer/api';
@ -30,6 +31,7 @@ const Index: FC<Props> = ({ visible = false, data, callback }) => {
},
});
const [showEditor, setShowEditor] = useState<boolean>(visible);
const [focusType, setForceType] = useState('');
const handleSubmit = () => {
if (!formData.content.value) {
@ -92,6 +94,10 @@ const Index: FC<Props> = ({ visible = false, data, callback }) => {
className="d-none"
/>
<Editor
className={classNames(
'form-control p-0',
focusType === 'answer' && 'focus',
)}
value={formData.content.value}
onChange={(val) => {
setFormData({
@ -102,6 +108,12 @@ const Index: FC<Props> = ({ visible = false, data, callback }) => {
},
});
}}
onFocus={() => {
setForceType('answer');
}}
onBlur={() => {
setForceType('');
}}
/>
<Form.Control.Feedback type="invalid">