mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-18 23:44:29 -06:00
Merge pull request #168 from kolaente/feature/137-custom-icons
Add support for custom icon markup
This commit is contained in:
commit
6470e10e29
@ -167,8 +167,13 @@ function createToolbarButton(options, enableActions, enableTooltips, shortcuts,
|
|||||||
el.classList.add('no-mobile');
|
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.
|
// Provide backwards compatibility with simple-markdown-editor by adding custom classes to the button.
|
||||||
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++) {
|
||||||
var classNamePart = classNameParts[classNameIndex];
|
var classNamePart = classNameParts[classNameIndex];
|
||||||
@ -191,6 +196,11 @@ function createToolbarButton(options, enableActions, enableTooltips, shortcuts,
|
|||||||
}
|
}
|
||||||
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) {
|
||||||
if (typeof options.action === 'function') {
|
if (typeof options.action === 'function') {
|
||||||
el.onclick = function (e) {
|
el.onclick = function (e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user