mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-15 14:04:28 -06:00
Also still add custom classes when using custom icon markup
This commit is contained in:
parent
85e59747ab
commit
cc0706bfc2
@ -167,12 +167,14 @@ function createToolbarButton(options, enableActions, enableTooltips, shortcuts,
|
|||||||
el.classList.add('no-mobile');
|
el.classList.add('no-mobile');
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a custom icon, use that
|
// Prevent errors if there is no class name in custom options
|
||||||
if (typeof options.icon !== 'undefined') {
|
var className = '';
|
||||||
el.innerHTML = options.icon;
|
if(typeof options.className !== 'undefined') {
|
||||||
} else {
|
className = options.className;
|
||||||
|
}
|
||||||
|
|
||||||
// Provide backwards compatibility with simple-markdown-editor by adding custom classes to the button.
|
// Provide backwards compatibility with simple-markdown-editor by adding custom classes to the button.
|
||||||
var classNameParts = options.className.split(' ');
|
var classNameParts = className.split(' ');
|
||||||
var iconClasses = [];
|
var iconClasses = [];
|
||||||
for (var classNameIndex = 0; classNameIndex < classNameParts.length; classNameIndex++) {
|
for (var classNameIndex = 0; classNameIndex < classNameParts.length; classNameIndex++) {
|
||||||
var classNamePart = classNameParts[classNameIndex];
|
var classNamePart = classNameParts[classNameIndex];
|
||||||
@ -194,6 +196,10 @@ function createToolbarButton(options, enableActions, enableTooltips, shortcuts,
|
|||||||
icon.classList.add(iconClass);
|
icon.classList.add(iconClass);
|
||||||
}
|
}
|
||||||
el.appendChild(icon);
|
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 (options.action && enableActions) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user