Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM] use uiw editor #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* for Docker builds.
*/
await import("./src/env.mjs");
import removeImports from 'next-remove-imports';

/** @type {import("next").NextConfig} */
const config = {
Expand All @@ -19,4 +20,4 @@ const config = {
},
};

export default config;
export default removeImports({})(config);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@trpc/next": "^10.37.1",
"@trpc/react-query": "^10.37.1",
"@trpc/server": "^10.37.1",
"@uiw/react-md-editor": "^4.0.1",
"async-mutex": "^0.4.0",
"flowbite": "^2.1.1",
"flowbite-react": "^0.6.4",
Expand Down
21 changes: 18 additions & 3 deletions src/components/MarkdownEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
import React, { type FC } from "react";
import { MdEditor } from "md-editor-rt";
import "md-editor-rt/lib/style.css";
import "@uiw/react-md-editor/markdown-editor.css";
import "@uiw/react-markdown-preview/markdown.css";
import dynamic from "next/dynamic";
import * as commands from "@uiw/react-md-editor/commands"

type MarkdownEditorProps = {
text: string;
setText: (text: string) => void;
};

const MDEditor = dynamic(
() => import("@uiw/react-md-editor"),
{ ssr: false }
);

const MarkdownEditor: FC<MarkdownEditorProps> = ({ text, setText }) => {
return <MdEditor modelValue={text} onChange={setText} language="en-US" />;
const handleOnChange = (e?: string) => {
setText(e ?? "");
}
return (
<div className="container">
<MDEditor value={text} onChange={handleOnChange} commands={[
commands.codeEdit, commands.codePreview
]} />
</div>);
};

export default MarkdownEditor;