1
0

fix(editor): don't use global shortcut when anything is focused

This commit is contained in:
kolaente
2023-10-22 12:48:31 +02:00
parent f6d5cbcf6f
commit 32ca8853bc
2 changed files with 6 additions and 17 deletions

View File

@ -177,7 +177,6 @@ import BaseButton from '@/components/base/BaseButton.vue'
import XButton from '@/components/input/button.vue'
import {Placeholder} from '@tiptap/extension-placeholder'
import {eventToHotkeyString} from '@github/hotkey'
import {useBaseStore} from '@/stores/base'
import {mergeAttributes} from '@tiptap/core'
import {createRandomID} from '@/helpers/randomId'
@ -271,8 +270,6 @@ const {
initialMode?: Mode,
}>()
const baseStore = useBaseStore()
const emit = defineEmits(['update:modelValue', 'save'])
const inputHTML = ref('')
@ -402,12 +399,6 @@ const editor = useEditor({
// JSON
// this.$emit('update:modelValue', this.editor.getJSON())
},
onFocus() {
baseStore.setEditorFocused(true)
},
onBlur() {
baseStore.setEditorFocused(false)
},
})
watch(
@ -529,7 +520,12 @@ function handleImagePaste(event) {
function setFocusToEditor(event) {
const hotkeyString = eventToHotkeyString(event)
if (!hotkeyString) return
if (hotkeyString !== editShortcut || baseStore.editorFocused) return
if (hotkeyString !== editShortcut ||
event.target.tagName.toLowerCase() === 'input' ||
event.target.tagName.toLowerCase() === 'textarea' ||
event.target.contentEditable === 'true') {
return
}
event.preventDefault()
if (initialMode === 'preview' && isEditEnabled && !isEditing.value) {