1
0
silverbullet/packages/web/types.ts

77 lines
2.1 KiB
TypeScript
Raw Normal View History

2022-04-05 15:02:17 +00:00
import { AppCommand } from "./hooks/command";
import { FilterOption, PageMeta } from "@silverbulletmd/common/types";
export const slashCommandRegexp = /\/[\w\-]*/;
export type Notification = {
id: number;
message: string;
date: Date;
};
export type AppViewState = {
currentPage?: string;
showPageNavigator: boolean;
showCommandPalette: boolean;
unsavedChanges: boolean;
2022-04-04 16:33:13 +00:00
showLHS: number; // 0 = hide, > 0 = flex
showRHS: number; // 0 = hide, > 0 = flex
2022-03-28 13:25:05 +00:00
rhsHTML: string;
2022-04-04 16:33:13 +00:00
lhsHTML: string;
allPages: Set<PageMeta>;
commands: Map<string, AppCommand>;
notifications: Notification[];
showFilterBox: boolean;
filterBoxLabel: string;
filterBoxPlaceHolder: string;
filterBoxOptions: FilterOption[];
filterBoxHelpText: string;
filterBoxOnSelect: (option: FilterOption | undefined) => void;
};
export const initialViewState: AppViewState = {
showPageNavigator: false,
showCommandPalette: false,
unsavedChanges: false,
2022-04-04 16:33:13 +00:00
showLHS: 0,
showRHS: 0,
rhsHTML: "",
lhsHTML: "",
allPages: new Set(),
commands: new Map(),
notifications: [],
showFilterBox: false,
filterBoxHelpText: "",
filterBoxLabel: "",
filterBoxOnSelect: () => {},
filterBoxOptions: [],
filterBoxPlaceHolder: "",
};
export type Action =
| { type: "page-loaded"; name: string }
| { type: "pages-listed"; pages: Set<PageMeta> }
| { type: "page-changed" }
| { type: "page-saved" }
| { type: "start-navigate" }
| { type: "stop-navigate" }
| { type: "update-commands"; commands: Map<string, AppCommand> }
| { type: "show-palette"; context?: string }
| { type: "hide-palette" }
| { type: "show-notification"; notification: Notification }
2022-03-28 13:25:05 +00:00
| { type: "dismiss-notification"; id: number }
2022-04-04 16:33:13 +00:00
| { type: "show-rhs"; html: string; flex: number }
| { type: "hide-rhs" }
| { type: "show-lhs"; html: string; flex: number }
| { type: "hide-lhs" }
| {
type: "show-filterbox";
options: FilterOption[];
placeHolder: string;
helpText: string;
label: string;
onSelect: (option: FilterOption | undefined) => void;
}
| { type: "hide-filterbox" };