https://github.com/eth-p/obsidian-extra
Utilities for working with Obsidian's undocumented API in a version-agnostic manner.
https://github.com/eth-p/obsidian-extra
Last synced: about 1 year ago
JSON representation
Utilities for working with Obsidian's undocumented API in a version-agnostic manner.
- Host: GitHub
- URL: https://github.com/eth-p/obsidian-extra
- Owner: eth-p
- License: mit
- Created: 2023-02-09T04:40:26.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-25T09:04:12.000Z (about 3 years ago)
- Last Synced: 2025-03-26T06:23:40.852Z (about 1 year ago)
- Language: TypeScript
- Size: 75.2 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# obsidian-extra
[](https://obsidian.md/) [](https://www.npmjs.com/package/obsidian-extra)
Utilities for working with Obsidian's [undocumented API](https://github.com/eth-p/obsidian-undocumented) in a version-agnostic manner.
## Installation
Use `npm` or `yarn` to install type definitions for undocumented Obsidian APIs:
```bash
npm install obsidian-extra
```
## Usage
Import the desired function(s) and use them!
```typescript
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.
## Design Goals
- **Tree-shakeable.**
Using functions from `obsidian-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.
## Features
### Workspace
- [Get secondary window DOMs](./src/functions/getFloatingWindowRoots.ts)
### Plugins
- [List installed plugins](./src/functions/getInstalledPluginIDs.ts)
- [List enabled plugins](./src/functions/getEnabledPluginIDs.ts)
- [Get plugin instances](./src/functions/getPluginInstance.ts)
- [Get plugin manifests](./src/functions/getPluginManifest.ts)
- [Open plugin settings pane](./src/functions/openPluginSettings.ts)
- [Enable plugins](./src/functions/enablePlugin.ts) (unsafe)
- [Disable plugins](./src/functions/disablePlugin.ts) (unsafe)
- [Reload plugins](./src/functions/reloadPlugin.ts) (unsafe)
### Settings
- [Close settings dialog](./src/functions/closeSettings.ts) (unsafe)
### CSS
- [List installed snippets](./src/functions/getInstalledSnippetIDs.ts)
- [List enabled snippets](./src/functions/getEnabledSnippetIDs.ts)
- [Check if snippet is installed](./src/functions/isSnippetInstalled.ts)
- [Check if snippet is enabled](./src/functions/isSnippetEnabled.ts)
- [Get style element of snippet](./src/functions/getSnippetStyleElement.ts)
- [Get style elements of all snippets](./src/functions/getSnippetStyleElements.ts)
- [List installed themes](./src/functions/getInstalledThemeIDs.ts)
- [Get current theme ID](./src/functions/getCurrentThemeID.ts)
- [Get theme manifest](./src/functions/getThemeManifest.ts)
- [Get theme style element](./src/functions/getThemeStyleElement.ts)
- [Check if theme is installed](./src/functions/isThemeInstalled.ts)
- [Get current color scheme](./src/functions/getCurrentColorScheme.ts)
- [Get Obsidian's CSS rules](./src/functions/fetchObsidianStyleSheet.ts)
### Custom CSS
- [Create a custom stylesheet at runtime](./src/functions/createCustomStyleSheet.ts)
### View Registry
- [Get registered view types](./src/functions/getRegisteredViewTypes.ts)
- [Get registered file extensions](./src/functions/getRegisteredFileExtensions.ts)
### Platform
- [Get OS info](./src/functions/detectPlatformOperatingSystem.ts)
- [Get runtime info](./src/functions/detectPlatformRuntime.ts)
- [Get browser info](./src/functions/detectPlatformBrowser.ts)