UNPKG

2.19 kBPlain TextView Raw
1// Copyright (c) Jupyter Development Team.
2// Distributed under the terms of the Modified BSD License.
3
4import { IRankedMenu, RankedMenu } from '@jupyterlab/ui-components';
5import { SemanticCommand } from '@jupyterlab/apputils';
6
7/**
8 * An interface for an Edit menu.
9 */
10export 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 */
30export 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 */
69export 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}