flint-plugin-api 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +10 -0
  2. package/index.d.ts +11 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Writing Flint plugins
2
2
 
3
+ The API's TypeScript types are on npm, versioned with Flint:
4
+
5
+ ```sh
6
+ npm install --save-dev flint-plugin-api
7
+ ```
8
+
9
+ ```ts
10
+ import type { ActivatePlugin } from 'flint-plugin-api'
11
+ ```
12
+
3
13
  A plugin is a folder inside a vault's `.flint/plugins/` directory:
4
14
 
5
15
  ```
package/index.d.ts CHANGED
@@ -21,10 +21,17 @@ export interface SidebarTab {
21
21
  /** Unique within the plugin. */
22
22
  id: string
23
23
  name: string
24
+ /** A Lucide icon name from https://lucide.dev/icons, like `bar-chart-3`. Defaults to the name's first letters. */
25
+ icon?: string
24
26
  /** Renders into `element`; the returned function runs when the tab is removed. */
25
27
  render: (element: HTMLElement) => Disposer | undefined
26
28
  }
27
29
 
30
+ export interface SettingsTab {
31
+ /** Renders into `element` when the section opens; the returned function runs when it closes. */
32
+ render: (element: HTMLElement) => Disposer | undefined
33
+ }
34
+
28
35
  export interface NoteEntry {
29
36
  path: string
30
37
  kind: 'file' | 'folder' | 'attachment'
@@ -93,6 +100,8 @@ export interface FlintApi {
93
100
  ui: {
94
101
  notice(message: string): void
95
102
  registerSidebarTab(tab: SidebarTab): Disposer
103
+ /** Adds a section named after the plugin to Settings. */
104
+ registerSettingsTab(tab: SettingsTab): Disposer
96
105
  }
97
106
 
98
107
  markdown: {
@@ -117,6 +126,7 @@ export interface FlintApi {
117
126
  }
118
127
 
119
128
  /** The default export of a plugin's `main.js`. It may return a cleanup function. */
129
+ /** The default export of a plugin's `main.js`; it may return a function to run when it's turned off. */
120
130
  export type ActivatePlugin = (
121
131
  flint: FlintApi,
122
- ) => Disposer | undefined | Promise<Disposer | undefined>
132
+ ) => Disposer | undefined | Promise<Disposer | undefined> | Promise<void>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flint-plugin-api",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "TypeScript types for writing Flint plugins",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "repository": {