Skip to content

ObsidianAPI

Meta Bind API for Obsidian.

Extends

  • API<MetaBindPlugin>

Constructors

new ObsidianAPI(plugin)

new ObsidianAPI(plugin): ObsidianAPI

Parameters

ParameterType
plugindefault

Returns

ObsidianAPI

Overrides

API<MetaBindPlugin>.constructor

Source

packages/obsidian/src/ObsidianAPI.ts:37

Properties

bindTargetParser

readonly bindTargetParser: BindTargetParser

Inherited from

API.bindTargetParser

Source

packages/core/src/api/API.ts:92


buttonActionRunner

readonly buttonActionRunner: ButtonActionRunner

Inherited from

API.buttonActionRunner

Source

packages/core/src/api/API.ts:97


buttonManager

readonly buttonManager: ButtonManager

Inherited from

API.buttonManager

Source

packages/core/src/api/API.ts:98


buttonParser

readonly buttonParser: ButtonParser

Inherited from

API.buttonParser

Source

packages/core/src/api/API.ts:91


inputFieldFactory

readonly inputFieldFactory: InputFieldFactory

Inherited from

API.inputFieldFactory

Source

packages/core/src/api/API.ts:94


inputFieldParser

readonly inputFieldParser: InputFieldParser

Inherited from

API.inputFieldParser

Source

packages/core/src/api/API.ts:88


jsViewFieldParser

readonly jsViewFieldParser: JsViewFieldParser

Inherited from

API.jsViewFieldParser

Source

packages/core/src/api/API.ts:90


plugin

readonly plugin: default

Inherited from

API.plugin

Source

packages/core/src/api/API.ts:86


syntaxHighlighting

readonly syntaxHighlighting: SyntaxHighlightingAPI

Inherited from

API.syntaxHighlighting

Source

packages/core/src/api/API.ts:100


viewFieldFactory

readonly viewFieldFactory: ViewFieldFactory

Inherited from

API.viewFieldFactory

Source

packages/core/src/api/API.ts:95


viewFieldParser

readonly viewFieldParser: ViewFieldParser

Inherited from

API.viewFieldParser

Source

packages/core/src/api/API.ts:89

Methods

constructMDRCWidget()

constructMDRCWidget(inlineFieldType, content, filePath, component): MarkdownRenderChildWidget

Creates a CM6 widget from a given widget type.

This is only useful fur use in a CodeMirror plugin.

Parameters

ParameterTypeDescription
inlineFieldTypeInlineFieldType
contentstring
filePathstring
componentComponent

Returns

MarkdownRenderChildWidget

Source

packages/obsidian/src/ObsidianAPI.ts:81


createBindTarget()

createBindTarget(storageType, storagePath, property, listenToChildren): BindTargetDeclaration

Creates a bind target declaration.

Parameters

ParameterTypeDefault valueDescription
storageTypestringundefinedthe storage type (also named metadata source sometimes)
storagePathstringundefinedthe storage path (usually the file path)
propertystring[]undefinedthe property path a.b.c = [‘a’, ‘b’, ‘c’]
listenToChildrenbooleanfalsewhether to listen to children, only relevant for arrays and objects

Returns

BindTargetDeclaration

Inherited from

API.createBindTarget

Source

packages/core/src/api/API.ts:642


createButtonGroupMountable()

createButtonGroupMountable(filePath, options): ButtonGroupMountable

Creates a button group from an options object.

Parameters

ParameterTypeDescription
filePathstringthe file path that the field is located in or an empty string
optionsButtonGroupOptions

Returns

ButtonGroupMountable

Inherited from

API.createButtonGroupMountable

Source

packages/core/src/api/API.ts:437


createButtonMountable()

createButtonMountable(filePath, options): ButtonMountable

Creates a button from an options object.

Parameters

ParameterTypeDescription
filePathstringthe file path that the field is located in or an empty string
optionsButtonOptions

Returns

ButtonMountable

Inherited from

API.createButtonMountable

Source

packages/core/src/api/API.ts:474


createEmbedMountable()

createEmbedMountable(filePath, options): EmbedMountable

Creates a meta bind embed fields from an options object.

Parameters

ParameterTypeDescription
filePathstringthe file path that the field is located in or an empty string
optionsEmbedOptions

Returns

EmbedMountable

Inherited from

API.createEmbedMountable

Source

packages/core/src/api/API.ts:504


createExcludedMountable()

createExcludedMountable(filePath): ExcludedMountable

Creates an excluded notification mountable for the excluded folders setting.

Parameters

