Automerge backed Markdown editor for the Atmosphere
Something went wrong. Try again.
1.4 kB · 42 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243// src/plugins/quick-access/quick-access-plugin.tsimport { Plugin } from '../../plugin/plugin'import type { App } from '../../plugin/app'import type { PluginManifest } from '../../plugin/types'import { QuickAccessView, QUICK_ACCESS_VIEW_TYPE } from './quick-access-view'
const QUICK_ACCESS_MANIFEST: PluginManifest = { id: 'reams-quick-access', name: 'Quick Access', author: 'Reams', version: '1.0.0', minAppVersion: '0.0.0', description: 'Recently-modified notes with title, tags, and preview',}
/** * Built-in plugin that owns the Quick Access sidebar view. * * Registers the `reams-quick-access` view type and, once layout is ready, * opens it in a left sidebar leaf. The leaf-creation is idempotent: if a * leaf with this view type already exists (e.g. after a hot-reload or a * StrictMode double-mount), no duplicate is created. */export class QuickAccessPlugin extends Plugin { constructor(app: App) { super(app, QUICK_ACCESS_MANIFEST) }
onload(): void { this.registerView(QUICK_ACCESS_VIEW_TYPE, (leaf) => new QuickAccessView(leaf, this.app), )
this.app.workspace.onLayoutReady(() => { if (this.app.workspace.getLeavesOfType(QUICK_ACCESS_VIEW_TYPE).length > 0) return const leaf = this.app.workspace.getLeftLeaf(true) leaf.openView(QUICK_ACCESS_VIEW_TYPE).catch((err) => { console.error('Failed to open Quick Access view:', err) }) }) }}