diff --git a/src/Components/LatextInput/LaTeXInputMemo.tsx b/src/Components/LatextInput/LaTeXInputMemo.tsx index 15ce686..59a361f 100644 --- a/src/Components/LatextInput/LaTeXInputMemo.tsx +++ b/src/Components/LatextInput/LaTeXInputMemo.tsx @@ -142,21 +142,26 @@ const LaTeXInputMemo: React.FC = React.memo( {showPreview && (
- {Preview?.map((item: any, index: number) => { + {Preview?.map((item: any, index: number,items) => { if (item?.isLatex) { return ( - handleEditModal(item)} className="LatexPreview" + > - - + +
); } - return
{item?.text}
; + return
1 ? "100%" : undefined, + whiteSpace: "pre-wrap", + }} + >{ items[index -1]?.isLatex ? item?.text?.replace(/\n/, ""):item?.text}
; })} )} diff --git a/src/Styles/components/LaTeXInput.scss b/src/Styles/components/LaTeXInput.scss index 563a79f..765ce30 100644 --- a/src/Styles/components/LaTeXInput.scss +++ b/src/Styles/components/LaTeXInput.scss @@ -36,6 +36,13 @@ border: 1px solid #d9d9d9; padding: 5px 10px; row-gap: 0px; + white-space:pre-line; + overflow-y: auto; + resize: none; + // height: 165px; + min-height: 164px; + max-height: 270px; + } .addMML { all: unset; diff --git a/src/utils/parseTextAndLatex.ts b/src/utils/parseTextAndLatex.ts index dc53b76..af93912 100644 --- a/src/utils/parseTextAndLatex.ts +++ b/src/utils/parseTextAndLatex.ts @@ -7,15 +7,19 @@ interface TextLatexPart { export const parseTextAndLatex = (input: string): TextLatexPart[] => { const result: TextLatexPart[] = []; + console.log(input) const parts = input?.split(/(\$\$[^$]+\$\$)/g); + console.log(parts) parts.forEach((part, index) => { if (part.startsWith("$$") && part.endsWith("$$")) { result.push({ text: part.slice(2, -2), isLatex: true, key: index }); - } else if (part.trim()) { + } + else { result.push({ text: part, isLatex: false, key: index }); } }); + console.log(result) return result; };