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.45k stars 319 forks source link

How to remove EasyMDE that is programmatically added? #340

Closed mlab817 closed 3 years ago

mlab817 commented 3 years ago

I am trying to make a feature where when a user clicks on a textarea, EasyMDE is added to that textarea. I am using the following code to do that:

let editor = new EasyMDE({ element: document.getElementById("editor") });

The problem is trying to remove it when I click a cancel button.

let editor = new EasyMDE({ element: document.getElementById("editor") }); editor.toTextArea(); editor = null;

It does remove the first EasyMDE but I'm left with another one.

What am I missing?

mlab817 commented 3 years ago

I guess it's because I'm creating a new instance with the remove editor code.