Socket
Socket
Sign inDemoInstall

obsidian

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

obsidian

Type definitions for the latest Obsidian API (https://obsidian.md)


Version published
Weekly downloads
2.2K
increased by2.82%
Maintainers
1
Weekly downloads
 
Created

Changelog

Source

v1.1.1 (2022-12-8 — Insider build)

Changes since v1.0

With these two changes, plugins should be able to adapt to the new Canvas view quite easily. Custom views that react the the currently focused views will automatically respond to the user clicking on file cards in the canvas. If a plugin is currently accessing the Editor using the following approach:

let view = app.workspace.getActiveViewOfType(MarkdownView);

if (view) {
    let editor = view.editor;
    // or
    let file = view.file;
}

Instead you can access the editor or file by looking under the activeEditor:

let { activeEditor } = app.workspace;
if (activeEditor) {
    let editor = activeEditor.editor;
    let file = activeEditor.file;
}

Readme

Source

Obsidian API

Type definitions for the latest Obsidian API.

Documentation

All API documentation is located in the file obsidian.d.ts. This will include types, properties, methods, and comments explaining what everything does.

For a full example on how to create Obsidian plugins, use the template at https://github.com/obsidianmd/obsidian-sample-plugin

Plugin structure

manifest.json

  • id the ID of your plugin.
  • name the display name of your plugin.
  • author the plugin author's name.
  • version the version of your plugin.
  • minAppVersion the minimum required Obsidian version for your plugin.
  • description the long description of your plugin.
  • authorUrl (optional) a URL to your own website.
  • isDesktopOnly whether your plugin uses NodeJS or Electron APIs.

main.js

  • This is the main entry point of your plugin.
  • Import any Obsidian API using require('obsidian')
  • Import NodeJS or Electron API using require('fs') or require('electron')
  • Must export a default class which extends Plugin
  • Must bundle all external dependencies into this file, using Rollup, Webpack, or another javascript bundler.

App Architecture

The app is organized into a few major modules:
  • App, the global object that owns everything else. You can access this via this.app inside your plugin. The App interface provides accessors for the following interfaces.
  • Vault, the interface that lets you interact with files and folders in the vault.
  • Workspace, the interface that lets you interact with panes on the screen.
  • MetadataCache, the interface that contains cached metadata about each markdown file, including headings, links, embeds, tags, and blocks.
Additionally, by inheriting Plugin, you can:
  • Add a ribbon icon using this.addRibbonIcon.
  • Add a status bar (bottom) element using this.addStatusBarItem.
  • Add a global command, optionally with a default hotkey, using this.addCommand.
  • Add a plugin settings tab using this.addSettingTab.
  • Register a new kind of view using this.registerView.
  • Save and load plugin data using this.loadData and this.saveData.
Registering events

For registering events from any event interfaces, such as App and Workspace, please use this.registerEvent, which will automatically detach your event handler when your plugin unloads:

this.registerEvent(app.on('event-name', callback));

If you register DOM events for elements that persist on the page after your plugin unloads, such as window or document events, please use this.registerDomEvent:

this.registerDomEvent(element, 'click', callback);

If you use setInterval, please use this.registerInterval:

this.registerInterval(setInterval(callback, 1000));

Keywords

FAQs

Package last updated on 19 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc