// components/readonly-editor.js import React, { useRef, useEffect } from "react"; import { Editor } from "@tinymce/tinymce-react"; function ReadOnlyEditor(props) { const editorRef = useRef(null); const handleInit = (evt, editor) => { editorRef.current = editor; // Set initial content if provided if (props.initialData) { editor.setContent(props.initialData); } // Disable all editing capabilities editor.on('keydown keyup keypress input', (e) => { e.preventDefault(); e.stopPropagation(); return false; }); editor.on('paste', (e) => { e.preventDefault(); e.stopPropagation(); return false; }); editor.on('drop', (e) => { e.preventDefault(); e.stopPropagation(); return false; }); // Disable mouse events that might allow editing editor.on('mousedown mousemove mouseup click dblclick', (e) => { if (e.target.closest('.mce-content-body')) { e.preventDefault(); e.stopPropagation(); return false; } }); }; // Update content when props change useEffect(() => { if (editorRef.current && props.initialData) { editorRef.current.setContent(props.initialData); } }, [props.initialData]); return ( ); } export default ReadOnlyEditor;