Fix cut/copy/paste shortcuts not working when menu button has focus

This commit is contained in:
Jos de Jong 2020-07-12 10:53:05 +02:00
parent 65c38f7b05
commit bdc9f3ba34
1 changed files with 18 additions and 18 deletions

View File

@ -410,6 +410,24 @@
function handleKeyDown (event) {
const combo = keyComboFromEvent(event)
const targetIsContentEditableDiv = (
event.target.nodeName === 'DIV' && event.target.contentEditable === 'true')
if (!targetIsContentEditableDiv) {
if (combo === 'Ctrl+X' || combo === 'Command+X') {
event.preventDefault()
handleCut()
}
if (combo === 'Ctrl+C' || combo === 'Command+C') {
event.preventDefault()
handleCopy()
}
if (combo === 'Ctrl+V' || combo === 'Command+V') {
event.preventDefault()
handlePaste()
}
}
if (combo === 'Ctrl+F' || combo === 'Command+F') {
event.preventDefault()
showSearch = true
@ -447,23 +465,6 @@
}
}
}
function handleKeyDownHiddenInput (event) {
const combo = keyComboFromEvent(event)
if (combo === 'Ctrl+X' || combo === 'Command+X') {
event.preventDefault()
handleCut()
}
if (combo === 'Ctrl+C' || combo === 'Command+C') {
event.preventDefault()
handleCopy()
}
if (combo === 'Ctrl+V' || combo === 'Command+V') {
event.preventDefault()
handlePaste()
}
}
</script>
<div class="jsoneditor" on:keydown={handleKeyDown}>
@ -546,7 +547,6 @@
class="hidden-input"
class:visible={!!selection}
bind:this={domHiddenInput}
on:keydown={handleKeyDownHiddenInput}
/>
</label>
<div class="contents" bind:this={divContents}>