|
@@ -1,5 +1,5 @@
|
|
import {
|
|
import {
|
|
- IAppShell, ICommandPalette, ICommandRegistry
|
|
|
|
|
|
+ IAppShell, ICommandPalette, ICommandRegistry, IShortcutManager
|
|
} from 'phosphide';
|
|
} from 'phosphide';
|
|
|
|
|
|
import {
|
|
import {
|
|
@@ -15,7 +15,7 @@ import {
|
|
} from 'phosphor-widget';
|
|
} from 'phosphor-widget';
|
|
|
|
|
|
import {
|
|
import {
|
|
- IFileBrowserWidget
|
|
|
|
|
|
+ IFileBrowserWidget, SHORTCUTS
|
|
} from '../index';
|
|
} from '../index';
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -29,14 +29,42 @@ import {
|
|
export
|
|
export
|
|
function resolve(container: Container): Promise<void> {
|
|
function resolve(container: Container): Promise<void> {
|
|
return container.resolve({
|
|
return container.resolve({
|
|
- requires: [IAppShell, ICommandPalette, IFileBrowserWidget],
|
|
|
|
- create: (shell: IAppShell, palette: ICommandPalette, browser: IFileBrowserWidget) => {
|
|
|
|
|
|
+ requires: [IAppShell, ICommandPalette, IFileBrowserWidget, IShortcutManager, ICommandRegistry],
|
|
|
|
+ create: (shell: IAppShell, palette: ICommandPalette, browser: IFileBrowserWidget, shortcutManager: IShortcutManager, commandRegistry: ICommandRegistry) => {
|
|
|
|
+ // Set up the command palette.
|
|
palette.widget.title.text = 'Commands';
|
|
palette.widget.title.text = 'Commands';
|
|
|
|
+ palette.widget.id = 'command-palette';
|
|
|
|
+ commandRegistry.add([
|
|
|
|
+ {
|
|
|
|
+ id: 'command-palette:activate',
|
|
|
|
+ handler: () => {
|
|
|
|
+ let id = palette.widget.id;
|
|
|
|
+ commandRegistry.execute('appshell:activate-left', { id });
|
|
|
|
+ commandRegistry.execute('command-palette:focus-input');
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ id: 'command-palette:deactivate',
|
|
|
|
+ handler: () => {
|
|
|
|
+ if (palette.widget.isAttached && palette.widget.isVisible) {
|
|
|
|
+ commandRegistry.execute('appshell:collapse-left');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]);
|
|
|
|
+ palette.commandTriggered.connect(() => {
|
|
|
|
+ commandRegistry.execute('command-palette:deactivate');
|
|
|
|
+ });
|
|
shell.addToLeftArea(palette.widget, { rank: 40 });
|
|
shell.addToLeftArea(palette.widget, { rank: 40 });
|
|
- shell.attach(document.body);
|
|
|
|
- window.addEventListener('resize', () => { shell.update(); });
|
|
|
|
|
|
+ // Set up the file browser.
|
|
browser.title.text = 'Files';
|
|
browser.title.text = 'Files';
|
|
|
|
+ browser.id = 'file-browser';
|
|
shell.addToLeftArea(browser, { rank: 40 });
|
|
shell.addToLeftArea(browser, { rank: 40 });
|
|
|
|
+ // Add the application keyboard shortcuts.
|
|
|
|
+ shortcutManager.add(SHORTCUTS);
|
|
|
|
+ // Attach the app shell to the DOM.
|
|
|
|
+ shell.attach(document.body);
|
|
|
|
+ window.addEventListener('resize', () => { shell.update(); });
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|