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 current editor value.
|
189 | */
|
190 | private _onValueChanged;
|
191 | /**
|
192 | * Handle a change to the current editor mimetype.
|
193 | */
|
194 | private _onMimeTypeChanged;
|
195 | private _model;
|
196 | private _cellModel;
|
197 | }
|
198 | /**
|
199 | * A raw metadata editor.
|
200 | */
|
201 | class MetadataEditorTool extends Tool {
|
202 | |
203 |
|
204 |
|
205 | constructor(options: MetadataEditorTool.IOptions);
|
206 | /**
|
207 | * The editor used by the tool.
|
208 | */
|
209 | readonly editor: JSONEditor;
|
210 | }
|
211 | /**
|
212 | * The namespace for `MetadataEditorTool` static data.
|
213 | */
|
214 | namespace MetadataEditorTool {
|
215 | |
216 |
|
217 |
|
218 | interface IOptions {
|
219 | |
220 |
|
221 |
|
222 | editorFactory: CodeEditor.Factory;
|
223 | |
224 |
|
225 |
|
226 | label?: string;
|
227 | |
228 |
|
229 |
|
230 | collapsed?: boolean;
|
231 | |
232 |
|
233 |
|
234 | translator?: ITranslator;
|
235 | }
|
236 | }
|
237 | |
238 |
|
239 |
|
240 | class NotebookMetadataEditorTool extends MetadataEditorTool {
|
241 | constructor(options: MetadataEditorTool.IOptions);
|
242 | /**
|
243 | * Handle a change to the notebook.
|
244 | */
|
245 | protected onActiveNotebookPanelChanged(msg: Message): void;
|
246 | /**
|
247 | * Handle a change to the notebook metadata.
|
248 | */
|
249 | protected onActiveNotebookPanelMetadataChanged(msg: Message): void;
|
250 | private _update;
|
251 | }
|
252 | /**
|
253 | * A cell metadata editor
|
254 | */
|
255 | class CellMetadataEditorTool extends MetadataEditorTool {
|
256 | constructor(options: MetadataEditorTool.IOptions);
|
257 | /**
|
258 | * Handle a change to the active cell.
|
259 | */
|
260 | protected onActiveCellChanged(msg: Message): void;
|
261 | /**
|
262 | * Handle a change to the active cell metadata.
|
263 | */
|
264 | protected onActiveCellMetadataChanged(msg: Message): void;
|
265 | private _update;
|
266 | }
|
267 | /**
|
268 | * A cell tool that provides a selection for a given metadata key.
|
269 | */
|
270 | class KeySelector extends Tool {
|
271 | |
272 |
|
273 |
|
274 | constructor(options: KeySelector.IOptions);
|
275 | /**
|
276 | * The metadata key used by the selector.
|
277 | */
|
278 | readonly key: string;
|
279 | /**
|
280 | * The select node for the widget.
|
281 | */
|
282 | get selectNode(): HTMLSelectElement;
|
283 | /**
|
284 | * Handle the DOM events for the widget.
|
285 | *
|
286 | * @param event - The DOM event sent to the widget.
|
287 | *
|
288 | * #### Notes
|
289 | * This method implements the DOM `EventListener` interface and is
|
290 | * called in response to events on the notebook panel's node. It should
|
291 | * not be called directly by user code.
|
292 | */
|
293 | handleEvent(event: Event): void;
|
294 | /**
|
295 | * Handle `after-attach` messages for the widget.
|
296 | */
|
297 | protected onAfterAttach(msg: Message): void;
|
298 | /**
|
299 | * Handle `before-detach` messages for the widget.
|
300 | */
|
301 | protected onBeforeDetach(msg: Message): void;
|
302 | /**
|
303 | * Handle a change to the active cell.
|
304 | */
|
305 | protected onActiveCellChanged(msg: Message): void;
|
306 | /**
|
307 | * Handle a change to the metadata of the active cell.
|
308 | */
|
309 | protected onActiveCellMetadataChanged(msg: ObservableJSON.ChangeMessage): void;
|
310 | /**
|
311 | * Handle a change to the value.
|
312 | */
|
313 | protected onValueChanged(): void;
|
314 | /**
|
315 | * Get the value for the data.
|
316 | */
|
317 | private _getValue;
|
318 | /**
|
319 | * Set the value for the data.
|
320 | */
|
321 | private _setValue;
|
322 | private _changeGuard;
|
323 | private _validCellTypes;
|
324 | private _getter;
|
325 | private _setter;
|
326 | private _default;
|
327 | }
|
328 | /**
|
329 | * The namespace for `KeySelector` static data.
|
330 | */
|
331 | namespace KeySelector {
|
332 | |
333 |
|
334 |
|
335 | interface IOptions {
|
336 | |
337 |
|
338 |
|
339 | key: string;
|
340 | |
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 | optionValueArray: ReadonlyPartialJSONOptionValueArray;
|
353 | |
354 |
|
355 |
|
356 | title: string;
|
357 | |
358 |
|
359 |
|
360 | validCellTypes?: nbformat.CellType[];
|
361 | |
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 | getter?: (cell: Cell) => ReadonlyPartialJSONValue | undefined;
|
369 | |
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 | setter?: (cell: Cell, value: ReadonlyPartialJSONValue | undefined) => void;
|
381 | |
382 |
|
383 |
|
384 | default?: ReadonlyPartialJSONValue;
|
385 | }
|
386 | }
|
387 | |
388 |
|
389 |
|
390 | function createSlideShowSelector(translator?: ITranslator): KeySelector;
|
391 | |
392 |
|
393 |
|
394 | function createNBConvertSelector(optionValueArray: ReadonlyPartialJSONOptionValueArray, translator?: ITranslator): KeySelector;
|
395 | }
|