mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 11:01:34 +08:00
Avoid scrolling to cursor when Control/Alt/Shift/Escape is hit
This behavior now matches other editors
This commit is contained in:
parent
03afc1ec29
commit
fc26306b7e
@ -54,7 +54,12 @@ export const EVENT_KEYS = Object.freeze(generateKeyHash([
|
||||
'ArrowLeft',
|
||||
'ArrowRight',
|
||||
'Tab',
|
||||
'Escape'
|
||||
'Escape',
|
||||
'Control',
|
||||
'Alt',
|
||||
'Shift',
|
||||
'PageUp',
|
||||
'PageDown'
|
||||
]))
|
||||
|
||||
export const LOWERCASE_TAGS = Object.freeze(generateKeyHash([
|
||||
|
@ -68,6 +68,10 @@ class Keyboard {
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (event.key === EVENT_KEYS.Control || event.key === EVENT_KEYS.Alt || event.key === EVENT_KEYS.Escape || event.key === EVENT_KEYS.Shift || event.key === EVENT_KEYS.PageUp || event.key === EVENT_KEYS.PageDown) { // we don't want to focus on the cursor if the user just hits one of these keys. Other editors do not.
|
||||
return
|
||||
}
|
||||
|
||||
// Cursor outside editor area or over not editable elements.
|
||||
if (event.target.closest('[contenteditable=false]')) {
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user