TagListComponent
A ListComponent of tags, stored without the # and shown with it. The add row suggests the vault’s tags, and a typed tag is refused unless it is a valid Obsidian tag: letters, digits, _, - and /, not digits only.
You can add this component using SettingEx.addTagList.
Import:
import { TagListComponent } from '@mnaoumov/obsidian-lib/setting-components/tag-list-component';Signature:
export class TagListComponent extends ListComponentExtends: ListComponent
Constructor
new TagListComponent(containerEl: HTMLElement, app: App)Creates a new tag list component.
Properties
| Property | Type | Description |
|---|---|---|
| listEl | HTMLElement | The element holding one row per item. (Inherited from ListComponent) |
| newItemButton | ExtraButtonComponent | The button that adds the typed item. (Inherited from ListComponent) |
| newItemInputEl | HTMLInputElement | The input the next item is typed into. (Inherited from ListComponent) |
| onChange | (callback: (newValue: readonly string[]) => void) => this | Sets a callback function to be called when the value of the component changes. (Inherited from ListComponent) |
| suggest | TagInputSuggest | The tag suggest attached to ListComponent.newItemInputEl. |
Methods
| Method | Returns | Description |
|---|---|---|
| addTypedItem() | boolean | Adds the text typed into ListComponent.newItemInputEl, when it normalizes to an item not yet in the list, and clears the input. (Inherited from ListComponent) |
| formatItem(item) | string | Shows a tag with its #. |
| getValue() | readonly string[] | Gets the items. (Inherited from ListComponent) |
| normalizeItem(text) | null | string | Strips the # from a typed tag and validates it. |
| onChange(callback) | this | Sets the callback to be called when the user adds, moves or removes an item. (Inherited from ListComponent) |
| setDisabled(isDisabled) | this | Sets the disabled state of the component. (Inherited from ListComponent) |
| setPlaceholder(placeholder) | this | Sets the placeholder of ListComponent.newItemInputEl. (Inherited from ListComponent) |
| setValue(value) | this | Sets the items. (Inherited from ListComponent) |
Links to this page: