forked from vikunja/frontend
fix(editor): don't use global shortcut when anything is focused
This commit is contained in:
parent
f6d5cbcf6f
commit
32ca8853bc
@ -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) {
|
||||
|
@ -30,7 +30,6 @@ export const useBaseStore = defineStore('base', () => {
|
||||
const quickActionsActive = ref(false)
|
||||
const logoVisible = ref(true)
|
||||
const updateAvailable = ref(false)
|
||||
const editorFocused = ref(false) // To allow tracking over multiple instances of the editor
|
||||
|
||||
function setLoading(newLoading: boolean) {
|
||||
loading.value = newLoading
|
||||
@ -93,10 +92,6 @@ export const useBaseStore = defineStore('base', () => {
|
||||
updateAvailable.value = value
|
||||
}
|
||||
|
||||
function setEditorFocused(value: boolean) {
|
||||
editorFocused.value = value
|
||||
}
|
||||
|
||||
async function handleSetCurrentProject(
|
||||
{project, forceUpdate = false}: {project: IProject | null, forceUpdate?: boolean},
|
||||
) {
|
||||
@ -155,7 +150,6 @@ export const useBaseStore = defineStore('base', () => {
|
||||
quickActionsActive: readonly(quickActionsActive),
|
||||
logoVisible: readonly(logoVisible),
|
||||
updateAvailable: readonly(updateAvailable),
|
||||
editorFocused: readonly(editorFocused),
|
||||
|
||||
setLoading,
|
||||
setReady,
|
||||
@ -167,7 +161,6 @@ export const useBaseStore = defineStore('base', () => {
|
||||
setBlurHash,
|
||||
setLogoVisible,
|
||||
setUpdateAvailable,
|
||||
setEditorFocused,
|
||||
|
||||
handleSetCurrentProject,
|
||||
loadApp,
|
||||
|
Loading…
x
Reference in New Issue
Block a user