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-public-latest';Signature:
export interface ChildWidgetType extends ObsidianWidgetTypeExtends: ObsidianWidgetType
Constructor
new ChildWidgetType(app: App, editor: MarkdownBaseView)Constructor.
To extract the constructor type, use ExtractConstructor<ChildWidgetType>.
Properties
| Property | Type | Description | |
|---|---|---|---|
| actionsEl | HTMLElement | null | Element holding the widget's action buttons, or null until the first action is added.(Inherited from ObsidianWidgetType) | |
| app | App | Reference to the app. | |
| children | Component[] | Child components added through ChildWidgetType.addChild. | |
| containerEl | HTMLElement | Container element built by ObsidianWidgetType.initDOM and cached by ObsidianWidgetType.toDOM. (Inherited from ObsidianWidgetType) | |
| editor | MarkdownBaseView | Edit view that owns the widget. | |
| end | number | End offset of the widget's range in the document, or -1 before ObsidianWidgetType.setPos is called.(Inherited from ObsidianWidgetType) | |
| noReuse | boolean | Whether the widget should never be reused for a different instance. | |
| resizeObserver? | ResizeObserver | Observer used by ObsidianWidgetType.resizeWidget, created on first use. (Inherited from ObsidianWidgetType) | |
| start | number | Start offset of the widget's range in the document, or -1 before ObsidianWidgetType.setPos is called.(Inherited from ObsidianWidgetType) |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addAction(el, callback) | this | Add an action to the widget's action bar, creating the bar on first use. (Inherited from ObsidianWidgetType) | |
| addChild(component) | void | Add a child component, registering it on the owning edit view. | |
| addEditButton(view, el) | void | Add the standard edit button, which selects the widget's source range when clicked. (Inherited from ObsidianWidgetType) | |
| hookClickHandler(view, el) | void | Make clicks on the element select the widget's source range, unless they land inside a nested editor. (Inherited from ObsidianWidgetType) | |
| initDOM(view) | HTMLElement | Build the widget's container element. (Inherited from ObsidianWidgetType) | |
| removeChild(component) | void | Remove a child component, unregistering it from the owning edit view. | |
| resizeWidget(view, el) | void | Re-measure the editor whenever the given element resizes. (Inherited from ObsidianWidgetType) | |
| setOwner(el) | void | Register 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) | void | Record the document range the widget stands for. (Inherited from ObsidianWidgetType) | |
| toDOM(view) | HTMLElement | Get the widget's container element, building it via ObsidianWidgetType.initDOM on first call. (Inherited from ObsidianWidgetType) |
Links to this page: