diff --git a/README.md b/README.md index 2a13104..59e129b 100644 --- a/README.md +++ b/README.md @@ -377,6 +377,10 @@ const easyMDE = new EasyMDE({ }, className: "fa fa-star", title: "Custom Button", + attributes: { // for custom attributes + id: "custom-id", + "data-value": "custom value" // HTML5 data-* attributes need to be enclosed in quotation marks ("") because of the dash (-) in its name. + } }, "|" // Separator // [, ...] diff --git a/src/js/easymde.js b/src/js/easymde.js index 3ee79e1..5016318 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -231,6 +231,12 @@ function createToolbarButton(options, enableActions, enableTooltips, shortcuts, } } + if (options.attributes) { + for (var attribute in options.attributes) { + el.setAttribute(attribute, options.attributes[attribute]); + } + } + if (options.noDisable) { el.classList.add('no-disable'); }