Fix cut/copy/paste shortcuts not working when menu button has focus
This commit is contained in:
parent
65c38f7b05
commit
bdc9f3ba34
|
@ -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}>
|
||||
|
|
Loading…
Reference in New Issue