feat: init
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { getContext, setContext } from "svelte";
|
||||
import type { App, Component } from "obsidian";
|
||||
import type { BoardStore } from "../vault/store.svelte";
|
||||
import type { BeaverCalendarSettings } from "../settings";
|
||||
|
||||
export interface ViewContext {
|
||||
app: App;
|
||||
store: BoardStore;
|
||||
settings: BeaverCalendarSettings;
|
||||
component: Component;
|
||||
portal: () => HTMLElement;
|
||||
}
|
||||
|
||||
const KEY = Symbol("beaver-calendar");
|
||||
|
||||
export function provideView(context: ViewContext): void {
|
||||
setContext(KEY, context);
|
||||
}
|
||||
|
||||
export function useView(): ViewContext {
|
||||
return getContext<ViewContext>(KEY);
|
||||
}
|
||||
Reference in New Issue
Block a user