UNPKG

6.54 kBTypeScriptView Raw
1import { IChangedArgs } from '@jupyterlab/coreutils';
2import { ISettingRegistry } from '@jupyterlab/settingregistry';
3import { Token } from '@lumino/coreutils';
4import { IDisposable } from '@lumino/disposable';
5import { ISignal } from '@lumino/signaling';
6import { Widget } from '@lumino/widgets';
7import { ISessionContext } from './sessioncontext';
8/**
9 * An interface for the session context dialogs.
10 */
11export interface ISessionContextDialogs extends ISessionContext.IDialogs {
12}
13/**
14 * The session context dialogs token.
15 */
16export declare const ISessionContextDialogs: Token<ISessionContext.IDialogs>;
17/**
18 * The theme manager token.
19 */
20export declare const IThemeManager: Token<IThemeManager>;
21/**
22 * An interface for a theme manager.
23 */
24export interface IThemeManager {
25 /**
26 * Get the name of the current theme.
27 */
28 readonly theme: string | null;
29 /**
30 * The names of the registered themes.
31 */
32 readonly themes: ReadonlyArray<string>;
33 /**
34 * A signal fired when the application theme changes.
35 */
36 readonly themeChanged: ISignal<this, IChangedArgs<string, string | null>>;
37 /**
38 * Load a theme CSS file by path.
39 *
40 * @param path - The path of the file to load.
41 */
42 loadCSS(path: string): Promise<void>;
43 /**
44 * Register a theme with the theme manager.
45 *
46 * @param theme - The theme to register.
47 *
48 * @returns A disposable that can be used to unregister the theme.
49 */
50 register(theme: IThemeManager.ITheme): IDisposable;
51 /**
52 * Set the current theme.
53 */
54 setTheme(name: string): Promise<void>;
55 /**
56 * Test whether a given theme is light.
57 */
58 isLight(name: string): boolean;
59 /**
60 * Test whether a given theme styles scrollbars,
61 * and if the user has scrollbar styling enabled.
62 */
63 themeScrollbars(name: string): boolean;
64 /**
65 * Get display name for theme.
66 */
67 getDisplayName(name: string): string;
68}
69/**
70 * A namespace for the `IThemeManager` sub-types.
71 */
72export declare namespace IThemeManager {
73 /**
74 * An interface for a theme.
75 */
76 interface ITheme {
77 /**
78 * The unique identifier name of the theme.
79 */
80 name: string;
81 /**
82 * The display name of the theme.
83 */
84 displayName?: string;
85 /**
86 * Whether the theme is light or dark. Downstream authors
87 * of extensions can use this information to customize their
88 * UI depending upon the current theme.
89 */
90 isLight: boolean;
91 /**
92 * Whether the theme includes styling for the scrollbar.
93 * If set to false, this theme will leave the native scrollbar untouched.
94 */
95 themeScrollbars?: boolean;
96 /**
97 * Load the theme.
98 *
99 * @returns A promise that resolves when the theme has loaded.
100 */
101 load(): Promise<void>;
102 /**
103 * Unload the theme.
104 *
105 * @returns A promise that resolves when the theme has unloaded.
106 */
107 unload(): Promise<void>;
108 }
109}
110/**
111 * The sanitizer token.
112 */
113export declare const ISanitizer: Token<ISanitizer>;
114export interface ISanitizer {
115 /**
116 * Sanitize an HTML string.
117 *
118 * @param dirty - The dirty text.
119 *
120 * @param options - The optional sanitization options.
121 *
122 * @returns The sanitized string.
123 */
124 sanitize(dirty: string, options?: ISanitizer.IOptions): string;
125}
126/**
127 * The namespace for `ISanitizer` related interfaces.
128 */
129export declare namespace ISanitizer {
130 /**
131 * The options used to sanitize.
132 */
133 interface IOptions {
134 /**
135 * The allowed tags.
136 */
137 allowedTags?: string[];
138 /**
139 * The allowed attributes for a given tag.
140 */
141 allowedAttributes?: {
142 [key: string]: string[];
143 };
144 /**
145 * The allowed style values for a given tag.
146 */
147 allowedStyles?: {
148 [key: string]: {
149 [key: string]: RegExp[];
150 };
151 };
152 }
153}
154/**
155 * The namespace for `IToolbarWidgetRegistry` related interfaces
156 */
157export declare namespace ToolbarRegistry {
158 /**
159 * Interface of item to be inserted in a toolbar
160 */
161 interface IToolbarItem {
162 /**
163 * Unique item name
164 */
165 name: string;
166 /**
167 * Toolbar widget
168 */
169 widget: Widget;
170 }
171 /**
172 * Interface describing a toolbar item widget
173 */
174 interface IWidget extends ISettingRegistry.IToolbarItem {
175 }
176 /**
177 * Options to set up the toolbar widget registry
178 */
179 interface IOptions {
180 /**
181 * Default toolbar widget factory
182 *
183 * The factory is receiving 3 arguments:
184 * @param widgetFactory The widget factory name that creates the toolbar
185 * @param widget The newly widget containing the toolbar
186 * @param toolbarItem The toolbar item definition
187 * @returns The widget to be inserted in the toolbar.
188 */
189 defaultFactory: (widgetFactory: string, widget: Widget, toolbarItem: IWidget) => Widget;
190 }
191}
192/**
193 * Toolbar widget registry interface
194 */
195export interface IToolbarWidgetRegistry {
196 /**
197 * Default toolbar item factory
198 */
199 defaultFactory: (widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget) => Widget;
200 /**
201 * Create a toolbar item widget
202 *
203 * @param widgetFactory The widget factory name that creates the toolbar
204 * @param widget The newly widget containing the toolbar
205 * @param toolbarItem The toolbar item definition
206 * @returns The widget to be inserted in the toolbar.
207 */
208 createWidget(widgetFactory: string, widget: Widget, toolbarItem: ToolbarRegistry.IWidget): Widget;
209 /**
210 * Register a new toolbar item factory
211 *
212 * @param widgetFactory The widget factory name that creates the toolbar
213 * @param toolbarItemName The unique toolbar item
214 * @param factory The factory function that receives the widget containing the toolbar and returns the toolbar widget.
215 * @returns The previously defined factory
216 */
217 registerFactory<T extends Widget = Widget>(widgetFactory: string, toolbarItemName: string, factory: (main: T) => Widget): ((main: T) => Widget) | undefined;
218}
219/**
220 * The toolbar registry token.
221 */
222export declare const IToolbarWidgetRegistry: Token<IToolbarWidgetRegistry>;
223
\No newline at end of file