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.39k stars 316 forks source link

Programmatical use of the toolbar functions #345

Closed zwarag closed 3 years ago

zwarag commented 3 years ago

Hi sparksuite, I was wondering if it would be possible to extend easymde so that function such as bold, italic, heading, code, ... could be triggered programmatically.

I like the editor, but I would like to put the toolbar in a different place and style it according to material guidelines. I think the easiest way would be to make the functions public, so that anybody can create their own toolbars.

So my concrete question is, is are you concerns about extending the public functions to trigger said functions externally.

This is not a feature request, I'd do the PR myself.

best regards and thank you for your work 👍

Tazaf commented 3 years ago

Hi @zwarag

You already can trigger those functions programmatically. They are exported by the module. You just need to give them the editor on which to apply the action.

Here's a pseudo-example:

import * as EasyMDE from 'easymde';

const editor = new EasyMDE();

EasyMDE.toggleBold(editor);
zwarag commented 3 years ago

I haven't thought about calling it that way. Thanks for clarifying @Tazaf 👍