-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
Replication steps:
- Format a text in editor 1 in bold
- Move the mouse to editor 2
Actual Result: Bold button in the second editor is selected
Expected Results: only the bold button in the first editor is selected
I added the following code in order to fix this:
getSelectedNode = function ()
{
if (document.selection) {
return document.selection.createRange().parentElement();
}
else
{
var selection = window.getSelection();
if (selection.rangeCount > 0) {
return selection.getRangeAt(0).startContainer.parentNode;
}
}
},
updateToolbar = function () {
if (options.activeToolbarClass) {
$(options.toolbarSelector).find(toolbarBtnSelector).each(function () {
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) && $.contains($(this).closest('.bs-editor')[0], getSelectedNode())) {
$(this).addClass(options.activeToolbarClass);
// Else the command is not active
} else {
$(this).removeClass(options.activeToolbarClass);
}
});
}
},
Metadata
Metadata
Assignees
Labels
No labels