mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
More ways to render markdown cells - when cell/notebook is executed, and new action to force it
This commit is contained in:
@@ -33,6 +33,7 @@ const NOTEBOOK_UNDO = 'notebook.undo';
|
||||
const NOTEBOOK_CURSOR_UP = 'notebook.cursorUp';
|
||||
const NOTEBOOK_CURSOR_DOWN = 'notebook.cursorDown';
|
||||
const CLEAR_ALL_CELLS_OUTPUTS_COMMAND_ID = 'notebook.clearAllCellsOutputs';
|
||||
const RENDER_ALL_MARKDOWN_CELLS = 'notebook.renderAllMarkdownCells';
|
||||
|
||||
// Cell Commands
|
||||
const INSERT_CODE_CELL_ABOVE_COMMAND_ID = 'notebook.cell.insertCodeCellAbove';
|
||||
@@ -261,6 +262,22 @@ registerAction2(class extends NotebookAction {
|
||||
}
|
||||
});
|
||||
|
||||
registerAction2(class extends NotebookAction {
|
||||
constructor() {
|
||||
super({
|
||||
id: RENDER_ALL_MARKDOWN_CELLS,
|
||||
title: localize('notebookActions.renderMarkdown', "Render All Markdown Cells"),
|
||||
category: NOTEBOOK_ACTIONS_CATEGORY,
|
||||
precondition: NOTEBOOK_IS_ACTIVE_EDITOR,
|
||||
f1: true
|
||||
});
|
||||
}
|
||||
|
||||
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
|
||||
renderAllMarkdownCells(context);
|
||||
}
|
||||
});
|
||||
|
||||
registerAction2(class extends NotebookAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -273,10 +290,19 @@ registerAction2(class extends NotebookAction {
|
||||
}
|
||||
|
||||
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
|
||||
renderAllMarkdownCells(context);
|
||||
return context.notebookEditor.executeNotebook();
|
||||
}
|
||||
});
|
||||
|
||||
function renderAllMarkdownCells(context: INotebookCellActionContext): void {
|
||||
context.notebookEditor.viewModel!.viewCells.forEach(cell => {
|
||||
if (cell.cellKind === CellKind.Markdown) {
|
||||
cell.editState = CellEditState.Preview;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
registerAction2(class extends NotebookAction {
|
||||
constructor() {
|
||||
super({
|
||||
|
||||
@@ -1130,6 +1130,11 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
|
||||
}
|
||||
|
||||
async executeNotebookCell(cell: ICellViewModel): Promise<void> {
|
||||
if (cell.cellKind === CellKind.Markdown) {
|
||||
cell.editState = CellEditState.Preview;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cell.getEvaluatedMetadata(this.notebookViewModel!.metadata).runnable) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user