Jotzy/frontend/src/pages/Markdown.tsx

69 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-11-23 09:08:01 +00:00
// src/pages/TestPage.tsx
import { FC } from "react";
import Markdown from "react-markdown";
import { MDXEditor, SandpackConfig } from "@mdxeditor/editor";
import {
headingsPlugin,
listsPlugin,
quotePlugin,
thematicBreakPlugin,
linkPlugin,
codeBlockPlugin,
codeMirrorPlugin,
sandpackPlugin,
markdownShortcutPlugin,
toolbarPlugin,
BoldItalicUnderlineToggles,
} from "@mdxeditor/editor";
import "@mdxeditor/editor/style.css";
const simpleSandpackConfig: SandpackConfig = {
defaultPreset: "react",
presets: [
{
label: "React",
name: "react",
meta: "live react",
sandpackTemplate: "react",
sandpackTheme: "dark",
snippetFileName: "/App.js",
snippetLanguage: "jsx",
},
],
};
export const MarkdownPage: FC = () => {
const markdown = `
# This is *perfect*!
- TestPage
- te
`;
return (
<MDXEditor
markdown={markdown}
plugins={[
toolbarPlugin({
toolbarClassName: "my-class",
toolbarContents: () => (
<>
<BoldItalicUnderlineToggles />
</>
),
}),
headingsPlugin(),
listsPlugin(),
quotePlugin(),
thematicBreakPlugin(),
linkPlugin(),
codeBlockPlugin({ defaultCodeBlockLanguage: "js" }),
sandpackPlugin({ sandpackConfig: simpleSandpackConfig }),
codeMirrorPlugin({
codeBlockLanguages: { js: "JavaScript", css: "CSS" },
}),
markdownShortcutPlugin(),
]}
/>
);
};