Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #10666: Don't sort context menu items by selector #12505

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions packages/application/src/frontend.ts
Expand Up @@ -50,7 +50,9 @@ export abstract class JupyterFrontEnd<
// render context menu/submenus with inline svg icon tweaks
this.contextMenu = new ContextMenuSvg({
commands: this.commands,
renderer: options.contextMenuRenderer
renderer: options.contextMenuRenderer,
groupByTarget: false,
sortBySelector: false
});

// The default restored promise if one does not exist in the options.
Expand Down Expand Up @@ -289,7 +291,7 @@ export namespace JupyterFrontEnd {
* @param path - Full URL of JupyterLab
* @param paths - The current IPaths object hydrated from PageConfig.
*/
export function inDocMode(path: string, paths: IPaths) {
export function inDocMode(path: string, paths: IPaths): boolean {
const docPattern = new RegExp(`^${paths.urls.doc}`);
const match = path.match(docPattern);
if (match) {
Expand Down
3 changes: 2 additions & 1 deletion packages/console-extension/schema/foreign.json
Expand Up @@ -5,7 +5,8 @@
"context": [
{
"command": "console:toggle-show-all-kernel-activity",
"selector": ".jp-CodeConsole"
"selector": ".jp-CodeConsole",
"rank": 20
}
]
},
Expand Down
6 changes: 4 additions & 2 deletions packages/console-extension/schema/tracker.json
Expand Up @@ -61,11 +61,13 @@
"context": [
{
"command": "console:clear",
"selector": ".jp-CodeConsole-content"
"selector": ".jp-CodeConsole-content",
"rank": 10
},
{
"command": "console:restart-kernel",
"selector": ".jp-CodeConsole"
"selector": ".jp-CodeConsole",
"rank": 30
}
]
},
Expand Down
8 changes: 4 additions & 4 deletions packages/docmanager-extension/schema/plugin.json
Expand Up @@ -73,22 +73,22 @@
{
"command": "docmanager:rename",
"selector": "[data-type=\"document-title\"]",
"rank": 1
"rank": 20
},
{
"command": "docmanager:delete",
"selector": "[data-type=\"document-title\"]",
"rank": 2
"rank": 21
},
{
"command": "docmanager:clone",
"selector": "[data-type=\"document-title\"]",
"rank": 3
"rank": 22
},
{
"command": "docmanager:show-in-file-browser",
"selector": "[data-type=\"document-title\"]",
"rank": 4
"rank": 23
}
]
},
Expand Down
40 changes: 20 additions & 20 deletions packages/filebrowser-extension/schema/browser.json
Expand Up @@ -57,31 +57,11 @@
"selector": ".jp-DirListing-content",
"rank": 0
},
{
"command": "filebrowser:create-new-directory",
"selector": ".jp-DirListing-content",
"rank": 1
},
{
"command": "filebrowser:open",
"selector": ".jp-DirListing-item[data-isdir]",
"rank": 1
},
{
"command": "filebrowser:create-new-file",
"selector": ".jp-DirListing-content",
"rank": 2
},
{
"command": "filebrowser:create-new-markdown-file",
"selector": ".jp-DirListing-content",
"rank": 3
},
{
"command": "filebrowser:paste",
"selector": ".jp-DirListing-content",
"rank": 4
},
{
"type": "separator",
"selector": ".jp-DirListing-item[data-isdir]",
Expand All @@ -107,6 +87,11 @@
"selector": ".jp-DirListing-item[data-isdir=\"false\"]",
"rank": 8
},
{
"command": "filebrowser:paste",
"selector": ".jp-DirListing-content",
"rank": 8.5
},
{
"command": "filebrowser:duplicate",
"selector": ".jp-DirListing-item[data-isdir=\"false\"]",
Expand Down Expand Up @@ -141,6 +126,21 @@
"command": "filebrowser:share-main",
"selector": ".jp-DirListing-item[data-isdir]",
"rank": 15
},
{
"type": "separator",
"selector": ".jp-DirListing-item[data-isdir]",
"rank": 50
},
{
"command": "filebrowser:create-new-file",
"selector": ".jp-DirListing-content",
"rank": 51
},
{
"command": "filebrowser:create-new-directory",
"selector": ".jp-DirListing-content",
"rank": 55
}
]
},
Expand Down
Expand Up @@ -6,7 +6,7 @@
{
"command": "filebrowser:open-browser-tab",
"selector": ".jp-DirListing-item[data-isdir=\"false\"]",
"rank": 3
"rank": 1.6
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion packages/filebrowser-extension/schema/open-with.json
Expand Up @@ -6,7 +6,7 @@
{
"type": "submenu",
"selector": ".jp-DirListing-item[data-isdir=\"false\"]",
"rank": 2,
"rank": 1.3,
"submenu": {
"id": "jp-contextmenu-open-with",
"label": "Open With",
Expand Down
18 changes: 10 additions & 8 deletions packages/fileeditor-extension/schema/plugin.json
Expand Up @@ -102,14 +102,6 @@
}
],
"context": [
{
"command": "fileeditor:create-console",
"selector": ".jp-FileEditor"
},
{
"command": "fileeditor:markdown-preview",
"selector": ".jp-FileEditor"
},
{
"command": "fileeditor:undo",
"selector": ".jp-FileEditor",
Expand Down Expand Up @@ -139,6 +131,16 @@
"command": "fileeditor:select-all",
"selector": ".jp-FileEditor",
"rank": 6
},
{
"command": "fileeditor:create-console",
"selector": ".jp-FileEditor",
"rank": 10
},
{
"command": "fileeditor:markdown-preview",
"selector": ".jp-FileEditor",
"rank": 11
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion packages/inspector-extension/schema/consoles.json
Expand Up @@ -5,7 +5,8 @@
"context": [
{
"command": "inspector:open",
"selector": ".jp-CodeConsole-promptCell"
"selector": ".jp-CodeConsole-promptCell",
"rank": 5
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion packages/inspector-extension/schema/notebooks.json
Expand Up @@ -6,7 +6,7 @@
{
"command": "inspector:open",
"selector": ".jp-Notebook",
"rank": 10
"rank": 50
}
]
},
Expand Down
4 changes: 3 additions & 1 deletion packages/logconsole-extension/schema/plugin.json
Expand Up @@ -18,7 +18,9 @@
]
}
],
"context": [{ "command": "logconsole:open", "selector": ".jp-Notebook" }]
"context": [
{ "command": "logconsole:open", "selector": ".jp-Notebook", "rank": 60 }
]
},
"title": "Log Console",
"description": "Log Console settings.",
Expand Down
2 changes: 1 addition & 1 deletion packages/mainmenu-extension/schema/plugin.json
Expand Up @@ -227,7 +227,7 @@
{
"command": "filemenu:create-console",
"selector": "[data-type=\"document-title\"].jp-mod-current",
"rank": 6
"rank": 10
}
]
},
Expand Down
28 changes: 18 additions & 10 deletions packages/notebook-extension/schema/tracker.json
Expand Up @@ -308,52 +308,60 @@
{
"command": "notebook:clear-all-cell-outputs",
"selector": ".jp-Notebook",
"rank": 0
"rank": 13
},
{
"type": "separator",
"selector": ".jp-Notebook",
"rank": 1
"rank": 20
},
{
"command": "notebook:enable-output-scrolling",
"selector": ".jp-Notebook",
"rank": 2
"rank": 21
},
{
"command": "notebook:disable-output-scrolling",
"selector": ".jp-Notebook",
"rank": 3
"rank": 22
},
{
"type": "separator",
"selector": ".jp-Notebook",
"rank": 4
"rank": 30
},
{
"command": "notebook:undo-cell-action",
"selector": ".jp-Notebook",
"rank": 5
"rank": 31
},
{
"command": "notebook:redo-cell-action",
"selector": ".jp-Notebook",
"rank": 6
"rank": 32
},
{
"command": "notebook:restart-kernel",
"selector": ".jp-Notebook",
"rank": 7
"rank": 33
},
{
"type": "separator",
"selector": ".jp-Notebook",
"rank": 8
"rank": 40
},
{
"command": "notebook:create-console",
"selector": ".jp-Notebook",
"rank": 9
"rank": 41
},
{
"command": "notebook:create-new",
"selector": ".jp-DirListing-content",
"rank": 52,
"args": {
"isContextMenu": true
}
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion packages/notebook-extension/src/index.ts
Expand Up @@ -1439,7 +1439,7 @@ function activateNotebookHandler(
''
);
}
if (args['isPalette']) {
if (args['isPalette'] || args['isContextMenu']) {
return trans.__('New Notebook');
}
return trans.__('Notebook');
Expand Down
8 changes: 8 additions & 0 deletions packages/toc-extension/schema/plugin.json
Expand Up @@ -3,6 +3,14 @@
"jupyter.lab.setting-icon-label": "Table of Contents",
"title": "Table of Contents",
"description": "Table of contents settings.",
"jupyter.lab.menus": {
"context": [
{
"command": "toc:run-cells",
"selector": ".jp-tocItem"
}
]
},
"properties": {
"numberingH1": {
"title": "Enable h1 numbering",
Expand Down
5 changes: 0 additions & 5 deletions packages/toc-extension/src/index.ts
Expand Up @@ -129,11 +129,6 @@ async function activateTOC(
label: trans.__('Run Cell(s)')
});

app.contextMenu.addItem({
selector: '.jp-tocItem',
command: CommandIDs.runCells
});

if (restorer) {
// Add the ToC widget to the application restorer:
restorer.add(toc, '@jupyterlab/toc:plugin');
Expand Down