Skip to content

TextAreaComponent

Mock of Obsidian’s TextAreaComponent: a text component backed by a <textarea>.

Import:

import { TextAreaComponent } from 'obsidian-test-mocks/obsidian';

Signature:

export class TextAreaComponent extends AbstractTextComponent<HTMLTextAreaElement>

Extends: AbstractTextComponent<HTMLTextAreaElement>

Constructor

new TextAreaComponent(containerEl: HTMLElement)

Creates a text area and appends its <textarea> to the container.

Properties

PropertyTypeDescription
changeCallback?(value: string) => unknownThe callback registered with AbstractTextComponent.onChange, if any.
(Inherited from AbstractTextComponent)
inputElHTMLTextAreaElementThe wrapped <input> or <textarea> element.
(Inherited from AbstractTextComponent)

Methods

MethodReturnsDescription
asOriginalType2__()ValueComponentOriginal<string>Mock-only: views this mock as Obsidian's ValueComponent type.
(Inherited from AbstractTextComponent)
asOriginalType3__()AbstractTextComponentOriginal<HTMLTextAreaElement>Mock-only: views this mock as Obsidian's AbstractTextComponent type.
(Inherited from AbstractTextComponent)
asOriginalType4__()TextAreaComponentOriginalMock-only: views this mock as Obsidian's TextAreaComponent type.
constructor2__()voidMock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(ValueComponent.prototype, 'constructor2__').
(Inherited from AbstractTextComponent)
constructor3__(_inputEl)voidMock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(AbstractTextComponent.prototype, 'constructor3__').
(Inherited from AbstractTextComponent)
constructor4__(_containerEl)voidMock-only construction hook, called at the end of the constructor; a no-op meant for vi.spyOn(TextAreaComponent.prototype, 'constructor4__').
getValue()stringGets the component's value.
(Inherited from AbstractTextComponent)
onChange(callback)thisRegisters the callback to call when the user edits the value, replacing any earlier one.
(Inherited from AbstractTextComponent)
onChanged()voidCalls the change callback with the element's current value. The element's input listener calls it.
(Inherited from AbstractTextComponent)
registerOptionListener(_listeners, _key)thisRegisters a listener under key that sets the component's value when called with one and returns the current value. A no-op in the mock, which registers nothing.
(Inherited from AbstractTextComponent)
setDisabled(disabled)thisEnables or disables the component, writing the flag to the wrapped element as Obsidian does.
(Inherited from AbstractTextComponent)
setPlaceholder(placeholder)thisSets the element's placeholder text.
(Inherited from AbstractTextComponent)
setValue(value)thisWrites the value into the element. As in Obsidian, the change callback is not called, and a value that is not a string is ignored.
(Inherited from AbstractTextComponent)
static create__(containerEl)TextAreaComponentMock-only factory: creates a text area, spyable via vi.spyOn(TextAreaComponent, 'create__').
static fromOriginalType2__(value)ValueComponent<string>Mock-only: views a value typed as Obsidian's ValueComponent as this mock.
(Inherited from AbstractTextComponent)
static fromOriginalType3__(value)AbstractTextComponent<HTMLTextAreaElement>Mock-only: views a value typed as Obsidian's AbstractTextComponent as this mock.
(Inherited from AbstractTextComponent)
static fromOriginalType4__(value)TextAreaComponentMock-only: views a value typed as Obsidian's TextAreaComponent as this mock.