Skip to content

PromptAPI

Constructors

new PromptAPI()

new PromptAPI(apiInstance): PromptAPI

Parameters

Parameter Type

apiInstance

API

Returns

PromptAPI

Defined in

jsEngine/api/PromptAPI.ts:101

Properties

apiInstance

readonly apiInstance: API

Defined in

jsEngine/api/PromptAPI.ts:99

Methods

button()

button<T>(options): Promise<undefined | T>

Prompts the user with a modal containing a list of buttons. Returns the value of the button that was clicked, or undefined if the modal was closed.

Type Parameters

Type Parameter

T

Parameters

Parameter Type

options

ButtonPromptOptions<T>

Returns

Promise<undefined | T>

Example

// Prompt the user with a true/false question.
const ret = await engine.prompt.button({
title: 'The set of natural numbers with zero and the addition operation is a monoid.',
buttons: [
{
label: 'True',
value: true,
},
{
label: 'False',
value: false,
},
{
label: 'Cancel',
value: undefined,
}
]
});

Defined in

jsEngine/api/PromptAPI.ts:132


confirm()

confirm(options): Promise<boolean>

Prompts the user with a confirm/cancel dialog. Returns true if the user confirms, false if the user cancels or otherwise closes the modal.

Parameters

Parameter Type

options

ConfirmPromptOptions

Returns

Promise<boolean>

Example

// Ask the user if they want to confirm an action.
const ret = await engine.prompt.confirm({
title: 'Confirm File Deletion',
content: 'Are you sure you want to delete this file? This action cannot be undone.',
});

Defined in

jsEngine/api/PromptAPI.ts:171


number()

number(options): Promise<undefined | number>

Prompts the user with a number input dialog. Returns the value of the input field, or undefined if the user closes the modal. While the input field is focused, the user can use enter to submit the value and esc to cancel and close the modal.

Parameters

Parameter Type

options

NumberInputPromptOptions

Returns

Promise<undefined | number>

Example

// Prompt the user to input their age.
const ret = await engine.prompt.text({
title: 'Please enter your age',
content: 'Please enter your age in years in the field below.',
});

Defined in

jsEngine/api/PromptAPI.ts:362


suggester()

suggester<T>(options): Promise<undefined | T>

Prompts the user with a fuzzy finder suggester dialog. Returns the value of the selected option, or undefined if the user closes the modal.

Type Parameters

Type Parameter

T

Parameters

Parameter Type

options

SuggesterPromptOptions<T>

Returns

Promise<undefined | T>

Example

// Query a list of files and prompt the user to select one.
const files = engine.query.files((file) => {
return {
label: file.name,
value: file.pat,
};
});
const ret = await engine.prompt.suggester({
placeholder: 'Select a file',
options: files,
});

Defined in

jsEngine/api/PromptAPI.ts:248


text()

text(options): Promise<undefined | string>

Prompts the user with a text input dialog. Returns the value of the input field, or undefined if the user closes the modal. While the input field is focused, the user can use enter to submit the value and esc to cancel and close the modal.

Parameters

Parameter Type

options

InputPromptOptions

Returns

Promise<undefined | string>

Example

// Prompt the user to input their name.
const ret = await engine.prompt.text({
title: 'Please enter your name',
content: 'Please enter your name in the field below.',
});

Defined in

jsEngine/api/PromptAPI.ts:275


textarea()

textarea(options): Promise<undefined | string>

Prompts the user with a textarea input dialog. Returns the value of the input field, or undefined if the user closes the modal. While the input field is focused, the user can use esc to cancel and close the modal.

Parameters

Parameter Type

options

InputPromptOptions

Returns

Promise<undefined | string>

Example

// Prompt the user to input a multi-line message.
const ret = await engine.prompt.textarea({
title: 'Please enter your message',
content: 'Please enter your message in the field below.',
placeholder: 'Your message here...',
});

Defined in

jsEngine/api/PromptAPI.ts:319


yesNo()

yesNo(options): Promise<undefined | boolean>

Prompts the user with a yes/no dialog. Returns true if the user selects yes, false if the user selects no, and undefined if the user otherwise closes the modal.

Parameters

Parameter Type

options

YesNoPromptOptions

Returns

Promise<undefined | boolean>

Example

// Ask the user if they like Obsidian.
const ret = await engine.prompt.yesNo({
title: 'Is this a test?',
content: 'Are you sure this is a test? Are you sure that your choice is really meaningless?',
});

Defined in

jsEngine/api/PromptAPI.ts:207