sparksuite / simplemde-markdown-editor

A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://simplemde.com
MIT License
9.79k stars 1.12k forks source link

Preview by default in NextJS #851

Open Aloysius999 opened 2 weeks ago

Aloysius999 commented 2 weeks ago

I've used successfully SimpleMDE in my NextJS project

import "easymde/dist/easymde.min.css";
import dynamic from "next/dynamic";
import { SimpleMdeToCodemirrorEvents } from "react-simplemde-editor";

const SimpleMDE = dynamic(() => import("react-simplemde-editor"), {
  ssr: false,
});

const mdeOptions = useMemo(() => {
  return {
    autofocus: true,
    toolbar: ["preview"],
    showIcons: [],
    hideIcons: [],
    status: false,
    initialValue: "hello world",
  } as EasyMDE.Options;
}, []);

const [simpleMDEEvents, setSimpleMDEEvents] =
  useState<SimpleMdeToCodemirrorEvents>({
    beforeChange: (instance: any, changeObj: any) => {
      console.log("beforeChange", changeObj);
      changeObj.canceled = true;
    },
  });

<SimpleMDE
  id="messageBody"
  // defaultValue={props.message}
  value={props.message}
  options={mdeOptions}
  events={simpleMDEEvents}
/>

But what I'd really like to do is open SimpleMDE in preview mode to use a markup viewer.

How can I do this?

Thanks