Skip to content

Commit

Permalink
Merge pull request #461 from vanillajonathan/patch-12
Browse files Browse the repository at this point in the history
  • Loading branch information
Ionaru committed May 22, 2022
2 parents eb51f0f + 554112b commit e57c16b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -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({
Expand All @@ -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",
Expand Down
9 changes: 8 additions & 1 deletion src/css/easymde.css
Expand Up @@ -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,
Expand Down Expand Up @@ -365,6 +368,10 @@
visibility: visible;
}

.easymde-dropdown-content button {
display: block;
}

span[data-img-src]::after {
content: '';
/*noinspection CssUnresolvedCustomProperty, added through JS*/
Expand Down
20 changes: 13 additions & 7 deletions src/js/easymde.js
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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') {
Expand Down

0 comments on commit e57c16b

Please sign in to comment.