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