Skip to content

FileComponent

A component that displays and edits a file.

You can add this component using SettingEx.addFile.

In order to add the styles for the component, use initPluginContext in your plugin’s onload() function.

Alternatively, you can copy styles from https://github.com/mnaoumov/obsidian-dev-utils/releases/latest/download/styles.css.

Import:

import { FileComponent } from 'obsidian-dev-utils/obsidian/setting-components/file-component';

Signature:

export class FileComponent extends TypedTextComponent<File | null>

Extends: TypedTextComponent<File | null>

Constructor

new FileComponent(containerEl: HTMLElement)

Creates a new file component.

Properties

PropertyTypeDescription
inputElHTMLInputElementAn input element of the component.
(Inherited from TypedTextComponent)
textComponentTextComponentThe inner text component.
(Inherited from TypedTextComponent)

Methods

MethodReturnsDescription
getValue()File | nullGets the value of the component.
onChange(callback)thisSets the callback function to be called when the component is changed.
(Inherited from TypedTextComponent)
onChanged()voidCalled when the component is changed.
(Inherited from TypedTextComponent)
setDisabled(disabled)thisSets the disabled state of the component.
(Inherited from TypedTextComponent)
setValue(value)thisSets the value of the component.
(Inherited from TypedTextComponent)
valueFromString()File | nullConverts a string to a file.
valueFromString(str)File | nullConverts a string to a value.
(Inherited from TypedTextComponent)
valueToString(value)stringConverts a file to a string.
valueToString(value)stringConverts a value to a string.
(Inherited from TypedTextComponent)

Links to this page: