1 | import { MainAreaWidget } from '@jupyterlab/apputils';
|
2 | import { CodeEditor } from '@jupyterlab/codeeditor';
|
3 | import { IChangedArgs } from '@jupyterlab/coreutils';
|
4 | import { Contents } from '@jupyterlab/services';
|
5 | import { ISharedFile } from '@jupyter/ydoc';
|
6 | import { ITranslator } from '@jupyterlab/translation';
|
7 | import { PartialJSONValue } from '@lumino/coreutils';
|
8 | import { ISignal } from '@lumino/signaling';
|
9 | import { Widget } from '@lumino/widgets';
|
10 | import { DocumentRegistry, IDocumentWidget } from './index';
|
11 |
|
12 |
|
13 |
|
14 | export declare class DocumentModel extends CodeEditor.Model implements DocumentRegistry.ICodeModel {
|
15 | |
16 |
|
17 |
|
18 | constructor(options?: DocumentRegistry.IModelOptions<ISharedFile>);
|
19 | /**
|
20 | * A signal emitted when the document content changes.
|
21 | */
|
22 | get contentChanged(): ISignal<this, void>;
|
23 | /**
|
24 | * A signal emitted when the document state changes.
|
25 | */
|
26 | get stateChanged(): ISignal<this, IChangedArgs<any>>;
|
27 | /**
|
28 | * The dirty state of the document.
|
29 | */
|
30 | get dirty(): boolean;
|
31 | set dirty(newValue: boolean);
|
32 | /**
|
33 | * The read only state of the document.
|
34 | */
|
35 | get readOnly(): boolean;
|
36 | set readOnly(newValue: boolean);
|
37 | /**
|
38 | * The default kernel name of the document.
|
39 | *
|
40 | * #### Notes
|
41 | * This is a read-only property.
|
42 | */
|
43 | get defaultKernelName(): string;
|
44 | /**
|
45 | * The default kernel language of the document.
|
46 | *
|
47 | * #### Notes
|
48 | * This is a read-only property.
|
49 | */
|
50 | get defaultKernelLanguage(): string;
|
51 | /**
|
52 | * Whether the model is collaborative or not.
|
53 | */
|
54 | get collaborative(): boolean;
|
55 | /**
|
56 | * Serialize the model to a string.
|
57 | */
|
58 | toString(): string;
|
59 | /**
|
60 | * Deserialize the model from a string.
|
61 | *
|
62 | * #### Notes
|
63 | * Should emit a [contentChanged] signal.
|
64 | */
|
65 | fromString(value: string): void;
|
66 | /**
|
67 | * Serialize the model to JSON.
|
68 | */
|
69 | toJSON(): PartialJSONValue;
|
70 | /**
|
71 | * Deserialize the model from JSON.
|
72 | *
|
73 | * #### Notes
|
74 | * Should emit a [contentChanged] signal.
|
75 | */
|
76 | fromJSON(value: PartialJSONValue): void;
|
77 | /**
|
78 | * Initialize the model with its current state.
|
79 | */
|
80 | initialize(): void;
|
81 | /**
|
82 | * Trigger a state change signal.
|
83 | */
|
84 | protected triggerStateChange(args: IChangedArgs<any>): void;
|
85 | /**
|
86 | * Trigger a content changed signal.
|
87 | */
|
88 | protected triggerContentChange(): void;
|
89 | private _onStateChanged;
|
90 | /**
|
91 | * The shared notebook model.
|
92 | */
|
93 | readonly sharedModel: ISharedFile;
|
94 | private _defaultLang;
|
95 | private _dirty;
|
96 | private _readOnly;
|
97 | private _contentChanged;
|
98 | private _stateChanged;
|
99 | private _collaborationEnabled;
|
100 | }
|
101 | /**
|
102 | * An implementation of a model factory for text files.
|
103 | */
|
104 | export declare class TextModelFactory implements DocumentRegistry.CodeModelFactory {
|
105 | |
106 |
|
107 |
|
108 | constructor(collaborative?: boolean);
|
109 | /**
|
110 | * The name of the model type.
|
111 | *
|
112 | * #### Notes
|
113 | * This is a read-only property.
|
114 | */
|
115 | get name(): string;
|
116 | /**
|
117 | * The type of the file.
|
118 | *
|
119 | * #### Notes
|
120 | * This is a read-only property.
|
121 | */
|
122 | get contentType(): Contents.ContentType;
|
123 | /**
|
124 | * The format of the file.
|
125 | *
|
126 | * This is a read-only property.
|
127 | */
|
128 | get fileFormat(): Contents.FileFormat;
|
129 | /**
|
130 | * Whether the model is collaborative or not.
|
131 | */
|
132 | get collaborative(): boolean;
|
133 | /**
|
134 | * Get whether the model factory has been disposed.
|
135 | */
|
136 | get isDisposed(): boolean;
|
137 | /**
|
138 | * Dispose of the resources held by the model factory.
|
139 | */
|
140 | dispose(): void;
|
141 | /**
|
142 | * Create a new model.
|
143 | *
|
144 | * @param options - Model options.
|
145 | *
|
146 | * @returns A new document model.
|
147 | */
|
148 | createNew(options?: DocumentRegistry.IModelOptions<ISharedFile>): DocumentRegistry.ICodeModel;
|
149 | /**
|
150 | * Get the preferred kernel language given a file path.
|
151 | */
|
152 | preferredLanguage(path: string): string;
|
153 | private _isDisposed;
|
154 | private _collaborative;
|
155 | }
|
156 | /**
|
157 | * An implementation of a model factory for base64 files.
|
158 | */
|
159 | export declare class Base64ModelFactory extends TextModelFactory {
|
160 | |
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 | get name(): string;
|
167 | |
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 | get contentType(): Contents.ContentType;
|
174 | |
175 |
|
176 |
|
177 |
|
178 |
|
179 | get fileFormat(): Contents.FileFormat;
|
180 | }
|
181 |
|
182 |
|
183 |
|
184 | export declare abstract class ABCWidgetFactory<T extends IDocumentWidget, U extends DocumentRegistry.IModel = DocumentRegistry.IModel> implements DocumentRegistry.IWidgetFactory<T, U> {
|
185 | |
186 |
|
187 |
|
188 | constructor(options: DocumentRegistry.IWidgetFactoryOptions<T>);
|
189 | /**
|
190 | * A signal emitted when a widget is created.
|
191 | */
|
192 | get widgetCreated(): ISignal<DocumentRegistry.IWidgetFactory<T, U>, T>;
|
193 | /**
|
194 | * Get whether the model factory has been disposed.
|
195 | */
|
196 | get isDisposed(): boolean;
|
197 | /**
|
198 | * Dispose of the resources used by the document manager.
|
199 | */
|
200 | dispose(): void;
|
201 | /**
|
202 | * Whether the widget factory is read only.
|
203 | */
|
204 | get readOnly(): boolean;
|
205 | /**
|
206 | * A unique name identifying of the widget.
|
207 | */
|
208 | get name(): string;
|
209 | /**
|
210 | * The label of the widget to display in dialogs.
|
211 | * If not given, name is used instead.
|
212 | */
|
213 | get label(): string;
|
214 | /**
|
215 | * The file types the widget can view.
|
216 | */
|
217 | get fileTypes(): string[];
|
218 | /**
|
219 | * The registered name of the model type used to create the widgets.
|
220 | */
|
221 | get modelName(): string;
|
222 | /**
|
223 | * The file types for which the factory should be the default.
|
224 | */
|
225 | get defaultFor(): string[];
|
226 | /**
|
227 | * The file types for which the factory should be the default for
|
228 | * rendering a document model, if different from editing.
|
229 | */
|
230 | get defaultRendered(): string[];
|
231 | /**
|
232 | * Whether the widgets prefer having a kernel started.
|
233 | */
|
234 | get preferKernel(): boolean;
|
235 | /**
|
236 | * Whether the widgets can start a kernel when opened.
|
237 | */
|
238 | get canStartKernel(): boolean;
|
239 | /**
|
240 | * The application language translator.
|
241 | */
|
242 | get translator(): ITranslator;
|
243 | /**
|
244 | * Whether the kernel should be shutdown when the widget is closed.
|
245 | */
|
246 | get shutdownOnClose(): boolean;
|
247 | set shutdownOnClose(value: boolean);
|
248 | /**
|
249 | * Whether to automatically select the preferred kernel during a kernel start
|
250 | */
|
251 | get autoStartDefault(): boolean;
|
252 | set autoStartDefault(value: boolean);
|
253 | /**
|
254 | * Create a new widget given a document model and a context.
|
255 | *
|
256 | * #### Notes
|
257 | * It should emit the [widgetCreated] signal with the new widget.
|
258 | */
|
259 | createNew(context: DocumentRegistry.IContext<U>, source?: T): T;
|
260 | /**
|
261 | * Create a widget for a context.
|
262 | */
|
263 | protected abstract createNewWidget(context: DocumentRegistry.IContext<U>, source?: T): T;
|
264 | /**
|
265 | * Default factory for toolbar items to be added after the widget is created.
|
266 | */
|
267 | protected defaultToolbarFactory(widget: T): DocumentRegistry.IToolbarItem[];
|
268 | private _toolbarFactory;
|
269 | private _isDisposed;
|
270 | private _translator;
|
271 | private _name;
|
272 | private _label;
|
273 | private _autoStartDefault;
|
274 | private _readOnly;
|
275 | private _canStartKernel;
|
276 | private _shutdownOnClose;
|
277 | private _preferKernel;
|
278 | private _modelName;
|
279 | private _fileTypes;
|
280 | private _defaultFor;
|
281 | private _defaultRendered;
|
282 | private _widgetCreated;
|
283 | }
|
284 | /**
|
285 | * A document widget implementation.
|
286 | */
|
287 | export declare class DocumentWidget<T extends Widget = Widget, U extends DocumentRegistry.IModel = DocumentRegistry.IModel> extends MainAreaWidget<T> implements IDocumentWidget<T, U> {
|
288 | constructor(options: DocumentWidget.IOptions<T, U>);
|
289 | /**
|
290 | * Set URI fragment identifier.
|
291 | */
|
292 | setFragment(fragment: string): void;
|
293 | /**
|
294 | * Handle a title change.
|
295 | */
|
296 | private _onTitleChanged;
|
297 | /**
|
298 | * Handle a path change.
|
299 | */
|
300 | private _onPathChanged;
|
301 | /**
|
302 | * Handle a change to the context model state.
|
303 | */
|
304 | private _onModelStateChanged;
|
305 | /**
|
306 | * Handle the dirty state of the context model.
|
307 | */
|
308 | private _handleDirtyState;
|
309 | readonly context: DocumentRegistry.IContext<U>;
|
310 | protected readonly _trans: import("@jupyterlab/rendermime-interfaces").IRenderMime.TranslationBundle;
|
311 | /**
|
312 | * Whether the document has an auto-generated name or not.
|
313 | *
|
314 | * #### Notes
|
315 | * A document has auto-generated name if its name is untitled and up
|
316 | * to the instant the user saves it manually for the first time.
|
317 | */
|
318 | isUntitled?: boolean;
|
319 | }
|
320 | export declare namespace DocumentWidget {
|
321 | interface IOptions<T extends Widget = Widget, U extends DocumentRegistry.IModel = DocumentRegistry.IModel> extends MainAreaWidget.IOptions<T> {
|
322 | context: DocumentRegistry.IContext<U>;
|
323 | }
|
324 | interface IOptionsOptionalContent<T extends Widget = Widget, U extends DocumentRegistry.IModel = DocumentRegistry.IModel> extends MainAreaWidget.IOptionsOptionalContent<T> {
|
325 | context: DocumentRegistry.IContext<U>;
|
326 | |
327 |
|
328 |
|
329 | translator?: ITranslator;
|
330 | }
|
331 | }
|