2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-07-18 23:44:29 -06:00

Fix for issue #380 Custom attributes for toolbar buttons

Added "attributes" option to custom toolbar button
This commit is contained in:
Zignature 2022-01-11 11:00:56 +01:00
parent 59a676bc8a
commit a9d9993dae
2 changed files with 10 additions and 0 deletions

View File

@ -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
// [, ...]

View File

@ -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');
}