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