Coder Social home page Coder Social logo

obsidian-api's Introduction

Obsidian API

Type definitions for the latest Obsidian API.

Documentation

You can browse our Plugin API documentation at https://docs.obsidian.md/

For an 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.
  • isDesktopOnly whether your plugin uses NodeJS or Electron APIs.
  • authorUrl (optional) a URL to your own website.
  • fundingUrl (optional) a link for users to donation to show appreciation and support plugin development.

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

andrewcrook avatar claremacrae avatar joethei avatar liamcain avatar lishid avatar mnaoumov avatar tehshrike avatar timrogers avatar topor-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

obsidian-api's Issues

Perform modifications at save

I've seen multiple plugins that performs action "on save", but I've not been able to find a proper API for it.

What I've seen being done in the wild so far is an override for the editor:save-file command callback, but it feels sub-optimal.
Are there any plans to make this easier, adding a dedicated event?

Event when block is loaded back into DOM?

As the title says, is there an event for when an element is loaded back into a note's DOM? I looked through the API, but didn't see one.

Use case:

My plugin uses LeafletJS, which has several functions related to the size of the containing element. If the map block is placed at the bottom of a long note, the containing element will not have a size, resulting in issues related to zooming and panning the map.

If I can detect when the element is added back in, I can tell the map to recalculate its scaling to the new container size. I built a workaround using a MutationObserver that disconnects itself once the map container has a size (only need to do it once), but I figured a native solution would be better.

Expose API to get Config

I'd like app.vault.getConfig() exposed, so I can get configuration settings to apply to custom file handlers (for example, my CookLang plugin).
Even better if we can get some sort of event to listen for when specific config values change, so plugin views can respond to config changes like line numbers, word wrap, readable line length, etc.

Installing a plugin results in 'sha seems to be corrupted' error

Steps to reproduce

  1. Clone a plugin
  2. Run npm i

Expected

The plugin gets installed

Actual

npm WARN tarball tarball data for obsidian@https://github.com/obsidianmd/obsidian-api/tarball/master (sha512-DZWdNPqkozADT1Mb7MyR+vQi2jE4lFJJG9TRZW/kl6NSuL/OHLiKudBnmythlybeYkWta1YuvAb0LLGUJlfqdg==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for obsidian@https://github.com/obsidianmd/obsidian-api/tarball/master (sha512-DZWdNPqkozADT1Mb7MyR+vQi2jE4lFJJG9TRZW/kl6NSuL/OHLiKudBnmythlybeYkWta1YuvAb0LLGUJlfqdg==) seems to be corrupted. Trying one more time.
npm WARN [email protected] No repository field.

npm ERR! code EINTEGRITY
npm ERR! Verification failed while extracting obsidian@https://github.com/obsidianmd/obsidian-api/tarball/master:
npm ERR! Verification failed while extracting obsidian@https://github.com/obsidianmd/obsidian-api/tarball/master:
npm ERR! sha512-DZWdNPqkozADT1Mb7MyR+vQi2jE4lFJJG9TRZW/kl6NSuL/OHLiKudBnmythlybeYkWta1YuvAb0LLGUJlfqdg== integrity checksum failed when using sha512: wanted sha512-DZWdNPqkozADT1Mb7MyR+vQi2jE4lFJJG9TRZW/kl6NSuL/OHLiKudBnmythlybeYkWta1YuvAb0LLGUJlfqdg== but got sha512-09/Zpb7sXE264OLk3DDbieU895d6NaNIIL8eyKR+5WpXPSYKeDfwy4yQh3WSb6KHWTJpbyvqUDchh8Yy4lHiRQ==. (15583 bytes)

is it possible to get header, status code, binary data in request()?

Hi,

I am building a plugin that requires http digest auth that requires reading response headers and status code.

Currently, the request() is the only way to bypass the annoying cors problem on obsidian mobile. But it seems that the function only returns the body as string and omits other information.

  1. Is it possible to read the response headers, and status code? Or could you please expose them to public api please?
  2. Is it possible to fetch binary data instead of string? (e.g. download a file)

Thank you!

Expose Markdown HTML handlers

I have some popovers with Markdown that I converted to HTML using renderMarkdown. However, if the resulting HTML is added to any view or modal but Obsidian's Markdown view, the event handlers for eg internal links and images are not added, which means internal links won't open and internal images aren't rendered.

It would be very useful if if were possible to attach these handlers using the Obsidian API, for example by passing an HTMLElement.

Can plugins add new file extension handlers?

My use case is to link/open .djvu files in vaults.

