Compare commits
No commits in common. "0412bccffb6b63b9197f0c78bdaec473497f4f35" and "9644b4e6ba1d1c8d29504cd650e74b5815f291b0" have entirely different histories.
0412bccffb
...
9644b4e6ba
|
|
@ -6,13 +6,12 @@ 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,setCurrentValue}:{
|
const AddLaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen}:{
|
||||||
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>()
|
||||||
|
|
@ -28,7 +27,6 @@ const AddLaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen,setCurren
|
||||||
|
|
||||||
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, useEffect, useState } from 'react';
|
import React, { Suspense, 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';
|
||||||
|
|
@ -18,9 +18,9 @@ const EditLazyModal = React.lazy(() => import("./EditLaTexModal"));
|
||||||
const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...props }) => {
|
const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...props }) => {
|
||||||
const { name ,value} = field;
|
const { name ,value} = field;
|
||||||
|
|
||||||
const { setFieldValue ,touched ,errors } = form;
|
const { setFieldValue } = form;
|
||||||
|
|
||||||
const { ShowLatexOption, Success } = useObjectToEdit();
|
const { ShowLatexOption } = 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,18 +52,11 @@ const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...prop
|
||||||
|
|
||||||
setFieldValue(name, curCentValue);
|
setFieldValue(name, curCentValue);
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
|
||||||
if(Success){
|
|
||||||
setCurrentValue(null)
|
|
||||||
}
|
|
||||||
}, [Success])
|
|
||||||
|
|
||||||
const isError = !!touched?.[name] && !!errors?.[name];
|
|
||||||
const errorMessage = isError ? errors?.[name] as string ?? "" : "" ;
|
|
||||||
return (
|
return (
|
||||||
<div className='LaTeXInput'>
|
<div className='LaTeXInput'>
|
||||||
<label htmlFor={name} className="text">
|
<label htmlFor={name} className="text">
|
||||||
<div>{t(label || name)}</div> <div className='error_message'>{t(errorMessage)}</div>
|
{t(label || name)}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div className='LaTeXInputArea'>
|
<div className='LaTeXInputArea'>
|
||||||
|
|
@ -104,9 +97,9 @@ const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...prop
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<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 fallback={<SpinContainer />}>
|
||||||
|
<AddLazyModal name={name} Latex={Latex} isModalOpen={isModalOpen} setIsModalOpen={setIsModalOpen} setLatex={setLatex} />
|
||||||
|
<EditLazyModal name={name} Latex={Latex} isModalOpen={isEditModalOpen} setIsModalOpen={setIsEditModalOpen} setLatex={setLatex} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
margin-bottom: 7px !important;
|
margin-bottom: 7px !important;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 19px;
|
font-size: 19px;
|
||||||
|
|
||||||
> span {
|
> span {
|
||||||
color: transparent;
|
color: transparent;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,7 @@ const AddPage: React.FC = () => {
|
||||||
<div onClick={handleCancel}>{t("practical.back")}</div>
|
<div onClick={handleCancel}>{t("practical.back")}</div>
|
||||||
<div
|
<div
|
||||||
className="relative"
|
className="relative"
|
||||||
onClick={()=>{ handleSubmit() }}
|
onClick={()=>{ Loading ? ()=>{} : handleValidateSingleQuestion(values,isValid,handleSubmit) }}
|
||||||
>
|
>
|
||||||
{t("practical.add")}
|
{t("practical.add")}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,9 @@ 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 (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import SelectTag from "../../../../Components/CustomFields/SelectTag";
|
||||||
import useKeyCombination from "../../../../Hooks/useKeyCombination";
|
import useKeyCombination from "../../../../Hooks/useKeyCombination";
|
||||||
import { CombinationKeyEnum } from "../../../../enums/CombinationKeyEnum";
|
import { CombinationKeyEnum } from "../../../../enums/CombinationKeyEnum";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
|
import LaTeXInput from "../../../../Components/LatextInput/LaTeXInput";
|
||||||
import LaTeXInputMemo from "../../../../Components/LatextInput/LaTeXInputMemo";
|
import LaTeXInputMemo from "../../../../Components/LatextInput/LaTeXInputMemo";
|
||||||
import ImageBoxFieldMemo from "../../../../Components/CustomFields/ImageBoxField/ImageBoxFieldMemo";
|
import ImageBoxFieldMemo from "../../../../Components/CustomFields/ImageBoxField/ImageBoxFieldMemo";
|
||||||
|
|
||||||
|
|
@ -47,8 +48,6 @@ const Form = () => {
|
||||||
}
|
}
|
||||||
}, [Success]);
|
}, [Success]);
|
||||||
|
|
||||||
console.log(formik.errors);
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row className="w-100 exercise_form_container">
|
<Row className="w-100 exercise_form_container">
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,7 @@ export const getValidationSchema = () => {
|
||||||
// validate input
|
// validate input
|
||||||
return Yup.object().shape({
|
return Yup.object().shape({
|
||||||
content_image: Yup.string().nullable(),
|
content_image: Yup.string().nullable(),
|
||||||
content: Yup.string().test(
|
content: Yup.string().nullable(),
|
||||||
"content",
|
|
||||||
"validation.one_of_image_and_content_should_be_enter_in_question",
|
|
||||||
(value: any,options:any) => {
|
|
||||||
const {content,content_image} = options?.parent
|
|
||||||
const haveImageOrContent = !(content) && !(content_image)
|
|
||||||
return !haveImageOrContent ;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
answers: Yup.array().of(
|
answers: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
content: Yup.string().nullable(),
|
content: Yup.string().nullable(),
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,23 @@ 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>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -359,18 +359,4 @@
|
||||||
.ListQuestions{
|
.ListQuestions{
|
||||||
@include Scrollbar();
|
@include Scrollbar();
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.LaTeXInput{
|
|
||||||
.text{
|
|
||||||
display: flex !important;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
.error_message{
|
|
||||||
color: red;
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user