From 10941b66d68493bc76a220579bb962ba1fbc9dd7 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Thu, 4 Jul 2024 21:59:53 +0530 Subject: [PATCH] removes undo rendo --- src/Components/Common/MarkdownEditor.tsx | 45 +----------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/src/Components/Common/MarkdownEditor.tsx b/src/Components/Common/MarkdownEditor.tsx index f6f64da4b46..c5cffc808c7 100644 --- a/src/Components/Common/MarkdownEditor.tsx +++ b/src/Components/Common/MarkdownEditor.tsx @@ -4,8 +4,6 @@ import { FaItalic, FaListOl, FaListUl, - FaUndo, - FaRedo, FaLink, FaUnlink, FaQuoteRight, @@ -66,8 +64,6 @@ const RichTextEditor: React.FC = () => { const [htmlCode, setHtmlCode] = useState(""); const [state, dispatch] = useReducer(editorReducer, initialState); const editorRef = useRef(null); - const undoStack = useRef([]); - const redoStack = useRef([]); useEffect(() => { document.addEventListener("selectionchange", handleSelectionChange); @@ -129,14 +125,6 @@ const RichTextEditor: React.FC = () => { }; const saveState = () => { - if (editorRef.current) { - undoStack.current.push(editorRef.current.innerHTML); - redoStack.current = []; - updatePreview(); - } - }; - - const updatePreview = () => { const turndownService = new TurndownService(); const htmlContent = editorRef.current?.innerHTML || ""; const markdownText = turndownService.turndown(htmlContent); @@ -144,28 +132,6 @@ const RichTextEditor: React.FC = () => { setHtmlCode(htmlContent); }; - const undo = () => { - if (undoStack.current.length > 0 && editorRef.current) { - redoStack.current.push(editorRef.current.innerHTML); - const lastState = undoStack.current.pop(); - if (lastState && editorRef.current) { - editorRef.current.innerHTML = lastState; - updatePreview(); - } - } - }; - - const redo = () => { - if (redoStack.current.length > 0 && editorRef.current) { - undoStack.current.push(editorRef.current.innerHTML); - const nextState = redoStack.current.pop(); - if (nextState && editorRef.current) { - editorRef.current.innerHTML = nextState; - updatePreview(); - } - } - }; - const applyStyle = (style: "bold" | "italic") => { const selection = window.getSelection(); if (!selection || !selection.rangeCount) return; @@ -373,22 +339,13 @@ const RichTextEditor: React.FC = () => {
- -
- - -