-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
file.ts
84 lines (71 loc) · 1.85 KB
/
file.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import { IRankedMenu, RankedMenu } from '@jupyterlab/ui-components';
import { find } from '@lumino/algorithm';
import { SemanticCommand } from '@jupyterlab/apputils';
/**
* An interface for a File menu.
*/
export interface IFileMenu extends IRankedMenu {
/**
* Option to add a `Quit` entry in the File menu
*/
quitEntry: boolean;
/**
* A submenu for creating new files/launching new activities.
*/
readonly newMenu: IRankedMenu;
/**
* The close and cleanup semantic command.
*/
readonly closeAndCleaners: SemanticCommand;
/**
* The console creator semantic command.
*/
readonly consoleCreators: SemanticCommand;
}
/**
* An extensible FileMenu for the application.
*/
export class FileMenu extends RankedMenu implements IFileMenu {
constructor(options: IRankedMenu.IOptions) {
super(options);
this.quitEntry = false;
this.closeAndCleaners = new SemanticCommand();
this.consoleCreators = new SemanticCommand();
}
/**
* The New submenu.
*/
get newMenu(): RankedMenu {
if (!this._newMenu) {
this._newMenu =
(find(this.items, menu => menu.submenu?.id === 'jp-mainmenu-file-new')
?.submenu as RankedMenu) ??
new RankedMenu({
commands: this.commands
});
}
return this._newMenu;
}
/**
* The close and cleanup semantic command.
*/
readonly closeAndCleaners: SemanticCommand;
/**
* The console creator semantic command.
*/
readonly consoleCreators: SemanticCommand;
/**
* Dispose of the resources held by the file menu.
*/
dispose(): void {
this._newMenu?.dispose();
super.dispose();
}
/**
* Option to add a `Quit` entry in File menu
*/
public quitEntry: boolean;
private _newMenu: RankedMenu;
}