[FIX] web_editor: use styling commands on shortcut too
When pressing the italic or underline buttons, we pass through a command in the editor. Their corresponding keyboard shortcuts however were not intercepted by the editor and were therefore triggering the default browser behavior. As a result we had different behaviors when using the buttons and the shortcuts. X-original-commit: 2e3c3b3a15fa6ff4fa209fc7dbac10864f8898a2 Part-of: odoo/odoo#86930
This commit is contained in:
@@ -70,6 +70,8 @@ const KEYBOARD_TYPES = { VIRTUAL: 'VIRTUAL', PHYSICAL: 'PHYSICAL', UNKNOWN: 'UKN
|
||||
const IS_KEYBOARD_EVENT_UNDO = ev => ev.key === 'z' && (ev.ctrlKey || ev.metaKey);
|
||||
const IS_KEYBOARD_EVENT_REDO = ev => ev.key === 'y' && (ev.ctrlKey || ev.metaKey);
|
||||
const IS_KEYBOARD_EVENT_BOLD = ev => ev.key === 'b' && (ev.ctrlKey || ev.metaKey);
|
||||
const IS_KEYBOARD_EVENT_ITALIC = ev => ev.key === 'i' && (ev.ctrlKey || ev.metaKey);
|
||||
const IS_KEYBOARD_EVENT_UNDERLINE = ev => ev.key === 'u' && (ev.ctrlKey || ev.metaKey);
|
||||
const IS_KEYBOARD_EVENT_STRIKETHROUGH = ev => ev.key === '5' && (ev.ctrlKey || ev.metaKey);
|
||||
|
||||
const CLIPBOARD_BLACKLISTS = {
|
||||
@@ -2362,6 +2364,16 @@ export class OdooEditor extends EventTarget {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
this.execCommand('bold');
|
||||
} else if (IS_KEYBOARD_EVENT_ITALIC(ev)) {
|
||||
// Ctrl-I
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
this.execCommand('italic');
|
||||
} else if (IS_KEYBOARD_EVENT_UNDERLINE(ev)) {
|
||||
// Ctrl-U
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
this.execCommand('underline');
|
||||
} else if (IS_KEYBOARD_EVENT_STRIKETHROUGH(ev)) {
|
||||
// Ctrl-5 / Ctrl-shift-(
|
||||
ev.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user