Plugin
Extends
Constructors
new Plugin()
new Plugin(
app
,manifest
):Plugin
Parameters
• app: App
• manifest: PluginManifest
Returns
Overrides
Properties
_children
_children:
Component
[]
Child Components attached to current component, will be unloaded on unloading parent component
Inherited from
_events
_events:
EventRef
[]
Events that are attached to the current component, will be detached on unloading parent component
Inherited from
_loaded
_loaded:
boolean
Whether the component and its children are loaded
Inherited from
app
app:
App
manifest
manifest:
PluginManifest
onConfigFileChange
Methods
_onConfigFileChange()
_onConfigFileChange():
Promise
<void
>
Returns
Promise
<void
>
addChild()
addChild<
T
>(component
):T
Adds a child component, loading it if this component is loaded
Type Parameters
• T extends Component
Parameters
• component: T
Returns
T
Inherited from
addCommand()
addCommand(
command
):Command
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
addRibbonIcon()
addRibbonIcon(
icon
,title
,callback
):HTMLElement
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
The click
callback.
Returns
addSettingTab()
addSettingTab(
settingTab
):void
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
Adds a status bar item to the bottom of the app. Not available on mobile.
Returns
HTMLElement - element to modify.
See
https://docs.obsidian.md/Plugins/User+interface/Status+bar
load()
load():
void
Load this component and its children
Returns
void
Inherited from
loadData()
loadData():
Promise
<any
>
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
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
>
Returns
void
| Promise
<void
>
Overrides
onunload()
onunload():
void
Override this to unload your component
Returns
void
Inherited from
onUserEnable()
onUserEnable():
void
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
Registers a callback to be called when unloading
Parameters
• cb
Returns
void
Inherited from
registerDomEvent()
registerDomEvent(el, type, callback, options)
registerDomEvent<
K
>(el
,type
,callback
,options
?):void
Registers an DOM event to be detached when unloading
Type Parameters
• K extends keyof WindowEventMap
Parameters
• el: Window
• type: K
• callback
• options?: boolean
| AddEventListenerOptions
Returns
void
Inherited from
registerDomEvent(el, type, callback, options)
registerDomEvent<
K
>(el
,type
,callback
,options
?):void
Registers an DOM event to be detached when unloading
Type Parameters
• K extends keyof DocumentEventMap
Parameters
• el: Document
• type: K
• callback
• options?: boolean
| AddEventListenerOptions
Returns
void
Inherited from
registerDomEvent(el, type, callback, options)
registerDomEvent<
K
>(el
,type
,callback
,options
?):void
Registers an DOM event to be detached when unloading
Type Parameters
• K extends keyof HTMLElementEventMap
Parameters
• el: HTMLElement
• type: K
• callback
• options?: boolean
| AddEventListenerOptions
Returns
void
Inherited from
registerEditorExtension()
registerEditorExtension(
extension
):void
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
Register an EditorSuggest which can provide live suggestions while the user is typing.
Parameters
• editorSuggest: EditorSuggest
<any
>
Returns
void
registerEvent()
registerEvent(
eventRef
):void
Registers an event to be detached when unloading
Parameters
• eventRef: EventRef
Returns
void
Inherited from
registerExtensions()
registerExtensions(
extensions
,viewType
):void
Parameters
• extensions: string
[]
• viewType: string
Returns
void
registerHoverLinkSource()
registerHoverLinkSource(
id
,info
):void
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
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
registerMarkdownCodeBlockProcessor()
registerMarkdownCodeBlockProcessor(
language
,handler
,sortOrder
?):MarkdownPostProcessor
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
• sortOrder?: number
Returns
See
https://docs.obsidian.md/Plugins/Editor/Markdown+post+processing#Post-process+Markdown+code+blocks
registerMarkdownPostProcessor()
registerMarkdownPostProcessor(
postProcessor
,sortOrder
?):MarkdownPostProcessor
Registers a post processor, to change how the document looks in reading mode.
Parameters
• postProcessor: MarkdownPostProcessor
• sortOrder?: number
Returns
See
https://docs.obsidian.md/Plugins/Editor/Markdown+post+processing
registerObsidianProtocolHandler()
registerObsidianProtocolHandler(
action
,handler
):void
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
Parameters
• keymapEventHandler: KeymapEventHandler
Returns
void
Inherited from
registerView()
registerView(
type
,viewCreator
):void
Parameters
• type: string
• viewCreator: ViewCreator
Returns
void
removeChild()
removeChild<
T
>(component
):T
Removes a child component, unloading it
Type Parameters
• T extends Component
Parameters
• component: T
Returns
T
Inherited from
removeCommand()
removeCommand(
commandId
):void
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
>
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
Unload this component and its children
Returns
void