Giter Site home page Giter Site logo

obsidian-api's Introduction

Obsidian API

Definitions for the latest Obsidian API.

Warning: The Obsidian API is still in early alpha and is subject to change at any time!

Documentation

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

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.
  • 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));

obsidian-api's People

Contributors

lishid avatar tehshrike avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.