Skip to content

API

Defined in: jsEngine/api/API.ts:18

Constructors

new API()

new API(app, plugin, instanceId): API

Defined in: jsEngine/api/API.ts:51

Parameters

Parameter Type

app

App

plugin

JsEnginePlugin

instanceId

InstanceId

Returns

API

Properties

app

readonly app: App

Defined in: jsEngine/api/API.ts:22

Reference to the obsidian app.


instanceId

readonly instanceId: InstanceId

Defined in: jsEngine/api/API.ts:27


internal

readonly internal: InternalAPI

Defined in: jsEngine/api/API.ts:49

API to interact with js engines internals.


lib

readonly lib: LibAPI

Defined in: jsEngine/api/API.ts:40

API to interact with packaged libraries.


markdown

readonly markdown: MarkdownAPI

Defined in: jsEngine/api/API.ts:32

API to interact with markdown.


message

readonly message: MessageAPI

Defined in: jsEngine/api/API.ts:36

API to interact with the plugins message system.


plugin

readonly plugin: JsEnginePlugin

Defined in: jsEngine/api/API.ts:26

Reference the JS Engine plugin.


prompt

readonly prompt: PromptAPI

Defined in: jsEngine/api/API.ts:45


query

readonly query: QueryAPI

Defined in: jsEngine/api/API.ts:44

API to query your vault with simple javascript functions.


validators

readonly validators: Validators

Defined in: jsEngine/api/API.ts:28

Methods

getObsidianModule()

getObsidianModule(): __module

Defined in: jsEngine/api/API.ts:110

Gets the obsidian module. This allows you to access all things exported by the obsidian module.

Returns

__module

Example

const obsidian = engine.getObsidianModule();
new obsidian.Notice('Hello World!');

getPlugin()

getPlugin(pluginId): undefined | Plugin

Defined in: jsEngine/api/API.ts:94

Gets a plugin by its id. A plugin id can be found by looking at its manifest. If the plugin is not enabled, this will return undefined.

Parameters

Parameter Type Description

pluginId

string

the id of the plugin.

Returns

undefined | Plugin


importJs()

importJs(path): Promise<unknown>

Defined in: jsEngine/api/API.ts:74

Loads an ECMAScript module from a vault relative path. Everything you import via this function will be loaded as an ECMAScript module.

Since imports are cached by the browser (aka Obsidian), you might need to reload Obsidian to see changes made to the imported file.

Parameters

Parameter Type Description

path

string

the vault relative path of the file to import

Returns

Promise<unknown>


parseLink(link): undefined | MarkdownLink

Defined in: jsEngine/api/API.ts:149

Parses a markdown link. This link can be a markdown link or a wiki link.

Parameters

Parameter Type Description

link

string

the link to parse.

Returns

undefined | MarkdownLink


reactive()

reactive(fn, …initialArgs): ReactiveComponent

Defined in: jsEngine/api/API.ts:121

Creates a reactive component. Reactive components are useful for creating dynamic content.

Parameters

Parameter Type Description

fn

JsFunc

the function to rerun. It’s return value will be rendered.

initialArgs

unknown[]

the initial arguments (for the first render) to pass to the function.

Returns

ReactiveComponent


resolveLinkToTFile()

resolveLinkToTFile(link, sourcePath): undefined | TFile

Defined in: jsEngine/api/API.ts:135

Gets the target file of a link. This link can be a markdown link or a wiki link. If the link target is not found, this will return undefined.

Parameters

Parameter Type Description

link

string

the link to get the target file of.

sourcePath

string

the path of the file that contains the link. This is needed to resolve relative links.

Returns

undefined | TFile