Utilities for working with Obsidian's undocumented API in a version-agnostic manner.
Use npm
or yarn
to install type definitions for undocumented Obsidian APIs:
npm install obsidian-extra
Import the desired function(s) and use them!
import { getEnabledPluginIDs, getPluginInstance } from "obsidian-extra";
// Inside your Plugin class:
const enabledPluginInstances = getEnabledPluginIDs(this.app)
.map((id) => getPluginInstance(this.app, id));
Certain functions are deemed "unsafe", as they have the ability to easily break Obsidian or interfere with the operation of other plugins. These functions are only available in the obsidian-extra/unsafe
import.
-
Tree-shakeable.
Using functions fromobsidian-extra
should only bring in exactly what they need. -
Safety first.
Functions should not have the ability to break Obsidian just by themselves, unless exported through the "unsafe" import. -
Simple abstraction.
No complicated classes and designs. A function does exactly what you need, only abstracting away the parts that could be accidentally misused.
- List installed plugins
- List enabled plugins
- Get plugin instances
- Get plugin manifests
- Open plugin settings pane
- Enable plugins (unsafe)
- Disable plugins (unsafe)
- Reload plugins (unsafe)
- Close settings dialog (unsafe)
- List installed snippets
- List enabled snippets
- Check if snippet is installed
- Check if snippet is enabled
- Get style element of snippet
- Get style elements of all snippets
- List installed themes
- Get current theme ID
- Get theme manifest
- Get theme style element
- Check if theme is installed
- Get current color scheme
- Get Obsidian's CSS rules