1 | // Copyright (c) Jupyter Development Team.
|
2 | // Distributed under the terms of the Modified BSD License.
|
3 |
|
4 | import { IRankedMenu, RankedMenu } from '@jupyterlab/ui-components';
|
5 | import { SemanticCommand } from '@jupyterlab/apputils';
|
6 |
|
7 | /**
|
8 | * An interface for an Edit menu.
|
9 | */
|
10 | export interface IEditMenu extends IRankedMenu {
|
11 | /**
|
12 | * Semantic commands IUndoers for the Edit menu.
|
13 | */
|
14 | readonly undoers: IEditMenu.IUndoer;
|
15 |
|
16 | /**
|
17 | * Semantic commands IClearers for the Edit menu.
|
18 | */
|
19 | readonly clearers: IEditMenu.IClearer;
|
20 |
|
21 | /**
|
22 | * Semantic commands IGoToLiners for the Edit menu.
|
23 | */
|
24 | readonly goToLiners: SemanticCommand;
|
25 | }
|
26 |
|
27 | /**
|
28 | * An extensible Edit menu for the application.
|
29 | */
|
30 | export class EditMenu extends RankedMenu implements IEditMenu {
|
31 | /**
|
32 | * Construct the edit menu.
|
33 | */
|
34 | constructor(options: IRankedMenu.IOptions) {
|
35 | super(options);
|
36 |
|
37 | this.undoers = {
|
38 | redo: new SemanticCommand(),
|
39 | undo: new SemanticCommand()
|
40 | };
|
41 |
|
42 | this.clearers = {
|
43 | clearAll: new SemanticCommand(),
|
44 | clearCurrent: new SemanticCommand()
|
45 | };
|
46 |
|
47 | this.goToLiners = new SemanticCommand();
|
48 | }
|
49 |
|
50 | /**
|
51 | * Semantic commands IUndoers for the Edit menu.
|
52 | */
|
53 | readonly undoers: IEditMenu.IUndoer;
|
54 |
|
55 | /**
|
56 | * Semantic commands IClearers for the Edit menu.
|
57 | */
|
58 | readonly clearers: IEditMenu.IClearer;
|
59 |
|
60 | /**
|
61 | * Semantic commands IGoToLiners for the Edit menu.
|
62 | */
|
63 | readonly goToLiners: SemanticCommand;
|
64 | }
|
65 |
|
66 | /**
|
67 | * Namespace for IEditMenu
|
68 | */
|
69 | export namespace IEditMenu {
|
70 | /**
|
71 | * Interface for an activity that uses Undo/Redo.
|
72 | */
|
73 | export interface IUndoer {
|
74 | /**
|
75 | * A semantic command to execute an undo command for the activity.
|
76 | */
|
77 | undo: SemanticCommand;
|
78 |
|
79 | /**
|
80 | * A semantic command to execute a redo command for the activity.
|
81 | */
|
82 | redo: SemanticCommand;
|
83 | }
|
84 |
|
85 | /**
|
86 | * Interface for an activity that wants to register a 'Clear...' menu item
|
87 | */
|
88 | export interface IClearer {
|
89 | /**
|
90 | * A semantic command to clear the currently portion of activity.
|
91 | */
|
92 | clearCurrent: SemanticCommand;
|
93 |
|
94 | /**
|
95 | * A semantic command to clear all of an activity.
|
96 | */
|
97 | clearAll: SemanticCommand;
|
98 | }
|
99 | }
|