Skip to content

Plugin

Defined in: obsidian.d.ts:3099

Extends

Constructors

new Plugin()

new Plugin(app, manifest): Plugin

Defined in: obsidian.d.ts:3112

Parameters

app

App

manifest

PluginManifest

Returns

Plugin

Overrides

Component.constructor

Properties

_children

_children: Component[]

Defined in: src/obsidian/augmentations/Components/Component.d.ts:9

Child Components attached to current component, will be unloaded on unloading parent component

Inherited from

Component._children


_events

_events: EventRef[]

Defined in: src/obsidian/augmentations/Components/Component.d.ts:13

Events that are attached to the current component, will be detached on unloading parent component

Inherited from

Component._events


_loaded

_loaded: boolean

Defined in: src/obsidian/augmentations/Components/Component.d.ts:17

Whether the component and its children are loaded

Inherited from

Component._loaded


app

app: App

Defined in: obsidian.d.ts:3104


manifest

manifest: PluginManifest

Defined in: obsidian.d.ts:3108


onConfigFileChange

onConfigFileChange: Debouncer<[], Promise<void>>

Defined in: src/obsidian/augmentations/Plugin.d.ts:5

Methods

_onConfigFileChange()

_onConfigFileChange(): Promise<void>

Defined in: src/obsidian/augmentations/Plugin.d.ts:7

Returns

Promise<void>


addChild()

addChild<T>(component): T

Defined in: obsidian.d.ts:887

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

Type Parameters

T extends Component

Parameters

component

T

Returns

T

Inherited from

Component.addChild


addCommand()

addCommand(command): Command

Defined in: obsidian.d.ts:3140

