Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions frontend/src/components/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,20 @@ function CustomCode(props: JSX.IntrinsicElements["code"]) {
return <code>{props.children}</code>;
}

function ResponsiveTable({ children, className, ...rest }: JSX.IntrinsicElements["table"]) {
// Strip off props added by react-markdown that the DOM doesn't understand
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { node, inline, ...safeRest } = rest as Record<string, unknown>;

return (
<div className="overflow-x-auto max-w-full w-0 min-w-full rounded-md border border-border/50">
<table className={className} {...(safeRest as object)}>
{children}
</table>
</div>
);
}

function escapeDollarNumber(text: string) {
let escapedText = "";

Expand Down Expand Up @@ -305,6 +319,7 @@ function MarkDownContentToMemo(props: { content: string }) {
components={{
pre: (props: JSX.IntrinsicElements["pre"]) => <PreCode {...props} />,
code: (props: JSX.IntrinsicElements["code"]) => <CustomCode {...props} />,
table: (props: JSX.IntrinsicElements["table"]) => <ResponsiveTable {...props} />,
p: (pProps) => <p {...pProps} dir="auto" />,
a: (aProps) => {
const href = aProps.href || "";
Expand Down
Loading