Ionaru / easy-markdown-editor

EasyMDE: A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://stackblitz.com/edit/easymde
MIT License
2.32k stars 308 forks source link

Option to disable the MDE #528

Open JoelAShepherd opened 1 year ago

JoelAShepherd commented 1 year ago

I'm using EMDE as part of a form. There are points in the process when I want the MDE to be disabled, so the text is visible but not editable. I can't currently see an option for this

Aloysius999 commented 3 months ago

I have a similar requirement to disable text input in my Next.js project - I'd like to keep the toolbar active since I want for example the Preview button to be visible and enabled so that the user can preview the text but not enter any text changes,

Aloysius999 commented 3 months ago

This is the way to disable input in Next.js:

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

      <SimpleMDE
        id="someid"
        value={somevalue}
        options={mdeOptions}
        events={simpleMDEEvents}
      />