Skip to content

Plugin

API reference uses a reviewed source snapshot. Source links open the published source; unverified line locations are omitted.

Defined in: plugin.ts:289

Base class for Lapis plugins.

Plugins extend Component, so teardown callbacks, events, commands, and DOM listeners registered through helper methods are cleaned up when the plugin unloads.

new Plugin(app, manifest): Plugin

Defined in: plugin.ts:307

App

PluginManifest

Plugin

Component.constructor

readonly app: App

Defined in: plugin.ts:308


basePath: string = ""

Defined in: plugin.ts:290


children: Component<Record<string, any>>[] = []

Defined in: view.svelte.ts:31

Component.children


loaded: boolean = false

Defined in: view.svelte.ts:33

Component.loaded


readonly manifest: PluginManifest

Defined in: plugin.ts:309

get containerEl(): HTMLElement

Defined in: view.svelte.ts:37

HTMLElement

set containerEl(el): void

Defined in: view.svelte.ts:41

HTMLElement

void

Component.containerEl


get enabled(): boolean

Defined in: plugin.ts:413

boolean


get errorMessage(): string | null

Defined in: plugin.ts:438

string | null


get failureCount(): number

Defined in: plugin.ts:446

number


get grantedCapabilities(): HostedPluginCapability[]

Defined in: plugin.ts:458

HostedPluginCapability[]


get hostMode(): string

Defined in: plugin.ts:450

string


get id(): string

Defined in: plugin.ts:462

string


get lastFailureMessage(): string | null

Defined in: plugin.ts:442

string | null


get provenance(): PluginProvenance

Defined in: plugin.ts:421

PluginProvenance


get registeredViewTypes(): ReadonlySet<string>

Defined in: plugin.ts:430

View types owned by this plugin across enable and disable cycles.

ReadonlySet<string>


get requestedCapabilities(): HostedPluginCapability[]

Defined in: plugin.ts:454

HostedPluginCapability[]


get required(): boolean

Defined in: plugin.ts:425

boolean


get source(): PluginSource

Defined in: plugin.ts:417

PluginSource


get state(): PluginRuntimeState

Defined in: plugin.ts:434

PluginRuntimeState


get syncHost(): SyncHostCapabilities

Defined in: plugin.ts:467

Host-authenticated durable capabilities for sync and similar plugins.

SyncHostCapabilities

addChild<T>(component): T

Defined in: view.svelte.ts:161

Adds a child component, loading it if this component is loaded

T extends Component<Record<string, any>>

T

T

Component.addChild


addCommand(command): Command

Defined in: plugin.ts:766

Command

Command


addRibbonIcon(icon, title, callback): void

Defined in: plugin.ts:749

string

string

(evt) => any

void


addSettingTab(settingTab): void

Defined in: plugin.ts:1366

Register a settings tab, which allows users to change settings.

PluginSettingTab

void

https://docs.obsidian.md/Plugins/User+interface/Settings#Register+a+settings+tab


addStatusBarItem(): HTMLElement

Defined in: plugin.ts:594

HTMLElement


configureRuntime(options?): void

Defined in: plugin.ts:334

Apply runtime metadata resolved by the plugin manager before activation.

PluginRuntimeOptions = {}

Runtime source, host, and capability information.

void


createDiagnosticCollection(id, options?): DiagnosticCollection

Defined in: plugin.ts:950

Create an owner-scoped diagnostic collection disposed with this plugin.

string

DiagnosticCollectionOptions = {}

DiagnosticCollection


deleteGeneratedState(key): Promise<void>

Defined in: plugin.ts:677

string

Promise<void>


disable(): Promise<void>

Defined in: plugin.ts:556

Promise<void>


dispatch<T>(eventName, …args): boolean

Defined in: events.ts:105

T extends string

T

…any[]

boolean

Component.dispatch


emit<T>(eventName, …args): boolean

Defined in: events.ts:98

T extends string

T

…any[]

boolean

Component.emit


enable(): Promise<void>

Defined in: plugin.ts:372

Enable the plugin and run its onload() lifecycle.

Promise<void>

A promise that resolves when activation completes.


load(): void

Defined in: view.svelte.ts:50

Load this component and its children

void

Component.load


loadData(): Promise<any>

Defined in: plugin.ts:616

Load settings data from disk. Data is stored in data.json in the plugin folder.

Promise<any>

https://docs.obsidian.md/Plugins/User+interface/Settings


loadGeneratedState<T>(key): Promise<T | null>

Defined in: plugin.ts:662

T

string

Promise<T | null>


measureTelemetry<T>(name, callback, options?): T

Defined in: plugin.ts:534

T

string

(span) => T

TelemetryMeasurementOptions = {}

T


measureTelemetryAsync<T>(name, callback, options?): Promise<T>

Defined in: plugin.ts:545

T

string

(span) => Promise<T>

TelemetryMeasurementOptions = {}

Promise<T>


migrateDataToGeneratedState<T>(legacyKey, options?): Promise<T | null>

Defined in: plugin.ts:684

T = unknown

string

string

