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

Preview by default in NextJS #851

Open
Aloysius999 opened this issue Jun 12, 2024 · 0 comments
Open

Preview by default in NextJS #851

Aloysius999 opened this issue Jun 12, 2024 · 0 comments

Comments

@Aloysius999
Copy link

Aloysius999 commented Jun 12, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant