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:
parent
f7cbcb793c
commit
323589f281
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Reference in New Issue