diff --git a/client/src/components/editor/FullCodeBlock.tsx b/client/src/components/editor/FullCodeBlock.tsx index aed362a..df53c82 100644 --- a/client/src/components/editor/FullCodeBlock.tsx +++ b/client/src/components/editor/FullCodeBlock.tsx @@ -6,99 +6,99 @@ import { getLanguageLabel, getMonacoLanguage } from '../../utils/language/langua import CopyButton from '../common/buttons/CopyButton'; export interface FullCodeBlockProps { - code: string; - language?: string; - showLineNumbers?: boolean; - } - - export const FullCodeBlock: React.FC = ({ - code, - language = 'plaintext', - showLineNumbers = true - }) => { - const isMarkdown = getLanguageLabel(language) === 'markdown'; - const [highlighterHeight, setHighlighterHeight] = useState("100px"); - const containerRef = useRef(null); - const LINE_HEIGHT = 19; - - useEffect(() => { - updateHighlighterHeight(); - const resizeObserver = new ResizeObserver(updateHighlighterHeight); - if (containerRef.current) { - resizeObserver.observe(containerRef.current); - } - return () => resizeObserver.disconnect(); - }, [code]); - - const updateHighlighterHeight = () => { - if (!containerRef.current) return; - - const lineCount = code.split('\n').length; - const contentHeight = (lineCount * LINE_HEIGHT) + 35; - const newHeight = Math.min(500, Math.max(100, contentHeight)); - setHighlighterHeight(`${newHeight}px`); - }; - - const customStyle = { - ...vscDarkPlus, - 'pre[class*="language-"]': { - ...vscDarkPlus['pre[class*="language-"]'], - margin: 0, - fontSize: '13px', - background: '#1E1E1E', - padding: '1rem', - }, - 'code[class*="language-"]': { - ...vscDarkPlus['code[class*="language-"]'], - fontSize: '13px', - background: '#1E1E1E', - display: 'block', - textIndent: 0, - } - }; - - return ( + code: string; + language?: string; + showLineNumbers?: boolean; +} + +export const FullCodeBlock: React.FC = ({ + code, + language = 'plaintext', + showLineNumbers = true +}) => { + const isMarkdown = getLanguageLabel(language) === 'markdown'; + const [highlighterHeight, setHighlighterHeight] = useState("100px"); + const containerRef = useRef(null); + const LINE_HEIGHT = 19; + + useEffect(() => { + updateHighlighterHeight(); + const resizeObserver = new ResizeObserver(updateHighlighterHeight); + if (containerRef.current) { + resizeObserver.observe(containerRef.current); + } + return () => resizeObserver.disconnect(); + }, [code]); + + const updateHighlighterHeight = () => { + if (!containerRef.current) return; + + const lineCount = code.split('\n').length; + const contentHeight = (lineCount * LINE_HEIGHT) + 35; + const newHeight = Math.min(500, Math.max(100, contentHeight)); + setHighlighterHeight(`${newHeight}px`); + }; + + const customStyle = { + ...vscDarkPlus, + 'pre[class*="language-"]': { + ...vscDarkPlus['pre[class*="language-"]'], + margin: 0, + fontSize: '13px', + background: '#1E1E1E', + padding: '1rem', + }, + 'code[class*="language-"]': { + ...vscDarkPlus['code[class*="language-"]'], + fontSize: '13px', + background: '#1E1E1E', + display: 'block', + textIndent: 0, + } + }; + + return ( +
-
- {isMarkdown ? ( -
- - {code} - -
- ) : ( -
+ + {code} + +
+ ) : ( +
+ - - {code} - -
- )} - - -
+ {code} + +
+ )} + +
- ); - }; \ No newline at end of file + + ); +}; \ No newline at end of file diff --git a/client/src/components/editor/PreviewCodeBlock.tsx b/client/src/components/editor/PreviewCodeBlock.tsx index 76ee131..cb064e0 100644 --- a/client/src/components/editor/PreviewCodeBlock.tsx +++ b/client/src/components/editor/PreviewCodeBlock.tsx @@ -46,6 +46,15 @@ export const PreviewCodeBlock: React.FC = ({