mirror of
https://github.com/Mail-0/Zero.git
synced 2026-06-28 23:06:54 +00:00
fixes to shortcuts
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import { AppSidebar } from '@/components/ui/app-sidebar';
|
||||
import { GlobalHotkeys } from '@/lib/hotkeys/global-hotkeys';
|
||||
import { HotkeyProviderWrapper } from '@/components/providers/hotkey-provider-wrapper';
|
||||
import { GlobalHotkeys } from '@/lib/hotkeys/global-hotkeys';
|
||||
import { AppSidebar } from '@/components/ui/app-sidebar';
|
||||
|
||||
export default function MailLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<HotkeyProviderWrapper>
|
||||
<AppSidebar />
|
||||
<GlobalHotkeys />
|
||||
<div className="w-full bg-lightBackground dark:bg-darkBackground">{children}</div>
|
||||
<div className="bg-lightBackground dark:bg-darkBackground w-full">{children}</div>
|
||||
</HotkeyProviderWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,25 +10,146 @@ export type Shortcut = {
|
||||
};
|
||||
|
||||
export const keyboardShortcuts: Shortcut[] = [
|
||||
{ keys: ["c"], action: "newEmail", type: "single", description: "Compose new email", scope: "global" },
|
||||
{ keys: ["mod", "Enter"], action: "sendEmail", type: "combination", description: "Send email", scope: "compose" },
|
||||
{ keys: ["r"], action: "reply", type: "single", description: "Reply to email", scope: "thread-display" },
|
||||
{ keys: ["a"], action: "replyAll", type: "single", description: "Reply all", scope: "thread-display" },
|
||||
{ keys: ["f"], action: "forward", type: "single", description: "Forward email", scope: "thread-display" },
|
||||
{ keys: ["g", "d"], action: "goToDrafts", type: "combination", description: "Go to drafts", scope: "global" },
|
||||
{ keys: ["g", "i"], action: "inbox", type: "combination", description: "Go to inbox", scope: "global" },
|
||||
{ keys: ["g", "t"], action: "sentMail", type: "combination", description: "Go to sent mail", scope: "global" },
|
||||
{ keys: ["#"], action: "delete", type: "single", description: "Delete email", scope: "mail-list" },
|
||||
{ keys: ["/"], action: "search", type: "single", description: "Search", scope: "global" },
|
||||
{ keys: ["u"], action: "markAsUnread", type: "single", description: "Mark as unread", scope: "mail-list" },
|
||||
{ keys: ["m"], action: "muteThread", type: "single", description: "Mute thread", scope: "mail-list" },
|
||||
{ keys: ["mod", "p"], action: "printEmail", type: "combination", description: "Print email", scope: "thread-display" },
|
||||
{ keys: ["e"], action: "archiveEmail", type: "single", description: "Archive email", scope: "mail-list" },
|
||||
{ keys: ["!"], action: "markAsSpam", type: "single", description: "Mark as spam", scope: "mail-list" },
|
||||
{ keys: ["v"], action: "moveToFolder", type: "single", description: "Move to folder", scope: "mail-list" },
|
||||
{ keys: ["z"], action: "undoLastAction", type: "single", description: "Undo last action", scope: "global" },
|
||||
{ keys: ["i"], action: "viewEmailDetails", type: "single", description: "View email details", scope: "thread-display" },
|
||||
{ keys: ["o"], action: "expandEmailView", type: "single", description: "Expand email view", scope: "mail-list" },
|
||||
{ keys: ["?"], action: "helpWithShortcuts", type: "single", description: "Show keyboard shortcuts", scope: "global" },
|
||||
{ keys: ["mod", "a"], action: "selectAll", type: "combination", description: "Select all emails", scope: "mail-list", preventDefault: true },
|
||||
{
|
||||
keys: ['c'],
|
||||
action: 'newEmail',
|
||||
type: 'single',
|
||||
description: 'Compose new email',
|
||||
scope: 'global',
|
||||
},
|
||||
{
|
||||
keys: ['mod', 'Enter'],
|
||||
action: 'sendEmail',
|
||||
type: 'combination',
|
||||
description: 'Send email',
|
||||
scope: 'compose',
|
||||
},
|
||||
{
|
||||
keys: ['r'],
|
||||
action: 'reply',
|
||||
type: 'single',
|
||||
description: 'Reply to email',
|
||||
scope: 'thread-display',
|
||||
},
|
||||
{
|
||||
keys: ['a'],
|
||||
action: 'replyAll',
|
||||
type: 'single',
|
||||
description: 'Reply all',
|
||||
scope: 'thread-display',
|
||||
},
|
||||
{
|
||||
keys: ['f'],
|
||||
action: 'forward',
|
||||
type: 'single',
|
||||
description: 'Forward email',
|
||||
scope: 'thread-display',
|
||||
},
|
||||
{
|
||||
keys: ['g', 'd'],
|
||||
action: 'goToDrafts',
|
||||
type: 'combination',
|
||||
description: 'Go to drafts',
|
||||
scope: 'global',
|
||||
},
|
||||
{
|
||||
keys: ['g', 'i'],
|
||||
action: 'inbox',
|
||||
type: 'combination',
|
||||
description: 'Go to inbox',
|
||||
scope: 'global',
|
||||
},
|
||||
{
|
||||
keys: ['g', 't'],
|
||||
action: 'sentMail',
|
||||
type: 'combination',
|
||||
description: 'Go to sent mail',
|
||||
scope: 'global',
|
||||
},
|
||||
{
|
||||
keys: ['#'],
|
||||
action: 'delete',
|
||||
type: 'single',
|
||||
description: 'Delete email',
|
||||
scope: 'mail-list',
|
||||
},
|
||||
{ keys: ['/'], action: 'search', type: 'single', description: 'Search', scope: 'global' },
|
||||
{
|
||||
keys: ['u'],
|
||||
action: 'markAsUnread',
|
||||
type: 'single',
|
||||
description: 'Mark as unread',
|
||||
scope: 'mail-list',
|
||||
},
|
||||
{
|
||||
keys: ['m'],
|
||||
action: 'muteThread',
|
||||
type: 'single',
|
||||
description: 'Mute thread',
|
||||
scope: 'mail-list',
|
||||
},
|
||||
{
|
||||
keys: ['mod', 'p'],
|
||||
action: 'printEmail',
|
||||
type: 'combination',
|
||||
description: 'Print email',
|
||||
scope: 'thread-display',
|
||||
},
|
||||
{
|
||||
keys: ['e'],
|
||||
action: 'archiveEmail',
|
||||
type: 'single',
|
||||
description: 'Archive email',
|
||||
scope: 'mail-list',
|
||||
},
|
||||
{
|
||||
keys: ['!'],
|
||||
action: 'markAsSpam',
|
||||
type: 'single',
|
||||
description: 'Mark as spam',
|
||||
scope: 'mail-list',
|
||||
},
|
||||
{
|
||||
keys: ['v'],
|
||||
action: 'moveToFolder',
|
||||
type: 'single',
|
||||
description: 'Move to folder',
|
||||
scope: 'mail-list',
|
||||
},
|
||||
{
|
||||
keys: ['z'],
|
||||
action: 'undoLastAction',
|
||||
type: 'single',
|
||||
description: 'Undo last action',
|
||||
scope: 'global',
|
||||
},
|
||||
{
|
||||
keys: ['i'],
|
||||
action: 'viewEmailDetails',
|
||||
type: 'single',
|
||||
description: 'View email details',
|
||||
scope: 'thread-display',
|
||||
},
|
||||
{
|
||||
keys: ['o'],
|
||||
action: 'expandEmailView',
|
||||
type: 'single',
|
||||
description: 'Expand email view',
|
||||
scope: 'mail-list',
|
||||
},
|
||||
{
|
||||
keys: ['?'],
|
||||
action: 'helpWithShortcuts',
|
||||
type: 'single',
|
||||
description: 'Show keyboard shortcuts',
|
||||
scope: 'global',
|
||||
},
|
||||
{
|
||||
keys: ['mod', 'a'],
|
||||
action: 'selectAll',
|
||||
type: 'combination',
|
||||
description: 'Select all emails',
|
||||
scope: 'mail-list',
|
||||
preventDefault: true,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -3,20 +3,24 @@
|
||||
import { keyboardShortcuts } from '@/config/shortcuts';
|
||||
import { useShortcuts } from './use-hotkey-utils';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useQueryState } from 'nuqs';
|
||||
|
||||
export function GlobalHotkeys() {
|
||||
const [composeOpen, setComposeOpen] = useQueryState('isComposeOpen');
|
||||
const router = useRouter();
|
||||
const scope = 'global';
|
||||
|
||||
console.log('i am loaded');
|
||||
|
||||
const handlers = {
|
||||
goToDrafts: () => router.push('/mail/draft'),
|
||||
inbox: () => router.push('/mail/inbox'),
|
||||
sentMail: () => router.push('/mail/sent'),
|
||||
search: () => {
|
||||
// TODO: Implement search - kinda tricky :/
|
||||
console.log('search');
|
||||
console.log('well well well');
|
||||
document.getElementsByName('q')[0]?.focus();
|
||||
},
|
||||
newEmail: () => router.push('isComposeOpen=true'),
|
||||
newEmail: () => setComposeOpen('true'),
|
||||
};
|
||||
|
||||
const globalShortcuts = keyboardShortcuts.filter((shortcut) => shortcut.scope === scope);
|
||||
|
||||
Reference in New Issue
Block a user