1 | import { Cell } from '@jupyterlab/cells';
|
2 | import { CodeEditor, JSONEditor } from '@jupyterlab/codeeditor';
|
3 | import * as nbformat from '@jupyterlab/nbformat';
|
4 | import { ObservableJSON } from '@jupyterlab/observables';
|
5 | import { ITranslator } from '@jupyterlab/translation';
|
6 | import { ReadonlyPartialJSONValue } from '@lumino/coreutils';
|
7 | import { ConflatableMessage, Message } from '@lumino/messaging';
|
8 | import { Widget } from '@lumino/widgets';
|
9 | import { NotebookPanel } from './panel';
|
10 | import { INotebookTools, INotebookTracker } from './tokens';
|
11 |
|
12 |
|
13 |
|
14 | export declare class NotebookTools extends Widget implements INotebookTools {
|
15 | |
16 |
|
17 |
|
18 | constructor(options: NotebookTools.IOptions);
|
19 | /**
|
20 | * The active cell widget.
|
21 | */
|
22 | get activeCell(): Cell | null;
|
23 | /**
|
24 | * The currently selected cells.
|
25 | */
|
26 | get selectedCells(): Cell[];
|
27 | /**
|
28 | * The current notebook.
|
29 | */
|
30 | get activeNotebookPanel(): NotebookPanel | null;
|
31 | /**
|
32 | * Add a cell tool item.
|
33 | */
|
34 | addItem(options: NotebookTools.IAddOptions): void;
|
35 | /**
|
36 | * Handle a change to the notebook panel.
|
37 | */
|
38 | private _onActiveNotebookPanelChanged;
|
39 | /**
|
40 | * Handle a change to the active cell.
|
41 | */
|
42 | private _onActiveCellChanged;
|
43 | /**
|
44 | * Handle a change in the selection.
|
45 | */
|
46 | private _onSelectionChanged;
|
47 | /**
|
48 | * Handle a change in the active cell metadata.
|
49 | */
|
50 | private _onActiveNotebookPanelMetadataChanged;
|
51 | /**
|
52 | * Handle a change in the notebook model metadata.
|
53 | */
|
54 | private _onActiveCellMetadataChanged;
|
55 | private _toolChildren;
|
56 | translator: ITranslator;
|
57 | private _trans;
|
58 | private _commonTools;
|
59 | private _advancedTools;
|
60 | private _tracker;
|
61 | private _prevActiveCell;
|
62 | private _prevActiveNotebookModel;
|
63 | }
|
64 | /**
|
65 | * The namespace for NotebookTools class statics.
|
66 | */
|
67 | export declare namespace NotebookTools {
|
68 | |
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | type ReadonlyPartialJSONOptionValueArray = [
|
75 | ReadonlyPartialJSONValue | undefined,
|
76 | ReadonlyPartialJSONValue
|
77 | ][];
|
78 | |
79 |
|
80 |
|
81 | interface IOptions {
|
82 | |
83 |
|
84 |
|
85 | tracker: INotebookTracker;
|
86 | |
87 |
|
88 |
|
89 | translator?: ITranslator;
|
90 | }
|
91 | |
92 |
|
93 |
|
94 | interface IAddOptions {
|
95 | |
96 |
|
97 |
|
98 | tool: Tool;
|
99 | |
100 |
|
101 |
|
102 | section?: 'common' | 'advanced';
|
103 | |
104 |
|
105 |
|
106 | rank?: number;
|
107 | }
|
108 | |
109 |
|
110 |
|
111 | const ActiveNotebookPanelMessage: ConflatableMessage;
|
112 | |
113 |
|
114 |
|
115 | const ActiveCellMessage: ConflatableMessage;
|
116 | |
117 |
|
118 |
|
119 | const SelectionMessage: ConflatableMessage;
|
120 | |
121 |
|
122 |
|
123 | class Tool extends Widget implements INotebookTools.ITool {
|
124 | |
125 |
|
126 |
|
127 | notebookTools: INotebookTools;
|
128 | dispose(): void;
|
129 | |
130 |
|
131 |
|
132 |
|
133 |
|
134 | processMessage(msg: Message): void;
|
135 | |
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 | protected onActiveNotebookPanelChanged(msg: Message): void;
|
142 | |
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 | protected onActiveCellChanged(msg: Message): void;
|
149 | |
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 | protected onSelectionChanged(msg: Message): void;
|
156 | |
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | protected onActiveCellMetadataChanged(msg: ObservableJSON.ChangeMessage): void;
|
163 | |
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 | protected onActiveNotebookPanelMetadataChanged(msg: ObservableJSON.ChangeMessage): void;
|
170 | }
|
171 | |
172 |
|
173 |
|
174 | class ActiveCellTool extends Tool {
|
175 | |
176 |
|
177 |
|
178 | constructor();
|
179 | /**
|
180 | * Dispose of the resources used by the tool.
|
181 | */
|
182 | dispose(): void;
|
183 | /**
|
184 | * Handle a change to the active cell.
|
185 | */
|
186 | protected onActiveCellChanged(): void;
|
187 | /**
|
188 | * Handle a change to the notebook panel.
|
189 | *
|
190 | * #### Notes
|
191 | * The default implementation is a no-op.
|
192 | */
|
193 | protected onActiveNotebookPanelChanged(msg: Message): void;
|
194 | /**
|
195 | * Handle a change to the current editor value.
|
196 | */
|
197 | private _onValueChanged;
|
198 | /**
|
199 | * Handle a change to the current editor mimetype.
|
200 | */
|
201 | private _onMimeTypeChanged;
|
202 | private _model;
|
203 | private _cellModel;
|
204 | }
|
205 | /**
|
206 | * A raw metadata editor.
|
207 | */
|
208 | class MetadataEditorTool extends Tool {
|
209 | |
210 |
|
211 |
|
212 | constructor(options: MetadataEditorTool.IOptions);
|
213 | /**
|
214 | * The editor used by the tool.
|
215 | */
|
216 | get editor(): JSONEditor;
|
217 | /**
|
218 | * Handle a change to the notebook.
|
219 | */
|
220 | protected onActiveNotebookPanelChanged(msg: Message): void;
|
221 | protected createEditor(): void;
|
222 | private _editor;
|
223 | private _editorLabel;
|
224 | private _editorFactory;
|
225 | }
|
226 | /**
|
227 | * The namespace for `MetadataEditorTool` static data.
|
228 | */
|
229 | namespace MetadataEditorTool {
|
230 | |
231 |
|
232 |
|
233 | interface IOptions {
|
234 | |
235 |
|
236 |
|
237 | editorFactory: CodeEditor.Factory;
|
238 | |
239 |
|
240 |
|
241 | label?: string;
|
242 | |
243 |
|
244 |
|
245 | collapsed?: boolean;
|
246 | |
247 |
|
248 |
|
249 | translator?: ITranslator;
|
250 | }
|
251 | }
|
252 | |
253 |
|
254 |
|
255 | class NotebookMetadataEditorTool extends MetadataEditorTool {
|
256 | constructor(options: MetadataEditorTool.IOptions);
|
257 | /**
|
258 | * Handle a change to the notebook.
|
259 | */
|
260 | protected onActiveNotebookPanelChanged(msg: Message): void;
|
261 | /**
|
262 | * Handle a change to the notebook metadata.
|
263 | */
|
264 | protected onActiveNotebookPanelMetadataChanged(msg: Message): void;
|
265 | private _update;
|
266 | }
|
267 | /**
|
268 | * A cell metadata editor
|
269 | */
|
270 | class CellMetadataEditorTool extends MetadataEditorTool {
|
271 | constructor(options: MetadataEditorTool.IOptions);
|
272 | /**
|
273 | * Handle a change to the active cell.
|
274 | */
|
275 | protected onActiveCellChanged(msg: Message): void;
|
276 | /**
|
277 | * Handle a change to the active cell metadata.
|
278 | */
|
279 | protected onActiveCellMetadataChanged(msg: Message): void;
|
280 | private _update;
|
281 | }
|
282 | /**
|
283 | * A cell tool that provides a selection for a given metadata key.
|
284 | */
|
285 | class KeySelector extends Tool {
|
286 | |
287 |
|
288 |
|
289 | constructor(options: KeySelector.IOptions);
|
290 | /**
|
291 | * The metadata key used by the selector.
|
292 | */
|
293 | readonly key: string;
|
294 | /**
|
295 | * The select node for the widget.
|
296 | */
|
297 | get selectNode(): HTMLSelectElement;
|
298 | /**
|
299 | * Handle the DOM events for the widget.
|
300 | *
|
301 | * @param event - The DOM event sent to the widget.
|
302 | *
|
303 | * #### Notes
|
304 | * This method implements the DOM `EventListener` interface and is
|
305 | * called in response to events on the notebook panel's node. It should
|
306 | * not be called directly by user code.
|
307 | */
|
308 | handleEvent(event: Event): void;
|
309 | /**
|
310 | * Handle `after-attach` messages for the widget.
|
311 | */
|
312 | protected onAfterAttach(msg: Message): void;
|
313 | /**
|
314 | * Handle `before-detach` messages for the widget.
|
315 | */
|
316 | protected onBeforeDetach(msg: Message): void;
|
317 | /**
|
318 | * Handle a change to the active cell.
|
319 | */
|
320 | protected onActiveCellChanged(msg: Message): void;
|
321 | /**
|
322 | * Handle a change to the metadata of the active cell.
|
323 | */
|
324 | protected onActiveCellMetadataChanged(msg: ObservableJSON.ChangeMessage): void;
|
325 | /**
|
326 | * Handle a change to the value.
|
327 | */
|
328 | protected onValueChanged(): void;
|
329 | /**
|
330 | * Get the value for the data.
|
331 | */
|
332 | private _getValue;
|
333 | /**
|
334 | * Set the value for the data.
|
335 | */
|
336 | private _setValue;
|
337 | private _changeGuard;
|
338 | private _validCellTypes;
|
339 | private _getter;
|
340 | private _setter;
|
341 | private _default;
|
342 | }
|
343 | /**
|
344 | * The namespace for `KeySelector` static data.
|
345 | */
|
346 | namespace KeySelector {
|
347 | |
348 |
|
349 |
|
350 | interface IOptions {
|
351 | |
352 |
|
353 |
|
354 | key: string;
|
355 | |
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 | optionValueArray: ReadonlyPartialJSONOptionValueArray;
|
368 | |
369 |
|
370 |
|
371 | title: string;
|
372 | |
373 |
|
374 |
|
375 | validCellTypes?: nbformat.CellType[];
|
376 | |
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 | getter?: (cell: Cell) => ReadonlyPartialJSONValue | undefined;
|
384 | |
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 | setter?: (cell: Cell, value: ReadonlyPartialJSONValue | undefined) => void;
|
396 | |
397 |
|
398 |
|
399 | default?: ReadonlyPartialJSONValue;
|
400 | }
|
401 | }
|
402 | |
403 |
|
404 |
|
405 | function createSlideShowSelector(translator?: ITranslator): KeySelector;
|
406 | |
407 |
|
408 |
|
409 | function createNBConvertSelector(optionValueArray: ReadonlyPartialJSONOptionValueArray, translator?: ITranslator): KeySelector;
|
410 | }
|