1 | import { IChangedArgs } from '@jupyterlab/coreutils';
|
2 | import { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry';
|
3 | import { Contents, Kernel, ServiceManager } from '@jupyterlab/services';
|
4 | import { Token } from '@lumino/coreutils';
|
5 | import { IDisposable } from '@lumino/disposable';
|
6 | import { ISignal } from '@lumino/signaling';
|
7 | import { Widget } from '@lumino/widgets';
|
8 | /**
|
9 | * The document registry token.
|
10 | */
|
11 | export declare const IDocumentManager: Token<IDocumentManager>;
|
12 | /**
|
13 | * The document widget opener token.
|
14 | */
|
15 | export declare const IDocumentWidgetOpener: Token<IDocumentWidgetOpener>;
|
16 | /**
|
17 | * The interface for a document manager.
|
18 | */
|
19 | export interface IDocumentManager extends IDisposable {
|
20 | /**
|
21 | * The registry used by the manager.
|
22 | */
|
23 | readonly registry: DocumentRegistry;
|
24 | /**
|
25 | * The service manager used by the manager.
|
26 | */
|
27 | readonly services: ServiceManager.IManager;
|
28 | /**
|
29 | * A signal emitted when one of the documents is activated.
|
30 | */
|
31 | readonly activateRequested: ISignal<this, string>;
|
32 | /**
|
33 | * Whether to autosave documents.
|
34 | */
|
35 | autosave: boolean;
|
36 | /**
|
37 | * Whether to ask confirmation to close a tab or not.
|
38 | */
|
39 | confirmClosingDocument: boolean;
|
40 | /**
|
41 | * Determines the time interval for autosave in seconds.
|
42 | */
|
43 | autosaveInterval: number;
|
44 | /**
|
45 | * Defines max acceptable difference, in milliseconds, between last modified timestamps on disk and client.
|
46 | */
|
47 | lastModifiedCheckMargin: number;
|
48 | /**
|
49 | * Whether to ask the user to rename untitled file on first manual save.
|
50 | */
|
51 | renameUntitledFileOnSave: boolean;
|
52 | /**
|
53 | * Signal triggered when an attribute changes.
|
54 | */
|
55 | readonly stateChanged: ISignal<IDocumentManager, IChangedArgs<any>>;
|
56 | /**
|
57 | * Clone a widget.
|
58 | *
|
59 | * @param widget - The source widget.
|
60 | *
|
61 | * @returns A new widget or `undefined`.
|
62 | *
|
63 | * #### Notes
|
64 | * Uses the same widget factory and context as the source, or returns
|
65 | * `undefined` if the source widget is not managed by this manager.
|
66 | */
|
67 | cloneWidget(widget: Widget): IDocumentWidget | undefined;
|
68 | /**
|
69 | * Close all of the open documents.
|
70 | *
|
71 | * @returns A promise resolving when the widgets are closed.
|
72 | */
|
73 | closeAll(): Promise<void>;
|
74 | /**
|
75 | * Close the widgets associated with a given path.
|
76 | *
|
77 | * @param path - The target path.
|
78 | *
|
79 | * @returns A promise resolving when the widgets are closed.
|
80 | */
|
81 | closeFile(path: string): Promise<void>;
|
82 | /**
|
83 | * Get the document context for a widget.
|
84 | *
|
85 | * @param widget - The widget of interest.
|
86 | *
|
87 | * @returns The context associated with the widget, or `undefined` if no such
|
88 | * context exists.
|
89 | */
|
90 | contextForWidget(widget: Widget): DocumentRegistry.Context | undefined;
|
91 | /**
|
92 | * Copy a file.
|
93 | *
|
94 | * @param fromFile - The full path of the original file.
|
95 | *
|
96 | * @param toDir - The full path to the target directory.
|
97 | *
|
98 | * @returns A promise which resolves to the contents of the file.
|
99 | */
|
100 | copy(fromFile: string, toDir: string): Promise<Contents.IModel>;
|
101 | /**
|
102 | * Create a new file and return the widget used to view it.
|
103 | *
|
104 | * @param path - The file path to create.
|
105 | *
|
106 | * @param widgetName - The name of the widget factory to use. 'default' will use the default widget.
|
107 | *
|
108 | * @param kernel - An optional kernel name/id to override the default.
|
109 | *
|
110 | * @returns The created widget, or `undefined`.
|
111 | *
|
112 | * #### Notes
|
113 | * This function will return `undefined` if a valid widget factory
|
114 | * cannot be found.
|
115 | */
|
116 | createNew(path: string, widgetName?: string, kernel?: Partial<Kernel.IModel>): Widget | undefined;
|
117 | /**
|
118 | * Delete a file.
|
119 | *
|
120 | * @param path - The full path to the file to be deleted.
|
121 | *
|
122 | * @returns A promise which resolves when the file is deleted.
|
123 | *
|
124 | * #### Notes
|
125 | * If there is a running session associated with the file and no other
|
126 | * sessions are using the kernel, the session will be shut down.
|
127 | */
|
128 | deleteFile(path: string): Promise<void>;
|
129 | /**
|
130 | * Duplicate a file.
|
131 | *
|
132 | * @param path - The full path to the file to be duplicated.
|
133 | *
|
134 | * @returns A promise which resolves when the file is duplicated.
|
135 | *
|
136 | */
|
137 | duplicate(path: string): Promise<Contents.IModel>;
|
138 | /**
|
139 | * See if a widget already exists for the given path and widget name.
|
140 | *
|
141 | * @param path - The file path to use.
|
142 | *
|
143 | * @param widgetName - The name of the widget factory to use. 'default' will use the default widget.
|
144 | *
|
145 | * @returns The found widget, or `undefined`.
|
146 | *
|
147 | * #### Notes
|
148 | * This can be used to find an existing widget instead of opening
|
149 | * a new widget.
|
150 | */
|
151 | findWidget(path: string, widgetName?: string | null): IDocumentWidget | undefined;
|
152 | /**
|
153 | * Create a new untitled file.
|
154 | *
|
155 | * @param options - The file content creation options.
|
156 | */
|
157 | newUntitled(options: Contents.ICreateOptions): Promise<Contents.IModel>;
|
158 | /**
|
159 | * Open a file and return the widget used to view it.
|
160 | *
|
161 | * @param path - The file path to open.
|
162 | *
|
163 | * @param widgetName - The name of the widget factory to use. 'default' will use the default widget.
|
164 | *
|
165 | * @param kernel - An optional kernel name/id to override the default.
|
166 | *
|
167 | * @returns The created widget, or `undefined`.
|
168 | *
|
169 | * #### Notes
|
170 | * This function will return `undefined` if a valid widget factory
|
171 | * cannot be found.
|
172 | */
|
173 | open(path: string, widgetName?: string, kernel?: Partial<Kernel.IModel>, options?: DocumentRegistry.IOpenOptions): IDocumentWidget | undefined;
|
174 | /**
|
175 | * Open a file and return the widget used to view it.
|
176 | * Reveals an already existing editor.
|
177 | *
|
178 | * @param path - The file path to open.
|
179 | *
|
180 | * @param widgetName - The name of the widget factory to use. 'default' will use the default widget.
|
181 | *
|
182 | * @param kernel - An optional kernel name/id to override the default.
|
183 | *
|
184 | * @returns The created widget, or `undefined`.
|
185 | *
|
186 | * #### Notes
|
187 | * This function will return `undefined` if a valid widget factory
|
188 | * cannot be found.
|
189 | */
|
190 | openOrReveal(path: string, widgetName?: string, kernel?: Partial<Kernel.IModel>, options?: DocumentRegistry.IOpenOptions): IDocumentWidget | undefined;
|
191 | /**
|
192 | * Overwrite a file.
|
193 | *
|
194 | * @param oldPath - The full path to the original file.
|
195 | *
|
196 | * @param newPath - The full path to the new file.
|
197 | *
|
198 | * @returns A promise containing the new file contents model.
|
199 | */
|
200 | overwrite(oldPath: string, newPath: string): Promise<Contents.IModel>;
|
201 | /**
|
202 | * Rename a file or directory.
|
203 | *
|
204 | * @param oldPath - The full path to the original file.
|
205 | *
|
206 | * @param newPath - The full path to the new file.
|
207 | *
|
208 | * @returns A promise containing the new file contents model. The promise
|
209 | * will reject if the newPath already exists. Use [[overwrite]] to overwrite
|
210 | * a file.
|
211 | */
|
212 | rename(oldPath: string, newPath: string): Promise<Contents.IModel>;
|
213 | }
|
214 | /**
|
215 | * The interface for a widget opener.
|
216 | */
|
217 | export interface IDocumentWidgetOpener {
|
218 | /**
|
219 | * Open the given widget.
|
220 | */
|
221 | open(widget: IDocumentWidget, options?: DocumentRegistry.IOpenOptions): void;
|
222 | /**
|
223 | * A signal emitted when a widget is opened
|
224 | */
|
225 | readonly opened: ISignal<IDocumentWidgetOpener, IDocumentWidget>;
|
226 | }
|