ParameterTypeDescription
filePathstringthe file path that the field is located in or an empty string

Returns

ExcludedMountable

Inherited from

API.createExcludedMountable

Source

packages/core/src/api/API.ts:525


createField()

createField<Type>(type, filePath, options, honorExcludedSetting): FieldMountable

Creates a field of a given type.

Type parameters

Type parameter
Type extends FieldType

Parameters

ParameterTypeDefault valueDescription
typeTypeundefinedthe type of the field
filePathstringundefinedthe file path that the field is located in, or an empty string if it is not in a file
optionsFieldOptionMap[Type]undefined
honorExcludedSettingbooleantruewhether to honor the excluded folders settings for this field

Returns

FieldMountable

Inherited from

API.createField

Source

packages/core/src/api/API.ts:128


createInlineFieldFromString()

createInlineFieldFromString(fieldString, filePath, scope, renderChildType, position?, honorExcludedSetting?): FieldMountable

Creates an inline field from a string. Will throw an error if the string is not a valid declaration.

Parameters

ParameterTypeDefault valueDescription
fieldStringstringundefinedthe declaration string of the field
filePathstringundefinedthe file path that the field is located in
scopeundefined | BindTargetScopeundefinedoptional bind target scope
renderChildTypeRenderChildTypeRenderChildType.INLINEthe render child type, default INLINE
position?NotePositionundefinedan optional note position
honorExcludedSetting?booleantruewhether to honor the excluded folders settings for this field

Returns

FieldMountable

Inherited from

API.createInlineFieldFromString

Source

packages/core/src/api/API.ts:188


createInlineFieldOfTypeFromString()

createInlineFieldOfTypeFromString(type, declaration, filePath, scope, renderChildType, position?, honorExcludedSetting?): FieldMountable

Creates an inline field of a given type and string. Will throw an error if the string is not a valid inline field type.

Parameters

ParameterTypeDefault valueDescription
typeInlineFieldTypeundefinedthe field type
declarationstringundefinedthe declaration string of the field
filePathstringundefinedthe file path that the field is located in
scopeundefined | BindTargetScopeundefinedoptional bind target scope
renderChildTypeRenderChildTypeRenderChildType.INLINEthe render child type, default INLINE
position?NotePositionundefinedan optional note position
honorExcludedSetting?booleantruewhether to honor the excluded folders settings for this field

Returns

FieldMountable

Inherited from

API.createInlineFieldOfTypeFromString

Source

packages/core/src/api/API.ts:245


createInputFieldMountable()

createInputFieldMountable(filePath, options): InputFieldMountable

Creates an input field from an options object.

Parameters

ParameterTypeDescription
filePathstringthe file path that the field is located in or an empty string
optionsInputFieldOptions

Returns

InputFieldMountable

Inherited from

API.createInputFieldMountable

Source

packages/core/src/api/API.ts:316


createJsViewFieldMountable()

createJsViewFieldMountable(filePath, options): JsViewFieldMountable

Creates a JS view field from an options object.

Parameters

ParameterTypeDescription
filePathstringthe file path that the field is located in or an empty string
optionsJsViewFieldOptions

Returns

JsViewFieldMountable

Inherited from

API.createJsViewFieldMountable

Source

packages/core/src/api/API.ts:384


createNotePosition()

createNotePosition(lineStart, lineEnd): NotePosition

Creates a note position from a line start and line end number.

Parameters

ParameterTypeDescription
lineStartnumber
lineEndnumber

Returns

NotePosition

Inherited from

API.createNotePosition

Source

packages/core/src/api/API.ts:809


createSignal()

createSignal<T>(value): Signal<T>

Creates a signal.

Type parameters

Type parameter
T

Parameters

ParameterTypeDescription
valueT

Returns

Signal<T>

Inherited from

API.createSignal

Source

packages/core/src/api/API.ts:630


createTableMountable()

createTableMountable(filePath, options): TableMountable

Creates a table from an options object.

Parameters

ParameterTypeDescription
filePathstringthe file path that the field is located in or an empty string
optionsTableOptions

Returns

TableMountable

Inherited from

API.createTableMountable

Source

packages/core/src/api/API.ts:414


createViewFieldMountable()

createViewFieldMountable(filePath, options): ViewFieldMountable

Creates a view field from an options object.

Parameters

ParameterTypeDescription
filePathstringthe file path that the field is located in or an empty string
optionsViewFieldOptions

Returns

ViewFieldMountable

Inherited from

API.createViewFieldMountable

Source

packages/core/src/api/API.ts:350


