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 (
+
+
+
+
+
+
+
+ {t("practical.cancel")}
+
+
+ {t(`practical.${ "edit"}`)}
+
+
+
+
+
+ )
+}
+
+export default EditLaTexModal
\ No newline at end of file
diff --git a/src/Components/LatextInput/LaTeXInput.tsx b/src/Components/LatextInput/LaTeXInput.tsx
index 57de2d6..e87f079 100644
--- a/src/Components/LatextInput/LaTeXInput.tsx
+++ b/src/Components/LatextInput/LaTeXInput.tsx
@@ -1,51 +1,66 @@
import TextArea from 'antd/es/input/TextArea'
import { useFormikContext } from 'formik';
-import React, { useState } from 'react'
-import { convertMathMLToLaTeX } from '../../utils/convertMathMLToLaTeX';
+import React, { Suspense, useState } from 'react'
import { parseTextAndLatex } from '../../utils/parseTextAndLatex';
import LatexPreview from '../../Components/CustomFields/MathComponent';
-import { Checkbox, Modal } from 'antd';
+import { Checkbox } from 'antd';
import { CheckboxProps } from 'antd/lib';
import { useTranslation } from 'react-i18next';
-import LaTexModal from './LaTexModal';
import { FaPlus } from 'react-icons/fa';
-
-const LaTeXInput = ({name}:{name:string}) => {
+import { useObjectToEdit } from '../../zustand/ObjectToEditState';
+import { TextAreaProps } from 'antd/lib/input';
+import SpinContainer from '../Layout/SpinContainer';
+ const AddLazyModal = React.lazy(()=> import("./AddLaTexModal"));
+ const EditLazyModal = React.lazy(()=> import("./EditLaTexModal"));
+interface ILaTeXInput extends TextAreaProps {
+ name:string,label:string
+}
+const LaTeXInput = ({name,label,...props}:ILaTeXInput) => {
- const {values,setFieldValue} = useFormikContext()
-
+ const {values,setFieldValue,getFieldProps} = useFormikContext()
+ const { ShowLatexOption } = useObjectToEdit();
const [showPreview, setShowPreview] = useState(false) ;
-
- console.log(values?.[name]);
-
+ const value = getFieldProps(name)?.value
const handleChangeInput =
- (
+ (
e: React.ChangeEvent,
) => {
setFieldValue(name,e.target.value);
};
-
- const Preview = parseTextAndLatex(values?.[name]) ;
-
+
+ const Preview = parseTextAndLatex(value ?? "") ;
+
const onPreviewChange: CheckboxProps['onChange'] = (e) => {
const value = e.target.checked
setShowPreview(value)
};
- const [t] = useTranslation()
+ const [t] = useTranslation()
+
+ const [isModalOpen, setIsModalOpen] = useState(false);
+ const [isEditModalOpen, setIsEditModalOpen] = useState(false);
- const [isModalOpen, setIsModalOpen] = useState(false);
- const [Latex, setLatex] = useState("")
-
-
- const showModal = () => {
+ const [Latex, setLatex] = useState("")
+
+
+ const showModal = () => {
setIsModalOpen(true);
};
+
-
+ const handelEditModal = (item:any)=>{
+ console.log(item);
+
+ setLatex(item)
+ setIsEditModalOpen(true)
+ }
return (
+
+