import { Entity } from '../../../framework'; import { LiveData } from '../../../livedata'; import { MemoryMemento } from '../../../storage'; import type { DocMode } from '../../doc'; export class GlobalContext extends Entity { memento = new MemoryMemento(); workspaceId = this.define('workspaceId'); isDoc = this.define('isDoc'); docId = this.define('docId'); isCollection = this.define('isCollection'); collectionId = this.define('collectionId'); isTrash = this.define('isTrash'); docMode = this.define('docMode'); isTag = this.define('isTag'); tagId = this.define('tagId'); define(key: string) { this.memento.set(key, null); const livedata$ = LiveData.from(this.memento.watch(key), null); return { get: () => this.memento.get(key) as T | null, set: (value: T | null) => this.memento.set(key, value), $: livedata$, }; } }