Skip to content

MetadataEditor

Extends

Properties

_children

_children: Component[]

Child Components attached to current component, will be unloaded on unloading parent component

Inherited from

Component._children


_events

_events: EventRef[]

Events that are attached to the current component, will be detached on unloading parent component

Inherited from

Component._events


_loaded

_loaded: boolean

Whether the component and its children are loaded

Inherited from

Component._loaded


addPropertyButtonEl

addPropertyButtonEl: HTMLButtonElement

Button element for adding a new property


app

app: App

Reference to the app


collapsed

collapsed: boolean

Whether the frontmatter editor is collapsed


containerEl

containerEl: HTMLElement

Container element for the metadata editor


contentEl

contentEl: HTMLElement

Element containing metadata table and addPropertyButton


focusedLine

focusedLine: null | MetadataEditorProperty

The currently focused property


foldEl

foldEl: HTMLElement

Fold button for folding away the frontmatter editor on hovering over headingEl


headingEl

headingEl: HTMLElement

Heading element for the metadata editor


hoverPopover

hoverPopover: null | HoverPopover

Hover element container


owner

owner: MarkdownView

Owner of the metadata editor


properties

properties: PropertyEntryData<unknown>[]

All properties existing in the metadata editor


propertyListEl

propertyListEl: HTMLElement

Element containing all property elements


rendered

rendered: MetadataEditorProperty[]

List of all property field editors


selectedLines

selectedLines: Set<MetadataEditorProperty>

Set of all selected property editors

Methods

_copyToClipboard()

_copyToClipboard(event, properties): void

Convert given properties to a serialized object and store in clipboard as obsidian/properties

Parameters

event: ClipboardEvent

properties: MetadataEditorProperty[]

Returns

void


addChild()

addChild<T>(component): T

Adds a child component, loading it if this component is loaded

Type Parameters

T extends Component

Parameters

component: T

Returns

T

Inherited from

Component.addChild


addProperty()

addProperty(): void

Uncollapse editor if collapsed and create a new property row

Returns

void


clear()

clear(): void

Clear all properties

Returns

void


clearSelection()

clearSelection(): void

Unselect all lines

Returns

void


focusKey()

focusKey(key): void

Focus on property field with given key

Parameters

key: string

Returns

void


focusProperty()

focusProperty(property): void

Focus on property

Parameters

property: MetadataEditorProperty

Returns

void


focusPropertyAtIndex()

focusPropertyAtIndex(index): void

Focus on property at specified index

Parameters

index: number

Returns

void


focusValue()

focusValue(value, which): void

Focus on property with value

Parameters

value: string

which: "both" | "end" | "start"

Returns

void


handleCopy()

handleCopy(event): void

Handle copy event on selection and serialize properties

Parameters

event: ClipboardEvent

Returns

void


handleCut()

handleCut(event): void

Handle cut event and serialize and remove properties

Parameters

event: ClipboardEvent

Returns

void


handleItemSelection()

handleItemSelection(event, property): boolean

Handle selection of item for drag handling

Parameters

event: PointerEvent

property: MetadataEditorProperty

Returns

boolean


handleKeypress()

handleKeypress(event): void

Handle key press event for controlling selection or movement of property up/down

Parameters

event: KeyboardEvent

Returns

void


handlePaste()

handlePaste(event): void

Handle paste event of properties into metadata editor

Parameters

event: ClipboardEvent

Returns

void


hasFocus()

hasFocus(): boolean

Whether the editor has focus

Returns

boolean


hasPropertyFocused()

hasPropertyFocused(): boolean

Whether there is a property that is focused

Returns

boolean


insertProperties()

insertProperties(properties): void

Add new properties to the metadata editor and save

Parameters

properties: Record<string, any>

Returns

void


load()

load(): void

Load this component and its children

Returns

void

Inherited from

Component.load


onload()

onload(): void

On loading of the metadata editor, register on metadata type change event

Returns

void

Overrides

Component.onload


onMetadataTypeChange()

onMetadataTypeChange(property): void

On vault metadata update, update property render

Parameters

property: MetadataEditorProperty

Returns

void


onunload()

onunload(): void

Override this to unload your component

Returns

void

Inherited from

Component.onunload


register()

register(cb): void

Registers a callback to be called when unloading

Parameters

cb

Returns

void

Inherited from

Component.register


registerDomEvent()

registerDomEvent(el, type, callback, options)

registerDomEvent<K>(el, type, callback, options?): void

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof WindowEventMap

Parameters

el: Window

type: K

callback

options?: boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent

registerDomEvent(el, type, callback, options)

registerDomEvent<K>(el, type, callback, options?): void

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof DocumentEventMap

Parameters

el: Document

type: K

callback

options?: boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent

registerDomEvent(el, type, callback, options)

registerDomEvent<K>(el, type, callback, options?): void

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof HTMLElementEventMap

Parameters

el: HTMLElement

type: K

callback

options?: boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent


registerEvent()

registerEvent(eventRef): void

Registers an event to be detached when unloading

Parameters

eventRef: EventRef

Returns

void

Inherited from

Component.registerEvent


registerInterval()

registerInterval(id): number

Registers an interval (from setInterval) to be cancelled when unloading Use setInterval instead of setInterval to avoid TypeScript confusing between NodeJS vs Browser API

Parameters

id: number

Returns

number

Inherited from

Component.registerInterval


registerScopeEvent()

registerScopeEvent(keymapEventHandler): void

Parameters

keymapEventHandler: KeymapEventHandler

Returns

void

Inherited from

Component.registerScopeEvent


removeChild()

removeChild<T>(component): T

Removes a child component, unloading it

Type Parameters

T extends Component

Parameters

component: T

Returns

T

Inherited from

Component.removeChild


removeProperties()

removeProperties(properties, reset_focus?): unknown

Remove specified properties from the metadata editor and save, and reset focus if specified

Parameters

properties: MetadataEditorProperty[]

reset_focus?: boolean

Returns

unknown


reorderKey()

reorderKey(entry, index): unknown

Reorder the entry to specified index position and save

Parameters

entry: PropertyEntryData<unknown>

index: number

Returns

unknown


save()

save(): void

Serialize the properties and save frontmatter

Returns

void


selectAll()

selectAll(): void

Select all property fields

Returns

void


selectProperty()

selectProperty(property, select): void

Mark specified property as selected

Parameters

property: undefined | MetadataEditorProperty

select: boolean

Returns

void


serialize()

serialize(): Record<string, any>

Convert properties to a serialized object

Returns

Record<string, any>


setCollapse()

setCollapse(collapsed, x): void

Sets frontmatter as collapsed or uncollapsed

Parameters

collapsed: boolean

x: boolean

Returns

void


showPropertiesMenu()

showPropertiesMenu(event): void

On context menu event on header element, show property menu

Parameters

event: MouseEvent

Returns

void


synchronize()

synchronize(data): void

Synchronize data with given properties and re-render them

Parameters

data: Record<string, any>

Returns

void


toggleCollapse()

toggleCollapse(): void

Toggle collapsed state of the metadata editor

Returns

void


unload()

unload(): void

Unload this component and its children

Returns

void

Inherited from

Component.unload