Files
AFFiNE-Mirror/packages/frontend/apps/electron/src/main/application-menu/index.ts
T
2025-03-28 09:12:26 +00:00

34 lines
919 B
TypeScript

import type { MainEventRegister } from '../type';
import { applicationMenuSubjects } from './subject';
export * from './create';
export * from './subject';
/**
* Events triggered by application menu
*/
export const applicationMenuEvents = {
/**
* File -> New Doc
*/
onNewPageAction: (fn: (type: 'page' | 'edgeless') => void) => {
const sub = applicationMenuSubjects.newPageAction$.subscribe(fn);
return () => {
sub.unsubscribe();
};
},
// todo: properly define the active tab type
openInSettingModal: (fn: (activeTab: string) => void) => {
const sub = applicationMenuSubjects.openInSettingModal$.subscribe(fn);
return () => {
sub.unsubscribe();
};
},
onOpenJournal: (fn: () => void) => {
const sub = applicationMenuSubjects.openJournal$.subscribe(fn);
return () => {
sub.unsubscribe();
};
},
} satisfies Record<string, MainEventRegister>;