UNPKG

obsidian-dev-utils

Version:

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

44 lines (43 loc) 1.23 kB
/** * @packageDocumentation * * Utility for displaying a selection modal in Obsidian. * * This module exports a function to display a modal that allows the user to select an item from a list. The modal uses fuzzy search to help the user find the item. */ import type { App } from 'obsidian'; /** * Options for {@link selectItem}. */ export interface SelectItemOptions<T> { /** * An Obsidian app instance. */ app: App; /** * A CSS class to apply to the modal. */ cssClass?: string; /** * A list of items to choose from. */ items: T[]; /** * Get the display text for each item * * @param item - The item to get the display text for. * @returns The display text for the item. */ itemTextFunc(item: T): string; /** * A placeholder text for the input field. */ placeholder?: string; } /** * Displays a selection modal in Obsidian for choosing an item from a list. * * @param options - The options for the selection modal. * @returns A {@link Promise} that resolves with the selected item or null if no item was selected. */ export declare function selectItem<T>(options: SelectItemOptions<T>): Promise<null | T>;