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