提交 2c5cae38 编写于 作者: R Rob Lourens

Add "insert cell" submenu

上级 fe4d4f7d
......@@ -120,6 +120,7 @@ export class MenuId {
static readonly CommentTitle = new MenuId('CommentTitle');
static readonly CommentActions = new MenuId('CommentActions');
static readonly NotebookCellTitle = new MenuId('NotebookCellTitle');
static readonly NotebookCellInsert = new MenuId('NotebookCellInsert');
static readonly NotebookCellBetween = new MenuId('NotebookCellBetween');
static readonly BulkEditTitle = new MenuId('BulkEditTitle');
static readonly BulkEditContext = new MenuId('BulkEditContext');
......
......@@ -89,6 +89,13 @@ const enum CellToolbarOrder {
DeleteCell
}
const enum CellOverflowToolbarGroups {
Copy = '1_copy',
Insert = '2_insert',
Edit = '3_edit',
Collapse = '4_collapse',
}
export interface INotebookActionContext {
readonly cellTemplate?: BaseCellRenderTemplate;
readonly cell?: ICellViewModel;
......@@ -373,6 +380,12 @@ registerAction2(class extends NotebookAction {
}
});
MenuRegistry.appendMenuItem(MenuId.NotebookCellTitle, {
submenu: MenuId.NotebookCellInsert,
title: localize('notebookMenu.insertCell', "Insert Cell"),
group: CellOverflowToolbarGroups.Insert
});
MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
command: {
id: EXECUTE_NOTEBOOK_COMMAND_ID,
......@@ -409,7 +422,7 @@ registerAction2(class extends NotebookCellAction {
menu: {
id: MenuId.NotebookCellTitle,
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CELL_EDITABLE, NOTEBOOK_CELL_TYPE.isEqualTo('markdown')),
group: '2_edit',
group: CellOverflowToolbarGroups.Edit,
}
});
}
......@@ -433,7 +446,7 @@ registerAction2(class extends NotebookCellAction {
menu: {
id: MenuId.NotebookCellTitle,
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CELL_EDITABLE, NOTEBOOK_CELL_TYPE.isEqualTo('code')),
group: '2_edit',
group: CellOverflowToolbarGroups.Edit,
}
});
}
......@@ -526,6 +539,10 @@ registerAction2(class extends InsertCellCommand {
when: ContextKeyExpr.and(NOTEBOOK_CELL_LIST_FOCUSED, InputFocusedContext.toNegated()),
weight: KeybindingWeight.WorkbenchContrib
},
menu: {
id: MenuId.NotebookCellInsert,
order: 0
}
},
CellKind.Code,
'above');
......@@ -543,6 +560,10 @@ registerAction2(class extends InsertCellCommand {
when: ContextKeyExpr.and(NOTEBOOK_CELL_LIST_FOCUSED, InputFocusedContext.toNegated()),
weight: KeybindingWeight.WorkbenchContrib
},
menu: {
id: MenuId.NotebookCellInsert,
order: 1
}
},
CellKind.Code,
'below');
......@@ -565,6 +586,10 @@ registerAction2(class extends InsertCellCommand {
{
id: INSERT_MARKDOWN_CELL_ABOVE_COMMAND_ID,
title: localize('notebookActions.insertMarkdownCellAbove', "Insert Markdown Cell Above"),
menu: {
id: MenuId.NotebookCellInsert,
order: 2
}
},
CellKind.Markdown,
'above');
......@@ -577,6 +602,10 @@ registerAction2(class extends InsertCellCommand {
{
id: INSERT_MARKDOWN_CELL_BELOW_COMMAND_ID,
title: localize('notebookActions.insertMarkdownCellBelow', "Insert Markdown Cell Below"),
menu: {
id: MenuId.NotebookCellInsert,
order: 3
}
},
CellKind.Markdown,
'below');
......@@ -766,7 +795,7 @@ registerAction2(class extends NotebookCellAction {
menu: {
id: MenuId.NotebookCellTitle,
when: NOTEBOOK_EDITOR_FOCUSED,
group: '1_copy',
group: CellOverflowToolbarGroups.Copy,
}
});
}
......@@ -788,7 +817,7 @@ registerAction2(class extends NotebookCellAction {
menu: {
id: MenuId.NotebookCellTitle,
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CELL_EDITABLE),
group: '1_copy',
group: CellOverflowToolbarGroups.Copy,
}
});
}
......@@ -817,7 +846,7 @@ registerAction2(class extends NotebookAction {
menu: {
id: MenuId.NotebookCellTitle,
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE),
group: '1_copy',
group: CellOverflowToolbarGroups.Copy,
}
});
}
......@@ -1375,7 +1404,7 @@ registerAction2(class extends NotebookCellAction {
menu: {
id: MenuId.NotebookCellTitle,
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CELL_EDITABLE),
group: '2_edit',
group: CellOverflowToolbarGroups.Edit,
}
});
}
......@@ -1419,7 +1448,7 @@ registerAction2(class extends NotebookCellAction {
menu: {
id: MenuId.NotebookCellTitle,
when: ContextKeyExpr.and(NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_INPUT_COLLAPSED.toNegated()),
group: '3_collapse',
group: CellOverflowToolbarGroups.Collapse,
}
});
}
......@@ -1442,7 +1471,7 @@ registerAction2(class extends NotebookCellAction {
menu: {
id: MenuId.NotebookCellTitle,
when: ContextKeyExpr.and(NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_INPUT_COLLAPSED),
group: '3_collapse',
group: CellOverflowToolbarGroups.Collapse,
}
});
}
......@@ -1465,7 +1494,7 @@ registerAction2(class extends NotebookCellAction {
menu: {
id: MenuId.NotebookCellTitle,
when: ContextKeyExpr.and(NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_OUTPUT_COLLAPSED.toNegated(), NOTEBOOK_CELL_HAS_OUTPUTS),
group: '3_collapse',
group: CellOverflowToolbarGroups.Collapse,
}
});
}
......@@ -1488,7 +1517,7 @@ registerAction2(class extends NotebookCellAction {
menu: {
id: MenuId.NotebookCellTitle,
when: ContextKeyExpr.and(NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_OUTPUT_COLLAPSED),
group: '3_collapse',
group: CellOverflowToolbarGroups.Collapse,
}
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册