From 4aadf69a8b5fdc3147ef330c36dccf3406ca0085 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 20 Jun 2024 09:48:21 +0200 Subject: [PATCH] Prevent hotkeys in contenteditable element --- client/src/app/core/hotkeys/hotkeys.service.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/src/app/core/hotkeys/hotkeys.service.ts b/client/src/app/core/hotkeys/hotkeys.service.ts index 9db8c9512..82bfb87e2 100644 --- a/client/src/app/core/hotkeys/hotkeys.service.ts +++ b/client/src/app/core/hotkeys/hotkeys.service.ts @@ -1,10 +1,10 @@ // Thanks to https://github.com/brtnshrdr/angular2-hotkeys import { Injectable, NgZone } from '@angular/core' -import { Hotkey } from './hotkey.model' +import debug from 'debug' import { Subject } from 'rxjs' import { tinykeys } from 'tinykeys' -import debug from 'debug' +import { Hotkey } from './hotkey.model' const debugLogger = debug('peertube:hotkeys') @@ -13,7 +13,8 @@ export class HotkeysService { cheatSheetToggle = new Subject() private hotkeys: Hotkey[] = [] - private preventIn = [ 'INPUT', 'SELECT', 'TEXTAREA' ] + private readonly preventIn = new Set([ 'INPUT', 'SELECT', 'TEXTAREA' ]) + private readonly preventAttribute = new Set([ 'INPUT', 'SELECT', 'TEXTAREA' ]) private disabled = false @@ -59,10 +60,10 @@ export class HotkeysService { [combo]: event => { if (this.disabled) return - const target = event.target as Element + const target = event.target as HTMLElement const nodeName: string = target.nodeName.toUpperCase() - if (this.preventIn.includes(nodeName)) { + if (target.isContentEditable || this.preventIn.has(nodeName)) { return }