ObsidianAPI
Defined in: packages/obsidian/src/ObsidianAPI.ts:38
Meta Bind API for Obsidian.
Extends
API
<MetaBindPlugin
>
Constructors
new ObsidianAPI()
new ObsidianAPI(
plugin
):ObsidianAPI
Defined in: packages/obsidian/src/ObsidianAPI.ts:39
Parameters
Parameter | Type |
---|---|
|
|
Returns
Overrides
API<MetaBindPlugin>.constructor
Properties
bindTargetParser
readonly
bindTargetParser:BindTargetParser
Defined in: packages/core/src/api/API.ts:91
Inherited from
API.bindTargetParser
buttonActionRunner
readonly
buttonActionRunner:ButtonActionRunner
Defined in: packages/core/src/api/API.ts:96
Inherited from
API.buttonActionRunner
buttonManager
readonly
buttonManager:ButtonManager
Defined in: packages/core/src/api/API.ts:97
Inherited from
API.buttonManager
buttonParser
readonly
buttonParser:ButtonParser
Defined in: packages/core/src/api/API.ts:90
Inherited from
API.buttonParser
inputFieldFactory
readonly
inputFieldFactory:InputFieldFactory
Defined in: packages/core/src/api/API.ts:93
Inherited from
API.inputFieldFactory
inputFieldParser
readonly
inputFieldParser:InputFieldParser
Defined in: packages/core/src/api/API.ts:87
Inherited from
API.inputFieldParser
jsViewFieldParser
readonly
jsViewFieldParser:JsViewFieldParser
Defined in: packages/core/src/api/API.ts:89
Inherited from
API.jsViewFieldParser
plugin
readonly
plugin:MetaBindPlugin
Defined in: packages/core/src/api/API.ts:85
Inherited from
API.plugin
syntaxHighlighting
readonly
syntaxHighlighting:SyntaxHighlightingAPI
Defined in: packages/core/src/api/API.ts:99
Inherited from
API.syntaxHighlighting
viewFieldFactory
readonly
viewFieldFactory:ViewFieldFactory
Defined in: packages/core/src/api/API.ts:94
Inherited from
API.viewFieldFactory
viewFieldParser
readonly
viewFieldParser:ViewFieldParser
Defined in: packages/core/src/api/API.ts:88
Inherited from
API.viewFieldParser
Methods
constructMDRCWidget()
constructMDRCWidget(
inlineFieldType
,content
,filePath
,component
):MarkdownRenderChildWidget
Defined in: packages/obsidian/src/ObsidianAPI.ts:83
Creates a CM6 widget from a given widget type.
This is only useful fur use in a CodeMirror plugin.
Parameters
Parameter | Type | Description |
---|---|---|
|
||
|
|
|
|
|
|
|
|
Returns
MarkdownRenderChildWidget
createBindTarget()
createBindTarget(
storageType
,storagePath
,property
,listenToChildren
):BindTargetDeclaration
Defined in: packages/core/src/api/API.ts:641
Creates a bind target declaration.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
|
|
|
the storage type (also named metadata source sometimes) |
|
|
|
the storage path (usually the file path) |
|
|
|
the property access path as an array. E.g. for the path |
|
|
|
whether to listen to children, only relevant for arrays and objects |
Returns
Inherited from
API.createBindTarget
createButtonGroupMountable()
createButtonGroupMountable(
filePath
,options
):ButtonGroupMountable
Defined in: packages/core/src/api/API.ts:436
Creates a button group from an options object.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the file path that the field is located in or an empty string |
|
Returns
ButtonGroupMountable
Inherited from
API.createButtonGroupMountable
createButtonMountable()
createButtonMountable(
filePath
,options
):ButtonMountable
Defined in: packages/core/src/api/API.ts:473
Creates a button from an options object.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the file path that the field is located in or an empty string |
|
Returns
ButtonMountable
Inherited from
API.createButtonMountable
createEmbedMountable()
createEmbedMountable(
filePath
,options
):EmbedMountable
Defined in: packages/core/src/api/API.ts:503
Creates a meta bind embed fields from an options object.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the file path that the field is located in or an empty string |
|
Returns
EmbedMountable
Inherited from
API.createEmbedMountable
createExcludedMountable()
createExcludedMountable(
filePath
):ExcludedMountable
Defined in: packages/core/src/api/API.ts:524
Creates an excluded notification mountable for the excluded folders setting.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the file path that the field is located in or an empty string |
Returns
ExcludedMountable
Inherited from
API.createExcludedMountable
createField()
createField<
Type
>(type
,filePath
,options
,honorExcludedSetting
):FieldMountable
Defined in: packages/core/src/api/API.ts:127
Creates a field of a given type.
Type Parameters
Type Parameter |
---|
|
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
|
|
|
the type of the field |
|
|
|
the file path that the field is located in, or an empty string if it is not in a file |
|
|
|
|
|
|
|
whether to honor the excluded folders settings for this field |
Returns
Inherited from
API.createField
createInlineFieldFromString()
createInlineFieldFromString(
fieldString
,filePath
,scope
,renderChildType
,position
?,honorExcludedSetting
?):FieldMountable
Defined in: packages/core/src/api/API.ts:187
Creates an inline field from a string. Will throw an error if the string is not a valid declaration.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
|
|
|
the declaration string of the field |
|
|
|
the file path that the field is located in |
|
|
|
optional bind target scope |
|
|
the render child type, default INLINE |
|
|
|
an optional note position |
|
|
|
|
whether to honor the excluded folders settings for this field |
Returns
Inherited from
API.createInlineFieldFromString
createInlineFieldOfTypeFromString()
createInlineFieldOfTypeFromString(
type
,declaration
,filePath
,scope
,renderChildType
,position
?,honorExcludedSetting
?):FieldMountable
Defined in: packages/core/src/api/API.ts:244
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
Parameter | Type | Default value | Description |
---|---|---|---|
|
|
the field type |
|
|
|
|
the declaration string of the field |
|
|
|
the file path that the field is located in |
|
|
|
optional bind target scope |
|
|
the render child type, default INLINE |
|
|
|
an optional note position |
|
|
|
|
whether to honor the excluded folders settings for this field |
Returns
Inherited from
API.createInlineFieldOfTypeFromString
createInputFieldMountable()
createInputFieldMountable(
filePath
,options
):InputFieldMountable
Defined in: packages/core/src/api/API.ts:315
Creates an input field from an options object.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the file path that the field is located in or an empty string |
|
Returns
InputFieldMountable
Inherited from
API.createInputFieldMountable
createJsViewFieldMountable()
createJsViewFieldMountable(
filePath
,options
):JsViewFieldMountable
Defined in: packages/core/src/api/API.ts:383
Creates a JS view field from an options object.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the file path that the field is located in or an empty string |
|
Returns
JsViewFieldMountable
Inherited from
API.createJsViewFieldMountable
createNotePosition()
createNotePosition(
lineStart
,lineEnd
):NotePosition
Defined in: packages/core/src/api/API.ts:813
Creates a note position from a line start and line end number.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
|
|
|
Returns
Inherited from
API.createNotePosition
createSignal()
createSignal<
T
>(value
):Signal
<T
>
Defined in: packages/core/src/api/API.ts:629
Creates a signal.
Type Parameters
Type Parameter |
---|
|
Parameters
Parameter | Type | Description |
---|---|---|
|
|
Returns
Signal
<T
>
Inherited from
API.createSignal
createTableMountable()
createTableMountable(
filePath
,options
):TableMountable
Defined in: packages/core/src/api/API.ts:413
Creates a table from an options object.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the file path that the field is located in or an empty string |
|
Returns
TableMountable
Inherited from
API.createTableMountable
createViewFieldMountable()
createViewFieldMountable(
filePath
,options
):ViewFieldMountable
Defined in: packages/core/src/api/API.ts:349
Creates a view field from an options object.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the file path that the field is located in or an empty string |
|
Returns
ViewFieldMountable
Inherited from
API.createViewFieldMountable
getInlineFieldDeclarationPrefix()
getInlineFieldDeclarationPrefix(
fieldType
):string
Defined in: packages/core/src/api/API.ts:543
Gets the prefix of a given widget type. (e.g. INPUT or VIEW).
Parameters
Parameter | Type | Description |
---|---|---|
|
Returns
string
Inherited from
API.getInlineFieldDeclarationPrefix
getMetadata()
getMetadata(
bindTarget
):unknown
Defined in: packages/core/src/api/API.ts:723
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
Parameter | Type | Description |
---|---|---|
|
Returns
unknown
Inherited from
API.getMetadata
isInlineFieldDeclaration()
isInlineFieldDeclaration(
fieldType
,str
):boolean
Defined in: packages/core/src/api/API.ts:574
Checks if a string is a declaration of a given widget type.
Parameters
Parameter | Type | Description |
---|---|---|
|
||
|
|
the declaration string |
Returns
boolean
Inherited from
API.isInlineFieldDeclaration
isInlineFieldDeclarationAndGetType()
isInlineFieldDeclarationAndGetType(
str
):undefined
|InlineFieldType
Defined in: packages/core/src/api/API.ts:597
Checks if a string is any declaration. If yes, it returns the widget type, otherwise undefined.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the declaration string |
Returns
undefined
| InlineFieldType
Inherited from
API.isInlineFieldDeclarationAndGetType
parseBindTarget()
parseBindTarget(
declarationString
,filePath
,scope
?):BindTargetDeclaration
Defined in: packages/core/src/api/API.ts:677
Parses a bind target declaration from a string.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the string to parse |
|
|
the file path that this bind target is relative to |
|
|
optional bind target scope |
Returns
Inherited from
API.parseBindTarget
reactiveMetadata()
reactiveMetadata(
bindTargets
,lifecycleHook
,callback
):ReactiveComponent
Defined in: packages/obsidian/src/ObsidianAPI.ts:109
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
Parameter | Type | Description |
---|---|---|
|
the bind targets to listen to |
|
|
|
|
|
(… |
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
setMetadata()
setMetadata(
bindTarget
,value
):void
Defined in: packages/core/src/api/API.ts:704
Sets a property in meta binds metadata cache.
Parameters
Parameter | Type | Description |
---|---|---|
|
||
|
|
Returns
void
Inherited from
API.setMetadata
subscribeToMetadata()
subscribeToMetadata(
bindTarget
,lifecycleHook
,callback
):void
Defined in: packages/core/src/api/API.ts:773
Subscribes to a property in meta binds metadata cache.
This expects some sort of lifecycle hook to be passed in.
This method will register a callback to the lifecycle hook.
To unsubscribe the subscription, the callback registered to the lifecycle hook must be called.
In the context of Obsidian, you should pass a Component
instance as the lifecycle hook and
make sure to unload the component when you are done using the metadata subscription.
NOT UNSUBSCRIBING WILL LEAD TO MEMORY LEAKS.
Parameters
Parameter | Type | Description |
---|---|---|
|
||
|
|
In Obsidian this is an instance of the Component class. The subscription will be automatically unsubscribed when the component is unloaded. |
|
( |
Returns
void
Inherited from
API.subscribeToMetadata
updateMetadata()
updateMetadata(
bindTarget
,updateFn
):void
Defined in: packages/core/src/api/API.ts:742
Updates a property in meta binds metadata cache.
Parameters
Parameter | Type | Description |
---|---|---|
|
||
|
( |
a function that takes the current value and returns the new value |
Returns
void
Inherited from
API.updateMetadata
wrapInMDRC()
wrapInMDRC(
mountable
,containerEl
,component
):MountableMDRC
Defined in: packages/obsidian/src/ObsidianAPI.ts:53
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
Parameter | Type | Description |
---|---|---|
|
the mountable to wrap in a MarkdownRenderChild |
|
|
the element to mount the MarkdownRenderChild to |
|
|
the ComponentLike to register the MarkdownRenderChild to |
Returns
MountableMDRC