Tastenkürzel-Plugin
Das Tastenkürzel-Plugin aktiviert globale Tastaturbefehle für Navigation, Terminverwaltung und Zwischenablage.
Installation
Installieren Sie das Plugin-Paket:
npm install @dayflow/plugin-keyboard-shortcuts
pnpm add @dayflow/plugin-keyboard-shortcuts
yarn add @dayflow/plugin-keyboard-shortcuts
bun add @dayflow/plugin-keyboard-shortcuts
Verwendung
import { useCalendarApp, DayFlowCalendar } from '@dayflow/react';
import { createKeyboardShortcutsPlugin } from '@dayflow/plugin-keyboard-shortcuts';
function MyCalendar() {
const calendar = useCalendarApp({
views: [
/* your views */
],
plugins: [
createKeyboardShortcutsPlugin({
// Optional configuration
}),
],
});
return <DayFlowCalendar calendar={calendar} />;
}<template>
<DayFlowCalendar :calendar="calendar" />
</template>
<script setup>
import { DayFlowCalendar, useCalendarApp } from '@dayflow/vue';
import { createKeyboardShortcutsPlugin } from '@dayflow/plugin-keyboard-shortcuts';
const calendar = useCalendarApp({
views: [
/* your views */
],
plugins: [
createKeyboardShortcutsPlugin({
// Optional configuration
}),
],
});
</script>import { Component } from '@angular/core';
import { DayFlowCalendarModule } from '@dayflow/angular';
import { createKeyboardShortcutsPlugin } from '@dayflow/plugin-keyboard-shortcuts';
@Component({
selector: 'app-root',
standalone: true,
imports: [DayFlowCalendarModule],
template: `<dayflow-calendar [calendar]="calendar"></dayflow-calendar>`
})
export class AppComponent {
calendar = {
views: [
/* your views */
],
plugins: [
createKeyboardShortcutsPlugin({
// Optional configuration
})
]
};
}<script>
import { DayFlowCalendar, useCalendarApp } from '@dayflow/svelte';
import { createKeyboardShortcutsPlugin } from '@dayflow/plugin-keyboard-shortcuts';
const calendar = useCalendarApp({
views: [
/* your views */
],
plugins: [
createKeyboardShortcutsPlugin({
// Optional configuration
}),
],
});
</script>
<DayFlowCalendar {calendar} />Standard-Tastenkürzel
| Aktion | Taste (Mac) | Taste (Windows/Linux) |
|---|---|---|
| Zu heute springen | Cmd + T | Ctrl + T |
| Suchen | Cmd + F | Ctrl + F |
| Neuer Termin | Cmd + N | Ctrl + N |
| Navigation | ArrowLeft / ArrowRight | ArrowLeft / ArrowRight |
| Termine durchtabben | Tab / Shift + Tab | Tab / Shift + Tab |
| Rückgängig | Cmd + Z | Ctrl + Z |
| Wiederholen | Cmd + Shift + Z / Cmd + Y | Ctrl + Y |
| Termin kopieren | Cmd + C | Ctrl + C |
| Termin ausschneiden | Cmd + X | Ctrl + X |
| Termin einfügen | Cmd + V | Ctrl + V |
| Termin löschen | Backspace / Delete | Backspace / Delete |
| Dialoge und Panels schließen | Esc | Esc |
Konfiguration
Sie können die Tastenbelegung anpassen und für jede Aktion eigene Callbacks hinterlegen:
createKeyboardShortcutsPlugin({
keyMap: {
today: 't',
search: 'f',
prev: 'ArrowLeft',
next: 'ArrowRight',
undo: 'z',
redo: 'y',
delete: 'Delete',
newEvent: 'n',
},
callbacks: {
undo: app => {
console.log('Custom undo logic');
app.undo();
},
redo: app => {
console.log('Custom redo logic');
if (app.redo) app.redo();
},
delete: app => {
if (confirm('Are you sure?')) {
const selectedId = app.state.selectedEventId;
if (selectedId) app.deleteEvent(selectedId);
}
},
},
});Verfügbare Callbacks
Im Objekt callbacks werden folgende Einträge unterstützt:
undo,redo,paste(erhaltenapp)copy,cut,delete(erhaltenappundevent?: Event)today,search,prev,next,newEvent,dismiss(erhaltenapp)tab(erhältappundreverse: boolean)
Plugin-API
Über den Plugin-Handle steuern Sie die Verarbeitung der Tastenkürzel zur Laufzeit:
import { type KeyboardShortcutsService } from '@dayflow/plugin-keyboard-shortcuts';
const kb = app.getPlugin<KeyboardShortcutsService>('keyboard-shortcuts');KeyboardShortcutsService
| Methode | Rückgabe | Beschreibung |
|---|---|---|
enable() | void | Aktiviert die Verarbeitung der Tastenkürzel wieder |
disable() | void | Unterdrückt alle Tastenkürzel, bis enable() aufgerufen wird |
isEnabled() | boolean | Gibt zurück, ob die Tastenkürzel gerade aktiv sind |
Ein typischer Anwendungsfall ist, die Kalender-Tastenkürzel zu unterdrücken, solange ein eigenes Modal oder ein Rich-Text-Editor geöffnet ist:
function MyModal() {
const kb = app.getPlugin<KeyboardShortcutsService>('keyboard-shortcuts');
useEffect(() => {
kb?.disable();
return () => kb?.enable(); // restore on unmount
}, []);
// ...
}Sie können auch jede geöffnete Oberfläche programmgesteuert schließen:
app.dismissUI();