1 | import { Widget } from '@lumino/widgets';
|
2 | /**
|
3 | * Options when add a command to a semantic group.
|
4 | */
|
5 | interface ISemanticCommand {
|
6 | /**
|
7 | * Command id
|
8 | */
|
9 | id: string;
|
10 | /**
|
11 | * Whether this command is enabled for a given widget
|
12 | * @param widget Widget
|
13 | */
|
14 | isEnabled?(widget: Widget): boolean;
|
15 | /**
|
16 | * Command rank in the semantic group
|
17 | *
|
18 | * #### Note
|
19 | * If multiple commands are enabled at the same time,
|
20 | * the one with the smallest rank will be executed.
|
21 | */
|
22 | rank?: number;
|
23 | }
|
24 | /**
|
25 | * Semantic group of commands
|
26 | */
|
27 | export declare class SemanticCommand {
|
28 | /**
|
29 | * Default rank for semantic command
|
30 | */
|
31 | static readonly DEFAULT_RANK = 500;
|
32 | /**
|
33 | * The command IDs used by this semantic command.
|
34 | */
|
35 | get ids(): string[];
|
36 | /**
|
37 | * Add a command to the semantic group
|
38 | *
|
39 | * @param command Command to add
|
40 | */
|
41 | add(command: ISemanticCommand): void;
|
42 | /**
|
43 | * Get the command id of the enabled command from this group
|
44 | * for the given widget.
|
45 | *
|
46 | * @param widget Widget
|
47 | * @returns Command id
|
48 | */
|
49 | getActiveCommandId(widget: Widget): string | null;
|
50 | /**
|
51 | * Remove a command ID.
|
52 | *
|
53 | * @param id Command ID to remove
|
54 | */
|
55 | remove(id: string): void;
|
56 | protected _commands: Required<ISemanticCommand>[];
|
57 | }
|
58 | export {};
|