UNPKG

obsidian-dev-utils

Version:

This is the collection of useful functions that you can use for your Obsidian plugin development

94 lines (93 loc) 3.11 kB
/** * @packageDocumentation * * Contains a component that displays and edits multiple text values. */ import type { Promisable } from 'type-fest'; import { ValueComponent } from 'obsidian'; import type { ValidatorElement } from '../../../HTMLElement.mjs'; import type { TextBasedComponent } from './TextBasedComponent.mjs'; import type { ValidatorComponent } from './ValidatorComponent.mjs'; import type { ValueComponentWithChangeTracking } from './ValueComponentWithChangeTracking.mjs'; /** * A component that displays and edits multiple text values. * * You can add this component using {@link SettingEx.addMultipleText}. * * In order to add the styles for the component, use {@link initPluginContext} in your plugin's `onload()` function. * * Alternatively, you can copy styles from {@link https://github.com/mnaoumov/obsidian-dev-utils/releases/latest/download/styles.css}. */ export declare class MultipleTextComponent extends ValueComponent<readonly string[]> implements TextBasedComponent<readonly string[]>, ValidatorComponent, ValueComponentWithChangeTracking<readonly string[]> { /** * The input element of the component. * * @returns The input element of the component. */ get inputEl(): HTMLTextAreaElement; /** * Gets the validator element of the component. * * @returns The validator element of the component. */ get validatorEl(): ValidatorElement; private readonly textAreaComponent; /** * Creates a new multiple text component. * * @param containerEl - The container element of the component. */ constructor(containerEl: HTMLElement); /** * Empties the component. */ empty(): void; /** * Gets the value of the component. * * @returns The value of the component. */ getValue(): readonly string[]; /** * Checks if the component is empty. * * @returns `true` if the component is empty, `false` otherwise. */ isEmpty(): boolean; /** * Adds a change listener to the component. * * @param callback - The callback to call when the value changes. * @returns The component. */ onChange(callback: (newValue: readonly string[]) => Promisable<void>): this; /** * Sets the disabled state of the component. * * @param disabled - The disabled state to set. * @returns The component. */ setDisabled(disabled: boolean): this; /** * Sets the placeholder of the component. * * @param placeholder - The placeholder to set. * @returns The component. */ setPlaceholder(placeholder: string): this; /** * Sets the placeholder value of the component. * * @param placeholderValue - The placeholder value to set. * @returns The component. */ setPlaceholderValue(placeholderValue: readonly string[]): this; /** * Sets the value of the component. * * @param value - The value to set. * @returns The component. */ setValue(value: readonly string[]): this; private valueToString; }