boolean

Promise<T | null>


off<T>(eventName, listener, context?, once?): void

Defined in: events.ts:78

T extends string

T

(…args) => void

any

boolean

void

Component.off


offref<T>(ref): void

Defined in: events.ts:87

T extends string

EventRef<Record<string, any>, T>

void

Component.offref


on<T>(eventName, listener, context?): EventRef<Record<string, any>, T, any>

Defined in: events.ts:48

T extends string

T

(…args) => void

any

EventRef<Record<string, any>, T, any>

Component.on


once<T>(eventName, listener, context?): EventRef<Record<string, any>, T, any>

Defined in: events.ts:63

T extends string

T

(…args) => void

any

EventRef<Record<string, any>, T, any>

Component.once


onExternalSettingsChange(): void | Promise<void>

Defined in: plugin.ts:964

void | Promise<void>


abstract onload(): void | Promise<void>

Defined in: plugin.ts:319

Load plugin state and register plugin-owned resources.

void | Promise<void>

Component.onload


onunload(): void | Promise<void>

Defined in: plugin.ts:326

Release plugin-owned resources before the plugin unloads.

void | Promise<void>

Component.onunload


onUserEnable(): void | Promise<void>

Defined in: plugin.ts:962

void | Promise<void>


register(cb): void

Defined in: view.svelte.ts:188

Registers a callback to be called when unloading

() => any

void

Component.register


registerAgentResultView(view): AgentResultViewRegistration

Defined in: plugin.ts:1352

Register a transcript result view. This is not a workspace palette command.

AgentResultViewDefinition<App>

AgentResultViewRegistration


registerAgentSkill(skill): AppSkillSourceRegistration

Defined in: plugin.ts:1330

Register a programmatic skill under this plugin’s lifecycle.

ProgrammaticAppSkill

AppSkillSourceRegistration


registerAgentSkillDirectory(path): AppSkillSourceRegistration

Defined in: plugin.ts:1310

Register a directory that contains one skill.

string

AppSkillSourceRegistration


registerAgentSkillRoot(path): AppSkillSourceRegistration

Defined in: plugin.ts:1320

Register a root that may contain many skill directories.

string

AppSkillSourceRegistration


registerAgentSlashCommand(command): AppSlashCommandRegistration

Defined in: plugin.ts:1340

Register a composer slash command. This is not a workspace palette command.

AppSlashCommandDefinition

AppSlashCommandRegistration


registerAgentTool<TInput>(tool): AppToolRegistration

Defined in: plugin.ts:1296

Register an application tool under this plugin’s lifecycle and identity.

TInput

AppTool<TInput>

AppToolRegistration


registerBasesView(viewId, registration): boolean

Defined in: plugin.ts:923

string

any

boolean


registerCliHandler(name, prefix, callback): void

Defined in: plugin.ts:915

string

string

(…args) => any

void


registerConfigurationOptionSource(id, provider): ConfigurationOptionSourceRegistration

Defined in: plugin.ts:883

string

Omit<ConfigurationOptionSourceProvider, "pluginId">

ConfigurationOptionSourceRegistration


registerContextKey(key, defaultValue?): ScopedContextKey

Defined in: plugin.ts:793

string

ContextKeyValue

ScopedContextKey


registerDomEvent<K>(el, type, callback, options?): void

Defined in: view.svelte.ts:207

Registers an DOM event to be detached when unloading

K extends keyof HTMLElementEventMap

HTMLElement

K

(this, ev) => any

boolean | AddEventListenerOptions

void

Component.registerDomEvent

registerDomEvent<K>(el, type, callback, options?): void

Defined in: view.svelte.ts:213

Registers an DOM event to be detached when unloading

K extends keyof DocumentEventMap

Document

K

(this, ev) => any

boolean | AddEventListenerOptions

void

Component.registerDomEvent

registerDomEvent<K>(el, type, callback, options?): void

Defined in: view.svelte.ts:219

Registers an DOM event to be detached when unloading

K extends keyof WindowEventMap

Window

K

(this, ev) => any

boolean | AddEventListenerOptions

void

Component.registerDomEvent


registerEditorExtension(extension, viewType?): void

Defined in: plugin.ts:1021

Registers a CodeMirror 6 extension. To reconfigure cm6 extensions for a plugin on the fly, an array should be passed in, and modified dynamically. Once this array is modified, calling Workspace.updateOptions will apply the changes.

ExtType

Must be a CodeMirror 6 Extension, or an array of Extensions.

string

void


registerEditorSuggest(editorSuggest, viewType?): void

Defined in: plugin.ts:1001

Register an EditorSuggest which can provide live suggestions while the user is typing.

EditorSuggest<any>

string = "markdown"

void


registerEditorView(contribution): void

Defined in: plugin.ts:874

EditorViewContribution

void


registerEvent<T, K>(eventRef): void

Defined in: view.svelte.ts:192

T extends ValidEventTypes

K extends string | symbol

EventRef<T, K, any>

void

Component.registerEvent


registerExtensions(extensions, viewType?, options?): void

