obsidian-dev-utils
Version:
This is the collection of useful functions that you can use for your Obsidian plugin development
43 lines (42 loc) • 1.21 kB
text/typescript
/**
* @packageDocumentation
*
* This module exports a base class for displaying modals in Obsidian.
*/
import type { App } from 'obsidian';
import { Modal } from 'obsidian';
import type { PromiseResolve } from '../../Async.mjs';
/**
* The base options for a modal.
*/
export interface ModalOptionsBase {
/**
* The application instance.
*/
app: App;
/**
* The CSS class to apply to the modal.
*/
cssClass?: string;
}
/**
* A base class for displaying modals in Obsidian.
*/
export declare abstract class ModalBase<Value, Options extends ModalOptionsBase> extends Modal {
protected resolve: PromiseResolve<Value>;
/**
* Creates a new modal.
*
* @param options - The options.
* @param resolve - The resolve function.
* @param modalCssClass - The modal CSS class.
*/
constructor(options: Options, resolve: PromiseResolve<Value>, modalCssClass: string);
}
/**
* Displays a modal in Obsidian.
*
* @param modalCreator - A function that creates a modal.
* @returns A {@link Promise} that resolves when the modal is closed.
*/
export declare function showModal<T>(modalCreator: (resolve: PromiseResolve<T>) => Modal): Promise<T>;