diff --git a/src/Components/LatextInput/LaTexModal.tsx b/src/Components/LatextInput/AddLaTexModal.tsx similarity index 92% rename from src/Components/LatextInput/LaTexModal.tsx rename to src/Components/LatextInput/AddLaTexModal.tsx index 723afe3..ab0a7fd 100644 --- a/src/Components/LatextInput/LaTexModal.tsx +++ b/src/Components/LatextInput/AddLaTexModal.tsx @@ -6,7 +6,7 @@ import { convertMathMLToLaTeX } from '../../utils/convertMathMLToLaTeX'; import { useTranslation } from 'react-i18next'; import { toast } from 'react-toastify'; -const LaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen}:{ +const AddLaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen}:{ name:string, setLatex: (value:string)=> void, Latex:string, @@ -66,13 +66,12 @@ const LaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen}:{
{t("practical.cancel")}
- + @@ -80,4 +79,4 @@ const LaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen}:{ ) } -export default LaTexModal \ No newline at end of file +export default AddLaTexModal \ No newline at end of file diff --git a/src/Components/LatextInput/EditLaTexModal.tsx b/src/Components/LatextInput/EditLaTexModal.tsx new file mode 100644 index 0000000..1aa17f6 --- /dev/null +++ b/src/Components/LatextInput/EditLaTexModal.tsx @@ -0,0 +1,89 @@ +import { Modal } from 'antd' +import TextArea from 'antd/es/input/TextArea' +import { useFormikContext } from 'formik'; +import React, { useState } from 'react' +import { convertMathMLToLaTeX } from '../../utils/convertMathMLToLaTeX'; +import { useTranslation } from 'react-i18next'; +import { toast } from 'react-toastify'; +import { parseTextAndLatex } from '../../utils/parseTextAndLatex'; + +const EditLaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen}:{ + name:string, + setLatex: (value:string)=> void, + Latex:any, + setIsModalOpen: (value:boolean)=> void , + isModalOpen:boolean, + +}) => { + const {values} = useFormikContext() + const [Value, setValue] = useState(Latex?.text ?? Latex) + + const handleOk = () => { + console.log(1); + + const oldValue = values?.[name]; + const currentKey = Latex?.key ; + const Preview = parseTextAndLatex(oldValue ?? "") ; + console.log(Latex); + + const newLatex = convertMathMLToLaTeX(Latex); + console.log(newLatex); + + if(newLatex){ + const newArray = Preview?.map((item:any,index:number)=>{ + if(item?.key) + return item + }) + + }else{ + toast.error(t("validation.that_is_not_a_valid_mml")) + } + }; + + const handleCancel = () => { + setIsModalOpen(false); + setLatex("") + }; + + const handleChangeInputLatex = ( + e: React.ChangeEvent, + ) => { + const newValue = e.target.value; + console.log(newValue,"newValue"); + setValue(newValue) + }; + + const [t] = useTranslation() + return ( + + +
+ +