Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip checking for disabled keyboard actions in text-editor app #9699

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog/unreleased/enhancement-app-templates
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ This enables developers to more easily create custom apps, and brings unified be
https://github.com/owncloud/web/issues/9302
https://github.com/owncloud/web/issues/9303
https://github.com/owncloud/web/issues/9617
https://github.com/owncloud/web/issues/9695
https://github.com/owncloud/web/pull/9485
https://github.com/owncloud/web/pull/9699
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export default defineComponent({
autosaveIntervalId = null
})

const { bindKeyAction } = useKeyboardActions()
const { bindKeyAction } = useKeyboardActions({ skipDisabledKeyBindingsCheck: true })
bindKeyAction({ modifier: ModifierKey.Ctrl, primary: Key.S }, () => {
if (!unref(isDirty)) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { useEventListener } from '@vueuse/core'
import { Ref, ref, unref } from 'vue'
import * as uuid from 'uuid'

interface KeyboardActionsOptions {
skipDisabledKeyBindingsCheck?: boolean
}

export enum Key {
C = 'c',
V = 'v',
Expand Down Expand Up @@ -65,12 +69,12 @@ const areCustomKeyBindingsDisabled = () => {
return isTextSelected
}

export const useKeyboardActions = (): KeyboardActions => {
export const useKeyboardActions = (options?: KeyboardActionsOptions): KeyboardActions => {
const actions = ref<Array<KeyboardAction>>([])
const selectionCursor = ref(0)

const listener = (event: KeyboardEvent): void => {
if (areCustomKeyBindingsDisabled()) {
if (!options?.skipDisabledKeyBindingsCheck && areCustomKeyBindingsDisabled()) {
return
}

Expand All @@ -81,6 +85,7 @@ export const useKeyboardActions = (): KeyboardActions => {
} else if (shiftKey) {
modifier = ModifierKey.Shift
}

unref(actions)
.filter((action) => {
return action.primary === key && action.modifier === modifier
Expand Down