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.26 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'; /** * The parameters for the selection modal. */ export interface SelectItemOptions<T> { /** * The Obsidian app instance. */ app: App; /** * The CSS class to apply to the modal. */ cssClass?: string; /** * The list of items to choose from. */ items: T[]; /** * A function to 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; /** * The 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>;