mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +08:00
8ce10e6d0a
fix AF-2447
36 lines
961 B
TypeScript
36 lines
961 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: (props: { activeTab: string; scrollAnchor?: 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>;
|