easy-markdown-editor
easy-markdown-editor copied to clipboard
Replace toolbar without recreating EasyMDE instance
After the editor has been created, I need to pass new functions to custom buttons on the toolbar.
I'd like to do something like:
instance.setToolbar(myNewToolbar)
or
instance.createToolbar(myNewToolbar, { replaceExisting: true })
Currently, my workaround looks like:
const toolbar = createToolbar(...)
const existingToolbar = document.getElementsByClassName(`editor-toolbar`)
if (existingToolbar) {
for (const element of existingToolbar) {
element.remove()
}
}
if (instance) {
(instance as any).createToolbar(toolbar)
}
The problem with my solution is that it breaks .toTextArea() method, and it could lead to unexpected behaviour.
I also like to replace the previewRender function is possible.
Many thanks Ionaru for maintaining the project!