Merge pull request #12917 from ArtemDzhereleiko/AD/bug-fix/hot-key-event

Fixed default events and add hot keys for Mac
This commit is contained in:
Igor Kulikov 2025-03-13 19:29:49 +02:00 committed by GitHub
commit 1f9de54796
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -174,66 +174,71 @@ export class DashboardLayoutComponent extends PageComponent implements ILayoutCo
private initHotKeys(): void { private initHotKeys(): void {
this.hotKeys.push( this.hotKeys.push(
new Hotkey('ctrl+c', (event: KeyboardEvent) => { new Hotkey(['ctrl+c', 'meta+c'], (event: KeyboardEvent) => {
if (this.isEdit && !this.isEditingWidget && !this.widgetEditMode) { if (this.isEdit && !this.isEditingWidget && !this.widgetEditMode) {
const widget = this.dashboard.getSelectedWidget(); const widget = this.dashboard.getSelectedWidget();
if (widget) { if (widget) {
event.preventDefault(); event.preventDefault();
this.copyWidget(event, widget); this.copyWidget(event, widget);
} }
}
return false; return false;
}
return true;
}, null, }, null,
this.translate.instant('action.copy')) this.translate.instant('action.copy'))
); );
this.hotKeys.push( this.hotKeys.push(
new Hotkey('ctrl+r', (event: KeyboardEvent) => { new Hotkey(['ctrl+r', 'meta+r'], (event: KeyboardEvent) => {
if (this.isEdit && !this.isEditingWidget && !this.widgetEditMode) { if (this.isEdit && !this.isEditingWidget && !this.widgetEditMode) {
const widget = this.dashboard.getSelectedWidget(); const widget = this.dashboard.getSelectedWidget();
if (widget) { if (widget) {
event.preventDefault(); event.preventDefault();
this.copyWidgetReference(event, widget); this.copyWidgetReference(event, widget);
} }
}
return false; return false;
}
return true;
}, null, }, null,
this.translate.instant('action.copy-reference')) this.translate.instant('action.copy-reference'))
); );
this.hotKeys.push( this.hotKeys.push(
new Hotkey('ctrl+v', (event: KeyboardEvent) => { new Hotkey(['ctrl+v', 'meta+v'], (event: KeyboardEvent) => {
if (this.isEdit && !this.isEditingWidget && !this.widgetEditMode) { if (this.isEdit && !this.isEditingWidget && !this.widgetEditMode) {
if (this.itembuffer.hasWidget()) { if (this.itembuffer.hasWidget()) {
event.preventDefault(); event.preventDefault();
this.pasteWidget(event); this.pasteWidget(event);
} }
}
return false; return false;
}
return true;
}, null, }, null,
this.translate.instant('action.paste')) this.translate.instant('action.paste'))
); );
this.hotKeys.push( this.hotKeys.push(
new Hotkey('ctrl+i', (event: KeyboardEvent) => { new Hotkey(['ctrl+i', 'meta+i'], (event: KeyboardEvent) => {
if (this.isEdit && !this.isEditingWidget && !this.widgetEditMode) { if (this.isEdit && !this.isEditingWidget && !this.widgetEditMode) {
if (this.itembuffer.canPasteWidgetReference(this.dashboardCtx.getDashboard(), if (this.itembuffer.canPasteWidgetReference(this.dashboardCtx.getDashboard(),
this.dashboardCtx.state, this.layoutCtx.id, this.layoutCtx.breakpoint)) { this.dashboardCtx.state, this.layoutCtx.id, this.layoutCtx.breakpoint)) {
event.preventDefault(); event.preventDefault();
this.pasteWidgetReference(event); this.pasteWidgetReference(event);
} }
}
return false; return false;
}
return true;
}, null, }, null,
this.translate.instant('action.paste-reference')) this.translate.instant('action.paste-reference'))
); );
this.hotKeys.push( this.hotKeys.push(
new Hotkey('ctrl+x', (event: KeyboardEvent) => { new Hotkey(['ctrl+x', 'meta+x'], (event: KeyboardEvent) => {
if (this.isEdit && !this.isEditingWidget && !this.widgetEditMode) { if (this.isEdit && !this.isEditingWidget && !this.widgetEditMode) {
const widget = this.dashboard.getSelectedWidget(); const widget = this.dashboard.getSelectedWidget();
if (widget) { if (widget) {
event.preventDefault(); event.preventDefault();
this.layoutCtx.dashboardCtrl.removeWidget(event, this.layoutCtx, widget); this.layoutCtx.dashboardCtrl.removeWidget(event, this.layoutCtx, widget);
} }
}
return false; return false;
}
return true;
}, null, }, null,
this.translate.instant('action.delete')) this.translate.instant('action.delete'))
); );