mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-05 17:14:27 -06:00
Add support for custom icon markup
This commit is contained in:
parent
3096bbe291
commit
a12ba4790a
@ -167,7 +167,12 @@ function createToolbarButton(options, enableActions, enableTooltips, shortcuts,
|
|||||||
el.classList.add('no-mobile');
|
el.classList.add('no-mobile');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there is a custom icon, use that
|
||||||
|
if (typeof options.icon !== 'undefined') {
|
||||||
|
el.innerHTML = options.icon;
|
||||||
|
} else {
|
||||||
// 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 = options.className.split(' ');
|
||||||
var iconClasses = [];
|
var iconClasses = [];
|
||||||
for (var classNameIndex = 0; classNameIndex < classNameParts.length; classNameIndex++) {
|
for (var classNameIndex = 0; classNameIndex < classNameParts.length; classNameIndex++) {
|
||||||
@ -190,6 +195,7 @@ function createToolbarButton(options, enableActions, enableTooltips, shortcuts,
|
|||||||
icon.classList.add(iconClass);
|
icon.classList.add(iconClass);
|
||||||
}
|
}
|
||||||
el.appendChild(icon);
|
el.appendChild(icon);
|
||||||
|
}
|
||||||
|
|
||||||
if (options.action && enableActions) {
|
if (options.action && enableActions) {
|
||||||
if (typeof options.action === 'function') {
|
if (typeof options.action === 'function') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user