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