UNPKG

2.61 kBTypeScriptView Raw
1import { SemanticCommand } from '@jupyterlab/apputils';
2import { TranslationBundle } from '@jupyterlab/translation';
3import { CommandRegistry } from '@lumino/commands';
4import { JupyterFrontEnd } from './frontend';
5export interface ISemanticCommandDefault {
6 /**
7 * Default command id to execute if no command is enabled
8 */
9 execute?: string;
10 /**
11 * Default command label
12 */
13 label?: string;
14 /**
15 * Default command caption
16 */
17 caption?: string;
18 /**
19 * Whether the default command is enabled.
20 */
21 isEnabled?: boolean;
22 /**
23 * Whether the default command is toggled.
24 */
25 isToggled?: boolean;
26 /**
27 * Whether the default command is visible.
28 */
29 isVisible?: boolean;
30}
31/**
32 * Semantic command(s) options
33 */
34export interface ISemanticCommandOptions {
35 /**
36 * Semantic command ID
37 */
38 id: string;
39 /**
40 * Application command registry
41 */
42 commands: CommandRegistry;
43 /**
44 * Application shell
45 */
46 shell: JupyterFrontEnd.IShell;
47 /**
48 * Semantic commands
49 */
50 semanticCommands: SemanticCommand | SemanticCommand[];
51 /**
52 * Default commands options
53 *
54 * It will be used if the enabled command is not defining one
55 * or if no command is enabled.
56 */
57 default?: ISemanticCommandDefault;
58 /**
59 * Override commands options
60 *
61 * It will override the enabled command attribute.
62 */
63 overrides?: Omit<CommandRegistry.ICommandOptions, 'execute'>;
64 /**
65 * Domain specific translation object.
66 */
67 trans?: TranslationBundle;
68}
69/**
70 * Add a semantic commands to the application and take care
71 * of setting up the command changed signal.
72 *
73 * @param options Semantic command options
74 */
75export declare function addSemanticCommand(options: ISemanticCommandOptions): void;
76/**
77 * Create the command options from the given semantic commands list
78 * and the given default values.
79 *
80 * @param app Jupyter Application
81 * @param semanticCommands Single semantic command or a list of commands
82 * @param defaultValues Default values
83 * @param trans Translation bundle
84 * @returns Command options
85 *
86 * @deprecated Please use {@link addSemanticCommand}. This function will
87 * be removed of the public API in JupyterLab 5.
88 */
89export declare function createSemanticCommand(app: JupyterFrontEnd | {
90 commands: CommandRegistry;
91 shell: JupyterFrontEnd.IShell;
92}, semanticCommands: SemanticCommand | SemanticCommand[], defaultValues: ISemanticCommandDefault, trans: TranslationBundle): CommandRegistry.ICommandOptions;