mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-08 18:39:40 +00:00
Support redo on Shift+CMD+Z (#27287)
* Support redo on Shift+CMD+Z * Update redo shortcut for macOS to CMD+Shift+Z
This commit is contained in:
committed by
Bram Kragten
parent
e4f008800b
commit
ac49fc7aba
@@ -12,11 +12,11 @@ export const KeyboardShortcutMixin = <T extends Constructor<LitElement>>(
|
||||
class extends superClass {
|
||||
private _keydownEvent = (event: KeyboardEvent) => {
|
||||
const supportedShortcuts = this.supportedShortcuts();
|
||||
const key = event.shiftKey ? event.key.toUpperCase() : event.key;
|
||||
if (
|
||||
(event.ctrlKey || event.metaKey) &&
|
||||
!event.shiftKey &&
|
||||
!event.altKey &&
|
||||
event.key in supportedShortcuts
|
||||
key in supportedShortcuts
|
||||
) {
|
||||
// Only capture the event if the user is not focused on an input
|
||||
if (!canOverrideAlphanumericInput(event.composedPath())) {
|
||||
@@ -27,14 +27,14 @@ export const KeyboardShortcutMixin = <T extends Constructor<LitElement>>(
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
supportedShortcuts[event.key]();
|
||||
supportedShortcuts[key]();
|
||||
return;
|
||||
}
|
||||
|
||||
const supportedSingleKeyShortcuts = this.supportedSingleKeyShortcuts();
|
||||
if (event.key in supportedSingleKeyShortcuts) {
|
||||
if (key in supportedSingleKeyShortcuts) {
|
||||
event.preventDefault();
|
||||
supportedSingleKeyShortcuts[event.key]();
|
||||
supportedSingleKeyShortcuts[key]();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -261,9 +261,16 @@ export class HaAutomationEditor extends UndoRedoMixin<
|
||||
<ha-tooltip placement="bottom" for="button-redo">
|
||||
${this.hass.localize("ui.common.redo")}
|
||||
<span class="shortcut">
|
||||
(<span>${shortcutIcon}</span>
|
||||
<span>+</span>
|
||||
<span>Y</span>)
|
||||
(
|
||||
${isMac
|
||||
? html`<span>${shortcutIcon}</span>
|
||||
<span>+</span>
|
||||
<span>Shift</span>
|
||||
<span>+</span>
|
||||
<span>Z</span>`
|
||||
: html`<span>${shortcutIcon}</span>
|
||||
<span>+</span>
|
||||
<span>Y</span>`})
|
||||
</span>
|
||||
</ha-tooltip>`
|
||||
: nothing}
|
||||
@@ -1196,6 +1203,7 @@ export class HaAutomationEditor extends UndoRedoMixin<
|
||||
Delete: () => this._deleteSelectedRow(),
|
||||
Backspace: () => this._deleteSelectedRow(),
|
||||
z: () => this.undo(),
|
||||
Z: () => this.redo(),
|
||||
y: () => this.redo(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -212,10 +212,17 @@ export class HaScriptEditor extends UndoRedoMixin<
|
||||
</ha-icon-button>
|
||||
<ha-tooltip placement="bottom" for="button-redo">
|
||||
${this.hass.localize("ui.common.redo")}
|
||||
<span class="shortcut">
|
||||
(<span>${shortcutIcon}</span>
|
||||
<span>+</span>
|
||||
<span>Y</span>)
|
||||
<span class="shortcut"
|
||||
>(
|
||||
${isMac
|
||||
? html`<span>${shortcutIcon}</span>
|
||||
<span>+</span>
|
||||
<span>Shift</span>
|
||||
<span>+</span>
|
||||
<span>Z</span>`
|
||||
: html`<span>${shortcutIcon}</span>
|
||||
<span>+</span>
|
||||
<span>Y</span>`})
|
||||
</span>
|
||||
</ha-tooltip>`
|
||||
: nothing}
|
||||
@@ -1104,6 +1111,7 @@ export class HaScriptEditor extends UndoRedoMixin<
|
||||
Delete: () => this._deleteSelectedRow(),
|
||||
Backspace: () => this._deleteSelectedRow(),
|
||||
z: () => this.undo(),
|
||||
Z: () => this.redo(),
|
||||
y: () => this.redo(),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user