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"; 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, getFieldProps } = useFormikContext(); const currentValue = getFieldProps(name).value; const handleOk = () => { const oldValue = currentValue ?? ""; const newLatex = convertMathMLToLaTeX(Latex); console.log(oldValue); if (newLatex) { setFieldValue(name, oldValue + " $$ " + newLatex + " $$ "); setCurrentValue(oldValue + " $$ " + newLatex + " $$ "); setLatex(""); setIsModalOpen(false); } else { setFieldValue(name, oldValue + " $$ " + Latex + " $$ "); setCurrentValue(oldValue + " $$ " + Latex + " $$ "); setLatex(""); setIsModalOpen(false); } }; const handleCancel = () => { setIsModalOpen(false); setLatex(""); }; const handleChangeInputLatex = ( e: React.ChangeEvent, ) => { const newValue = e.target.value; setLatex(newValue); }; const [t] = useTranslation(); return (