1 | import { Widget } from '@phosphor/widgets';
|
2 | import { Message } from '@phosphor/messaging';
|
3 | import { Event } from '../common/event';
|
4 | import { MaybePromise } from '../common/types';
|
5 | import { AbstractDialog } from './dialogs';
|
6 | export interface Saveable {
|
7 | readonly dirty: boolean;
|
8 | readonly onDirtyChanged: Event<void>;
|
9 | readonly autoSave: 'off' | 'afterDelay' | 'onFocusChange' | 'onWindowChange';
|
10 | |
11 |
|
12 |
|
13 | save(options?: SaveOptions): MaybePromise<void>;
|
14 | |
15 |
|
16 |
|
17 | revert?(options?: Saveable.RevertOptions): Promise<void>;
|
18 | |
19 |
|
20 |
|
21 | createSnapshot?(): Saveable.Snapshot;
|
22 | |
23 |
|
24 |
|
25 | applySnapshot?(snapshot: object): void;
|
26 | }
|
27 | export interface SaveableSource {
|
28 | readonly saveable: Saveable;
|
29 | }
|
30 | export declare namespace Saveable {
|
31 | interface RevertOptions {
|
32 | |
33 |
|
34 |
|
35 |
|
36 | soft?: boolean;
|
37 | }
|
38 | type Snapshot = {
|
39 | value: string;
|
40 | } | {
|
41 | read(): string | null;
|
42 | };
|
43 | function isSource(arg: unknown): arg is SaveableSource;
|
44 | function is(arg: unknown): arg is Saveable;
|
45 | function get(arg: unknown): Saveable | undefined;
|
46 | function getDirty(arg: unknown): Saveable | undefined;
|
47 | function isDirty(arg: unknown): boolean;
|
48 | function save(arg: unknown, options?: SaveOptions): Promise<void>;
|
49 | function confirmSaveBeforeClose(toClose: Iterable<Widget>, others: Widget[]): Promise<boolean | undefined>;
|
50 | function apply(widget: Widget, getOtherSaveables?: () => Array<Widget | SaveableWidget>, doSave?: (widget: Widget, options?: SaveOptions) => Promise<void>): SaveableWidget | undefined;
|
51 | function shouldSave(saveable: Saveable, cb: () => MaybePromise<boolean | undefined>): Promise<boolean | undefined>;
|
52 | }
|
53 | export interface SaveableWidget extends Widget {
|
54 | |
55 |
|
56 |
|
57 | closeWithoutSaving(doRevert?: boolean): Promise<void>;
|
58 | closeWithSaving(options?: SaveableWidget.CloseOptions): Promise<void>;
|
59 | }
|
60 | export declare const close: unique symbol;
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | export interface PostCreationSaveableWidget extends SaveableWidget {
|
66 | |
67 |
|
68 |
|
69 | [close](): void;
|
70 | }
|
71 | export declare namespace SaveableWidget {
|
72 | function is(widget: Widget | undefined): widget is SaveableWidget;
|
73 | function getDirty<T extends Widget>(widgets: Iterable<T>): IterableIterator<SaveableWidget & T>;
|
74 | function get<T extends Widget>(widgets: Iterable<T>, filter?: (widget: T) => boolean): IterableIterator<SaveableWidget & T>;
|
75 | interface CloseOptions {
|
76 | shouldSave?(): MaybePromise<boolean | undefined>;
|
77 | }
|
78 | }
|
79 |
|
80 |
|
81 |
|
82 | export declare const enum FormatType {
|
83 | |
84 |
|
85 |
|
86 | ON = 1,
|
87 | |
88 |
|
89 |
|
90 | OFF = 2,
|
91 | |
92 |
|
93 |
|
94 | DIRTY = 3
|
95 | }
|
96 | export interface SaveOptions {
|
97 | |
98 |
|
99 |
|
100 | readonly formatType?: FormatType;
|
101 | }
|
102 | export declare function setDirty(widget: Widget, dirty: boolean): void;
|
103 | export declare class ShouldSaveDialog extends AbstractDialog<boolean> {
|
104 | protected shouldSave: boolean;
|
105 | protected readonly dontSaveButton: HTMLButtonElement;
|
106 | constructor(widget: Widget);
|
107 | protected appendDontSaveButton(): HTMLButtonElement;
|
108 | protected onAfterAttach(msg: Message): void;
|
109 | get value(): boolean;
|
110 | }
|
111 | //# sourceMappingURL=saveable.d.ts.map |
\ | No newline at end of file |