diff --git a/package.json b/package.json index 4449abe..7ebcd26 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "@jupyterlab/ui-components": "^4.0.5", "@lumino/algorithm": "^2.0.0", "@lumino/commands": "^2.0.1", + "@lumino/coreutils": "^2.0.1", "@lumino/signaling": "^2.0.0", "@lumino/widgets": "^2.0.1" }, diff --git a/src/index.ts b/src/index.ts index b8e008e..498e939 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,23 +22,26 @@ import { } from './utils'; import { PageConfig } from '@jupyterlab/coreutils'; +export { IFavorites } from './token'; + const TOOLBAR_CLASS = 'jp-FileBrowser-toolbar'; /** * Initialization data for the jupyterlab-favorites extension. */ -const favorites: JupyterFrontEndPlugin = { +const favorites: JupyterFrontEndPlugin = { id: PluginIDs.favorites, autoStart: true, requires: [IDefaultFileBrowser, IFileBrowserFactory, ISettingRegistry], + provides: IFavorites, optional: [IMainMenu], - activate: async ( + activate: ( app: JupyterFrontEnd, filebrowser: IDefaultFileBrowser, factory: IFileBrowserFactory, settingsRegistry: ISettingRegistry, mainMenu: IMainMenu - ) => { + ): IFavorites => { console.log('JupyterLab extension jupyterlab-favorites is activated!'); const docRegistry = app.docRegistry; const layout = filebrowser.layout as PanelLayout; @@ -213,6 +216,8 @@ const favorites: JupyterFrontEndPlugin = { execute: () => favoritesManager.clearFavorites(), label: 'Clear Favorites' }); + + return favoritesManager; } }; diff --git a/src/token.ts b/src/token.ts index 44e7c29..35ba946 100644 --- a/src/token.ts +++ b/src/token.ts @@ -1,3 +1,5 @@ +import { Token } from '@lumino/coreutils'; + export namespace PluginIDs { export const favorites = 'jupyterlab-favorites'; } @@ -32,3 +34,9 @@ export namespace IFavorites { showWidget?: boolean; }; } + +export const IFavorites = new Token('jupyterlab-favorites:IFavorites'); + +export interface IFavorites { + readonly favorites: IFavorites.Favorite[]; +}