Skip to content

DialogContext

Opens the library’s dialogs, or lets an instance-scoped DialogDriver answer them.

Create one context per plugin instance, or per test. Never keep a driver in a module global or a class static, because queued answers would leak between tests, vaults and plugins.

Import:

import { DialogContext } from '@mnaoumov/obsidian-lib/modals/dialog-context';

Signature:

export class DialogContext

Constructor

new DialogContext(params: DialogContextConstructorParams)

Creates a dialog context.

Properties

PropertyTypeDescription
appApp | undefinedThe Obsidian app the real modals open in.
driverDialogDriver | undefinedThe driver consulted before each dialog opens.

Methods

MethodReturnsDescription
alert(params)Promise<void>Shows an alert, or lets the driver acknowledge it.
confirm(params)Promise<boolean>Shows a confirm, or lets the driver answer it.
prompt(params)Promise<null | string>Shows a prompt, or lets the driver answer it.

A scripted text must pass the prompt's valueValidator, because the real prompt would not accept it otherwise.
selectItem(params)Promise<null | T>Shows a selectItem, or lets the driver answer it.
selectOption(params)Promise<null | T>Shows a selectOption, or lets the driver answer it.

Links to this page: