PromptAPI
Defined in: jsEngine/api/PromptAPI.ts:98
Constructors
new PromptAPI()
new PromptAPI(
apiInstance
):PromptAPI
Defined in: jsEngine/api/PromptAPI.ts:101
Parameters
Parameter | Type |
---|---|
|
Returns
Properties
apiInstance
readonly
apiInstance:API
Defined in: jsEngine/api/PromptAPI.ts:99
Methods
button()
button<
T
>(options
):Promise
<undefined
|T
>
Defined in: jsEngine/api/PromptAPI.ts:132
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 |
---|
|
Parameters
Parameter | Type |
---|---|
|
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, } ]});
confirm()
confirm(
options
):Promise
<boolean
>
Defined in: jsEngine/api/PromptAPI.ts:171
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 |
---|---|
|
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.',});
number()
number(
options
):Promise
<undefined
|number
>
Defined in: jsEngine/api/PromptAPI.ts:362
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 |
---|---|
|
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.',});
suggester()
suggester<
T
>(options
):Promise
<undefined
|T
>
Defined in: jsEngine/api/PromptAPI.ts:248
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 |
---|
|
Parameters
Parameter | Type |
---|---|
|
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,});
text()
text(
options
):Promise
<undefined
|string
>
Defined in: jsEngine/api/PromptAPI.ts:275
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 |
---|---|
|
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.',});
textarea()
textarea(
options
):Promise
<undefined
|string
>
Defined in: jsEngine/api/PromptAPI.ts:319
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 |
---|---|
|
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...',});
yesNo()
yesNo(
options
):Promise
<undefined
|boolean
>
Defined in: jsEngine/api/PromptAPI.ts:207
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 |
---|---|
|
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?',});