Skip to content
Closed
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
25 changes: 25 additions & 0 deletions frontend/src/components/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,30 @@ function CustomCode(props: JSX.IntrinsicElements["code"]) {
return <code>{props.children}</code>;
}

function ResponsiveTable(props: JSX.IntrinsicElements["table"]) {
return (
<div
className="overflow-x-auto"
style={{
maxWidth: "100%",
width: "100%"
}}
>
<table
{...props}
style={{
...props.style,
width: "max-content",
minWidth: "100%",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: minWidth:100% combined with width:max-content could cause narrow tables to stretch unnecessarily. Consider making minWidth conditional

maxWidth: "100%"
}}
>
{props.children}
</table>
</div>
);
}

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

Expand Down Expand Up @@ -305,6 +329,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