FilePathComponent
A component that edits the path of one vault file: a text input whose suggest offers the vault’s files, showing each file’s name and path with the matched characters highlighted. The value is the typed text; a path need not exist yet, and FilePathComponent.getFile resolves it.
You can add this component using SettingEx.addFilePath.
In order to add the styles for the component, use initPluginContext in your plugin’s onload() function.
Import:
import { FilePathComponent } from '@mnaoumov/obsidian-lib/setting-components/file-path-component';Signature:
export class FilePathComponent extends TypedTextComponent<string> implements TextBasedComponent<string>Extends: TypedTextComponent<string>
Implements: TextBasedComponent<string>
Constructor
new FilePathComponent(containerEl: HTMLElement, app: App, options?: FileInputSuggestConstructorOptions | undefined)Creates a new file path component.
Properties
| Property | Type | Description |
|---|---|---|
| empty | () => void | Empties the component. (Inherited from TextBasedComponent) |
| inputEl | HTMLInputElement | An input element of the component. (Inherited from TypedTextComponent) |
| isEmpty | () => boolean | Checks if the component is empty. (Inherited from TextBasedComponent) |
| onChange | (callback: (newValue: string) => void) => this | Sets a callback function to be called when the value of the component changes. (Inherited from TypedTextComponent) |
| setPlaceholderValue | (placeholderValue: string) => this | Sets the placeholder value of the component. (Inherited from TextBasedComponent) |
| suggest | FileInputSuggest | The file suggest attached to TypedTextComponent.inputEl. |
| textComponent | TextComponent | The inner text component. (Inherited from TypedTextComponent) |
| validatorEl | ValidatorElement | A validator element of the component. (Inherited from TypedTextComponent) |
Methods
| Method | Returns | Description |
|---|---|---|
| empty() | void | Empties the component. |
| getFile() | null | TFile | Resolves the typed path, normalized with Obsidian's normalizePath, to a vault file. |
| getValue() | string | Gets the value of the component. (Inherited from TypedTextComponent) |
| isEmpty() | boolean | Checks if the component is empty. |
| onChange(callback) | this | Sets the callback function to be called when the component is changed. (Inherited from TypedTextComponent) |
| onChanged() | void | Called when the component is changed. (Inherited from TypedTextComponent) |
| setDisabled(isDisabled) | this | Sets the disabled state of the component. (Inherited from TypedTextComponent) |
| setPlaceholderValue(placeholderValue) | this | Sets the placeholder value of the component. |
| setValue(value) | this | Sets the value of the component. (Inherited from TypedTextComponent) |
| valueFromString($string) | string | Converts a string to a file path. |
| valueToString(value) | string | Converts a value to a string. (Inherited from TypedTextComponent) |
Links to this page: