Options
All
  • Public
  • Public/Protected
  • All
Menu

Module notebook-extension

Index

Variables

Const commandEditItem

commandEditItem: JupyterFrontEndPlugin<void> = {id: '@jupyterlab/notebook-extension:mode-status',autoStart: true,requires: [INotebookTracker, ITranslator],optional: [IStatusBar],activate: (app: JupyterFrontEnd,tracker: INotebookTracker,translator: ITranslator,statusBar: IStatusBar | null) => {if (!statusBar) {// Automatically disable if statusbar missingreturn;}const { shell } = app;const item = new CommandEditStatus(translator);// Keep the status item up-to-date with the current notebook.tracker.currentChanged.connect(() => {const current = tracker.currentWidget;item.model.notebook = current && current.content;});statusBar.registerStatusItem('@jupyterlab/notebook-extension:mode-status', {item,align: 'right',rank: 4,isActive: () =>!!shell.currentWidget &&!!tracker.currentWidget &&shell.currentWidget === tracker.currentWidget});}}

A plugin providing a CommandEdit status item.

Const default

default: JupyterFrontEndPlugin<any>[] = [factory,trackerPlugin,exportPlugin,tools,commandEditItem,notebookTrustItem,widgetFactoryPlugin,logNotebookOutput,clonedOutputsPlugin,codeConsolePlugin]

Export the plugins as default.

Const exportPlugin

exportPlugin: JupyterFrontEndPlugin<void> = {id: '@jupyterlab/notebook-extension:export',autoStart: true,requires: [ITranslator, INotebookTracker],optional: [IMainMenu, ICommandPalette],activate: (app: JupyterFrontEnd,translator: ITranslator,tracker: INotebookTracker,mainMenu: IMainMenu | null,palette: ICommandPalette | null) => {const trans = translator.load('jupyterlab');const { commands, shell } = app;const services = app.serviceManager;const isEnabled = (): boolean => {return Private.isEnabled(shell, tracker);};commands.addCommand(CommandIDs.exportToFormat, {label: args => {const formatLabel = args['label'] as string;return args['isPalette']? trans.__('Export Notebook: %1', formatLabel): formatLabel;},execute: args => {const current = getCurrent(tracker, shell, args);if (!current) {return;}const url = PageConfig.getNBConvertURL({format: args['format'] as string,download: true,path: current.context.path});const child = window.open('', '_blank');const { context } = current;if (child) {child.opener = null;}if (context.model.dirty && !context.model.readOnly) {return context.save().then(() => {child?.location.assign(url);});}return new Promise<void>(resolve => {child?.location.assign(url);resolve(undefined);});},isEnabled});// Add a notebook group to the File menu.const exportTo = new Menu({ commands });exportTo.title.label = trans.__('Export Notebook As…');void services.nbconvert.getExportFormats().then(response => {if (response) {const formatLabels: any = Private.getFormatLabels(translator);// Convert export list to palette and menu items.const formatList = Object.keys(response);formatList.forEach(function (key) {const capCaseKey = trans.__(key[0].toUpperCase() + key.substr(1));const labelStr = formatLabels[key] ? formatLabels[key] : capCaseKey;let args = {format: key,label: labelStr,isPalette: false};if (FORMAT_EXCLUDE.indexOf(key) === -1) {exportTo.addItem({command: CommandIDs.exportToFormat,args: args});if (palette) {args = {format: key,label: labelStr,isPalette: true};const category = trans.__('Notebook Operations');palette.addItem({command: CommandIDs.exportToFormat,category,args});}}});if (mainMenu) {const fileGroup = [{ type: 'submenu', submenu: exportTo } as Menu.IItemOptions];mainMenu.fileMenu.addGroup(fileGroup, 10);}}});}}

A plugin providing export commands in the main menu and command palette

Const notebookTrustItem

notebookTrustItem: JupyterFrontEndPlugin<void> = {id: '@jupyterlab/notebook-extension:trust-status',autoStart: true,requires: [INotebookTracker, ITranslator],optional: [IStatusBar],activate: (app: JupyterFrontEnd,tracker: INotebookTracker,tranlator: ITranslator,statusBar: IStatusBar | null) => {if (!statusBar) {// Automatically disable if statusbar missingreturn;}const { shell } = app;const item = new NotebookTrustStatus(tranlator);// Keep the status item up-to-date with the current notebook.tracker.currentChanged.connect(() => {const current = tracker.currentWidget;item.model.notebook = current && current.content;});statusBar.registerStatusItem('@jupyterlab/notebook-extension:trust-status',{item,align: 'right',rank: 3,isActive: () =>!!shell.currentWidget &&!!tracker.currentWidget &&shell.currentWidget === tracker.currentWidget});}}

A plugin that adds a notebook trust status item to the status bar.

Generated using TypeDoc