mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-17 12:39:54 +08:00
Duplicate notebook menu option (#7374)
* WIP: Create new application:duplicate command, add to menu * WIP: Duplicate a file, then open the new file. * Polish * Removes null check for variable not typed to be null * Removes unneeded import, type declaration * Simplifies comments * Update Playwright Snapshots * Update Playwright Snapshots --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
30587b826a
commit
0a66f40c46
@ -10,6 +10,10 @@
|
||||
"command": "application:rename",
|
||||
"rank": 4.5
|
||||
},
|
||||
{
|
||||
"command": "application:duplicate",
|
||||
"rank": 4.8
|
||||
},
|
||||
{
|
||||
"command": "notebook:trust",
|
||||
"rank": 20
|
||||
|
@ -83,6 +83,11 @@ const JUPYTERLAB_DOCMANAGER_PLUGIN_ID =
|
||||
* The command IDs used by the application plugin.
|
||||
*/
|
||||
namespace CommandIDs {
|
||||
/**
|
||||
* Duplicate the current document and open the new document
|
||||
*/
|
||||
export const duplicate = 'application:duplicate';
|
||||
|
||||
/**
|
||||
* Handle local links
|
||||
*/
|
||||
@ -615,6 +620,20 @@ const title: JupyterFrontEndPlugin<void> = {
|
||||
return !!(currentWidget && docManager.contextForWidget(currentWidget));
|
||||
};
|
||||
|
||||
commands.addCommand(CommandIDs.duplicate, {
|
||||
label: () => trans.__('Duplicate'),
|
||||
isEnabled,
|
||||
execute: async () => {
|
||||
if (!isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Duplicate the file, and open the new file.
|
||||
const result = await docManager.duplicate(current.context.path);
|
||||
await commands.execute('docmanager:open', { path: result.path });
|
||||
},
|
||||
});
|
||||
|
||||
commands.addCommand(CommandIDs.rename, {
|
||||
label: () => trans.__('Rename…'),
|
||||
isEnabled,
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 8.2 KiB |
Loading…
Reference in New Issue
Block a user