23 lines
581 B
TypeScript
23 lines
581 B
TypeScript
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);
|
|
}
|