Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 9 additions & 5 deletions client/src/components/ExerciseParts/ExerciseSearchDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ const ExerciseSearchDialog: React.FC<ExerciseSearchDialogProps> = ({
.map((exercise) => {
const blockIds = selectedBlocks[exercise._id] || [];
const blockDurations: Record<string, number> = {};

// Create mapping of blockId to duration
blockIds.forEach(blockId => {
const block = exercise.description_blocks.find(b => b._id === blockId);
blockIds.forEach((blockId) => {
const block = exercise.description_blocks.find(
(b) => b._id === blockId,
);
if (block) {
blockDurations[blockId] = block.time_min;
}
Expand Down Expand Up @@ -244,8 +246,10 @@ const ExerciseSearchDialog: React.FC<ExerciseSearchDialogProps> = ({
>
<Box flex={1}>
<Typography variant="subtitle2">
{t("block", { defaultValue: "Block" })}{" "}
{index + 1}
{t("block.title", {
blockNumber: index + 1,
defaultValue: "Block {{blockNumber}}",
})}
</Typography>
<Typography
variant="caption"
Expand Down
40 changes: 38 additions & 2 deletions client/src/components/MarkdownRenderer/MarkdownRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,48 @@
import Markdown from "react-markdown";
import { Box } from "@mui/material";
import { useTheme } from "@mui/material/styles";
import MDEditor from "@uiw/react-md-editor";
import "@uiw/react-markdown-preview/markdown.css";
import remarkGfm from "remark-gfm";

interface MarkdownRendererProps {
children: string;
}

const MarkdownRenderer = ({ children }: MarkdownRendererProps) => {
return <Markdown remarkPlugins={[remarkGfm]}>{children}</Markdown>;
const theme = useTheme();

return (
<Box
sx={{
overflowX: "auto",
"& .wmde-markdown": {
backgroundColor: "transparent",
color: "inherit",
fontFamily: "inherit",
},
"& .wmde-markdown > :first-of-type": {
mt: 0,
},
"& .wmde-markdown > :last-child": {
mb: 0,
},
"& .wmde-markdown pre": {
overflowX: "auto",
},
"& .wmde-markdown table": {
display: "block",
maxWidth: "100%",
overflowX: "auto",
},
}}
>
<MDEditor.Markdown
source={children}
remarkPlugins={[remarkGfm]}
wrapperElement={{ "data-color-mode": theme.palette.mode }}
/>
</Box>
);
};

export default MarkdownRenderer;
Loading