Skip to content

Commit 32599af

Browse files
committed
Add option to insert additional icons in SMDE
1 parent d5e285f commit 32599af

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/js/simplemde.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,12 @@ function SimpleMDE(options) {
13271327
}
13281328
}
13291329

1330+
// Add custom toolbar actions
1331+
if (options.additionalToolbarButtons !== undefined) {
1332+
for (var index in options.additionalToolbarButtons) {
1333+
options.toolbar.push(options.additionalToolbarButtons[index]);
1334+
}
1335+
}
13301336

13311337
// Handle status bar
13321338
if(!options.hasOwnProperty("status")) {
@@ -1686,11 +1692,9 @@ SimpleMDE.prototype.createToolbar = function(items) {
16861692
// Don't include trailing separators
16871693
if(items[i] === "|") {
16881694
var nonSeparatorIconsFollow = false;
1689-
1690-
for(var x = (i + 1); x < items.length; x++) {
1691-
if(items[x] !== "|" && (!self.options.hideIcons || self.options.hideIcons.indexOf(items[x].name) == -1)) {
1692-
nonSeparatorIconsFollow = true;
1693-
}
1695+
var x = Math.min(i + 1, items.length - 1);
1696+
if(items[x] !== "|" && (!self.options.hideIcons || self.options.hideIcons.indexOf(items[x].name) == -1)) {
1697+
nonSeparatorIconsFollow = true;
16941698
}
16951699

16961700
if(!nonSeparatorIconsFollow)
@@ -2025,4 +2029,4 @@ SimpleMDE.prototype.toTextArea = function() {
20252029
}
20262030
};
20272031

2028-
module.exports = SimpleMDE;
2032+
module.exports = SimpleMDE;

0 commit comments

Comments
 (0)