Defined in: plugin.ts:966

string[]

string = "markdown"

ExtensionRegistrationOptions

void


registerHoverLinkSource(id, info): void

Defined in: plugin.ts:900

string

any

void


registerIcon(localId, svg): string

Defined in: plugin.ts:854

Register an App-owned SVG and dispose it automatically on plugin unload.

string

string

string


registerIconPack(input): string

Defined in: plugin.ts:865

Register an owned icon pack; use the returned prefix in prefix:icon IDs.

IconLoader

string


registerIndexProjection<T>(registration): RegisteredIndexProjectionHandle<T>

Defined in: plugin.ts:1157

T = Record<string, unknown>

IndexProjectionRegistration

RegisteredIndexProjectionHandle<T>


registerInterval(id): void

Defined in: view.svelte.ts:198

Timeout

void

Component.registerInterval


registerLapisServiceProvider(registration): void

Defined in: plugin.ts:939

Omit<LapisServiceProviderRegistration, "pluginId">

void


registerMarkdownCodeBlockProcessor(language, handler, sortOrder?): MarkdownPostProcessor

Defined in: plugin.ts:1081

string

(source, el, ctx) => void | Promise<any>

number

MarkdownPostProcessor


registerMarkdownDirectiveRenderer(directive, renderer): void

Defined in: plugin.ts:1129

string

MarkdownDirectiveRenderer

void


registerMarkdownEmbedder(embedder): void

Defined in: plugin.ts:1146

MarkdownEmbedder

void


registerMarkdownExtension(contribution): void

Defined in: plugin.ts:1029

Register a plugin-owned Markdown contribution for every Markdown surface.

MarkdownExtensionContribution

void


registerMarkdownFileSurfaceProvider(provider): void

Defined in: plugin.ts:1034

Register a provider for complete Markdown file surfaces.

MarkdownFileSurfaceProvider

void


registerMarkdownPostProcessor(postProcessor, sortOrder?): MarkdownPostProcessor

Defined in: plugin.ts:1047

Registers a post processor, to change how the document looks in reading mode.

MarkdownPostProcessor

number

MarkdownPostProcessor

https://docs.obsidian.md/Plugins/Editor/Markdown+post+processing


registerMarkdownViewMenuItem(provider): void

Defined in: plugin.ts:1139

MarkdownViewMenuItemProvider

void


registerMetadataProcessor(processor, ext?): void

Defined in: plugin.ts:1150

MetadataProcessor

string = "md"

void


registerObsidianProtocolHandler(action, handler): void

Defined in: plugin.ts:907

string

(params) => any

void


registerSearchDocumentProvider(localId, provider): SearchDocumentProviderRegistration

Defined in: plugin.ts:1263

Contribute normalized searchable content without writing generated state. The local id is namespaced by this plugin’s runtime id.

string

Omit<SearchDocumentProvider, "id">

SearchDocumentProviderRegistration


registerSearchResultProvider(localId, provider): SearchResultProviderRegistration

Defined in: plugin.ts:1281

Contribute query results whose navigation remains provider-owned.

string

Omit<SearchResultProvider, "id">

SearchResultProviderRegistration


registerSettingsSection(definition): PluginSettingsRegistration

Defined in: plugin.ts:1407

Register one controlled declarative settings definition with Workspace Settings. Source-backed values remain owned by the plugin.

WorkspaceSettingsDefinition

PluginSettingsRegistration


registerShortcut(handler): void

Defined in: plugin.ts:808

KeymapEventHandler

void


registerSidebarView(type, viewCreator, options?, access?): void

Defined in: plugin.ts:832

string

ViewCreator

string

string

string

boolean

string

"right" | "left"

string

ViewAccess

void


registerTypeWidget(widget): void

Defined in: plugin.ts:983

TypeWidget

void


registerView(type, viewCreator, access?): void

Defined in: plugin.ts:812

string

ViewCreator

ViewAccess

void


removeChild<T>(component): T

Defined in: view.svelte.ts:175

Removes a child component, unloading it

T extends Component<Record<string, any>>

T

T

Component.removeChild


removeCommand(commandId): void

Defined in: plugin.ts:789

string

void


saveData(data): Promise<void>

Defined in: plugin.ts:649

Write settings data to disk. Data is stored in data.json in the plugin folder.

any

Promise<void>

https://docs.obsidian.md/Plugins/User+interface/Settings


saveGeneratedState(key, value): Promise<void>

Defined in: plugin.ts:670

string

unknown

Promise<void>


startTelemetrySpan(name, options?): TelemetrySpan

Defined in: plugin.ts:524

string

TelemetrySpanOptions = {}

TelemetrySpan


trigger<T>(eventName, …args): boolean

Defined in: events.ts:91

T extends string

T

…any[]

boolean

Component.trigger


tryTrigger<T>(evt, …args): void

Defined in: events.ts:112

T extends string

EventRef<Record<string, any>, T>

…any[]

void

Component.tryTrigger


unload(): void

Defined in: view.svelte.ts:91

Unload this component and its children

void

Component.unload