1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-26 00:27:28 +02:00

Fix missing isAltKey (#855)

This commit is contained in:
Leon Koole
2017-05-30 22:15:11 +02:00
committed by Ian Storm Taylor
parent 890d790d42
commit b6541854fa

View File

@@ -69,7 +69,7 @@ In this case our plugin object will have one property: a `onKeyDown` handler, wi
```js ```js
function MarkHotkey(options) { function MarkHotkey(options) {
const { type, code } = options const { type, code, isAltKey = false } = options
// Return our "plugin" object, containing the `onKeyDown` handler. // Return our "plugin" object, containing the `onKeyDown` handler.
return { return {
@@ -212,12 +212,12 @@ import keycode from `keycode`
function MarkHotkey(options) { function MarkHotkey(options) {
// Change the options to take a `key`. // Change the options to take a `key`.
const { type, key } = options const { type, key, isAltKey = false } = options
return { return {
onKeyDown(event, data, state) { onKeyDown(event, data, state) {
// Change the comparison to use the key name. // Change the comparison to use the key name.
if (!event.metaKey || keycode(event.which) != key) return if (!event.metaKey || keycode(event.which) != key || event.altKey != isAltKey) return
event.preventDefault() event.preventDefault()
return state return state
.transform() .transform()