Register a command globally. Registered commands will be available from the @{link https://help.obsidian.md/Plugins/Command+palette Command palette}. The command id and name will be automatically prefixed with this plugin’s id and name.

Parameters

command

Command

Returns

Command


addRibbonIcon()

addRibbonIcon(icon, title, callback): HTMLElement

Defined in: obsidian.d.ts:3125

Adds a ribbon icon to the left bar.

Parameters

icon

string

The icon name to be used. See addIcon

title

string

The title to be displayed in the tooltip.

callback

(evt) => any

The click callback.

Returns

HTMLElement


addSettingTab()

addSettingTab(settingTab): void

Defined in: obsidian.d.ts:3152

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

Parameters

settingTab

PluginSettingTab

Returns

void

See

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


addStatusBarItem()

addStatusBarItem(): HTMLElement

Defined in: obsidian.d.ts:3133

Adds a status bar item to the bottom of the app. Not available on mobile.

Returns

HTMLElement

HTMLElement - element to modify.

See

https://docs.obsidian.md/Plugins/User+interface/Status+bar


load()

load(): void

Defined in: obsidian.d.ts:865

Load this component and its children

Returns

void

Inherited from

Component.load


loadData()

loadData(): Promise<any>

Defined in: obsidian.d.ts:3208

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

Returns

Promise<any>

See

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


onExternalSettingsChange()?

optional onExternalSettingsChange(): any

Defined in: obsidian.d.ts:3234

Called when the data.json file is modified on disk externally from Obsidian. This usually means that a Sync service or external program has modified the plugin settings.

Implement this method to reload plugin settings when they have changed externally.

Returns

any


onload()

onload(): void | Promise<void>

Defined in: obsidian.d.ts:3117

Returns

void | Promise<void>

Overrides

Component.onload


onunload()

onunload(): void

Defined in: obsidian.d.ts:882

Override this to unload your component

Returns

void

Inherited from

Component.onunload


onUserEnable()

onUserEnable(): void

Defined in: obsidian.d.ts:3223

Perform any initial setup code. The user has explicitly interacted with the plugin so its safe to engage with the user. If your plugin registers a custom view, you can open it here.

Returns

void


register()

register(cb): void

Defined in: obsidian.d.ts:897

Registers a callback to be called when unloading

Parameters

cb

() => any

Returns

void

Inherited from

Component.register


registerDomEvent()

Call Signature

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

Defined in: obsidian.d.ts:907

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof WindowEventMap

Parameters
el

Window

type

K

callback

(this, ev) => any

options?

boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent

Call Signature

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

Defined in: obsidian.d.ts:912

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof DocumentEventMap

Parameters
el

Document

type

K

callback

(this, ev) => any

options?

boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent

Call Signature

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

Defined in: obsidian.d.ts:917

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof HTMLElementEventMap

Parameters
el

HTMLElement

type

K

callback

(this, ev) => any

options?

boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent


registerEditorExtension()

registerEditorExtension(extension): void

Defined in: obsidian.d.ts:3188

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.

Parameters

extension

Extension

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

Returns

void


registerEditorSuggest()

registerEditorSuggest(editorSuggest): void

Defined in: obsidian.d.ts:3201

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

Parameters

editorSuggest

EditorSuggest<any>

Returns

void


registerEvent()

registerEvent(eventRef): void

Defined in: obsidian.d.ts:902

Registers an event to be detached when unloading

Parameters

eventRef

EventRef

Returns

void

Inherited from

Component.registerEvent


registerExtensions()

registerExtensions(extensions, viewType): void

Defined in: obsidian.d.ts:3165

Parameters

extensions

string[]

viewType

string

Returns

void


registerHoverLinkSource()

registerHoverLinkSource(id, info): void

Defined in: obsidian.d.ts:3161

Registers a view with the ‘Page preview’ core plugin as an emitter of the ‘hover-link’ event.

Parameters

id

string

info

HoverLinkSource

Returns

void


registerInterval()

registerInterval(id): number

Defined in: obsidian.d.ts:924

Registers an interval (from setInterval) to be cancelled when unloading Use setInterval instead of setInterval to avoid TypeScript confusing between NodeJS vs Browser API

Parameters

id

number

Returns

number

Inherited from

Component.registerInterval


registerMarkdownCodeBlockProcessor()

registerMarkdownCodeBlockProcessor(language, handler, sortOrder?): MarkdownPostProcessor

Defined in: obsidian.d.ts:3179

Register a special post processor that handles fenced code given a language and a handler. This special post processor takes care of removing the <pre><code> and create a <div> that will be passed to the handler, and is expected to be filled with custom elements.

Parameters

language

string

handler

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

sortOrder?

number

Returns

MarkdownPostProcessor

See

https://docs.obsidian.md/Plugins/Editor/Markdown+post+processing#Post-process+Markdown+code+blocks


registerMarkdownPostProcessor()

registerMarkdownPostProcessor(postProcessor, sortOrder?): MarkdownPostProcessor

Defined in: obsidian.d.ts:3171

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

Parameters

postProcessor

MarkdownPostProcessor

sortOrder?

number

Returns

MarkdownPostProcessor

See

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


registerObsidianProtocolHandler()

registerObsidianProtocolHandler(action, handler): void

Defined in: obsidian.d.ts:3196

Register a handler for obsidian:// URLs.

Parameters

action

string

the action string. For example, ‘open’ corresponds to obsidian://open.

handler

ObsidianProtocolHandler

the callback to trigger. A key-value pair that is decoded from the query will be passed in. For example, obsidian://open?key=value would generate {'action': 'open', 'key': 'value'}.

Returns

void


registerScopeEvent()

registerScopeEvent(keymapEventHandler): void

Defined in: src/obsidian/augmentations/Components/Component.d.ts:19

Parameters

keymapEventHandler

KeymapEventHandler

Returns

void

Inherited from

Component.registerScopeEvent


registerView()

registerView(type, viewCreator): void

Defined in: obsidian.d.ts:3156

Parameters

type

string

viewCreator

ViewCreator

Returns

void


removeChild()

removeChild<T>(component): T

Defined in: obsidian.d.ts:892

Removes a child component, unloading it

Type Parameters

T extends Component

Parameters

component

T

Returns

T

Inherited from

Component.removeChild


removeCommand()

removeCommand(commandId): void

Defined in: obsidian.d.ts:3146

Manually remove a command from the list of global commands. This should not be needed unless your plugin registers commands dynamically.

Parameters

commandId

string

Returns

void


saveData()

saveData(data): Promise<void>

Defined in: obsidian.d.ts:3215

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

Parameters

data

any

Returns

Promise<void>

See

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


unload()

unload(): void

Defined in: obsidian.d.ts:876

Unload this component and its children

Returns

void

Inherited from

Component.unload