瀏覽代碼

Update context menu tab logic in application extension

Grant Nestor 6 年之前
父節點
當前提交
878754ace7

+ 0 - 1
packages/application-extension/package.json

@@ -34,7 +34,6 @@
     "@jupyterlab/application": "^1.0.0-alpha.6",
     "@jupyterlab/apputils": "^1.0.0-alpha.6",
     "@jupyterlab/coreutils": "^3.0.0-alpha.6",
-    "@jupyterlab/docmanager": "^1.0.0-alpha.3",
     "@phosphor/algorithm": "^1.1.2",
     "@phosphor/widgets": "^1.6.0",
     "react": "~16.8.4"

+ 4 - 6
packages/application-extension/src/index.tsx

@@ -441,20 +441,18 @@ function addCommands(app: JupyterLab, palette: ICommandPalette): void {
   const { commands, contextMenu, shell } = app;
   const category = 'Main Area';
 
-  // Returns the doc widget associated with the most recent contextmenu event.
+  // Returns the widget associated with the most recent contextmenu event.
   const contextMenuWidget = (): Widget => {
-    const pathRe = /[Pp]ath:\s?(.*)\n?/;
-    const test = (node: HTMLElement) =>
-      node['title'] && !!node['title'].match(pathRe);
+    const test = (node: HTMLElement) => !!node.dataset.id;
     const node = app.contextMenuHitTest(test);
 
     if (!node) {
-      // Fall back to active doc widget if path cannot be obtained from event.
+      // Fall back to active widget if path cannot be obtained from event.
       return shell.currentWidget;
     }
 
     const matches = toArray(shell.widgets('main')).filter(
-      widget => widget.node === node
+      widget => widget.id === node.dataset.id
     );
 
     if (matches.length < 1) {

+ 0 - 3
packages/application-extension/tsconfig.json

@@ -14,9 +14,6 @@
     },
     {
       "path": "../coreutils"
-    },
-    {
-      "path": "../docmanager"
     }
   ]
 }

+ 3 - 0
packages/application/src/shell.ts

@@ -734,6 +734,9 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell {
     if (options.ref) {
       ref = find(dock.widgets(), value => value.id === options.ref!) || null;
     }
+
+    widget.title.dataset = { ...widget.title.dataset, id: widget.id };
+
     dock.addWidget(widget, { mode, ref });
 
     // The dock panel doesn't account for placement information while