Currently if I disable bold for example in the toolbar users can still simply ctrl + b. Ideally disabling it in the toolbar would also disable the specific keyboard shortcut. Currently it looks like you can only disable every keyboard shortcut which is a little much.
I don't necessarily agree that by not including something in the toolbar that the command should be disabled completely. There are scenarios where the toolbar might not even be present, or the toolbar could be completely replaced.
However, I do agree that there should be some way to disable certain keyboard shortcuts. Perhaps a new extension or some modification of the keyboard-commands extension?
Currently, the keyboard-commands extension just allows for mapping keyboard shortcuts to built-in commands. It allows passing a custom configuration to map any key combination to an existing command. However, if you disable the extension completely, there are still browsers that support keyboard commands (ie bold, italic, underline). If we wanted to disable them completely, we'd need to listen in on that combination of keys (ie COMMAND + B) and disable.
Seems like a good candidate for an enhancement, I bet there could be a way to add some functionality to the keyboard-commands extension to support disabling of keyboard shortcuts in addition to mapping keyboard shortcuts to commands...
Hi, any ideas how to do that stuff?
Maybe something like
commands: [
{
command: 'bold',
...
enabled: false
},
@r3verser @renarsvilnis There were some more thoughts about this in #1079 which we've closed as a duplicate of this issue.
Looking at the code I think there's a workaround you could use to prevent the default keyboard shortcuts until the extension is modified to more cleanly support the behavior you're describing.
You can pass in no-op functions as handlers for the commands in the keyboardCommands extension, this will kill the event and then try to execute the handler code, which would do nothing (since it's a no-op).
const config = {
keyboardCommands: {
commands: [
{
command: function () {},
key: 'B',
meta: true,
shift: false,
alt: false
}, {
command: function () {},
key: 'I',
meta: true,
shift: false,
alt: false
}, {
command: function () {},
key: 'U',
meta: true,
shift: false,
alt: false
}
]
}
};
@nmielnik Thanks, seems it's what i need!
A workaround is included here, and this issue actually appears to be a duplicate of #480
Most helpful comment
@nmielnik Thanks, seems it's what i need!