Skip to content

MetadataEditor

Unofficial

Editor component for managing frontmatter property fields in a markdown view.

Import:

import type { MetadataEditor } from '@obsidian-typings/obsidian-public-latest';

Signature:

export interface MetadataEditor extends Component

Extends: Component

Constructor

new MetadataEditor()

Constructor.

To extract the constructor type, use ExtractConstructor<Component>.

Properties

PropertyTypeDescription
_childrenComponent[]Child Components attached to current component, will be unloaded on unloading parent component.
(Inherited from Component)
_eventsEventRef[]Events that are attached to the current component, will be detached on unloading parent component.
(Inherited from Component)
_loadedbooleanWhether the component and its children are loaded.
(Inherited from Component)
addPropertyButtonElHTMLButtonElementButton element for adding a new property.
appAppReference to the app.
collapsedbooleanWhether the frontmatter editor is collapsed.
containerElHTMLElementContainer element for the metadata editor.
contentElHTMLElementElement containing metadata table and addPropertyButton.
focusedLineMetadataEditorProperty | nullThe currently focused property.
foldElHTMLElementFold button for folding away the frontmatter editor on hovering over headingEl.
headingElHTMLElementHeading element for the metadata editor.
hoverPopoverHoverPopover | nullHover element container.
ownerMarkdownViewOwner of the metadata editor.
propertiesPropertyEntryData<unknown>[]All properties existing in the metadata editor.
propertyListElHTMLElementElement containing all property elements.
renderedMetadataEditorProperty[]List of all property field editors.
selectedLinesSet<MetadataEditorProperty>Set of all selected property editors.

Methods

MethodReturnsDescription
_copyToClipboard(event, properties)voidConvert given properties to a serialized object and store in clipboard as obsidian/properties.
addChild(component)TAdds a child component, loading it if this component is loaded.
(Inherited from Component)
addProperty()voidUncollapse editor if collapsed and create a new property row.
clear()voidClear all properties.
clearSelection()voidUnselect all lines.
focusKey(key)voidFocus on property field with given key.
focusProperty(property)voidFocus on property.
focusPropertyAtIndex(index)voidFocus on property at specified index.
focusValue(value, mode)voidFocus on property with value.
handleCopy(event)voidHandle copy event on selection and serialize properties.
handleCut(event)voidHandle cut event and serialize and remove properties.
handleItemSelection(event, property)booleanHandle selection of item for drag handling.
handleKeypress(event)voidHandle key press event for controlling selection or movement of property up/down.
handlePaste(event)voidHandle paste event of properties into metadata editor.
hasFocus()booleanWhether the editor has focus.
hasPropertyFocused()booleanWhether there is a property that is focused.
insertProperties(properties)voidAdd new properties to the metadata editor and save.
load()voidLoad this component and its children.
(Inherited from Component)
onload()voidOn loading of the metadata editor, register on metadata type change event.
onMetadataTypeChange(property)voidOn vault metadata update, update property render.
onunload()voidOverride this to unload your component
(Inherited from Component)
register(cb)voidRegisters a callback to be called when unloading.
(Inherited from Component)
registerDomEvent(el, type, callback, options?)voidRegisters a DOM event to be detached when unloading.
(Inherited from Component)
registerDomEvent(el, type, callback, options?)voidRegisters a DOM event to be detached when unloading
(Inherited from Component)
registerDomEvent(el, type, callback, options?)voidRegisters a DOM event to be detached when unloading
(Inherited from Component)
registerEvent(eventRef)voidRegisters an event to be detached when unloading.
(Inherited from Component)
registerInterval(id)numberRegisters an interval (from setInterval) to be cancelled when unloading. Use window.setInterval instead of setInterval to avoid TypeScript confusing between NodeJS vs Browser API
(Inherited from Component)
registerScopeEvent(keymapEventHandler)voidRegister a scope keymap event handler to be removed on unload.
(Inherited from Component)
removeChild(component)TRemoves a child component, unloading it.
(Inherited from Component)
removeProperties(properties, resetFocus?)unknownRemove specified properties from the metadata editor and save, and reset focus if specified.
reorderKey(entry, index)unknownReorder the entry to specified index position and save.
save()voidSerialize the properties and save frontmatter.
selectAll()voidSelect all property fields.
selectProperty(property, select)voidMark specified property as selected.
serialize()Record<string, unknown>Convert properties to a serialized object.
setCollapse(collapsed, x)voidSets frontmatter as collapsed or uncollapsed.
showPropertiesMenu(event)voidOn context menu event on header element, show property menu.
synchronize(data)voidSynchronize data with given properties and re-render them.
toggleCollapse()voidToggle collapsed state of the metadata editor.
unload()voidOverride this to unload your component.
(Inherited from Component)

Links to this page: