platform/packages/presentation/src/context.ts
Vyacheslav Tumanov df5fc73eeb
UBER-135/TSK-1430: allow changing image in PDFViewer through arrow-keys (keyboard) (#3186)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
2023-05-24 18:51:48 +06:00

24 lines
595 B
TypeScript

import { ViewContext, ViewContextType } from '@hcengineering/view'
import { writable } from 'svelte/store'
/**
* @public
*/
export class ContextStore {
constructor (readonly contexts: ViewContext[]) {}
getLastContext (): ViewContext | undefined {
return this.contexts[this.contexts.length - 1]
}
isIncludes (type: ViewContextType): boolean {
return (
this.contexts.find((it) => it.mode === type || (Array.isArray(it.mode) && it.mode.includes(type))) !== undefined
)
}
}
/**
* @public
*/
export const contextStore = writable<ContextStore>(new ContextStore([]))