diff --git a/bootstrap-wysiwyg.js b/bootstrap-wysiwyg.js index 69f64a7..d7cbfc3 100644 --- a/bootstrap-wysiwyg.js +++ b/bootstrap-wysiwyg.js @@ -26,9 +26,16 @@ updateToolbar = function () { if (options.activeToolbarClass) { $(options.toolbarSelector).find(toolbarBtnSelector).each(function () { - var command = $(this).data(options.commandRole); - if (document.queryCommandState(command)) { + var commandArr = $(this).data(options.commandRole).split(' '), + command = commandArr[0]; + + // If the command has an argument and its value matches this button. == used for string/number comparison + if (commandArr.length > 1 && document.queryCommandEnabled(command) && document.queryCommandValue(command) == commandArr[1]) { + $(this).addClass(options.activeToolbarClass); + // Else if the command has no arguments and it is active + } else if (commandArr.length === 1 && document.queryCommandEnabled(command) && document.queryCommandState(command)) { $(this).addClass(options.activeToolbarClass); + // Else the command is not active } else { $(this).removeClass(options.activeToolbarClass); }