Current status:

  • .djvu files do not show up in internal link suggestions (those shown while you are typing [[ and some words)
  • Such internal links cannot be opened in a new pane. "Open in default app" works though.

To support above use cases, would it be possible for a plugin to declare that files with certain extensions should show up in link suggestions, and customize how such files would be rendered? For .djvu, it seems that djvu.js is a possibility.

Expose the Obsidian search parser or functionality

It can be very valuable if the API would allow plugins to use the Obsidian note search syntax.
For example, Vault could have a search(query: string) method that returns a Promise<TAbstractFile[]> for the results of the search represented by query, which might include Obsidian search operators like tag: and others.
As of today, plugins wishing to implement a file search box currently need to duplicate this functionality, which is unfortunate because the query options that Obsidian supports make a powerful tool, and we rather use the same syntax in plugins.

As a nice bonus, it would be great to have a FileSearchQuery text box component that would show the user tips as in Obsidian's Find in Files pane and Graph View.

Expose an API to handle multiple cursors programmatically

I am trying to develop a functionality similar to pycharm's or sublime text's multiple selections (when you select some text, press hotkey and capture the following occurrences of the text, getting a way to edit multiple instances of the text).

Multiple cursor functionality is available in the Obsidian (https://help.obsidian.md/How+to/Working+with+multiple+cursors) from the UI but I see no quick way to achieve that programmatically.

The only way to create cursors is by using the setCursor method but it does not allow creating multiple cursors

        /** Set the cursor position. You can either pass a single {line, ch} object, or the line and the character as two separate parameters.
        Will replace all selections with a single, empty selection at the given position.
        The supported options are the same as for setSelection */
        setCursor(
            pos: CodeMirror.Position | number,
            ch?: number,
            options?: { bias?: number; origin?: string; scroll?: boolean },
        ): void;

this code sample

        editor.setCursor(
            { line: cursorStart.line, ch: cursorStart.ch + 2 },
        )
        editor.setCursor(
            { line: cursorStart.line, ch: cursorStart.ch + 5 },
        )
        editor.setCursor(
            { line: cursorStart.line, ch: cursorStart.ch + 8 },
        )

obviously just sets the cursor to the latest value.

Thanks

De-couple `file-open` from `active-leaf-change`

Currently, the file-open event has a callback for the TFile opened. However, it provides no information as to the containing leaf of said TFile. I tried iterating through all open leaves, but found out that apparently they all contain the same TFile by reference, so... Is there not an actual way to find out the leaf for a file-open event?

Wrong API for MarkdownPostProcessor?

The API type definition requires the MarkdownPostProcessor to be a function which takes two arguments. However, when registering a simple plugin with such a post processor it causes exceptions:

const postprocessor: MarkdownPostProcessor = (el: HTMLElement, ctx: MarkdownPostProcessorContext) => {
	console.log('post-processing!')
	console.log(ctx, el)
}

export default class MyPlugin extends Plugin {
	onload() {
		console.log('loading plugin');
		MarkdownPreviewRenderer.registerPostProcessor(postprocessor)
	}

	onunload() {
		MarkdownPreviewRenderer.unregisterPostProcessor(postprocessor)
		console.log('unloading plugin');
	}
}

image

It apparently expects an object with a function called render which takes one argument. By inspecting the crashing code it looks like other PostProcessors that are registered take this shape where e seems to be the HTMLElement:

image

Either the registerPostProcessor function fails to do a transformation of the value or the API definition is wrong, either way, it currently crashes on 0.9.11.

EDIT: I'm not quite sure if this is the place to report such an issue ๐Ÿคทโ€โ™‚๏ธ

Proposal: Use a dropdown for keymap selection

Originally posted here:
https://forum.obsidian.md/t/proposal-use-a-dropdown-for-keymap-selection/18270

But maybe it is better to have it here instead?

I'd like to propose an alternate way of handling the keyMap inside of Obsidian. Currently, there are two ways of modifying the keyMap value of CodeMirror:

image

The second option only exists on Mac OS, which makes handling keyMap logic 'simple' on non-Mac platforms (app.vault.config.vimMode), but since Obsidian is cross platform, any plugin developer needs to account for Mac OS, so the complexity is still there no matter what.

If the keyMap option was presented as a dropdown, instead of two booleans, there would be some immediate wins from this:

  1. Any plugins that have to set up their own CodeMirror instance, or run something like a SwapDoc command, could easily set the keyMap option to match whatever the user intends it to be by reading from app.vault.config.
  2. It would eliminate the impossible to fulfill state of having both 'Legacy Emacs-style' and 'Vim' bindings enabled. The current result of having both these enabled is that 'Vim' mode is preferred. But that is not obvious to the end user, and only happens because of the way the logic handles the different boolean flags.

One dropdown would solve this, and give one less option to the user. This would also simplify the internal Obsidian logic, since you would just be setting a direct value. Here are some plugins that could benefit from this change:

https://github.com/deathau/csv-obsidian
https://github.com/deathau/ini-obsidian
https://github.com/zsviczian/obsidian-excalidraw-plugin
https://github.com/ryanpcmcquen/obsidian-org-mode

There may be others as well.

any way to change mtime only?

Hi,

Is there any way to change mtime only? (which is similar to Linux's touch command).

I found there are modify() and modifyBinary(). But the content (data) must be provided, which means that though I could change the mtime by writing same content, it's very inefficient. I also tried to pass undefined to data but received no luck.

Another related issue is that the api also lacks the support of appending file instead of rewriting file. Is it also possible to do that?

Thank you so much!

Create versioning / releases in Github

Hey,
from my point of view, it is hard to track what changed in each version.
Therfore, it would be nice if you could create a github release for the upcoming versions with a small changelog section :-)

Thank you in advance!

Icon Gallery

Is it possible to add a Wiki - page with all existing icons for the addRibbonIcon() - method?
Or at least to explain how to use the addIcon() - method

Bug: `origin` param in `Editor.replaceRange`/`replaceSelection` not working

obsidian-api/obsidian.d.ts

Lines 733 to 736 in 5af3ef9

/** @public */
abstract replaceSelection(replacement: string, origin?: string): void;
/** @public */
abstract replaceRange(replacement: string, from: EditorPosition, to?: EditorPosition, origin?: string): void;

Seems that in the source code, the last param (origin) is never read and only range and replacement params get passed to CodeMirror instance, so when batch editing document, the change histories can not be merged as expected.

IMO, since CodeMirror 6 and 5 have distinct implementation on history, I think an helper function can be provided to allow batch editing, similar to vscode, which use WorkspaceEdit to keep track of batch changes.

Error running tests

Currently, I import the obsidian module in the fileDoc.ts as follows:

import type { App } from "obsidian";

As part of removing the path library from the code, I have switched to use normalizePath function as seen on fileDoc.ts on branch remove-path-api as follows:

import { FileSystemAdapter, normalizePath } from "obsidian";

With this changes, which eliminates the usage of type from the import statement, my tests no longer work as seen in this Action run.

Run npm run test

> [email protected] test /home/runner/work/obsidian-readwise/obsidian-readwise
> mocha -r ts-node/register tests/*.ts


Error: Cannot find module 'obsidian'
Require stack:
- /home/runner/work/obsidian-readwise/obsidian-readwise/src/fileDoc.ts
- /home/runner/work/obsidian-readwise/obsidian-readwise/tests/fileDoc.ts
- /home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/mocha/lib/esm-utils.js
- /home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/mocha/lib/mocha.js
- /home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/mocha/lib/cli/one-and-dones.js
- /home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/mocha/lib/cli/options.js
- /home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/mocha/bin/mocha
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/runner/work/obsidian-readwise/obsidian-readwise/src/fileDoc.ts:4:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Module.m._compile (/home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/ts-node/src/index.ts:1056:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Object.require.extensions.<computed> [as .ts] (/home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/ts-node/src/index.ts:1059:12)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/runner/work/obsidian-readwise/obsidian-readwise/tests/fileDoc.ts:3:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Module.m._compile (/home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/ts-node/src/index.ts:1056:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Object.require.extensions.<computed> [as .ts] (/home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/ts-node/src/index.ts:1059:12)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.exports.requireOrImport (/home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/mocha/lib/esm-utils.js:42:12)
    at Object.exports.loadFilesAsync (/home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/mocha/lib/esm-utils.js:55:34)
    at Mocha.loadFilesAsync (/home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/mocha/lib/mocha.js:473:19)
    at singleRun (/home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/mocha/lib/cli/run-helpers.js:125:15)
    at exports.runMocha (/home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/mocha/lib/cli/run-helpers.js:190:10)
    at Object.exports.handler (/home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/mocha/lib/cli/run.js:362:11)
    at /home/runner/work/obsidian-readwise/obsidian-readwise/node_modules/yargs/build/index.cjs:443:71
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `mocha -r ts-node/register tests/*.ts`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-04-13T12_38_37_318Z-debug.log
Error: Process completed with exit code 1.

Expose parseLinktext method

Hi, we talked about it in the discord some time ago.

In order to go from LinkCache.link to getFirstLinkpathDest you need to use parseLinktext method, but currently it's not exposed in API.

anyway to track file movement?

Hi, when a file is moved from location A to location B, inside the same vault, is there any api to track the movement?

I tried this.app.vault.on("create", ...) and this.app.vault.on("modify", ...) event, and both of them do not work. Is this possible to add a move event?

on(name: 'create', callback: (file: TAbstractFile) => any, ctx?: any): EventRef;

Ability to disable Settings

It would be great to be able to disable specific settings. For example if two toggle settings are "linked" so that the second only applies if the first is enabled. It would be great to be able to show both settings so the user understands that they both exist but have the second disabled (visually and functionally) so they can't click it without enabling the other one first.

I'm picturing something like this:

// ... in display() of PluginSettings
const setting1 = new Setting(containerEl)
  .setName('First setting')
  .setDescription('enable something and allow second setting to be set')
  .addToggle((toggle) => toggle.setValue(this.plugin.settings.firstOpt).onChange(async(value) => {
    this.plugin.settings.firstOpt = value
    await this.plugin.saveSettings();
    if (value) {
      setting2.enable()
    }
    else {
      this.plugin.settings.secondOpt = false;
      setting2.disable()
    }
  }))

const setting2 = new Setting(containerEl)
  .setName('Second setting')
  .setDescription('Enable something else. only enabled when firstOpt is on')
  .addToggle((toggle) => toggle.setValue(this.plugin.settings.secondOpt).onChange(async(value) => {
    this.plugin.settings.secondOpt = value;
    await this.plugin.saveSettings();
  }))
if (this.Plugin.settings.firstOpt) {
  setting2.disable()
}

are some restrictions of `requestUrl` expected?

Hi,

I just have the opportunity to try the new requestUrl, but I find something weird restrictions:

The headers: {} cannot content the following keys: host, content-length

try this:

  requestUrl({
    url: "https://httpbin.org/put",
    method: 'PUT',
    headers: {
        x: 'x',
        'content-length': '331'  // comment or not comment
    },
    body: 'xyz'
  }).then(x=>console.log(x.json))

Here is the error:

index.html:1 Uncaught (in promise) Error: net::ERR_INVALID_ARGUMENT
    at SimpleURLLoaderWrapper.<anonymous> (node:electron/js2c/browser_init:101:7068)
    at SimpleURLLoaderWrapper.emit (node:events:394:28)
Promise.then (async)
(anonymous) @ VM587:9

04d1bfebca1cf64cbdb047089e91456

I don't know it's by designed or not, and I can only find out the above headers by try and error. Are there any more docs here?

setActiveLeaf doesn't remove current focus if target view doesn't handle `focus` state

If you attempt to activate and focus a leaf via the API, and the targeted leaf's view doesn't explicitly handle the focus ephemeral state (e.g. backlinks view, outline view, graph view, empty pane, etc.), focus remains wherever it was before. In order to get this to work properly, one has to also explicitly blur the previously-focused element, otherwise commands and cursor movement may affect the previously-active pane.

Perhaps WorkspaceLeaf's setEphemeralState() with a .focus should blur the active element if it's not a child of the leaf, before calling the view's setEphemeralState? That way, if the view actually does manage its own focus, it won't be affected by redundantly setting the state, but the many types of views in the core and third-party plugins wouldn't have to duplicate this functionality if they don't need a specific element to be focused.

Preserve CJK characters in `normalizePath` function

Hey,

One of our plugin's users mentioned this here: readwiseio/obsidian-readwise#3

They are suggesting using a custom sanitization function instead, but ideally, I'd like to still use Obsidian's own normalizePath function and satisfy the user's needs.

Is there a specific reason you're normalizing those characters as well as slashes etc.?
Could we perhaps control this behavior with a param?

If you don't think this is a good idea at all โ€” any chance for a suggestion on how to best mitigate this?

Thanks a lot for the Obsidian app and keep up the good work!

MenuItem is undefined

Although the type info is present in the index.d.ts, Obsidian (at least as of 0.12.5) does not actually provide MenuItem as a runtime export. Importing it results in undefined.

Allow returning promise in SuggestModal's getSuggestions

Hi,

This is API feature request.

At the moment SuggestModal's implementation of getSuggestions allows only array returns (T[]).

This limits its use to only static suggestions (i.e. selection from a predefined number of commands).

I am working on a plugin that needs to be able to receive suggestions from an HTTP endpoint. In order to achieve this getSuggestions needs to also allow Promise<T[]> returns.

EditorSuggest's implementation of getSuggestions already has this functionality.

Please let me know if more information is required

Thanks a million!

[Bug Report] Electron failed to install correctly

Plugin failure: obsidian-bundler Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
    at getElectronPath (eval at <anonymous> (app.js:1), <anonymous>:91:11)
    at eval (eval at <anonymous> (app.js:1), <anonymous>:95:16)
    at e.<anonymous> (app.js:1)
    at app.js:1
    at Object.next (app.js:1)
    at s (app.js:1)

My code is :

import { remote } from "electron";
//...
  const result = await remote.dialog.showOpenDialog({
    properties: ["openDirectory"]
  });
// ...

Environment:

  • Windows 10 2004 19041.630
  • Obsidian v0.9.15

is it possible to expose Stat for TFolder?

Hi,

Currently a Stat property containing mtime and ctime is exposed for TFile, but the same info is not exposed for TFolder. It is possible to directly include this info insider TFolder?

Thanks!

Mechanism to detect whether the plugin is running on Mobile or Desktop

As of now there is no sanctioned way of detecting inside a plugin code that it is running in the mobile app vs the desktop.

This comes handy for the following reasons:

  • Usage of a feature that is only available on Desktop or Mobile
  • Change design and visuals based on whether is running on Mobile or Desktop.

As of now, I am aware of the possibility of using app.isMobile, but that involves having to extend the typings declaration, plus the fact that I am using an undocumented API that could be changed/removed in the future

Allow plugins to add links between notes

In a plugin I'm going to develop with @SkepticMystic, we would like our plugin to manually add links between notes. This has also been requested in DataView use cases, where users expect the outputs of DV to link from the source note to the outputs of DV.

We might be able to hack around with resolvedLinks and the ReferenceCache, but that sounds challenging and unreliable.

Document Keymap.isModifier, since it's the right way to check for the mod key on events

I've been trying to encourage plugin developers to use event.button == 1 || Keymap.isModifier(event, "Mod") as the Obsidian standard way to detect "a click that should open in a new pane", but it turns out that Keymap isn't actually listed in the API despite being exported. (See e.g. the last paragraph of this comment, and subsequent disussion re: Keymap.)

The other Keymap statics are occasionally useful, too, but this one seems particularly important for writing plugins that work consistently across platforms the way Obsidian does.

Note auto-complete search component

Hi there!

I'm not sure if this exists or how I would find it but I would love to re-use the auto-complete search component that's currently in the "Daily Notes" settings:

Screenshot 2021-02-02 at 14 30 25

Any pointers before I start to re-invent this wheel? Thank you! :)

`wasm` bindings

I have thoroughly been enjoying this project! I wanted to know if it would perhaps be possible to add wasm bindings to the API's? In my use case, it would be for Rust with WebAssembly, which, in my opinion, has the best wasm interop story at the moment.

Expose Locale information

This has arisen from an issue in @liamcain's calendar plugin, and the need to know if 2020 has 53 or 52 weeks, and the answer was... Depends what your locale is.

The correct way of solving this issue would be to ask the OS for its locale, but according to @liamcain, Obsidian's API does not expose it. Does it make sense to expose it to the plugins?

`requestUrl` doesn't allow unusual method on Android

One of my plugin enables webdav connections from Obsidian.

Webdav has some unusual http methods, like PROPFIND, MKCOL, etc. And, to avoid CORS issue, requestUrl is needed instead of fetch or axios. Obsidian desktop (Windows) version, and iOS version, do not restrict the methods in requestUrl, and the requests are constructed successfully and work as expected.

Unfortunately, Android's requestUrl seems to has some limitations, only allowing methods in OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, PATCH!

Is it possible to fix this bug, and relax the restriction on Android? Thanks!

Here is the code to reproduce the issue, which works in desktop's console, but doesn't work in Android's console.

requestUrl({url:'https://example.com',method:'PROPFIND'}).then(x=>x.text).then(x=>console.log(x))

...

image

...

6458bead4778f748e3d1120756661a2

Add plugin dependencies

Although not technically part of the API, I think it would be very useful for Obsidian to support plugin dependencies for other plugins. For instance, 'extended context menu' (https://github.com/phibr0/obsidian-extended-context-menu) exists primarily to be extended by other plugins.
Furthermore, some plugins might extend (eg) dataview by using its query language within the plugin.

Is there any chance plugins will be able to specify dependencies on other plugins? This can improve compatibility and decrease code duplication, while making it easier for users to install. Of course, it should be clear to the user what other plugins will be installed.

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.