UNPKG

2.18 kBTypeScriptView Raw
1import "../../";
2
3export type DialogCloseFunction = () => void;
4
5export interface DialogOptions {
6 bottom?: boolean | undefined;
7}
8
9export interface OpenDialogOptions extends DialogOptions {
10 /** If true, the dialog will be closed when the user presses enter in the input. Defaults to true. */
11 closeOnEnter?: boolean | undefined;
12 /** Determines whether the dialog is closed when it loses focus. Defaults to true. */
13 closeOnBlur?: boolean | undefined;
14 /** An event handler that will be called whenever keydown fires in the dialog's input. If the callback returns true, the dialog will not do any further processing of the event. */
15 onKeyDown?(event: KeyboardEvent, value: string, close: DialogCloseFunction): boolean | undefined;
16 /** An event handler that will be called whenever keyup fires in the dialog's input. If the callback returns true, the dialog will not do any further processing of the event. */
17 onKeyUp?(event: KeyboardEvent, value: string, close: DialogCloseFunction): boolean | undefined;
18 /** An event handler that will be called whenever input fires in the dialog's input. If the callback returns true, the dialog will not do any further processing of the event. */
19 onInput?(event: KeyboardEvent, value: string, close: DialogCloseFunction): boolean | undefined;
20 /** A callback that will be called after the dialog has been closed and removed from the DOM. */
21 onClose?(instance: HTMLElement): void;
22}
23
24export interface OpenNotificationOptions extends DialogOptions {
25 duration?: number | undefined;
26}
27
28declare module "../../" {
29 interface Editor {
30 /** Provides a very simple way to query users for text input. */
31 openDialog(
32 template: string | Node,
33 callback: (value: string, e: Event) => void,
34 options?: OpenDialogOptions,
35 ): DialogCloseFunction;
36 openNotification(template: string | Node, options?: OpenNotificationOptions): DialogCloseFunction;
37 openConfirm(
38 template: string | Node,
39 callbacks: ReadonlyArray<(editor: Editor) => void>,
40 options?: DialogOptions,
41 ): DialogCloseFunction;
42 }
43}