fixx
This commit is contained in:
parent
fa8f705a75
commit
ca653967fa
|
|
@ -6,12 +6,13 @@ import { convertMathMLToLaTeX } from '../../utils/convertMathMLToLaTeX';
|
|||
import { useTranslation } from 'react-i18next';
|
||||
import { toast } from 'react-toastify';
|
||||
|
||||
const AddLaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen}:{
|
||||
const AddLaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen,setCurrentValue}:{
|
||||
name:string,
|
||||
setLatex: (value:string)=> void,
|
||||
Latex:string,
|
||||
setIsModalOpen: (value:boolean)=> void ,
|
||||
isModalOpen:boolean,
|
||||
setCurrentValue:(value:string)=> void
|
||||
|
||||
}) => {
|
||||
const {values,setFieldValue} = useFormikContext<any>()
|
||||
|
|
@ -27,6 +28,7 @@ const AddLaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen}:{
|
|||
|
||||
if(newLatex){
|
||||
setFieldValue(name, oldValue + " $$ " +newLatex +" $$ ");
|
||||
setCurrentValue(oldValue + " $$ " +newLatex +" $$ ")
|
||||
setLatex("")
|
||||
setIsModalOpen(false);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import TextArea from 'antd/es/input/TextArea';
|
||||
import { useFormikContext } from 'formik';
|
||||
import React, { Suspense, useState } from 'react';
|
||||
import React, { Suspense, useEffect, useState } from 'react';
|
||||
import { parseTextAndLatex } from '../../utils/parseTextAndLatex';
|
||||
import LatexPreview from '../CustomFields/MathComponent';
|
||||
import { Checkbox } from 'antd';
|
||||
|
|
@ -20,7 +20,7 @@ const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...prop
|
|||
|
||||
const { setFieldValue } = form;
|
||||
|
||||
const { ShowLatexOption } = useObjectToEdit();
|
||||
const { ShowLatexOption, Success } = useObjectToEdit();
|
||||
const [showPreview, setShowPreview] = useState(false);
|
||||
const Preview = parseTextAndLatex(value ?? "");
|
||||
|
||||
|
|
@ -39,9 +39,9 @@ const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...prop
|
|||
};
|
||||
|
||||
const handleEditModal = (item: any) => {
|
||||
console.log(item);
|
||||
setLatex(item);
|
||||
setIsEditModalOpen(true);
|
||||
// console.log(item);
|
||||
// setLatex(item);
|
||||
// setIsEditModalOpen(true);
|
||||
};
|
||||
|
||||
const [curCentValue, setCurrentValue] = useState(value)
|
||||
|
|
@ -52,6 +52,12 @@ const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...prop
|
|||
|
||||
setFieldValue(name, curCentValue);
|
||||
}
|
||||
useEffect(() => {
|
||||
if(Success){
|
||||
setCurrentValue(null)
|
||||
}
|
||||
}, [Success])
|
||||
|
||||
|
||||
return (
|
||||
<div className='LaTeXInput'>
|
||||
|
|
@ -97,9 +103,9 @@ const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...prop
|
|||
)}
|
||||
</div>
|
||||
|
||||
<Suspense fallback={<SpinContainer />}>
|
||||
<AddLazyModal name={name} Latex={Latex} isModalOpen={isModalOpen} setIsModalOpen={setIsModalOpen} setLatex={setLatex} />
|
||||
<AddLazyModal name={name} Latex={Latex} isModalOpen={isModalOpen} setIsModalOpen={setIsModalOpen} setLatex={setLatex} setCurrentValue={setCurrentValue} />
|
||||
<EditLazyModal name={name} Latex={Latex} isModalOpen={isEditModalOpen} setIsModalOpen={setIsEditModalOpen} setLatex={setLatex} />
|
||||
<Suspense fallback={<SpinContainer />}>
|
||||
</Suspense>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -40,9 +40,6 @@ const Choices = React.memo( ({setFieldValue ,values,parent_index }:any) => {
|
|||
|
||||
setFieldValue(`Questions.${parent_index}.answers`, updatedItems);
|
||||
};
|
||||
console.log(123);
|
||||
console.log(setFieldValue);
|
||||
console.log(values?.Questions?.[parent_index]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -7,23 +7,7 @@ const Dummy = () => {
|
|||
return (
|
||||
<div className="DummyHomePage">
|
||||
|
||||
<Formik initialValues={{}} onSubmit={()=>{}}>
|
||||
<Form>
|
||||
{Array.from({length:1000}).map((item:any,index)=>{
|
||||
return (
|
||||
<div key={index}>
|
||||
|
||||
<Field
|
||||
name={`content${index}`}
|
||||
component={LaTeXInputMemo}
|
||||
label={t("input.answer_content")}
|
||||
/>
|
||||
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</Form>
|
||||
</Formik>
|
||||
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user