feat(markdown): Enhance ThinkBox and MarkdownRenderer for improved content handling and security

This commit is contained in:
Willie Zutz 2025-07-19 12:00:08 -06:00
parent 1b0c2c59b8
commit 9f58910254
3 changed files with 20 additions and 9 deletions

View file

@ -39,7 +39,7 @@ const ThinkTagProcessor = ({
if (isOverlayMode) {
return null;
}
return <ThinkBox content={children as string} />;
return <ThinkBox content={children} />;
};
const CodeBlock = ({
@ -149,6 +149,11 @@ const MarkdownRenderer = ({
pre: {
component: ({ children }) => children,
},
// Prevent rendering of certain HTML elements for security
iframe: () => null, // Don't render iframes
script: () => null, // Don't render scripts
object: () => null, // Don't render objects
style: () => null, // Don't render styles
},
};
@ -170,7 +175,7 @@ const MarkdownRenderer = ({
'prose prose-h1:mb-3 prose-h2:mb-2 prose-h2:mt-6 prose-h2:font-[800] prose-h3:mt-4 prose-h3:mb-1.5 prose-h3:font-[600] prose-invert prose-p:leading-relaxed prose-pre:p-0 font-[400]',
'prose-code:bg-transparent prose-code:p-0 prose-code:text-inherit prose-code:font-normal prose-code:before:content-none prose-code:after:content-none',
'prose-pre:bg-transparent prose-pre:border-0 prose-pre:m-0 prose-pre:p-0',
'break-words text-black dark:text-white',
'break-words text-black dark:text-white max-w-full',
className,
)}
options={markdownOverrides}