Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import React, { useRef, useEffect } from "react"; import MDEditor from "@uiw/react-md-editor"; type MarkdownOutputPropTypes = { content: string | undefined; className?: string; }; function MarkdownOutput({ content, className }: MarkdownOutputPropTypes) { const notesRef = useRef<HTMLDivElement>(null); useEffect(() => { const handleScroll = (e) => { Iif (notesRef.current && notesRef.current.contains(e.target)) { e.stopPropagation(); } }; const currentRef = notesRef.current; Iif (currentRef) { currentRef.addEventListener("wheel", handleScroll, { passive: false }); } return () => { Iif (currentRef) { currentRef.removeEventListener("wheel", handleScroll); } }; }, []); Iif (!content) return null; return ( <div data-color-mode="light" ref={notesRef}> <MDEditor.Markdown source={content} className={`${className} p-3 w-full max-h-[400px] overflow-y-auto`} /> </div> ); } export default MarkdownOutput; |