getInlineFieldDeclarationPrefix()

getInlineFieldDeclarationPrefix(fieldType): string

Gets the prefix of a given widget type. (e.g. INPUT or VIEW).

Parameters

ParameterTypeDescription
fieldTypeFieldType

Returns

string

Inherited from

API.getInlineFieldDeclarationPrefix

Source

packages/core/src/api/API.ts:544


getMetadata()

getMetadata(bindTarget): unknown

Reads a property from meta binds metadata cache. If the value is not present in the cache, it will check the underlying source. E.g. Obsidians metadata cache.

Parameters

ParameterTypeDescription
bindTargetBindTargetDeclaration

Returns

unknown

Inherited from

API.getMetadata

Source

packages/core/src/api/API.ts:724


isInlineFieldDeclaration()

isInlineFieldDeclaration(fieldType, str): boolean

Checks if a string is a declaration of a given widget type.

Parameters

ParameterTypeDescription
fieldTypeFieldType
strstringthe declaration string

Returns

boolean

Inherited from

API.isInlineFieldDeclaration

Source

packages/core/src/api/API.ts:575


isInlineFieldDeclarationAndGetType()

isInlineFieldDeclarationAndGetType(str): undefined | InlineFieldType

Checks if a string is any declaration and if yes returns the widget type.

Parameters

ParameterTypeDescription
strstringthe declaration string

Returns

undefined | InlineFieldType

Inherited from

API.isInlineFieldDeclarationAndGetType

Source

packages/core/src/api/API.ts:598


parseBindTarget()

parseBindTarget(declarationString, filePath, scope?): BindTargetDeclaration

Parses a bind target declaration from a string.

Parameters

ParameterTypeDescription
declarationStringstringthe string to parse
filePathstringthe file path that this bind target is relative to
scope?BindTargetScopeoptional bind target scope

Returns

BindTargetDeclaration

Inherited from

API.parseBindTarget

Source

packages/core/src/api/API.ts:678


reactiveMetadata()

reactiveMetadata(bindTargets, lifecycleHook, callback): ReactiveComponent

Creates a JS Engine reactive component that will re-render when the given bind targets change.

This requires JS Engine to be installed and enabled!

Parameters

ParameterTypeDescription
bindTargetsBindTargetDeclaration[]the bind targets to listen to
lifecycleHookLifecycleHooka Component
callback(…values) => Promise<unknown>the callback to call with all the values of the bind targets when one of them changes. What ever this callback returns will be rendered by the reactive component.

Returns

ReactiveComponent

Source

packages/obsidian/src/ObsidianAPI.ts:107


setMetadata()

setMetadata(bindTarget, value): void

Sets a property in meta binds metadata cache.

Parameters

ParameterTypeDescription
bindTargetBindTargetDeclaration
valueunknown

Returns

void

Inherited from

API.setMetadata

Source

packages/core/src/api/API.ts:705


subscribeToMetadata()

subscribeToMetadata(bindTarget, lifecycleHook, callback): void

Subscribes to a property in meta binds metadata cache. This returns a subscription that can be used to unsubscribe as well as update the cache. IF YOU DON’T CALL unsubscribe THE SUBSCRIPTION WILL LEAK MEMORY.

Parameters

ParameterTypeDescription
bindTargetBindTargetDeclaration
lifecycleHookLifecycleHookIn Obsidian this is an instance of the Component class. The subscription will be automatically unsubscribed when the component is unloaded.
callback(value) => void

Returns

void

Inherited from

API.subscribeToMetadata

Source

packages/core/src/api/API.ts:769


updateMetadata()

updateMetadata(bindTarget, updateFn): void

Updates a property in meta binds metadata cache.

Parameters

ParameterTypeDescription
bindTargetBindTargetDeclaration
updateFn(value) => unknowna function that takes the current value and returns the new value

Returns

void

Inherited from

API.updateMetadata

Source

packages/core/src/api/API.ts:743


wrapInMDRC()

wrapInMDRC(mountable, containerEl, component): MountableMDRC

Wraps any mountable in a MarkdownRenderChild and adds it as a child to the passed in ComponentLike.

A ComponentLike is either a Component or a MarkdownPostProcessorContext

Parameters

ParameterTypeDescription
mountableMountablethe mountable to wrap in a MarkdownRenderChild
containerElHTMLElementthe element to mount the MarkdownRenderChild to
componentComponentLikethe ComponentLike to register the MarkdownRenderChild to

Returns

MountableMDRC

Source

packages/obsidian/src/ObsidianAPI.ts:51