diff --git a/README.md b/README.md index 479161e..208e940 100644 --- a/README.md +++ b/README.md @@ -355,7 +355,7 @@ const easyMDE = new EasyMDE({ }); ``` -All information and/or add your own icons +All information and/or add your own icons or text ```js const easyMDE = new EasyMDE({ @@ -373,6 +373,7 @@ const easyMDE = new EasyMDE({ // Add your own code }, className: "fa fa-star", + text: "Starred", title: "Custom Button", attributes: { // for custom attributes id: "custom-id", diff --git a/src/css/easymde.css b/src/css/easymde.css index c1bbe4b..ec7e5f6 100644 --- a/src/css/easymde.css +++ b/src/css/easymde.css @@ -140,7 +140,10 @@ } .editor-toolbar button { - width: 30px; + font-weight: bold; + min-width: 30px; + padding: 0 6px; + white-space: nowrap; } .editor-toolbar button.active, @@ -365,6 +368,10 @@ visibility: visible; } +.easymde-dropdown-content button { + display: block; +} + span[data-img-src]::after { content: ''; /*noinspection CssUnresolvedCustomProperty, added through JS*/ diff --git a/src/js/easymde.js b/src/js/easymde.js index 64270e4..40de328 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -242,7 +242,11 @@ function createToolbarButton(options, enableActions, enableTooltips, shortcuts, el.setAttribute('type', markup); enableTooltips = (enableTooltips == undefined) ? true : enableTooltips; - // Properly hande custom shortcuts + if (options.text) { + el.innerText = options.text; + } + + // Properly handle custom shortcuts if (options.name && options.name in shortcuts) { bindings[options.name] = options.action; } @@ -289,13 +293,15 @@ function createToolbarButton(options, enableActions, enableTooltips, shortcuts, el.tabIndex = -1; - // Create icon element and append as a child to the button - var icon = document.createElement('i'); - for (var iconClassIndex = 0; iconClassIndex < iconClasses.length; iconClassIndex++) { - var iconClass = iconClasses[iconClassIndex]; - icon.classList.add(iconClass); + if (iconClasses.length > 0) { + // Create icon element and append as a child to the button + var icon = document.createElement('i'); + for (var iconClassIndex = 0; iconClassIndex < iconClasses.length; iconClassIndex++) { + var iconClass = iconClasses[iconClassIndex]; + 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') {