Skip to content

ChildWidgetType

Unofficial

ObsidianWidgetType that can host obsidian#Component children.

Children are registered on the owning edit view rather than on the widget, so they survive for as long as the view does; the widget only keeps its own list so it can drop them again.

Despite managing components, this is not itself a obsidian#Component - it is a CodeMirror @codemirror/view#WidgetType.

Import:

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

Signature:

export interface ChildWidgetType extends ObsidianWidgetType

Extends: ObsidianWidgetType

Constructor

new ChildWidgetType(app: App, editor: MarkdownBaseView)

Constructor.

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

Properties

PropertyTypeDescription
actionsElHTMLElement | nullElement holding the widget's action buttons, or null until the first action is added.
(Inherited from ObsidianWidgetType)
appAppReference to the app.
childrenComponent[]Child components added through ChildWidgetType.addChild.
containerElHTMLElementContainer element built by ObsidianWidgetType.initDOM and cached by ObsidianWidgetType.toDOM.
(Inherited from ObsidianWidgetType)
editorMarkdownBaseViewEdit view that owns the widget.
endnumberEnd offset of the widget's range in the document, or -1 before ObsidianWidgetType.setPos is called.
(Inherited from ObsidianWidgetType)
noReusebooleanWhether the widget should never be reused for a different instance.
resizeObserver?ResizeObserverObserver used by ObsidianWidgetType.resizeWidget, created on first use.
(Inherited from ObsidianWidgetType)
startnumberStart offset of the widget's range in the document, or -1 before ObsidianWidgetType.setPos is called.
(Inherited from ObsidianWidgetType)

Methods

MethodReturnsDescription
addAction(el, callback)thisAdd an action to the widget's action bar, creating the bar on first use.
(Inherited from ObsidianWidgetType)
addChild(component)voidAdd a child component, registering it on the owning edit view.
addEditButton(view, el)voidAdd the standard edit button, which selects the widget's source range when clicked.
(Inherited from ObsidianWidgetType)
hookClickHandler(view, el)voidMake clicks on the element select the widget's source range, unless they land inside a nested editor.
(Inherited from ObsidianWidgetType)
initDOM(view)HTMLElementBuild the widget's container element.
(Inherited from ObsidianWidgetType)
removeChild(component)voidRemove a child component, unregistering it from the owning edit view.
resizeWidget(view, el)voidRe-measure the editor whenever the given element resizes.
(Inherited from ObsidianWidgetType)
setOwner(el)voidRegister the widget as the owner of the given element, so that clicks on it can be routed back here.
(Inherited from ObsidianWidgetType)
setPos(start, end)voidRecord the document range the widget stands for.
(Inherited from ObsidianWidgetType)
toDOM(view)HTMLElementGet the widget's container element, building it via ObsidianWidgetType.initDOM on first call.
(Inherited from ObsidianWidgetType)

Links to this page: