2020-10-21 01:23:55 +02:00
|
|
|
import Plugin from '../Plugin';
|
2020-11-14 02:02:17 +02:00
|
|
|
import { ButtonSpec, ViewHandle, DialogResult } from './types';
|
2020-10-21 01:23:55 +02:00
|
|
|
/**
|
2020-11-18 12:38:48 +02:00
|
|
|
* Allows creating and managing dialogs. A dialog is modal window that
|
|
|
|
* contains a webview and a row of buttons. You can update the update the
|
|
|
|
* webview using the `setHtml` method. Dialogs are hidden by default and
|
|
|
|
* you need to call `open()` to open them. Once the user clicks on a
|
|
|
|
* button, the `open` call will return an object indicating what button was
|
|
|
|
* clicked on.
|
2020-10-21 01:23:55 +02:00
|
|
|
*
|
2020-11-18 12:38:48 +02:00
|
|
|
* ## Retrieving form values
|
|
|
|
*
|
|
|
|
* If your HTML content included one or more forms, a `formData` object
|
|
|
|
* will also be included with the key/value for each form.
|
|
|
|
*
|
|
|
|
* ## Special button IDs
|
|
|
|
*
|
|
|
|
* The following buttons IDs have a special meaning:
|
|
|
|
*
|
|
|
|
* - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
|
|
|
|
* - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
|
|
|
|
*
|
|
|
|
* This information is used by the application to determine what action
|
|
|
|
* should be done when the user presses "Enter" or "Escape" within the
|
|
|
|
* dialog. If they press "Enter", the first "submit" button will be
|
|
|
|
* automatically clicked. If they press "Escape" the first "dismiss" button
|
|
|
|
* will be automatically clicked.
|
|
|
|
*
|
|
|
|
* [View the demo
|
|
|
|
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
2020-10-21 01:23:55 +02:00
|
|
|
*/
|
|
|
|
export default class JoplinViewsDialogs {
|
|
|
|
private store;
|
|
|
|
private plugin;
|
|
|
|
private implementation_;
|
|
|
|
constructor(implementation: any, plugin: Plugin, store: any);
|
|
|
|
private controller;
|
|
|
|
/**
|
|
|
|
* Creates a new dialog
|
|
|
|
*/
|
2020-11-13 19:09:28 +02:00
|
|
|
create(id: string): Promise<ViewHandle>;
|
2020-10-21 01:23:55 +02:00
|
|
|
/**
|
|
|
|
* Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel"
|
|
|
|
*/
|
|
|
|
showMessageBox(message: string): Promise<number>;
|
|
|
|
/**
|
|
|
|
* Sets the dialog HTML content
|
|
|
|
*/
|
|
|
|
setHtml(handle: ViewHandle, html: string): Promise<string>;
|
2021-01-03 15:21:48 +02:00
|
|
|
/**
|
|
|
|
* Adds and loads a new JS or CSS files into the dialog.
|
|
|
|
*/
|
|
|
|
addScript(handle: ViewHandle, scriptPath: string): Promise<void>;
|
2020-10-21 01:23:55 +02:00
|
|
|
/**
|
|
|
|
* Sets the dialog buttons.
|
|
|
|
*/
|
|
|
|
setButtons(handle: ViewHandle, buttons: ButtonSpec[]): Promise<ButtonSpec[]>;
|
|
|
|
/**
|
|
|
|
* Opens the dialog
|
|
|
|
*/
|
2020-11-14 02:02:17 +02:00
|
|
|
open(handle: ViewHandle): Promise<DialogResult>;
|
2020-10-21 01:23:55 +02:00
|
|
|
}
|