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

Add new file and new markdown file to file browser context menu #7483

Merged
merged 1 commit into from Nov 7, 2019
Merged
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
48 changes: 47 additions & 1 deletion packages/filebrowser-extension/src/index.ts
Expand Up @@ -87,6 +87,10 @@ namespace CommandIDs {

export const createNewDirectory = 'filebrowser:create-new-directory';

export const createNewFile = 'filebrowser:create-new-file';

export const createNewMarkdownFile = 'filebrowser:create-new-markdown-file';

export const rename = 'filebrowser:rename';

// For main browser only.
Expand Down Expand Up @@ -640,6 +644,36 @@ function addCommands(
label: 'New Folder'
});

commands.addCommand(CommandIDs.createNewFile, {
execute: () => {
const {
model: { path }
} = browser;
commands.execute('docmanager:new-untitled', {
path,
type: 'file',
ext: 'txt'
});
},
iconClass: 'jp-MaterialIcon jp-TextEditorIcon',
label: 'New File'
});

commands.addCommand(CommandIDs.createNewMarkdownFile, {
execute: () => {
const {
model: { path }
} = browser;
commands.execute('docmanager:new-untitled', {
path,
type: 'file',
ext: 'md'
});
},
iconClass: 'jp-MaterialIcon jp-MarkdownIcon',
label: 'New Markdown File'
});

commands.addCommand(CommandIDs.rename, {
execute: args => {
const widget = tracker.currentWidget;
Expand Down Expand Up @@ -842,11 +876,23 @@ function addCommands(
});

app.contextMenu.addItem({
command: CommandIDs.paste,
command: CommandIDs.createNewFile,
selector: selectorContent,
rank: 2
});

app.contextMenu.addItem({
command: CommandIDs.createNewMarkdownFile,
selector: selectorContent,
rank: 3
});

app.contextMenu.addItem({
command: CommandIDs.paste,
selector: selectorContent,
rank: 4
});

app.contextMenu.addItem({
command: CommandIDs.open,
selector: selectorItem,
Expand Down