|
@@ -39,10 +39,12 @@ import { IStateDB } from '@jupyterlab/statedb';
|
|
|
|
|
|
import { ITranslator, TranslationBundle } from '@jupyterlab/translation';
|
|
import { ITranslator, TranslationBundle } from '@jupyterlab/translation';
|
|
|
|
|
|
-import { buildIcon } from '@jupyterlab/ui-components';
|
|
|
|
|
|
+import { buildIcon, Switch } from '@jupyterlab/ui-components';
|
|
|
|
|
|
import { each, iter, toArray } from '@lumino/algorithm';
|
|
import { each, iter, toArray } from '@lumino/algorithm';
|
|
|
|
|
|
|
|
+import { CommandRegistry } from '@lumino/commands';
|
|
|
|
+
|
|
import { PromiseDelegate } from '@lumino/coreutils';
|
|
import { PromiseDelegate } from '@lumino/coreutils';
|
|
|
|
|
|
import { DisposableDelegate, DisposableSet } from '@lumino/disposable';
|
|
import { DisposableDelegate, DisposableSet } from '@lumino/disposable';
|
|
@@ -940,6 +942,59 @@ const propertyInspector: JupyterFrontEndPlugin<IPropertyInspectorProvider> = {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * The single-document mode switch in the top area.
|
|
|
|
+ */
|
|
|
|
+const modeSwitch: JupyterFrontEndPlugin<void> = {
|
|
|
|
+ id: '@jupyterlab/application-extension:mode-switch',
|
|
|
|
+ requires: [ILabShell, ITranslator],
|
|
|
|
+ activate: (
|
|
|
|
+ app: JupyterFrontEnd,
|
|
|
|
+ shell: ILabShell,
|
|
|
|
+ translator: ITranslator
|
|
|
|
+ ) => {
|
|
|
|
+ const trans = translator.load('jupyterlab');
|
|
|
|
+
|
|
|
|
+ const spacer = new Widget();
|
|
|
|
+ spacer.id = 'jp-top-spacer';
|
|
|
|
+ spacer.node.style.flexGrow = '1';
|
|
|
|
+ shell.add(spacer, 'top', { rank: 1000 });
|
|
|
|
+
|
|
|
|
+ const modeSwitch = new Switch();
|
|
|
|
+ modeSwitch.id = 'jp-single-document-mode';
|
|
|
|
+
|
|
|
|
+ modeSwitch.valueChanged.connect((_, args) => {
|
|
|
|
+ shell.mode = args.newValue ? 'single-document' : 'multiple-document';
|
|
|
|
+ });
|
|
|
|
+ shell.modeChanged.connect((_, mode) => {
|
|
|
|
+ modeSwitch.value = mode === 'single-document';
|
|
|
|
+ });
|
|
|
|
+ modeSwitch.value = shell.mode === 'single-document';
|
|
|
|
+
|
|
|
|
+ // Show the current file browser shortcut in its title.
|
|
|
|
+ const updateModeSwitchTitle = () => {
|
|
|
|
+ const binding = app.commands.keyBindings.find(
|
|
|
|
+ b => b.command === CommandIDs.toggleMode
|
|
|
|
+ );
|
|
|
|
+ if (binding) {
|
|
|
|
+ const ks = CommandRegistry.formatKeystroke(binding.keys.join(' '));
|
|
|
|
+ modeSwitch.caption = trans.__('Single-Document Mode (%1)', ks);
|
|
|
|
+ } else {
|
|
|
|
+ modeSwitch.caption = trans.__('Single-Document Mode');
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ updateModeSwitchTitle();
|
|
|
|
+ app.commands.keyBindingChanged.connect(() => {
|
|
|
|
+ updateModeSwitchTitle();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ modeSwitch.label = trans.__('Mode');
|
|
|
|
+
|
|
|
|
+ shell.add(modeSwitch, 'top', { rank: 1010 });
|
|
|
|
+ },
|
|
|
|
+ autoStart: true
|
|
|
|
+};
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Export the plugins as default.
|
|
* Export the plugins as default.
|
|
*/
|
|
*/
|
|
@@ -955,7 +1010,8 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
|
|
status,
|
|
status,
|
|
info,
|
|
info,
|
|
paths,
|
|
paths,
|
|
- propertyInspector
|
|
|
|
|
|
+ propertyInspector,
|
|
|
|
+ modeSwitch
|
|
];
|
|
];
|
|
|
|
|
|
export default plugins;
|
|
export default plugins;
|