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

Add buttons to toolbar without removing the defaults #190

Open izzues opened 4 years ago

izzues commented 4 years ago

Is it possible to do that?

Ionaru commented 4 years ago

You can use the showIcons property to show buttons that are normally hidden by default. If you want custom buttons then you'll have to write down the defaults again.

This example uses 3 of the standard buttons and one custom one.

var easyMDE = new EasyMDE({
    toolbar: [
        "bold", 
        {
            name: "custom",
            action: function customFunction(editor){
                // Add your own code
            },
            className: "fa fa-star",
            title: "Custom Button",
        },
        "italic",
        "heading", 
        "|" // Separator
        // [, ...]
    ]
});
izzues commented 4 years ago

Ok, thanks!

So I'll leave this as a suggestion: Expose an object containing all of EasyMDE's default options so I can simply merge them with my own and then pass the result to the constructor! What do you think?

Ionaru commented 4 years ago

That's not a bad idea