Skip to content

MetadataEditor

Unofficial

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

Import:

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

Signature:

export interface MetadataEditor extends Component

Extends: Component

Constructor

new MetadataEditor()

Constructor.

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

Properties

Property Type Description
_children Component[] Child Components attached to current component, will be unloaded on unloading parent component.
(Inherited from Component)
_events EventRef[] Events that are attached to the current component, will be detached on unloading parent component.
(Inherited from Component)
_loaded boolean Whether the component and its children are loaded.
(Inherited from Component)
addPropertyButtonEl HTMLButtonElement Button element for adding a new property.
app App Reference to the app.
collapsed boolean Whether the frontmatter editor is collapsed.
containerEl HTMLElement Container element for the metadata editor.
contentEl HTMLElement Element containing metadata table and addPropertyButton.
focusedLine MetadataEditorProperty | null The currently focused property.
foldEl HTMLElement Fold button for folding away the frontmatter editor on hovering over headingEl.
headingEl HTMLElement Heading element for the metadata editor.
hoverPopover HoverPopover | null Hover element container.
owner MarkdownView Owner of the metadata editor.
properties PropertyEntryData<unknown>[] All properties existing in the metadata editor.
propertyListEl HTMLElement Element containing all property elements.
rendered MetadataEditorProperty[] List of all property field editors.
selectedLines Set<MetadataEditorProperty> Set of all selected property editors.

Methods

Method Returns Description
_copyToClipboard(event, properties) void Convert given properties to a serialized object and store in clipboard as obsidian/properties.
addChild(component) T Adds a child component, loading it if this component is loaded.
(Inherited from Component)
addProperty() void Uncollapse editor if collapsed and create a new property row.
clear() void Clear all properties.
clearSelection() void Unselect all lines.
focusKey(key) void Focus on property field with given key.
focusProperty(property) void Focus on property.
focusPropertyAtIndex(index) void Focus on property at specified index.
focusValue(value, mode) void Focus on property with value.
handleCopy(event) void Handle copy event on selection and serialize properties.
handleCut(event) void Handle cut event and serialize and remove properties.
handleItemSelection(event, property) boolean Handle selection of item for drag handling.
handleKeypress(event) void Handle key press event for controlling selection or movement of property up/down.
handlePaste(event) void Handle paste event of properties into metadata editor.
hasFocus() boolean Whether the editor has focus.
hasPropertyFocused() boolean Whether there is a property that is focused.
insertProperties(properties) void Add new properties to the metadata editor and save.
load() void Load this component and its children.
(Inherited from Component)
onload() void On loading of the metadata editor, register on metadata type change event.
onMetadataTypeChange(property) void On vault metadata update, update property render.
onunload() void Override this to unload your component
(Inherited from Component)
register(cb) void Registers a callback to be called when unloading.
(Inherited from Component)
registerDomEvent(el, type, callback, options?) void Registers a DOM event to be detached when unloading.
(Inherited from Component)
registerDomEvent(el, type, callback, options?) void Registers a DOM event to be detached when unloading
(Inherited from Component)
registerDomEvent(el, type, callback, options?) void Registers a DOM event to be detached when unloading
(Inherited from Component)
registerEvent(eventRef) void Registers an event to be detached when unloading.
(Inherited from Component)
registerInterval(id) number Registers 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) void Register a scope keymap event handler to be removed on unload.
(Inherited from Component)
removeChild(component) T Removes a child component, unloading it.
(Inherited from Component)
removeProperties(properties, resetFocus?) unknown Remove specified properties from the metadata editor and save, and reset focus if specified.
reorderKey(entry, index) unknown Reorder the entry to specified index position and save.
save() void Serialize the properties and save frontmatter.
selectAll() void Select all property fields.
selectProperty(property, select) void Mark specified property as selected.
serialize() Record<string, unknown> Convert properties to a serialized object.
setCollapse(collapsed, x) void Sets frontmatter as collapsed or uncollapsed.
showPropertiesMenu(event) void On context menu event on header element, show property menu.
synchronize(data) void Synchronize data with given properties and re-render them.
toggleCollapse() void Toggle collapsed state of the metadata editor.
unload() void Override this to unload your component.
(Inherited from Component)

Links to this page: