1 |
|
2 |
|
3 |
|
4 |
|
5 | import { Widget } from '@lumino/widgets';
|
6 | import { NotebookActions } from './actions';
|
7 | const NOTEBOOK_FOOTER_CLASS = 'jp-Notebook-footer';
|
8 |
|
9 |
|
10 |
|
11 | export class NotebookFooter extends Widget {
|
12 | |
13 |
|
14 |
|
15 | constructor(notebook) {
|
16 | super({ node: document.createElement('button') });
|
17 | this.notebook = notebook;
|
18 | const trans = notebook.translator.load('jupyterlab');
|
19 | this.addClass(NOTEBOOK_FOOTER_CLASS);
|
20 | this.node.setAttribute('tabindex', '-1');
|
21 | this.node.innerText = trans.__('Click to add a cell.');
|
22 | }
|
23 | |
24 |
|
25 |
|
26 | handleEvent(event) {
|
27 | switch (event.type) {
|
28 | case 'click':
|
29 | this.onClick();
|
30 | break;
|
31 | case 'keydown':
|
32 | if (event.key === 'ArrowUp') {
|
33 | this.onArrowUp();
|
34 | break;
|
35 | }
|
36 | }
|
37 | }
|
38 | |
39 |
|
40 |
|
41 | onClick() {
|
42 | if (this.notebook.widgets.length > 0) {
|
43 | this.notebook.activeCellIndex = this.notebook.widgets.length - 1;
|
44 | }
|
45 | NotebookActions.insertBelow(this.notebook);
|
46 |
|
47 | void NotebookActions.focusActiveCell(this.notebook);
|
48 | }
|
49 | |
50 |
|
51 |
|
52 |
|
53 | onArrowUp() {
|
54 |
|
55 | }
|
56 | |
57 |
|
58 |
|
59 | onAfterAttach(msg) {
|
60 | super.onAfterAttach(msg);
|
61 | this.node.addEventListener('click', this);
|
62 | this.node.addEventListener('keydown', this);
|
63 | }
|
64 | |
65 |
|
66 |
|
67 | onBeforeDetach(msg) {
|
68 | this.node.removeEventListener('click', this);
|
69 | this.node.removeEventListener('keydown', this);
|
70 | super.onBeforeDetach(msg);
|
71 | }
|
72 | }
|
73 |
|
\ | No newline at end of file |