Merge pull request #168 from kolaente/feature/137-custom-icons

Add support for custom icon markup
pull/175/head
Jeroen Akkerman 4 years ago committed by GitHub
commit 6470e10e29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -167,8 +167,13 @@ function createToolbarButton(options, enableActions, enableTooltips, shortcuts,
el.classList.add('no-mobile');
}
// Prevent errors if there is no class name in custom options
var classNameParts = [];
if(typeof options.className !== 'undefined') {
classNameParts = options.className.split(' ');
}
// Provide backwards compatibility with simple-markdown-editor by adding custom classes to the button.
var classNameParts = options.className.split(' ');
var iconClasses = [];
for (var classNameIndex = 0; classNameIndex < classNameParts.length; classNameIndex++) {
var classNamePart = classNameParts[classNameIndex];
@ -191,6 +196,11 @@ function createToolbarButton(options, enableActions, enableTooltips, shortcuts,
}
el.appendChild(icon);
// If there is a custom icon markup set, use that
if (typeof options.icon !== 'undefined') {
el.innerHTML = options.icon;
}
if (options.action && enableActions) {
if (typeof options.action === 'function') {
el.onclick = function (e) {

Loading…
Cancel
Save