UNPKG

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