Default markdown editors to preview mode

- Open markdown editors in the rendered preview state instead of raw markdown by default.
- Preserve edit and live views through the editor toolbar.
- Keep the `preview` prop overridable by callers because it is spread after the default.
This commit is contained in:
Brian Fertig 2026-09-21 11:04:08 -06:00
parent f7cbcb793c
commit 323589f281
1 changed files with 10 additions and 1 deletions

View File

@ -9,7 +9,16 @@ import type { RehypeRewriteOptions } from "rehype-rewrite";
// out of the initial board bundle. Shared here so every place that needs
// markdown (group notes, to-do details) uses the exact same editor/preview
// widgets instead of each declaring its own dynamic import.
export const MDEditor = dynamic(() => import("@uiw/react-md-editor"), { ssr: false });
const RawMDEditor = dynamic(() => import("@uiw/react-md-editor"), { ssr: false });
// `preview` only seeds the editor's initial mode -- @uiw/react-md-editor
// owns it as internal state after that, flipped by the edit/live/preview
// toolbar buttons. Defaulting it to "preview" opens every editor rendered
// instead of raw markdown, while the toolbar still lets someone drop into
// "edit" (or the split "live" view) when they want granular control.
export function MDEditor(props: ComponentProps<typeof RawMDEditor>) {
return <RawMDEditor preview="preview" {...props} />;
}
const RawMarkdownPreview = dynamic(
() => import("@uiw/react-md-editor").then((mod) => mod.default.Markdown),