parent
932f26f3c0
commit
e8acbb5f38
|
@ -45,7 +45,6 @@ const CHANGE_CELL_TO_MARKDOWN_COMMAND_ID = 'notebook.cell.changeToMarkdown';
|
|||
|
||||
const EDIT_CELL_COMMAND_ID = 'notebook.cell.edit';
|
||||
const QUIT_EDIT_CELL_COMMAND_ID = 'notebook.cell.quitEdit';
|
||||
const SAVE_CELL_COMMAND_ID = 'notebook.cell.save';
|
||||
const DELETE_CELL_COMMAND_ID = 'notebook.cell.delete';
|
||||
|
||||
const MOVE_CELL_UP_COMMAND_ID = 'notebook.cell.moveUp';
|
||||
|
@ -324,30 +323,6 @@ registerAction2(class extends NotebookAction {
|
|||
}
|
||||
});
|
||||
|
||||
registerAction2(class extends NotebookAction {
|
||||
constructor() {
|
||||
super({
|
||||
id: QUIT_EDIT_CELL_COMMAND_ID,
|
||||
title: localize('notebookActions.quitEditing', "Quit Notebook Cell Editing"),
|
||||
category: NOTEBOOK_ACTIONS_CATEGORY,
|
||||
keybinding: {
|
||||
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, InputFocusedContext, EditorContextKeys.hoverVisible.toNegated()),
|
||||
primary: KeyCode.Escape,
|
||||
weight: EDITOR_WIDGET_ACTION_WEIGHT - 5
|
||||
},
|
||||
precondition: NOTEBOOK_IS_ACTIVE_EDITOR,
|
||||
});
|
||||
}
|
||||
|
||||
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
|
||||
if (context.cell.cellKind === CellKind.Markdown) {
|
||||
context.cell.editState = CellEditState.Preview;
|
||||
}
|
||||
|
||||
await context.notebookEditor.focusNotebookCell(context.cell, 'container');
|
||||
}
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
|
||||
command: {
|
||||
id: EXECUTE_NOTEBOOK_COMMAND_ID,
|
||||
|
@ -626,7 +601,7 @@ registerAction2(class extends NotebookAction {
|
|||
}
|
||||
|
||||
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
|
||||
context.notebookEditor.editNotebookCell(context.cell);
|
||||
context.notebookEditor.focusNotebookCell(context.cell, 'editor');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -634,8 +609,8 @@ registerAction2(class extends NotebookAction {
|
|||
constructor() {
|
||||
super(
|
||||
{
|
||||
id: SAVE_CELL_COMMAND_ID,
|
||||
title: localize('notebookActions.saveCell', "Save Cell"),
|
||||
id: QUIT_EDIT_CELL_COMMAND_ID,
|
||||
title: localize('notebookActions.quitEdit', "Stop Editing Cell"),
|
||||
menu: {
|
||||
id: MenuId.NotebookCellTitle,
|
||||
when: ContextKeyExpr.and(
|
||||
|
@ -644,12 +619,24 @@ registerAction2(class extends NotebookAction {
|
|||
NOTEBOOK_CELL_EDITABLE),
|
||||
order: CellToolbarOrder.SaveCell
|
||||
},
|
||||
icon: { id: 'codicon/check' }
|
||||
icon: { id: 'codicon/check' },
|
||||
keybinding: {
|
||||
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, InputFocusedContext, EditorContextKeys.hoverVisible.toNegated()),
|
||||
primary: KeyCode.Escape,
|
||||
weight: EDITOR_WIDGET_ACTION_WEIGHT - 5
|
||||
},
|
||||
category: NOTEBOOK_ACTIONS_CATEGORY,
|
||||
precondition: NOTEBOOK_IS_ACTIVE_EDITOR,
|
||||
f1: true
|
||||
});
|
||||
}
|
||||
|
||||
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext) {
|
||||
return context.notebookEditor.saveNotebookCell(context.cell);
|
||||
if (context.cell.cellKind === CellKind.Markdown) {
|
||||
context.cell.editState = CellEditState.Preview;
|
||||
}
|
||||
|
||||
return context.notebookEditor.focusNotebookCell(context.cell, 'container');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -219,19 +219,6 @@ export interface INotebookEditor extends IEditor {
|
|||
*/
|
||||
moveCell(cell: ICellViewModel, relativeToCell: ICellViewModel, direction: 'above' | 'below'): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Switch the cell into editing mode.
|
||||
*
|
||||
* For code cell, the monaco editor will be focused.
|
||||
* For markdown cell, it will switch from preview mode to editing mode, which focuses the monaco editor.
|
||||
*/
|
||||
editNotebookCell(cell: ICellViewModel): void;
|
||||
|
||||
/**
|
||||
* Quit cell editing mode.
|
||||
*/
|
||||
saveNotebookCell(cell: ICellViewModel): void;
|
||||
|
||||
/**
|
||||
* Focus the container of a cell (the monaco editor inside is not focused).
|
||||
*/
|
||||
|
|
|
@ -1091,10 +1091,6 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
|
|||
this.renderedEditors.get(cell)?.focus();
|
||||
}
|
||||
|
||||
saveNotebookCell(cell: ICellViewModel): void {
|
||||
cell.editState = CellEditState.Preview;
|
||||
}
|
||||
|
||||
getActiveCell() {
|
||||
let elements = this.list?.getFocusedElements();
|
||||
|
||||
|
|
|
@ -184,12 +184,6 @@ export class TestNotebookEditor implements INotebookEditor {
|
|||
deleteNotebookCell(cell: CellViewModel): Promise<boolean> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
editNotebookCell(cell: CellViewModel): void {
|
||||
// throw new Error('Method not implemented.');
|
||||
}
|
||||
saveNotebookCell(cell: CellViewModel): void {
|
||||
// throw new Error('Method not implemented.');
|
||||
}
|
||||
focusNotebookCell(cell: CellViewModel, focusItem: 'editor' | 'container' | 'output'): void {
|
||||
// throw new Error('Method not implemented.');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue