瀏覽代碼

notebook: Remove celltoolbar if not notebook

If the current Panel is not a NotebookPanel, remove the cell toolbar tab
from the left menu. Show it only when the Panel is a NotebookPanel.
AbdealiJK 8 年之前
父節點
當前提交
967c5971c3
共有 1 個文件被更改,包括 13 次插入1 次删除
  1. 13 1
      src/notebook/plugin.ts

+ 13 - 1
src/notebook/plugin.ts

@@ -152,7 +152,19 @@ function activateCellTools(app: JupyterLab, restorer: IInstanceRestorer, tracker
   celltools.addItem({ tool: metadataEditor, rank: 4 });
 
   restorer.add(celltools, namespace);
-  app.shell.addToLeftArea(celltools);
+
+  app.shell.currentChanged.connect((sender, args) => {
+    if (args.newValue instanceof NotebookPanel) {
+      app.shell.addToLeftArea(celltools);
+    } else {
+      celltools.close();
+    }
+  });
+  // To avoid a race condition (if it was changed before the plugin was
+  // activated), add it here also
+  if (app.shell.currentWidget instanceof NotebookPanel) {
+     app.shell.addToLeftArea(celltools);
+  }
 
   return Promise.resolve(celltools);
 }